diff options
author | chengzhi.hou <chengzhi.hou@ck-telecom.com> | 2016-02-24 20:01:17 +0800 |
---|---|---|
committer | Martin Brabham <optedoblivion@cyngn.com> | 2016-02-29 15:42:11 -0800 |
commit | 80c9a59ac18e0676d4a4a8d73255b12672b5c094 (patch) | |
tree | 20d7562f7ab08be61cd26b0c197b556afce9bd72 | |
parent | 60ba9b62ac79f6cf5443b0a8cb6a71cf1b66dd12 (diff) | |
download | packages_apps_Messaging-80c9a59ac18e0676d4a4a8d73255b12672b5c094.tar.gz packages_apps_Messaging-80c9a59ac18e0676d4a4a8d73255b12672b5c094.tar.bz2 packages_apps_Messaging-80c9a59ac18e0676d4a4a8d73255b12672b5c094.zip |
Messaging:Swipe right to delete conversation
Change "swipe delete" to "swipe right delete", so SwipeArchive and SwipeDelete
can exist at the same time.
Change-Id: Ic03c850cecfb3546108a94e9af82eaa714b8d4e1
9 files changed, 29 insertions, 26 deletions
diff --git a/res/values/cm_constants.xml b/res/values/cm_constants.xml index b664dd0..87ed210 100644 --- a/res/values/cm_constants.xml +++ b/res/values/cm_constants.xml @@ -18,8 +18,8 @@ <!-- Preference keys for user-visible settings --> <!-- Application-wide settings --> - <string name="swipe_deletes_conversation_key" translatable="false">swipe_deletes_conversation</string> + <string name="swipe_right_deletes_conversation_key" translatable="false">swipe_right_deletes_conversation</string> <!-- This should really go into a config xml, but whoever wrote this app is an idiot, so follow their pattern --> - <bool name="swipe_deletes_conversation_default" translatable="false">false</bool> + <bool name="swipe_right_deletes_conversation_default" translatable="false">false</bool> </resources> diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 333f433..8c48b8f 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -22,7 +22,7 @@ <string name="pref_unicode_stripping_leave_intact">Leave characters intact</string> <string name="pref_unicode_stripping_non_encodable">Strip non-encodable characters</string> <string name="pref_unicode_stripping_all">Strip all unicode characters</string> - <string name="swipe_deletes_conversation_text">Swipe deletes conversation</string> + <string name="swipe_right_deletes_conversation_text">Swipe right deletes conversation</string> <!-- QUICKMESSAGE SUPPORT --> <!-- Preferences --> diff --git a/res/xml-v21/preferences_application.xml b/res/xml-v21/preferences_application.xml index d98fb10..cae8d2e 100644 --- a/res/xml-v21/preferences_application.xml +++ b/res/xml-v21/preferences_application.xml @@ -76,8 +76,8 @@ android:entryValues="@array/pref_unicode_stripping_values" /> <SwitchPreference - android:key="@string/swipe_deletes_conversation_key" - android:title="@string/swipe_deletes_conversation_text" + android:key="@string/swipe_right_deletes_conversation_key" + android:title="@string/swipe_right_deletes_conversation_text" android:defaultValue="false" android:persistent="true" /> diff --git a/res/xml-v23/preferences_application.xml b/res/xml-v23/preferences_application.xml index 210aa72..57480ac 100644 --- a/res/xml-v23/preferences_application.xml +++ b/res/xml-v23/preferences_application.xml @@ -77,8 +77,8 @@ android:entryValues="@array/pref_unicode_stripping_values" /> <SwitchPreference - android:key="@string/swipe_deletes_conversation_key" - android:title="@string/swipe_deletes_conversation_text" + android:key="@string/swipe_right_deletes_conversation_key" + android:title="@string/swipe_right_deletes_conversation_text" android:defaultValue="false" android:persistent="true" /> diff --git a/res/xml/preferences_application.xml b/res/xml/preferences_application.xml index c0d8373..2a29fe2 100644 --- a/res/xml/preferences_application.xml +++ b/res/xml/preferences_application.xml @@ -76,8 +76,8 @@ android:entryValues="@array/pref_unicode_stripping_values" /> <SwitchPreference - android:key="@string/swipe_deletes_conversation_key" - android:title="@string/swipe_deletes_conversation_text" + android:key="@string/swipe_right_deletes_conversation_key" + android:title="@string/swipe_right_deletes_conversation_text" android:defaultValue="false" android:persistent="true" /> diff --git a/src/com/android/messaging/ui/appsettings/ApplicationSettingsActivity.java b/src/com/android/messaging/ui/appsettings/ApplicationSettingsActivity.java index d41c0b4..20ffebf 100644 --- a/src/com/android/messaging/ui/appsettings/ApplicationSettingsActivity.java +++ b/src/com/android/messaging/ui/appsettings/ApplicationSettingsActivity.java @@ -98,8 +98,8 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity { private String mSmsEnabledPrefKey; private Preference mSmsEnabledPreference; private boolean mIsSmsPreferenceClicked; - private String mSwipeToDeleteConversationkey; - private SwitchPreference mSwipeToDeleteConversationPreference; + private String mSwipeRightToDeleteConversationkey; + private SwitchPreference mSwipeRightToDeleteConversationPreference; public ApplicationSettingsFragment() { // Required empty constructor @@ -124,9 +124,10 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity { mSmsDisabledPreference = findPreference(mSmsDisabledPrefKey); mSmsEnabledPrefKey = getString(R.string.sms_enabled_pref_key); mSmsEnabledPreference = findPreference(mSmsEnabledPrefKey); - mSwipeToDeleteConversationkey = getString(R.string.swipe_deletes_conversation_key); - mSwipeToDeleteConversationPreference = - (SwitchPreference) findPreference(mSwipeToDeleteConversationkey); + mSwipeRightToDeleteConversationkey = getString( + R.string.swipe_right_deletes_conversation_key); + mSwipeRightToDeleteConversationPreference = + (SwitchPreference) findPreference(mSwipeRightToDeleteConversationkey); mIsSmsPreferenceClicked = false; final SharedPreferences prefs = getPreferenceScreen().getSharedPreferences(); diff --git a/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java b/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java index 3095829..cbfc1e4 100644 --- a/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java +++ b/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java @@ -81,6 +81,8 @@ public class ConversationListItemView extends FrameLayout implements OnClickList private static String sPlusOneString; private static String sPlusNString; + private static final int SWIPE_DIRECTION_RIGHT = 2; + public interface HostInterface { boolean isConversationSelected(final String conversationId); void onConversationClicked(final ConversationListItemData conversationListItemData, @@ -520,11 +522,11 @@ public class ConversationListItemView extends FrameLayout implements OnClickList final int notificationBellVisiblity = mData.getNotificationEnabled() ? GONE : VISIBLE; mNotificationBellView.setVisibility(notificationBellVisiblity); - if (PrefsUtils.isSwipeToDeleteEnabled()) { + if (PrefsUtils.isSwipeRightToDeleteEnabled()) { mCrossSwipeArchiveLeftImageView.setImageDrawable(getResources() .getDrawable(R.drawable.ic_delete_small_dark)); mCrossSwipeArchiveRightImageView.setImageDrawable(getResources() - .getDrawable(R.drawable.ic_delete_small_dark)); + .getDrawable(R.drawable.ic_archive_small_dark)); } else { mCrossSwipeArchiveLeftImageView.setImageDrawable(getResources() .getDrawable(R.drawable.ic_archive_small_dark)); @@ -564,11 +566,11 @@ public class ConversationListItemView extends FrameLayout implements OnClickList } } - public void onSwipeComplete() { + public void onSwipeComplete(int swipeDirection) { final String conversationId = mData.getConversationId(); - if (PrefsUtils.isSwipeToDeleteEnabled()) { + if (PrefsUtils.isSwipeRightToDeleteEnabled() + && swipeDirection == ConversationListSwipeHelper.SWIPE_DIRECTION_RIGHT) { mData.deleteConversation(); - UiUtils.showToastAtBottom(R.string.conversation_deleted); return; } UpdateConversationArchiveStatusAction.archiveConversation(conversationId); diff --git a/src/com/android/messaging/ui/conversationlist/ConversationListSwipeHelper.java b/src/com/android/messaging/ui/conversationlist/ConversationListSwipeHelper.java index 4988259..ac2aeb0 100644 --- a/src/com/android/messaging/ui/conversationlist/ConversationListSwipeHelper.java +++ b/src/com/android/messaging/ui/conversationlist/ConversationListSwipeHelper.java @@ -44,9 +44,9 @@ public class ConversationListSwipeHelper implements OnItemTouchListener { private static final float PERCENTAGE_OF_WIDTH_TO_DISMISS = 0.4f; private static final float FLING_PERCENTAGE_OF_WIDTH_TO_DISMISS = 0.05f; - private static final int SWIPE_DIRECTION_NONE = 0; - private static final int SWIPE_DIRECTION_LEFT = 1; - private static final int SWIPE_DIRECTION_RIGHT = 2; + public static final int SWIPE_DIRECTION_NONE = 0; + public static final int SWIPE_DIRECTION_LEFT = 1; + public static final int SWIPE_DIRECTION_RIGHT = 2; private final RecyclerView mRecyclerView; private final long mDefaultRestoreAnimationDuration; @@ -269,7 +269,7 @@ public class ConversationListSwipeHelper implements OnItemTouchListener { private void onSwipeGestureEnd(final ConversationListItemView itemView, final int swipeDirection) { if (swipeDirection == SWIPE_DIRECTION_RIGHT || swipeDirection == SWIPE_DIRECTION_LEFT) { - itemView.onSwipeComplete(); + itemView.onSwipeComplete(swipeDirection); } // Balances out onSwipeGestureStart. diff --git a/src/com/cyanogenmod/messaging/util/PrefsUtils.java b/src/com/cyanogenmod/messaging/util/PrefsUtils.java index 7c8990d..d6e4279 100644 --- a/src/com/cyanogenmod/messaging/util/PrefsUtils.java +++ b/src/com/cyanogenmod/messaging/util/PrefsUtils.java @@ -39,12 +39,12 @@ public class PrefsUtils { * the conversation rather than archiving it. * @return hopefully true */ - public static boolean isSwipeToDeleteEnabled() { + public static boolean isSwipeRightToDeleteEnabled() { final BuglePrefs prefs = BuglePrefs.getApplicationPrefs(); final Context context = Factory.get().getApplicationContext(); - final String prefKey = context.getString(R.string.swipe_deletes_conversation_key); + final String prefKey = context.getString(R.string.swipe_right_deletes_conversation_key); final boolean defaultValue = context.getResources().getBoolean( - R.bool.swipe_deletes_conversation_default); + R.bool.swipe_right_deletes_conversation_default); return prefs.getBoolean(prefKey, defaultValue); } |