diff --git a/QKSMS/build.gradle b/QKSMS/build.gradle
index 6ecf2a02..8e7b8df4 100644
--- a/QKSMS/build.gradle
+++ b/QKSMS/build.gradle
@@ -25,8 +25,8 @@ android {
buildToolsVersion '23.0.0'
defaultConfig {
- versionCode 110
- versionName "2.0.1"
+ versionCode 111
+ versionName "2.1.0"
minSdkVersion 15
targetSdkVersion 22
}
diff --git a/QKSMS/src/main/AndroidManifest.xml b/QKSMS/src/main/AndroidManifest.xml
index 6d4ba301..a315488a 100644
--- a/QKSMS/src/main/AndroidManifest.xml
+++ b/QKSMS/src/main/AndroidManifest.xml
@@ -50,18 +50,6 @@
android:taskAffinity=""
android:theme="@style/AppThemeLightDialog"
android:windowSoftInputMode="adjustPan">
-
-
-
-
-
-
-
-
-
-
-
-
@@ -85,7 +73,19 @@
android:logo="@color/transparent"
android:windowSoftInputMode="stateUnchanged|adjustResize">
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/QKSMS/src/main/java/com/moez/QKSMS/mmssms/Utils.java b/QKSMS/src/main/java/com/moez/QKSMS/mmssms/Utils.java
index f52105fc..04a125a9 100644
--- a/QKSMS/src/main/java/com/moez/QKSMS/mmssms/Utils.java
+++ b/QKSMS/src/main/java/com/moez/QKSMS/mmssms/Utils.java
@@ -282,7 +282,6 @@ public class Utils {
*/
public static long getOrCreateThreadId(Context context, String recipient) {
Set recipients = new HashSet<>();
-
recipients.add(recipient);
return getOrCreateThreadId(context, recipients);
}
@@ -293,8 +292,31 @@ public class Utils {
* @param recipients is the set of people message is being sent to
* @return the thread_id to use in the database
*/
- public static long getOrCreateThreadId(
- Context context, Set recipients) {
+ public static long getOrCreateThreadId(Context context, Set recipients) {
+ long threadId = getThreadId(context, recipients);
+ Random random = new Random();
+ return threadId == -1 ? random.nextLong() : threadId;
+ }
+
+ /**
+ * Gets the current thread_id or -1 if none found
+ * @param context is the context of the activity or service
+ * @param recipient is the person message is being sent to
+ * @return the thread_id to use in the database, -1 if none found
+ */
+ public static long getThreadId(Context context, String recipient) {
+ Set recipients = new HashSet<>();
+ recipients.add(recipient);
+ return getThreadId(context, recipients);
+ }
+
+ /**
+ * Gets the current thread_id or -1 if none found
+ * @param context is the context of the activity or service
+ * @param recipients is the set of people message is being sent to
+ * @return the thread_id to use in the database, -1 if none found
+ */
+ public static long getThreadId(Context context, Set recipients) {
Uri.Builder uriBuilder = Uri.parse("content://mms-sms/threadID").buildUpon();
for (String recipient : recipients) {
@@ -320,9 +342,7 @@ public class Utils {
}
}
- Random random = new Random();
- return random.nextLong();
- //throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
+ return -1;
}
private static boolean isEmailAddress(String address) {
diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/MainActivity.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/MainActivity.java
index 855ab042..66ca389a 100644
--- a/QKSMS/src/main/java/com/moez/QKSMS/ui/MainActivity.java
+++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/MainActivity.java
@@ -16,6 +16,8 @@ import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.ContactsContract;
import android.support.v4.content.ContextCompat;
+import android.telephony.PhoneNumberUtils;
+import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
@@ -33,6 +35,7 @@ import com.moez.QKSMS.common.utils.KeyboardUtils;
import com.moez.QKSMS.common.utils.MessageUtils;
import com.moez.QKSMS.common.utils.Units;
import com.moez.QKSMS.data.Conversation;
+import com.moez.QKSMS.mmssms.Utils;
import com.moez.QKSMS.receiver.IconColorReceiver;
import com.moez.QKSMS.transaction.NotificationManager;
import com.moez.QKSMS.transaction.SmsHelper;
@@ -53,25 +56,31 @@ import com.moez.QKSMS.ui.welcome.WelcomeActivity;
import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.listeners.ActionClickListener;
+import java.net.URLDecoder;
import java.util.Collection;
-public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListener,
- SlidingMenu.OnCloseListener, SlidingMenu.OnOpenedListener, SlidingMenu.OnClosedListener,
- ActionClickListener {
+public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListener, SlidingMenu.OnCloseListener,
+ SlidingMenu.OnOpenedListener, SlidingMenu.OnClosedListener, ActionClickListener {
private final String TAG = "MainActivity";
public final static String EXTRA_THREAD_ID = "thread_id";
+ private final String KEY_TYPE = "type";
+ private final String KEY_POSITION = "position";
+ private final String KEY_THREADID = "thread_id";
+
+ private final int TYPE_COMPOSE = 0;
+ private final int TYPE_CONVERSATION = 1;
+ private final int TYPE_SETTINGS = 2;
+ private final int TYPE_SEARCH = 3;
+
private static final int THREAD_LIST_QUERY_TOKEN = 1701;
private static final int UNREAD_THREADS_QUERY_TOKEN = 1702;
public static final int DELETE_CONVERSATION_TOKEN = 1801;
public static final int HAVE_LOCKED_MESSAGES_TOKEN = 1802;
private static final int DELETE_OBSOLETE_THREADS_TOKEN = 1803;
- public final static String MENU_FRAGMENT_TAG = "menu";
- public final static String CONTENT_FRAGMENT_TAG = "content";
-
public static final String MMS_SETUP_DONT_ASK_AGAIN = "mmsSetupDontAskAgain";
// thread IDs are always nonnegative
@@ -83,7 +92,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
private static SharedPreferences prefs;
private SlidingMenu mSlidingMenu;
- private Fragment menuFragment;
+ private ConversationListFragment menuFragment;
private Fragment content;
private long mWaitingForThreadId = -1;
@@ -108,9 +117,55 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
mSlidingMenu = (SlidingMenu) findViewById(R.id.sliding_menu);
setupSlidingMenu();
+ setupFragments(savedInstanceState);
+ onNewIntent(getIntent());
+
showDialogIfNeeded(savedInstanceState);
}
+ /**
+ * Sets up menu and content fragments
+ * If the fragments are stored in the bundle, use those. Otherwise, instantiate new ones
+ */
+ private void setupFragments(Bundle savedInstanceState) {
+ int type = 0;
+ int position = 0;
+ threadId = 0;
+
+ if (savedInstanceState != null) {
+ type = savedInstanceState.getInt(KEY_TYPE, 0);
+ position = savedInstanceState.getInt(KEY_POSITION, 0);
+ threadId = savedInstanceState.getLong(KEY_THREADID, 0);
+ }
+
+ menuFragment = new ConversationListFragment();
+ menuFragment.setPosition(position);
+ getFragmentManager().beginTransaction()
+ .replace(R.id.menu_frame, menuFragment)
+ .commit();
+
+ switch (type) {
+ case TYPE_COMPOSE:
+ content = new ComposeFragment();
+ break;
+ case TYPE_CONVERSATION:
+ Bundle args = new Bundle();
+ args.putLong(MessageListFragment.ARG_THREAD_ID, threadId);
+ content = MessageListFragment.getInstance(args);
+ break;
+ case TYPE_SETTINGS:
+ content = SettingsFragment.newInstance(R.xml.settings_simple);
+ break;
+ case TYPE_SEARCH:
+ content = new SearchFragment();
+ break;
+ }
+
+ getFragmentManager().beginTransaction()
+ .replace(R.id.content_frame, content)
+ .commit();
+ }
+
/**
* Shows at most one dialog using the intent extras and the restored state of the activity.
*
@@ -380,33 +435,6 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
isShowing = true;
ThemeManager.loadThemeProperties(this);
- if (menuFragment == null || content == null) {
- menuFragment = new ConversationListFragment();
-
- if (getIntent().getExtras() != null) {
- content = getFragmentManager().getFragment(getIntent().getExtras(), "content");
- }
-
- threadId = getIntent().getLongExtra(EXTRA_THREAD_ID, -1);
- if (threadId != -1) {
- // Open the conversation if a thread ID exists
- setConversation(threadId);
- } else {
- // Otherwise, show the ConversationList and put a compose fragment as the content
- // fragment.
- mSlidingMenu.showMenu(false);
- content = new ComposeFragment();
- }
-
- getFragmentManager().beginTransaction()
- .replace(R.id.content_frame, content)
- .commitAllowingStateLoss();
-
- getFragmentManager().beginTransaction()
- .replace(R.id.menu_frame, menuFragment)
- .commitAllowingStateLoss();
- }
-
if (!mSlidingMenu.isMenuShowing()) {
QKContentFragment.notifyOnContentOpened(content);
}
@@ -429,17 +457,44 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
setIntent(intent);
// This method is called whenever a MainActivity intent is started. Sometimes this is from a
- // notifications; other times it's from the user clicking on the app icon in the home
- // screen. If it has a thread id, then we know it's from a notification and we can set the
+ // notification; other times it's from the user clicking on the app icon in the home screen
+ long threadId = intent.getLongExtra(EXTRA_THREAD_ID, -1);
+
+ // 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 data = intent.getData().toString();
+ String scheme = intent.getData().getScheme();
+
+ if (scheme.startsWith("smsto") || scheme.startsWith("mmsto")) {
+ String address = data.replace("smsto:", "").replace("mmsto:", "");
+ threadId = Utils.getThreadId(this, formatPhoneNumber(address));
+ } else if (scheme.startsWith("sms") || (scheme.startsWith("mms"))) {
+ String address = data.replace("sms:", "").replace("mms:", "");
+ threadId = Utils.getThreadId(this, formatPhoneNumber(address));
+ }
+ }
+
+ // If it has a thread id, then we know it's from a notification and we can set the
// conversation.
- long threadId = getIntent().getLongExtra(EXTRA_THREAD_ID, -1);
if (threadId != -1) {
+ Log.v(TAG, "Opening thread: " + threadId);
setConversation(threadId);
+ mSlidingMenu.showContent();
+ } else {
+ mSlidingMenu.showMenu(false);
}
// Otherwise we'll just resume what was previously there, which doesn't require any code.
}
+ private String formatPhoneNumber(String address) {
+ address = URLDecoder.decode(address);
+ address = "" + Html.fromHtml(address);
+ address = PhoneNumberUtils.formatNumber(address);
+ return address;
+ }
+
private void beginMmsSetup() {
if (!prefs.getBoolean(MMS_SETUP_DONT_ASK_AGAIN, false) &&
TextUtils.isEmpty(prefs.getString(SettingsFragment.MMSC_URL, "")) &&
@@ -470,27 +525,15 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
FragmentManager m = getFragmentManager();
// Save whether or not the mms setup fragment was dismissed
- if (getFragmentManager().findFragmentByTag(MMSSetupFragment.TAG) == null) {
+ if (m.findFragmentByTag(MMSSetupFragment.TAG) == null) {
outState.putBoolean(KEY_MMS_SETUP_FRAGMENT_DISMISSED, true);
}
- // Check to make sure that the fragments we're looking to save are actually in the fragment
- // manager before saving them. This bug is hard to reproduce, but it's one of the most
- // reported issues on the Play dev console.
- if (content != null && m.findFragmentById(R.id.content_frame) != null) {
- m.putFragment(outState, CONTENT_FRAGMENT_TAG, content);
- }
- if (menuFragment != null && m.findFragmentById(R.id.menu_frame) != null) {
- m.putFragment(outState, MENU_FRAGMENT_TAG, menuFragment);
- }
- }
-
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
-
- menuFragment = getFragmentManager().getFragment(savedInstanceState, MENU_FRAGMENT_TAG);
- content = getFragmentManager().getFragment(savedInstanceState, CONTENT_FRAGMENT_TAG);
+ outState.putInt(KEY_TYPE, content instanceof MessageListFragment ? TYPE_CONVERSATION :
+ content instanceof SettingsFragment ? TYPE_SETTINGS :
+ content instanceof SearchFragment ? TYPE_SEARCH : TYPE_COMPOSE);
+ outState.putInt(KEY_POSITION, menuFragment.getPosition());
+ outState.putLong(KEY_THREADID, threadId);
}
public void switchContent(Fragment fragment, boolean animate) {
@@ -538,7 +581,6 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
args.putString(MessageListFragment.ARG_HIGHLIGHT, pattern);
args.putBoolean(MessageListFragment.ARG_SHOW_IMMEDIATE, !animate);
- Fragment contentFragment = getFragmentManager().findFragmentById(R.id.content_frame);
MessageListFragment fragment = MessageListFragment.getInstance(args);
// Save the thread ID here and switch the content
diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/base/RecyclerCursorAdapter.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/base/RecyclerCursorAdapter.java
index b1f2cb23..cb6e7dea 100644
--- a/QKSMS/src/main/java/com/moez/QKSMS/ui/base/RecyclerCursorAdapter.java
+++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/base/RecyclerCursorAdapter.java
@@ -61,6 +61,10 @@ public abstract class RecyclerCursorAdapter {
+ public LoadConversationTask() {
+ Log.d(TAG, "LoadConversationTask");
+ }
+
@Override
protected Void doInBackground(Void... params) {
Log.d(TAG, "Loading conversation");
diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/popup/QKComposeActivity.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/popup/QKComposeActivity.java
index e2b73091..12ea9d54 100644
--- a/QKSMS/src/main/java/com/moez/QKSMS/ui/popup/QKComposeActivity.java
+++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/popup/QKComposeActivity.java
@@ -3,25 +3,19 @@ package com.moez.QKSMS.ui.popup;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
-import android.os.Handler;
import android.telephony.PhoneNumberUtils;
-import android.text.Html;
import android.view.View;
import android.widget.AdapterView;
import com.android.ex.chips.recipientchip.DrawableRecipientChip;
import com.moez.QKSMS.R;
-import com.moez.QKSMS.data.Contact;
-import com.moez.QKSMS.data.ContactHelper;
+import com.moez.QKSMS.common.utils.KeyboardUtils;
import com.moez.QKSMS.interfaces.ActivityLauncher;
import com.moez.QKSMS.interfaces.RecipientProvider;
-import com.moez.QKSMS.common.utils.KeyboardUtils;
import com.moez.QKSMS.ui.base.QKPopupActivity;
import com.moez.QKSMS.ui.view.AutoCompleteContactView;
import com.moez.QKSMS.ui.view.ComposeView;
import com.moez.QKSMS.ui.view.StarredContactsView;
-import java.net.URLDecoder;
-
public class QKComposeActivity extends QKPopupActivity implements ComposeView.OnSendListener, RecipientProvider,
ActivityLauncher, AdapterView.OnItemClickListener {
@@ -54,40 +48,6 @@ public class QKComposeActivity extends QKPopupActivity implements ComposeView.On
// Apply different attachments based on the type.
mCompose.loadMessageFromIntent(getIntent());
-
- // Check for {sms,mms}{,to}: schemes, in which case we can set the recipients.
- if (getIntent().getData() != null) {
- String data = getIntent().getData().toString();
- String scheme = getIntent().getData().getScheme();
-
- if (scheme.startsWith("smsto") || scheme.startsWith("mmsto")) {
- String address = data.replace("smsto:", "").replace("mmsto:", "");
- final Contact contact = Contact.get(formatPhoneNumber(address), true);
- final Handler handler = new Handler();
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- mRecipients.submitItem(contact.getName(), contact.getNumber(),
- ContactHelper.getPhotoUri(mContext, contact.getUri()));
- }
- }, 100);
-
- } else if (scheme.startsWith("sms") || (scheme.startsWith("mms"))) {
- String address = data.replace("sms:", "").replace("mms:", "");
- final Contact contact = Contact.get(formatPhoneNumber(address), true);
- final Handler handler = new Handler();
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- mRecipients.submitItem(contact.getName(), contact.getNumber(),
- ContactHelper.getPhotoUri(mContext, contact.getUri()));
- }
- }, 100);
-
- }
-
- mCompose.requestReplyTextFocus();
- }
}
@Override
@@ -95,13 +55,6 @@ public class QKComposeActivity extends QKPopupActivity implements ComposeView.On
return R.layout.activity_qkcompose;
}
- private String formatPhoneNumber(String address) {
- address = URLDecoder.decode(address);
- address = "" + Html.fromHtml(address);
- address = PhoneNumberUtils.formatNumber(address);
- return address;
- }
-
@Override
protected void onPause() {
super.onPause();
diff --git a/QKSMS/src/main/res/values/donottranslate.xml b/QKSMS/src/main/res/values/donottranslate.xml
index 08bb267c..31a40183 100644
--- a/QKSMS/src/main/res/values/donottranslate.xml
+++ b/QKSMS/src/main/res/values/donottranslate.xml
@@ -51,6 +51,7 @@
+ - 2.1.0
- 2.0.1
- 1.13.1
- 1.13.0
@@ -159,6 +160,7 @@
+ - August 31, 2015
- August 16, 2015
- August 16, 2015
- August 16, 2015
@@ -267,6 +269,7 @@
+ - " • Added option to delete failed messages\n • Fixed send button animations\n • Improved timestamps\n • New font option\n • Improved unicode stripping\n • Crash fixes\n • Updated translations\n • Improved 24 hour time compatibility\n • Improved sharing functionality\n • Improved rotation support"
- " • QKSMS is now open source. View the source code at https://github.com/qklabs/qksms"
- " • Multiple crash fixes"
- " • Updated messaging UI\n • Fixed phone number showing up instead of name for contacts\n • Fixed delete conversation option\n • Crash fixes"