Use swipe preference for archive/delete action
Since some people prefer delete over archive, we will use their conversation list swipe preference to determine whether to show a "Delete" action or an "Archive"/"Remove label" action. "Delete" will be shown if they have selected "Always delete" UR9 version of I4eb0d408474a9f613cc4267c3851cc7277a22ebd Change-Id: Ia2f1382b88c1ee6f64e864cb8b780d02821b673d
This commit is contained in:
parent
82eadd601a
commit
2f9c66d08b
@ -63,8 +63,8 @@
|
||||
android:summary="@string/general_preference_reply_all_summary" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="swipe_delete"
|
||||
android:persistent="true"
|
||||
android:key="conversation-list-swipe-action"
|
||||
android:persistent="false"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/general_preference_swipe_delete_label"
|
||||
android:summary="@string/general_preference_swipe_delete_summary" />
|
||||
|
@ -53,6 +53,7 @@ public class Preferences {
|
||||
private static final String REQUIRE_MANUAL_SYNC_DIALOG_SHOWN = "requireManualSyncDialogShown";
|
||||
private static final String CONFIRM_DELETE = "confirm_delete";
|
||||
private static final String CONFIRM_SEND = "confirm_send";
|
||||
@Deprecated
|
||||
private static final String SWIPE_DELETE = "swipe_delete";
|
||||
private static final String SHOW_CHECKBOXES = "show_checkboxes";
|
||||
|
||||
@ -64,7 +65,6 @@ public class Preferences {
|
||||
private static final boolean CONFIRM_DELETE_DEFAULT = false;
|
||||
private static final boolean CONFIRM_SEND_DEFAULT = false;
|
||||
private static final boolean SHOW_CHECKBOXES_DEFAULT = false;
|
||||
private static final boolean SWIPE_DELETE_DEFAULT = true;
|
||||
|
||||
// The following constants are used as offsets into R.array.general_preference_text_zoom_size.
|
||||
public static final int TEXT_ZOOM_TINY = 0;
|
||||
@ -217,12 +217,16 @@ public class Preferences {
|
||||
mSharedPreferences.edit().putBoolean(CONFIRM_SEND, set).apply();
|
||||
}
|
||||
|
||||
public boolean getSwipeDelete() {
|
||||
return mSharedPreferences.getBoolean(SWIPE_DELETE, SWIPE_DELETE_DEFAULT);
|
||||
/** @deprecated Only used for migration */
|
||||
@Deprecated
|
||||
public boolean hasSwipeDelete() {
|
||||
return mSharedPreferences.contains(SWIPE_DELETE);
|
||||
}
|
||||
|
||||
public void setSwipeDelete(boolean set) {
|
||||
mSharedPreferences.edit().putBoolean(SWIPE_DELETE, set).apply();
|
||||
/** @deprecated Only used for migration */
|
||||
@Deprecated
|
||||
public boolean getSwipeDelete() {
|
||||
return mSharedPreferences.getBoolean(SWIPE_DELETE, false);
|
||||
}
|
||||
|
||||
public int getTextZoom() {
|
||||
|
@ -39,7 +39,6 @@ public class GeneralPreferences extends EmailPreferenceFragment implements
|
||||
private static final String PREFERENCE_KEY_TEXT_ZOOM = "text_zoom";
|
||||
private static final String PREFERENCE_KEY_CONFIRM_DELETE = "confirm_delete";
|
||||
private static final String PREFERENCE_KEY_CONFIRM_SEND = "confirm_send";
|
||||
private static final String PREFERENCE_KEY_SWIPE_DELETE = "swipe_delete";
|
||||
private static final String PREFERENCE_KEY_SHOW_CHECKBOXES = "show_checkboxes";
|
||||
private static final String PREFERENCE_KEY_CLEAR_TRUSTED_SENDERS = "clear_trusted_senders";
|
||||
|
||||
@ -139,8 +138,11 @@ public class GeneralPreferences extends EmailPreferenceFragment implements
|
||||
} else if (PREFERENCE_KEY_SHOW_CHECKBOXES.equals(key)) {
|
||||
mPreferences.setShowCheckboxes(mShowCheckboxes.isChecked());
|
||||
return true;
|
||||
} else if (PREFERENCE_KEY_SWIPE_DELETE.equals(key)) {
|
||||
mPreferences.setSwipeDelete(mSwipeDelete.isChecked());
|
||||
} else if (MailPrefs.PreferenceKeys.CONVERSATION_LIST_SWIPE_ACTION.equals(key)) {
|
||||
mMailPrefs
|
||||
.setConversationListSwipeAction(mSwipeDelete.isChecked()
|
||||
? MailPrefs.ConversationListSwipeActions.DELETE
|
||||
: MailPrefs.ConversationListSwipeActions.DISABLED);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -161,7 +163,10 @@ public class GeneralPreferences extends EmailPreferenceFragment implements
|
||||
mConfirmDelete = (CheckBoxPreference) findPreference(PREFERENCE_KEY_CONFIRM_DELETE);
|
||||
mConfirmSend = (CheckBoxPreference) findPreference(PREFERENCE_KEY_CONFIRM_SEND);
|
||||
mShowCheckboxes = (CheckBoxPreference) findPreference(PREFERENCE_KEY_SHOW_CHECKBOXES);
|
||||
mSwipeDelete = (CheckBoxPreference) findPreference(PREFERENCE_KEY_SWIPE_DELETE);
|
||||
mSwipeDelete = (CheckBoxPreference)
|
||||
findPreference(MailPrefs.PreferenceKeys.CONVERSATION_LIST_SWIPE_ACTION);
|
||||
mSwipeDelete.setChecked(MailPrefs.ConversationListSwipeActions.DELETE.equals(
|
||||
mMailPrefs.getConversationListSwipeAction(false)));
|
||||
|
||||
final Preference replyAllPreference =
|
||||
findPreference(MailPrefs.PreferenceKeys.DEFAULT_REPLY_ALL);
|
||||
|
@ -78,6 +78,7 @@ import com.android.emailcommon.service.SearchParams;
|
||||
import com.android.emailcommon.utility.AttachmentUtilities;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
import com.android.ex.photo.provider.PhotoContract;
|
||||
import com.android.mail.preferences.MailPrefs;
|
||||
import com.android.mail.providers.Folder;
|
||||
import com.android.mail.providers.FolderList;
|
||||
import com.android.mail.providers.UIProvider;
|
||||
@ -2786,6 +2787,7 @@ outer:
|
||||
}
|
||||
|
||||
final Preferences prefs = Preferences.getPreferences(getContext());
|
||||
final MailPrefs mailPrefs = MailPrefs.get(getContext());
|
||||
if (projectionColumns.contains(UIProvider.AccountColumns.SettingsColumns.CONFIRM_DELETE)) {
|
||||
values.put(UIProvider.AccountColumns.SettingsColumns.CONFIRM_DELETE,
|
||||
prefs.getConfirmDelete() ? "1" : "0");
|
||||
@ -2796,7 +2798,9 @@ outer:
|
||||
}
|
||||
if (projectionColumns.contains(UIProvider.AccountColumns.SettingsColumns.SWIPE)) {
|
||||
values.put(UIProvider.AccountColumns.SettingsColumns.SWIPE,
|
||||
prefs.getSwipeDelete() ? SWIPE_DELETE : SWIPE_DISABLED);
|
||||
MailPrefs.ConversationListSwipeActions.DELETE.equals(mailPrefs
|
||||
.getConversationListSwipeAction(false))
|
||||
? SWIPE_DELETE : SWIPE_DISABLED);
|
||||
}
|
||||
if (projectionColumns.contains(
|
||||
UIProvider.AccountColumns.SettingsColumns.SHOW_CHECKBOXES)) {
|
||||
|
@ -21,6 +21,7 @@ import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.android.email.Preferences;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.mail.providers.Account;
|
||||
import com.android.mail.providers.Folder;
|
||||
@ -65,7 +66,20 @@ public class PreferenceMigrator extends BasePreferenceMigrator {
|
||||
protected static void migrate(final Context context, final int oldVersion, final int newVersion,
|
||||
final List<Account> accounts) {
|
||||
if (oldVersion < 1) {
|
||||
// No global settings to move yet
|
||||
// Move global settings
|
||||
final Preferences preferences = Preferences.getPreferences(context);
|
||||
final MailPrefs mailPrefs = MailPrefs.get(context);
|
||||
|
||||
android.os.Debug.waitForDebugger();
|
||||
@SuppressWarnings("deprecation")
|
||||
final boolean hasSwipeDelete = preferences.hasSwipeDelete();
|
||||
if (hasSwipeDelete) {
|
||||
@SuppressWarnings("deprecation")
|
||||
final String swipeAction =
|
||||
preferences.getSwipeDelete() ? MailPrefs.ConversationListSwipeActions.DELETE
|
||||
: MailPrefs.ConversationListSwipeActions.DISABLED;
|
||||
mailPrefs.setConversationListSwipeAction(swipeAction);
|
||||
}
|
||||
|
||||
// Move folder notification settings
|
||||
for (final Account account : accounts) {
|
||||
|
Loading…
Reference in New Issue
Block a user