Browse Source

Added confirmation dialog when removing server, RSS feed or web search settings. Fixes #133.

pull/148/merge
Eric Kok 11 years ago
parent
commit
4361d175c6
  1. 1
      core/res/values/strings.xml
  2. 29
      core/src/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java
  3. 26
      core/src/org/transdroid/core/gui/settings/ServerSettingsActivity.java
  4. 25
      core/src/org/transdroid/core/gui/settings/WebsearchSettingsActivity.java

1
core/res/values/strings.xml

@ -221,6 +221,7 @@
<string name="pref_rssfeeds">RSS feeds</string> <string name="pref_rssfeeds">RSS feeds</string>
<string name="pref_addrssfeed">Add RSS feed</string> <string name="pref_addrssfeed">Add RSS feed</string>
<string name="pref_others">Other settings</string> <string name="pref_others">Other settings</string>
<string name="pref_confirmremove">Are you sure you want to remove these settings?</string>
<string name="pref_name">Name</string> <string name="pref_name">Name</string>
<string name="pref_name_optional">Optional personal name</string> <string name="pref_name_optional">Optional personal name</string>

29
core/src/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java

@ -20,22 +20,28 @@ import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem; import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu; import org.androidannotations.annotations.OptionsMenu;
import org.transdroid.core.R; import org.transdroid.core.R;
import org.transdroid.core.app.settings.*; import org.transdroid.core.app.settings.ApplicationSettings_;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
/** /**
* Activity that allows for a configuration of some RSS feed. The key can be supplied to update an * Activity that allows for a configuration of some RSS feed. The key can be supplied to update an existing RSS feed
* existing RSS feed setting instead of creating a new one. * setting instead of creating a new one.
* @author Eric Kok * @author Eric Kok
*/ */
@EActivity @EActivity
@OptionsMenu(resName = "activity_deleteableprefs") @OptionsMenu(resName = "activity_deleteableprefs")
public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity { public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity {
private static final int DIALOG_CONFIRMREMOVE = 0;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -57,10 +63,25 @@ public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
} }
@SuppressWarnings("deprecation")
@OptionsItem(resName = "action_removesettings") @OptionsItem(resName = "action_removesettings")
protected void removeSettings() { protected void removeSettings() {
ApplicationSettings_.getInstance_(this).removeRssfeedSettings(key); showDialog(DIALOG_CONFIRMREMOVE);
}
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_CONFIRMREMOVE:
return new AlertDialog.Builder(this).setMessage(R.string.pref_confirmremove)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationSettings_.getInstance_(RssfeedSettingsActivity.this).removeRssfeedSettings(key);
finish(); finish();
} }
}).setNegativeButton(android.R.string.cancel, null).create();
}
return null;
}
} }

26
core/src/org/transdroid/core/gui/settings/ServerSettingsActivity.java

@ -20,10 +20,14 @@ import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem; import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu; import org.androidannotations.annotations.OptionsMenu;
import org.transdroid.core.R; import org.transdroid.core.R;
import org.transdroid.core.app.settings.*; import org.transdroid.core.app.settings.ApplicationSettings_;
import org.transdroid.daemon.Daemon; import org.transdroid.daemon.Daemon;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
@ -40,6 +44,8 @@ import android.preference.PreferenceManager;
@OptionsMenu(resName = "activity_deleteableprefs") @OptionsMenu(resName = "activity_deleteableprefs")
public class ServerSettingsActivity extends KeyBoundPreferencesActivity { public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
private static final int DIALOG_CONFIRMREMOVE = 0;
private EditTextPreference extraPass, folder, downloadDir; private EditTextPreference extraPass, folder, downloadDir;
@Override @Override
@ -82,11 +88,27 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
} }
@SuppressWarnings("deprecation")
@OptionsItem(resName = "action_removesettings") @OptionsItem(resName = "action_removesettings")
protected void removeSettings() { protected void removeSettings() {
ApplicationSettings_.getInstance_(this).removeNormalServerSettings(key); showDialog(DIALOG_CONFIRMREMOVE);
}
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_CONFIRMREMOVE:
return new AlertDialog.Builder(this).setMessage(R.string.pref_confirmremove)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationSettings_.getInstance_(ServerSettingsActivity.this).removeNormalServerSettings(
key);
finish(); finish();
} }
}).setNegativeButton(android.R.string.cancel, null).create();
}
return null;
}
@Override @Override
protected void onPreferencesChanged() { protected void onPreferencesChanged() {

25
core/src/org/transdroid/core/gui/settings/WebsearchSettingsActivity.java

@ -20,9 +20,13 @@ import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem; import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu; import org.androidannotations.annotations.OptionsMenu;
import org.transdroid.core.R; import org.transdroid.core.R;
import org.transdroid.core.app.settings.*; import org.transdroid.core.app.settings.ApplicationSettings_;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -36,6 +40,8 @@ import android.os.Bundle;
@OptionsMenu(resName="activity_deleteableprefs") @OptionsMenu(resName="activity_deleteableprefs")
public class WebsearchSettingsActivity extends KeyBoundPreferencesActivity { public class WebsearchSettingsActivity extends KeyBoundPreferencesActivity {
private static final int DIALOG_CONFIRMREMOVE = 0;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -56,10 +62,25 @@ public class WebsearchSettingsActivity extends KeyBoundPreferencesActivity {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
} }
@SuppressWarnings("deprecation")
@OptionsItem(resName = "action_removesettings") @OptionsItem(resName = "action_removesettings")
protected void removeSettings() { protected void removeSettings() {
ApplicationSettings_.getInstance_(this).removeWebsearchSettings(key); showDialog(DIALOG_CONFIRMREMOVE);
}
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_CONFIRMREMOVE:
return new AlertDialog.Builder(this).setMessage(R.string.pref_confirmremove)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationSettings_.getInstance_(WebsearchSettingsActivity.this).removeWebsearchSettings(key);
finish(); finish();
} }
}).setNegativeButton(android.R.string.cancel, null).create();
}
return null;
}
} }

Loading…
Cancel
Save