mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-12 04:25:08 -05:00
Refactoring
- Moved ListPreference helper functions from FontSizeSettings to K9PreferenceActivity - Used helper functions in Prefs - Reordered preferences in Prefs to match the order in global_preferences.xml (display order)
This commit is contained in:
parent
96f18734f4
commit
385c34e190
@ -3,7 +3,8 @@ package com.fsck.k9.activity;
|
||||
import com.fsck.k9.K9;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
|
||||
|
||||
public class K9PreferenceActivity extends PreferenceActivity
|
||||
@ -16,5 +17,72 @@ public class K9PreferenceActivity extends PreferenceActivity
|
||||
super.onCreate(icicle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the {@link ListPreference} instance identified by {@code key}.
|
||||
*
|
||||
* @param key
|
||||
* The key of the {@link ListPreference} object.
|
||||
* @param value
|
||||
* Initial value for the {@link ListPreference} object.
|
||||
*
|
||||
* @return The {@link ListPreference} instance identified by {@code key}.
|
||||
*/
|
||||
protected ListPreference setupListPreference(final String key, final String value)
|
||||
{
|
||||
final ListPreference prefView = (ListPreference) findPreference(key);
|
||||
prefView.setValue(value);
|
||||
prefView.setSummary(prefView.getEntry());
|
||||
prefView.setOnPreferenceChangeListener(new PreferenceChangeListener(prefView));
|
||||
return prefView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a given {@link ListPreference} instance.
|
||||
*
|
||||
* @param prefView
|
||||
* The {@link ListPreference} instance to initialize.
|
||||
* @param value
|
||||
* Initial value for the {@link ListPreference} object.
|
||||
* @param entries
|
||||
* Sets the human-readable entries to be shown in the list.
|
||||
* @param entryValues
|
||||
* The array to find the value to save for a preference when an
|
||||
* entry from entries is selected.
|
||||
*/
|
||||
protected void initListPreference(final ListPreference prefView, final String value,
|
||||
final CharSequence[] entries, final CharSequence[] entryValues)
|
||||
{
|
||||
prefView.setEntries(entries);
|
||||
prefView.setEntryValues(entryValues);
|
||||
prefView.setValue(value);
|
||||
prefView.setSummary(prefView.getEntry());
|
||||
prefView.setOnPreferenceChangeListener(new PreferenceChangeListener(prefView));
|
||||
}
|
||||
|
||||
/**
|
||||
* This class handles value changes of the {@link ListPreference} objects.
|
||||
*/
|
||||
private class PreferenceChangeListener implements Preference.OnPreferenceChangeListener
|
||||
{
|
||||
private ListPreference mPrefView;
|
||||
|
||||
private PreferenceChangeListener(final ListPreference prefView)
|
||||
{
|
||||
this.mPrefView = prefView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the preference value in the preference summary field.
|
||||
*/
|
||||
@Override
|
||||
public boolean onPreferenceChange(final Preference preference, final Object newValue)
|
||||
{
|
||||
final String summary = newValue.toString();
|
||||
final int index = mPrefView.findIndexOfValue(summary);
|
||||
mPrefView.setSummary(mPrefView.getEntries()[index]);
|
||||
mPrefView.setValue(summary);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -74,24 +74,54 @@ public class FontSizeSettings extends K9PreferenceActivity
|
||||
FontSizes fontSizes = K9.getFontSizes();
|
||||
addPreferencesFromResource(R.xml.font_preferences);
|
||||
|
||||
mAccountName = initializeListPreference(PREFERENCE_ACCOUNT_NAME_FONT, fontSizes.getAccountName());
|
||||
mAccountDescription = initializeListPreference(PREFERENCE_ACCOUNT_DESCRIPTION_FONT, fontSizes.getAccountDescription());
|
||||
mAccountName = setupListPreference(
|
||||
PREFERENCE_ACCOUNT_NAME_FONT,
|
||||
Integer.toString(fontSizes.getAccountName()));
|
||||
mAccountDescription = setupListPreference(
|
||||
PREFERENCE_ACCOUNT_DESCRIPTION_FONT,
|
||||
Integer.toString(fontSizes.getAccountDescription()));
|
||||
|
||||
mFolderName = initializeListPreference(PREFERENCE_FOLDER_NAME_FONT, fontSizes.getFolderName());
|
||||
mFolderStatus = initializeListPreference(PREFERENCE_FOLDER_STATUS_FONT, fontSizes.getFolderStatus());
|
||||
mFolderName = setupListPreference(
|
||||
PREFERENCE_FOLDER_NAME_FONT,
|
||||
Integer.toString(fontSizes.getFolderName()));
|
||||
mFolderStatus = setupListPreference(
|
||||
PREFERENCE_FOLDER_STATUS_FONT,
|
||||
Integer.toString(fontSizes.getFolderStatus()));
|
||||
|
||||
mMessageListSubject = initializeListPreference(PREFERENCE_MESSAGE_LIST_SUBJECT_FONT, fontSizes.getMessageListSubject());
|
||||
mMessageListSender = initializeListPreference(PREFERENCE_MESSAGE_LIST_SENDER_FONT, fontSizes.getMessageListSender());
|
||||
mMessageListDate = initializeListPreference(PREFERENCE_MESSAGE_LIST_DATE_FONT, fontSizes.getMessageListDate());
|
||||
mMessageListSubject = setupListPreference(
|
||||
PREFERENCE_MESSAGE_LIST_SUBJECT_FONT,
|
||||
Integer.toString(fontSizes.getMessageListSubject()));
|
||||
mMessageListSender = setupListPreference(
|
||||
PREFERENCE_MESSAGE_LIST_SENDER_FONT,
|
||||
Integer.toString(fontSizes.getMessageListSender()));
|
||||
mMessageListDate = setupListPreference(
|
||||
PREFERENCE_MESSAGE_LIST_DATE_FONT,
|
||||
Integer.toString(fontSizes.getMessageListDate()));
|
||||
|
||||
mMessageViewSender = initializeListPreference(PREFERENCE_MESSAGE_VIEW_SENDER_FONT, fontSizes.getMessageViewSender());
|
||||
mMessageViewTo = initializeListPreference(PREFERENCE_MESSAGE_VIEW_TO_FONT, fontSizes.getMessageViewTo());
|
||||
mMessageViewCC = initializeListPreference(PREFERENCE_MESSAGE_VIEW_CC_FONT, fontSizes.getMessageViewCC());
|
||||
mMessageViewAdditionalHeaders = initializeListPreference(PREFERENCE_MESSAGE_VIEW_ADDITIONAL_HEADERS_FONT, fontSizes.getMessageViewAdditionalHeaders());
|
||||
mMessageViewSubject = initializeListPreference(PREFERENCE_MESSAGE_VIEW_SUBJECT_FONT, fontSizes.getMessageViewSubject());
|
||||
mMessageViewTime = initializeListPreference(PREFERENCE_MESSAGE_VIEW_TIME_FONT, fontSizes.getMessageViewTime());
|
||||
mMessageViewDate = initializeListPreference(PREFERENCE_MESSAGE_VIEW_DATE_FONT, fontSizes.getMessageViewDate());
|
||||
mMessageViewContent = initializeListPreference(PREFERENCE_MESSAGE_VIEW_CONTENT_FONT, fontSizes.getMessageViewContentAsInt());
|
||||
mMessageViewSender = setupListPreference(
|
||||
PREFERENCE_MESSAGE_VIEW_SENDER_FONT,
|
||||
Integer.toString(fontSizes.getMessageViewSender()));
|
||||
mMessageViewTo = setupListPreference(
|
||||
PREFERENCE_MESSAGE_VIEW_TO_FONT,
|
||||
Integer.toString(fontSizes.getMessageViewTo()));
|
||||
mMessageViewCC = setupListPreference(
|
||||
PREFERENCE_MESSAGE_VIEW_CC_FONT,
|
||||
Integer.toString(fontSizes.getMessageViewCC()));
|
||||
mMessageViewAdditionalHeaders = setupListPreference(
|
||||
PREFERENCE_MESSAGE_VIEW_ADDITIONAL_HEADERS_FONT,
|
||||
Integer.toString(fontSizes.getMessageViewAdditionalHeaders()));
|
||||
mMessageViewSubject = setupListPreference(
|
||||
PREFERENCE_MESSAGE_VIEW_SUBJECT_FONT,
|
||||
Integer.toString(fontSizes.getMessageViewSubject()));
|
||||
mMessageViewTime = setupListPreference(
|
||||
PREFERENCE_MESSAGE_VIEW_TIME_FONT,
|
||||
Integer.toString(fontSizes.getMessageViewTime()));
|
||||
mMessageViewDate = setupListPreference(
|
||||
PREFERENCE_MESSAGE_VIEW_DATE_FONT,
|
||||
Integer.toString(fontSizes.getMessageViewDate()));
|
||||
mMessageViewContent = setupListPreference(
|
||||
PREFERENCE_MESSAGE_VIEW_CONTENT_FONT,
|
||||
Integer.toString(fontSizes.getMessageViewContentAsInt()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,46 +166,4 @@ public class FontSizeSettings extends K9PreferenceActivity
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the ListPreference instance identified by <code>key</code>.
|
||||
*
|
||||
* @param key The key of the ListPreference object.
|
||||
* @param value Initial value for the ListPreference object.
|
||||
* @return The ListPreference instance identified by <code>key</code>.
|
||||
*/
|
||||
private ListPreference initializeListPreference(String key, int value)
|
||||
{
|
||||
ListPreference prefView = (ListPreference) findPreference(key);
|
||||
prefView.setValue(Integer.toString(value));
|
||||
prefView.setSummary(prefView.getEntry());
|
||||
prefView.setOnPreferenceChangeListener(new PreferenceChangeListener(prefView));
|
||||
return prefView;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class handles value changes of the ListPreference objects.
|
||||
*/
|
||||
private class PreferenceChangeListener implements Preference.OnPreferenceChangeListener
|
||||
{
|
||||
private ListPreference mPrefView;
|
||||
|
||||
private PreferenceChangeListener(ListPreference prefView)
|
||||
{
|
||||
this.mPrefView = prefView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the preference value in the preference summary field.
|
||||
*/
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
final String summary = newValue.toString();
|
||||
int index = mPrefView.findIndexOfValue(summary);
|
||||
mPrefView.setSummary(mPrefView.getEntries()[index]);
|
||||
mPrefView.setValue(summary);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,63 +33,58 @@ public class Prefs extends K9PreferenceActivity
|
||||
*/
|
||||
private static final CharSequence[] EMPTY_CHAR_SEQUENCE_ARRAY = new CharSequence[0];
|
||||
|
||||
/*
|
||||
* Keys of the preferences defined in res/xml/global_preferences.xml
|
||||
*/
|
||||
private static final String PREFERENCE_LANGUAGE = "language";
|
||||
private static final String PREFERENCE_THEME = "theme";
|
||||
private static final String PREFERENCE_FONT_SIZE = "font_size";
|
||||
private static final String PREFERENCE_DATE_FORMAT = "dateFormat";
|
||||
private static final String PREFERENCE_BACKGROUND_OPS = "background_ops";
|
||||
private static final String PREFERENCE_DEBUG_LOGGING = "debug_logging";
|
||||
private static final String PREFERENCE_SENSITIVE_LOGGING = "sensitive_logging";
|
||||
|
||||
private static final String PREFERENCE_ANIMATIONS = "animations";
|
||||
private static final String PREFERENCE_GESTURES = "gestures";
|
||||
private static final String PREFERENCE_VOLUME_NAVIGATION = "volumeNavigation";
|
||||
private static final String PREFERENCE_MANAGE_BACK = "manage_back";
|
||||
private static final String PREFERENCE_START_INTEGRATED_INBOX = "start_integrated_inbox";
|
||||
private static final String PREFERENCE_CONFIRM_ACTIONS = "confirm_actions";
|
||||
private static final String PREFERENCE_PRIVACY_MODE = "privacy_mode";
|
||||
private static final String PREFERENCE_MEASURE_ACCOUNTS = "measure_accounts";
|
||||
private static final String PREFERENCE_COUNT_SEARCH = "count_search";
|
||||
private static final String PREFERENCE_MESSAGELIST_TOUCHABLE = "messagelist_touchable";
|
||||
private static final String PREFERENCE_MESSAGELIST_STARS = "messagelist_stars";
|
||||
private static final String PREFERENCE_MESSAGELIST_CHECKBOXES = "messagelist_checkboxes";
|
||||
private static final String PREFERENCE_MESSAGELIST_TOUCHABLE = "messagelist_touchable";
|
||||
private static final String PREFERENCE_MESSAGELIST_SHOW_CONTACT_NAME = "messagelist_show_contact_name";
|
||||
private static final String PREFERENCE_MESSAGELIST_CONTACT_NAME_COLOR = "messagelist_contact_name_color";
|
||||
private static final String PREFERENCE_MESSAGEVIEW_FIXEDWIDTH = "messageview_fixedwidth_font";
|
||||
private static final String PREFERENCE_MESSAGEVIEW_RETURN_TO_LIST = "messageview_return_to_list";
|
||||
|
||||
private static final String PREFERENCE_MEASURE_ACCOUNTS = "measure_accounts";
|
||||
private static final String PREFERENCE_COUNT_SEARCH = "count_search";
|
||||
private static final String PREFERENCE_BACKGROUND_OPS = "background_ops";
|
||||
private static final String PREFERENCE_GALLERY_BUG_WORKAROUND = "use_gallery_bug_workaround";
|
||||
private static final String PREFERENCE_DEBUG_LOGGING = "debug_logging";
|
||||
private static final String PREFERENCE_SENSITIVE_LOGGING = "sensitive_logging";
|
||||
|
||||
private static final String PREFERENCE_CONFIRM_ACTIONS = "confirm_actions";
|
||||
|
||||
private static final String PREFERENCE_PRIVACY_MODE = "privacy_mode";
|
||||
|
||||
private ListPreference mLanguage;
|
||||
private ListPreference mTheme;
|
||||
private ListPreference mDateFormat;
|
||||
private ListPreference mBackgroundOps;
|
||||
private CheckBoxPreference mDebugLogging;
|
||||
private CheckBoxPreference mSensitiveLogging;
|
||||
private CheckBoxPreference mAnimations;
|
||||
private CheckBoxPreference mGestures;
|
||||
private CheckBoxListPreference mVolumeNavigation;
|
||||
private CheckBoxPreference mManageBack;
|
||||
private CheckBoxPreference mStartIntegratedInbox;
|
||||
private CheckBoxPreference mAnimations;
|
||||
private CheckBoxListPreference mConfirmActions;
|
||||
private CheckBoxPreference mPrivacyMode;
|
||||
private CheckBoxPreference mMeasureAccounts;
|
||||
private CheckBoxPreference mCountSearch;
|
||||
private CheckBoxPreference mTouchable;
|
||||
private CheckBoxPreference mStars;
|
||||
private CheckBoxPreference mCheckboxes;
|
||||
private CheckBoxPreference mTouchable;
|
||||
private CheckBoxPreference mShowContactName;
|
||||
private CheckBoxPreference mChangeContactNameColor;
|
||||
private CheckBoxPreference mFixedWidth;
|
||||
private CheckBoxPreference mReturnToList;
|
||||
|
||||
private CheckBoxPreference mMeasureAccounts;
|
||||
private CheckBoxPreference mCountSearch;
|
||||
private ListPreference mBackgroundOps;
|
||||
private CheckBoxPreference mUseGalleryBugWorkaround;
|
||||
|
||||
private CheckBoxListPreference mConfirmActions;
|
||||
|
||||
private CheckBoxPreference mPrivacyMode;
|
||||
|
||||
private String initBackgroundOps;
|
||||
private CheckBoxPreference mDebugLogging;
|
||||
private CheckBoxPreference mSensitiveLogging;
|
||||
|
||||
|
||||
public static void actionPrefs(Context context)
|
||||
@ -103,7 +98,6 @@ public class Prefs extends K9PreferenceActivity
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
addPreferencesFromResource(R.xml.global_preferences);
|
||||
|
||||
mLanguage = (ListPreference) findPreference(PREFERENCE_LANGUAGE);
|
||||
@ -119,36 +113,12 @@ public class Prefs extends K9PreferenceActivity
|
||||
entryValueVector.remove(i);
|
||||
}
|
||||
}
|
||||
mLanguage.setEntries(entryVector.toArray(EMPTY_CHAR_SEQUENCE_ARRAY));
|
||||
mLanguage.setEntryValues(entryValueVector.toArray(EMPTY_CHAR_SEQUENCE_ARRAY));
|
||||
mLanguage.setValue(K9.getK9Language());
|
||||
mLanguage.setSummary(mLanguage.getEntry());
|
||||
mLanguage.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
final String summary = newValue.toString();
|
||||
int index = mLanguage.findIndexOfValue(summary);
|
||||
mLanguage.setSummary(mLanguage.getEntries()[index]);
|
||||
mLanguage.setValue(summary);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
initListPreference(mLanguage, K9.getK9Language(),
|
||||
entryVector.toArray(EMPTY_CHAR_SEQUENCE_ARRAY),
|
||||
entryValueVector.toArray(EMPTY_CHAR_SEQUENCE_ARRAY));
|
||||
|
||||
mTheme = (ListPreference) findPreference(PREFERENCE_THEME);
|
||||
mTheme.setValue(String.valueOf(K9.getK9Theme() == android.R.style.Theme ? "dark" : "light"));
|
||||
mTheme.setSummary(mTheme.getEntry());
|
||||
mTheme.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
final String summary = newValue.toString();
|
||||
int index = mTheme.findIndexOfValue(summary);
|
||||
mTheme.setSummary(mTheme.getEntries()[index]);
|
||||
mTheme.setValue(summary);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
final String theme = (K9.getK9Theme() == android.R.style.Theme) ? "dark" : "light";
|
||||
mTheme = setupListPreference(PREFERENCE_THEME, theme);
|
||||
|
||||
findPreference(PREFERENCE_FONT_SIZE).setOnPreferenceClickListener(
|
||||
new Preference.OnPreferenceClickListener()
|
||||
@ -170,49 +140,14 @@ public class Prefs extends K9PreferenceActivity
|
||||
entries[i] = DateFormatter.getSampleDate(this, format);;
|
||||
values[i] = format;
|
||||
}
|
||||
mDateFormat.setEntries(entries);
|
||||
mDateFormat.setEntryValues(values);
|
||||
|
||||
mDateFormat.setValue(DateFormatter.getFormat(this));
|
||||
mDateFormat.setSummary(mDateFormat.getEntry());
|
||||
mDateFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
final String summary = newValue.toString();
|
||||
int index = mDateFormat.findIndexOfValue(summary);
|
||||
mDateFormat.setSummary(mDateFormat.getEntries()[index]);
|
||||
mDateFormat.setValue(summary);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mBackgroundOps = (ListPreference) findPreference(PREFERENCE_BACKGROUND_OPS);
|
||||
initBackgroundOps = K9.getBackgroundOps().toString();
|
||||
mBackgroundOps.setValue(initBackgroundOps);
|
||||
mBackgroundOps.setSummary(mBackgroundOps.getEntry());
|
||||
mBackgroundOps.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
final String summary = newValue.toString();
|
||||
int index = mBackgroundOps.findIndexOfValue(summary);
|
||||
mBackgroundOps.setSummary(mBackgroundOps.getEntries()[index]);
|
||||
mBackgroundOps.setValue(summary);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mDebugLogging = (CheckBoxPreference)findPreference(PREFERENCE_DEBUG_LOGGING);
|
||||
mSensitiveLogging = (CheckBoxPreference)findPreference(PREFERENCE_SENSITIVE_LOGGING);
|
||||
|
||||
mDebugLogging.setChecked(K9.DEBUG);
|
||||
mSensitiveLogging.setChecked(K9.DEBUG_SENSITIVE);
|
||||
initListPreference(mDateFormat, DateFormatter.getFormat(this), entries, values);
|
||||
|
||||
mAnimations = (CheckBoxPreference)findPreference(PREFERENCE_ANIMATIONS);
|
||||
mAnimations.setChecked(K9.showAnimations());
|
||||
|
||||
mGestures = (CheckBoxPreference)findPreference(PREFERENCE_GESTURES);
|
||||
mGestures.setChecked(K9.gesturesEnabled());
|
||||
|
||||
mVolumeNavigation = (CheckBoxListPreference)findPreference(PREFERENCE_VOLUME_NAVIGATION);
|
||||
mVolumeNavigation.setItems(new CharSequence[] {getString(R.string.volume_navigation_message), getString(R.string.volume_navigation_list)});
|
||||
mVolumeNavigation.setCheckedItems(new boolean[] {K9.useVolumeKeysForNavigationEnabled(), K9.useVolumeKeysForListNavigationEnabled()});
|
||||
@ -223,6 +158,21 @@ public class Prefs extends K9PreferenceActivity
|
||||
mStartIntegratedInbox = (CheckBoxPreference)findPreference(PREFERENCE_START_INTEGRATED_INBOX);
|
||||
mStartIntegratedInbox.setChecked(K9.startIntegratedInbox());
|
||||
|
||||
mConfirmActions = (CheckBoxListPreference) findPreference(PREFERENCE_CONFIRM_ACTIONS);
|
||||
mConfirmActions.setItems(new CharSequence[] {getString(R.string.global_settings_confirm_action_delete)});
|
||||
mConfirmActions.setCheckedItems(new boolean[] {K9.confirmDelete()});
|
||||
|
||||
mPrivacyMode = (CheckBoxPreference) findPreference(PREFERENCE_PRIVACY_MODE);
|
||||
mPrivacyMode.setChecked(K9.keyguardPrivacy());
|
||||
|
||||
mMeasureAccounts = (CheckBoxPreference)findPreference(PREFERENCE_MEASURE_ACCOUNTS);
|
||||
mMeasureAccounts.setChecked(K9.measureAccounts());
|
||||
|
||||
mCountSearch = (CheckBoxPreference)findPreference(PREFERENCE_COUNT_SEARCH);
|
||||
mCountSearch.setChecked(K9.countSearchMessages());
|
||||
|
||||
mTouchable = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_TOUCHABLE);
|
||||
mTouchable.setChecked(K9.messageListTouchable());
|
||||
|
||||
mStars = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_STARS);
|
||||
mStars.setChecked(K9.messageListStars());
|
||||
@ -230,23 +180,25 @@ public class Prefs extends K9PreferenceActivity
|
||||
mCheckboxes = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_CHECKBOXES);
|
||||
mCheckboxes.setChecked(K9.messageListCheckboxes());
|
||||
|
||||
mTouchable = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_TOUCHABLE);
|
||||
mTouchable.setChecked(K9.messageListTouchable());
|
||||
|
||||
mShowContactName = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_SHOW_CONTACT_NAME);
|
||||
mShowContactName.setChecked(K9.showContactName());
|
||||
|
||||
mChangeContactNameColor = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_CONTACT_NAME_COLOR);
|
||||
mChangeContactNameColor.setChecked(K9.changeContactNameColor());
|
||||
if (K9.changeContactNameColor())
|
||||
{
|
||||
mChangeContactNameColor.setSummary(R.string.global_settings_registered_name_color_changed);
|
||||
}
|
||||
else
|
||||
{
|
||||
mChangeContactNameColor.setSummary(R.string.global_settings_registered_name_color_default);
|
||||
}
|
||||
mChangeContactNameColor.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
if ((boolean)(Boolean)newValue == true)
|
||||
final Boolean checked = (Boolean) newValue;
|
||||
if (checked)
|
||||
{
|
||||
onChooseContactNameColor();
|
||||
mChangeContactNameColor.setSummary(R.string.global_settings_registered_name_color_changed);
|
||||
@ -255,7 +207,7 @@ public class Prefs extends K9PreferenceActivity
|
||||
{
|
||||
mChangeContactNameColor.setSummary(R.string.global_settings_registered_name_color_default);
|
||||
}
|
||||
mChangeContactNameColor.setChecked((Boolean)newValue);
|
||||
mChangeContactNameColor.setChecked(checked);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@ -266,34 +218,43 @@ public class Prefs extends K9PreferenceActivity
|
||||
mReturnToList = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGEVIEW_RETURN_TO_LIST);
|
||||
mReturnToList.setChecked(K9.messageViewReturnToList());
|
||||
|
||||
mMeasureAccounts = (CheckBoxPreference)findPreference(PREFERENCE_MEASURE_ACCOUNTS);
|
||||
mMeasureAccounts.setChecked(K9.measureAccounts());
|
||||
|
||||
mCountSearch = (CheckBoxPreference)findPreference(PREFERENCE_COUNT_SEARCH);
|
||||
mCountSearch.setChecked(K9.countSearchMessages());
|
||||
mBackgroundOps = setupListPreference(PREFERENCE_BACKGROUND_OPS, K9.getBackgroundOps().toString());
|
||||
|
||||
mUseGalleryBugWorkaround = (CheckBoxPreference)findPreference(PREFERENCE_GALLERY_BUG_WORKAROUND);
|
||||
mUseGalleryBugWorkaround.setChecked(K9.useGalleryBugWorkaround());
|
||||
|
||||
mConfirmActions = (CheckBoxListPreference) findPreference(PREFERENCE_CONFIRM_ACTIONS);
|
||||
mConfirmActions.setItems(new CharSequence[] {getString(R.string.global_settings_confirm_action_delete)});
|
||||
mConfirmActions.setCheckedItems(new boolean[] {K9.confirmDelete()});
|
||||
mDebugLogging = (CheckBoxPreference)findPreference(PREFERENCE_DEBUG_LOGGING);
|
||||
mSensitiveLogging = (CheckBoxPreference)findPreference(PREFERENCE_SENSITIVE_LOGGING);
|
||||
|
||||
mPrivacyMode = (CheckBoxPreference) findPreference(PREFERENCE_PRIVACY_MODE);
|
||||
mPrivacyMode.setChecked(K9.keyguardPrivacy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
mDebugLogging.setChecked(K9.DEBUG);
|
||||
mSensitiveLogging.setChecked(K9.DEBUG_SENSITIVE);
|
||||
}
|
||||
|
||||
private void saveSettings()
|
||||
{
|
||||
SharedPreferences preferences = Preferences.getPreferences(this).getPreferences();
|
||||
|
||||
K9.setK9Language(mLanguage.getValue());
|
||||
K9.setK9Theme(mTheme.getValue().equals("dark") ? android.R.style.Theme : android.R.style.Theme_Light);
|
||||
K9.setAnimations(mAnimations.isChecked());
|
||||
K9.setGesturesEnabled(mGestures.isChecked());
|
||||
K9.setUseVolumeKeysForNavigation(mVolumeNavigation.getCheckedItems()[0]);
|
||||
K9.setUseVolumeKeysForListNavigation(mVolumeNavigation.getCheckedItems()[1]);
|
||||
K9.setManageBack(mManageBack.isChecked());
|
||||
K9.setStartIntegratedInbox(mStartIntegratedInbox.isChecked());
|
||||
K9.setConfirmDelete(mConfirmActions.getCheckedItems()[0]);
|
||||
K9.setKeyguardPrivacy(mPrivacyMode.isChecked());
|
||||
K9.setMeasureAccounts(mMeasureAccounts.isChecked());
|
||||
K9.setCountSearchMessages(mCountSearch.isChecked());
|
||||
K9.setMessageListTouchable(mTouchable.isChecked());
|
||||
K9.setMessageListStars(mStars.isChecked());
|
||||
K9.setMessageListCheckboxes(mCheckboxes.isChecked());
|
||||
K9.setShowContactName(mShowContactName.isChecked());
|
||||
K9.setChangeContactNameColor(mChangeContactNameColor.isChecked());
|
||||
K9.setMessageViewFixedWidthFont(mFixedWidth.isChecked());
|
||||
K9.setMessageViewReturnToList(mReturnToList.isChecked());
|
||||
boolean needsRefresh = K9.setBackgroundOps(mBackgroundOps.getValue());
|
||||
K9.setUseGalleryBugWorkaround(mUseGalleryBugWorkaround.isChecked());
|
||||
|
||||
if (!K9.DEBUG && mDebugLogging.isChecked())
|
||||
{
|
||||
@ -301,36 +262,12 @@ public class Prefs extends K9PreferenceActivity
|
||||
}
|
||||
K9.DEBUG = mDebugLogging.isChecked();
|
||||
K9.DEBUG_SENSITIVE = mSensitiveLogging.isChecked();
|
||||
boolean needsRefresh = K9.setBackgroundOps(mBackgroundOps.getValue());
|
||||
|
||||
K9.setAnimations(mAnimations.isChecked());
|
||||
K9.setGesturesEnabled(mGestures.isChecked());
|
||||
K9.setUseVolumeKeysForNavigation(mVolumeNavigation.getCheckedItems()[0]);
|
||||
K9.setUseVolumeKeysForListNavigation(mVolumeNavigation.getCheckedItems()[1]);
|
||||
K9.setManageBack(mManageBack.isChecked());
|
||||
K9.setStartIntegratedInbox(mStartIntegratedInbox.isChecked());
|
||||
K9.setMessageListStars(mStars.isChecked());
|
||||
K9.setMessageListCheckboxes(mCheckboxes.isChecked());
|
||||
K9.setMessageListTouchable(mTouchable.isChecked());
|
||||
|
||||
K9.setShowContactName(mShowContactName.isChecked());
|
||||
K9.setChangeContactNameColor(mChangeContactNameColor.isChecked());
|
||||
K9.setMessageViewFixedWidthFont(mFixedWidth.isChecked());
|
||||
K9.setMessageViewReturnToList(mReturnToList.isChecked());
|
||||
|
||||
K9.setMeasureAccounts(mMeasureAccounts.isChecked());
|
||||
K9.setCountSearchMessages(mCountSearch.isChecked());
|
||||
|
||||
K9.setUseGalleryBugWorkaround(mUseGalleryBugWorkaround.isChecked());
|
||||
|
||||
K9.setConfirmDelete(mConfirmActions.getCheckedItems()[0]);
|
||||
|
||||
K9.setKeyguardPrivacy(mPrivacyMode.isChecked());
|
||||
|
||||
Editor editor = preferences.edit();
|
||||
K9.save(editor);
|
||||
DateFormatter.setDateFormat(editor, mDateFormat.getValue());
|
||||
editor.commit();
|
||||
|
||||
if (needsRefresh)
|
||||
{
|
||||
MailService.actionReset(this, null);
|
||||
@ -358,7 +295,7 @@ public class Prefs extends K9PreferenceActivity
|
||||
FontSizeSettings.actionEditSettings(this);
|
||||
}
|
||||
|
||||
public void onChooseContactNameColor()
|
||||
private void onChooseContactNameColor()
|
||||
{
|
||||
new ColorPickerDialog(this, new ColorPickerDialog.OnColorChangedListener()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user