nsclient preferences cleanup

This commit is contained in:
Milos Kozak 2018-04-21 20:46:55 +02:00
parent 3d7cdd3819
commit ea59458383
2 changed files with 45 additions and 44 deletions

View file

@ -67,7 +67,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
MainApp.bus().post(new EventRefreshGui()); MainApp.bus().post(new EventRefreshGui());
} }
if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens)) && SP.getBoolean(R.string.key_openapsama_useautosens, false)) { if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens)) && SP.getBoolean(R.string.key_openapsama_useautosens, false)) {
OKDialog.show(this, MainApp.sResources.getString(R.string.configbuilder_sensitivity), MainApp.sResources.getString(R.string.sensitivity_warning), null); OKDialog.show(this, MainApp.gs(R.string.configbuilder_sensitivity), MainApp.gs(R.string.sensitivity_warning), null);
} }
updatePrefSummary(myPreferenceFragment.getPreference(key)); updatePrefSummary(myPreferenceFragment.getPreference(key));
} }
@ -81,13 +81,13 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
EditTextPreference editTextPref = (EditTextPreference) pref; EditTextPreference editTextPref = (EditTextPreference) pref;
if (pref.getKey().contains("password") || pref.getKey().contains("secret")) { if (pref.getKey().contains("password") || pref.getKey().contains("secret")) {
pref.setSummary("******"); pref.setSummary("******");
} else if (pref.getKey().equals(MainApp.sResources.getString(R.string.key_danars_name))) { } else if (pref.getKey().equals(MainApp.gs(R.string.key_danars_name))) {
pref.setSummary(SP.getString(R.string.key_danars_name, "")); pref.setSummary(SP.getString(R.string.key_danars_name, ""));
} else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) { } else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) {
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage()); ((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
pref.setSummary(editTextPref.getText()); pref.setSummary(editTextPref.getText());
} else if (pref.getKey().contains("smscommunicator_allowednumbers") && TextUtils.isEmpty(editTextPref.getText().trim())) { } else if (pref.getKey().contains("smscommunicator_allowednumbers") && TextUtils.isEmpty(editTextPref.getText().trim())) {
pref.setSummary(MainApp.sResources.getString(R.string.smscommunicator_allowednumbers_summary)); pref.setSummary(MainApp.gs(R.string.smscommunicator_allowednumbers_summary));
} }
} }
} }
@ -127,7 +127,6 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
if (id != -1) { if (id != -1) {
addPreferencesFromResource(id); addPreferencesFromResource(id);
addPreferencesFromResource(R.xml.pref_advanced);
} else { } else {
addPreferencesFromResource(R.xml.pref_overview); addPreferencesFromResource(R.xml.pref_overview);

View file

@ -2,7 +2,6 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto"> xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory <PreferenceCategory
android:key="ns_api"
android:title="@string/nsclientinternal_title"> android:title="@string/nsclientinternal_title">
<com.andreabaccega.widget.ValidatingEditTextPreference <com.andreabaccega.widget.ValidatingEditTextPreference
@ -22,29 +21,11 @@
android:key="@string/key_nsclientinternal_api_secret" android:key="@string/key_nsclientinternal_api_secret"
android:title="@string/nsclientinternal_secret_title" /> android:title="@string/nsclientinternal_secret_title" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_autobackfill"
android:title="@string/ns_autobackfill" />
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_ns_logappstartedevent" android:key="@string/key_ns_logappstartedevent"
android:title="@string/ns_logappstartedevent" /> android:title="@string/ns_logappstartedevent" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_create_announcements_from_errors"
android:title="@string/ns_create_announcements_from_errors_title"
android:summary="@string/ns_create_announcements_from_errors_summary"/>
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_localbroadcasts"
android:title="@string/ns_localbroadcasts_title"
android:summary="@string/ns_localbroadcasts"/>
<PreferenceScreen android:title="@string/ns_alarmoptions"> <PreferenceScreen android:title="@string/ns_alarmoptions">
<SwitchPreference <SwitchPreference
@ -73,17 +54,17 @@
android:title="@string/nsalarm_staledata" /> android:title="@string/nsalarm_staledata" />
<com.andreabaccega.widget.ValidatingEditTextPreference <com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="numericRange"
validate:minNumber="15"
validate:maxNumber="120"
android:digits="0123456789"
android:defaultValue="16" android:defaultValue="16"
android:digits="0123456789"
android:inputType="number"
android:key="@string/key_nsalarm_staledatavalue"
android:maxLines="20"
android:selectAllOnFocus="true" android:selectAllOnFocus="true"
android:singleLine="true" android:singleLine="true"
android:inputType="number"
android:maxLines="20"
android:title="@string/nsalarm_staledatavalue_label" android:title="@string/nsalarm_staledatavalue_label"
android:key="@string/key_nsalarm_staledatavalue" /> validate:maxNumber="120"
validate:minNumber="15"
validate:testType="numericRange" />
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
@ -91,17 +72,38 @@
android:title="@string/nsalarm_urgentstaledata" /> android:title="@string/nsalarm_urgentstaledata" />
<com.andreabaccega.widget.ValidatingEditTextPreference <com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="numericRange"
validate:minNumber="30"
validate:maxNumber="180"
android:digits="0123456789"
android:defaultValue="31" android:defaultValue="31"
android:digits="0123456789"
android:inputType="number"
android:key="@string/key_nsalarm_urgent_staledatavalue"
android:maxLines="20"
android:selectAllOnFocus="true" android:selectAllOnFocus="true"
android:singleLine="true" android:singleLine="true"
android:inputType="number"
android:maxLines="20"
android:title="@string/nsalarm_urgent_staledatavalue_label" android:title="@string/nsalarm_urgent_staledatavalue_label"
android:key="@string/key_nsalarm_urgent_staledatavalue" /> validate:maxNumber="180"
validate:minNumber="30"
validate:testType="numericRange" />
</PreferenceScreen>
<PreferenceScreen android:title="@string/advancedsettings_title">
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_autobackfill"
android:title="@string/ns_autobackfill" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_create_announcements_from_errors"
android:summary="@string/ns_create_announcements_from_errors_summary"
android:title="@string/ns_create_announcements_from_errors_title" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_localbroadcasts"
android:summary="@string/ns_localbroadcasts"
android:title="@string/ns_localbroadcasts_title" />
</PreferenceScreen> </PreferenceScreen>