Migrate "show sender image" to UnifiedEmail
Bug: 9497358 Change-Id: Iefe39052fb7d53de02535ef98b45c66f1f918209
This commit is contained in:
parent
dc1160e4c3
commit
ccf730fbe5
@ -193,14 +193,12 @@ public class Preferences {
|
||||
mSharedPreferences.edit().putInt(AUTO_ADVANCE_DIRECTION, direction).apply();
|
||||
}
|
||||
|
||||
/** @deprecated Only used for migration */
|
||||
@Deprecated
|
||||
public String getConversationListIcon() {
|
||||
return mSharedPreferences.getString(CONV_LIST_ICON, CONV_LIST_ICON_SENDER_IMAGE);
|
||||
}
|
||||
|
||||
public void setConversationListIcon(String value) {
|
||||
mSharedPreferences.edit().putString(CONV_LIST_ICON, value).apply();
|
||||
}
|
||||
|
||||
public boolean getConfirmDelete() {
|
||||
return mSharedPreferences.getBoolean(CONFIRM_DELETE, CONFIRM_DELETE_DEFAULT);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
@ -108,7 +109,9 @@ public class GeneralPreferences extends EmailPreferenceFragment implements
|
||||
mMailPrefs.setDefaultReplyAll((Boolean) newValue);
|
||||
return true;
|
||||
} else if (PREFERENCE_KEY_CONV_LIST_ICON.equals(key)) {
|
||||
mPreferences.setConversationListIcon((String) newValue);
|
||||
// TODO: Fix this to use a checkbox, instead of a list
|
||||
mMailPrefs.setShowSenderImages(
|
||||
TextUtils.equals((String)newValue, Preferences.CONV_LIST_ICON_SENDER_IMAGE));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -149,7 +152,10 @@ public class GeneralPreferences extends EmailPreferenceFragment implements
|
||||
|
||||
mConvListIcon = (ListPreference) findPreference(PREFERENCE_KEY_CONV_LIST_ICON);
|
||||
if (mConvListIcon != null) {
|
||||
mConvListIcon.setValue(mPreferences.getConversationListIcon());
|
||||
// TODO: Fix this to use a checkbox, instead of a list
|
||||
final boolean showSenderImage = mMailPrefs.getShowSenderImages();
|
||||
mConvListIcon.setValue(showSenderImage ?
|
||||
Preferences.CONV_LIST_ICON_SENDER_IMAGE : Preferences.CONV_LIST_ICON_NONE);
|
||||
mConvListIcon.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
|
@ -2568,9 +2568,8 @@ public class EmailProvider extends ContentProvider {
|
||||
}
|
||||
if (projectionColumns.contains(
|
||||
UIProvider.AccountColumns.SettingsColumns.CONV_LIST_ICON)) {
|
||||
String convListIcon = prefs.getConversationListIcon();
|
||||
values.put(UIProvider.AccountColumns.SettingsColumns.CONV_LIST_ICON,
|
||||
convListIconToUiValue(convListIcon));
|
||||
getConversationListIcon(mailPrefs));
|
||||
}
|
||||
if (projectionColumns.contains(UIProvider.AccountColumns.SettingsColumns.AUTO_ADVANCE)) {
|
||||
int autoAdvance = prefs.getAutoAdvanceDirection();
|
||||
@ -2676,16 +2675,6 @@ public class EmailProvider extends ContentProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private static int convListIconToUiValue(String convListIcon) {
|
||||
if (Preferences.CONV_LIST_ICON_SENDER_IMAGE.equals(convListIcon)) {
|
||||
return UIProvider.ConversationListIcon.SENDER_IMAGE;
|
||||
} else if (Preferences.CONV_LIST_ICON_NONE.equals(convListIcon)) {
|
||||
return UIProvider.ConversationListIcon.NONE;
|
||||
} else {
|
||||
return UIProvider.ConversationListIcon.DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a Uri string for a combined mailbox uri
|
||||
* @param type the uri command type (e.g. "uimessages")
|
||||
@ -2811,7 +2800,7 @@ public class EmailProvider extends ContentProvider {
|
||||
}
|
||||
if (colPosMap.containsKey(UIProvider.AccountColumns.SettingsColumns.CONV_LIST_ICON)) {
|
||||
values[colPosMap.get(UIProvider.AccountColumns.SettingsColumns.CONV_LIST_ICON)] =
|
||||
convListIconToUiValue(prefs.getConversationListIcon());
|
||||
getConversationListIcon(mailPrefs);
|
||||
}
|
||||
if (colPosMap.containsKey(UIProvider.AccountColumns.SettingsColumns.CONFIRM_DELETE)) {
|
||||
values[colPosMap.get(UIProvider.AccountColumns.SettingsColumns.CONFIRM_DELETE)] =
|
||||
@ -2837,6 +2826,12 @@ public class EmailProvider extends ContentProvider {
|
||||
mc.addRow(values);
|
||||
}
|
||||
|
||||
private int getConversationListIcon(MailPrefs mailPrefs) {
|
||||
return mailPrefs.getShowSenderImages() ?
|
||||
UIProvider.ConversationListIcon.SENDER_IMAGE :
|
||||
UIProvider.ConversationListIcon.NONE;
|
||||
}
|
||||
|
||||
private Cursor getVirtualMailboxCursor(long mailboxId) {
|
||||
MatrixCursor mc = new MatrixCursorWithCachedColumns(UIProvider.FOLDERS_PROJECTION, 1);
|
||||
mc.addRow(getVirtualMailboxRow(getVirtualMailboxAccountId(mailboxId),
|
||||
|
@ -20,6 +20,7 @@ import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.email.Preferences;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
@ -147,5 +148,12 @@ public class PreferenceMigrator extends BasePreferenceMigrator {
|
||||
mailPrefs.setSenderWhitelist(whitelistedAddresses);
|
||||
}
|
||||
|
||||
if (oldVersion < 3) {
|
||||
@SuppressWarnings("deprecation")
|
||||
// The default for the conversation list icon is the sender image.
|
||||
final boolean showSenderImages = !TextUtils.equals(
|
||||
Preferences.CONV_LIST_ICON_NONE, preferences.getConversationListIcon());
|
||||
mailPrefs.setShowSenderImages(showSenderImages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user