forked from upstream-mirrors/quik
Added dialog to let user delete all failed messages
This commit is contained in:
committed by
Moez Bhatti
parent
bc4a25c417
commit
47df8e529f
+1
-1
@@ -3,7 +3,7 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.3.0'
|
classpath 'com.android.tools.build:gradle:1.2.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.util.Log;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import com.moez.QKSMS.R;
|
import com.moez.QKSMS.R;
|
||||||
import com.moez.QKSMS.data.Conversation;
|
import com.moez.QKSMS.data.Conversation;
|
||||||
|
import com.moez.QKSMS.transaction.SmsHelper;
|
||||||
import com.moez.QKSMS.ui.MainActivity;
|
import com.moez.QKSMS.ui.MainActivity;
|
||||||
import com.moez.QKSMS.ui.conversationlist.ConversationListAdapter;
|
import com.moez.QKSMS.ui.conversationlist.ConversationListAdapter;
|
||||||
import com.moez.QKSMS.ui.dialog.DefaultSmsHelper;
|
import com.moez.QKSMS.ui.dialog.DefaultSmsHelper;
|
||||||
@@ -21,6 +22,11 @@ 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>();
|
||||||
|
threadIds.add(threadId);
|
||||||
|
showDeleteFailedConversationDialog(context, threadIds);
|
||||||
|
}
|
||||||
|
|
||||||
public static void showDeleteConversationDialog(final MainActivity context, final List<Long> threadIds) {
|
public static void showDeleteConversationDialog(final MainActivity context, final List<Long> threadIds) {
|
||||||
|
|
||||||
@@ -70,4 +76,23 @@ public class DialogHelper {
|
|||||||
}).setNegativeButton(R.string.cancel, null)
|
}).setNegativeButton(R.string.cancel, null)
|
||||||
.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) {
|
||||||
|
SmsHelper.deleteFailedMessages(context);
|
||||||
|
}
|
||||||
|
}).setNegativeButton(R.string.cancel, null)
|
||||||
|
.show(context.getFragmentManager(), QKDialog.CONFIRMATION_TAG);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ 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;
|
||||||
@@ -593,6 +594,7 @@ public class Conversation {
|
|||||||
*/
|
*/
|
||||||
public synchronized boolean hasError() {
|
public synchronized boolean hasError() {
|
||||||
return mHasError;
|
return mHasError;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ public class ConversationLegacy {
|
|||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void markRead() {
|
public void markRead() {
|
||||||
|
|
||||||
new Thread() {
|
new Thread() {
|
||||||
|
|||||||
@@ -542,6 +542,33 @@ public class SmsHelper {
|
|||||||
return messages;
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Message> deleteFailedMessages(Context context) {
|
||||||
|
|
||||||
|
Log.d(TAG, "Deleting all failed messages");
|
||||||
|
|
||||||
|
List<Message> messages = new ArrayList<Message>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
cursor = context.getContentResolver().query(SMS_CONTENT_PROVIDER, new String[]{COLUMN_ID}, FAILED_SELECTION, null, sortDateDesc);
|
||||||
|
cursor.moveToFirst();
|
||||||
|
for (int i = 0; i < cursor.getCount(); i++) {
|
||||||
|
messages.add(new Message(context, cursor.getLong(cursor.getColumnIndexOrThrow(COLUMN_ID))));
|
||||||
|
cursor.moveToNext();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Message m : messages)
|
||||||
|
{
|
||||||
|
Log.d(TAG,"Deleting failed message to " + m.getName() + "\n Body: " + m.getBody());
|
||||||
|
m.delete();
|
||||||
|
}
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an SMS to the given URI.
|
* Add an SMS to the given URI.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
|||||||
private final int MENU_MARK_UNREAD = 5;
|
private final int MENU_MARK_UNREAD = 5;
|
||||||
private final int MENU_DELETE_CONVERSATION = 6;
|
private final int MENU_DELETE_CONVERSATION = 6;
|
||||||
private final int MENU_MULTI_SELECT = 7;
|
private final int MENU_MULTI_SELECT = 7;
|
||||||
|
private final int MENU_DELETE_FAILED = 8;
|
||||||
|
|
||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private FloatingActionButton mFab;
|
private FloatingActionButton mFab;
|
||||||
@@ -195,6 +196,8 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
|||||||
|
|
||||||
dialog.addMenuItem(R.string.menu_delete_conversation, MENU_DELETE_CONVERSATION);
|
dialog.addMenuItem(R.string.menu_delete_conversation, MENU_DELETE_CONVERSATION);
|
||||||
|
|
||||||
|
dialog.addMenuItem(R.string.delete_failed, MENU_DELETE_FAILED);
|
||||||
|
|
||||||
dialog.buildMenu(new AdapterView.OnItemClickListener() {
|
dialog.buildMenu(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
@@ -233,6 +236,10 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
|||||||
case MENU_DELETE_CONVERSATION:
|
case MENU_DELETE_CONVERSATION:
|
||||||
DialogHelper.showDeleteConversationDialog((MainActivity) mContext, threadId);
|
DialogHelper.showDeleteConversationDialog((MainActivity) mContext, threadId);
|
||||||
break;
|
break;
|
||||||
|
case MENU_DELETE_FAILED:
|
||||||
|
//Deletes all failed messages from all conversations
|
||||||
|
DialogHelper.showDeleteFailedConversationDialog((MainActivity) mContext, threadId);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).show(((MainActivity) mContext).getFragmentManager(), "conversation options");
|
}).show(((MainActivity) mContext).getFragmentManager(), "conversation options");
|
||||||
|
|||||||
@@ -333,8 +333,12 @@
|
|||||||
<string name="restart_message">These changes will take effect the next time QKSMS is opened</string>
|
<string name="restart_message">These changes will take effect the next time QKSMS is opened</string>
|
||||||
<!--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-->
|
||||||
|
<string name="delete_all_failed">Delete conversation</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-->
|
||||||
|
<string name="delete_all_failed_confirmation">Are you sure you would like to all failed messages? (from all conversations)</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-->
|
||||||
@@ -346,6 +350,7 @@
|
|||||||
|
|
||||||
<!-- Dialog message text explaining that a draft message will not be saved due to invalid recipients -->
|
<!-- Dialog message text explaining that a draft message will not be saved due to invalid recipients -->
|
||||||
<string name="discard_message_reason">Your message will be discarded because it has no valid recipients.</string>
|
<string name="discard_message_reason">Your message will be discarded because it has no valid recipients.</string>
|
||||||
|
<string name="delete_failed">Delete failed messages</string>
|
||||||
|
|
||||||
<string name="invalid_code">Invalid code</string>
|
<string name="invalid_code">Invalid code</string>
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,6 +3,6 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.0.1'
|
classpath 'com.android.tools.build:gradle:1.2.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user