diff options
-rw-r--r-- | res/layout/conversation_list_item_view.xml | 2 | ||||
-rw-r--r-- | res/values/cm_constants.xml | 25 | ||||
-rw-r--r-- | res/values/cm_strings.xml | 19 | ||||
-rw-r--r-- | res/xml-v21/preferences_application.xml | 6 | ||||
-rw-r--r-- | res/xml-v23/preferences_application.xml | 6 | ||||
-rw-r--r-- | res/xml/preferences_application.xml | 6 | ||||
-rw-r--r-- | src/com/android/messaging/ui/appsettings/ApplicationSettingsActivity.java | 6 | ||||
-rw-r--r-- | src/com/android/messaging/ui/conversationlist/ConversationListItemView.java | 19 | ||||
-rw-r--r-- | src/com/cyanogenmod/messaging/util/PrefsUtils.java | 42 |
9 files changed, 128 insertions, 3 deletions
diff --git a/res/layout/conversation_list_item_view.xml b/res/layout/conversation_list_item_view.xml index 636616b..43cb3ee 100644 --- a/res/layout/conversation_list_item_view.xml +++ b/res/layout/conversation_list_item_view.xml @@ -37,7 +37,6 @@ android:layout_height="wrap_content" android:gravity="center_vertical|left" android:visibility="gone" - android:src="@drawable/ic_archive_small_dark" android:importantForAccessibility="no" android:contentDescription="@null"/> <FrameLayout @@ -50,7 +49,6 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical|right" android:visibility="gone" - android:src="@drawable/ic_archive_small_dark" android:importantForAccessibility="no" android:contentDescription="@null"/> </LinearLayout> diff --git a/res/values/cm_constants.xml b/res/values/cm_constants.xml new file mode 100644 index 0000000..b664dd0 --- /dev/null +++ b/res/values/cm_constants.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2016 The CyanogenMod Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<resources> + + <!-- Preference keys for user-visible settings --> + <!-- Application-wide settings --> + <string name="swipe_deletes_conversation_key" translatable="false">swipe_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> +</resources> diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml new file mode 100644 index 0000000..7759e77 --- /dev/null +++ b/res/values/cm_strings.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2015 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="swipe_deletes_conversation_text">Swipe deletes conversation</string> +</resources> diff --git a/res/xml-v21/preferences_application.xml b/res/xml-v21/preferences_application.xml index 5d8ee4c..374b1d2 100644 --- a/res/xml-v21/preferences_application.xml +++ b/res/xml-v21/preferences_application.xml @@ -66,6 +66,12 @@ android:persistent="true" android:dependency="@string/notifications_enabled_pref_key" /> + <SwitchPreference + android:key="@string/swipe_deletes_conversation_key" + android:title="@string/swipe_deletes_conversation_text" + android:defaultValue="false" + android:persistent="true" /> + <PreferenceScreen android:key="@string/advanced_pref_key" android:title="@string/advanced_settings" /> diff --git a/res/xml-v23/preferences_application.xml b/res/xml-v23/preferences_application.xml index 8fbadc4..c6b934a 100644 --- a/res/xml-v23/preferences_application.xml +++ b/res/xml-v23/preferences_application.xml @@ -67,6 +67,12 @@ android:persistent="true" android:dependency="@string/notifications_enabled_pref_key" /> + <SwitchPreference + android:key="@string/swipe_deletes_conversation_key" + android:title="@string/swipe_deletes_conversation_text" + android:defaultValue="false" + android:persistent="true" /> + <PreferenceScreen android:key="@string/advanced_pref_key" android:title="@string/advanced_settings" /> diff --git a/res/xml/preferences_application.xml b/res/xml/preferences_application.xml index 7a18d09..f9895d0 100644 --- a/res/xml/preferences_application.xml +++ b/res/xml/preferences_application.xml @@ -66,6 +66,12 @@ android:persistent="true" android:dependency="@string/notifications_enabled_pref_key" /> + <SwitchPreference + android:key="@string/swipe_deletes_conversation_key" + android:title="@string/swipe_deletes_conversation_text" + android:defaultValue="false" + android:persistent="true" /> + <PreferenceScreen android:key="@string/advanced_pref_key" android:title="@string/advanced_settings" /> diff --git a/src/com/android/messaging/ui/appsettings/ApplicationSettingsActivity.java b/src/com/android/messaging/ui/appsettings/ApplicationSettingsActivity.java index 906009f..d41c0b4 100644 --- a/src/com/android/messaging/ui/appsettings/ApplicationSettingsActivity.java +++ b/src/com/android/messaging/ui/appsettings/ApplicationSettingsActivity.java @@ -28,6 +28,7 @@ import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceScreen; import android.preference.RingtonePreference; +import android.preference.SwitchPreference; import android.preference.TwoStatePreference; import android.provider.Settings; import android.support.v4.app.NavUtils; @@ -97,6 +98,8 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity { private String mSmsEnabledPrefKey; private Preference mSmsEnabledPreference; private boolean mIsSmsPreferenceClicked; + private String mSwipeToDeleteConversationkey; + private SwitchPreference mSwipeToDeleteConversationPreference; public ApplicationSettingsFragment() { // Required empty constructor @@ -121,6 +124,9 @@ 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); 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 6b02eb3..8261159 100644 --- a/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java +++ b/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java @@ -58,6 +58,7 @@ import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.Typefaces; import com.android.messaging.util.UiUtils; import com.android.messaging.util.UriUtil; +import com.cyanogenmod.messaging.util.PrefsUtils; import java.util.List; @@ -502,6 +503,18 @@ public class ConversationListItemView extends FrameLayout implements OnClickList final int notificationBellVisiblity = mData.getNotificationEnabled() ? GONE : VISIBLE; mNotificationBellView.setVisibility(notificationBellVisiblity); + + if (PrefsUtils.isSwipeToDeleteEnabled()) { + mCrossSwipeArchiveLeftImageView.setImageDrawable(getResources() + .getDrawable(R.drawable.ic_delete_small_dark)); + mCrossSwipeArchiveRightImageView.setImageDrawable(getResources() + .getDrawable(R.drawable.ic_delete_small_dark)); + } else { + mCrossSwipeArchiveLeftImageView.setImageDrawable(getResources() + .getDrawable(R.drawable.ic_archive_small_dark)); + mCrossSwipeArchiveRightImageView.setImageDrawable(getResources() + .getDrawable(R.drawable.ic_archive_small_dark)); + } } public boolean isSwipeAnimatable() { @@ -537,8 +550,12 @@ public class ConversationListItemView extends FrameLayout implements OnClickList public void onSwipeComplete() { final String conversationId = mData.getConversationId(); + if (PrefsUtils.isSwipeToDeleteEnabled()) { + mData.deleteConversation(); + UiUtils.showToastAtBottom(R.string.conversation_deleted); + return; + } UpdateConversationArchiveStatusAction.archiveConversation(conversationId); - final Runnable undoRunnable = new Runnable() { @Override public void run() { diff --git a/src/com/cyanogenmod/messaging/util/PrefsUtils.java b/src/com/cyanogenmod/messaging/util/PrefsUtils.java new file mode 100644 index 0000000..9df56b0 --- /dev/null +++ b/src/com/cyanogenmod/messaging/util/PrefsUtils.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2016 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.cyanogenmod.messaging.util; + +import android.content.Context; +import com.android.messaging.Factory; +import com.android.messaging.R; +import com.android.messaging.util.BuglePrefs; + +public class PrefsUtils { + private PrefsUtils() { + //Don't instantiate + } + + /** + * Returns whether or not swipe to dismiss in the ConversationListFragment deletes + * the conversation rather than archiving it. + * @return hopefully true + */ + public static boolean isSwipeToDeleteEnabled() { + final BuglePrefs prefs = BuglePrefs.getApplicationPrefs(); + final Context context = Factory.get().getApplicationContext(); + final String prefKey = context.getString(R.string.swipe_deletes_conversation_key); + final boolean defaultValue = context.getResources().getBoolean( + R.bool.swipe_deletes_conversation_default); + return prefs.getBoolean(prefKey, defaultValue); + } +} |