forked from upstream-mirrors/quik
Merge branch 'master' into mainactivity-cleanup
This commit is contained in:
@@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -74,6 +75,7 @@ dependencies {
|
||||
compile 'com.googlecode.ez-vcard:ez-vcard:0.9.6'
|
||||
compile 'com.google.code.gson:gson:2.3'
|
||||
compile 'com.koushikdutta.ion:ion:1.1.7'
|
||||
compile 'org.ligi:snackengage:0.4'
|
||||
|
||||
// Google libraries
|
||||
compile 'com.android.support:appcompat-v7:22.2.1'
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.moez.QKSMS.common;
|
||||
|
||||
import com.moez.QKSMS.R;
|
||||
|
||||
import org.ligi.snackengage.conditions.AfterNumberOfOpportunities;
|
||||
import org.ligi.snackengage.conditions.NeverAgainWhenClickedOnce;
|
||||
import org.ligi.snackengage.snacks.RateSnack;
|
||||
|
||||
/* https://github.com/ligi/SnackEngage
|
||||
* "This shows a snackbar after MainActivity was created *10* times and never again when once clicked on Rate" */
|
||||
|
||||
public class QKRateSnack extends RateSnack {
|
||||
public QKRateSnack() {
|
||||
withConditions(new NeverAgainWhenClickedOnce(), new AfterNumberOfOpportunities(10));
|
||||
}
|
||||
|
||||
@Override public String getText(){
|
||||
return getString(R.string.rate_title);
|
||||
}
|
||||
|
||||
@Override public String getActionText(){
|
||||
return getString(R.string.rate_action);
|
||||
}
|
||||
}
|
||||
@@ -38,28 +38,29 @@ public class EmojiRegistry {
|
||||
public static String parseEmojis(String body) {
|
||||
if (TextUtils.isEmpty(body)) {
|
||||
return body;
|
||||
} else {
|
||||
// whitespace and punctuation characters
|
||||
String ACCEPTED_CHARS = "[\\s.,?:;'\"!]";
|
||||
|
||||
// explanation: we want to match:
|
||||
// 1) either an accepted char or the beginning of the text (i.e. ^)
|
||||
// 2) the actual emoji code (to be inserted in the loop)
|
||||
// 3) either an accepted char or the end of the text (i.e. $)
|
||||
String REGEX_TEMPLATE = String.format("(^|%s)%s(%s|$)", ACCEPTED_CHARS, "%s", ACCEPTED_CHARS);
|
||||
|
||||
// iterate over all the entries
|
||||
for (Map.Entry<String, String> entry : EmojiRegistry.EMOJIS_MAP.entrySet()) {
|
||||
// quote the emoji code because some characters like ) are protected in regex land
|
||||
String quoted = Pattern.quote(entry.getKey());
|
||||
String regex = String.format(REGEX_TEMPLATE, quoted);
|
||||
|
||||
// the $1 and $2 represent the character* that came before the emoji and the
|
||||
// character* that came after the emoji
|
||||
// * - or beginning / end of text
|
||||
body = body.replaceAll(regex, "$1:" + entry.getValue() + ":$2");
|
||||
}
|
||||
return EmojiParser.parseToUnicode(body);
|
||||
}
|
||||
|
||||
// whitespace and punctuation characters
|
||||
String ACCEPTED_CHARS = "[\\s.,?:;'\"!]";
|
||||
|
||||
// explanation: we want to match:
|
||||
// 1) either an accepted char or the beginning of the text (i.e. ^)
|
||||
// 2) the actual emoji code (to be inserted in the loop)
|
||||
// 3) either an accepted char or the end of the text (i.e. $)
|
||||
String REGEX_TEMPLATE = String.format("(^|%s)%s(%s|$)", ACCEPTED_CHARS, "%s", ACCEPTED_CHARS);
|
||||
|
||||
// iterate over all the entries
|
||||
for (Map.Entry<String, String> entry : EmojiRegistry.EMOJIS_MAP.entrySet()) {
|
||||
// quote the emoji code because some characters like ) are protected in regex land
|
||||
String quoted = Pattern.quote(entry.getKey());
|
||||
String regex = String.format(REGEX_TEMPLATE, quoted);
|
||||
|
||||
// the $1 and $2 represent the character* that came before the emoji and the
|
||||
// character* that came after the emoji
|
||||
// * - or beginning / end of text
|
||||
body = body.replaceAll(regex, "$1:" + entry.getValue() + ":$2");
|
||||
}
|
||||
|
||||
return EmojiParser.parseToUnicode(body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.moez.QKSMS.common.emoji;
|
||||
|
||||
/**
|
||||
* Defines all supported emojis
|
||||
*/
|
||||
public class Emojis {
|
||||
public static final String SMILE = "smile";
|
||||
public static final String SMILEY = "smiley";
|
||||
|
||||
@@ -122,6 +122,7 @@ public class Contact {
|
||||
mIsStale = true;
|
||||
mSendToVoicemail = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("{ number=%s, name=%s, nameAndNumber=%s, label=%s, person_id=%d, hash=%d method_id=%d }",
|
||||
|
||||
@@ -188,10 +188,9 @@ public class ContactHelper {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
public static Bitmap blankContact(Context context, String name) {
|
||||
String text = name == null || PhoneNumberUtils.isWellFormedSmsAddress(PhoneNumberUtils.stripSeparators(name)) || name.length() == 0 ? "#" : "" + name.toUpperCase().charAt(0);
|
||||
|
||||
|
||||
@@ -82,12 +82,12 @@ public class Message {
|
||||
}
|
||||
|
||||
public boolean isMms() {
|
||||
boolean bool = false;
|
||||
boolean isMms = false;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = context.getContentResolver().query(MMS_SMS_CONTENT_PROVIDER, new String[]{SmsHelper.COLUMN_MMS}, "_id=" + id, null, null);
|
||||
cursor.moveToFirst();
|
||||
bool = "application/vnd.wap.multipart.related".equals(cursor.getString(cursor.getColumnIndex(SmsHelper.COLUMN_MMS)));
|
||||
isMms = "application/vnd.wap.multipart.related".equals(cursor.getString(cursor.getColumnIndex(SmsHelper.COLUMN_MMS)));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
@@ -95,7 +95,7 @@ public class Message {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
return bool;
|
||||
return isMms;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
|
||||
@@ -95,8 +95,6 @@ public class SmsHelper {
|
||||
private static final String TAG = "SMSHelper";
|
||||
private static SmsManager sms;
|
||||
|
||||
private static Cursor cursor;
|
||||
|
||||
private static Settings sendSettings;
|
||||
|
||||
public SmsHelper() {
|
||||
@@ -157,11 +155,6 @@ public class SmsHelper {
|
||||
|
||||
private static String[] sNoSubjectStrings;
|
||||
|
||||
public static long getLastThreadId(Context context) {
|
||||
Cursor cursor = context.getContentResolver().query(SmsHelper.RECEIVED_MESSAGE_CONTENT_PROVIDER, new String[]{COLUMN_ID}, null, null, "date DESC");
|
||||
return (cursor != null && cursor.moveToFirst()) ? cursor.getLong(0) : 0;
|
||||
}
|
||||
|
||||
public static void markSmsSeen(Context context) {
|
||||
Cursor cursor = context.getContentResolver().query(RECEIVED_MESSAGE_CONTENT_PROVIDER,
|
||||
new String[]{SmsHelper.COLUMN_ID}, SmsHelper.UNSEEN_SELECTION + " AND " + SmsHelper.UNREAD_SELECTION, null, null);
|
||||
@@ -290,7 +283,7 @@ public class SmsHelper {
|
||||
}
|
||||
|
||||
public static int getUnseenSMSCount(Context context, long threadId) {
|
||||
|
||||
Cursor cursor = null;
|
||||
int count = 0;
|
||||
String selection = UNSEEN_SELECTION + " AND " + UNREAD_SELECTION + (threadId == 0 ? "" : " AND " + COLUMN_THREAD_ID + " = " + threadId);
|
||||
|
||||
@@ -301,7 +294,9 @@ public class SmsHelper {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
cursor.close();
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -314,6 +309,7 @@ public class SmsHelper {
|
||||
*/
|
||||
public static String getHistoryForWearable(Context context, String name, long threadId) {
|
||||
final String me = context.getString(R.string.me);
|
||||
Cursor cursor = null;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
MessageColumns.ColumnsMap map = new MessageColumns.ColumnsMap();
|
||||
|
||||
@@ -432,6 +428,7 @@ public class SmsHelper {
|
||||
}
|
||||
|
||||
public static long getThreadId(Context context, String address) {
|
||||
Cursor cursor = null;
|
||||
long threadId = 0;
|
||||
|
||||
try {
|
||||
@@ -440,67 +437,13 @@ public class SmsHelper {
|
||||
threadId = cursor.getLong(cursor.getColumnIndexOrThrow(COLUMN_THREAD_ID));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return threadId;
|
||||
}
|
||||
|
||||
public static long getLastSentThreadId(Context context) {
|
||||
long threadId = 0;
|
||||
|
||||
try {
|
||||
cursor = context.getContentResolver().query(SENT_MESSAGE_CONTENT_PROVIDER, new String[]{COLUMN_THREAD_ID}, null, null, sortDateDesc);
|
||||
cursor.moveToFirst();
|
||||
threadId = cursor.getLong(cursor.getColumnIndexOrThrow(COLUMN_THREAD_ID));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return threadId;
|
||||
}
|
||||
|
||||
public static List<String> getUnseenMessageNames(Context context) {
|
||||
List<Message> messages = getUnseenMessages(context);
|
||||
List<String> names = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < messages.size(); i++) {
|
||||
if (!names.contains(messages.get(i).getName()))
|
||||
names.add(messages.get(i).getName());
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
public static String getUnseenMessageText(Context context, boolean names) {
|
||||
List<Message> messages = getUnseenMessages(context);
|
||||
String s = "";
|
||||
|
||||
for (Message message : messages) {
|
||||
if (names) s += message.getName() + ": ";
|
||||
s += message.getBody() + "\n";
|
||||
}
|
||||
|
||||
return s.substring(0, s.length() - 1);
|
||||
}
|
||||
|
||||
public static List<Message> getUnseenMessages(Context context) {
|
||||
|
||||
List<Message> messages = new ArrayList<>();
|
||||
|
||||
try {
|
||||
cursor = context.getContentResolver().query(RECEIVED_MESSAGE_CONTENT_PROVIDER, new String[]{COLUMN_ID}, UNSEEN_SELECTION + " AND " + UNREAD_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();
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
return messages;
|
||||
return threadId;
|
||||
}
|
||||
|
||||
public static int getUnreadMessageCount(Context context) {
|
||||
@@ -519,11 +462,13 @@ public class SmsHelper {
|
||||
} while (conversationCursor.moveToNext());
|
||||
}
|
||||
|
||||
conversationCursor.close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<Message> getFailedMessages(Context context) {
|
||||
|
||||
Cursor cursor = null;
|
||||
List<Message> messages = new ArrayList<>();
|
||||
|
||||
try {
|
||||
@@ -536,16 +481,17 @@ public class SmsHelper {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
cursor.close();
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
public static List<Message> deleteFailedMessages(Context context, long threadId) {
|
||||
|
||||
Log.d(TAG, "Deleting failed messages");
|
||||
|
||||
Cursor cursor = null;
|
||||
List<Message> messages = new ArrayList<>();
|
||||
|
||||
try {
|
||||
@@ -558,12 +504,13 @@ public class SmsHelper {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
cursor.close();
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
for (Message m : messages)
|
||||
{
|
||||
if(m.getThreadId() == threadId) {
|
||||
for (Message m : messages) {
|
||||
if (m.getThreadId() == threadId) {
|
||||
Log.d(TAG, "Deleting failed message to " + m.getName() + "\n Body: " + m.getBody());
|
||||
m.delete();
|
||||
}
|
||||
|
||||
@@ -24,10 +24,12 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.google.android.mms.pdu_alt.PduHeaders;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
||||
import com.moez.QKSMS.common.DonationManager;
|
||||
import com.moez.QKSMS.common.QKRateSnack;
|
||||
import com.moez.QKSMS.common.google.DraftCache;
|
||||
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
||||
import com.moez.QKSMS.common.utils.MessageUtils;
|
||||
@@ -52,6 +54,9 @@ import com.moez.QKSMS.ui.welcome.WelcomeActivity;
|
||||
import com.nispok.snackbar.Snackbar;
|
||||
import com.nispok.snackbar.listeners.ActionClickListener;
|
||||
|
||||
import org.ligi.snackengage.SnackEngage;
|
||||
import org.ligi.snackengage.snacks.BaseSnack;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -112,6 +117,10 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
||||
onNewIntent(getIntent());
|
||||
|
||||
showDialogIfNeeded(savedInstanceState);
|
||||
|
||||
//Adds a small/non intrusive snackbar that asks the user to rate the app
|
||||
SnackEngage.from(this).withSnack(new QKRateSnack().withDuration(BaseSnack.DURATION_LONG))
|
||||
.build().engageWhenAppropriate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
<string name="details_body">Inhalt</string>
|
||||
<string name="details_date_sent">Gesendet</string>
|
||||
<string name="details_date_received">Empfangen</string>
|
||||
<string name="rate_title">Gefällt dir QKSMS?</string>
|
||||
<string name="rate_action">Bewerten</string>
|
||||
<string name="pref_category_appearance">Erscheinungsbild</string>
|
||||
<string name="pref_category_summary_appearance">Themen, Schriften, Farben, Avatare und mehr</string>
|
||||
<string name="pref_category_general">Allgemein</string>
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
<item>Jacob Klinker</item>
|
||||
<item>Jeff Gilfelt</item>
|
||||
<item>Melnykov Oleksandr</item>
|
||||
<item>ligi</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="contributor_githubs">
|
||||
@@ -39,6 +40,7 @@
|
||||
<item>github.com/klinker41</item>
|
||||
<item>github.com/jgilfelt</item>
|
||||
<item>github.com/makovkastar</item>
|
||||
<item>github.com/ligi</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="contributor_projects">
|
||||
@@ -48,6 +50,7 @@
|
||||
<item>android-smsmms\nandroid-chips</item>
|
||||
<item>SystemBarTint</item>
|
||||
<item>FloatingActionButton</item>
|
||||
<item>SnackEngage</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="changelog_versions">
|
||||
|
||||
@@ -101,6 +101,10 @@
|
||||
<string name="details_date_sent">Date sent</string>
|
||||
<!--Title for date received of a message in message details popup-->
|
||||
<string name="details_date_received">Date received</string>
|
||||
<!--Title for rate snackbar-->
|
||||
<string name="rate_title">Like QKSMS?</string>
|
||||
<!--Title for rate button-->
|
||||
<string name="rate_action">Rate</string>
|
||||
|
||||
<string name="pref_category_appearance">Appearance</string>
|
||||
<string name="pref_category_summary_appearance">Themes, fonts, colors, avatars, and more</string>
|
||||
|
||||
@@ -49,7 +49,7 @@ Any new code written should follow these guidelines
|
||||
|
||||
# Bug Reports / Feature Requests
|
||||
|
||||
We track issues and pull requests using GitHub issues. You can view existing issues and create your own here: https://github.com/qklabs/qksms/issues
|
||||
We track issues and feature requests using GitHub issues. You can view existing issues and create your own here: https://github.com/qklabs/qksms/issues
|
||||
|
||||
### How to help
|
||||
|
||||
@@ -90,12 +90,12 @@ The conversation isn't marked as read.
|
||||
#### Helping reproduce bugs
|
||||
Reproducing a bug is important, since if we can't reproduce an issue then it's hard to figure out what's going wrong, and we can't know that we've fixed it.
|
||||
|
||||
To see bugs that need "repro steps", go to the Issues section and search for `is:open label:needs-repro`. If you see any bugs that you know how to reproduce (see above for example repro steps), then make a comment with the steps and we'll track the bug down!
|
||||
You can see bugs which need "repro steps" [here](https://github.com/qklabs/qksms/issues?q=is%3Aopen+is%3Aissue+label%3Aneeds-repro). If you see any bugs that you know how to reproduce (see above for example repro steps), then make a comment with the steps and we'll track the bug down!
|
||||
|
||||
#### Making enhancement requests
|
||||
There are no rules for enhancement requests. Your ideas are all awesome. Although we may not implement every suggestion, we love brainstorming with you and hearing your feedback.
|
||||
|
||||
To make an enhancement request, add an "issue" with the "enhancement" label.
|
||||
To make an enhancement request, add an "issue".
|
||||
|
||||
# Contact
|
||||
|
||||
|
||||
Reference in New Issue
Block a user