Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix part of #3600: Add tablet UI for FAQs and Third-party Dependencies #3671

Merged
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
1c7f2a1
Create ThirdPartyActivity
prayutsu Jul 18, 2021
41d01d2
Fix lints
prayutsu Jul 18, 2021
ced7633
Fix actionbar issue
prayutsu Jul 18, 2021
c76e1cb
Add tests
prayutsu Jul 18, 2021
b4b7869
Add KDocs
prayutsu Jul 19, 2021
6b7c417
Add LicenseListActivity to Manifest
prayutsu Jul 23, 2021
f2893aa
Fix LicenseListFragment
prayutsu Jul 23, 2021
cdd569c
Merge branch 'develop' of github.com:oppia/oppia-android into display…
prayutsu Jul 23, 2021
8869156
Add test cases
prayutsu Jul 23, 2021
46d71f9
Add LicenseTextViewerFragment
prayutsu Jul 23, 2021
2414c77
Pass index to LicenseListFragment
prayutsu Jul 23, 2021
91dbd1d
Fix all the bugs
prayutsu Jul 24, 2021
5dc5e8d
Fix lints
prayutsu Jul 24, 2021
ef6dfac
Add tests files for all activities and fragments
prayutsu Jul 24, 2021
05883aa
Fix lints
prayutsu Jul 24, 2021
b2b4134
Add viewModels to BUILD.bazel
prayutsu Jul 24, 2021
b420bce
Correct path of files in exemptions file
prayutsu Jul 24, 2021
f58b2d5
Add suggested changes
prayutsu Jul 25, 2021
6da89ef
Add suggested changes
prayutsu Jul 25, 2021
9243bae
Remove unused imports
prayutsu Jul 25, 2021
e2a473f
Correct styles in xml
prayutsu Jul 25, 2021
5c6d0df
Optimize layouts
prayutsu Jul 25, 2021
c4e0ca9
fix lints
prayutsu Jul 25, 2021
696dfae
Correct layout width
prayutsu Jul 25, 2021
86a3fdd
Add test cases for all files
prayutsu Jul 25, 2021
5724f53
Add an extra test case
prayutsu Jul 28, 2021
92bd873
Add more test cases
prayutsu Jul 28, 2021
e9cc0b7
revert changes in ktlint_lint_check.sh
prayutsu Jul 28, 2021
230689b
Add suggested changes
prayutsu Jul 28, 2021
f580b3b
Add marquee effect
prayutsu Jul 28, 2021
db07e95
Try setting text directly from fragment.
prayutsu Jul 28, 2021
7d8b1cf
Add code to preserve text format
prayutsu Jul 29, 2021
15abbd0
Add more test cases in LicenseTextViewerFragmentTest.kt
prayutsu Jul 29, 2021
597b4b9
Add label for LicenseTextViewerActivity
prayutsu Jul 30, 2021
bd5ff2e
Merge branch 'develop' of github.com:oppia/oppia-android into display…
prayutsu Jul 30, 2021
6ba640b
Merge branches 'display-dependencies-list' and 'develop' of github.co…
prayutsu Jul 30, 2021
3022255
Add suggested changes
prayutsu Aug 3, 2021
bd7a2de
Use direct import for isRoot()
prayutsu Aug 3, 2021
d60146f
Merge branch 'develop' of github.com:oppia/oppia-android into display…
prayutsu Aug 3, 2021
e97647d
Add KDocs for TestApplicationComponent in Test files
prayutsu Aug 3, 2021
f358d1a
Remove unused imports
prayutsu Aug 3, 2021
c9e622f
Correct imports order
prayutsu Aug 3, 2021
291882f
Fix Kdocs check
prayutsu Aug 3, 2021
017a105
Add suggested changes
prayutsu Aug 4, 2021
f05f22e
Add suggested changes
prayutsu Aug 4, 2021
670b3a5
Fix failing test cases
prayutsu Aug 4, 2021
65fdb1e
Add interfaces to load fragments
prayutsu Aug 5, 2021
2c9d67a
Remove extra Kdocs and add test files to Kdoc exemptions
prayutsu Aug 5, 2021
827b7f7
Add suggested changes
prayutsu Aug 5, 2021
80766c0
Replace original dependencies name with dummy text
prayutsu Aug 6, 2021
d37d8ec
Update with develop
prayutsu Aug 6, 2021
fb4bef5
Merge branch 'display-dependencies-list' of github.com:oppia/oppia-an…
prayutsu Aug 8, 2021
8117008
create helplist item viewmodel
prayutsu Aug 9, 2021
df2f309
Merge branch 'develop' of github.com:oppia/oppia-android into hifi-ta…
prayutsu Aug 9, 2021
36f31b9
Merge branch 'develop' of github.com:oppia/oppia-android into hifi-ta…
prayutsu Aug 11, 2021
7b80809
Add support for new UIs for FAQList and ThirdPartyDependencyList in t…
prayutsu Aug 12, 2021
50cf5f4
Merge branch 'develop' of github.com:oppia/oppia-android into add-tab…
prayutsu Aug 12, 2021
9d3c967
Delete unwanted files
prayutsu Aug 12, 2021
b18716a
Fix nits
prayutsu Aug 12, 2021
b75409b
Add Listeners and ViewModels to BUILD.bazel
prayutsu Aug 12, 2021
7b0fc82
Add test cases and add test exemptions
prayutsu Aug 12, 2021
6abbd14
Correct Bug
prayutsu Aug 12, 2021
22fdff9
Correct import
prayutsu Aug 12, 2021
a98d05b
Fix crashing after clicking item
prayutsu Aug 12, 2021
282b9b1
Add suggested changes
prayutsu Aug 13, 2021
89d340a
Correct test case
prayutsu Aug 13, 2021
de8c999
Hide Back arrow by default
prayutsu Aug 13, 2021
a91b50c
Correct test case
prayutsu Aug 13, 2021
ee52e66
Add TAG suffix to fragment tags
prayutsu Aug 14, 2021
0ae413f
Add suggested changes
prayutsu Aug 16, 2021
c7d9b1c
Add minHeight
prayutsu Aug 16, 2021
a6a8d55
Add suggested changes
prayutsu Aug 17, 2021
7a2269d
Add punctuation in KDoc
prayutsu Aug 17, 2021
be8512e
Correct name in test_file_exemptions.textproto
prayutsu Aug 17, 2021
38c1289
Merge branch 'develop' of github.com:oppia/oppia-android into add-tab…
prayutsu Aug 17, 2021
f4f5b41
Merge branch 'develop' of github.com:oppia/oppia-android into add-tab…
prayutsu Aug 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ LISTENERS = [
"src/main/java/org/oppia/android/app/devoptions/RouteToMarkTopicsCompletedListener.kt",
"src/main/java/org/oppia/android/app/devoptions/RouteToViewEventLogsListener.kt",
"src/main/java/org/oppia/android/app/drawer/RouteToProfileProgressListener.kt",
"src/main/java/org/oppia/android/app/help/LoadFAQListFragmentListener.kt",
"src/main/java/org/oppia/android/app/help/LoadThirdPartyDependencyListFragmentListener.kt",
"src/main/java/org/oppia/android/app/help/RouteToFAQListListener.kt",
"src/main/java/org/oppia/android/app/help/RouteToThirdPartyDependencyListListener.kt",
"src/main/java/org/oppia/android/app/help/faq/RouteToFAQSingleListener.kt",
Expand Down Expand Up @@ -138,6 +140,7 @@ DATABINDING_LAYOUTS = ["src/main/res/layout*/**"]
VIEW_MODELS_WITH_RESOURCE_IMPORTS = [
"src/main/java/org/oppia/android/app/help/HelpItemViewModel.kt",
"src/main/java/org/oppia/android/app/help/HelpListViewModel.kt",
"src/main/java/org/oppia/android/app/help/HelpViewModel.kt",
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
"src/main/java/org/oppia/android/app/help/faq/FAQListViewModel.kt",
"src/main/java/org/oppia/android/app/help/thirdparty/LicenseListViewModel.kt",
"src/main/java/org/oppia/android/app/help/thirdparty/LicenseTextViewModel.kt",
Expand Down
73 changes: 71 additions & 2 deletions app/src/main/java/org/oppia/android/app/help/HelpActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,56 @@ package org.oppia.android.app.help
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.widget.TextView
import org.oppia.android.R
import org.oppia.android.app.activity.InjectableAppCompatActivity
import org.oppia.android.app.drawer.NAVIGATION_PROFILE_ID_ARGUMENT_KEY
import org.oppia.android.app.help.faq.FAQListActivity
import org.oppia.android.app.help.faq.RouteToFAQSingleListener
import org.oppia.android.app.help.faq.faqsingle.FAQSingleActivity
import org.oppia.android.app.help.thirdparty.LicenseListActivity
import org.oppia.android.app.help.thirdparty.LicenseTextViewerActivity
import org.oppia.android.app.help.thirdparty.RouteToLicenseListListener
import org.oppia.android.app.help.thirdparty.RouteToLicenseTextListener
import org.oppia.android.app.help.thirdparty.ThirdPartyDependencyListActivity
import javax.inject.Inject

private const val HELP_OPTIONS_TITLE_SAVED_KEY = "HelpActivity.help_options_title"
private const val SELECTED_FRAGMENT_SAVED_KEY = "HelpActivity.selected_fragment"
const val FAQ_LIST_FRAGMENT_TAG = "FAQListFragment.tag"
const val THIRD_PARTY_DEPENDENCY_LIST_FRAGMENT_TAG = "ThirdPartyDependencyListFragment.tag"

/** The help page activity for FAQs and third-party dependencies. */
class HelpActivity :
InjectableAppCompatActivity(),
RouteToFAQListListener,
RouteToThirdPartyDependencyListListener {
RouteToFAQSingleListener,
RouteToThirdPartyDependencyListListener,
RouteToLicenseTextListener,
RouteToLicenseListListener,
LoadFAQListFragmentListener,
LoadThirdPartyDependencyListFragmentListener {

@Inject
lateinit var helpActivityPresenter: HelpActivityPresenter

private lateinit var selectedFragment: String

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityComponent.inject(this)
val isFromNavigationDrawer = intent.getBooleanExtra(
BOOL_IS_FROM_NAVIGATION_DRAWER_EXTRA_KEY,
/* defaultValue= */ false
)
helpActivityPresenter.handleOnCreate(isFromNavigationDrawer)
selectedFragment =
savedInstanceState?.getString(SELECTED_FRAGMENT_SAVED_KEY) ?: FAQ_LIST_FRAGMENT_TAG
val extraHelpOptionsTitle = savedInstanceState?.getString(HELP_OPTIONS_TITLE_SAVED_KEY)
helpActivityPresenter.handleOnCreate(
extraHelpOptionsTitle,
isFromNavigationDrawer,
selectedFragment
)
title = getString(R.string.menu_help)
}

Expand Down Expand Up @@ -56,4 +82,47 @@ class HelpActivity :
val intent = ThirdPartyDependencyListActivity.createThirdPartyDependencyListActivityIntent(this)
startActivity(intent)
}

override fun loadFAQListFragment() {
selectedFragment = FAQ_LIST_FRAGMENT_TAG
helpActivityPresenter.handleLoadFAQListFragment()
}

override fun loadThirdPartyDependencyListFragment() {
selectedFragment = THIRD_PARTY_DEPENDENCY_LIST_FRAGMENT_TAG
helpActivityPresenter.handleLoadThirdPartyDependencyListFragment()
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
val titleTextView = findViewById<TextView>(R.id.help_multipane_options_title_textview)
if (titleTextView != null) {
outState.putString(HELP_OPTIONS_TITLE_SAVED_KEY, titleTextView.text.toString())
}
outState.putString(SELECTED_FRAGMENT_SAVED_KEY, selectedFragment)
}

override fun onRouteToLicenseText(dependencyIndex: Int, licenseIndex: Int) {
startActivity(
LicenseTextViewerActivity.createLicenseTextViewerActivityIntent(
this,
dependencyIndex,
licenseIndex
)
)
}

override fun onRouteToLicenseList(dependencyIndex: Int) {
startActivity(
LicenseListActivity
.createLicenseListActivityIntent(
context = this,
dependencyIndex = dependencyIndex
)
)
}

override fun onRouteToFAQSingle(question: String, answer: String) {
startActivity(FAQSingleActivity.createFAQSingleActivityIntent(this, question, answer))
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package org.oppia.android.app.help

import android.view.View
import android.widget.FrameLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.drawerlayout.widget.DrawerLayout
import androidx.fragment.app.Fragment
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityScope
import org.oppia.android.app.drawer.NavigationDrawerFragment
import org.oppia.android.app.help.faq.FAQListFragment
import org.oppia.android.app.help.thirdparty.ThirdPartyDependencyListFragment
import javax.inject.Inject

/** The presenter for [HelpActivity]. */
Expand All @@ -15,7 +20,11 @@ class HelpActivityPresenter @Inject constructor(private val activity: AppCompatA
private lateinit var navigationDrawerFragment: NavigationDrawerFragment
private lateinit var toolbar: Toolbar

fun handleOnCreate(isFromNavigationDrawer: Boolean) {
fun handleOnCreate(
extraHelpOptionsTitle: String?,
isFromNavigationDrawer: Boolean,
selectedFragment: String
) {
if (isFromNavigationDrawer) {
activity.setContentView(R.layout.help_activity)
setUpToolbar()
Expand All @@ -28,12 +37,53 @@ class HelpActivityPresenter @Inject constructor(private val activity: AppCompatA
activity.finish()
}
}
if (getHelpFragment() == null) {
activity.supportFragmentManager.beginTransaction().add(
R.id.help_fragment_placeholder,
HelpFragment()
).commitNow()
val titleTextView =
activity.findViewById<TextView>(R.id.options_activity_selected_options_title)
if (titleTextView != null) {
setMultipaneContainerTitle(extraHelpOptionsTitle!!)
}
val isMultipane = activity.findViewById<FrameLayout>(R.id.multipane_options_container) != null
if (isMultipane) {
loadMultipaneFragment(selectedFragment)
}
val previousFragment = getHelpFragment()
if (previousFragment != null) {
activity.supportFragmentManager.beginTransaction().remove(previousFragment).commitNow()
}
activity.supportFragmentManager.beginTransaction().add(
R.id.help_fragment_placeholder,
HelpFragment.newInstance(isMultipane)
).commitNow()
}

/** Loads [ThirdPartyDependencyListFragment] in tablet devices. */
fun handleLoadThirdPartyDependencyListFragment() {
setMultipaneContainerTitle(
activity.getString(R.string.third_party_dependency_list_activity_title)
)
getMultipaneOptionsFragment()?.let {
activity.supportFragmentManager.beginTransaction().remove(
it
).commit()
}
val thirdPartyDependencyListFragment = ThirdPartyDependencyListFragment.newInstance()
activity.supportFragmentManager.beginTransaction().add(
R.id.multipane_options_container,
thirdPartyDependencyListFragment
).commitNow()
}

/** Loads [FAQListFragment] in tablet devices. */
fun handleLoadFAQListFragment() {
setMultipaneContainerTitle(activity.getString(R.string.faq_activity_title))
getMultipaneOptionsFragment()?.let {
activity.supportFragmentManager.beginTransaction().remove(it)
.commit()
}
activity.supportFragmentManager.beginTransaction().add(
R.id.multipane_options_container,
FAQListFragment()
).commitNow()
}

private fun setUpToolbar() {
Expand All @@ -59,4 +109,19 @@ class HelpActivityPresenter @Inject constructor(private val activity: AppCompatA
.supportFragmentManager
.findFragmentById(R.id.help_fragment_placeholder) as HelpFragment?
}

private fun loadMultipaneFragment(selectedFragment: String) {
when (selectedFragment) {
FAQ_LIST_FRAGMENT_TAG -> handleLoadFAQListFragment()
THIRD_PARTY_DEPENDENCY_LIST_FRAGMENT_TAG -> handleLoadThirdPartyDependencyListFragment()
}
}

private fun setMultipaneContainerTitle(title: String) {
activity.findViewById<TextView>(R.id.help_multipane_options_title_textview).text = title
}

private fun getMultipaneOptionsFragment(): Fragment? {
return activity.supportFragmentManager.findFragmentById(R.id.multipane_options_container)
}
}
19 changes: 18 additions & 1 deletion app/src/main/java/org/oppia/android/app/help/HelpFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,24 @@ import android.view.ViewGroup
import org.oppia.android.app.fragment.InjectableFragment
import javax.inject.Inject

private const val IS_MULTIPANE_KEY = "HelpFragment.bool_is_multipane"

/** Fragment that contains help in the app. */
class HelpFragment : InjectableFragment() {
@Inject
lateinit var helpFragmentPresenter: HelpFragmentPresenter

companion object {
/** Returns instance of [HelpFragment]. */
fun newInstance(isMultipane: Boolean): HelpFragment {
val args = Bundle()
args.putBoolean(IS_MULTIPANE_KEY, isMultipane)
val fragment = HelpFragment()
fragment.arguments = args
return fragment
}
}

override fun onAttach(context: Context) {
super.onAttach(context)
fragmentComponent.inject(this)
Expand All @@ -23,6 +36,10 @@ class HelpFragment : InjectableFragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return helpFragmentPresenter.handleCreateView(inflater, container)
val args = checkNotNull(arguments) {
"Expected arguments to be passed to HelpFragment"
}
val isMultipane = args.getBoolean(IS_MULTIPANE_KEY)
return helpFragmentPresenter.handleCreateView(inflater, container, isMultipane)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ class HelpFragmentPresenter @Inject constructor(
) {
private lateinit var binding: HelpFragmentBinding

fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? {
fun handleCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
isMultipane: Boolean
): View? {
val viewModel = getHelpListViewModel()
viewModel.isMultipane.set(isMultipane)

binding = HelpFragmentBinding.inflate(
inflater,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,30 @@ import org.oppia.android.app.viewmodel.ObservableViewModel
/** [ObservableViewModel] for the recycler view of HelpActivity. */
class HelpItemViewModel(
val activity: AppCompatActivity,
val title: String
val title: String,
val isMultipane: Boolean
) : ObservableViewModel() {
fun onClick(title: String) {
when (title) {
activity.getString(R.string.frequently_asked_questions_FAQ) -> {
val routeToFAQListener = activity as RouteToFAQListListener
routeToFAQListener.onRouteToFAQList()
if (isMultipane) {
val loadFAQListFragmentListener = activity as LoadFAQListFragmentListener
loadFAQListFragmentListener.loadFAQListFragment()
} else {
val routeToFAQListener = activity as RouteToFAQListListener
routeToFAQListener.onRouteToFAQList()
}
}
activity.getString(R.string.third_party_dependency_list_activity_title) -> {
val routeToThirdPartyDependencyListListener = activity
as RouteToThirdPartyDependencyListListener
routeToThirdPartyDependencyListListener.onRouteToThirdPartyDependencyList()
if (isMultipane) {
val loadThirdPartyDependencyListFragmentListener = activity as
LoadThirdPartyDependencyListFragmentListener
loadThirdPartyDependencyListFragmentListener.loadThirdPartyDependencyListFragment()
} else {
val routeToThirdPartyDependencyListListener = activity
as RouteToThirdPartyDependencyListListener
routeToThirdPartyDependencyListListener.onRouteToThirdPartyDependencyList()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package org.oppia.android.app.help

import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.R
import org.oppia.android.app.viewmodel.ObservableViewModel
import javax.inject.Inject

/** View model in [HelpFragment]. */
class HelpListViewModel @Inject constructor(
val activity: AppCompatActivity
) : ObservableViewModel() {
) : HelpViewModel() {
private val arrayList = ArrayList<HelpItemViewModel>()

val helpItemList: List<HelpItemViewModel> by lazy {
Expand All @@ -22,11 +21,11 @@ class HelpListViewModel @Inject constructor(
when (item) {
HelpItems.FAQ -> {
category = activity.getString(R.string.frequently_asked_questions_FAQ)
helpItemViewModel = HelpItemViewModel(activity, category)
helpItemViewModel = HelpItemViewModel(activity, category, isMultipane.get()!!)
}
HelpItems.THIRD_PARTY -> {
category = activity.getString(R.string.third_party_dependency_list_activity_title)
helpItemViewModel = HelpItemViewModel(activity, category)
helpItemViewModel = HelpItemViewModel(activity, category, isMultipane.get()!!)
}
}
arrayList.add(helpItemViewModel)
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/org/oppia/android/app/help/HelpViewModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.oppia.android.app.help

import androidx.databinding.ObservableField
import org.oppia.android.app.viewmodel.ObservableViewModel

/** Option items view model for the recyclerView in [HelpFragment] */
abstract class HelpViewModel : ObservableViewModel() {
/** Determines whether the device in use has a large screen. */
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
val isMultipane = ObservableField<Boolean>(false)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.oppia.android.app.help

/** Listener for when a selection should result to [FAQListFragment] in tablet devices. */
interface LoadFAQListFragmentListener {
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
/** Starts [FAQListFragment] in tablet devices. */
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
fun loadFAQListFragment()
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.oppia.android.app.help

/**
* Listener for when a selection should result to [ThirdPartyDependencyListFragment] in tablet
* devices.
*/
interface LoadThirdPartyDependencyListFragmentListener {
/** Starts [ThirdPartyDependencyListFragment] in tablet devices. */
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
fun loadThirdPartyDependencyListFragment()
}
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/ic_arrow_back_black_24_dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:autoMirrored="true"
android:viewportHeight="24.0">
<path
android:fillColor="#333333"
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>
Loading