From f5a333e2ac3c3032f787d6b7f66b751aa70767ef Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 8 Oct 2021 20:19:50 +0800 Subject: Show a dialog before closing CustomizeThemeActivity. --- .../activities/CustomizeThemeActivity.java | 17 ++++++++++++++--- .../events/ChangeConfirmToExitEvent.java | 9 --------- 2 files changed, 14 insertions(+), 12 deletions(-) delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeConfirmToExitEvent.java (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java index 989eb34f..cadaa8d5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java @@ -15,6 +15,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.appbar.AppBarLayout; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.snackbar.Snackbar; import org.greenrobot.eventbus.EventBus; @@ -27,6 +28,9 @@ import javax.inject.Named; import butterknife.BindView; import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.Infinity; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.adapters.CustomizeThemeRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.asynctasks.GetCustomTheme; import ml.docilealligator.infinityforreddit.asynctasks.InsertCustomTheme; @@ -34,9 +38,6 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomTheme; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeSettingsItem; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent; -import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils; public class CustomizeThemeActivity extends BaseActivity { @@ -230,6 +231,16 @@ public class CustomizeThemeActivity extends BaseActivity { } } + @Override + public void onBackPressed() { + new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.discard) + .setPositiveButton(R.string.discard_dialog_button, (dialogInterface, i) + -> super.onBackPressed()) + .setNegativeButton(R.string.no, null) + .show(); + } + @Override protected SharedPreferences getDefaultSharedPreferences() { return sharedPreferences; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeConfirmToExitEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeConfirmToExitEvent.java deleted file mode 100644 index fbfc4ae3..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeConfirmToExitEvent.java +++ /dev/null @@ -1,9 +0,0 @@ -package ml.docilealligator.infinityforreddit.events; - -public class ChangeConfirmToExitEvent { - public boolean confirmToExit; - - public ChangeConfirmToExitEvent(boolean confirmToExit) { - this.confirmToExit = confirmToExit; - } -} -- cgit v1.2.3