Now only deletes failed messages of the conversation selected

This commit is contained in:
Andrew Thomas
2015-08-16 20:35:36 -05:00
committed by Moez Bhatti
parent 639747ca27
commit 00ffc716a9
8 changed files with 31 additions and 38 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.2.3' classpath 'com.android.tools.build:gradle:1.3.0'
} }
} }
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
@@ -22,10 +22,26 @@ public class DialogHelper {
threadIds.add(threadId); threadIds.add(threadId);
showDeleteConversationDialog(context, threadIds); showDeleteConversationDialog(context, threadIds);
} }
public static void showDeleteFailedConversationDialog(MainActivity context, long threadId) {
List<Long> threadIds = new ArrayList<Long>(); public static void showDeleteFailedMessagesDialog(final MainActivity context, final long threadId) {
threadIds.add(threadId); new DefaultSmsHelper(context, null, R.string.not_default_delete).showIfNotDefault(null);
showDeleteFailedConversationDialog(context, threadIds);
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<Long> threadIds) { public static void showDeleteConversationDialog(final MainActivity context, final List<Long> threadIds) {
@@ -77,26 +93,4 @@ public class DialogHelper {
.show(context.getFragmentManager(), QKDialog.CONFIRMATION_TAG); .show(context.getFragmentManager(), QKDialog.CONFIRMATION_TAG);
} }
public static void showDeleteFailedConversationDialog(final MainActivity context, final List<Long> 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);
}
} }
@@ -32,7 +32,6 @@ import com.moez.QKSMS.common.utils.AddressUtils;
import com.moez.QKSMS.common.utils.PhoneNumberUtils; import com.moez.QKSMS.common.utils.PhoneNumberUtils;
import com.moez.QKSMS.transaction.NotificationManager; import com.moez.QKSMS.transaction.NotificationManager;
import com.moez.QKSMS.transaction.SmsHelper; import com.moez.QKSMS.transaction.SmsHelper;
import com.moez.QKSMS.ui.MainActivity;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -594,7 +593,6 @@ public class Conversation {
*/ */
public synchronized boolean hasError() { public synchronized boolean hasError() {
return mHasError; return mHasError;
} }
/** /**
@@ -239,7 +239,6 @@ public class ConversationLegacy {
return ids; return ids;
} }
public void markRead() { public void markRead() {
new Thread() { new Thread() {
@@ -542,9 +542,9 @@ public class SmsHelper {
return messages; return messages;
} }
public static List<Message> deleteFailedMessages(Context context) { public static List<Message> deleteFailedMessages(Context context, long threadID) {
Log.d(TAG, "Deleting all failed messages"); Log.d(TAG, "Deleting failed messages");
List<Message> messages = new ArrayList<Message>(); List<Message> messages = new ArrayList<Message>();
@@ -563,8 +563,10 @@ public class SmsHelper {
for (Message m : messages) for (Message m : messages)
{ {
Log.d(TAG,"Deleting failed message to " + m.getName() + "\n Body: " + m.getBody()); if(m.getThreadId() == threadID) {
m.delete(); Log.d(TAG, "Deleting failed message to " + m.getName() + "\n Body: " + m.getBody());
m.delete();
}
} }
return messages; return messages;
} }
@@ -238,7 +238,7 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
break; break;
case MENU_DELETE_FAILED: case MENU_DELETE_FAILED:
//Deletes all failed messages from all conversations //Deletes all failed messages from all conversations
DialogHelper.showDeleteFailedConversationDialog((MainActivity) mContext, threadId); DialogHelper.showDeleteFailedMessagesDialog((MainActivity) mContext, threadId);
break; break;
} }
} }
+2 -2
View File
@@ -334,11 +334,11 @@
<!--Dialog title for asking if a user wants to delete a conversation--> <!--Dialog title for asking if a user wants to delete a conversation-->
<string name="delete_conversation">Delete conversation</string> <string name="delete_conversation">Delete conversation</string>
<!--Dialog title for asking if a user wants to delete all failed messages--> <!--Dialog title for asking if a user wants to delete all failed messages-->
<string name="delete_all_failed">Delete conversation</string> <string name="delete_all_failed">Delete failed messages</string>
<!--CDialog title for asking if a user wants to delete a conversation--> <!--CDialog title for asking if a user wants to delete a conversation-->
<string name="delete_confirmation">Are you sure you would like to delete the conversation?</string> <string name="delete_confirmation">Are you sure you would like to delete the conversation?</string>
<!--CDialog title for asking if a user wants to delete all failed messages--> <!--CDialog title for asking if a user wants to delete all failed messages-->
<string name="delete_all_failed_confirmation">Are you sure you would like to all failed messages? (from all conversations)</string> <string name="delete_all_failed_confirmation">Are you sure you would like to all failed messages?</string>
<!--(Unused) Dialog title shown if APNs have not been set--> <!--(Unused) Dialog title shown if APNs have not been set-->
<string name="apns_not_set">APNs not set</string> <string name="apns_not_set">APNs not set</string>
<!--(Unused) Dialog description shown if APNs have not been set--> <!--(Unused) Dialog description shown if APNs have not been set-->
+1 -1
View File
@@ -3,6 +3,6 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.2.3' classpath 'com.android.tools.build:gradle:1.3.0'
} }
} }