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 #5025: App and OS Deprecation Milestone 3 - Add New Deprecation Dialog Fragments #5096

Merged
merged 28 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
48440d6
When merged, this commit will;
Jul 19, 2023
61ea673
fix: Fix linting issues
Jul 19, 2023
cd5ea5e
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Aug 1, 2023
5cabe33
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Aug 8, 2023
9951c5a
fix: Fix testfile, Kdocs validation and string resource validation tests
kkmurerwa Aug 8, 2023
200d781
feat: Add test config for the three deprecation dialogs
kkmurerwa Aug 15, 2023
81a1519
test: Add tests for all newly added dialog fragments
kkmurerwa Aug 15, 2023
1494b47
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Aug 16, 2023
a643504
fix: Fix comments from the self-review.
kkmurerwa Aug 17, 2023
d40aaba
chore: Cleanup unused dependencies in the bazel file
kkmurerwa Aug 17, 2023
eada6c9
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Sep 7, 2023
b8747f7
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Sep 11, 2023
bfbe182
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Sep 12, 2023
84f5446
chore: Update logic flow on deprecation dialog close action and varia…
kkmurerwa Sep 12, 2023
885a53d
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Sep 13, 2023
2aa9443
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Sep 18, 2023
cc3fa50
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Sep 21, 2023
cec888a
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Sep 25, 2023
1139110
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Sep 28, 2023
e5fd786
chore: Reinstate the existing code before this feature
kkmurerwa Sep 28, 2023
305cd22
fix: Fix linting issues
kkmurerwa Sep 28, 2023
4c5d3b8
fix: Add missing swahili translation and fix failing kdoc check
kkmurerwa Sep 28, 2023
5ce1586
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Oct 9, 2023
b956930
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Oct 9, 2023
07cde7b
Merge branch 'develop' into app-and-os-deprecation-milestone-3
kkmurerwa Oct 17, 2023
bffbd4b
fix: Make minor changes on the code for consistency with the rest of …
kkmurerwa Oct 17, 2023
ba44ff6
fix: Fix linting issues
kkmurerwa Oct 17, 2023
ab5d21c
Merge branch 'develop' into app-and-os-deprecation-milestone-3
BenHenning Oct 24, 2023
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
12 changes: 12 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@
android:name=".app.notice.testing.GeneralAvailabilityUpgradeNoticeDialogFragmentTestActivity"
android:label="@string/test_activity_label"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.notice.testing.ForcedAppDeprecationNoticeDialogFragmentTestActivity"
android:label="@string/test_activity_label"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.notice.testing.OptionalAppDeprecationNoticeDialogFragmentTestActivity"
android:label="@string/test_activity_label"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.notice.testing.OsDeprecationNoticeDialogFragmentTestActivity"
android:label="@string/test_activity_label"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.onboarding.OnboardingActivity"
android:label="@string/onboarding_activity_title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ import org.oppia.android.app.mydownloads.MyDownloadsFragment
import org.oppia.android.app.mydownloads.UpdatesTabFragment
import org.oppia.android.app.notice.AutomaticAppDeprecationNoticeDialogFragment
import org.oppia.android.app.notice.BetaNoticeDialogFragment
import org.oppia.android.app.notice.ForcedAppDeprecationNoticeDialogFragment
import org.oppia.android.app.notice.GeneralAvailabilityUpgradeNoticeDialogFragment
import org.oppia.android.app.notice.OptionalAppDeprecationNoticeDialogFragment
import org.oppia.android.app.notice.OsDeprecationNoticeDialogFragment
import org.oppia.android.app.onboarding.OnboardingFragment
import org.oppia.android.app.ongoingtopiclist.OngoingTopicListFragment
import org.oppia.android.app.options.AppLanguageFragment
Expand Down Expand Up @@ -113,7 +116,10 @@ interface FragmentComponentImpl : FragmentComponent, ViewComponentBuilderInjecto
fun inject(appVersionFragment: AppVersionFragment)
fun inject(audioFragment: AudioFragment)
fun inject(audioLanguageFragment: AudioLanguageFragment)
fun inject(autoAppDeprecationNoticeDialogFragment: AutomaticAppDeprecationNoticeDialogFragment)
fun inject(
automaticAppDeprecationNoticeDialogFragment:
AutomaticAppDeprecationNoticeDialogFragment
)
fun inject(betaNoticeDialogFragment: BetaNoticeDialogFragment)
fun inject(cellularAudioDialogFragment: CellularAudioDialogFragment)
fun inject(completedStoryListFragment: CompletedStoryListFragment)
Expand All @@ -127,6 +133,7 @@ interface FragmentComponentImpl : FragmentComponent, ViewComponentBuilderInjecto
fun inject(explorationTestActivityTestFragment: ExplorationTestActivityPresenter.TestFragment)
fun inject(faqListFragment: FAQListFragment)
fun inject(forceNetworkTypeFragment: ForceNetworkTypeFragment)
fun inject(forcedAppDeprecationNoticeDialogFragment: ForcedAppDeprecationNoticeDialogFragment)
fun inject(fragment: GeneralAvailabilityUpgradeNoticeDialogFragment)
fun inject(helpFragment: HelpFragment)
fun inject(hintsAndSolutionDialogFragment: HintsAndSolutionDialogFragment)
Expand All @@ -146,7 +153,9 @@ interface FragmentComponentImpl : FragmentComponent, ViewComponentBuilderInjecto
fun inject(navigationDrawerFragment: NavigationDrawerFragment)
fun inject(onboardingFragment: OnboardingFragment)
fun inject(ongoingTopicListFragment: OngoingTopicListFragment)
fun inject(optionalAppDeprecationNoticeDialogFragment: OptionalAppDeprecationNoticeDialogFragment)
fun inject(optionFragment: OptionsFragment)
fun inject(osDeprecationNoticeDialogFragment: OsDeprecationNoticeDialogFragment)
fun inject(policiesFragment: PoliciesFragment)
fun inject(profileAndDeviceIdFragment: ProfileAndDeviceIdFragment)
fun inject(profileChooserFragment: ProfileChooserFragment)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.oppia.android.app.notice

import org.oppia.android.app.splash.DeprecationNoticeActionType

/** Listener for when an option on any deprecation dialog is clicked. */
interface DeprecationNoticeActionListener {
/** Called when a dialog button is clicked. */
fun onActionButtonClicked(noticeType: DeprecationNoticeActionType)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.oppia.android.app.notice

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import org.oppia.android.app.fragment.FragmentComponentImpl
import org.oppia.android.app.fragment.InjectableDialogFragment
import javax.inject.Inject

/** Dialog fragment that informs the user of an app deprecation. */
class ForcedAppDeprecationNoticeDialogFragment : InjectableDialogFragment() {
companion object {
/** Returns a new instance of [ForcedAppDeprecationNoticeDialogFragment]. */
fun newInstance(): ForcedAppDeprecationNoticeDialogFragment {
return ForcedAppDeprecationNoticeDialogFragment()
}
}

@Inject lateinit var presenter: ForcedAppDeprecationNoticeDialogFragmentPresenter

override fun onAttach(context: Context) {
super.onAttach(context)
(fragmentComponent as FragmentComponentImpl).inject(this)
}

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return presenter.handleOnCreateDialog()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.oppia.android.app.notice

import android.app.Dialog
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.R
import org.oppia.android.app.splash.DeprecationNoticeActionType
import org.oppia.android.app.translation.AppLanguageResourceHandler
import javax.inject.Inject

/** Presenter class responsible for showing an app deprecation dialog to the user. */
class ForcedAppDeprecationNoticeDialogFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val resourceHandler: AppLanguageResourceHandler
) {
private val deprecationNoticeActionListener by lazy {
activity as DeprecationNoticeActionListener
}

/** Handles dialog creation for the forced app deprecation notice. */
fun handleOnCreateDialog(): Dialog {
val appName = resourceHandler.getStringInLocale(R.string.app_name)

val dialog = AlertDialog.Builder(activity, R.style.DeprecationAlertDialogTheme)
.setTitle(R.string.forced_app_update_dialog_title)
.setMessage(
resourceHandler.getStringInLocaleWithWrapping(
R.string.forced_app_update_dialog_message,
appName
)
)
.setPositiveButton(R.string.forced_app_update_dialog_update_button_text) { _, _ ->
deprecationNoticeActionListener.onActionButtonClicked(
DeprecationNoticeActionType.UPDATE
)
}
.setNegativeButton(R.string.forced_app_update_dialog_close_button_text) { _, _ ->
deprecationNoticeActionListener.onActionButtonClicked(
DeprecationNoticeActionType.CLOSE
)
}
.setCancelable(false)
.create()
dialog.setCanceledOnTouchOutside(false)
return dialog
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.oppia.android.app.notice

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import org.oppia.android.app.fragment.FragmentComponentImpl
import org.oppia.android.app.fragment.InjectableDialogFragment
import javax.inject.Inject

/** Dialog fragment that informs the user that a new app version is available for download. */
class OptionalAppDeprecationNoticeDialogFragment : InjectableDialogFragment() {
companion object {
/** Returns a new instance of [OptionalAppDeprecationNoticeDialogFragment]. */
fun newInstance(): OptionalAppDeprecationNoticeDialogFragment {
return OptionalAppDeprecationNoticeDialogFragment()
}
}

@Inject lateinit var optionalAppDeprecationNoticeDialogFragmentPresenter:
OptionalAppDeprecationNoticeDialogFragmentPresenter

override fun onAttach(context: Context) {
super.onAttach(context)
(fragmentComponent as FragmentComponentImpl).inject(this)
}

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return optionalAppDeprecationNoticeDialogFragmentPresenter.handleOnCreateDialog()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.oppia.android.app.notice

import android.app.Dialog
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.R
import org.oppia.android.app.splash.DeprecationNoticeActionType
import org.oppia.android.app.translation.AppLanguageResourceHandler
import javax.inject.Inject

/** Presenter class responsible for showing an optional update dialog to the user. */
class OptionalAppDeprecationNoticeDialogFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val resourceHandler: AppLanguageResourceHandler
) {
private val deprecationNoticeActionListener by lazy {
activity as DeprecationNoticeActionListener
}

/** Handles dialog creation for the optional app deprecation notice. */
fun handleOnCreateDialog(): Dialog {
val appName = resourceHandler.getStringInLocale(R.string.app_name)

val dialog = AlertDialog.Builder(activity, R.style.DeprecationAlertDialogTheme)
.setTitle(R.string.optional_app_update_dialog_title)
.setMessage(
resourceHandler.getStringInLocaleWithWrapping(
R.string.optional_app_update_dialog_message,
appName
)
)
.setPositiveButton(R.string.optional_app_update_dialog_update_button_text) { _, _ ->
deprecationNoticeActionListener.onActionButtonClicked(
DeprecationNoticeActionType.UPDATE
)
}
.setNegativeButton(R.string.optional_app_update_dialog_dismiss_button_text) { _, _ ->
deprecationNoticeActionListener.onActionButtonClicked(
DeprecationNoticeActionType.DISMISS
)
}
.setCancelable(false)
.create()
dialog.setCanceledOnTouchOutside(false)
return dialog
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.oppia.android.app.notice

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import org.oppia.android.app.fragment.FragmentComponentImpl
import org.oppia.android.app.fragment.InjectableDialogFragment
import javax.inject.Inject

/**
* Dialog fragment that informs the user that their phone OS is no longer supported by Oppia and
* they will no longer be able to update their app to the latest version.
*/
class OsDeprecationNoticeDialogFragment : InjectableDialogFragment() {
companion object {
/** Returns a new instance of [OsDeprecationNoticeDialogFragment]. */
fun newInstance(): OsDeprecationNoticeDialogFragment {
return OsDeprecationNoticeDialogFragment()
}
}

@Inject lateinit var osDeprecationNoticeDialogFragmentPresenter:
OsDeprecationNoticeDialogFragmentPresenter

override fun onAttach(context: Context) {
super.onAttach(context)
(fragmentComponent as FragmentComponentImpl).inject(this)
}

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return osDeprecationNoticeDialogFragmentPresenter.handleOnCreateDialog()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.oppia.android.app.notice

import android.app.Dialog
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.R
import org.oppia.android.app.splash.DeprecationNoticeActionType
import org.oppia.android.app.translation.AppLanguageResourceHandler
import javax.inject.Inject

/** Presenter class responsible for showing an OS deprecation dialog to the user. */
class OsDeprecationNoticeDialogFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val resourceHandler: AppLanguageResourceHandler
) {
private val deprecationNoticeActionListener by lazy {
activity as DeprecationNoticeActionListener
}

/** Handles dialog creation for the OS deprecation notice. */
fun handleOnCreateDialog(): Dialog {
val appName = resourceHandler.getStringInLocale(R.string.app_name)

val dialog = AlertDialog.Builder(activity, R.style.DeprecationAlertDialogTheme)
.setTitle(R.string.os_deprecation_dialog_title)
.setMessage(
resourceHandler.getStringInLocaleWithWrapping(
R.string.os_deprecation_dialog_message,
appName
)
)
.setNegativeButton(R.string.os_deprecation_dialog_dismiss_button_text) { _, _ ->
deprecationNoticeActionListener.onActionButtonClicked(
DeprecationNoticeActionType.DISMISS
)
}
.setCancelable(false)
.create()
dialog.setCanceledOnTouchOutside(false)
return dialog
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ kt_android_library(
],
)

kt_android_library(
name = "forced_app_deprecation_notice_dialog_fragment_test_activity",
testonly = True,
srcs = [
"ForcedAppDeprecationNoticeDialogFragmentTestActivity.kt",
],
visibility = ["//app:app_testing_visibility"],
deps = [
"//app",
"//app/src/main/java/org/oppia/android/app/testing/activity:test_activity",
],
)

kt_android_library(
name = "general_availability_upgrade_notice_dialog_fragment_test_activity",
testonly = True,
Expand All @@ -31,4 +44,30 @@ kt_android_library(
],
)

kt_android_library(
name = "optional_app_deprecation_notice_dialog_fragment_test_activity",
testonly = True,
srcs = [
"OptionalAppDeprecationNoticeDialogFragmentTestActivity.kt",
],
visibility = ["//app:app_testing_visibility"],
deps = [
"//app",
"//app/src/main/java/org/oppia/android/app/testing/activity:test_activity",
],
)

kt_android_library(
name = "os_deprecation_notice_dialog_fragment_test_activity",
testonly = True,
srcs = [
"OsDeprecationNoticeDialogFragmentTestActivity.kt",
],
visibility = ["//app:app_testing_visibility"],
deps = [
"//app",
"//app/src/main/java/org/oppia/android/app/testing/activity:test_activity",
],
)

dagger_rules()
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.oppia.android.app.notice.testing

import android.os.Bundle
import org.oppia.android.app.notice.DeprecationNoticeActionListener
import org.oppia.android.app.notice.ForcedAppDeprecationNoticeDialogFragment
import org.oppia.android.app.splash.DeprecationNoticeActionType
import org.oppia.android.app.testing.activity.TestActivity

/** [TestActivity] for setting up a test environment for testing the beta notice dialog. */
class ForcedAppDeprecationNoticeDialogFragmentTestActivity :
TestActivity(),
DeprecationNoticeActionListener {
/**
* [DeprecationNoticeActionListener] that must be initialized by the test, and is presumed to be a
* Mockito mock (though this is not, strictly speaking, required).
*
* This listener will be used as the callback for the dialog in response to UI operations.
*/
lateinit var mockCallbackListener: DeprecationNoticeActionListener

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ForcedAppDeprecationNoticeDialogFragment.newInstance()
.showNow(supportFragmentManager, "forced_app_deprecation_dialog")
}

override fun onActionButtonClicked(noticeType: DeprecationNoticeActionType) {
mockCallbackListener.onActionButtonClicked(noticeType)
}
}
Loading
Loading