Merge remote-tracking branch 'qklabs/master'

This commit is contained in:
l3d00m
2015-09-01 19:58:54 +02:00
10 changed files with 197 additions and 148 deletions
+2 -2
View File
@@ -25,8 +25,8 @@ android {
buildToolsVersion '23.0.0' buildToolsVersion '23.0.0'
defaultConfig { defaultConfig {
versionCode 110 versionCode 111
versionName "2.0.1" versionName "2.1.0"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 22 targetSdkVersion 22
} }
+12 -12
View File
@@ -50,18 +50,6 @@
android:taskAffinity="" android:taskAffinity=""
android:theme="@style/AppThemeLightDialog" android:theme="@style/AppThemeLightDialog"
android:windowSoftInputMode="adjustPan"> android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEND" /> <action android:name="android.intent.action.SEND" />
@@ -85,7 +73,19 @@
android:logo="@color/transparent" android:logo="@color/transparent"
android:windowSoftInputMode="stateUnchanged|adjustResize"> android:windowSoftInputMode="stateUnchanged|adjustResize">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
<data android:scheme="sms_body" />
</intent-filter> </intent-filter>
</activity> </activity>
@@ -282,7 +282,6 @@ public class Utils {
*/ */
public static long getOrCreateThreadId(Context context, String recipient) { public static long getOrCreateThreadId(Context context, String recipient) {
Set<String> recipients = new HashSet<>(); Set<String> recipients = new HashSet<>();
recipients.add(recipient); recipients.add(recipient);
return getOrCreateThreadId(context, recipients); return getOrCreateThreadId(context, recipients);
} }
@@ -293,8 +292,31 @@ public class Utils {
* @param recipients is the set of people message is being sent to * @param recipients is the set of people message is being sent to
* @return the thread_id to use in the database * @return the thread_id to use in the database
*/ */
public static long getOrCreateThreadId( public static long getOrCreateThreadId(Context context, Set<String> recipients) {
Context context, Set<String> 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<String> 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<String> recipients) {
Uri.Builder uriBuilder = Uri.parse("content://mms-sms/threadID").buildUpon(); Uri.Builder uriBuilder = Uri.parse("content://mms-sms/threadID").buildUpon();
for (String recipient : recipients) { for (String recipient : recipients) {
@@ -320,9 +342,7 @@ public class Utils {
} }
} }
Random random = new Random(); return -1;
return random.nextLong();
//throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
} }
private static boolean isEmailAddress(String address) { private static boolean isEmailAddress(String address) {
@@ -16,6 +16,8 @@ import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.telephony.PhoneNumberUtils;
import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; 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.MessageUtils;
import com.moez.QKSMS.common.utils.Units; import com.moez.QKSMS.common.utils.Units;
import com.moez.QKSMS.data.Conversation; import com.moez.QKSMS.data.Conversation;
import com.moez.QKSMS.mmssms.Utils;
import com.moez.QKSMS.receiver.IconColorReceiver; import com.moez.QKSMS.receiver.IconColorReceiver;
import com.moez.QKSMS.transaction.NotificationManager; import com.moez.QKSMS.transaction.NotificationManager;
import com.moez.QKSMS.transaction.SmsHelper; 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.Snackbar;
import com.nispok.snackbar.listeners.ActionClickListener; import com.nispok.snackbar.listeners.ActionClickListener;
import java.net.URLDecoder;
import java.util.Collection; import java.util.Collection;
public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListener, public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListener, SlidingMenu.OnCloseListener,
SlidingMenu.OnCloseListener, SlidingMenu.OnOpenedListener, SlidingMenu.OnClosedListener, SlidingMenu.OnOpenedListener, SlidingMenu.OnClosedListener, ActionClickListener {
ActionClickListener {
private final String TAG = "MainActivity"; private final String TAG = "MainActivity";
public final static String EXTRA_THREAD_ID = "thread_id"; 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 THREAD_LIST_QUERY_TOKEN = 1701;
private static final int UNREAD_THREADS_QUERY_TOKEN = 1702; private static final int UNREAD_THREADS_QUERY_TOKEN = 1702;
public static final int DELETE_CONVERSATION_TOKEN = 1801; public static final int DELETE_CONVERSATION_TOKEN = 1801;
public static final int HAVE_LOCKED_MESSAGES_TOKEN = 1802; public static final int HAVE_LOCKED_MESSAGES_TOKEN = 1802;
private static final int DELETE_OBSOLETE_THREADS_TOKEN = 1803; 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"; public static final String MMS_SETUP_DONT_ASK_AGAIN = "mmsSetupDontAskAgain";
// thread IDs are always nonnegative // thread IDs are always nonnegative
@@ -83,7 +92,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
private static SharedPreferences prefs; private static SharedPreferences prefs;
private SlidingMenu mSlidingMenu; private SlidingMenu mSlidingMenu;
private Fragment menuFragment; private ConversationListFragment menuFragment;
private Fragment content; private Fragment content;
private long mWaitingForThreadId = -1; private long mWaitingForThreadId = -1;
@@ -108,9 +117,55 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
mSlidingMenu = (SlidingMenu) findViewById(R.id.sliding_menu); mSlidingMenu = (SlidingMenu) findViewById(R.id.sliding_menu);
setupSlidingMenu(); setupSlidingMenu();
setupFragments(savedInstanceState);
onNewIntent(getIntent());
showDialogIfNeeded(savedInstanceState); 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. * 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; isShowing = true;
ThemeManager.loadThemeProperties(this); 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()) { if (!mSlidingMenu.isMenuShowing()) {
QKContentFragment.notifyOnContentOpened(content); QKContentFragment.notifyOnContentOpened(content);
} }
@@ -429,17 +457,44 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
setIntent(intent); setIntent(intent);
// This method is called whenever a MainActivity intent is started. Sometimes this is from a // 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 // notification; other times it's from the user clicking on the app icon in the home screen
// screen. If it has a thread id, then we know it's from a notification and we can set the 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. // conversation.
long threadId = getIntent().getLongExtra(EXTRA_THREAD_ID, -1);
if (threadId != -1) { if (threadId != -1) {
Log.v(TAG, "Opening thread: " + threadId);
setConversation(threadId); setConversation(threadId);
mSlidingMenu.showContent();
} else {
mSlidingMenu.showMenu(false);
} }
// Otherwise we'll just resume what was previously there, which doesn't require any code. // 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() { private void beginMmsSetup() {
if (!prefs.getBoolean(MMS_SETUP_DONT_ASK_AGAIN, false) && if (!prefs.getBoolean(MMS_SETUP_DONT_ASK_AGAIN, false) &&
TextUtils.isEmpty(prefs.getString(SettingsFragment.MMSC_URL, "")) && TextUtils.isEmpty(prefs.getString(SettingsFragment.MMSC_URL, "")) &&
@@ -470,27 +525,15 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
FragmentManager m = getFragmentManager(); FragmentManager m = getFragmentManager();
// Save whether or not the mms setup fragment was dismissed // 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); 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 outState.putInt(KEY_TYPE, content instanceof MessageListFragment ? TYPE_CONVERSATION :
// manager before saving them. This bug is hard to reproduce, but it's one of the most content instanceof SettingsFragment ? TYPE_SETTINGS :
// reported issues on the Play dev console. content instanceof SearchFragment ? TYPE_SEARCH : TYPE_COMPOSE);
if (content != null && m.findFragmentById(R.id.content_frame) != null) { outState.putInt(KEY_POSITION, menuFragment.getPosition());
m.putFragment(outState, CONTENT_FRAGMENT_TAG, content); outState.putLong(KEY_THREADID, threadId);
}
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);
} }
public void switchContent(Fragment fragment, boolean animate) { 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.putString(MessageListFragment.ARG_HIGHLIGHT, pattern);
args.putBoolean(MessageListFragment.ARG_SHOW_IMMEDIATE, !animate); args.putBoolean(MessageListFragment.ARG_SHOW_IMMEDIATE, !animate);
Fragment contentFragment = getFragmentManager().findFragmentById(R.id.content_frame);
MessageListFragment fragment = MessageListFragment.getInstance(args); MessageListFragment fragment = MessageListFragment.getInstance(args);
// Save the thread ID here and switch the content // Save the thread ID here and switch the content
@@ -61,6 +61,10 @@ public abstract class RecyclerCursorAdapter<VH extends RecyclerView.ViewHolder,
return mCursor; return mCursor;
} }
public int getCount() {
return mCursor == null ? 0 : mCursor.getColumnCount();
}
protected abstract DataType getItem(int position); protected abstract DataType getItem(int position);
public boolean isInMultiSelectMode() { public boolean isInMultiSelectMode() {
@@ -62,6 +62,9 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
private ConversationDetailsDialog mConversationDetailsDialog; private ConversationDetailsDialog mConversationDetailsDialog;
private QKActivity mContext; private QKActivity mContext;
// This does not hold the current position of the list, rather the position the list is pending being set to
private int mPosition;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -244,7 +247,18 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
break; break;
} }
} }
}).show(((MainActivity) mContext).getFragmentManager(), "conversation options"); }).show(mContext.getFragmentManager(), "conversation options");
}
public void setPosition(int position) {
mPosition = position;
if (mLayoutManager != null && mAdapter != null) {
mLayoutManager.scrollToPosition(Math.min(mPosition, mAdapter.getCount() - 1));
}
}
public int getPosition() {
return mLayoutManager.findFirstVisibleItemPosition();
} }
private void initLoaderManager() { private void initLoaderManager() {
@@ -277,6 +291,10 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
if (mAdapter != null) { if (mAdapter != null) {
// Swap the new cursor in. (The framework will take care of closing the, old cursor once we return.) // Swap the new cursor in. (The framework will take care of closing the, old cursor once we return.)
mAdapter.changeCursor(data); mAdapter.changeCursor(data);
if (mPosition != 0) {
mRecyclerView.scrollToPosition(Math.min(mPosition, data.getCount() - 1));
mPosition = 0;
}
} }
} }
@@ -68,6 +68,9 @@ public class MessageColumns {
}; };
public static class ColumnsMap { public static class ColumnsMap {
private final String TAG = "ColumnsMap";
private final boolean DEBUG = false;
public int mColumnMsgType; public int mColumnMsgType;
public int mColumnMsgId; public int mColumnMsgId;
public int mColumnSmsAddress; public int mColumnSmsAddress;
@@ -123,121 +126,121 @@ public class MessageColumns {
try { try {
mColumnMsgType = cursor.getColumnIndexOrThrow(Telephony.MmsSms.TYPE_DISCRIMINATOR_COLUMN); mColumnMsgType = cursor.getColumnIndexOrThrow(Telephony.MmsSms.TYPE_DISCRIMINATOR_COLUMN);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnMsgId = cursor.getColumnIndexOrThrow(BaseColumns._ID); mColumnMsgId = cursor.getColumnIndexOrThrow(BaseColumns._ID);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnSmsAddress = cursor.getColumnIndexOrThrow(Telephony.Sms.ADDRESS); mColumnSmsAddress = cursor.getColumnIndexOrThrow(Telephony.Sms.ADDRESS);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnSmsBody = cursor.getColumnIndexOrThrow(Telephony.Sms.BODY); mColumnSmsBody = cursor.getColumnIndexOrThrow(Telephony.Sms.BODY);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnSmsDate = cursor.getColumnIndexOrThrow(Telephony.Sms.DATE); mColumnSmsDate = cursor.getColumnIndexOrThrow(Telephony.Sms.DATE);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnSmsDateSent = cursor.getColumnIndexOrThrow(Telephony.Sms.DATE_SENT); mColumnSmsDateSent = cursor.getColumnIndexOrThrow(Telephony.Sms.DATE_SENT);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnSmsType = cursor.getColumnIndexOrThrow(Telephony.Sms.TYPE); mColumnSmsType = cursor.getColumnIndexOrThrow(Telephony.Sms.TYPE);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnSmsStatus = cursor.getColumnIndexOrThrow(Telephony.Sms.STATUS); mColumnSmsStatus = cursor.getColumnIndexOrThrow(Telephony.Sms.STATUS);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnSmsLocked = cursor.getColumnIndexOrThrow(Telephony.Sms.LOCKED); mColumnSmsLocked = cursor.getColumnIndexOrThrow(Telephony.Sms.LOCKED);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnSmsErrorCode = cursor.getColumnIndexOrThrow(Telephony.Sms.ERROR_CODE); mColumnSmsErrorCode = cursor.getColumnIndexOrThrow(Telephony.Sms.ERROR_CODE);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnMmsSubject = cursor.getColumnIndexOrThrow(Telephony.Mms.SUBJECT); mColumnMmsSubject = cursor.getColumnIndexOrThrow(Telephony.Mms.SUBJECT);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnMmsSubjectCharset = cursor.getColumnIndexOrThrow(Telephony.Mms.SUBJECT_CHARSET); mColumnMmsSubjectCharset = cursor.getColumnIndexOrThrow(Telephony.Mms.SUBJECT_CHARSET);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnMmsMessageType = cursor.getColumnIndexOrThrow(Telephony.Mms.MESSAGE_TYPE); mColumnMmsMessageType = cursor.getColumnIndexOrThrow(Telephony.Mms.MESSAGE_TYPE);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnMmsMessageBox = cursor.getColumnIndexOrThrow(Telephony.Mms.MESSAGE_BOX); mColumnMmsMessageBox = cursor.getColumnIndexOrThrow(Telephony.Mms.MESSAGE_BOX);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnMmsDeliveryReport = cursor.getColumnIndexOrThrow(Telephony.Mms.DELIVERY_REPORT); mColumnMmsDeliveryReport = cursor.getColumnIndexOrThrow(Telephony.Mms.DELIVERY_REPORT);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnMmsReadReport = cursor.getColumnIndexOrThrow(Telephony.Mms.READ_REPORT); mColumnMmsReadReport = cursor.getColumnIndexOrThrow(Telephony.Mms.READ_REPORT);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnMmsErrorType = cursor.getColumnIndexOrThrow(Telephony.MmsSms.PendingMessages.ERROR_TYPE); mColumnMmsErrorType = cursor.getColumnIndexOrThrow(Telephony.MmsSms.PendingMessages.ERROR_TYPE);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnMmsLocked = cursor.getColumnIndexOrThrow(Telephony.Mms.LOCKED); mColumnMmsLocked = cursor.getColumnIndexOrThrow(Telephony.Mms.LOCKED);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnMmsStatus = cursor.getColumnIndexOrThrow(Telephony.Mms.STATUS); mColumnMmsStatus = cursor.getColumnIndexOrThrow(Telephony.Mms.STATUS);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
try { try {
mColumnMmsTextOnly = cursor.getColumnIndexOrThrow(Telephony.Mms.TEXT_ONLY); mColumnMmsTextOnly = cursor.getColumnIndexOrThrow(Telephony.Mms.TEXT_ONLY);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.w("colsMap", e.getMessage()); if (DEBUG) Log.w(TAG, e.getMessage());
} }
} }
} }
@@ -173,6 +173,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
private long mLastMessageId; private long mLastMessageId;
private BackgroundQueryHandler mBackgroundQueryHandler; private BackgroundQueryHandler mBackgroundQueryHandler;
private LoadConversationTask mLoadConversationTask;
public static final String ARG_THREAD_ID = "threadId"; public static final String ARG_THREAD_ID = "threadId";
public static final String ARG_ROW_ID = "rowId"; public static final String ARG_ROW_ID = "rowId";
@@ -325,8 +326,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
* Note: This will have no effect if the context has not been initialized yet. * Note: This will have no effect if the context has not been initialized yet.
*/ */
private void onOpenConversation() { private void onOpenConversation() {
Log.d(TAG, "onOpenConversation with threadId: " + mThreadId); new LoadConversationTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null);
new LoadConversationTask().execute((Void[]) null);
} }
public void setTitle() { public void setTitle() {
@@ -745,7 +745,9 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
@Override @Override
protected void onContentClosed() { protected void onContentClosed() {
mSensorManager.unregisterListener(this); if (mSensorManager != null) {
mSensorManager.unregisterListener(this);
}
if (mOpened) { if (mOpened) {
if (mConversationLegacy != null) { if (mConversationLegacy != null) {
@@ -1372,6 +1374,10 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
private class LoadConversationTask extends AsyncTask<Void, Void, Void> { private class LoadConversationTask extends AsyncTask<Void, Void, Void> {
public LoadConversationTask() {
Log.d(TAG, "LoadConversationTask");
}
@Override @Override
protected Void doInBackground(Void... params) { protected Void doInBackground(Void... params) {
Log.d(TAG, "Loading conversation"); Log.d(TAG, "Loading conversation");
@@ -3,25 +3,19 @@ package com.moez.QKSMS.ui.popup;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.telephony.PhoneNumberUtils; import android.telephony.PhoneNumberUtils;
import android.text.Html;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import com.android.ex.chips.recipientchip.DrawableRecipientChip; import com.android.ex.chips.recipientchip.DrawableRecipientChip;
import com.moez.QKSMS.R; import com.moez.QKSMS.R;
import com.moez.QKSMS.data.Contact; import com.moez.QKSMS.common.utils.KeyboardUtils;
import com.moez.QKSMS.data.ContactHelper;
import com.moez.QKSMS.interfaces.ActivityLauncher; import com.moez.QKSMS.interfaces.ActivityLauncher;
import com.moez.QKSMS.interfaces.RecipientProvider; 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.base.QKPopupActivity;
import com.moez.QKSMS.ui.view.AutoCompleteContactView; import com.moez.QKSMS.ui.view.AutoCompleteContactView;
import com.moez.QKSMS.ui.view.ComposeView; import com.moez.QKSMS.ui.view.ComposeView;
import com.moez.QKSMS.ui.view.StarredContactsView; import com.moez.QKSMS.ui.view.StarredContactsView;
import java.net.URLDecoder;
public class QKComposeActivity extends QKPopupActivity implements ComposeView.OnSendListener, RecipientProvider, public class QKComposeActivity extends QKPopupActivity implements ComposeView.OnSendListener, RecipientProvider,
ActivityLauncher, AdapterView.OnItemClickListener { ActivityLauncher, AdapterView.OnItemClickListener {
@@ -54,40 +48,6 @@ public class QKComposeActivity extends QKPopupActivity implements ComposeView.On
// Apply different attachments based on the type. // Apply different attachments based on the type.
mCompose.loadMessageFromIntent(getIntent()); 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 @Override
@@ -95,13 +55,6 @@ public class QKComposeActivity extends QKPopupActivity implements ComposeView.On
return R.layout.activity_qkcompose; 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 @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
@@ -51,6 +51,7 @@
</string-array> </string-array>
<string-array name="changelog_versions"> <string-array name="changelog_versions">
<item>2.1.0</item>
<item>2.0.1</item> <item>2.0.1</item>
<item>1.13.1</item> <item>1.13.1</item>
<item>1.13.0</item> <item>1.13.0</item>
@@ -159,6 +160,7 @@
</string-array> </string-array>
<string-array name="changelog_dates"> <string-array name="changelog_dates">
<item>August 31, 2015</item>
<item>August 16, 2015</item> <item>August 16, 2015</item>
<item>August 16, 2015</item> <item>August 16, 2015</item>
<item>August 16, 2015</item> <item>August 16, 2015</item>
@@ -267,6 +269,7 @@
</string-array> </string-array>
<string-array name="changelog_changes"> <string-array name="changelog_changes">
<item>" • 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"</item>
<item>" • QKSMS is now open source. View the source code at https://github.com/qklabs/qksms"</item> <item>" • QKSMS is now open source. View the source code at https://github.com/qklabs/qksms"</item>
<item>" • Multiple crash fixes"</item> <item>" • Multiple crash fixes"</item>
<item>" • Updated messaging UI\n • Fixed phone number showing up instead of name for contacts\n • Fixed delete conversation option\n • Crash fixes"</item> <item>" • Updated messaging UI\n • Fixed phone number showing up instead of name for contacts\n • Fixed delete conversation option\n • Crash fixes"</item>