Search in sources :

Example 1 with DefaultSmsHelper

use of com.moez.QKSMS.ui.dialog.DefaultSmsHelper in project qksms by moezbhatti.

the class DialogHelper method showDeleteFailedMessagesDialog.

public static void showDeleteFailedMessagesDialog(final MainActivity context, final Set<Long> threadIds) {
    new DefaultSmsHelper(context, R.string.not_default_delete).showIfNotDefault(null);
    // Make a copy so the list isn't reset when multi-select is disabled
    Set<Long> threads = new HashSet<>(threadIds);
    new QKDialog().setContext(context).setTitle(R.string.delete_all_failed).setMessage(context.getString(R.string.delete_all_failed_confirmation, threads.size())).setPositiveButton(R.string.yes, v -> {
        new Thread(() -> {
            for (long threadId : threads) {
                SmsHelper.deleteFailedMessages(context, threadId);
            }
        }).start();
    }).setNegativeButton(R.string.cancel, null).show();
}
Also used : QKDialog(com.moez.QKSMS.ui.dialog.QKDialog) DefaultSmsHelper(com.moez.QKSMS.ui.dialog.DefaultSmsHelper) HashSet(java.util.HashSet)

Example 2 with DefaultSmsHelper

use of com.moez.QKSMS.ui.dialog.DefaultSmsHelper in project qksms by moezbhatti.

the class ConversationLegacy method markUnread.

public void markUnread() {
    new DefaultSmsHelper(context, R.string.not_default_mark_unread).showIfNotDefault(null);
    try {
        cursor = context.getContentResolver().query(getUri(), MessageColumns.PROJECTION, null, null, SmsHelper.sortDateDesc);
        cursor.moveToFirst();
        MessageColumns.ColumnsMap columnsMap = new MessageColumns.ColumnsMap(cursor);
        MessageItem message = new MessageItem(context, cursor.getString(columnsMap.mColumnMsgType), cursor, columnsMap, null, true);
        if (message.isMe()) {
            while (cursor.moveToNext()) {
                MessageItem message2 = new MessageItem(context, cursor.getString(columnsMap.mColumnMsgType), cursor, columnsMap, null, true);
                if (!message2.isMe()) {
                    message = message2;
                    break;
                }
            }
        }
        ContentValues cv = new ContentValues();
        cv.put("read", false);
        cv.put("seen", false);
        context.getContentResolver().update(message.mMessageUri, cv, null, null);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    NotificationManager.create(context);
}
Also used : MessageItem(com.moez.QKSMS.ui.messagelist.MessageItem) ContentValues(android.content.ContentValues) DefaultSmsHelper(com.moez.QKSMS.ui.dialog.DefaultSmsHelper) MessageColumns(com.moez.QKSMS.ui.messagelist.MessageColumns)

Example 3 with DefaultSmsHelper

use of com.moez.QKSMS.ui.dialog.DefaultSmsHelper in project qksms by moezbhatti.

the class MessageListActivity method onActivityResult.

/**
 * When In-App billing is done, it'll return information via onActivityResult().
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ConversationSettingsDialog.RINGTONE_REQUEST_CODE) {
        if (data != null) {
            if (mWaitingForThreadId > 0) {
                ConversationPrefsHelper conversationPrefs = new ConversationPrefsHelper(this, mWaitingForThreadId);
                Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
                conversationPrefs.putString(SettingsFragment.NOTIFICATION_TONE, (uri == null) ? "" : uri.toString());
                mWaitingForThreadId = -1;
            }
        }
    } else if (requestCode == WelcomeActivity.WELCOME_REQUEST_CODE) {
        new DefaultSmsHelper(this, R.string.not_default_first).showIfNotDefault(null);
    }
}
Also used : DefaultSmsHelper(com.moez.QKSMS.ui.dialog.DefaultSmsHelper) Uri(android.net.Uri) ConversationPrefsHelper(com.moez.QKSMS.common.ConversationPrefsHelper)

Example 4 with DefaultSmsHelper

use of com.moez.QKSMS.ui.dialog.DefaultSmsHelper in project qksms by moezbhatti.

the class ConversationLegacy method delete.

public void delete() {
    // TODO do this using AsyncQueryHandler
    new DefaultSmsHelper(context, R.string.not_default_delete).showIfNotDefault(null);
    new AsyncTask<Void, Void, Void>() {

        @Override
        protected Void doInBackground(Void... params) {
            SqliteWrapper.delete(context, context.getContentResolver(), getUri(), null, null);
            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            super.onPostExecute(aVoid);
            Toast.makeText(context, R.string.toast_conversation_deleted, Toast.LENGTH_SHORT).show();
        }
    }.execute((Void[]) null);
}
Also used : DefaultSmsHelper(com.moez.QKSMS.ui.dialog.DefaultSmsHelper)

Example 5 with DefaultSmsHelper

use of com.moez.QKSMS.ui.dialog.DefaultSmsHelper in project qksms by moezbhatti.

the class DialogHelper method showDeleteConversationsDialog.

public static void showDeleteConversationsDialog(final QKActivity context, final Set<Long> threadIds) {
    new DefaultSmsHelper(context, R.string.not_default_delete).showIfNotDefault(null);
    // Make a copy so the list isn't reset when multi-select is disabled
    Set<Long> threads = new HashSet<>(threadIds);
    new QKDialog().setContext(context).setTitle(R.string.delete_conversation).setMessage(context.getString(R.string.delete_confirmation, threads.size())).setPositiveButton(R.string.yes, v -> {
        Log.d(TAG, "Deleting threads: " + Arrays.toString(threads.toArray()));
        Conversation.ConversationQueryHandler handler = new Conversation.ConversationQueryHandler(context.getContentResolver(), context);
        Conversation.startDelete(handler, 0, false, threads);
        Conversation.asyncDeleteObsoleteThreads(handler, 0);
        if (context instanceof MessageListActivity) {
            context.onBackPressed();
        }
    }).setNegativeButton(R.string.cancel, null).show();
}
Also used : MessageListActivity(com.moez.QKSMS.ui.messagelist.MessageListActivity) QKDialog(com.moez.QKSMS.ui.dialog.QKDialog) DefaultSmsHelper(com.moez.QKSMS.ui.dialog.DefaultSmsHelper) Conversation(com.moez.QKSMS.data.Conversation) HashSet(java.util.HashSet)

Aggregations

DefaultSmsHelper (com.moez.QKSMS.ui.dialog.DefaultSmsHelper)5 QKDialog (com.moez.QKSMS.ui.dialog.QKDialog)2 HashSet (java.util.HashSet)2 ContentValues (android.content.ContentValues)1 Uri (android.net.Uri)1 ConversationPrefsHelper (com.moez.QKSMS.common.ConversationPrefsHelper)1 Conversation (com.moez.QKSMS.data.Conversation)1 MessageColumns (com.moez.QKSMS.ui.messagelist.MessageColumns)1 MessageItem (com.moez.QKSMS.ui.messagelist.MessageItem)1 MessageListActivity (com.moez.QKSMS.ui.messagelist.MessageListActivity)1