diff --git a/app/src/main/java/org/oppia/android/app/fragment/FragmentComponentImpl.kt b/app/src/main/java/org/oppia/android/app/fragment/FragmentComponentImpl.kt
index 9a861937346..d2851214e68 100644
--- a/app/src/main/java/org/oppia/android/app/fragment/FragmentComponentImpl.kt
+++ b/app/src/main/java/org/oppia/android/app/fragment/FragmentComponentImpl.kt
@@ -63,6 +63,7 @@ import org.oppia.android.app.profile.ResetPinDialogFragment
import org.oppia.android.app.profileprogress.ProfilePictureEditDialogFragment
import org.oppia.android.app.profileprogress.ProfileProgressFragment
import org.oppia.android.app.resumelesson.ResumeLessonFragment
+import org.oppia.android.app.settings.profile.DeleteProfileSuccessDialogFragment
import org.oppia.android.app.settings.profile.ProfileEditDeletionDialogFragment
import org.oppia.android.app.settings.profile.ProfileEditFragment
import org.oppia.android.app.settings.profile.ProfileListFragment
@@ -128,6 +129,7 @@ interface FragmentComponentImpl : FragmentComponent, ViewComponentBuilderInjecto
fun inject(cellularAudioDialogFragment: CellularAudioDialogFragment)
fun inject(completedStoryListFragment: CompletedStoryListFragment)
fun inject(conceptCardFragment: ConceptCardFragment)
+ fun inject(deleteProfileSuccessDialogFragment: DeleteProfileSuccessDialogFragment)
fun inject(developerOptionsFragment: DeveloperOptionsFragment)
fun inject(downloadsTabFragment: DownloadsTabFragment)
fun inject(dragDropTestFragment: DragDropTestFragment)
diff --git a/app/src/main/java/org/oppia/android/app/settings/profile/DeleteProfileSuccessDialogFragmment.kt b/app/src/main/java/org/oppia/android/app/settings/profile/DeleteProfileSuccessDialogFragmment.kt
new file mode 100644
index 00000000000..bde9a823f9a
--- /dev/null
+++ b/app/src/main/java/org/oppia/android/app/settings/profile/DeleteProfileSuccessDialogFragmment.kt
@@ -0,0 +1,61 @@
+package org.oppia.android.app.settings.profile
+
+import android.app.Dialog
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import androidx.appcompat.app.AlertDialog
+import androidx.fragment.app.DialogFragment
+import org.oppia.android.R
+import org.oppia.android.app.administratorcontrols.AdministratorControlsActivity
+import org.oppia.android.app.fragment.FragmentComponentImpl
+import org.oppia.android.app.fragment.InjectableDialogFragment
+import org.oppia.android.app.translation.AppLanguageResourceHandler
+import javax.inject.Inject
+
+/** [DialogFragment] that notifies the user after a profile is successfully deleted. */
+class DeleteProfileSuccessDialogFragment : InjectableDialogFragment() {
+
+ companion object {
+ /** Argument key for Profile Deletion Success Dialog in [ProfileEditFragmentPresenter]. */
+ const val DELETE_PROFILE_SUCCESS_DIALOG_FRAGMENT_TAG = "DELETE_PROFILE_SUCCESS_DIALOG_FRAGMENT"
+
+ /** This function returns a new instance of [DeleteProfileSuccessDialogFragment]. */
+ fun createNewInstance(): DeleteProfileSuccessDialogFragment {
+ return DeleteProfileSuccessDialogFragment()
+ }
+ }
+
+ @Inject
+ lateinit var resourceHandler: AppLanguageResourceHandler
+
+ override fun onAttach(context: Context) {
+ super.onAttach(context)
+ (fragmentComponent as FragmentComponentImpl).inject(this)
+ }
+
+ override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
+ val alertDialog = AlertDialog
+ .Builder(requireContext(), R.style.OppiaAlertDialogTheme).apply {
+ setMessage(
+ resourceHandler.getStringInLocale(R.string.profile_edit_delete_successful_message)
+ )
+ setPositiveButton(
+ resourceHandler.getStringInLocale(R.string.log_out_dialog_okay_button)
+ ) { _, _ ->
+ if (requireContext().resources.getBoolean(R.bool.isTablet)) {
+ val intent =
+ Intent(requireContext(), AdministratorControlsActivity::class.java)
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
+ startActivity(intent)
+ } else {
+ val intent = Intent(requireContext(), ProfileListActivity::class.java)
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
+ startActivity(intent)
+ }
+ }
+ }.create()
+ alertDialog.setCanceledOnTouchOutside(true)
+ return alertDialog
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditFragmentPresenter.kt
index c5df7aa5439..d52153c4ee5 100644
--- a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditFragmentPresenter.kt
+++ b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditFragmentPresenter.kt
@@ -151,16 +151,11 @@ class ProfileEditFragmentPresenter @Inject constructor(
fragment,
Observer {
if (it is AsyncResult.Success) {
- if (fragment.requireContext().resources.getBoolean(R.bool.isTablet)) {
- val intent =
- Intent(fragment.requireContext(), AdministratorControlsActivity::class.java)
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
- fragment.startActivity(intent)
- } else {
- val intent = Intent(fragment.requireContext(), ProfileListActivity::class.java)
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
- fragment.startActivity(intent)
- }
+ DeleteProfileSuccessDialogFragment.createNewInstance()
+ .showNow(
+ fragment.childFragmentManager,
+ DeleteProfileSuccessDialogFragment.DELETE_PROFILE_SUCCESS_DIALOG_FRAGMENT_TAG
+ )
}
}
)
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0c43c5e2c26..6b93e1d3975 100755
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -347,6 +347,7 @@
All progress will be deleted and cannot be recovered.
Delete
Cancel
+ Profile deleted successfully.
Allow Download Access
User is able to download and delete content without Administrator password
diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt
index b6ae6b60b22..e8003d4a2af 100644
--- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt
+++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt
@@ -184,6 +184,11 @@ class ProfileEditFragmentTest {
testCoroutineDispatchers.runCurrent()
onView(withText(R.string.profile_edit_delete_dialog_message))
.inRoot(isDialog()).check(matches(isDisplayed()))
+ onView(withText(android.R.string.ok)).perform(click())
+ testCoroutineDispatchers.runCurrent()
+ onView(withText(R.string.profile_edit_delete_dialog_success_message))
+ .inRoot(isDialog()).check(matches(isDisplayed()))
+ onView(withText(android.R.string.ok)).perform(click())
}
}
@@ -196,9 +201,50 @@ class ProfileEditFragmentTest {
testCoroutineDispatchers.runCurrent()
onView(withText(R.string.profile_edit_delete_dialog_message))
.inRoot(isDialog()).check(matches(isCompletelyDisplayed()))
+ onView(withText(android.R.string.ok)).perform(click())
+ testCoroutineDispatchers.runCurrent()
+ onView(withText(R.string.profile_edit_delete_dialog_success_message))
+ .inRoot(isDialog()).check(matches(isDisplayed()))
+ onView(withText(android.R.string.ok)).perform(click())
+ }
+ }
+
+ @Test
+ @Config(qualifiers = "land")
+ fun testProfileEdit_startWithUserProfile_clickDelete_checkOpensDeletionSuccessDialog() {
+ launchFragmentTestActivity(internalProfileId = 1).use {
+ onView(withId(R.id.profile_delete_button)).perform(scrollTo()).perform(click())
+ testCoroutineDispatchers.runCurrent()
+ onView(withText(R.string.profile_edit_delete_dialog_message))
+ .inRoot(isDialog()).check(matches(isDisplayed()))
+ onView(withText(android.R.string.ok)).perform(click())
+ testCoroutineDispatchers.runCurrent()
+ onView(withText(R.string.profile_edit_delete_dialog_success_message))
+ .inRoot(isDialog()).check(matches(isDisplayed()))
+ onView(withText(android.R.string.ok)).perform(click())
}
}
+ @Test
+ @Config(qualifiers = "land")
+ fun testProfileEdit_deleteProfile_checkNavigationAfterDeletion() {
+ launchFragmentTestActivity(internalProfileId = 1).use {
+ onView(withId(R.id.profile_delete_button)).perform(scrollTo()).perform(click())
+ testCoroutineDispatchers.runCurrent()
+ onView(withText(R.string.profile_edit_delete_dialog_message))
+ .inRoot(isDialog()).check(matches(isDisplayed()))
+ onView(withText(android.R.string.ok)).perform(click())
+ testCoroutineDispatchers.runCurrent()
+ onView(withText(R.string.profile_edit_delete_dialog_success_message))
+ .inRoot(isDialog()).check(matches(isDisplayed()))
+ onView(withText(android.R.string.ok)).perform(click())
+ if (fragment.requireContext().resources.getBoolean(R.bool.isTablet)) {
+ intended(hasComponent(AdministratorControlsActivity::class.java.name))
+ } else {
+ intended(hasComponent(ProfileListActivity::class.java.name))
+ }
+ }
+ }
@Test
fun testProfileEdit_startWithUserHasDownloadAccess_downloadsDisabled_switchIsNotDisplayed() {
TestPlatformParameterModule.forceEnableDownloadsSupport(false)