added on/off summaries

This commit is contained in:
Adithya Abraham Philip
2015-08-17 03:39:24 +05:30
parent 3f8f70b0a9
commit f625a26bbd
3 changed files with 34 additions and 8 deletions

View File

@@ -503,10 +503,12 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
);
}
private void initializeSyncCheckBox(CheckBoxPreference syncCheckBox, final Account account,
private void initializeSyncCheckBox(final CheckBoxPreference syncCheckBox,
final Account account,
final String authority) {
boolean syncEnabled = ContentResolver.getSyncAutomatically(account, authority);
syncCheckBox.setChecked(syncEnabled);
setSummary(syncCheckBox, authority, syncEnabled);
syncCheckBox.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
@@ -520,10 +522,33 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
// cancel any ongoing/pending syncs
ContentResolver.cancelSync(account, authority);
}
setSummary(syncCheckBox, authority, syncEnabled);
return true;
}
});
}
private void setSummary(CheckBoxPreference syncCheckBox, String authority,
boolean checked) {
switch (authority) {
case Constants.PROVIDER_AUTHORITY: {
if (checked) {
syncCheckBox.setSummary(R.string.label_sync_settings_keyserver_summary_on);
} else {
syncCheckBox.setSummary(R.string.label_sync_settings_keyserver_summary_off);
}
break;
}
case ContactsContract.AUTHORITY: {
if (checked) {
syncCheckBox.setSummary(R.string.label_sync_settings_contacts_summary_on);
} else {
syncCheckBox.setSummary(R.string.label_sync_settings_contacts_summary_off);
}
break;
}
}
}
}
protected boolean isValidFragment(String fragmentName) {

View File

@@ -177,9 +177,13 @@
<string name="pref_keybase_summary">"Search keys on keybase.io"</string>
<string name="label_sync_settings_keyserver_title">"Automatically update keys"</string>
<string name="label_sync_settings_keyserver_summary">"Updates keys older than a week, from the preferred keyserver"</string>
<string name="label_sync_settings_keyserver_summary_on">"Keys older than a week are updated from the preferred keyserver"</string>
<string name="label_sync_settings_keyserver_summary_off">"Keys not automatically updated"</string>
<string name="label_sync_settings_contacts_title">"Sync Contacts with Keys"</string>
<string name="label_sync_settings_contacts_summary">"Associates contacts with imported keys, based on email, completely offline"</string>
<string name="label_sync_settings_contacts_summary_on">"Keys linked to contacts with matching emails, happens completely offline"</string>
<string name="label_sync_settings_contacts_summary_off">"New keys will not be linked to contacts"</string>
<!-- label shown in Android settings under the OpenKeychain account -->
<string name="keyserver_sync_settings_title">"Automatically update keys"</string>
<!-- Proxy Preferences -->
<string name="pref_proxy_tor_title">"Enable Tor"</string>
@@ -1358,7 +1362,6 @@
<string name="passp_cache_notif_pwd">"Password"</string>
<!-- Keyserver sync -->
<string name="keyserver_sync_settings_title">"Update Keys from Cloud"</string>
<string name="keyserver_sync_orbot_notif_title">"Sync From Cloud requires Orbot"</string>
<string name="keyserver_sync_orbot_notif_msg">"Tap to start orbot"</string>
<string name="keyserver_sync_orbot_notif_start">"Start Orbot"</string>

View File

@@ -2,11 +2,9 @@
<CheckBoxPreference
android:key="syncKeyserver"
android:persistent="false"
android:title="@string/label_sync_settings_keyserver_title"
android:summary="@string/label_sync_settings_keyserver_summary" />
android:title="@string/label_sync_settings_keyserver_title"/>
<CheckBoxPreference
android:key="syncContacts"
android:persistent="false"
android:title="@string/label_sync_settings_contacts_title"
android:summary="@string/label_sync_settings_contacts_summary" />
android:title="@string/label_sync_settings_contacts_title" />
</PreferenceScreen>