refine preference ux

This commit is contained in:
B. Petersen
2018-12-24 01:51:38 +01:00
parent 4582b76e92
commit 8fa32cc4f7
3 changed files with 46 additions and 42 deletions
+34 -34
View File
@@ -1,6 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/pref_communication">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_read_receipts"
android:summary="@string/pref_read_receipts_explain"
android:title="@string/pref_read_receipts" />
<Preference
android:key="preference_category_blocked"
android:title="@string/pref_blocked_contacts" />
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_divider" />
<PreferenceCategory android:title="@string/pref_app_access">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_screen_security"
android:summary="@string/pref_screen_security_explain"
android:title="@string/pref_screen_security" />
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_incognito_keyboard"
android:summary="@string/pref_incognito_keyboard_explain"
android:title="@string/pref_incognito_keyboard" />
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_divider" />
<PreferenceCategory android:title="@string/screenlock_title">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
@@ -27,38 +61,4 @@
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_divider" />
<PreferenceCategory android:title="@string/pref_app_access">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_screen_security"
android:summary="@string/pref_screen_security_explain"
android:title="@string/pref_screen_security" />
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_incognito_keyboard"
android:summary="@string/pref_incognito_keyboard_explain"
android:title="@string/pref_incognito_keyboard" />
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_divider" />
<PreferenceCategory android:title="@string/pref_communication">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_read_receipts"
android:summary="@string/pref_read_receipts_explain"
android:title="@string/pref_read_receipts" />
<Preference
android:key="preference_category_blocked"
android:title="@string/pref_blocked_contacts" />
</PreferenceCategory>
</PreferenceScreen>
@@ -138,12 +138,16 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment
}
public static CharSequence getSummary(Context context) {
final int privacySummaryResId = R.string.pref_summary_privacy;
final String onRes = context.getString(R.string.pref_summary_on);
final String offRes = context.getString(R.string.pref_summary_off);
final String onRes = context.getString(R.string.on);
final String offRes = context.getString(R.string.off);
String screenLockState = Prefs.isScreenLockEnabled(context) ? onRes : offRes;
String readReceiptState = DcHelper.getContext(context).getConfigInt("mdns_enabled", DcContext.DC_PREF_DEFAULT_MDNS_ENABLED)!=0? onRes : offRes;
return context.getString(privacySummaryResId, screenLockState, readReceiptState);
// adding combined strings as "Read receipt: %1$s, Screen lock: %1$s, "
// makes things inflexible on changes and/or adds lot of additional works to programmers.
// however, if needed, we can refine this later.
return context.getString(R.string.pref_read_receipts) + " " + readReceiptState + ", "
+ context.getString(R.string.screenlock_title) + " " + screenLockState;
}
private class ChangePassphraseClickListener implements Preference.OnPreferenceClickListener {
@@ -44,10 +44,10 @@ public class AppearancePreferenceFragment extends ListSummaryPreferenceFragment
String imagePath = Prefs.getBackgroundImagePath(getContext());
String backgroundString;
if(imagePath.isEmpty()){
backgroundString = this.getString(R.string.pref_summary_default);
backgroundString = this.getString(R.string.def);
}
else{
backgroundString = this.getString(R.string.pref_summary_custom);
backgroundString = this.getString(R.string.custom);
}
this.findPreference(Prefs.BACKGROUND_PREF).setSummary(backgroundString);
}
@@ -73,10 +73,10 @@ public class AppearancePreferenceFragment extends ListSummaryPreferenceFragment
String imagePath = Prefs.getBackgroundImagePath(context);
String backgroundString;
if(imagePath.isEmpty()){
backgroundString = context.getString(R.string.pref_summary_default);
backgroundString = context.getString(R.string.def);
}
else{
backgroundString = context.getString(R.string.pref_summary_custom);
backgroundString = context.getString(R.string.custom);
}
return context.getString(R.string.pref_summary_appearance,