Merged branch master into master

This commit is contained in:
Ray
2016-07-09 22:35:19 -05:00
62 changed files with 758 additions and 256 deletions
@@ -33,9 +33,9 @@ import java.util.Collections;
* @hide
*/
public class DhcpInfoInternal {
private final static String TAG = "DhcpInfoInternal";
private static final String TAG = "DhcpInfoInternal";
private final static boolean LOCAL_LOGV = false;
private static final boolean LOCAL_LOGV = false;
public String ipAddress;
public int prefixLength;
@@ -140,7 +140,7 @@ public class DhcpInfoInternal {
dns2 = orig.dns2;
}
if (mRoutes.size() == 0) {
if (mRoutes.isEmpty()) {
for (RouteInfo route : orig.getRoutes()) {
addRoute(route);
}
@@ -15,7 +15,7 @@ public interface IConnectivityManager extends android.os.IInterface {
/**
* Local-side IPC implementation stub class.
*/
public static abstract class Stub extends android.os.Binder implements android.net.IConnectivityManager {
public abstract static class Stub extends android.os.Binder implements android.net.IConnectivityManager {
private static final String DESCRIPTOR = "android.net.IConnectivityManager";
/**
@@ -11,7 +11,7 @@ public interface INetworkPolicyListener extends android.os.IInterface {
/**
* Local-side IPC implementation stub class.
*/
public static abstract class Stub extends android.os.Binder implements android.net.INetworkPolicyListener {
public abstract static class Stub extends android.os.Binder implements android.net.INetworkPolicyListener {
private static final String DESCRIPTOR = "android.net.INetworkPolicyListener";
/**
@@ -13,7 +13,7 @@ public interface INetworkPolicyManager extends android.os.IInterface {
/**
* Local-side IPC implementation stub class.
*/
public static abstract class Stub extends android.os.Binder implements android.net.INetworkPolicyManager {
public abstract static class Stub extends android.os.Binder implements android.net.INetworkPolicyManager {
private static final String DESCRIPTOR = "android.net.INetworkPolicyManager";
/**
@@ -65,28 +65,28 @@ public class LinkCapabilities implements Parcelable {
*
* @see ConnectivityManager
*/
public final static int RO_NETWORK_TYPE = 1;
public static final int RO_NETWORK_TYPE = 1;
/**
* Desired minimum forward link (download) bandwidth for the
* in kilobits per second (kbps). Values should be strings such
* "50", "100", "1500", etc.
*/
public final static int RW_DESIRED_FWD_BW = 2;
public static final int RW_DESIRED_FWD_BW = 2;
/**
* Required minimum forward link (download) bandwidth, in
* per second (kbps), below which the socket cannot function.
* Values should be strings such as "50", "100", "1500", etc.
*/
public final static int RW_REQUIRED_FWD_BW = 3;
public static final int RW_REQUIRED_FWD_BW = 3;
/**
* Available forward link (download) 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_FWD_BW = 4;
public static final int RO_AVAILABLE_FWD_BW = 4;
/**
* Desired minimum reverse link (upload) bandwidth for the socket
@@ -95,7 +95,7 @@ public class LinkCapabilities implements Parcelable {
* <p/>
* 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;
}
/**
@@ -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();
@@ -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();
@@ -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;
@@ -903,7 +903,7 @@ public class PduPersister {
* Here <table_name> shall be "video" or "audio" or "images"
* <row_index> 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();
@@ -18,7 +18,13 @@ public class CIELChEvaluator implements TypeEvaluator<Integer> {
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<Integer> {
@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;
@@ -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);
@@ -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;
@@ -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;
}
}
@@ -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";
@@ -29,6 +29,8 @@ import java.util.LinkedHashMap;
* from Peter Balwin and books app.
*/
public class SimpleCache<K, V> {
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<K, V> {
}
}
private static <V> V unwrap(SoftReference<V> ref) {
return ref != null ? ref.get() : null;
}
private final SoftReferenceMap mSoftReferences;
private final HardReferenceMap mHardReferences;
/**
* Constructor.
*
@@ -95,6 +90,10 @@ public class SimpleCache<K, V> {
}
}
private static <V> V unwrap(SoftReference<V> ref) {
return ref != null ? ref.get() : null;
}
/**
* See {@link java.util.Map#get(Object)}.
*/
@@ -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.
@@ -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", ""));
@@ -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);
}
}
@@ -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),
@@ -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;
@@ -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()];
+10 -10
View File
@@ -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() {
@@ -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;
}
@@ -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);
@@ -279,16 +279,19 @@ public class SlideModel extends Model implements List<MediaModel>, 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<? extends MediaModel> 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<MediaModel>, 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<MediaModel> 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<MediaModel>, 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> 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<? extends MediaModel> 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<MediaModel>, 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<MediaModel> listIterator() {
return mMedia.listIterator();
}
@Override
public ListIterator<MediaModel> 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<MediaModel>, EventListener
return media;
}
@Override
public MediaModel set(int location, MediaModel object) {
throw new UnsupportedOperationException("Operation not supported.");
}
@Override
public List<MediaModel> subList(int start, int end) {
return mMedia.subList(start, end);
}
@@ -406,6 +406,7 @@ public class SlideshowModel extends Model
//
// Implement List<E> 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<? extends SlideModel> 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<SlideModel> 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> 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<? extends SlideModel> 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<SlideModel> listIterator() {
return mSlides.listIterator();
}
@Override
public ListIterator<SlideModel> 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) {
@@ -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);
}
}
}
}
@@ -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;
}
@@ -364,46 +379,57 @@ public class ThemeManager {
.show();
}
@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 +449,7 @@ public class ThemeManager {
mReceivedBubbleColored = colored;
}
@ColorInt
public static int getNeutralBubbleColor() {
if (mTheme == null) {
return 0xeeeeee;
@@ -441,13 +468,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 +490,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 +667,7 @@ public class ThemeManager {
getColorString(color)
);
int colorFrom = mColor;
int colorFrom = mActiveColor;
mColor = color;
mActiveColor = color;
@@ -596,8 +715,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 +756,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);
}
}
}
@@ -13,14 +13,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<ConversationListViewHolder, Conversation> {
@@ -52,6 +49,10 @@ public class ConversationListAdapter extends RecyclerCursorAdapter<ConversationL
holder.errorIndicator.setColorFilter(ThemeManager.getColor());
});
LiveViewManager.registerView(QKPreference.BACKGROUND, this, key -> {
holder.root.setBackgroundDrawable(ThemeManager.getRippleBackground());
});
return holder;
}
@@ -104,8 +105,9 @@ public class ConversationListAdapter extends RecyclerCursorAdapter<ConversationL
holder.mSelected.setVisibility(View.GONE);
}
LiveViewManager.registerView(QKPreference.HIDE_AVATAR_CONVERSATIONS, this, key ->
holder.mAvatarView.setVisibility(mContext.getBoolean(QKPreference.HIDE_AVATAR_CONVERSATIONS) ? View.GONE : View.VISIBLE));
LiveViewManager.registerView(QKPreference.HIDE_AVATAR_CONVERSATIONS, this, key -> {
holder.mAvatarView.setVisibility(mContext.getBoolean(QKPreference.HIDE_AVATAR_CONVERSATIONS) ? View.GONE : View.VISIBLE);
});
// Date
holder.dateView.setText(DateFormatter.getConversationTimestamp(mContext, conversation.getDate()));
@@ -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;
@@ -208,7 +208,7 @@ public class DeliveryReportHelper {
return null;
}
if (reportReqs.size() == 0) {
if (reportReqs.isEmpty()) {
return null;
}
@@ -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);
}
}
@@ -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) {
@@ -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);
@@ -165,6 +165,8 @@ public class MessageListAdapter extends RecyclerCursorAdapter<MessageListViewHol
}
LiveViewManager.registerView(QKPreference.BACKGROUND, this, key -> {
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<MessageListViewHol
MessageItem messageItem2 = getItem(position + 1);
if(mPrefs.getBoolean(SettingsFragment.FORCE_TIMESTAMPS, false)) {
if (mPrefs.getBoolean(SettingsFragment.FORCE_TIMESTAMPS, false)) {
return true;
} else if (messageItem.mDeliveryStatus != MessageItem.DeliveryStatus.NONE) {
return true;
@@ -9,7 +9,10 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.moez.QKSMS.R;
import com.moez.QKSMS.common.LiveViewManager;
import com.moez.QKSMS.common.utils.DateFormatter;
import com.moez.QKSMS.enums.QKPreference;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.base.QKActivity;
import com.moez.QKSMS.ui.base.RecyclerCursorAdapter;
@@ -37,6 +40,11 @@ public class SearchAdapter extends RecyclerCursorAdapter<SearchViewHolder, Searc
public SearchViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(mContext);
View view = inflater.inflate(R.layout.list_item_search, parent, false);
LiveViewManager.registerView(QKPreference.BACKGROUND, this, key -> {
view.setBackgroundDrawable(ThemeManager.getRippleBackground());
});
return new SearchViewHolder(mContext, view);
}
@@ -116,7 +116,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";
@@ -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);
}
@@ -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);
}
}
});
}
@@ -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);