-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1fbe0c
commit 52cdbce
Showing
5 changed files
with
115 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...c/main/java/org/oppia/android/app/settings/profile/DeleteProfileSuccessDialogFragmment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters