diff --git a/.travis.yml b/.travis.yml index ea0f94b1..c41f5a98 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: android +sudo: false android: components: diff --git a/QKSMS/src/androidTest/java/com/moez/QKSMS/common/utils/DateFormatterTest.java b/QKSMS/src/androidTest/java/com/moez/QKSMS/common/utils/DateFormatterTest.java index 6fc42a99..47f9213a 100644 --- a/QKSMS/src/androidTest/java/com/moez/QKSMS/common/utils/DateFormatterTest.java +++ b/QKSMS/src/androidTest/java/com/moez/QKSMS/common/utils/DateFormatterTest.java @@ -1,9 +1,6 @@ package com.moez.QKSMS.common.utils; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; import android.test.AndroidTestCase; -import com.moez.QKSMS.ui.settings.SettingsFragment; import java.text.SimpleDateFormat; @@ -12,13 +9,6 @@ public class DateFormatterTest extends AndroidTestCase { super.setUp(); } - public void test24Hours() { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - prefs.edit().putBoolean(SettingsFragment.TIMESTAMPS_24H, true).apply(); - assertTrue(DateFormatter.accountFor24HourTime(getContext(), new SimpleDateFormat("h:mm a")).equals(new SimpleDateFormat("H:mm"))); - prefs.edit().putBoolean(SettingsFragment.TIMESTAMPS_24H, false).apply(); - } - public void testDateSymbolsAPI(){ assertEquals(new SimpleDateFormat("H:mm a").toPattern(), "H:mm a"); } diff --git a/QKSMS/src/main/AndroidManifest.xml b/QKSMS/src/main/AndroidManifest.xml index 152d35ac..c1349f5e 100644 --- a/QKSMS/src/main/AndroidManifest.xml +++ b/QKSMS/src/main/AndroidManifest.xml @@ -39,7 +39,7 @@ @@ -66,9 +66,11 @@ @@ -92,22 +94,50 @@ + + + + + + + + + + + + + + @@ -119,7 +149,7 @@ @@ -131,7 +161,7 @@ @@ -143,7 +173,7 @@ @@ -155,7 +185,7 @@ @@ -167,7 +197,7 @@ @@ -179,7 +209,7 @@ @@ -191,7 +221,7 @@ @@ -203,7 +233,7 @@ @@ -215,7 +245,7 @@ @@ -227,7 +257,7 @@ @@ -239,7 +269,7 @@ @@ -251,7 +281,7 @@ @@ -263,7 +293,7 @@ @@ -275,7 +305,7 @@ @@ -287,7 +317,7 @@ @@ -299,7 +329,7 @@ @@ -311,7 +341,7 @@ @@ -323,7 +353,7 @@ @@ -335,17 +365,21 @@ - + * This key is set via the needs map. */ - public final static int RW_DESIRED_REV_BW = 5; + public static final int RW_DESIRED_REV_BW = 5; /** * Required minimum reverse link (upload) bandwidth, in kilobits @@ -103,21 +103,21 @@ public class LinkCapabilities implements Parcelable { * If a rate is not specified, the default rate of kbps will be * Values should be strings such as "50", "100", "1500", etc. */ - public final static int RW_REQUIRED_REV_BW = 6; + public static final int RW_REQUIRED_REV_BW = 6; /** * Available reverse link (upload) bandwidth for the socket. * This value is in kilobits per second (kbps). * Values will be strings such as "50", "100", "1500", etc. */ - public final static int RO_AVAILABLE_REV_BW = 7; + public static final int RO_AVAILABLE_REV_BW = 7; /** * Maximum latency for the socket, in milliseconds, above which * socket cannot function. * Values should be strings such as "50", "300", "500", etc. */ - public final static int RW_MAX_ALLOWED_LATENCY = 8; + public static final int RW_MAX_ALLOWED_LATENCY = 8; /** * Interface that the socket is bound to. This can be a virtual @@ -125,7 +125,7 @@ public class LinkCapabilities implements Parcelable { * (e.g. wlan0 or rmnet0). * Values will be strings such as "wlan0", "rmnet0" */ - public final static int RO_BOUND_INTERFACE = 9; + public static final int RO_BOUND_INTERFACE = 9; /** * Physical interface that the socket is routed on. @@ -134,7 +134,7 @@ public class LinkCapabilities implements Parcelable { * if seamless mobility is supported. * Values will be strings such as "wlan0", "rmnet0" */ - public final static int RO_PHYSICAL_INTERFACE = 10; + public static final int RO_PHYSICAL_INTERFACE = 10; } /** diff --git a/QKSMS/src/main/java/com/android/mms/dom/smil/ElementTimeImpl.java b/QKSMS/src/main/java/com/android/mms/dom/smil/ElementTimeImpl.java index a3443cd8..d3e11305 100644 --- a/QKSMS/src/main/java/com/android/mms/dom/smil/ElementTimeImpl.java +++ b/QKSMS/src/main/java/com/android/mms/dom/smil/ElementTimeImpl.java @@ -81,7 +81,7 @@ public abstract class ElementTimeImpl implements ElementTime { // Ignore badly formatted times } } - if (beginTimeList.size() == 0) { + if (beginTimeList.isEmpty()) { /* * What is the right default value? * @@ -139,7 +139,7 @@ public abstract class ElementTimeImpl implements ElementTime { } // "end" time is not specified - if (endTimeList.size() == 0) { + if (endTimeList.isEmpty()) { // Get duration float duration = getDur(); diff --git a/QKSMS/src/main/java/com/android/mms/transaction/TransactionService.java b/QKSMS/src/main/java/com/android/mms/transaction/TransactionService.java index 699348cf..aba3ab71 100644 --- a/QKSMS/src/main/java/com/android/mms/transaction/TransactionService.java +++ b/QKSMS/src/main/java/com/android/mms/transaction/TransactionService.java @@ -473,7 +473,7 @@ public class TransactionService extends Service implements Observer { try { synchronized (mProcessing) { mProcessing.remove(transaction); - if (mPending.size() > 0) { + if (!mPending.isEmpty()) { if (LOCAL_LOGV) Log.v(TAG, "update: handle next pending transaction..."); Message msg = mServiceHandler.obtainMessage( EVENT_HANDLE_NEXT_PENDING_TRANSACTION, @@ -799,7 +799,7 @@ public class TransactionService extends Service implements Observer { public void markAllPendingTransactionsAsFailed() { synchronized (mProcessing) { - while (mPending.size() != 0) { + while (!mPending.isEmpty()) { Transaction transaction = mPending.remove(0); transaction.mTransactionState.setState(TransactionState.FAILED); if (transaction instanceof SendTransaction) { @@ -824,7 +824,7 @@ public class TransactionService extends Service implements Observer { int numProcessTransaction; synchronized (mProcessing) { - if (mPending.size() != 0) { + if (!mPending.isEmpty()) { transaction = mPending.remove(0); } numProcessTransaction = mProcessing.size(); diff --git a/QKSMS/src/main/java/com/google/android/mms/pdu_alt/PduComposer.java b/QKSMS/src/main/java/com/google/android/mms/pdu_alt/PduComposer.java index 54b94985..d41da8ec 100644 --- a/QKSMS/src/main/java/com/google/android/mms/pdu_alt/PduComposer.java +++ b/QKSMS/src/main/java/com/google/android/mms/pdu_alt/PduComposer.java @@ -34,11 +34,11 @@ public class PduComposer { /** * Address type. */ - static private final int PDU_PHONE_NUMBER_ADDRESS_TYPE = 1; - static private final int PDU_EMAIL_ADDRESS_TYPE = 2; - static private final int PDU_IPV4_ADDRESS_TYPE = 3; - static private final int PDU_IPV6_ADDRESS_TYPE = 4; - static private final int PDU_UNKNOWN_ADDRESS_TYPE = 5; + private static final int PDU_PHONE_NUMBER_ADDRESS_TYPE = 1; + private static final int PDU_EMAIL_ADDRESS_TYPE = 2; + private static final int PDU_IPV4_ADDRESS_TYPE = 3; + private static final int PDU_IPV6_ADDRESS_TYPE = 4; + private static final int PDU_UNKNOWN_ADDRESS_TYPE = 5; /** * Address regular expression string. @@ -63,25 +63,25 @@ public class PduComposer { /** * Error values. */ - static private final int PDU_COMPOSE_SUCCESS = 0; - static private final int PDU_COMPOSE_CONTENT_ERROR = 1; - static private final int PDU_COMPOSE_FIELD_NOT_SET = 2; - static private final int PDU_COMPOSE_FIELD_NOT_SUPPORTED = 3; + private static final int PDU_COMPOSE_SUCCESS = 0; + private static final int PDU_COMPOSE_CONTENT_ERROR = 1; + private static final int PDU_COMPOSE_FIELD_NOT_SET = 2; + private static final int PDU_COMPOSE_FIELD_NOT_SUPPORTED = 3; /** * WAP values defined in WSP spec. */ - static private final int QUOTED_STRING_FLAG = 34; - static private final int END_STRING_FLAG = 0; - static private final int LENGTH_QUOTE = 31; - static private final int TEXT_MAX = 127; - static private final int SHORT_INTEGER_MAX = 127; - static private final int LONG_INTEGER_LENGTH_MAX = 8; + private static final int QUOTED_STRING_FLAG = 34; + private static final int END_STRING_FLAG = 0; + private static final int LENGTH_QUOTE = 31; + private static final int TEXT_MAX = 127; + private static final int SHORT_INTEGER_MAX = 127; + private static final int LONG_INTEGER_LENGTH_MAX = 8; /** * Block size when read data from InputStream. */ - static private final int PDU_COMPOSER_BLOCK_SIZE = 1024; + private static final int PDU_COMPOSER_BLOCK_SIZE = 1024; private static final String TAG = "PduComposer"; /** @@ -1029,7 +1029,7 @@ public class PduComposer { /** * Record current message informations. */ - static private class LengthRecordNode { + private static class LengthRecordNode { ByteArrayOutputStream currentMessage = null; public int currentPosition = 0; diff --git a/QKSMS/src/main/java/com/google/android/mms/pdu_alt/PduPersister.java b/QKSMS/src/main/java/com/google/android/mms/pdu_alt/PduPersister.java index f11d67ad..9b048881 100644 --- a/QKSMS/src/main/java/com/google/android/mms/pdu_alt/PduPersister.java +++ b/QKSMS/src/main/java/com/google/android/mms/pdu_alt/PduPersister.java @@ -903,7 +903,7 @@ public class PduPersister { * Here shall be "video" or "audio" or "images" * the index of the content in given table */ - static public String convertUriToPath(Context context, Uri uri) { + public static String convertUriToPath(Context context, Uri uri) { String path = null; if (null != uri) { String scheme = uri.getScheme(); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/QKSMSAppBase.java b/QKSMS/src/main/java/com/moez/QKSMS/QKSMSAppBase.java index 19a1a49b..6f602499 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/QKSMSAppBase.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/QKSMSAppBase.java @@ -94,6 +94,7 @@ public class QKSMSAppBase extends MultiDexApplication { registerActivityLifecycleCallbacks(new LifecycleHandler()); ThemeManager.init(this); + ThemeManager.migrateIcon(this); // TODO a few versions after 2.7, we can phase this out along with the old alias MmsConfig.init(this); Contact.init(this); DraftCache.init(this); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/CIELChEvaluator.java b/QKSMS/src/main/java/com/moez/QKSMS/common/CIELChEvaluator.java index 746dab1a..b487db1d 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/CIELChEvaluator.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/CIELChEvaluator.java @@ -18,7 +18,13 @@ public class CIELChEvaluator implements TypeEvaluator { private final ColorCIELCh mStartColor; private final ColorCIELCh mEndColor; + private final int mStartInt; + private final int mEndInt; + public CIELChEvaluator(int startColor, int endColor) { + mStartInt = startColor; + mEndInt = endColor; + mStartColor = convertRgbToCIELCH(startColor); mEndColor = convertRgbToCIELCH(endColor); } @@ -29,6 +35,9 @@ public class CIELChEvaluator implements TypeEvaluator { @Override public Integer evaluate(float fraction, Integer ignored, Integer ignored2) { + if (mStartInt == mEndInt) { + return mStartInt; + } // CIELCH to CIELAB double L = mStartColor.L * (1 - fraction) + mEndColor.L * fraction; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/DonationManager.java b/QKSMS/src/main/java/com/moez/QKSMS/common/DonationManager.java index eb14dbb1..63c3a4da 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/DonationManager.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/DonationManager.java @@ -7,9 +7,11 @@ import android.util.Log; import android.view.View; import android.widget.Toast; import com.moez.QKSMS.R; +import com.moez.QKSMS.enums.QKPreference; import com.moez.QKSMS.external.iab.IabHelper; import com.moez.QKSMS.external.iab.IabResult; import com.moez.QKSMS.external.iab.Purchase; +import com.moez.QKSMS.ui.ThemeManager; import com.moez.QKSMS.ui.base.QKActivity; import com.moez.QKSMS.ui.dialog.QKDialog; @@ -197,6 +199,13 @@ public class DonationManager { view.findViewById(R.id.donate_10).setOnClickListener(clickListener); view.findViewById(R.id.donate_paypal).setOnClickListener(clickListener); + LiveViewManager.registerView(QKPreference.BACKGROUND, this, key -> { + view.findViewById(R.id.donate_1).setBackgroundDrawable(ThemeManager.getRippleBackground()); + view.findViewById(R.id.donate_5).setBackgroundDrawable(ThemeManager.getRippleBackground()); + view.findViewById(R.id.donate_10).setBackgroundDrawable(ThemeManager.getRippleBackground()); + view.findViewById(R.id.donate_paypal).setBackgroundDrawable(ThemeManager.getRippleBackground()); + }); + QKDialog dialog = new QKDialog() .setContext(mContext) .setCustomView(view); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/google/BlobCache.java b/QKSMS/src/main/java/com/moez/QKSMS/common/google/BlobCache.java index 293c14b7..2167be6b 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/google/BlobCache.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/google/BlobCache.java @@ -123,6 +123,11 @@ public class BlobCache implements Closeable { private byte[] mBlobHeader = new byte[BLOB_HEADER_SIZE]; private Adler32 mAdler32 = new Adler32(); + private int mSlotOffset; + private int mFileOffset; + + private LookupRequest mLookupRequest = new LookupRequest(); + // Creates the cache. Three files will be created: // path + ".idx", path + ".0", and path + ".1" // The ".0" file and the ".1" file each stores data for a region. Each of @@ -431,7 +436,6 @@ public class BlobCache implements Closeable { // This method is for one-off lookup. For repeated lookup, use the version // accepting LookupRequest to avoid repeated memory allocation. - private LookupRequest mLookupRequest = new LookupRequest(); public byte[] lookup(long key) throws IOException { mLookupRequest.key = key; mLookupRequest.buffer = null; @@ -555,8 +559,6 @@ public class BlobCache implements Closeable { // insertion. // If the lookup is successful, the file offset is also saved in // mFileOffset. - private int mSlotOffset; - private int mFileOffset; private boolean lookupInternal(long key, int hashStart) { int slot = (int) (key % mMaxEntries); if (slot < 0) slot += mMaxEntries; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/google/DraftCache.java b/QKSMS/src/main/java/com/moez/QKSMS/common/google/DraftCache.java index 250b6029..2c49b653 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/google/DraftCache.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/google/DraftCache.java @@ -35,6 +35,12 @@ package com.moez.QKSMS.common.google; public class DraftCache { private static final String TAG = "Mms/draft"; + static final String[] DRAFT_PROJECTION = new String[] { + Conversations.THREAD_ID // 0 + }; + + static final int COLUMN_DRAFT_THREAD_ID = 0; + private static DraftCache sInstance; private final Context mContext; @@ -61,12 +67,6 @@ public class DraftCache { refresh(); } - static final String[] DRAFT_PROJECTION = new String[] { - Conversations.THREAD_ID // 0 - }; - - static final int COLUMN_DRAFT_THREAD_ID = 0; - /** To be called whenever the draft state might have changed. * Dispatches work to a thread and returns immediately. */ @@ -131,7 +131,7 @@ public class DraftCache { // If nobody's interested in finding out about changes, // just bail out early. synchronized (mChangeListenersLock) { - if (mChangeListeners.size() < 1) { + if (mChangeListeners.isEmpty()) { return; } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/google/Recycler.java b/QKSMS/src/main/java/com/moez/QKSMS/common/google/Recycler.java index 682cf776..c34132db 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/google/Recycler.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/google/Recycler.java @@ -104,9 +104,9 @@ public abstract class Recycler { return /*prefs.getBoolean(MessagingPreferenceActivity.AUTO_DELETE, DEFAULT_AUTO_DELETE)*/ false; } - abstract public int getMessageLimit(Context context); + public abstract int getMessageLimit(Context context); - abstract public void setMessageLimit(Context context, int limit); + public abstract void setMessageLimit(Context context, int limit); public int getMessageMinLimit() { return MmsConfig.getMinMessageCountPerThread(); @@ -116,15 +116,15 @@ public abstract class Recycler { return MmsConfig.getMaxMessageCountPerThread(); } - abstract protected long getThreadId(Cursor cursor); + protected abstract long getThreadId(Cursor cursor); - abstract protected Cursor getAllThreads(Context context); + protected abstract Cursor getAllThreads(Context context); - abstract protected void deleteMessagesForThread(Context context, long threadId, int keep); + protected abstract void deleteMessagesForThread(Context context, long threadId, int keep); - abstract protected void dumpMessage(Cursor cursor, Context context); + protected abstract void dumpMessage(Cursor cursor, Context context); - abstract protected boolean anyThreadOverLimit(Context context); + protected abstract boolean anyThreadOverLimit(Context context); public static class SmsRecycler extends Recycler { private static final String[] ALL_SMS_THREADS_PROJECTION = { @@ -135,7 +135,7 @@ public abstract class Recycler { private static final int ID = 0; private static final int MESSAGE_COUNT = 1; - static private final String[] SMS_MESSAGE_PROJECTION = new String[] { + private static final String[] SMS_MESSAGE_PROJECTION = new String[] { BaseColumns._ID, Conversations.THREAD_ID, Sms.ADDRESS, @@ -148,14 +148,14 @@ public abstract class Recycler { // The indexes of the default columns which must be consistent // with above PROJECTION. - static private final int COLUMN_ID = 0; - static private final int COLUMN_THREAD_ID = 1; - static private final int COLUMN_SMS_ADDRESS = 2; - static private final int COLUMN_SMS_BODY = 3; - static private final int COLUMN_SMS_DATE = 4; - static private final int COLUMN_SMS_READ = 5; - static private final int COLUMN_SMS_TYPE = 6; - static private final int COLUMN_SMS_STATUS = 7; + private static final int COLUMN_ID = 0; + private static final int COLUMN_THREAD_ID = 1; + private static final int COLUMN_SMS_ADDRESS = 2; + private static final int COLUMN_SMS_BODY = 3; + private static final int COLUMN_SMS_DATE = 4; + private static final int COLUMN_SMS_READ = 5; + private static final int COLUMN_SMS_TYPE = 6; + private static final int COLUMN_SMS_STATUS = 7; private final String MAX_SMS_MESSAGES_PER_THREAD = "MaxSmsMessagesPerThread"; @@ -283,7 +283,7 @@ public abstract class Recycler { private static final int ID = 0; private static final int MESSAGE_COUNT = 1; - static private final String[] MMS_MESSAGE_PROJECTION = new String[] { + private static final String[] MMS_MESSAGE_PROJECTION = new String[] { BaseColumns._ID, Conversations.THREAD_ID, Mms.DATE, @@ -291,10 +291,10 @@ public abstract class Recycler { // The indexes of the default columns which must be consistent // with above PROJECTION. - static private final int COLUMN_ID = 0; - static private final int COLUMN_THREAD_ID = 1; - static private final int COLUMN_MMS_DATE = 2; - static private final int COLUMN_MMS_READ = 3; + private static final int COLUMN_ID = 0; + private static final int COLUMN_THREAD_ID = 1; + private static final int COLUMN_MMS_DATE = 2; + private static final int COLUMN_MMS_READ = 3; private final String MAX_MMS_MESSAGES_PER_THREAD = "MaxMmsMessagesPerThread"; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/google/SimpleCache.java b/QKSMS/src/main/java/com/moez/QKSMS/common/google/SimpleCache.java index a98a2182..b624667b 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/google/SimpleCache.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/google/SimpleCache.java @@ -29,6 +29,8 @@ import java.util.LinkedHashMap; * from Peter Balwin and books app. */ public class SimpleCache { + private final SoftReferenceMap mSoftReferences; + private final HardReferenceMap mHardReferences; /** * A simple LRU cache to prevent the number of {@link java.util.Map.Entry} instances @@ -66,13 +68,6 @@ public class SimpleCache { } } - private static V unwrap(SoftReference ref) { - return ref != null ? ref.get() : null; - } - - private final SoftReferenceMap mSoftReferences; - private final HardReferenceMap mHardReferences; - /** * Constructor. * @@ -95,6 +90,10 @@ public class SimpleCache { } } + private static V unwrap(SoftReference ref) { + return ref != null ? ref.get() : null; + } + /** * See {@link java.util.Map#get(Object)}. */ diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/google/UriImage.java b/QKSMS/src/main/java/com/moez/QKSMS/common/google/UriImage.java index 38e2297e..d7d71d22 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/google/UriImage.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/google/UriImage.java @@ -47,6 +47,7 @@ import java.io.IOException; import java.io.InputStream; public class UriImage { + private static final int NUMBER_OF_RESIZE_ATTEMPTS = 4; private static final String TAG = "Mms/image"; private static final boolean DEBUG = false; private static final boolean LOCAL_LOGV = false; @@ -259,8 +260,6 @@ public class UriImage { return part; } - private static final int NUMBER_OF_RESIZE_ATTEMPTS = 4; - /** * Resize and recompress the image such that it fits the given limits. The resulting byte * array contains an image in JPEG format, regardless of the original image's content type. diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/utils/DateFormatter.java b/QKSMS/src/main/java/com/moez/QKSMS/common/utils/DateFormatter.java index 43619e7e..0d240d7d 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/utils/DateFormatter.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/utils/DateFormatter.java @@ -1,13 +1,10 @@ package com.moez.QKSMS.common.utils; import android.content.Context; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; import android.text.format.DateFormat; import android.text.format.DateUtils; import com.moez.QKSMS.QKSMSApp; import com.moez.QKSMS.R; -import com.moez.QKSMS.ui.settings.SettingsFragment; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -48,8 +45,7 @@ public abstract class DateFormatter { } public static SimpleDateFormat accountFor24HourTime(Context context, SimpleDateFormat input) { //pass in 12 hour time. If needed, change to 24 hr. - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - boolean isUsing24HourTime = prefs.getBoolean(SettingsFragment.TIMESTAMPS_24H, DateFormat.is24HourFormat(context)); + boolean isUsing24HourTime = DateFormat.is24HourFormat(context); if (isUsing24HourTime) { return new SimpleDateFormat(input.toPattern().replace('h', 'H').replaceAll(" a", "")); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/data/Contact.java b/QKSMS/src/main/java/com/moez/QKSMS/data/Contact.java index 2686a569..4d447f4e 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/data/Contact.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/data/Contact.java @@ -503,14 +503,14 @@ public class Contact { while (true) { Runnable r = null; synchronized (mThingsToLoad) { - if (mThingsToLoad.size() == 0) { + if (mThingsToLoad.isEmpty()) { try { mThingsToLoad.wait(); } catch (InterruptedException ex) { break; // Exception sent by Contact.init() to stop Runnable } } - if (mThingsToLoad.size() > 0) { + if (!mThingsToLoad.isEmpty()) { r = mThingsToLoad.remove(0); } } @@ -1175,7 +1175,7 @@ public class Contact { } } } - if (candidates.size() == 0) { + if (candidates.isEmpty()) { mContactsHash.remove(key); } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/enums/QKPreference.java b/QKSMS/src/main/java/com/moez/QKSMS/enums/QKPreference.java index 32b53c70..92987148 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/enums/QKPreference.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/enums/QKPreference.java @@ -33,7 +33,6 @@ public enum QKPreference { HIDE_AVATAR_RECEIVED("pref_key_hide_avatar_received", false), MESSAGE_COUNT("pref_key_message_count", false), - TIMESTAMPS_24H("pref_key_24h", false), // General DELAYED_MESSAGING("pref_key_delayed", false), @@ -101,7 +100,8 @@ public enum QKPreference { // Storage COMPOSE_DRAFT("compose_draft", ""), - LAST_AUTO_DELETE_CHECK("last_auto_delete_check", 0); + LAST_AUTO_DELETE_CHECK("last_auto_delete_check", 0), + MIGRATED_ICON("migrated_icon", false); private String mKey; private Object mDefaultValue; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/exif/ExifData.java b/QKSMS/src/main/java/com/moez/QKSMS/exif/ExifData.java index 6a8eb851..3e7c1c45 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/exif/ExifData.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/exif/ExifData.java @@ -110,7 +110,7 @@ class ExifData { * Returns true if this header contains uncompressed strip. */ protected boolean hasUncompressedStrip() { - return mStripBytes.size() != 0; + return !mStripBytes.isEmpty(); } /** @@ -264,7 +264,7 @@ class ExifData { } } } - if (ret.size() == 0) { + if (ret.isEmpty()) { return null; } return ret; @@ -287,7 +287,7 @@ class ExifData { for (ExifTag t : tags) { ret.add(t); } - if (ret.size() == 0) { + if (ret.isEmpty()) { return null; } return ret; @@ -307,7 +307,7 @@ class ExifData { } } } - if (ret.size() == 0) { + if (ret.isEmpty()) { return null; } return ret; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/exif/ExifInterface.java b/QKSMS/src/main/java/com/moez/QKSMS/exif/ExifInterface.java index b2f09621..6c7c6159 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/exif/ExifInterface.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/exif/ExifInterface.java @@ -2348,7 +2348,7 @@ public class ExifInterface { l.add(ifds[i]); } } - if (l.size() <= 0) { + if (l.isEmpty()) { return null; } int[] ret = new int[l.size()]; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/external/iab/Base64.java b/QKSMS/src/main/java/com/moez/QKSMS/external/iab/Base64.java index 73a315f7..c5352f21 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/external/iab/Base64.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/external/iab/Base64.java @@ -40,21 +40,21 @@ package com.moez.QKSMS.external.iab; */ public class Base64 { /** Specify encoding (value is {@code true}). */ - public final static boolean ENCODE = true; + public static final boolean ENCODE = true; /** Specify decoding (value is {@code false}). */ - public final static boolean DECODE = false; + public static final boolean DECODE = false; /** The equals sign (=) as a byte. */ - private final static byte EQUALS_SIGN = (byte) '='; + private static final byte EQUALS_SIGN = (byte) '='; /** The new line character (\n) as a byte. */ - private final static byte NEW_LINE = (byte) '\n'; + private static final byte NEW_LINE = (byte) '\n'; /** * The 64 valid Base64 values. */ - private final static byte[] ALPHABET = + private static final byte[] ALPHABET = {(byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P', @@ -72,7 +72,7 @@ public class Base64 { /** * The 64 valid web safe Base64 values. */ - private final static byte[] WEBSAFE_ALPHABET = + private static final byte[] WEBSAFE_ALPHABET = {(byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P', @@ -91,7 +91,7 @@ public class Base64 { * Translates a Base64 value to either its 6-bit reconstruction value * or a negative number indicating some other meaning. **/ - private final static byte[] DECODABET = {-9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 0 - 8 + private static final byte[] DECODABET = {-9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 0 - 8 -5, -5, // Whitespace: Tab and Linefeed -9, -9, // Decimal 11 - 12 -5, // Whitespace: Carriage Return @@ -125,7 +125,7 @@ public class Base64 { }; /** The web safe decodabet */ - private final static byte[] WEBSAFE_DECODABET = + private static final byte[] WEBSAFE_DECODABET = {-9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 0 - 8 -5, -5, // Whitespace: Tab and Linefeed -9, -9, // Decimal 11 - 12 @@ -161,9 +161,9 @@ public class Base64 { }; // Indicates white space in encoding - private final static byte WHITE_SPACE_ENC = -5; + private static final byte WHITE_SPACE_ENC = -5; // Indicates equals sign in encoding - private final static byte EQUALS_SIGN_ENC = -1; + private static final byte EQUALS_SIGN_ENC = -1; /** Defeats instantiation. */ private Base64() { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/external/iab/IabHelper.java b/QKSMS/src/main/java/com/moez/QKSMS/external/iab/IabHelper.java index 41df69fb..b2f01221 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/external/iab/IabHelper.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/external/iab/IabHelper.java @@ -921,7 +921,7 @@ public class IabHelper { } } - if (skuList.size() == 0) { + if (skuList.isEmpty()) { logDebug("queryPrices: nothing to do because there are no SKUs."); return BILLING_RESPONSE_RESULT_OK; } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/model/MediaModel.java b/QKSMS/src/main/java/com/moez/QKSMS/model/MediaModel.java index cad605e3..d97edc23 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/model/MediaModel.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/model/MediaModel.java @@ -282,7 +282,7 @@ public abstract class MediaModel extends Model implements EventListener { } public MediaAction getCurrentAction() { - if (0 == mMediaActions.size()) { + if (mMediaActions.isEmpty()) { return MediaAction.NO_ACTIVE_ACTION; } return mMediaActions.remove(0); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/model/SlideModel.java b/QKSMS/src/main/java/com/moez/QKSMS/model/SlideModel.java index 7b580132..bcea5e28 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/model/SlideModel.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/model/SlideModel.java @@ -279,16 +279,19 @@ public class SlideModel extends Model implements List, EventListener * @throws ContentRestrictionException when can not add this object. * */ + @Override public boolean add(MediaModel object) { internalAdd(object); notifyModelChanged(true); return true; } + @Override public boolean addAll(Collection collection) { throw new UnsupportedOperationException("Operation not supported."); } + @Override public void clear() { if (mMedia.size() > 0) { for (MediaModel media : mMedia) { @@ -312,22 +315,27 @@ public class SlideModel extends Model implements List, EventListener } } + @Override public boolean contains(Object object) { return mMedia.contains(object); } + @Override public boolean containsAll(Collection collection) { return mMedia.containsAll(collection); } + @Override public boolean isEmpty() { return mMedia.isEmpty(); } + @Override public Iterator iterator() { return mMedia.iterator(); } + @Override public boolean remove(Object object) { if ((object != null) && (object instanceof MediaModel) && internalRemove(object)) { @@ -337,35 +345,43 @@ public class SlideModel extends Model implements List, EventListener return false; } + @Override public boolean removeAll(Collection collection) { throw new UnsupportedOperationException("Operation not supported."); } + @Override public boolean retainAll(Collection collection) { throw new UnsupportedOperationException("Operation not supported."); } + @Override public int size() { return mMedia.size(); } + @Override public Object[] toArray() { return mMedia.toArray(); } + @Override public T[] toArray(T[] array) { return mMedia.toArray(array); } + @Override public void add(int location, MediaModel object) { throw new UnsupportedOperationException("Operation not supported."); } + @Override public boolean addAll(int location, Collection collection) { throw new UnsupportedOperationException("Operation not supported."); } + @Override public MediaModel get(int location) { if (mMedia.size() == 0) { return null; @@ -374,22 +390,27 @@ public class SlideModel extends Model implements List, EventListener return mMedia.get(location); } + @Override public int indexOf(Object object) { return mMedia.indexOf(object); } + @Override public int lastIndexOf(Object object) { return mMedia.lastIndexOf(object); } + @Override public ListIterator listIterator() { return mMedia.listIterator(); } + @Override public ListIterator listIterator(int location) { return mMedia.listIterator(location); } + @Override public MediaModel remove(int location) { MediaModel media = mMedia.get(location); if ((media != null) && internalRemove(media)) { @@ -398,10 +419,12 @@ public class SlideModel extends Model implements List, EventListener return media; } + @Override public MediaModel set(int location, MediaModel object) { throw new UnsupportedOperationException("Operation not supported."); } + @Override public List subList(int start, int end) { return mMedia.subList(start, end); } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/model/SlideshowModel.java b/QKSMS/src/main/java/com/moez/QKSMS/model/SlideshowModel.java index 88cb3512..1e6142b5 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/model/SlideshowModel.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/model/SlideshowModel.java @@ -406,6 +406,7 @@ public class SlideshowModel extends Model // // Implement List interface. // + @Override public boolean add(SlideModel object) { int increaseSize = object.getSlideSize(); checkMessageSize(increaseSize); @@ -422,10 +423,12 @@ public class SlideshowModel extends Model return false; } + @Override public boolean addAll(Collection collection) { throw new UnsupportedOperationException("Operation not supported."); } + @Override public void clear() { if (mSlides.size() > 0) { for (SlideModel slide : mSlides) { @@ -440,22 +443,27 @@ public class SlideshowModel extends Model } } + @Override public boolean contains(Object object) { return mSlides.contains(object); } + @Override public boolean containsAll(Collection collection) { return mSlides.containsAll(collection); } + @Override public boolean isEmpty() { return mSlides.isEmpty(); } + @Override public Iterator iterator() { return mSlides.iterator(); } + @Override public boolean remove(Object object) { if ((object != null) && mSlides.remove(object)) { SlideModel slide = (SlideModel) object; @@ -467,26 +475,32 @@ public class SlideshowModel extends Model return false; } + @Override public boolean removeAll(Collection collection) { throw new UnsupportedOperationException("Operation not supported."); } + @Override public boolean retainAll(Collection collection) { throw new UnsupportedOperationException("Operation not supported."); } + @Override public int size() { return mSlides.size(); } + @Override public Object[] toArray() { return mSlides.toArray(); } + @Override public T[] toArray(T[] array) { return mSlides.toArray(array); } + @Override public void add(int location, SlideModel object) { if (object != null) { int increaseSize = object.getSlideSize(); @@ -502,31 +516,38 @@ public class SlideshowModel extends Model } } + @Override public boolean addAll(int location, Collection collection) { throw new UnsupportedOperationException("Operation not supported."); } + @Override public SlideModel get(int location) { return (location >= 0 && location < mSlides.size()) ? mSlides.get(location) : null; } + @Override public int indexOf(Object object) { return mSlides.indexOf(object); } + @Override public int lastIndexOf(Object object) { return mSlides.lastIndexOf(object); } + @Override public ListIterator listIterator() { return mSlides.listIterator(); } + @Override public ListIterator listIterator(int location) { return mSlides.listIterator(location); } + @Override public SlideModel remove(int location) { SlideModel slide = mSlides.remove(location); if (slide != null) { @@ -537,6 +558,7 @@ public class SlideshowModel extends Model return slide; } + @Override public SlideModel set(int location, SlideModel object) { SlideModel slide = mSlides.get(location); if (null != object) { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/service/HeadlessSmsSendService.java b/QKSMS/src/main/java/com/moez/QKSMS/service/HeadlessSmsSendService.java index 2bd6eafc..213ce11d 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/service/HeadlessSmsSendService.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/service/HeadlessSmsSendService.java @@ -1,12 +1,49 @@ package com.moez.QKSMS.service; -import android.app.Service; +import android.app.IntentService; import android.content.Intent; -import android.os.IBinder; +import android.net.Uri; +import android.os.Bundle; +import android.telephony.TelephonyManager; +import android.text.TextUtils; +import com.moez.QKSMS.mmssms.Message; +import com.moez.QKSMS.mmssms.Transaction; +import com.moez.QKSMS.transaction.NotificationManager; +import com.moez.QKSMS.transaction.SmsHelper; + +import static com.moez.QKSMS.data.Conversation.getRecipients; + +public class HeadlessSmsSendService extends IntentService { + private static final String TAG = "HeadlessSmsSendService"; + + public HeadlessSmsSendService() { + super(TAG); + } -public class HeadlessSmsSendService extends Service { @Override - public IBinder onBind(Intent intent) { - return null; + protected void onHandleIntent(Intent intent) { + String action = intent.getAction(); + if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(action)) { + return; + } + + Bundle extras = intent.getExtras(); + if (extras != null) { + String body = extras.getString(Intent.EXTRA_TEXT); + Uri intentUri = intent.getData(); + String recipients = getRecipients(intentUri); + + if (!TextUtils.isEmpty(recipients) && !TextUtils.isEmpty(body)) { + String[] destinations = TextUtils.split(recipients, ";"); + + Transaction sendTransaction = new Transaction(this, SmsHelper.getSendSettings(this)); + + Message message = new Message(body, destinations); + message.setType(Message.TYPE_SMSMMS); + + sendTransaction.sendNewMessage(message, Transaction.NO_THREAD_ID); + NotificationManager.update(this); + } + } } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java index f9778643..1ef3120d 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java @@ -11,24 +11,39 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Resources; +import android.graphics.Color; +import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Build; import android.preference.PreferenceManager; +import android.support.annotation.ColorInt; +import android.support.annotation.DrawableRes; +import android.support.v4.content.ContextCompat; +import android.support.v4.view.ViewPager; import android.util.Log; -import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; import android.view.animation.DecelerateInterpolator; +import android.view.inputmethod.EditorInfo; +import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.SeekBar; +import butterknife.Bind; +import butterknife.ButterKnife; import com.moez.QKSMS.R; import com.moez.QKSMS.common.AnalyticsManager; import com.moez.QKSMS.common.CIELChEvaluator; import com.moez.QKSMS.common.ConversationPrefsHelper; import com.moez.QKSMS.common.LiveViewManager; -import com.moez.QKSMS.enums.QKPreference; import com.moez.QKSMS.common.utils.ColorUtils; +import com.moez.QKSMS.common.utils.KeyboardUtils; +import com.moez.QKSMS.enums.QKPreference; import com.moez.QKSMS.receiver.IconColorReceiver; import com.moez.QKSMS.ui.base.QKActivity; +import com.moez.QKSMS.ui.dialog.ColorPickerPagerAdapter; import com.moez.QKSMS.ui.dialog.QKDialog; import com.moez.QKSMS.ui.settings.SettingsFragment; +import com.moez.QKSMS.ui.view.QKEditText; import com.moez.QKSMS.ui.view.QKTextView; import com.moez.QKSMS.ui.view.colorpicker.ColorPickerPalette; import com.moez.QKSMS.ui.widget.WidgetProvider; @@ -227,7 +242,7 @@ public class ThemeManager { private static int mReceivedBubbleRes; private static int mReceivedBubbleAltRes; private static boolean mReceivedBubbleColored; - private static Drawable mRippleBackground; + private static int mRippleBackgroundRes; private static Resources mResources; private static SharedPreferences mPrefs; @@ -240,7 +255,7 @@ public class ThemeManager { mPrefs = PreferenceManager.getDefaultSharedPreferences(context); mResources = context.getResources(); - mColor = Integer.parseInt(mPrefs.getString(SettingsFragment.THEME, "" + ThemeManager.DEFAULT_COLOR)); + mColor = Integer.parseInt(mPrefs.getString(SettingsFragment.THEME, "" + DEFAULT_COLOR)); mActiveColor = mColor; initializeTheme(Theme.fromString(mPrefs.getString(SettingsFragment.BACKGROUND, "offwhite"))); @@ -281,21 +296,21 @@ public class ThemeManager { mBackgroundColor = mResources.getColor(R.color.grey_light_mega_ultra); mTextOnBackgroundPrimary = mResources.getColor(R.color.theme_light_text_primary); mtextOnBackgroundSecondary = mResources.getColor(R.color.theme_light_text_secondary); - mRippleBackground = mResources.getDrawable(R.drawable.button_background_transparent); + mRippleBackgroundRes = R.drawable.ripple; break; case DARK: mBackgroundColor = mResources.getColor(R.color.grey_material); mTextOnBackgroundPrimary = mResources.getColor(R.color.theme_dark_text_primary); mtextOnBackgroundSecondary = mResources.getColor(R.color.theme_dark_text_secondary); - mRippleBackground = mResources.getDrawable(R.drawable.button_background_transparent_light); + mRippleBackgroundRes = R.drawable.ripple_light; break; case BLACK: mBackgroundColor = mResources.getColor(R.color.black); mTextOnBackgroundPrimary = mResources.getColor(R.color.theme_dark_text_primary); mtextOnBackgroundSecondary = mResources.getColor(R.color.theme_dark_text_secondary); - mRippleBackground = mResources.getDrawable(R.drawable.button_background_transparent_light); + mRippleBackgroundRes = R.drawable.ripple_light; break; } @@ -311,7 +326,7 @@ public class ThemeManager { LiveViewManager.refreshViews(QKPreference.BACKGROUND); } - public static void setIcon(final QKActivity context) { + public static void setIcon(final QKActivity context, boolean dark) { new QKDialog() .setContext(context) .setTitle(R.string.update_icon_title) @@ -320,90 +335,116 @@ public class ThemeManager { .setPositiveButton(R.string.okay, v -> { PackageManager packageManager = context.getPackageManager(); - String[] colors = { - "Red", "Pink", "Purple", "DeepPurple", "Indigo", "Blue", - "LightBlue", "Cyan", "Teal", "Green", "LightGreen", "Lime", - "Yellow", "Amber", "Orange", "DeepOrange", "Brown", "Grey", - "BlueGrey" - }; + String defaultComponent = "com.moez.QKSMS.ui.MainActivity-Default"; + String darkComponent = "com.moez.QKSMS.ui.MainActivity-Dark"; - // Disable all of the color aliases, except for the alias with the current - // color. - String enabledComponent = null; - for (int i = 0; i < colors.length; i++) { - String componentClassName = String.format( - "com.moez.QKSMS.ui.MainActivity-%s", colors[i] - ); - - // Save the enabled component so we can kill the app with this one when - // it's all done. - if (getSwatchColor(mColor) == PALETTE[i]) { - enabledComponent = componentClassName; - - } else { - packageManager.setComponentEnabledSetting( - new ComponentName(context, componentClassName), - PackageManager.COMPONENT_ENABLED_STATE_DISABLED, - // Don't kill the app while we're in the loop! This will - // prevent the other component enabled settings from - // changing, i.e. they will all be disabled and the app - // won't show up to the user. - PackageManager.DONT_KILL_APP - ); - } - } + packageManager.setComponentEnabledSetting( + new ComponentName(context, dark ? defaultComponent : darkComponent), + PackageManager.COMPONENT_ENABLED_STATE_DISABLED, + // Don't kill the app while we're in the loop! This will + // prevent the other component enabled settings from + // changing, i.e. they will all be disabled and the app + // won't show up to the user. + PackageManager.DONT_KILL_APP + ); // Broadcast an intent to a receiver that will: // 1) enable the last component; and // 2) relaunch QKSMS with the new component name. Intent intent = new Intent(IconColorReceiver.ACTION_ICON_COLOR_CHANGED); - intent.putExtra(IconColorReceiver.EXTRA_COMPONENT_NAME, enabledComponent); + intent.putExtra(IconColorReceiver.EXTRA_COMPONENT_NAME, dark ? darkComponent : defaultComponent); context.sendBroadcast(intent); }) - .setNegativeButton(R.string.cancel, null) + .setCancelOnTouchOutside(false) .show(); } + public static void migrateIcon(Context context) { + PackageManager packageManager = context.getPackageManager(); + + // If we've already migrated to use the MainActivity-Default component, we don't need to do anything + if (mPrefs.getBoolean(QKPreference.MIGRATED_ICON.getKey(), (Boolean) QKPreference.MIGRATED_ICON.getDefaultValue())) { + return; + } + + mPrefs.edit().putBoolean(QKPreference.MIGRATED_ICON.getKey(), true).apply(); + + String[] colors = { + "Red", "Pink", "Purple", "DeepPurple", "Indigo", "Blue", + "LightBlue", "Cyan", "Teal", "Green", "LightGreen", "Lime", + "Yellow", "Amber", "Orange", "DeepOrange", "Brown", "Grey", + "BlueGrey" + }; + + // Disable all of the old components + for (String color : colors) { + String componentClassName = String.format("com.moez.QKSMS.ui.MainActivity-%s", color); + packageManager.setComponentEnabledSetting( + new ComponentName(context, componentClassName), + PackageManager.COMPONENT_ENABLED_STATE_DISABLED, + PackageManager.DONT_KILL_APP + ); + } + + // Enable the new component + ComponentName componentName = new ComponentName(context, "com.moez.QKSMS.ui.MainActivity-Default"); + packageManager.setComponentEnabledSetting(componentName, + PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + PackageManager.DONT_KILL_APP + ); + } + + @ColorInt public static int getBackgroundColor() { return mBackgroundColor; } + @ColorInt public static int getTextOnColorPrimary() { return mTextOnColorPrimary; } + @ColorInt public static int getTextOnColorSecondary() { return mTextOnColorSecondary; } + @ColorInt public static int getTextOnBackgroundPrimary() { return mTextOnBackgroundPrimary; } + @ColorInt public static int getTextOnBackgroundSecondary() { return mtextOnBackgroundSecondary; } + @DrawableRes public static int getSentBubbleRes() { return mSentBubbleRes; } + @DrawableRes public static int getSentBubbleAltRes() { return mSentBubbleAltRes; } + @ColorInt public static int getSentBubbleColor() { return mSentBubbleColored ? mActiveColor : getNeutralBubbleColor(); } + @DrawableRes public static int getReceivedBubbleRes() { return mReceivedBubbleRes; } + @DrawableRes public static int getReceivedBubbleAltRes() { return mReceivedBubbleAltRes; } + @ColorInt public static int getReceivedBubbleColor() { return mReceivedBubbleColored ? mActiveColor : getNeutralBubbleColor(); } @@ -423,6 +464,7 @@ public class ThemeManager { mReceivedBubbleColored = colored; } + @ColorInt public static int getNeutralBubbleColor() { if (mTheme == null) { return 0xeeeeee; @@ -441,13 +483,15 @@ public class ThemeManager { } public static Drawable getRippleBackground() { - return mRippleBackground; + return mResources.getDrawable(mRippleBackgroundRes); } + @ColorInt public static int getColor() { return mActiveColor; } + @ColorInt public static int getThemeColor() { return mColor; } @@ -461,53 +505,143 @@ public class ThemeManager { } public static void showColorPickerDialog(final QKActivity context) { - final QKDialog dialog = new QKDialog(); - - ColorPickerPalette palette = new ColorPickerPalette(context); - palette.setGravity(Gravity.CENTER); - palette.init(19, 4, color -> { - palette.init(getSwatch(color).length, 4, color2 -> { - setColor(context, color2); - dialog.dismiss(); - }); - - palette.drawPalette(getSwatch(color), mColor); - }); - - palette.drawPalette(PALETTE, getSwatchColor(mColor)); - - dialog.setContext(context) - .setTitle(R.string.pref_theme) - .setCustomView(palette) - .setNegativeButton(R.string.cancel, null); - - dialog.show(); + showColorPicker(context, v -> setColor(context, getColor())); } public static void showColorPickerDialogForConversation(final QKActivity context, ConversationPrefsHelper prefs) { + showColorPicker(context, v -> { + prefs.putString(QKPreference.THEME.getKey(), "" + getColor()); + LiveViewManager.refreshViews(QKPreference.CONVERSATION_THEME); + }); + } + + private static void showColorPicker(QKActivity context, View.OnClickListener saveListener) { final QKDialog dialog = new QKDialog(); - ColorPickerPalette palette = new ColorPickerPalette(context); - palette.setGravity(Gravity.CENTER); - palette.init(19, 4, color -> { - palette.init(getSwatch(color).length, 4, color2 -> { - prefs.putString(QKPreference.THEME.getKey(), "" + color2); - setActiveColor(color2); - LiveViewManager.refreshViews(QKPreference.CONVERSATION_THEME); - dialog.dismiss(); - }); + View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_color_picker, null, false); + ColorPickerViewHolder holder = new ColorPickerViewHolder(view); - palette.drawPalette(getSwatch(color), prefs.getColor()); + holder.mTab1.setBackgroundDrawable(getRippleBackground()); + holder.mTab2.setBackgroundDrawable(getRippleBackground()); + holder.mTab1.setOnClickListener(v -> holder.mPager.setCurrentItem(0)); + holder.mTab2.setOnClickListener(v -> holder.mPager.setCurrentItem(1)); + + ColorPickerPagerAdapter adapter = new ColorPickerPagerAdapter(context); + holder.mPager.setAdapter(adapter); + holder.mPager.setOffscreenPageLimit(1); + holder.mPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { + @Override + public void onPageSelected(int position) { + super.onPageSelected(position); + holder.mTab1.setTextColor(position == 0 ? getColor() : getTextOnBackgroundPrimary()); + holder.mTab2.setTextColor(position == 1 ? getColor() : getTextOnBackgroundPrimary()); + } }); - palette.drawPalette(PALETTE, getSwatchColor(prefs.getColor())); + int swatchColor = getSwatchColor(getColor()); + holder.mPalette.init(19, 4, color -> { + holder.mPalette.init(getSwatch(color).length, 4, color2 -> { + setActiveColor(color2); + saveListener.onClick(null); + dialog.dismiss(); + }); + holder.mPalette.drawPalette(getSwatch(color), getColor()); + }); + holder.mPalette.drawPalette(PALETTE, swatchColor); + + if (swatchColor == getColor()) { // If the current theme was set from the RGB picker, show that page instead + holder.mPager.setCurrentItem(1); + } + + + SeekBar.OnSeekBarChangeListener seekListener = new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + int color = getColor(); + color = Color.rgb(seekBar == holder.mRed ? progress : Color.red(color), + seekBar == holder.mGreen ? progress : Color.green(color), + seekBar == holder.mBlue ? progress : Color.blue(color)); + + if (seekBar == holder.mRed) holder.mRedValue.setText(String.valueOf(progress)); + if (seekBar == holder.mGreen) holder.mGreenValue.setText(String.valueOf(progress)); + if (seekBar == holder.mBlue) holder.mBlueValue.setText(String.valueOf(progress)); + + setActiveColor(color); + String colorString = Integer.toHexString(color); + holder.mHex.setTextChangedListenerEnabled(false); + holder.mHex.setText(colorString.substring(colorString.length() > 6 ? colorString.length() - 6 : 0)); + holder.mHex.setTextChangedListenerEnabled(true); + holder.mError.setVisibility(View.INVISIBLE); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + } + }; + + Drawable thumbRed = ContextCompat.getDrawable(mContext, R.drawable.seek_thumb); + Drawable thumbGreen = ContextCompat.getDrawable(mContext, R.drawable.seek_thumb); + Drawable thumbBlue = ContextCompat.getDrawable(mContext, R.drawable.seek_thumb); + LiveViewManager.registerView(QKPreference.THEME, holder.mPreview, key -> { + holder.mPreview.setBackgroundColor(getColor()); + holder.mRed.getProgressDrawable().setColorFilter(getColor(), PorterDuff.Mode.MULTIPLY); + holder.mGreen.getProgressDrawable().setColorFilter(getColor(), PorterDuff.Mode.MULTIPLY); + holder.mBlue.getProgressDrawable().setColorFilter(getColor(), PorterDuff.Mode.MULTIPLY); + if (holder.mPager.getCurrentItem() == 0) { + holder.mTab1.setTextColor(getColor()); + } else { + holder.mTab2.setTextColor(getColor()); + } + }); + + LiveViewManager.registerView(QKPreference.BACKGROUND, holder.mHex, key -> { + holder.mHex.getBackground().setColorFilter(0x22888888, PorterDuff.Mode.MULTIPLY); + holder.mError.setColorFilter(getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP); + }); + + holder.mRed.setThumb(thumbRed); + holder.mRed.setOnSeekBarChangeListener(seekListener); + holder.mGreen.setThumb(thumbGreen); + holder.mGreen.setOnSeekBarChangeListener(seekListener); + holder.mBlue.setThumb(thumbBlue); + holder.mBlue.setOnSeekBarChangeListener(seekListener); + + holder.mRed.setProgress(Color.red(getColor())); + holder.mGreen.setProgress(Color.green(getColor())); + holder.mBlue.setProgress(Color.blue(getColor())); + + String colorString = Integer.toHexString(getColor()); + holder.mHex.setText(colorString.substring(colorString.length() > 6 ? colorString.length() - 6 : 0)); + holder.mHex.setOnEditorActionListener((v, actionId, event) -> { + if (actionId == EditorInfo.IME_ACTION_DONE) { + holder.mHex.clearFocus(); + KeyboardUtils.hide(mContext, holder.mHex); + } + return false; + }); + holder.mHex.setTextChangedListener(s -> { + if (s.length() == 6) { + int color = Color.parseColor("#" + s.toString()); + holder.mError.setVisibility(View.INVISIBLE); + if (color != getColor()) { + holder.mRed.setProgress(Color.red(color)); + holder.mGreen.setProgress(Color.green(color)); + holder.mBlue.setProgress(Color.blue(color)); + } + } else { + holder.mError.setVisibility(View.VISIBLE); + } + }); dialog.setContext(context) - .setTitle(R.string.pref_theme) - .setCustomView(palette) - .setNegativeButton(R.string.cancel, null); - - dialog.show(); + .setCustomView(view) + .setNegativeButton(R.string.cancel, v -> setActiveColor(getThemeColor())) + .setPositiveButton(R.string.save, saveListener) + .show(); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) @@ -548,7 +682,7 @@ public class ThemeManager { getColorString(color) ); - int colorFrom = mColor; + int colorFrom = mActiveColor; mColor = color; mActiveColor = color; @@ -596,8 +730,10 @@ public class ThemeManager { } public static void setActiveColor(int color) { - mActiveColor = color; - LiveViewManager.refreshViews(QKPreference.THEME); + if (mActiveColor != color) { + mActiveColor = color; + LiveViewManager.refreshViews(QKPreference.THEME); + } } private static boolean isColorDarkEnough(int color) { @@ -635,4 +771,25 @@ public class ThemeManager { return PALETTE; } + + static class ColorPickerViewHolder { + @Bind(R.id.tab_1) QKTextView mTab1; + @Bind(R.id.tab_2) QKTextView mTab2; + @Bind(R.id.pager) ViewPager mPager; + @Bind(R.id.palette) ColorPickerPalette mPalette; + @Bind(R.id.preview) View mPreview; + @Bind(R.id.red) SeekBar mRed; + @Bind(R.id.red_value) QKTextView mRedValue; + @Bind(R.id.green) SeekBar mGreen; + @Bind(R.id.green_value) QKTextView mGreenValue; + @Bind(R.id.blue) SeekBar mBlue; + @Bind(R.id.blue_value) QKTextView mBlueValue; + @Bind(R.id.hex) QKEditText mHex; + @Bind(R.id.error) ImageView mError; + + public ColorPickerViewHolder(View view) { + ButterKnife.bind(this, view); + } + + } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListAdapter.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListAdapter.java index 37dbfef7..9f5897a1 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListAdapter.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListAdapter.java @@ -14,14 +14,11 @@ import com.moez.QKSMS.common.utils.DateFormatter; import com.moez.QKSMS.data.Contact; import com.moez.QKSMS.data.Conversation; import com.moez.QKSMS.enums.QKPreference; -import com.moez.QKSMS.interfaces.LiveView; import com.moez.QKSMS.ui.ThemeManager; import com.moez.QKSMS.ui.base.QKActivity; import com.moez.QKSMS.ui.base.RecyclerCursorAdapter; import com.moez.QKSMS.ui.settings.SettingsFragment; -import static com.moez.QKSMS.R.id.conversation; - public class ConversationListAdapter extends RecyclerCursorAdapter { @@ -53,6 +50,10 @@ public class ConversationListAdapter extends RecyclerCursorAdapter { + holder.root.setBackgroundDrawable(ThemeManager.getRippleBackground()); + }); + return holder; } @@ -105,8 +106,9 @@ public class ConversationListAdapter extends RecyclerCursorAdapter - holder.mAvatarView.setVisibility(QKPreferences.getBoolean(QKPreference.HIDE_AVATAR_CONVERSATIONS) ? View.GONE : View.VISIBLE)); + LiveViewManager.registerView(QKPreference.HIDE_AVATAR_CONVERSATIONS, this, key -> { + holder.mAvatarView.setVisibility(QKPreferences.getBoolean(QKPreference.HIDE_AVATAR_CONVERSATIONS) ? View.GONE : View.VISIBLE); + }); // Date holder.dateView.setText(DateFormatter.getConversationTimestamp(mContext, conversation.getDate())); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListViewHolder.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListViewHolder.java index 2e7d3712..f065c4e9 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListViewHolder.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListViewHolder.java @@ -11,7 +11,6 @@ import com.moez.QKSMS.R; import com.moez.QKSMS.data.Contact; import com.moez.QKSMS.data.Conversation; import com.moez.QKSMS.data.ConversationLegacy; -import com.moez.QKSMS.ui.MainActivity; import com.moez.QKSMS.ui.ThemeManager; import com.moez.QKSMS.ui.base.ClickyViewHolder; import com.moez.QKSMS.ui.base.QKActivity; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/delivery/DeliveryReportHelper.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/delivery/DeliveryReportHelper.java index 7bbab4e1..d2e10596 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/delivery/DeliveryReportHelper.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/delivery/DeliveryReportHelper.java @@ -208,7 +208,7 @@ public class DeliveryReportHelper { return null; } - if (reportReqs.size() == 0) { + if (reportReqs.isEmpty()) { return null; } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/ColorPickerPagerAdapter.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/ColorPickerPagerAdapter.java new file mode 100644 index 00000000..0eacfa77 --- /dev/null +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/ColorPickerPagerAdapter.java @@ -0,0 +1,57 @@ +package com.moez.QKSMS.ui.dialog; + +import android.support.v4.view.PagerAdapter; +import android.view.View; +import android.view.ViewGroup; +import com.moez.QKSMS.R; +import com.moez.QKSMS.ui.base.QKActivity; + +public class ColorPickerPagerAdapter extends PagerAdapter { + + private QKActivity mContext; + + public ColorPickerPagerAdapter(QKActivity context) { + mContext = context; + } + + public Object instantiateItem(ViewGroup collection, int position) { + int resId = 0; + switch (position) { + case 0: + resId = R.id.palette; + break; + + case 1: + resId = R.id.rgb; + break; + } + + return collection.findViewById(resId); + } + + @Override + public CharSequence getPageTitle(int position) { + int resId = 0; + switch (position) { + case 0: + resId = R.string.title_palette; + break; + + case 1: + resId = R.string.title_rgb; + break; + } + + return mContext.getString(resId); + } + + @Override + public int getCount() { + return 2; + } + + @Override + public boolean isViewFromObject(View arg0, Object arg1) { + return arg0 == ((View) arg1); + } +} diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/QKDialog.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/QKDialog.java index 465258ae..24c97785 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/QKDialog.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/QKDialog.java @@ -24,7 +24,9 @@ import android.widget.LinearLayout; import android.widget.ListView; import android.widget.ScrollView; import com.moez.QKSMS.R; +import com.moez.QKSMS.common.LiveViewManager; import com.moez.QKSMS.common.utils.Units; +import com.moez.QKSMS.enums.QKPreference; import com.moez.QKSMS.ui.ThemeManager; import com.moez.QKSMS.ui.base.QKActivity; import com.moez.QKSMS.ui.view.QKTextView; @@ -130,8 +132,10 @@ public class QKDialog extends DialogFragment { mPositiveButtonView = (QKTextView) view.findViewById(R.id.buttonPositive); mPositiveButtonView.setVisibility(View.VISIBLE); mPositiveButtonView.setText(mPositiveButtonText); - mPositiveButtonView.setTextColor(ThemeManager.getColor()); mPositiveButtonView.setOnClickListener(mPositiveButtonClickListener); + LiveViewManager.registerView(QKPreference.THEME, mPositiveButtonView, key -> { + mPositiveButtonView.setTextColor(ThemeManager.getColor()); + }); } if (mNeutralButtonEnabled) { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/mms/MMSSetupFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/mms/MMSSetupFragment.java index 9b7fd721..4a73eb25 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/mms/MMSSetupFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/mms/MMSSetupFragment.java @@ -207,7 +207,7 @@ public class MMSSetupFragment extends QKFragment implements DialogFragmentListen } private void showConfigurationDialog() { - if (mAPNs.size() == 0) { + if (mAPNs.isEmpty()) { // Give the user a support channel and further instructions if automatic // configuration failed. launchDialog(NO_CONFIGURATIONS_FOUND); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListAdapter.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListAdapter.java index cf05dafd..6730b902 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListAdapter.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListAdapter.java @@ -165,6 +165,8 @@ public class MessageListAdapter extends RecyclerCursorAdapter { + holder.mRoot.setBackgroundDrawable(ThemeManager.getRippleBackground()); + holder.mSlideShowButton.setBackgroundDrawable(ThemeManager.getRippleBackground()); holder.mMmsView.getForeground().setColorFilter(ThemeManager.getBackgroundColor(), PorterDuff.Mode.SRC_ATOP); }); @@ -280,7 +282,7 @@ public class MessageListAdapter extends RecyclerCursorAdapter { + view.setBackgroundDrawable(ThemeManager.getRippleBackground()); + }); + return new SearchViewHolder(mContext, view); } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java index 01602b30..3a40f5b8 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java @@ -82,7 +82,7 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O public static final String CATEGORY_APPEARANCE_SYSTEM_BARS = "pref_key_category_appearance_system_bars"; public static final String THEME = "pref_key_theme"; - public static final String ICON = "pref_key_icon"; + public static final String ICON = "pref_key_icon_dark"; public static final String STATUS_TINT = "pref_key_status_tint"; public static final String NAVIGATION_TINT = "pref_key_navigation_tint"; public static final String BACKGROUND = "pref_key_background"; @@ -121,7 +121,6 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O public static final String SPLIT_COUNTER = "pref_key_split_counter"; public static final String LONG_AS_MMS = "pref_key_long_as_mms"; public static final String LONG_AS_MMS_AFTER = "pref_key_long_as_mms_after"; - public static final String TIMESTAMPS_24H = "pref_key_24h"; public static final String NOTIFICATIONS = "pref_key_notifications"; public static final String NOTIFICATION_LED = "pref_key_led"; public static final String NOTIFICATION_LED_COLOR = "pref_key_theme_led"; @@ -426,6 +425,9 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O case BACKGROUND: ThemeManager.setTheme(ThemeManager.Theme.fromString((String) newValue)); break; + case ICON: + ThemeManager.setIcon(mContext, (Boolean) newValue); + break; case STATUS_TINT: ThemeManager.setStatusBarTintEnabled(mContext, (Boolean) newValue); break; @@ -569,9 +571,6 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O case BUBBLES: new BubblePreferenceDialog().setContext(mContext).show(); break; - case ICON: - ThemeManager.setIcon(mContext); - break; case BLOCKED_FUTURE: BlockedNumberDialog.showDialog(mContext); break; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/TimePickerFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/TimePickerFragment.java index 3d38215d..66373d10 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/TimePickerFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/TimePickerFragment.java @@ -55,7 +55,7 @@ public class TimePickerFragment extends DialogFragment implements TimePickerDial int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); - boolean isUsing24HourTime = mPrefs.getBoolean(SettingsFragment.TIMESTAMPS_24H, DateFormat.is24HourFormat(getActivity())); + boolean isUsing24HourTime = DateFormat.is24HourFormat(getActivity()); return new TimePickerDialog(getActivity(), this, hour, minute, isUsing24HourTime); } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKEditText.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKEditText.java index aed937c4..3bc8c1c5 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKEditText.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKEditText.java @@ -21,6 +21,7 @@ public class QKEditText extends android.widget.EditText { } private Context mContext; + private boolean mTextChangedListenerEnabled = true; public QKEditText(Context context) { super(context); @@ -77,6 +78,10 @@ public class QKEditText extends android.widget.EditText { super.setText(text, type); } + public void setTextChangedListenerEnabled(boolean textChangedListenerEnabled) { + mTextChangedListenerEnabled = textChangedListenerEnabled; + } + public void setTextChangedListener(final TextChangedListener listener) { if (listener != null) { addTextChangedListener(new TextWatcher() { @@ -91,7 +96,9 @@ public class QKEditText extends android.widget.EditText { @Override public void afterTextChanged(Editable s) { - listener.onTextChanged(s); + if (mTextChangedListenerEnabled) { + listener.onTextChanged(s); + } } }); } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/colorpicker/ColorPickerDialog.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/colorpicker/ColorPickerDialog.java index 038024ac..1dd77778 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/colorpicker/ColorPickerDialog.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/colorpicker/ColorPickerDialog.java @@ -63,7 +63,7 @@ public class ColorPickerDialog extends DialogFragment implements ColorPickerSwat } public Dialog onCreateDialog(Bundle bundle) { - View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_color_picker, null); + View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_color_picker_led, null); mProgress = ((ProgressBar) view.findViewById(android.R.id.progress)); mPalette = ((ColorPickerPalette) view.findViewById(R.id.color_picker)); mPalette.init(mSize, mColumns, this); diff --git a/QKSMS/src/main/res/drawable-v21/button_background_transparent.xml b/QKSMS/src/main/res/drawable-v21/ripple.xml similarity index 100% rename from QKSMS/src/main/res/drawable-v21/button_background_transparent.xml rename to QKSMS/src/main/res/drawable-v21/ripple.xml diff --git a/QKSMS/src/main/res/drawable-v21/button_background_transparent_light.xml b/QKSMS/src/main/res/drawable-v21/ripple_light.xml similarity index 100% rename from QKSMS/src/main/res/drawable-v21/button_background_transparent_light.xml rename to QKSMS/src/main/res/drawable-v21/ripple_light.xml diff --git a/QKSMS/src/main/res/drawable/edittext.xml b/QKSMS/src/main/res/drawable/edittext.xml index 86e52c4e..df0c20ea 100644 --- a/QKSMS/src/main/res/drawable/edittext.xml +++ b/QKSMS/src/main/res/drawable/edittext.xml @@ -1,21 +1,9 @@ - - - - - - - - + - - - + + + - \ No newline at end of file diff --git a/QKSMS/src/main/res/drawable/button_background_transparent.xml b/QKSMS/src/main/res/drawable/ripple.xml similarity index 100% rename from QKSMS/src/main/res/drawable/button_background_transparent.xml rename to QKSMS/src/main/res/drawable/ripple.xml diff --git a/QKSMS/src/main/res/drawable/button_background_transparent_light.xml b/QKSMS/src/main/res/drawable/ripple_light.xml similarity index 100% rename from QKSMS/src/main/res/drawable/button_background_transparent_light.xml rename to QKSMS/src/main/res/drawable/ripple_light.xml diff --git a/QKSMS/src/main/res/drawable/seek_thumb.xml b/QKSMS/src/main/res/drawable/seek_thumb.xml new file mode 100644 index 00000000..4c0c4293 --- /dev/null +++ b/QKSMS/src/main/res/drawable/seek_thumb.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/QKSMS/src/main/res/layout/dialog_color_picker.xml b/QKSMS/src/main/res/layout/dialog_color_picker.xml index a4cb534a..61c29e35 100644 --- a/QKSMS/src/main/res/layout/dialog_color_picker.xml +++ b/QKSMS/src/main/res/layout/dialog_color_picker.xml @@ -1,31 +1,208 @@ - + - + - + android:layout_height="match_parent" + android:gravity="center" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:text="@string/title_palette" + app:type="primary_bold" /> + + + + + + - - \ No newline at end of file + android:id="@+id/palette" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/QKSMS/src/main/res/layout/dialog_color_picker_led.xml b/QKSMS/src/main/res/layout/dialog_color_picker_led.xml new file mode 100644 index 00000000..a4cb534a --- /dev/null +++ b/QKSMS/src/main/res/layout/dialog_color_picker_led.xml @@ -0,0 +1,31 @@ + + + + + + + + + + \ No newline at end of file diff --git a/QKSMS/src/main/res/layout/dialog_donate.xml b/QKSMS/src/main/res/layout/dialog_donate.xml index d3822943..1ca79dcb 100644 --- a/QKSMS/src/main/res/layout/dialog_donate.xml +++ b/QKSMS/src/main/res/layout/dialog_donate.xml @@ -30,7 +30,6 @@ android:id="@+id/donate_1" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" android:orientation="vertical" android:padding="8dp"> @@ -52,7 +51,6 @@ android:id="@+id/donate_5" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" android:orientation="vertical" android:padding="8dp"> @@ -74,7 +72,6 @@ android:id="@+id/donate_10" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" android:orientation="vertical" android:padding="8dp"> @@ -104,7 +101,6 @@ android:id="@+id/donate_paypal" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" android:orientation="vertical" android:padding="8dp"> diff --git a/QKSMS/src/main/res/layout/list_item_conversation.xml b/QKSMS/src/main/res/layout/list_item_conversation.xml index f3a9b130..8d99be80 100644 --- a/QKSMS/src/main/res/layout/list_item_conversation.xml +++ b/QKSMS/src/main/res/layout/list_item_conversation.xml @@ -7,7 +7,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:animateLayoutChanges="true" - android:background="?android:attr/selectableItemBackground" android:gravity="top" android:minHeight="72dp" android:orientation="horizontal" diff --git a/QKSMS/src/main/res/layout/list_item_message_in.xml b/QKSMS/src/main/res/layout/list_item_message_in.xml index 8ff6f43b..35727712 100644 --- a/QKSMS/src/main/res/layout/list_item_message_in.xml +++ b/QKSMS/src/main/res/layout/list_item_message_in.xml @@ -6,7 +6,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" android:orientation="horizontal" android:paddingTop="2dp"> @@ -77,7 +76,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:background="@drawable/button_background_transparent" android:padding="16dp" android:src="@drawable/ic_play" android:visibility="gone" /> diff --git a/QKSMS/src/main/res/layout/list_item_message_out.xml b/QKSMS/src/main/res/layout/list_item_message_out.xml index fea4a9bc..8f13d321 100644 --- a/QKSMS/src/main/res/layout/list_item_message_out.xml +++ b/QKSMS/src/main/res/layout/list_item_message_out.xml @@ -6,7 +6,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" android:orientation="horizontal" android:paddingTop="2dp"> @@ -77,7 +76,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:background="@drawable/button_background_transparent" android:padding="16dp" android:src="@drawable/ic_play" android:visibility="gone" /> diff --git a/QKSMS/src/main/res/layout/list_item_search.xml b/QKSMS/src/main/res/layout/list_item_search.xml index 08171dac..3c4090e6 100644 --- a/QKSMS/src/main/res/layout/list_item_search.xml +++ b/QKSMS/src/main/res/layout/list_item_search.xml @@ -4,7 +4,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" android:gravity="top" android:orientation="horizontal" android:paddingBottom="8dp" diff --git a/QKSMS/src/main/res/layout/view_compose.xml b/QKSMS/src/main/res/layout/view_compose.xml index 48fa2277..c3d57bbe 100644 --- a/QKSMS/src/main/res/layout/view_compose.xml +++ b/QKSMS/src/main/res/layout/view_compose.xml @@ -142,7 +142,7 @@ android:id="@+id/attach" android:layout_width="56dp" android:layout_height="56dp" - android:background="@drawable/button_background_transparent_light" + android:background="@drawable/ripple_light" android:padding="16dp" android:src="@drawable/ic_photo" /> @@ -150,7 +150,7 @@ android:id="@+id/camera" android:layout_width="56dp" android:layout_height="56dp" - android:background="@drawable/button_background_transparent_light" + android:background="@drawable/ripple_light" android:padding="16dp" android:src="@drawable/ic_camera" /> @@ -158,7 +158,7 @@ android:id="@+id/delay" android:layout_width="56dp" android:layout_height="56dp" - android:background="@drawable/button_background_transparent_light" + android:background="@drawable/ripple_light" android:padding="16dp" android:src="@drawable/ic_timer" /> diff --git a/QKSMS/src/main/res/layout/widget.xml b/QKSMS/src/main/res/layout/widget.xml index c069a938..bbe8731c 100644 --- a/QKSMS/src/main/res/layout/widget.xml +++ b/QKSMS/src/main/res/layout/widget.xml @@ -37,7 +37,7 @@ android:id="@+id/widget_compose" android:layout_width="56dp" android:layout_height="56dp" - android:background="@drawable/button_background_transparent" + android:background="@drawable/ripple" android:contentDescription="@string/new_message" android:padding="16dp" android:src="@drawable/ic_compose" /> diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 00000000..b220561c Binary files /dev/null and b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_amber.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_amber.png deleted file mode 100755 index f61ae596..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_amber.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_blue.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_blue.png deleted file mode 100755 index ca3a1207..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_blue.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_blue_grey.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_blue_grey.png deleted file mode 100755 index b44a8312..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_blue_grey.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_brown.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_brown.png deleted file mode 100755 index fe0db1cf..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_brown.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_cyan.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_cyan.png deleted file mode 100755 index 1c5e344d..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_cyan.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_dark.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_dark.png new file mode 100644 index 00000000..6f481929 Binary files /dev/null and b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_dark.png differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_deep_orange.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_deep_orange.png deleted file mode 100755 index c9f6f272..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_deep_orange.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_deep_purple.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_deep_purple.png deleted file mode 100755 index b7718eb1..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_deep_purple.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_green.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_green.png deleted file mode 100755 index 21ad10f7..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_green.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_grey.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_grey.png deleted file mode 100755 index 5c774deb..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_grey.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_indigo.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_indigo.png deleted file mode 100755 index 3208780a..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_indigo.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_light_blue.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_light_blue.png deleted file mode 100755 index 00258423..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_light_blue.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_light_green.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_light_green.png deleted file mode 100755 index 145cf056..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_light_green.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_lime.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_lime.png deleted file mode 100755 index edee3645..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_lime.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_orange.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_orange.png deleted file mode 100755 index fe6eda7d..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_orange.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_pink.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_pink.png deleted file mode 100755 index 4697e499..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_pink.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_purple.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_purple.png deleted file mode 100755 index a7560cb6..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_purple.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_red.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_red.png deleted file mode 100755 index 990c7665..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_red.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_teal.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_teal.png deleted file mode 100755 index 3a6d8b65..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_teal.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_yellow.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_yellow.png deleted file mode 100755 index 6bc58908..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_yellow.png and /dev/null differ diff --git a/QKSMS/src/main/res/values/strings.xml b/QKSMS/src/main/res/values/strings.xml index 78e21277..dbf79bca 100644 --- a/QKSMS/src/main/res/values/strings.xml +++ b/QKSMS/src/main/res/values/strings.xml @@ -19,6 +19,7 @@ Enter a message Enter code + Hex New message @@ -124,8 +125,8 @@ Theme color Tap to change theme - Update QKSMS icon color - Update the QKSMS icon to match your theme color + Use dark icon + Use the dark version of the QKSMS icon on your homescreen, to better match your wallpaper Tinted status bar Tinted navigation bar Background color @@ -203,8 +204,6 @@ Send long messages as MMS instead of splitting them Send long as MMS after Send long messages as MMS when they exceed the length of a number of messages - 24h time - Display timestamps in 24-hour format Show return button Show return key on keyboard instead of Emoji button Text @@ -321,6 +320,8 @@ Block number Unblock number %s selected + Palette + RGB Update icon color - QKSMS must be restarted when changing the icon color. Restart now? + QKSMS must be restarted when changing the icon color Conversation details Last message date diff --git a/QKSMS/src/main/res/values/styles.xml b/QKSMS/src/main/res/values/styles.xml index 804f1746..a376f9c8 100644 --- a/QKSMS/src/main/res/values/styles.xml +++ b/QKSMS/src/main/res/values/styles.xml @@ -19,9 +19,4 @@ tertiary - - diff --git a/QKSMS/src/main/res/xml/settings.xml b/QKSMS/src/main/res/xml/settings.xml index 36085a35..1ab095da 100644 --- a/QKSMS/src/main/res/xml/settings.xml +++ b/QKSMS/src/main/res/xml/settings.xml @@ -3,7 +3,8 @@ - + diff --git a/QKSMS/src/main/res/xml/settings_appearance.xml b/QKSMS/src/main/res/xml/settings_appearance.xml index f99286db..3d326e22 100644 --- a/QKSMS/src/main/res/xml/settings_appearance.xml +++ b/QKSMS/src/main/res/xml/settings_appearance.xml @@ -10,12 +10,13 @@ android:layout="@layout/list_item_preference" android:summary="@string/pref_theme_summary_alt" android:title="@string/pref_theme" /> - + android:summary="@string/pref_icon_dark_summary" + android:title="@string/pref_icon_dark" + android:widgetLayout="@layout/view_switch" /> - \ No newline at end of file diff --git a/README.md b/README.md index c5554327..776c6798 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # QKSMS -[![Join the chat at https://gitter.im/qklabs/qksms](https://badges.gitter.im/qklabs/qksms.svg)](https://gitter.im/qklabs/qksms?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Join the chat at https://gitter.im/moezbhatti/qksms](https://badges.gitter.im/moezbhatti/qksms.svg)](https://gitter.im/moezbhatti/qksms?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![ZenHub] (https://raw.githubusercontent.com/ZenHubIO/support/master/zenhub-badge.png)] (https://zenhub.io) -[![Build Status](https://travis-ci.org/qklabs/qksms.svg?branch=master)](https://travis-ci.org/qklabs/qksms) +[![Build Status](https://travis-ci.org/moezbhatti/qksms.svg?branch=master)](https://travis-ci.org/moezbhatti/qksms) QKSMS is an open source replacement to the [stock messaging app](https://github.com/android/platform_packages_apps_mms) on Android. It is currently available on the Google Play Store. @@ -53,7 +53,7 @@ Any new code written should follow these guidelines. # Bug Reports / Feature Requests -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 +We track issues and feature requests using GitHub issues. You can view existing issues and create your own here: https://github.com/moezbhatti/qksms/issues ### How to help @@ -94,7 +94,7 @@ 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. -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! +You can see bugs which need "repro steps" [here](https://github.com/moezbhatti/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. diff --git a/build.gradle b/build.gradle index f4add3ee..0edb821f 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,6 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.0-alpha4' + classpath 'com.android.tools.build:gradle:2.1.2' } }