Skip to content

Commit

Permalink
Fix #3600: Add complete UI for tablet devices for copyright licenses …
Browse files Browse the repository at this point in the history
…lists and texts (#3680)

* Create ThirdPartyActivity

* Fix lints

* Fix actionbar issue

* Add tests

* Add KDocs

* Add LicenseListActivity to Manifest

* Fix LicenseListFragment

* Add test cases

* Add LicenseTextViewerFragment

* Pass index to LicenseListFragment

* Fix all the bugs

* Fix lints

* Add tests files for all activities and fragments

* Fix lints

* Add viewModels to BUILD.bazel

* Correct path of files in exemptions file

* Add suggested changes

* Add suggested changes

* Remove unused imports

* Correct styles in xml

* Optimize layouts

* fix lints

* Correct layout width

* Add test cases for all files

* Add an extra test case

* Add more test cases

* revert changes in ktlint_lint_check.sh

* Add suggested changes

* Add marquee effect

* Try setting text directly from fragment.

* Add code to preserve text format

* Add more test cases in LicenseTextViewerFragmentTest.kt

* Add label for LicenseTextViewerActivity

* Add suggested changes

* Use direct import for isRoot()

* Add KDocs for TestApplicationComponent in Test files

* Remove unused imports

* Correct imports order

* Fix Kdocs check

* Add suggested changes

* Add suggested changes

* Fix failing test cases

* Add interfaces to load fragments

* Remove extra Kdocs and add test files to Kdoc exemptions

* Add suggested changes

* Replace original dependencies name with dummy text

* create helplist item viewmodel

* Add support for new UIs for FAQList and ThirdPartyDependencyList in tablets

* Delete unwanted files

* Fix nits

* Add Listeners and ViewModels to BUILD.bazel

* Add test cases and add test exemptions

* Correct Bug

* Correct import

* Fix crashing after clicking item

* Add support for Displaying LicenseList and LicenseText in Split mode in tablet devices

* Add back button listener

* Remove extra methods

* Add suggested changes

* Correct test case

* Update branch

* Hide Back arrow by default

* Correct test case

* Add test exemptions

* Fix lints

* Add TODO

* Remove unwanted imports

* Add TAG suffix to fragment tags

* Fix handling of back button

* Delete Unwanted fields

* Make const names consistent.

* Fix lint

* Add white background in license_text_viewer_fragment.xml

* Add suggested changes

* Add content description for back button

* Fix bug

* Add test case

* Add minHeight

* Add all test cases

* Add suggested changes

* Add punctuation in KDoc

* Correct name in test_file_exemptions.textproto

* Undo unwanted changes

* Add suggested changes

* Add extra test case

* Add suggested changes

* Correct string id
  • Loading branch information
prayutsu authored Aug 19, 2021
1 parent d2372ae commit d219920
Show file tree
Hide file tree
Showing 22 changed files with 897 additions and 88 deletions.
4 changes: 3 additions & 1 deletion app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ LISTENERS = [
"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/LoadLicenseListFragmentListener.kt",
"src/main/java/org/oppia/android/app/help/LoadLicenseTextViewerFragmentListener.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",
Expand Down Expand Up @@ -142,6 +144,7 @@ VIEW_MODELS_WITH_RESOURCE_IMPORTS = [
"src/main/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeViewModel.kt",
"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",
"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 Expand Up @@ -205,7 +208,6 @@ VIEW_MODELS = [
"src/main/java/org/oppia/android/app/help/faq/faqItemViewModel/FAQHeaderViewModel.kt",
"src/main/java/org/oppia/android/app/help/faq/faqItemViewModel/FAQItemViewModel.kt",
"src/main/java/org/oppia/android/app/help/HelpItems.kt",
"src/main/java/org/oppia/android/app/help/HelpViewModel.kt",
"src/main/java/org/oppia/android/app/help/thirdparty/LicenseItemViewModel.kt",
"src/main/java/org/oppia/android/app/help/thirdparty/ThirdPartyDependencyItemViewModel.kt",
"src/main/java/org/oppia/android/app/hintsandsolution/HintsAndSolutionItemViewModel.kt",
Expand Down
69 changes: 31 additions & 38 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,40 +3,44 @@ 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
import kotlin.properties.Delegates

private const val HELP_OPTIONS_TITLE_SAVED_KEY = "HelpActivity.help_options_title"
private const val SELECTED_FRAGMENT_SAVED_KEY = "HelpActivity.selected_fragment"
const val HELP_OPTIONS_TITLE_SAVED_KEY = "HelpActivity.help_options_title"
const val SELECTED_FRAGMENT_SAVED_KEY = "HelpActivity.selected_fragment"
const val THIRD_PARTY_DEPENDENCY_INDEX_SAVED_KEY =
"HelpActivity.third_party_dependency_index"
const val LICENSE_INDEX_SAVED_KEY = "HelpActivity.license_index"
const val FAQ_LIST_FRAGMENT_TAG = "FAQListFragment.tag"
const val THIRD_PARTY_DEPENDENCY_LIST_FRAGMENT_TAG = "ThirdPartyDependencyListFragment.tag"
const val LICENSE_LIST_FRAGMENT_TAG = "LicenseListFragment.tag"
const val LICENSE_TEXT_FRAGMENT_TAG = "LicenseTextFragment.tag"

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

@Inject
lateinit var helpActivityPresenter: HelpActivityPresenter

private lateinit var selectedFragment: String
private lateinit var selectedHelpOptionsTitle: String
private var selectedDependencyIndex by Delegates.notNull<Int>()
private var selectedLicenseIndex by Delegates.notNull<Int>()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -47,11 +51,17 @@ class HelpActivity :
)
selectedFragment =
savedInstanceState?.getString(SELECTED_FRAGMENT_SAVED_KEY) ?: FAQ_LIST_FRAGMENT_TAG
val extraHelpOptionsTitle = savedInstanceState?.getString(HELP_OPTIONS_TITLE_SAVED_KEY)
selectedDependencyIndex =
savedInstanceState?.getInt(THIRD_PARTY_DEPENDENCY_INDEX_SAVED_KEY) ?: 0
selectedLicenseIndex = savedInstanceState?.getInt(LICENSE_INDEX_SAVED_KEY) ?: 0
selectedHelpOptionsTitle = savedInstanceState?.getString(HELP_OPTIONS_TITLE_SAVED_KEY)
?: getString(R.string.faq_activity_title)
helpActivityPresenter.handleOnCreate(
extraHelpOptionsTitle,
selectedHelpOptionsTitle,
isFromNavigationDrawer,
selectedFragment
selectedFragment,
selectedDependencyIndex,
selectedLicenseIndex
)
title = getString(R.string.menu_help)
}
Expand Down Expand Up @@ -84,44 +94,27 @@ class HelpActivity :
}

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 loadLicenseListFragment(dependencyIndex: Int) {
helpActivityPresenter.handleLoadLicenseListFragment(dependencyIndex)
}

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

override fun onRouteToLicenseList(dependencyIndex: Int) {
startActivity(
LicenseListActivity
.createLicenseListActivityIntent(
context = this,
dependencyIndex = dependencyIndex
)
)
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
helpActivityPresenter.handleOnSavedInstanceState(outState)
}

// TODO(#3681): Add support to display Single FAQ in split mode on tablet devices.
override fun onRouteToFAQSingle(question: String, answer: String) {
startActivity(FAQSingleActivity.createFAQSingleActivityIntent(this, question, answer))
}
Expand Down
Loading

0 comments on commit d219920

Please sign in to comment.