From cd7de68186fadb02aa5dce90e15bde740af01fad Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 8 Dec 2009 07:08:05 +0000 Subject: [PATCH] reimplement the "list widgets on the left?" preference I'd previously complained about as an account preference --- res/layout-land/message_list_item.xml | 14 +++++++++++--- res/layout/message_list_item.xml | 19 ++++++++++++++----- res/layout/message_list_widgets.xml | 1 + res/values/strings.xml | 1 + res/xml/account_settings_preferences.xml | 7 ++++++- src/com/android/email/Account.java | 16 ++++++++++++++++ .../android/email/activity/MessageList.java | 15 +++++++++++++++ .../email/activity/setup/AccountSettings.java | 10 ++++++++++ 8 files changed, 74 insertions(+), 9 deletions(-) diff --git a/res/layout-land/message_list_item.xml b/res/layout-land/message_list_item.xml index 714c5ede1..f50cccaf0 100644 --- a/res/layout-land/message_list_item.xml +++ b/res/layout-land/message_list_item.xml @@ -6,14 +6,22 @@ android:paddingRight="1dip" android:paddingTop="2dip" android:background="@drawable/message_list_item_background"> + + - + android:layout_toLeftOf="@+id/widgets_right" /> diff --git a/res/layout/message_list_item.xml b/res/layout/message_list_item.xml index d615d1500..93591fe80 100644 --- a/res/layout/message_list_item.xml +++ b/res/layout/message_list_item.xml @@ -7,13 +7,22 @@ android:paddingTop="2dip" android:background="#999999" > + + - diff --git a/res/layout/message_list_widgets.xml b/res/layout/message_list_widgets.xml index 7b26de7f1..4a1645fde 100644 --- a/res/layout/message_list_widgets.xml +++ b/res/layout/message_list_widgets.xml @@ -1,6 +1,7 @@ Notify in status bar when mail arrives Notify in status bar while mail is checked Show combined Inbox + Show list widgets on the left Notify for mail I sent Notify even for mail sent from an account identity diff --git a/res/xml/account_settings_preferences.xml b/res/xml/account_settings_preferences.xml index 29aeb3137..7fbd18757 100644 --- a/res/xml/account_settings_preferences.xml +++ b/res/xml/account_settings_preferences.xml @@ -41,7 +41,12 @@ android:entryValues="@array/account_settings_display_count_values" android:dialogTitle="@string/account_settings_mail_display_count_label" /> - + + + + identities; public enum FolderMode @@ -92,6 +94,7 @@ public class Account implements Serializable mNotifySync = true; mVibrate = false; mNotifySelfNewMail = true; + mLeftHanded = false; mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS; mFolderSyncMode = FolderMode.FIRST_CLASS; mFolderPushMode = FolderMode.FIRST_CLASS; @@ -171,6 +174,7 @@ public class Account implements Serializable mTransportUri = Utility.base64Decode(preferences.getPreferences().getString(mUuid + ".transportUri", null)); mDescription = preferences.getPreferences().getString(mUuid + ".description", null); + mLeftHanded = preferences.getPreferences().getBoolean(mUuid + ".leftHanded", false); mAlwaysBcc = preferences.getPreferences().getString(mUuid + ".alwaysBcc", mAlwaysBcc); mAutomaticCheckIntervalMinutes = preferences.getPreferences().getInt(mUuid + ".automaticCheckIntervalMinutes", -1); @@ -430,6 +434,16 @@ public class Account implements Serializable identities.get(0).setEmail(email); } + + public boolean getLeftHanded() { + return mLeftHanded; + } + + public void setLeftHanded(boolean leftie) + { + mLeftHanded = leftie; + } + public String getAlwaysBcc() { return mAlwaysBcc; @@ -495,6 +509,7 @@ public class Account implements Serializable editor.remove(mUuid + ".name"); editor.remove(mUuid + ".email"); editor.remove(mUuid + ".alwaysBcc"); + editor.remove(mUuid + ".mLeftHanded"); editor.remove(mUuid + ".automaticCheckIntervalMinutes"); editor.remove(mUuid + ".lastAutomaticCheckTime"); editor.remove(mUuid + ".notifyNewMail"); @@ -563,6 +578,7 @@ public class Account implements Serializable editor.putString(mUuid + ".transportUri", Utility.base64Encode(mTransportUri)); editor.putString(mUuid + ".description", mDescription); editor.putString(mUuid + ".alwaysBcc", mAlwaysBcc); + editor.putBoolean(mUuid + ".leftHanded", mLeftHanded); editor.putInt(mUuid + ".automaticCheckIntervalMinutes", mAutomaticCheckIntervalMinutes); editor.putInt(mUuid + ".displayCount", mDisplayCount); editor.putLong(mUuid + ".lastAutomaticCheckTime", mLastAutomaticCheckTime); diff --git a/src/com/android/email/activity/MessageList.java b/src/com/android/email/activity/MessageList.java index ccb22cdd2..7eb4a3d22 100644 --- a/src/com/android/email/activity/MessageList.java +++ b/src/com/android/email/activity/MessageList.java @@ -31,6 +31,7 @@ import android.view.ContextMenu.ContextMenuInfo; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.ListView; +import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; @@ -148,6 +149,7 @@ public class MessageList private boolean mStartup = false; + private boolean mLeftHanded = false; private int mSelectedCount = 0; private View mBatchButtonArea; @@ -437,6 +439,8 @@ public class MessageList */ colorChipResId = colorChipResIds[mAccount.getAccountNumber() % colorChipResIds.length]; + mLeftHanded = mAccount.getLeftHanded(); + mAdapter = new MessageListAdapter(); final Object previousData = getLastNonConfigurationInstance(); @@ -1753,6 +1757,17 @@ public class MessageList { view = mInflater.inflate(R.layout.message_list_item, parent, false); view.setId(R.layout.message_list_item); + View widgetParent; + if (mLeftHanded == false ) + { + widgetParent = view.findViewById(R.id.widgets_right); + } + else { + widgetParent = view.findViewById(R.id.widgets_left); + } + View widgets = mInflater.inflate(R.layout.message_list_widgets,parent,false); + widgets.setId(R.id.widgets); + ((LinearLayout) widgetParent).addView(widgets); } diff --git a/src/com/android/email/activity/setup/AccountSettings.java b/src/com/android/email/activity/setup/AccountSettings.java index 1df5858ce..ea0f136d6 100644 --- a/src/com/android/email/activity/setup/AccountSettings.java +++ b/src/com/android/email/activity/setup/AccountSettings.java @@ -57,6 +57,8 @@ public class AccountSettings extends K9PreferenceActivity private static final String PREFERENCE_TARGET_MODE = "folder_target_mode"; private static final String PREFERENCE_DELETE_POLICY = "delete_policy"; private static final String PREFERENCE_AUTO_EXPAND_FOLDER = "account_setup_auto_expand_folder"; + private static final String PREFERENCE_LEFT_HANDED = "left_handed"; + private Account mAccount; @@ -77,6 +79,9 @@ public class AccountSettings extends K9PreferenceActivity private ListPreference mDeletePolicy; private Preference mAutoExpandFolder; + private CheckBoxPreference mLeftHanded; + + public static void actionSettings(Context context, Account account) { Intent i = new Intent(context, AccountSettings.class); @@ -233,6 +238,10 @@ public class AccountSettings extends K9PreferenceActivity mAccountDefault.setChecked( mAccount.equals(Preferences.getPreferences(this).getDefaultAccount())); + + mLeftHanded = (CheckBoxPreference) findPreference(PREFERENCE_LEFT_HANDED); + mLeftHanded.setChecked(mAccount.getLeftHanded()); + mAccountHideButtons = (ListPreference) findPreference(PREFERENCE_HIDE_BUTTONS); mAccountHideButtons.setValue("" + mAccount.getHideMessageViewButtons()); mAccountHideButtons.setSummary(mAccountHideButtons.getEntry()); @@ -351,6 +360,7 @@ public class AccountSettings extends K9PreferenceActivity mAccount.setRingtone(prefs.getString(PREFERENCE_RINGTONE, null)); mAccount.setHideMessageViewButtons(Account.HideButtons.valueOf(mAccountHideButtons.getValue())); mAccount.setAutoExpandFolderName(reverseTranslateFolder(mAutoExpandFolder.getSummary().toString())); + mAccount.setLeftHanded(mLeftHanded.isChecked()); mAccount.save(Preferences.getPreferences(this)); Email.setServicesEnabled(this); // TODO: refresh folder list here