From 00ffc716a94d944e523cd9ab6cefd802bb8c4622 Mon Sep 17 00:00:00 2001 From: Andrew Thomas Date: Sun, 16 Aug 2015 20:35:36 -0500 Subject: [PATCH] Now only deletes failed messages of the conversation selected --- QKSMS/build.gradle | 2 +- .../com/moez/QKSMS/common/DialogHelper.java | 46 ++++++++----------- .../com/moez/QKSMS/data/Conversation.java | 2 - .../moez/QKSMS/data/ConversationLegacy.java | 1 - .../com/moez/QKSMS/transaction/SmsHelper.java | 10 ++-- .../ConversationListFragment.java | 2 +- QKSMS/src/main/res/values/strings.xml | 4 +- build.gradle | 2 +- 8 files changed, 31 insertions(+), 38 deletions(-) diff --git a/QKSMS/build.gradle b/QKSMS/build.gradle index de479764..52c50486 100644 --- a/QKSMS/build.gradle +++ b/QKSMS/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' } } apply plugin: 'com.android.application' diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/DialogHelper.java b/QKSMS/src/main/java/com/moez/QKSMS/common/DialogHelper.java index 567e225d..f7db2b48 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/DialogHelper.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/DialogHelper.java @@ -22,10 +22,26 @@ public class DialogHelper { threadIds.add(threadId); showDeleteConversationDialog(context, threadIds); } - public static void showDeleteFailedConversationDialog(MainActivity context, long threadId) { - List threadIds = new ArrayList(); - threadIds.add(threadId); - showDeleteFailedConversationDialog(context, threadIds); + + public static void showDeleteFailedMessagesDialog(final MainActivity context, final long threadId) { + new DefaultSmsHelper(context, null, R.string.not_default_delete).showIfNotDefault(null); + + new QKDialog() + .setContext(context) + .setTitle(R.string.delete_all_failed) + .setMessage(R.string.delete_all_failed_confirmation) + .setPositiveButton(R.string.yes, new View.OnClickListener() { + + @Override + public void onClick(View v) { + new Thread(new Runnable() { + public void run() { + SmsHelper.deleteFailedMessages(context, threadId); + } + }).start(); + } + }).setNegativeButton(R.string.cancel, null) + .show(context.getFragmentManager(), QKDialog.CONFIRMATION_TAG); } public static void showDeleteConversationDialog(final MainActivity context, final List threadIds) { @@ -77,26 +93,4 @@ public class DialogHelper { .show(context.getFragmentManager(), QKDialog.CONFIRMATION_TAG); } - public static void showDeleteFailedConversationDialog(final MainActivity context, final List threadIds) { - - new DefaultSmsHelper(context, null, R.string.not_default_delete).showIfNotDefault(null); - - new QKDialog() - .setContext(context) - .setTitle(R.string.delete_all_failed) - .setMessage(R.string.delete_all_failed_confirmation) - .setPositiveButton(R.string.yes, new View.OnClickListener() { - - @Override - public void onClick(View v) { - new Thread(new Runnable() { - public void run() { - SmsHelper.deleteFailedMessages(context); - } - }).start(); - } - }).setNegativeButton(R.string.cancel, null) - .show(context.getFragmentManager(), QKDialog.CONFIRMATION_TAG); - - } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/data/Conversation.java b/QKSMS/src/main/java/com/moez/QKSMS/data/Conversation.java index bb5ef824..7cc9b78a 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/data/Conversation.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/data/Conversation.java @@ -32,7 +32,6 @@ import com.moez.QKSMS.common.utils.AddressUtils; import com.moez.QKSMS.common.utils.PhoneNumberUtils; import com.moez.QKSMS.transaction.NotificationManager; import com.moez.QKSMS.transaction.SmsHelper; -import com.moez.QKSMS.ui.MainActivity; import java.util.ArrayList; import java.util.Collection; @@ -594,7 +593,6 @@ public class Conversation { */ public synchronized boolean hasError() { return mHasError; - } /** diff --git a/QKSMS/src/main/java/com/moez/QKSMS/data/ConversationLegacy.java b/QKSMS/src/main/java/com/moez/QKSMS/data/ConversationLegacy.java index 126f107a..462099f1 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/data/ConversationLegacy.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/data/ConversationLegacy.java @@ -239,7 +239,6 @@ public class ConversationLegacy { return ids; } - public void markRead() { new Thread() { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/transaction/SmsHelper.java b/QKSMS/src/main/java/com/moez/QKSMS/transaction/SmsHelper.java index bda9ec2f..f7213f25 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/transaction/SmsHelper.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/transaction/SmsHelper.java @@ -542,9 +542,9 @@ public class SmsHelper { return messages; } - public static List deleteFailedMessages(Context context) { + public static List deleteFailedMessages(Context context, long threadID) { - Log.d(TAG, "Deleting all failed messages"); + Log.d(TAG, "Deleting failed messages"); List messages = new ArrayList(); @@ -563,8 +563,10 @@ public class SmsHelper { for (Message m : messages) { - Log.d(TAG,"Deleting failed message to " + m.getName() + "\n Body: " + m.getBody()); - m.delete(); + if(m.getThreadId() == threadID) { + Log.d(TAG, "Deleting failed message to " + m.getName() + "\n Body: " + m.getBody()); + m.delete(); + } } return messages; } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListFragment.java index c8743390..967a08fe 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListFragment.java @@ -238,7 +238,7 @@ public class ConversationListFragment extends QKFragment implements LoaderManage break; case MENU_DELETE_FAILED: //Deletes all failed messages from all conversations - DialogHelper.showDeleteFailedConversationDialog((MainActivity) mContext, threadId); + DialogHelper.showDeleteFailedMessagesDialog((MainActivity) mContext, threadId); break; } } diff --git a/QKSMS/src/main/res/values/strings.xml b/QKSMS/src/main/res/values/strings.xml index 78d174e4..25839024 100644 --- a/QKSMS/src/main/res/values/strings.xml +++ b/QKSMS/src/main/res/values/strings.xml @@ -334,11 +334,11 @@ Delete conversation - Delete conversation + Delete failed messages Are you sure you would like to delete the conversation? - Are you sure you would like to all failed messages? (from all conversations) + Are you sure you would like to all failed messages? APNs not set diff --git a/build.gradle b/build.gradle index 37dd7865..58264c23 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,6 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' } }