diff --git a/Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java b/Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java index 52ce57a9..8ea4078f 100644 --- a/Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java +++ b/Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java @@ -49,6 +49,7 @@ public class ChanSettings { public static final BooleanSetting anonymize; public static final BooleanSetting anonymizeIds; public static final BooleanSetting repliesButtonsBottom; + public static final BooleanSetting confirmExit; public static final BooleanSetting watchEnabled; public static final BooleanSetting watchCountdown; @@ -92,6 +93,7 @@ public class ChanSettings { anonymize = new BooleanSetting(p, "preference_anonymize", false); anonymizeIds = new BooleanSetting(p, "preference_anonymize_ids", false); repliesButtonsBottom = new BooleanSetting(p, "preference_buttons_bottom", false); + confirmExit = new BooleanSetting(p, "preference_confirm_exit", false); watchEnabled = new BooleanSetting(p, "preference_watch_enabled", false, new Setting.SettingCallback() { @Override diff --git a/Clover/app/src/main/java/org/floens/chan/ui/activity/StartActivity.java b/Clover/app/src/main/java/org/floens/chan/ui/activity/StartActivity.java index 46ed91ed..a2013473 100644 --- a/Clover/app/src/main/java/org/floens/chan/ui/activity/StartActivity.java +++ b/Clover/app/src/main/java/org/floens/chan/ui/activity/StartActivity.java @@ -1,5 +1,7 @@ package org.floens.chan.ui.activity; +import android.app.AlertDialog; +import android.content.DialogInterface; import android.content.res.Configuration; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; @@ -8,6 +10,7 @@ import android.view.ViewGroup; import org.floens.chan.ChanApplication; import org.floens.chan.R; import org.floens.chan.controller.Controller; +import org.floens.chan.core.settings.ChanSettings; import org.floens.chan.ui.controller.BrowseController; import org.floens.chan.ui.controller.RootNavigationController; import org.floens.chan.utils.ThemeHelper; @@ -68,9 +71,23 @@ public class StartActivity extends AppCompatActivity { @Override public void onBackPressed() { if (!stackTop().onBack()) { - // Don't destroy the view, let Android do that or it'll create artifacts - stackTop().onHide(); - super.onBackPressed(); + if (ChanSettings.confirmExit.get()) { + new AlertDialog.Builder(this) + .setTitle(R.string.setting_confirm_exit_title) + .setNegativeButton(R.string.cancel, null) + .setPositiveButton(R.string.exit, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + stackTop().onHide(); + StartActivity.super.onBackPressed(); + } + }) + .show(); + } else { + // Don't destroy the view, let Android do that or it'll create artifacts + stackTop().onHide(); + super.onBackPressed(); + } } } diff --git a/Clover/app/src/main/java/org/floens/chan/ui/controller/AdvancedSettingsController.java b/Clover/app/src/main/java/org/floens/chan/ui/controller/AdvancedSettingsController.java index 2c16df4e..f0b861a4 100644 --- a/Clover/app/src/main/java/org/floens/chan/ui/controller/AdvancedSettingsController.java +++ b/Clover/app/src/main/java/org/floens/chan/ui/controller/AdvancedSettingsController.java @@ -69,6 +69,7 @@ public class AdvancedSettingsController extends SettingsController { settings.add(new BooleanSettingView(this, ChanSettings.anonymize, string(R.string.preference_anonymize), null)); settings.add(new BooleanSettingView(this, ChanSettings.anonymizeIds, string(R.string.preference_anonymize_ids), null)); settings.add(new BooleanSettingView(this, ChanSettings.repliesButtonsBottom, string(R.string.setting_buttons_bottom), null)); + settings.add(new BooleanSettingView(this, ChanSettings.confirmExit, string(R.string.setting_confirm_exit), null)); groups.add(settings); } diff --git a/Clover/app/src/main/res/values/strings.xml b/Clover/app/src/main/res/values/strings.xml index 467d97ac..6822e0e3 100644 --- a/Clover/app/src/main/res/values/strings.xml +++ b/Clover/app/src/main/res/values/strings.xml @@ -26,6 +26,7 @@ along with this program. If not, see . OK On Off + Exit %d minute @@ -229,6 +230,8 @@ along with this program. If not, see . Make everyone Anonymous Hide IDs Reply buttons on the bottom + Confirm before exit + Confirm exit Watcher settings Watcher settings