Skip to content

Commit

Permalink
Fix #1390: Show terms of service & privacy policy notices. (#3852)
Browse files Browse the repository at this point in the history
* fix  color and null checks

* added number formatter for numbered list

* Update LiTagHandler.kt

* Update CustomHtmlContentHandler.kt

* Update CustomHtmlContentHandler.kt

* added files to build.bazel

* Update test_file_exemptions.textproto

* fixed ci errors

* fix lints

* Add local for number formatter

* Update LiTagHandler.kt

* fix lint checks

* fix policy-type declaration failure

* Added number formatter

* Update MachineLocaleImpl.kt

* Update BUILD.bazel

* Trigger Build

* fix html build

* Update BUILD.bazel

* Update app/src/main/res/values/strings.xml

Co-authored-by: Ben Henning <[email protected]>

* Update utility/src/main/java/org/oppia/android/util/parser/html/PolicyType.kt

Co-authored-by: Ben Henning <[email protected]>

* Update utility/src/main/java/org/oppia/android/util/parser/html/PolicyType.kt

Co-authored-by: Ben Henning <[email protected]>

* fixed nits

* fixed html parser

* fixed bulletspan

* fixed lint

* fixed conflicts

* Update HtmlParserTest.kt

* fixed lint

* Update HtmlParser.kt

* Fixed ci failure for customContentHandler

* fixed lints

* Update BUILD.bazel

* Update BUILD.bazel

* Update BUILD.bazel

* Fixed taghandler error

* fixed listener dependencies

* Update ListItemLeadingMarginSpan.kt

* Update BUILD.bazel

* Fixed failing tests in utility

* fixed lint

* fix tests

* Update utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt

Co-authored-by: Ben Henning <[email protected]>

* Update arguments.proto

* fix number formatting

* Fixed bullet gap and failing tests

* Update MachineLocaleImplTest.kt

* fixed errors

* Update HtmlParserTest.kt

* Update HtmlParserTest.kt

* Add 2 create methods with and without loading image

* Update HtmlParserTest.kt

* add displaylocale to utility

* Update HtmlParserTest.kt

* fixed nits

* fix lint

* Update HtmlParserTest.kt

* Update LiTagHandler.kt

* Update MachineLocaleImpl.kt

* Update HtmlParserTest.kt

* added tests in bazel

* fixed locale in tests

* Update BUILD.bazel

* removed test from bazel

* fix bazel format

* Update AppLanguageResourceHandler.kt

* Update BUILD.bazel

* Update BUILD.bazel

* Update BUILD.bazel

* Update CODEOWNERS

* Delete BulletTagHandler.kt

* Update app/src/main/res/values/strings.xml

Co-authored-by: Ben Henning <[email protected]>

* Update app/src/main/java/org/oppia/android/app/translation/AppLanguageResourceHandler.kt

Co-authored-by: Ben Henning <[email protected]>

* moved strings file to utility

* fixed changes

* removed unused import

* Update MachineLocaleImplTest.kt

* fixed testcases

* Update PoliciesFragmentTest.kt

* Update file_content_validation_checks.textproto

* Update file_content_validation_checks.textproto

* Update BUILD.bazel

* fixed file validations errors

* Update BUILD.bazel

* Update BUILD.bazel

* Update BUILD.bazel

* Update BUILD.bazel

* removed test resources from domain

* Update BUILD.bazel

* Update DisplayLocaleImplTest.kt

* Update utility/src/main/java/org/oppia/android/util/parser/html/CustomHtmlContentHandler.kt

Co-authored-by: Ben Henning <[email protected]>

* Update utility/src/main/java/org/oppia/android/util/parser/html/LiTagHandler.kt

Co-authored-by: Ben Henning <[email protected]>

* Update utility/src/main/java/org/oppia/android/util/parser/html/ListItemLeadingMarginSpan.kt

Co-authored-by: Ben Henning <[email protected]>

* Update utility/src/main/java/org/oppia/android/util/parser/html/LiTagHandler.kt

Co-authored-by: Ben Henning <[email protected]>

* optimized code

* fixed errors in tests

* fixed tests

* fixed testcases

* fixed nit

* fixed nits

* Update CustomHtmlContentHandlerTest.kt

* Update Project.xml

* Update BUILD.bazel

* fixed testcases

* Update ListItemLeadingMarginSpan.kt

* Fixed create html parser create method

* fixed indentation

* Update ListItemLeadingMarginSpan.kt

* Update ListItemLeadingMarginSpanTest.kt

* Update LiTagHandlerTest.kt

* fixed issues

* removed list from custom tag handler

* fixed strings file

* Update CustomHtmlContentHandlerTest.kt

* fixed tests

* fixed lints

* Update DisplayLocaleImplTest.kt

* fixed gradle for test class

* fixed dependencies

* Update BUILD.bazel

* Update BUILD.bazel

* Update BUILD.bazel

* removed exception

* Update BUILD.bazel

* Working on tests.

* Update BUILD.bazel

* fixed tests

* remove unused code

* fixed Litaghandler tests

* Update LiTagHandler.kt

* Update ListItemLeadingMarginSpanTest.kt

* fixing build file

* Update BUILD.bazel

* Update BUILD.bazel

* Update BUILD.bazel

* Update BUILD.bazel

* fixing build file

* Update BUILD.bazel

* Update BUILD.bazel

* fix test resource path

* add test dependencies

* fix lint error

* Update DisplayLocaleImplTest.kt

* Update DisplayLocaleImplTest.kt

* commented unused code

* Update DisplayLocaleImplTest.kt

* Update BUILD.bazel

* Add utility dependency to test bazel

* Update DisplayLocaleImplTest.kt

* added locale in custom package

* fixing tests

* Update DisplayLocaleImplTest.kt

* Update DisplayLocaleImplTest.kt

* changed import to locale

* Remove R import

* Update app/src/sharedTest/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt

Co-authored-by: Ben Henning <[email protected]>

* fix bazel and span class

* Update app/src/sharedTest/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt

Co-authored-by: Ben Henning <[email protected]>

* fixed issues related to tests

* Update ListItemLeadingMarginSpanTest.kt

* Update ListItemLeadingMarginSpanTest.kt

* Update ListItemLeadingMarginSpanTest.kt

* compute x for RTL

* fixed nit

* Update LiTagHandler.kt

* Update LiTagHandler.kt

* Fixed lint errors

* Update LiTagHandler.kt

* Update ListItemLeadingMarginSpan.kt

* fixed extention method and tos and faq strings

* Update DisplayLocaleImpl.kt

* fixed rtl in html parser

* fixed lint errors

* Update PoliciesFragmentTest.kt

* fixed tests for rtl

* Update HtmlParserTest.kt

* Update HtmlParser.kt

* Update LiTagHandler.kt

* Update LiTagHandler.kt

* Update LiTagHandler.kt

* Update utility/src/main/java/org/oppia/android/util/locale/OppiaLocale.kt

Co-authored-by: Ben Henning <[email protected]>

* fixed nit

* Update LiTagHandler.kt

* Fixed canvas width in test

* Update ListItemLeadingMarginSpanTest.kt

* Update ListItemLeadingMarginSpanTest.kt

* Update ListItemLeadingMarginSpanTest.kt

* Update ListItemLeadingMarginSpanTest.kt

* Update ListItemLeadingMarginSpanTest.kt

Co-authored-by: Ben Henning <[email protected]>
  • Loading branch information
veena14cs and BenHenning authored Aug 26, 2022
1 parent 9131166 commit 1ca0a4a
Show file tree
Hide file tree
Showing 95 changed files with 5,125 additions and 756 deletions.
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ config/kitkat_main_dex_class_list.txt @BenHenning
# Global domain module code ownership.
/domain/**/*.kt @BenHenning

# Domain test resources.
/domain/src/test/res/values/strings.xml @BenHenning

# Questions support.
/domain/src/*/java/org/oppia/android/domain/question/ @BenHenning

Expand Down Expand Up @@ -181,6 +178,9 @@ config/kitkat_main_dex_class_list.txt @BenHenning
# Global utility module code ownership.
/utility/**/*.kt @BenHenning

# Utility test resources.
/utility/src/test/res/values/strings.xml @BenHenning

# Accessibility utilities.
/utility/src/*/java/org/oppia/android/util/accessibility/ @rt4914

Expand Down
6 changes: 5 additions & 1 deletion app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ LISTENERS = [
"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/LoadPoliciesFragmentListener.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 @@ -143,6 +144,7 @@ LISTENERS = [
"src/main/java/org/oppia/android/app/player/state/listener/RouteToHintsAndSolutionListener.kt",
"src/main/java/org/oppia/android/app/player/state/listener/StateKeyboardButtonListener.kt",
"src/main/java/org/oppia/android/app/player/state/listener/SubmitNavigationButtonListener.kt",
"src/main/java/org/oppia/android/app/policies/RouteToPoliciesListener.kt",
"src/main/java/org/oppia/android/app/profile/RouteToAdminPinListener.kt",
"src/main/java/org/oppia/android/app/profileprogress/ProfilePictureClickListener.kt",
"src/main/java/org/oppia/android/app/profileprogress/RouteToCompletedStoryListListener.kt",
Expand Down Expand Up @@ -603,6 +605,7 @@ kt_android_library(
deps = [
":dagger",
"//domain/src/main/java/org/oppia/android/domain/audio:cellular_audio_dialog_controller",
"//model/src/main/proto:arguments_java_proto_lite",
"//model/src/main/proto:question_java_proto_lite",
"//model/src/main/proto:topic_java_proto_lite",
"//third_party:androidx_recyclerview_recyclerview",
Expand Down Expand Up @@ -890,9 +893,10 @@ TEST_DEPS = [
"//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module",
"//utility/src/main/java/org/oppia/android/util/math:math_expression_parser",
"//utility/src/main/java/org/oppia/android/util/networking:debug_module",
"//utility/src/main/java/org/oppia/android/util/parser/html:custom_bullet_span",
"//utility/src/main/java/org/oppia/android/util/parser/html:html_parser",
"//utility/src/main/java/org/oppia/android/util/parser/html:html_parser_entity_type_module",
"//utility/src/main/java/org/oppia/android/util/parser/html:list_item_leading_margin_span",
"//utility/src/main/java/org/oppia/android/util/parser/html:policy_type",
"//utility/src/main/java/org/oppia/android/util/parser/image:glide_image_loader",
"//utility/src/main/java/org/oppia/android/util/parser/image:glide_image_loader_module",
"//utility/src/main/java/org/oppia/android/util/parser/image:image_parsing_module",
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,12 @@
<activity android:name=".app.testing.InputInteractionViewTestActivity" />
<activity android:name=".app.testing.ImageRegionSelectionTestActivity" />
<activity android:name=".app.testing.ImageViewBindingAdaptersTestActivity" />
<activity android:name=".app.testing.ListItemLeadingMarginSpanTestActivity" />
<activity android:name=".app.testing.MarginBindingAdaptersTestActivity" />
<activity
android:name=".app.testing.NavigationDrawerTestActivity"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity android:name=".app.testing.PoliciesFragmentTestActivity" />
<activity
android:name=".app.testing.ProfileChooserFragmentTestActivity"
android:theme="@style/OppiaThemeWithoutActionBar" />
Expand Down Expand Up @@ -276,6 +278,9 @@
<activity
android:name=".app.devoptions.forcenetworktype.testing.ForceNetworkTypeTestActivity"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity android:name=".app.policies.PoliciesActivity"
android:label="@string/policy_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.devoptions.mathexpressionparser.MathExpressionParserActivity"
android:label="@string/math_expression_parser_activity_title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import org.oppia.android.app.options.OptionsActivity
import org.oppia.android.app.options.ReadingTextSizeActivity
import org.oppia.android.app.player.exploration.ExplorationActivity
import org.oppia.android.app.player.state.testing.StateFragmentTestActivity
import org.oppia.android.app.policies.PoliciesActivity
import org.oppia.android.app.profile.AddProfileActivity
import org.oppia.android.app.profile.AdminAuthActivity
import org.oppia.android.app.profile.AdminPinActivity
Expand Down Expand Up @@ -66,8 +67,10 @@ import org.oppia.android.app.testing.HtmlParserTestActivity
import org.oppia.android.app.testing.ImageRegionSelectionTestActivity
import org.oppia.android.app.testing.ImageViewBindingAdaptersTestActivity
import org.oppia.android.app.testing.InputInteractionViewTestActivity
import org.oppia.android.app.testing.ListItemLeadingMarginSpanTestActivity
import org.oppia.android.app.testing.MarginBindingAdaptersTestActivity
import org.oppia.android.app.testing.NavigationDrawerTestActivity
import org.oppia.android.app.testing.PoliciesFragmentTestActivity
import org.oppia.android.app.testing.ProfileChooserFragmentTestActivity
import org.oppia.android.app.testing.ProfileEditFragmentTestActivity
import org.oppia.android.app.testing.SplashTestActivity
Expand Down Expand Up @@ -137,6 +140,7 @@ interface ActivityComponentImpl :
fun inject(inputInteractionViewTestActivity: InputInteractionViewTestActivity)
fun inject(licenseListActivity: LicenseListActivity)
fun inject(licenseTextViewerActivity: LicenseTextViewerActivity)
fun inject(listItemLeadingMarginSpanTestActivity: ListItemLeadingMarginSpanTestActivity)
fun inject(markChaptersCompletedActivity: MarkChaptersCompletedActivity)
fun inject(markChaptersCompletedTestActivity: MarkChaptersCompletedTestActivity)
fun inject(markStoriesCompletedActivity: MarkStoriesCompletedActivity)
Expand All @@ -151,6 +155,8 @@ interface ActivityComponentImpl :
fun inject(ongoingTopicListActivity: OngoingTopicListActivity)
fun inject(optionActivity: OptionsActivity)
fun inject(pinPasswordActivity: PinPasswordActivity)
fun inject(policiesActivity: PoliciesActivity)
fun inject(policiesFragmentTestActivity: PoliciesFragmentTestActivity)
fun inject(profileAndDeviceIdActivity: ProfileAndDeviceIdActivity)
fun inject(profileChooserActivity: ProfileChooserActivity)
fun inject(profileChooserFragmentTestActivity: ProfileChooserFragmentTestActivity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class MathExpressionParserViewModel @Inject constructor(
gcsResourceName = "",
entityType = "",
entityId = "",
imageCenterAlign = false
imageCenterAlign = false,
displayLocale = appLanguageResourceHandler.getDisplayLocale()
)
}
private lateinit var parseResultTextView: TextView
Expand Down Expand Up @@ -89,7 +90,10 @@ class MathExpressionParserViewModel @Inject constructor(
val newText = computeParseResult()
// Only parse HTML if there is HTML to preserve formatting.
parseResultTextView.text = if ("oppia-noninteractive-math" in newText) {
htmlParser.parseOppiaHtml(newText.replace("\n", "<br />"), parseResultTextView)
htmlParser.parseOppiaHtml(
newText.replace("\n", "<br />"),
parseResultTextView
)
} else newText
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import org.oppia.android.app.player.state.itemviewmodel.InteractionViewModelModu
import org.oppia.android.app.player.stopplaying.ProgressDatabaseFullDialogFragment
import org.oppia.android.app.player.stopplaying.StopExplorationDialogFragment
import org.oppia.android.app.player.stopplaying.UnsavedExplorationDialogFragment
import org.oppia.android.app.policies.PoliciesFragment
import org.oppia.android.app.profile.AdminSettingsDialogFragment
import org.oppia.android.app.profile.ProfileChooserFragment
import org.oppia.android.app.profile.ResetPinDialogFragment
Expand Down Expand Up @@ -135,6 +136,7 @@ interface FragmentComponentImpl : FragmentComponent, ViewComponentBuilderInjecto
fun inject(onboardingFragment: OnboardingFragment)
fun inject(ongoingTopicListFragment: OngoingTopicListFragment)
fun inject(optionFragment: OptionsFragment)
fun inject(policiesFragment: PoliciesFragment)
fun inject(profileAndDeviceIdFragment: ProfileAndDeviceIdFragment)
fun inject(profileChooserFragment: ProfileChooserFragment)
fun inject(profileEditDeletionDialogFragment: ProfileEditDeletionDialogFragment)
Expand Down
26 changes: 24 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 @@ -11,7 +11,12 @@ 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.ThirdPartyDependencyListActivity
import org.oppia.android.app.model.PoliciesActivityParams
import org.oppia.android.app.model.PolicyPage
import org.oppia.android.app.policies.PoliciesActivity
import org.oppia.android.app.policies.RouteToPoliciesListener
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.util.extensions.getProto
import org.oppia.android.util.extensions.getStringFromBundle
import javax.inject.Inject

Expand All @@ -21,17 +26,21 @@ 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 POLICIES_ARGUMENT_PROTO = "PoliciesActivity.policy_page"
const val POLICIES_FRAGMENT_TAG = "PoliciesFragment.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. */
/** The help page activity for FAQs, third-party dependencies and policies page. */
class HelpActivity :
InjectableAppCompatActivity(),
RouteToFAQListListener,
RouteToFAQSingleListener,
RouteToPoliciesListener,
RouteToThirdPartyDependencyListListener,
LoadFaqListFragmentListener,
LoadPoliciesFragmentListener,
LoadThirdPartyDependencyListFragmentListener,
LoadLicenseListFragmentListener,
LoadLicenseTextViewerFragmentListener {
Expand Down Expand Up @@ -59,12 +68,17 @@ class HelpActivity :
val selectedLicenseIndex = savedInstanceState?.getInt(LICENSE_INDEX_SAVED_KEY) ?: 0
selectedHelpOptionsTitle = savedInstanceState?.getStringFromBundle(HELP_OPTIONS_TITLE_SAVED_KEY)
?: resourceHandler.getStringInLocale(R.string.faq_activity_title)
val policiesActivityParams = savedInstanceState?.getProto(
POLICIES_ARGUMENT_PROTO,
PoliciesActivityParams.getDefaultInstance()
)
helpActivityPresenter.handleOnCreate(
selectedHelpOptionsTitle,
isFromNavigationDrawer,
selectedFragment,
selectedDependencyIndex,
selectedLicenseIndex
selectedLicenseIndex,
policiesActivityParams
)
title = resourceHandler.getStringInLocale(R.string.menu_help)
}
Expand Down Expand Up @@ -121,4 +135,12 @@ class HelpActivity :
override fun onRouteToFAQSingle(question: String, answer: String) {
startActivity(FAQSingleActivity.createFAQSingleActivityIntent(this, question, answer))
}

override fun onRouteToPolicies(policyPage: PolicyPage) {
startActivity(PoliciesActivity.createPoliciesActivityIntent(this, policyPage))
}

override fun loadPoliciesFragment(policyPage: PolicyPage) {
helpActivityPresenter.handleLoadPoliciesFragment(policyPage)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import org.oppia.android.app.help.faq.FAQListFragment
import org.oppia.android.app.help.thirdparty.LicenseListFragment
import org.oppia.android.app.help.thirdparty.LicenseTextViewerFragment
import org.oppia.android.app.help.thirdparty.ThirdPartyDependencyListFragment
import org.oppia.android.app.model.PoliciesActivityParams
import org.oppia.android.app.model.PoliciesFragmentArguments
import org.oppia.android.app.model.PolicyPage
import org.oppia.android.app.policies.PoliciesFragment
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.util.extensions.putProto
import javax.inject.Inject

/** The presenter for [HelpActivity]. */
Expand All @@ -32,18 +37,24 @@ class HelpActivityPresenter @Inject constructor(
private lateinit var selectedHelpOptionTitle: String
private var selectedDependencyIndex: Int? = null
private var selectedLicenseIndex: Int? = null
private var internalPolicyPage: PolicyPage = PolicyPage.POLICY_PAGE_UNSPECIFIED

fun handleOnCreate(
helpOptionsTitle: String,
isFromNavigationDrawer: Boolean,
selectedFragment: String,
dependencyIndex: Int,
licenseIndex: Int
licenseIndex: Int,
policiesActivityParams: PoliciesActivityParams?
) {
selectedFragmentTag = selectedFragment
selectedDependencyIndex = dependencyIndex
selectedLicenseIndex = licenseIndex
selectedHelpOptionTitle = helpOptionsTitle
if (policiesActivityParams != null) {
internalPolicyPage = policiesActivityParams.policyPage
}

if (isFromNavigationDrawer) {
activity.setContentView(R.layout.help_activity)
setUpToolbar()
Expand Down Expand Up @@ -141,6 +152,12 @@ class HelpActivityPresenter @Inject constructor(
outState.putString(SELECTED_FRAGMENT_SAVED_KEY, selectedFragmentTag)
selectedDependencyIndex?.let { outState.putInt(THIRD_PARTY_DEPENDENCY_INDEX_SAVED_KEY, it) }
selectedLicenseIndex?.let { outState.putInt(LICENSE_INDEX_SAVED_KEY, it) }
val policiesActivityParams =
PoliciesActivityParams
.newBuilder()
.setPolicyPage(internalPolicyPage)
.build()
outState.putProto(POLICIES_ARGUMENT_PROTO, policiesActivityParams)
}

private fun setUpToolbar() {
Expand Down Expand Up @@ -194,6 +211,7 @@ class HelpActivityPresenter @Inject constructor(
) {
when (selectedFragment) {
FAQ_LIST_FRAGMENT_TAG -> handleLoadFAQListFragment()
POLICIES_FRAGMENT_TAG -> handleLoadPoliciesFragment(internalPolicyPage)
THIRD_PARTY_DEPENDENCY_LIST_FRAGMENT_TAG -> handleLoadThirdPartyDependencyListFragment()
LICENSE_LIST_FRAGMENT_TAG -> handleLoadLicenseListFragment(dependencyIndex)
LICENSE_TEXT_FRAGMENT_TAG -> handleLoadLicenseTextViewerFragment(
Expand Down Expand Up @@ -296,4 +314,38 @@ class HelpActivityPresenter @Inject constructor(
private fun getMultipaneOptionsFragment(): Fragment? {
return activity.supportFragmentManager.findFragmentById(R.id.multipane_options_container)
}

fun handleLoadPoliciesFragment(policyPage: PolicyPage) {
internalPolicyPage = policyPage
selectPoliciesFragment(policyPage)

val policiesFragmentArguments =
PoliciesFragmentArguments
.newBuilder()
.setPolicyPage(policyPage)
.build()
val previousFragment = getMultipaneOptionsFragment()
if (previousFragment != null) {
activity.supportFragmentManager.beginTransaction().remove(previousFragment).commitNow()
}
activity.supportFragmentManager.beginTransaction().add(
R.id.multipane_options_container,
PoliciesFragment.newInstance(policiesFragmentArguments)
).commitNow()
}

private fun selectPoliciesFragment(policyPage: PolicyPage) {
when (policyPage) {
PolicyPage.PRIVACY_POLICY -> setMultipaneContainerTitle(
resourceHandler.getStringInLocale(R.string.privacy_policy_title)
)
PolicyPage.TERMS_OF_SERVICE -> setMultipaneContainerTitle(
resourceHandler.getStringInLocale(R.string.terms_of_service_title)
)
else -> { }
}
setMultipaneBackButtonVisibility(View.GONE)
selectedFragmentTag = POLICIES_FRAGMENT_TAG
selectedHelpOptionTitle = getMultipaneContainerTitle()
}
}
19 changes: 19 additions & 0 deletions app/src/main/java/org/oppia/android/app/help/HelpItemViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package org.oppia.android.app.help

import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.R
import org.oppia.android.app.model.PolicyPage
import org.oppia.android.app.policies.RouteToPoliciesListener
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.app.viewmodel.ObservableViewModel

Expand Down Expand Up @@ -34,6 +36,23 @@ class HelpItemViewModel(
routeToThirdPartyDependencyListListener.onRouteToThirdPartyDependencyList()
}
}
resourceHandler.getStringInLocale(R.string.privacy_policy_title) -> {
loadPolicyPage(PolicyPage.PRIVACY_POLICY)
}
resourceHandler.getStringInLocale(R.string.terms_of_service_title) -> {
loadPolicyPage(PolicyPage.TERMS_OF_SERVICE)
}
}
}

private fun loadPolicyPage(policyPage: PolicyPage) {
if (isMultipane) {
val loadPoliciesFragmentListener = activity as
LoadPoliciesFragmentListener
loadPoliciesFragmentListener.loadPoliciesFragment(policyPage)
} else {
val routeToPoliciesListener = activity as RouteToPoliciesListener
routeToPoliciesListener.onRouteToPolicies(policyPage)
}
}
}
6 changes: 5 additions & 1 deletion app/src/main/java/org/oppia/android/app/help/HelpItems.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ package org.oppia.android.app.help
/** Enum class containing the items for the Recycler view of [HelpActivity]. */
enum class HelpItems {
FAQ,
THIRD_PARTY;
THIRD_PARTY,
/** Corresponds to the Privacy Policy page. */
PRIVACY_POLICY,
/** Corresponds to the Terms of Service page. */
TERMS_OF_SERVICE
}
Loading

0 comments on commit 1ca0a4a

Please sign in to comment.