mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Launch Conversation from intent through MainActivity, so it always exists in stack
This commit is contained in:
@@ -316,8 +316,8 @@ public class NotificationManager {
|
||||
PendingIntent PI;
|
||||
if (failedCursor.getCount() == 1) {
|
||||
title = sRes.getString(R.string.failed_message);
|
||||
Intent intent = new Intent(context, MessageListActivity.class);
|
||||
intent.putExtra(MainActivity.EXTRA_THREAD_ID, failedCursor.getLong(0));
|
||||
Intent intent = new Intent(context, MainActivity.class);
|
||||
intent.putExtra(MessageListActivity.ARG_THREAD_ID, failedCursor.getLong(0));
|
||||
PI = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
} else {
|
||||
title = failedCursor.getCount() + " " + sRes.getString(R.string.failed_messages);
|
||||
@@ -475,8 +475,8 @@ public class NotificationManager {
|
||||
replyIntent.putExtra(QKReplyActivity.EXTRA_SHOW_KEYBOARD, true);
|
||||
final PendingIntent replyPI = PendingIntent.getActivity(context, buildRequestCode(threadId, 0), replyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
Intent threadIntent = new Intent(context, MessageListActivity.class);
|
||||
threadIntent.putExtra(MainActivity.EXTRA_THREAD_ID, threadId);
|
||||
Intent threadIntent = new Intent(context, MainActivity.class);
|
||||
threadIntent.putExtra(MessageListActivity.ARG_THREAD_ID, threadId);
|
||||
final PendingIntent threadPI = PendingIntent.getActivity(context, buildRequestCode(threadId, 1), threadIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
Intent readIntent = new Intent(ACTION_MARK_READ);
|
||||
@@ -575,8 +575,8 @@ public class NotificationManager {
|
||||
replyIntent.putExtra(QKReplyActivity.EXTRA_SHOW_KEYBOARD, true);
|
||||
PendingIntent replyPI = PendingIntent.getActivity(context, buildRequestCode(threadId, 0), replyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
Intent threadIntent = new Intent(context, MessageListActivity.class);
|
||||
threadIntent.putExtra(MainActivity.EXTRA_THREAD_ID, threadId);
|
||||
Intent threadIntent = new Intent(context, MainActivity.class);
|
||||
threadIntent.putExtra(MessageListActivity.ARG_THREAD_ID, threadId);
|
||||
PendingIntent threadPI = PendingIntent.getActivity(context, buildRequestCode(threadId, 1), threadIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
Intent readIntent = new Intent(ACTION_MARK_READ);
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.moez.QKSMS.ui.dialog.ConversationSettingsDialog;
|
||||
import com.moez.QKSMS.ui.dialog.DefaultSmsHelper;
|
||||
import com.moez.QKSMS.ui.dialog.QKDialog;
|
||||
import com.moez.QKSMS.ui.dialog.mms.MMSSetupFragment;
|
||||
import com.moez.QKSMS.ui.messagelist.MessageListActivity;
|
||||
import com.moez.QKSMS.ui.messagelist.MessageListFragment;
|
||||
import com.moez.QKSMS.ui.popup.QKReplyActivity;
|
||||
import com.moez.QKSMS.ui.search.SearchActivity;
|
||||
@@ -57,8 +58,6 @@ import java.util.Collection;
|
||||
public class MainActivity extends QKActivity {
|
||||
private final String TAG = "MainActivity";
|
||||
|
||||
public final static String EXTRA_THREAD_ID = "thread_id";
|
||||
|
||||
public static long sThreadShowing;
|
||||
|
||||
private static final int THREAD_LIST_QUERY_TOKEN = 1701;
|
||||
@@ -86,6 +85,7 @@ public class MainActivity extends QKActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
launchWelcomeActivity();
|
||||
onNewIntent(getIntent());
|
||||
|
||||
setContentView(R.layout.activity_fragment);
|
||||
setTitle(R.string.title_conversation_list);
|
||||
@@ -101,7 +101,6 @@ public class MainActivity extends QKActivity {
|
||||
menuTransaction.replace(R.id.content_frame, mConversationList);
|
||||
menuTransaction.commit();
|
||||
|
||||
onNewIntent(getIntent());
|
||||
showDialogIfNeeded(savedInstanceState);
|
||||
|
||||
LiveViewManager.registerView(QKPreference.BACKGROUND, this, key -> {
|
||||
@@ -288,6 +287,40 @@ public class MainActivity extends QKActivity {
|
||||
NotificationManager.initQuickCompose(this, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* MainActivity has a "singleTask" launch mode, which means that if it is currently running
|
||||
* and another intent is launched to open it, instead of creating a new MainActivity it
|
||||
* just opens the current MainActivity. We use this so that when you click on notifications,
|
||||
* only one main activity is ever used.
|
||||
* <p>
|
||||
* onNewIntent() is called every time the homescreen shortcut is tapped, even if the app
|
||||
* is already running in the background. It's also called when the app is launched via other
|
||||
* intents
|
||||
* <p>
|
||||
* Docs:
|
||||
* http://developer.android.com/guide/components/tasks-and-back-stack.html#TaskLaunchModes
|
||||
*/
|
||||
@Override
|
||||
public void onNewIntent(Intent intent) {
|
||||
// onNewIntent doesn't change the result of getIntent() by default, so here we set it since
|
||||
// that makes the most sense.
|
||||
setIntent(intent);
|
||||
|
||||
boolean shouldOpenConversation = intent.hasExtra(MessageListActivity.ARG_THREAD_ID);
|
||||
|
||||
// The activity can also be launched by clicking on the message button from the contacts app
|
||||
// Check for {sms,mms}{,to}: schemes, in which case we know to open a conversation
|
||||
if (intent.getData() != null) {
|
||||
String scheme = intent.getData().getScheme();
|
||||
shouldOpenConversation = shouldOpenConversation || scheme.startsWith("sms") || scheme.startsWith("mms");
|
||||
}
|
||||
|
||||
if (shouldOpenConversation) {
|
||||
intent.setClass(this, MessageListActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private void beginMmsSetup() {
|
||||
if (!mPrefs.getBoolean(MMS_SETUP_DONT_ASK_AGAIN, false) &&
|
||||
TextUtils.isEmpty(mPrefs.getString(SettingsFragment.MMSC_URL, "")) &&
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.moez.QKSMS.ui.messagelist;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.PhoneNumberUtils;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
@@ -11,6 +10,7 @@ import android.view.MenuItem;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.DonationManager;
|
||||
import com.moez.QKSMS.common.utils.PhoneNumberUtils;
|
||||
import com.moez.QKSMS.mmssms.Utils;
|
||||
import com.moez.QKSMS.ui.base.QKActivity;
|
||||
import com.moez.QKSMS.ui.base.QKSwipeBackActivity;
|
||||
|
||||
@@ -133,7 +133,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
|
||||
private long mLastMessageId;
|
||||
private BackgroundQueryHandler mBackgroundQueryHandler;
|
||||
|
||||
public static final String ARG_THREAD_ID = "thread_id";
|
||||
public static final String ARG_THREAD_ID = "threadId";
|
||||
public static final String ARG_ROW_ID = "rowId";
|
||||
public static final String ARG_HIGHLIGHT = "highlight";
|
||||
public static final String ARG_SHOW_IMMEDIATE = "showImmediate";
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.moez.QKSMS.ui.MainActivity;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
import com.moez.QKSMS.ui.base.QKPopupActivity;
|
||||
import com.moez.QKSMS.ui.messagelist.MessageColumns;
|
||||
import com.moez.QKSMS.ui.messagelist.MessageListActivity;
|
||||
import com.moez.QKSMS.ui.view.ComposeView;
|
||||
|
||||
public class QKReplyActivity extends QKPopupActivity implements DialogInterface.OnDismissListener,
|
||||
@@ -190,7 +191,7 @@ public class QKReplyActivity extends QKPopupActivity implements DialogInterface.
|
||||
|
||||
case R.id.menu_open_thread:
|
||||
Intent threadIntent = new Intent(this, MainActivity.class);
|
||||
threadIntent.putExtra(MainActivity.EXTRA_THREAD_ID, mConversationLegacy.getThreadId());
|
||||
threadIntent.putExtra(MessageListActivity.ARG_THREAD_ID, mConversationLegacy.getThreadId());
|
||||
startActivity(threadIntent);
|
||||
finish();
|
||||
return true;
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.moez.QKSMS.data.ContactHelper;
|
||||
import com.moez.QKSMS.data.Conversation;
|
||||
import com.moez.QKSMS.ui.MainActivity;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
import com.moez.QKSMS.ui.messagelist.MessageListActivity;
|
||||
|
||||
public class WidgetService extends RemoteViewsService {
|
||||
private static final String TAG = "WidgetService";
|
||||
@@ -205,7 +206,7 @@ public class WidgetService extends RemoteViewsService {
|
||||
|
||||
// On click intent.
|
||||
Intent clickIntent = new Intent();
|
||||
clickIntent.putExtra(MainActivity.EXTRA_THREAD_ID, conversation.getThreadId());
|
||||
clickIntent.putExtra(MessageListActivity.ARG_THREAD_ID, conversation.getThreadId());
|
||||
remoteViews.setOnClickFillInIntent(R.id.conversation, clickIntent);
|
||||
|
||||
return remoteViews;
|
||||
|
||||
Reference in New Issue
Block a user