Add confirm before exit

filtering
Floens 10 years ago
parent 5c9c6a0bdd
commit 0e02d2e25f
  1. 2
      Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java
  2. 23
      Clover/app/src/main/java/org/floens/chan/ui/activity/StartActivity.java
  3. 1
      Clover/app/src/main/java/org/floens/chan/ui/controller/AdvancedSettingsController.java
  4. 3
      Clover/app/src/main/res/values/strings.xml

@ -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<Boolean>() {
@Override

@ -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();
}
}
}

@ -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);
}

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<string name="ok">OK</string>
<string name="on">On</string>
<string name="off">Off</string>
<string name="exit">Exit</string>
<plurals name="minutes">
<item quantity="one">%d minute</item>
@ -229,6 +230,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<string name="setting_anonymize">Make everyone Anonymous</string>
<string name="setting_anonymize_ids">Hide IDs</string>
<string name="setting_buttons_bottom">Reply buttons on the bottom</string>
<string name="setting_confirm_exit">Confirm before exit</string>
<string name="setting_confirm_exit_title">Confirm exit</string>
<string name="settings_screen_watch">Watcher settings</string>
<string name="settings_group_watch">Watcher settings</string>

Loading…
Cancel
Save