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()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
apply plugin: 'com.android.application'
@@ -22,10 +22,26 @@ public class DialogHelper {
threadIds.add(threadId);
showDeleteConversationDialog(context, threadIds);
}
public static void showDeleteFailedConversationDialog(MainActivity context, long threadId) {
List<Long> threadIds = new ArrayList<Long>();
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<Long> threadIds) {
@@ -77,26 +93,4 @@ public class DialogHelper {
.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.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;
}
/**
@@ -239,7 +239,6 @@ public class ConversationLegacy {
return ids;
}
public void markRead() {
new Thread() {
@@ -542,9 +542,9 @@ public class SmsHelper {
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>();
@@ -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;
}
@@ -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;
}
}
+2 -2
View File
@@ -334,11 +334,11 @@
<!--Dialog title for asking if a user wants to delete a conversation-->
<string name="delete_conversation">Delete conversation</string>
<!--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-->
<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-->
<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-->
<string name="apns_not_set">APNs not set</string>
<!--(Unused) Dialog description shown if APNs have not been set-->
+1 -1
View File
@@ -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'
}
}