mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Merge tag 'v3.2.1'
This commit is contained in:
@@ -21,14 +21,11 @@ import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.DatabaseUtils;
|
||||
import android.database.sqlite.SqliteWrapper;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Telephony.Mms;
|
||||
import android.provider.Telephony.Mms.Inbox;
|
||||
import com.android.mms.MmsConfig;
|
||||
@@ -61,23 +58,21 @@ import static com.google.android.mms.pdu_alt.PduHeaders.MESSAGE_TYPE_READ_ORIG_I
|
||||
*/
|
||||
public class PushReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = LogTag.TAG;
|
||||
private static final boolean DEBUG = false;
|
||||
private static final boolean LOCAL_LOGV = true;
|
||||
|
||||
static final String[] PROJECTION = new String[] {
|
||||
Mms.CONTENT_LOCATION,
|
||||
Mms.LOCKED
|
||||
};
|
||||
static final String[] PROJECTION = new String[]{Mms.CONTENT_LOCATION, Mms.LOCKED};
|
||||
|
||||
static final int COLUMN_CONTENT_LOCATION = 0;
|
||||
static final int COLUMN_CONTENT_LOCATION = 0;
|
||||
|
||||
private static Set<String> downloadedUrls = new HashSet<String>();
|
||||
private static final ExecutorService PUSH_RECEIVER_EXECUTOR = Executors.newSingleThreadExecutor();
|
||||
|
||||
private class ReceivePushTask extends AsyncTask<Intent,Void,Void> {
|
||||
private class ReceivePushTask extends AsyncTask<Intent, Void, Void> {
|
||||
private Context mContext;
|
||||
public ReceivePushTask(Context context) {
|
||||
private PendingResult pendingResult;
|
||||
|
||||
private ReceivePushTask(Context context, PendingResult pendingResult) {
|
||||
mContext = context;
|
||||
this.pendingResult = pendingResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,7 +85,7 @@ public class PushReceiver extends BroadcastReceiver {
|
||||
PduParser parser = new PduParser(pushData);
|
||||
GenericPdu pdu = parser.parse();
|
||||
|
||||
if (null == pdu) {
|
||||
if (pdu == null) {
|
||||
Log.e(TAG, "Invalid PUSH data");
|
||||
return null;
|
||||
}
|
||||
@@ -98,7 +93,7 @@ public class PushReceiver extends BroadcastReceiver {
|
||||
PduPersister p = PduPersister.getPduPersister(mContext);
|
||||
ContentResolver cr = mContext.getContentResolver();
|
||||
int type = pdu.getMessageType();
|
||||
long threadId = -1;
|
||||
long threadId;
|
||||
|
||||
try {
|
||||
switch (type) {
|
||||
@@ -123,11 +118,11 @@ public class PushReceiver extends BroadcastReceiver {
|
||||
NotificationInd nInd = (NotificationInd) pdu;
|
||||
|
||||
if (MmsConfig.getTransIdEnabled()) {
|
||||
byte [] contentLocation = nInd.getContentLocation();
|
||||
byte[] contentLocation = nInd.getContentLocation();
|
||||
if ('=' == contentLocation[contentLocation.length - 1]) {
|
||||
byte [] transactionId = nInd.getTransactionId();
|
||||
byte [] contentLocationWithId = new byte [contentLocation.length
|
||||
+ transactionId.length];
|
||||
byte[] transactionId = nInd.getTransactionId();
|
||||
byte[] contentLocationWithId = new byte[contentLocation.length
|
||||
+ transactionId.length];
|
||||
System.arraycopy(contentLocation, 0, contentLocationWithId,
|
||||
0, contentLocation.length);
|
||||
System.arraycopy(transactionId, 0, contentLocationWithId,
|
||||
@@ -156,9 +151,8 @@ public class PushReceiver extends BroadcastReceiver {
|
||||
Log.v(TAG, "receiving on a lollipop+ device");
|
||||
|
||||
DownloadManager.getInstance().downloadMultimediaMessage(mContext, location, uri, true);
|
||||
} else if (LOCAL_LOGV) {
|
||||
Log.v(TAG, "Skip downloading duplicate message: "
|
||||
+ new String(nInd.getContentLocation()));
|
||||
} else {
|
||||
Log.v(TAG, "Skip downloading duplicate message: " + new String(nInd.getContentLocation()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -171,12 +165,15 @@ public class PushReceiver extends BroadcastReceiver {
|
||||
Log.e(TAG, "Unexpected RuntimeException.", e);
|
||||
}
|
||||
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(TAG, "PUSH Intent processed.");
|
||||
}
|
||||
Log.v(TAG, "PUSH Intent processed.");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
pendingResult.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,28 +181,16 @@ public class PushReceiver extends BroadcastReceiver {
|
||||
Log.v(TAG, intent.getAction() + " " + intent.getType());
|
||||
if ((intent.getAction().equals(WAP_PUSH_DELIVER_ACTION) || intent.getAction().equals(WAP_PUSH_RECEIVED_ACTION))
|
||||
&& ContentType.MMS_MESSAGE.equals(intent.getType())) {
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(TAG, "Received PUSH Intent: " + intent);
|
||||
}
|
||||
Log.v(TAG, "Received PUSH Intent: " + intent);
|
||||
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
// Hold a wake lock for 5 seconds, enough to give any
|
||||
// services we start time to take their own wake locks.
|
||||
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||
"MMS PushReceiver");
|
||||
wl.acquire(5000);
|
||||
MmsConfig.init(context);
|
||||
new ReceivePushTask(context).executeOnExecutor(PUSH_RECEIVER_EXECUTOR, intent);
|
||||
new ReceivePushTask(context, goAsync()).executeOnExecutor(PUSH_RECEIVER_EXECUTOR, intent);
|
||||
|
||||
Log.v("mms_receiver", context.getPackageName() + " received and aborted");
|
||||
|
||||
abortBroadcast();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getContentLocation(Context context, Uri uri)
|
||||
throws MmsException {
|
||||
public static String getContentLocation(Context context, Uri uri) throws MmsException {
|
||||
Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
|
||||
uri, PROJECTION, null, null, null);
|
||||
|
||||
@@ -245,8 +230,8 @@ public class PushReceiver extends BroadcastReceiver {
|
||||
// sb.append(')');
|
||||
|
||||
Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
|
||||
Mms.CONTENT_URI, new String[] { Mms.THREAD_ID },
|
||||
sb.toString(), null, null);
|
||||
Mms.CONTENT_URI, new String[]{Mms.THREAD_ID},
|
||||
sb.toString(), null, null);
|
||||
if (cursor != null) {
|
||||
try {
|
||||
if ((cursor.getCount() == 1) && cursor.moveToFirst()) {
|
||||
@@ -262,16 +247,15 @@ public class PushReceiver extends BroadcastReceiver {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static boolean isDuplicateNotification(
|
||||
Context context, NotificationInd nInd) {
|
||||
private static boolean isDuplicateNotification(Context context, NotificationInd nInd) {
|
||||
byte[] rawLocation = nInd.getContentLocation();
|
||||
if (rawLocation != null) {
|
||||
String location = new String(rawLocation);
|
||||
String selection = Mms.CONTENT_LOCATION + " = ?";
|
||||
String[] selectionArgs = new String[] { location };
|
||||
String[] selectionArgs = new String[]{location};
|
||||
Cursor cursor = SqliteWrapper.query(
|
||||
context, context.getContentResolver(),
|
||||
Mms.CONTENT_URI, new String[] { Mms._ID },
|
||||
Mms.CONTENT_URI, new String[]{Mms._ID},
|
||||
selection, selectionArgs, null);
|
||||
if (cursor != null) {
|
||||
try {
|
||||
|
||||
@@ -253,7 +253,11 @@ public class TransactionService extends Service implements Observer {
|
||||
}
|
||||
|
||||
public void onNewIntent(Intent intent, int serviceId) {
|
||||
mobileDataEnabled = Utils.isMobileDataEnabled(this);
|
||||
try {
|
||||
mobileDataEnabled = Utils.isMobileDataEnabled(this);
|
||||
} catch (Exception e) {
|
||||
mobileDataEnabled = true;
|
||||
}
|
||||
mConnMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if (!mobileDataEnabled) {
|
||||
Utils.setMobileDataEnabled(this, true);
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Jacob Klinker
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.klinker.android.send_message;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import com.klinker.android.logger.Log;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public class DeliveredReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.v("delivery_receiver", "marking message as delivered");
|
||||
Uri uri;
|
||||
|
||||
try {
|
||||
uri = Uri.parse(intent.getStringExtra("message_uri"));
|
||||
|
||||
if (uri.equals("")) {
|
||||
uri = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
uri = null;
|
||||
}
|
||||
|
||||
switch (getResultCode()) {
|
||||
case Activity.RESULT_OK:
|
||||
// notify user that message was delivered
|
||||
Intent delivered = new Intent(Transaction.NOTIFY_OF_DELIVERY);
|
||||
delivered.putExtra("result", true);
|
||||
delivered.putExtra("message_uri", uri == null ? "" : uri.toString());
|
||||
BroadcastUtils.sendExplicitBroadcast(
|
||||
context, delivered, Transaction.NOTIFY_OF_DELIVERY);
|
||||
|
||||
if (uri != null) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("status", "0");
|
||||
values.put("date_sent", Calendar.getInstance().getTimeInMillis());
|
||||
values.put("read", true);
|
||||
context.getContentResolver().update(uri, values, null, null);
|
||||
} else {
|
||||
Cursor query = context.getContentResolver().query(Uri.parse("content://sms/sent"), null, null, null, "date desc");
|
||||
|
||||
// mark message as delivered in database
|
||||
if (query.moveToFirst()) {
|
||||
String id = query.getString(query.getColumnIndex("_id"));
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("status", "0");
|
||||
values.put("date_sent", Calendar.getInstance().getTimeInMillis());
|
||||
values.put("read", true);
|
||||
context.getContentResolver().update(Uri.parse("content://sms/sent"), values, "_id=" + id, null);
|
||||
}
|
||||
|
||||
query.close();
|
||||
}
|
||||
|
||||
break;
|
||||
case Activity.RESULT_CANCELED:
|
||||
// notify user that message failed to be delivered
|
||||
Intent notDelivered = new Intent(Transaction.NOTIFY_OF_DELIVERY);
|
||||
notDelivered.putExtra("result", false);
|
||||
notDelivered.putExtra("message_uri", uri == null ? "" : uri.toString());
|
||||
BroadcastUtils.sendExplicitBroadcast(
|
||||
context, notDelivered, Transaction.NOTIFY_OF_DELIVERY);
|
||||
|
||||
if (uri != null) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("status", "64");
|
||||
values.put("date_sent", Calendar.getInstance().getTimeInMillis());
|
||||
values.put("read", true);
|
||||
values.put("error_code", getResultCode());
|
||||
context.getContentResolver().update(uri, values, null, null);
|
||||
} else {
|
||||
Cursor query2 = context.getContentResolver().query(Uri.parse("content://sms/sent"), null, null, null, "date desc");
|
||||
|
||||
// mark failed in database
|
||||
if (query2.moveToFirst()) {
|
||||
String id = query2.getString(query2.getColumnIndex("_id"));
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("status", "64");
|
||||
values.put("read", true);
|
||||
values.put("error_code", getResultCode());
|
||||
context.getContentResolver().update(Uri.parse("content://sms/sent"), values, "_id=" + id, null);
|
||||
}
|
||||
|
||||
query2.close();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
BroadcastUtils.sendExplicitBroadcast(context, new Intent(), Transaction.REFRESH);
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jacob Klinker
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.klinker.android.send_message
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.*
|
||||
import android.net.Uri
|
||||
import android.provider.Telephony
|
||||
import android.util.Log
|
||||
import com.google.android.mms.MmsException
|
||||
import com.google.android.mms.util_alt.SqliteWrapper
|
||||
import java.io.File
|
||||
|
||||
open class MmsSentReceiver : BroadcastReceiver() {
|
||||
|
||||
companion object {
|
||||
private val TAG = "MmsSentReceiver"
|
||||
|
||||
const val MMS_SENT = "com.klinker.android.messaging.MMS_SENT"
|
||||
const val EXTRA_CONTENT_URI = "content_uri"
|
||||
const val EXTRA_FILE_PATH = "file_path"
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
Log.v(TAG, "MMS sending result: " + resultCode)
|
||||
|
||||
val uri = Uri.parse(intent.getStringExtra(EXTRA_CONTENT_URI))
|
||||
Log.v(TAG, uri.toString())
|
||||
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
Log.v(TAG, "MMS has finished sending, marking it as so in the database")
|
||||
val values = ContentValues(1)
|
||||
values.put(Telephony.Mms.MESSAGE_BOX, Telephony.Mms.MESSAGE_BOX_SENT)
|
||||
SqliteWrapper.update(context, context.contentResolver, uri, values, null, null)
|
||||
} else {
|
||||
Log.v(TAG, "MMS has failed to send, marking it as so in the database")
|
||||
try {
|
||||
val messageId = ContentUris.parseId(uri)
|
||||
|
||||
val values = ContentValues(1)
|
||||
values.put(Telephony.Mms.MESSAGE_BOX, Telephony.Mms.MESSAGE_BOX_FAILED)
|
||||
SqliteWrapper.update(context, context.contentResolver, Telephony.Mms.CONTENT_URI, values,
|
||||
"${Telephony.Mms._ID} = ?", arrayOf(messageId.toString()))
|
||||
|
||||
// TODO this query isn't able to find any results
|
||||
// Need to figure out why the message isn't appearing in the PendingMessages Uri,
|
||||
// so that we can properly assign the error type
|
||||
val errorTypeValues = ContentValues(1)
|
||||
errorTypeValues.put(Telephony.MmsSms.PendingMessages.ERROR_TYPE, Telephony.MmsSms.ERR_TYPE_GENERIC_PERMANENT)
|
||||
SqliteWrapper.update(context, context.contentResolver, Telephony.MmsSms.PendingMessages.CONTENT_URI,
|
||||
errorTypeValues, "${Telephony.MmsSms.PendingMessages.MSG_ID} = ?", arrayOf(messageId.toString()))
|
||||
|
||||
} catch (e: MmsException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val filePath = intent.getStringExtra(EXTRA_FILE_PATH)
|
||||
Log.v(TAG, filePath)
|
||||
File(filePath).delete()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Jacob Klinker
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.klinker.android.send_message;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.telephony.SmsManager;
|
||||
import com.klinker.android.logger.Log;
|
||||
|
||||
public class SentReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.v("sent_receiver", "marking message as sent");
|
||||
Uri uri;
|
||||
|
||||
try {
|
||||
uri = Uri.parse(intent.getStringExtra("message_uri"));
|
||||
|
||||
if (uri.equals("")) {
|
||||
uri = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
uri = null;
|
||||
}
|
||||
|
||||
switch (getResultCode()) {
|
||||
case Activity.RESULT_OK:
|
||||
if (uri != null) {
|
||||
try {
|
||||
Log.v("sent_receiver", "using supplied uri");
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("type", 2);
|
||||
values.put("read", 1);
|
||||
context.getContentResolver().update(uri, values, null, null);
|
||||
} catch (NullPointerException e) {
|
||||
markFirstAsSent(context);
|
||||
}
|
||||
} else {
|
||||
markFirstAsSent(context);
|
||||
}
|
||||
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
|
||||
case SmsManager.RESULT_ERROR_NO_SERVICE:
|
||||
case SmsManager.RESULT_ERROR_NULL_PDU:
|
||||
case SmsManager.RESULT_ERROR_RADIO_OFF:
|
||||
if (uri != null) {
|
||||
Log.v("sent_receiver", "using supplied uri");
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("type", 5);
|
||||
values.put("read", true);
|
||||
values.put("error_code", getResultCode());
|
||||
context.getContentResolver().update(uri, values, null, null);
|
||||
} else {
|
||||
Log.v("sent_receiver", "using first message");
|
||||
Cursor query = context.getContentResolver().query(Uri.parse("content://sms/outbox"), null, null, null, null);
|
||||
|
||||
// mark message failed
|
||||
if (query != null && query.moveToFirst()) {
|
||||
String id = query.getString(query.getColumnIndex("_id"));
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("type", 5);
|
||||
values.put("read", 1);
|
||||
values.put("error_code", getResultCode());
|
||||
context.getContentResolver().update(Uri.parse("content://sms/outbox"), values, "_id=" + id, null);
|
||||
|
||||
query.close();
|
||||
}
|
||||
}
|
||||
|
||||
BroadcastUtils.sendExplicitBroadcast(
|
||||
context, new Intent(), Transaction.NOTIFY_SMS_FAILURE);
|
||||
break;
|
||||
}
|
||||
|
||||
BroadcastUtils.sendExplicitBroadcast(context, new Intent(), Transaction.REFRESH);
|
||||
}
|
||||
|
||||
private void markFirstAsSent(Context context) {
|
||||
Log.v("sent_receiver", "using first message");
|
||||
Cursor query = context.getContentResolver().query(Uri.parse("content://sms/outbox"), null, null, null, null);
|
||||
|
||||
// mark message as sent successfully
|
||||
if (query != null && query.moveToFirst()) {
|
||||
String id = query.getString(query.getColumnIndex("_id"));
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("type", 2);
|
||||
values.put("read", 1);
|
||||
context.getContentResolver().update(Uri.parse("content://sms/outbox"), values, "_id=" + id, null);
|
||||
|
||||
query.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,10 @@ public class Transaction {
|
||||
public String SMS_SENT = ".SMS_SENT";
|
||||
public String SMS_DELIVERED = ".SMS_DELIVERED";
|
||||
|
||||
public static final String MMS_SENT = "com.moez.QKSMS.MMS_SENT";
|
||||
public static final String EXTRA_CONTENT_URI = "content_uri";
|
||||
public static final String EXTRA_FILE_PATH = "file_path";
|
||||
|
||||
public static String NOTIFY_SMS_FAILURE = ".NOTIFY_SMS_FAILURE";
|
||||
public static final String MMS_UPDATED = "com.moez.QKSMS.MMS_UPDATED";
|
||||
public static final String MMS_ERROR = "com.klinker.android.send_message.MMS_ERROR";
|
||||
@@ -384,11 +388,11 @@ public class Transaction {
|
||||
PduPersister persister = PduPersister.getPduPersister(context);
|
||||
Uri messageUri = persister.persist(sendReq, Uri.parse("content://mms/outbox"), true, true, null);
|
||||
|
||||
Intent sentIntent = new Intent(MmsSentReceiver.MMS_SENT);
|
||||
BroadcastUtils.addClassName(context, sentIntent, MmsSentReceiver.MMS_SENT);
|
||||
Intent sentIntent = new Intent(MMS_SENT);
|
||||
BroadcastUtils.addClassName(context, sentIntent, MMS_SENT);
|
||||
|
||||
sentIntent.putExtra(MmsSentReceiver.EXTRA_CONTENT_URI, messageUri.toString());
|
||||
sentIntent.putExtra(MmsSentReceiver.EXTRA_FILE_PATH, mSendFile.getPath());
|
||||
sentIntent.putExtra(EXTRA_CONTENT_URI, messageUri.toString());
|
||||
sentIntent.putExtra(EXTRA_FILE_PATH, mSendFile.getPath());
|
||||
final PendingIntent sentPI = PendingIntent.getBroadcast(
|
||||
context, 0, sentIntent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ android {
|
||||
applicationId "com.moez.QKSMS"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 27
|
||||
versionCode 168
|
||||
versionName "3.2.0"
|
||||
versionCode 169
|
||||
versionName "3.2.1"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
buildConfigField "String", "AMPLITUDE_API_KEY", "\"${System.getenv("AMPLITUDE_API_KEY")}\""
|
||||
@@ -115,6 +115,7 @@ dependencies {
|
||||
kapt "io.realm:realm-annotations-processor:$realm_version"
|
||||
|
||||
// rxjava
|
||||
implementation 'com.akaita.java:rxjava2-debug:1.2.2'
|
||||
implementation "io.reactivex.rxjava2:rxandroid:$rxandroid_version"
|
||||
implementation "io.reactivex.rxjava2:rxjava:$rxjava_version"
|
||||
implementation "io.reactivex.rxjava2:rxkotlin:$rxkotlin_version"
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name="receiver.MmsSentReceiver"
|
||||
android:taskAffinity="com.klinker.android.messaging.MMS_SENT" />
|
||||
android:taskAffinity="com.moez.QKSMS.MMS_SENT" />
|
||||
<receiver
|
||||
android:name="receiver.MmsUpdatedReceiver"
|
||||
android:taskAffinity="com.moez.QKSMS.MMS_UPDATED" />
|
||||
|
||||
@@ -29,10 +29,9 @@ import com.moez.QKSMS.R
|
||||
import common.base.QkAdapter
|
||||
import common.base.QkViewHolder
|
||||
import common.util.Colors
|
||||
import common.util.extensions.resolveThemeColor
|
||||
import common.util.extensions.setVisible
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.menu_list_item.view.*
|
||||
@@ -65,17 +64,15 @@ class MenuItemAdapter @Inject constructor(private val context: Context, private
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
val view = LayoutInflater.from(context).inflate(R.layout.menu_list_item, parent, false)
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val view = layoutInflater.inflate(R.layout.menu_list_item, parent, false)
|
||||
|
||||
val states = arrayOf(
|
||||
intArrayOf(android.R.attr.state_selected),
|
||||
intArrayOf(-android.R.attr.state_selected))
|
||||
|
||||
disposables += Observables
|
||||
.combineLatest(colors.theme, colors.textTertiary, { theme, textSecondary ->
|
||||
ColorStateList(states, intArrayOf(theme, textSecondary))
|
||||
})
|
||||
.subscribe { view.check.imageTintList = it }
|
||||
val text = parent.context.resolveThemeColor(android.R.attr.textColorTertiary)
|
||||
view.check.imageTintList = ColorStateList(states, intArrayOf(colors.theme().theme, text))
|
||||
|
||||
return QkViewHolder(view)
|
||||
}
|
||||
|
||||
@@ -51,13 +51,19 @@ class QKApplication : Application(), HasActivityInjector {
|
||||
@Inject lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Activity>
|
||||
@Inject lateinit var nightModeManager: NightModeManager
|
||||
|
||||
private val packages = arrayOf("common", "feature", "injection", "filter", "interactor", "manager", "mapper",
|
||||
"migration", "model", "receiver", "repository", "service", "util")
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
Bugsnag.init(this, Configuration(BuildConfig.BUGSNAG_API_KEY).apply {
|
||||
appVersion = BuildConfig.VERSION_NAME
|
||||
projectPackages = packages
|
||||
})
|
||||
|
||||
//RxJava2Debug.enableRxJava2AssemblyTracking(packages)
|
||||
|
||||
Realm.init(this)
|
||||
Realm.setDefaultConfiguration(RealmConfiguration.Builder()
|
||||
.compactOnLaunch()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package common
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.support.annotation.StringRes
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import common.util.extensions.dpToPx
|
||||
@@ -23,7 +23,7 @@ class QkDialog @Inject constructor(private val context: Context, val adapter: Me
|
||||
}
|
||||
|
||||
fun show(activity: Activity) {
|
||||
val recyclerView = RecyclerView(context)
|
||||
val recyclerView = RecyclerView(activity)
|
||||
recyclerView.layoutManager = LinearLayoutManager(context)
|
||||
recyclerView.adapter = adapter
|
||||
recyclerView.setPadding(top = 8.dpToPx(context), bottom = 8.dpToPx(context))
|
||||
|
||||
@@ -38,6 +38,7 @@ abstract class QkAdapter<T> : RecyclerView.Adapter<QkViewHolder>() {
|
||||
val diff = DiffUtil.calculateDiff(getDiffUtilCallback(field, value))
|
||||
field = value
|
||||
diff.dispatchUpdatesTo(this)
|
||||
onDatasetChanged()
|
||||
|
||||
emptyView?.setVisible(value.isEmpty())
|
||||
}
|
||||
|
||||
@@ -22,16 +22,20 @@ import android.annotation.SuppressLint
|
||||
import android.app.ActivityManager
|
||||
import android.arch.lifecycle.Lifecycle
|
||||
import android.graphics.BitmapFactory
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.util.Colors
|
||||
import common.util.extensions.setBackgroundTint
|
||||
import common.util.extensions.resolveThemeColor
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.subjects.BehaviorSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.toolbar.*
|
||||
import util.Preferences
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
@@ -43,6 +47,7 @@ import javax.inject.Inject
|
||||
abstract class QkThemedActivity : QkActivity() {
|
||||
|
||||
@Inject lateinit var colors: Colors
|
||||
@Inject lateinit var prefs: Preferences
|
||||
|
||||
/**
|
||||
* In case the activity should be themed for a specific conversation, the selected conversation
|
||||
@@ -55,40 +60,58 @@ abstract class QkThemedActivity : QkActivity() {
|
||||
*/
|
||||
protected val theme = threadId
|
||||
.distinctUntilChanged()
|
||||
.switchMap { threadId -> colors.themeForConversation(threadId) }
|
||||
.switchMap { threadId -> colors.themeObservable(threadId) }
|
||||
|
||||
@SuppressLint("InlinedApi")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
val night = prefs.night.get()
|
||||
val black = prefs.black.get()
|
||||
setTheme(getActivityThemeRes(night, black))
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
getAppThemeResourcesObservable()
|
||||
// When certain preferences change, we need to recreate the activity
|
||||
Observable.merge(
|
||||
listOf(prefs.night, prefs.black, prefs.textSize, prefs.systemFont)
|
||||
.map { it.asObservable().skip(1) })
|
||||
.autoDisposable(scope())
|
||||
.subscribe { res -> setTheme(res) }
|
||||
.subscribe { recreate() }
|
||||
|
||||
colors.systemBarIcons
|
||||
.autoDisposable(scope())
|
||||
.subscribe { systemUiVisibility -> window.decorView.systemUiVisibility = systemUiVisibility }
|
||||
// Set the color for the status bar icons
|
||||
// If night mode, or no dark icons supported, use light icons
|
||||
// If night mode and only dark status icons supported, use dark status icons
|
||||
// If night mode and all dark icons supported, use all dark icons
|
||||
window.decorView.systemUiVisibility = when {
|
||||
night || Build.VERSION.SDK_INT < Build.VERSION_CODES.M -> 0
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.O -> View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||
else -> View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||
}
|
||||
|
||||
colors.statusBar
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> window.statusBarColor = color }
|
||||
// Set the color for the overflow and navigation icon
|
||||
val textTertiary = resolveThemeColor(android.R.attr.textColorTertiary)
|
||||
toolbar?.overflowIcon = toolbar?.overflowIcon?.apply { setTint(textTertiary) }
|
||||
toolbar?.navigationIcon = toolbar?.navigationIcon?.apply { setTint(textTertiary) }
|
||||
|
||||
colors.navigationBar
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> window.navigationBarColor = color }
|
||||
// Set the color for the recent apps title
|
||||
val toolbarColor = resolveThemeColor(R.attr.colorPrimary)
|
||||
val icon = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
|
||||
val taskDesc = ActivityManager.TaskDescription(getString(R.string.app_name), icon, toolbarColor)
|
||||
setTaskDescription(taskDesc)
|
||||
}
|
||||
|
||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||
super.onPostCreate(savedInstanceState)
|
||||
|
||||
// Update the colours of the menu items
|
||||
Observables.combineLatest(menu, theme, colors.textSecondary, { menu, theme, text ->
|
||||
Observables.combineLatest(menu, theme, { menu, theme ->
|
||||
val text = resolveThemeColor(android.R.attr.textColorSecondary)
|
||||
(0 until menu.size())
|
||||
.map { position -> menu.getItem(position) }
|
||||
.forEach { menuItem ->
|
||||
menuItem?.icon?.run {
|
||||
setTint(when (menuItem.itemId) {
|
||||
in getColoredMenuItems() -> theme
|
||||
in getColoredMenuItems() -> theme.theme
|
||||
else -> text
|
||||
})
|
||||
|
||||
@@ -96,27 +119,6 @@ abstract class QkThemedActivity : QkActivity() {
|
||||
}
|
||||
}
|
||||
}).autoDisposable(scope(Lifecycle.Event.ON_DESTROY)).subscribe()
|
||||
|
||||
colors.textTertiary
|
||||
.doOnNext { color -> toolbar?.overflowIcon = toolbar?.overflowIcon?.apply { setTint(color) } }
|
||||
.doOnNext { color -> toolbar?.navigationIcon = toolbar?.navigationIcon?.apply { setTint(color) } }
|
||||
.autoDisposable(scope(Lifecycle.Event.ON_DESTROY))
|
||||
.subscribe()
|
||||
|
||||
colors.popupThemeResource
|
||||
.autoDisposable(scope(Lifecycle.Event.ON_DESTROY))
|
||||
.subscribe { res -> toolbar?.popupTheme = res }
|
||||
|
||||
colors.toolbarColor
|
||||
.doOnNext { color -> toolbar?.setBackgroundTint(color) }
|
||||
.doOnNext { color ->
|
||||
// Set the color for the recent apps title
|
||||
val icon = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
|
||||
val taskDesc = ActivityManager.TaskDescription(getString(R.string.app_name), icon, color)
|
||||
setTaskDescription(taskDesc)
|
||||
}
|
||||
.autoDisposable(scope(Lifecycle.Event.ON_DESTROY))
|
||||
.subscribe { color -> toolbar?.setBackgroundTint(color) }
|
||||
}
|
||||
|
||||
open fun getColoredMenuItems(): List<Int> {
|
||||
@@ -126,6 +128,10 @@ abstract class QkThemedActivity : QkActivity() {
|
||||
/**
|
||||
* This can be overridden in case an activity does not want to use the default themes
|
||||
*/
|
||||
open fun getAppThemeResourcesObservable() = colors.appThemeResources
|
||||
open fun getActivityThemeRes(night: Boolean, black: Boolean) = when {
|
||||
night && black -> R.style.AppThemeBlack
|
||||
night && !black -> R.style.AppThemeDark
|
||||
else -> R.style.AppThemeLight
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,15 +18,11 @@
|
||||
*/
|
||||
package common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.support.annotation.ColorRes
|
||||
import android.view.View
|
||||
import com.moez.QKSMS.R
|
||||
import common.util.extensions.getColorCompat
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import util.Preferences
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
@@ -34,6 +30,13 @@ import javax.inject.Singleton
|
||||
@Singleton
|
||||
class Colors @Inject constructor(private val context: Context, private val prefs: Preferences) {
|
||||
|
||||
data class Theme(val theme: Int, private val colors: Colors) {
|
||||
val highlight by lazy { colors.highlightColorForTheme(theme) }
|
||||
val textPrimary by lazy { colors.textPrimaryOnThemeForColor(theme) }
|
||||
val textSecondary by lazy { colors.textSecondaryOnThemeForColor(theme) }
|
||||
val textTertiary by lazy { colors.textTertiaryOnThemeForColor(theme) }
|
||||
}
|
||||
|
||||
val materialColors = listOf(
|
||||
listOf(0xffffebee, 0xffffcdd2, 0xffef9a9a, 0xffe57373, 0xffef5350, 0xfff44336, 0xffe53935, 0xffd32f2f, 0xffc62828, 0xffb71c1c),
|
||||
listOf(0xffFCE4EC, 0xffF8BBD0, 0xffF48FB1, 0xffF06292, 0xffEC407A, 0xffE91E63, 0xffD81B60, 0xffC2185B, 0xffAD1457, 0xff880E4F),
|
||||
@@ -59,228 +62,43 @@ class Colors @Inject constructor(private val context: Context, private val prefs
|
||||
private val minimumContrastRatio = 2
|
||||
|
||||
// Cache these values so they don't need to be recalculated
|
||||
private val primaryTextLuminance = measureLuminance(getColor(R.color.textPrimaryDark))
|
||||
private val secondaryTextLuminance = measureLuminance(getColor(R.color.textSecondaryDark))
|
||||
private val tertiaryTextLuminance = measureLuminance(getColor(R.color.textTertiaryDark))
|
||||
private val primaryTextLuminance = measureLuminance(context.getColorCompat(R.color.textPrimaryDark))
|
||||
private val secondaryTextLuminance = measureLuminance(context.getColorCompat(R.color.textSecondaryDark))
|
||||
private val tertiaryTextLuminance = measureLuminance(context.getColorCompat(R.color.textTertiaryDark))
|
||||
|
||||
val theme = themeForConversation()
|
||||
fun theme(threadId: Long = 0): Theme = Theme(prefs.theme(threadId).get(), this)
|
||||
|
||||
val appThemeResources = Observables.combineLatest(prefs.night.asObservable(), prefs.black.asObservable(),
|
||||
{ night, black ->
|
||||
when {
|
||||
night && black -> R.style.AppThemeBlack
|
||||
night && !black -> R.style.AppThemeDark
|
||||
else -> R.style.AppThemeLight
|
||||
}
|
||||
})
|
||||
|
||||
val appDialogThemeResources = Observables.combineLatest(prefs.night.asObservable(), prefs.black.asObservable(),
|
||||
{ night, black ->
|
||||
when {
|
||||
night && black -> R.style.AppThemeBlackDialog
|
||||
night && !black -> R.style.AppThemeDarkDialog
|
||||
else -> R.style.AppThemeLightDialog
|
||||
}
|
||||
})
|
||||
|
||||
val popupThemeResource = Observables.combineLatest(prefs.night.asObservable(), prefs.black.asObservable(),
|
||||
{ night, black ->
|
||||
when {
|
||||
night && black -> R.style.PopupThemeBlack
|
||||
night && !black -> R.style.PopupThemeDark
|
||||
else -> R.style.PopupThemeLight
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Returns the flags to be used for the system bars. This is used for tinting the icons
|
||||
* according to the colour of the system bars (light or dark)
|
||||
*
|
||||
* If night mode, or no dark icons supported, use light icons
|
||||
*
|
||||
* If night mode and only dark status icons supported, use dark status icons
|
||||
*
|
||||
* If night mode and all dark icons supported, use all dark icons
|
||||
*/
|
||||
@SuppressLint("InlinedApi")
|
||||
val systemBarIcons: Observable<Int> = prefs.night.asObservable()
|
||||
.map { night ->
|
||||
when {
|
||||
night || Build.VERSION.SDK_INT < Build.VERSION_CODES.M -> 0
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.O -> View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||
else -> View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||
}
|
||||
}
|
||||
.distinctUntilChanged()
|
||||
|
||||
val statusBar: Observable<Int> = Observables.combineLatest(prefs.night.asObservable(), prefs.black.asObservable(),
|
||||
{ night, black ->
|
||||
when {
|
||||
night && black -> R.color.black
|
||||
night && !black -> R.color.statusBarDark
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.M -> R.color.black
|
||||
else -> R.color.statusBarLight
|
||||
}
|
||||
})
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val navigationBar: Observable<Int> = Observables.combineLatest(prefs.night.asObservable(), prefs.black.asObservable(),
|
||||
{ night, black ->
|
||||
when {
|
||||
night && black -> R.color.black
|
||||
night && !black -> R.color.backgroundDark
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.O -> R.color.black
|
||||
else -> R.color.white
|
||||
}
|
||||
})
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val toolbarColor: Observable<Int> = Observables.combineLatest(prefs.night.asObservable(), prefs.black.asObservable(),
|
||||
{ night, black ->
|
||||
when {
|
||||
night && black -> R.color.black
|
||||
night && !black -> R.color.toolbarDark
|
||||
else -> R.color.toolbarLight
|
||||
}
|
||||
})
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val background: Observable<Int> = Observables.combineLatest(prefs.night.asObservable(), prefs.black.asObservable(),
|
||||
{ night, black ->
|
||||
when {
|
||||
night && black -> R.color.black
|
||||
night && !black -> R.color.backgroundDark
|
||||
else -> R.color.white
|
||||
}
|
||||
})
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val ripple: Observable<Int> = prefs.night.asObservable()
|
||||
.map { night ->
|
||||
when (night) {
|
||||
true -> R.drawable.ripple_dark
|
||||
false -> R.drawable.ripple
|
||||
}
|
||||
}
|
||||
.distinctUntilChanged()
|
||||
|
||||
val field: Observable<Int> = prefs.night.asObservable()
|
||||
.map { night -> if (night) R.color.fieldDark else R.color.fieldLight }
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val composeBackground: Observable<Int> = Observables.combineLatest(prefs.night.asObservable(), prefs.black.asObservable(),
|
||||
{ night, black ->
|
||||
when {
|
||||
night && black -> R.color.black
|
||||
night && !black -> R.color.backgroundDark
|
||||
else -> R.color.backgroundLight
|
||||
}
|
||||
})
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val separator: Observable<Int> = prefs.night.asObservable()
|
||||
.map { night -> if (night) R.color.separatorDark else R.color.separatorLight }
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val textPrimary: Observable<Int> = prefs.night.asObservable()
|
||||
.map { night -> if (night) R.color.textPrimaryDark else R.color.textPrimary }
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val textSecondary: Observable<Int> = prefs.night.asObservable()
|
||||
.map { night -> if (night) R.color.textSecondaryDark else R.color.textSecondary }
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val textTertiary: Observable<Int> = prefs.night.asObservable()
|
||||
.map { night -> if (night) R.color.textTertiaryDark else R.color.textTertiary }
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val highlightColor: Observable<Int> = theme
|
||||
.map { theme -> FloatArray(3).apply { Color.colorToHSV(theme, this) } }
|
||||
.map { hsv -> hsv.apply { set(2, 0.75f) } } // 75% value
|
||||
.map { hsv -> Color.HSVToColor(85, hsv) } // 33% alpha
|
||||
|
||||
val textPrimaryOnTheme = textPrimaryOnThemeForConversation()
|
||||
|
||||
val textSecondaryOnTheme = textSecondaryOnThemeForConversation()
|
||||
|
||||
val textTertiaryOnTheme = textTertiaryOnThemeForConversation()
|
||||
|
||||
val bubble: Observable<Int> = prefs.night.asObservable()
|
||||
.map { night -> if (night) R.color.bubbleDark else R.color.bubbleLight }
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val switchThumbEnabled: Observable<Int> = prefs.night.asObservable()
|
||||
.map { night -> if (night) R.color.switchThumbEnabledDark else R.color.switchThumbEnabledLight }
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val switchThumbDisabled: Observable<Int> = prefs.night.asObservable()
|
||||
.map { night -> if (night) R.color.switchThumbDisabledDark else R.color.switchThumbDisabledLight }
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val switchTrackEnabled: Observable<Int> = prefs.night.asObservable()
|
||||
.map { night -> if (night) R.color.switchTrackEnabledDark else R.color.switchTrackEnabledLight }
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
val switchTrackDisabled: Observable<Int> = prefs.night.asObservable()
|
||||
.map { night -> if (night) R.color.switchTrackDisabledDark else R.color.switchTrackDisabledLight }
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
fun themeForConversation(threadId: Long = 0): Observable<Int> = prefs.theme(threadId)
|
||||
.asObservable()
|
||||
.distinctUntilChanged()
|
||||
|
||||
fun textPrimaryOnThemeForConversation(threadId: Long = 0): Observable<Int> = themeForConversation(threadId)
|
||||
.switchMap { color -> textPrimaryOnThemeForColor(color) }
|
||||
|
||||
fun textPrimaryOnThemeForColor(color: Int): Observable<Int> = Observable.just(color)
|
||||
.map { theme -> measureLuminance(theme) }
|
||||
.map { themeLuminance -> primaryTextLuminance / themeLuminance }
|
||||
.map { contrastRatio -> contrastRatio < minimumContrastRatio }
|
||||
.map { contrastRatio -> if (contrastRatio) R.color.textPrimary else R.color.textPrimaryDark }
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
fun textSecondaryOnThemeForConversation(threadId: Long = 0): Observable<Int> = themeForConversation(threadId)
|
||||
.switchMap { color -> textSecondaryOnThemeForColor(color) }
|
||||
|
||||
fun textSecondaryOnThemeForColor(color: Int): Observable<Int> = Observable.just(color)
|
||||
.map { theme -> measureLuminance(theme) }
|
||||
.map { themeLuminance -> secondaryTextLuminance / themeLuminance }
|
||||
.map { contrastRatio -> contrastRatio < minimumContrastRatio }
|
||||
.map { contrastRatio -> if (contrastRatio) R.color.textSecondary else R.color.textSecondaryDark }
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
fun textTertiaryOnThemeForConversation(threadId: Long = 0): Observable<Int> = themeForConversation(threadId)
|
||||
.switchMap { color -> textTertiaryOnThemeForColor(color) }
|
||||
|
||||
fun textTertiaryOnThemeForColor(color: Int): Observable<Int> = Observable.just(color)
|
||||
.map { theme -> measureLuminance(theme) }
|
||||
.map { themeLuminance -> tertiaryTextLuminance / themeLuminance }
|
||||
.map { contrastRatio -> contrastRatio < minimumContrastRatio }
|
||||
.map { contrastRatio -> if (contrastRatio) R.color.textTertiary else R.color.textTertiaryDark }
|
||||
.map { res -> getColor(res) }
|
||||
.distinctUntilChanged()
|
||||
|
||||
private fun getColor(@ColorRes res: Int): Int {
|
||||
return context.resources.getColor(res)
|
||||
fun themeObservable(threadId: Long = 0): Observable<Theme> {
|
||||
return prefs.theme(threadId).asObservable()
|
||||
.map { color -> Theme(color, this) }
|
||||
}
|
||||
|
||||
fun highlightColorForTheme(theme: Int): Int = FloatArray(3)
|
||||
.apply { Color.colorToHSV(theme, this) }
|
||||
.let { hsv -> hsv.apply { set(2, 0.75f) } } // 75% value
|
||||
.let { hsv -> Color.HSVToColor(85, hsv) } // 33% alpha
|
||||
|
||||
fun textPrimaryOnThemeForColor(color: Int): Int = color
|
||||
.let { theme -> measureLuminance(theme) }
|
||||
.let { themeLuminance -> primaryTextLuminance / themeLuminance }
|
||||
.let { contrastRatio -> contrastRatio < minimumContrastRatio }
|
||||
.let { contrastRatio -> if (contrastRatio) R.color.textPrimary else R.color.textPrimaryDark }
|
||||
.let { res -> context.getColorCompat(res) }
|
||||
|
||||
fun textSecondaryOnThemeForColor(color: Int): Int = color
|
||||
.let { theme -> measureLuminance(theme) }
|
||||
.let { themeLuminance -> secondaryTextLuminance / themeLuminance }
|
||||
.let { contrastRatio -> contrastRatio < minimumContrastRatio }
|
||||
.let { contrastRatio -> if (contrastRatio) R.color.textSecondary else R.color.textSecondaryDark }
|
||||
.let { res -> context.getColorCompat(res) }
|
||||
|
||||
fun textTertiaryOnThemeForColor(color: Int): Int = color
|
||||
.let { theme -> measureLuminance(theme) }
|
||||
.let { themeLuminance -> tertiaryTextLuminance / themeLuminance }
|
||||
.let { contrastRatio -> contrastRatio < minimumContrastRatio }
|
||||
.let { contrastRatio -> if (contrastRatio) R.color.textTertiary else R.color.textTertiaryDark }
|
||||
.let { res -> context.getColorCompat(res) }
|
||||
|
||||
/**
|
||||
* Measures the luminance value of a color to be able to measure the contrast ratio between two materialColors
|
||||
* Based on https://stackoverflow.com/a/9733420
|
||||
|
||||
@@ -22,28 +22,15 @@ import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import android.support.v4.content.res.ResourcesCompat
|
||||
import com.moez.QKSMS.R
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.subjects.BehaviorSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import timber.log.Timber
|
||||
import util.Preferences
|
||||
import util.extensions.Optional
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class FontProvider @Inject constructor(context: Context, prefs: Preferences) {
|
||||
class FontProvider @Inject constructor(context: Context) {
|
||||
|
||||
val typeface: Observable<Optional<Typeface>> = prefs.systemFont.asObservable()
|
||||
.distinctUntilChanged()
|
||||
.switchMap { systemFont ->
|
||||
when (systemFont) {
|
||||
true -> Observable.just(Optional(null))
|
||||
false -> lato
|
||||
}
|
||||
}
|
||||
|
||||
private val lato: Observable<Optional<Typeface>> = BehaviorSubject.create()
|
||||
private var lato: Typeface? = null
|
||||
private val pendingCallbacks = ArrayList<(Typeface) -> Unit>()
|
||||
|
||||
init {
|
||||
ResourcesCompat.getFont(context, R.font.lato, object : ResourcesCompat.FontCallback() {
|
||||
@@ -52,10 +39,16 @@ class FontProvider @Inject constructor(context: Context, prefs: Preferences) {
|
||||
}
|
||||
|
||||
override fun onFontRetrieved(typeface: Typeface) {
|
||||
val subject = lato as Subject<Optional<Typeface>>
|
||||
subject.onNext(Optional(typeface))
|
||||
lato = typeface
|
||||
|
||||
pendingCallbacks.forEach { lato?.run(it) }
|
||||
pendingCallbacks.clear()
|
||||
}
|
||||
}, null)
|
||||
}
|
||||
|
||||
fun getLato(callback: (Typeface) -> Unit) {
|
||||
lato?.run(callback) ?: pendingCallbacks.add(callback)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -108,9 +108,14 @@ class NotificationManagerImpl @Inject constructor(
|
||||
val readPI = PendingIntent.getBroadcast(context, threadId.toInt() + 30000, readIntent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
val readAction = NotificationCompat.Action(R.drawable.ic_check_white_24dp, context.getString(R.string.notification_read), readPI)
|
||||
|
||||
// We can't store a null preference, so map it to a null Uri if the pref string is empty
|
||||
val ringtone = prefs.ringtone(threadId).get()
|
||||
.takeIf { it.isNotEmpty() }
|
||||
?.let(Uri::parse)
|
||||
|
||||
val notification = NotificationCompat.Builder(context, getChannelIdForNotification(threadId))
|
||||
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
|
||||
.setColor(colors.themeForConversation(threadId).blockingFirst())
|
||||
.setColor(colors.theme(threadId).theme)
|
||||
.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setNumber(messages.size)
|
||||
@@ -118,7 +123,7 @@ class NotificationManagerImpl @Inject constructor(
|
||||
.setContentIntent(contentPI)
|
||||
.setDeleteIntent(seenPI)
|
||||
.addAction(readAction)
|
||||
.setSound(Uri.parse(prefs.ringtone(threadId).get()))
|
||||
.setSound(ringtone)
|
||||
.setLights(Color.WHITE, 500, 2000)
|
||||
.setVibrate(if (prefs.vibration(threadId).get()) VIBRATE_PATTERN else longArrayOf(0))
|
||||
|
||||
@@ -207,7 +212,7 @@ class NotificationManagerImpl @Inject constructor(
|
||||
val notification = NotificationCompat.Builder(context, getChannelIdForNotification(threadId))
|
||||
.setContentTitle(context.getString(R.string.notification_message_failed_title))
|
||||
.setContentText(context.getString(R.string.notification_message_failed_text, conversation.getTitle()))
|
||||
.setColor(colors.themeForConversation(threadId).blockingFirst())
|
||||
.setColor(colors.theme(threadId).theme)
|
||||
.setPriority(NotificationManagerCompat.IMPORTANCE_MAX)
|
||||
.setSmallIcon(R.drawable.ic_notification_failed)
|
||||
.setAutoCancel(true)
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package common.util
|
||||
|
||||
import android.graphics.Typeface
|
||||
import android.util.AttributeSet
|
||||
import android.widget.TextView
|
||||
import com.moez.QKSMS.R
|
||||
import common.util.extensions.getColorCompat
|
||||
import common.util.extensions.resolveThemeColor
|
||||
import common.widget.QkEditText
|
||||
import common.widget.QkTextView
|
||||
import util.Preferences
|
||||
import javax.inject.Inject
|
||||
|
||||
class TextViewStyler @Inject constructor(
|
||||
private val prefs: Preferences,
|
||||
private val colors: Colors,
|
||||
private val fontProvider: FontProvider
|
||||
) {
|
||||
|
||||
companion object {
|
||||
const val COLOR_PRIMARY = 0
|
||||
const val COLOR_SECONDARY = 1
|
||||
const val COLOR_TERTIARY = 2
|
||||
const val COLOR_PRIMARY_ON_THEME = 3
|
||||
const val COLOR_SECONDARY_ON_THEME = 4
|
||||
const val COLOR_TERTIARY_ON_THEME = 5
|
||||
const val COLOR_THEME = 6
|
||||
|
||||
const val SIZE_PRIMARY = 0
|
||||
const val SIZE_SECONDARY = 1
|
||||
const val SIZE_TERTIARY = 2
|
||||
const val SIZE_TOOLBAR = 3
|
||||
}
|
||||
|
||||
fun applyAttributes(textView: TextView, attrs: AttributeSet?) {
|
||||
textView.run {
|
||||
when (this) {
|
||||
is QkTextView -> context.obtainStyledAttributes(attrs, R.styleable.QkTextView)?.run {
|
||||
val colorAttr = getInt(R.styleable.QkTextView_textColor, -1)
|
||||
val textSizeAttr = getInt(R.styleable.QkTextView_textSize, -1)
|
||||
applyAttributes(textView, colorAttr, textSizeAttr)
|
||||
recycle()
|
||||
}
|
||||
|
||||
is QkEditText -> context.obtainStyledAttributes(attrs, R.styleable.QkEditText)?.run {
|
||||
val colorAttr = getInt(R.styleable.QkEditText_textColor, -1)
|
||||
val textSizeAttr = getInt(R.styleable.QkEditText_textSize, -1)
|
||||
applyAttributes(textView, colorAttr, textSizeAttr)
|
||||
recycle()
|
||||
}
|
||||
}
|
||||
|
||||
if (!prefs.systemFont.get()) {
|
||||
fontProvider.getLato { lato ->
|
||||
setTypeface(lato, typeface?.style ?: Typeface.NORMAL)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun applyAttributes(textView: TextView, colorAttr: Int, textSizeAttr: Int) {
|
||||
textView.run {
|
||||
if (isInEditMode) {
|
||||
setTextColor(context.getColorCompat(when (colorAttr) {
|
||||
COLOR_PRIMARY -> R.color.textPrimary
|
||||
COLOR_SECONDARY -> R.color.textSecondary
|
||||
COLOR_TERTIARY -> R.color.textTertiary
|
||||
COLOR_PRIMARY_ON_THEME -> R.color.textPrimaryDark
|
||||
COLOR_SECONDARY_ON_THEME -> R.color.textSecondaryDark
|
||||
COLOR_TERTIARY_ON_THEME -> R.color.textTertiaryDark
|
||||
COLOR_THEME -> R.color.tools_theme
|
||||
else -> R.color.textPrimary
|
||||
}))
|
||||
|
||||
textSize = when (textSizeAttr) {
|
||||
SIZE_PRIMARY -> 16f
|
||||
SIZE_SECONDARY -> 14f
|
||||
SIZE_TERTIARY -> 12f
|
||||
SIZE_TOOLBAR -> 20f
|
||||
else -> textSize
|
||||
}
|
||||
} else {
|
||||
setTextColor(when (colorAttr) {
|
||||
COLOR_PRIMARY -> context.resolveThemeColor(android.R.attr.textColorPrimary)
|
||||
COLOR_SECONDARY -> context.resolveThemeColor(android.R.attr.textColorSecondary)
|
||||
COLOR_TERTIARY -> context.resolveThemeColor(android.R.attr.textColorTertiary)
|
||||
COLOR_PRIMARY_ON_THEME -> colors.theme().textPrimary
|
||||
COLOR_SECONDARY_ON_THEME -> colors.theme().textSecondary
|
||||
COLOR_TERTIARY_ON_THEME -> colors.theme().textTertiary
|
||||
COLOR_THEME -> colors.theme().theme
|
||||
else -> currentTextColor
|
||||
})
|
||||
|
||||
setTextSize(textView, textSizeAttr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SIZE_PRIMARY
|
||||
* @see SIZE_SECONDARY
|
||||
* @see SIZE_TERTIARY
|
||||
* @see SIZE_TOOLBAR
|
||||
*/
|
||||
fun setTextSize(textView: TextView, textSizeAttr: Int) {
|
||||
val textSizePref = prefs.textSize.get()
|
||||
when (textSizeAttr) {
|
||||
SIZE_PRIMARY -> textView.textSize = when (textSizePref) {
|
||||
Preferences.TEXT_SIZE_SMALL -> 14f
|
||||
Preferences.TEXT_SIZE_NORMAL -> 16f
|
||||
Preferences.TEXT_SIZE_LARGE -> 18f
|
||||
Preferences.TEXT_SIZE_LARGER -> 20f
|
||||
else -> 16f
|
||||
}
|
||||
|
||||
SIZE_SECONDARY -> textView.textSize = when (textSizePref) {
|
||||
Preferences.TEXT_SIZE_SMALL -> 12f
|
||||
Preferences.TEXT_SIZE_NORMAL -> 14f
|
||||
Preferences.TEXT_SIZE_LARGE -> 16f
|
||||
Preferences.TEXT_SIZE_LARGER -> 18f
|
||||
else -> 14f
|
||||
}
|
||||
|
||||
SIZE_TERTIARY -> textView.textSize = when (textSizePref) {
|
||||
Preferences.TEXT_SIZE_SMALL -> 10f
|
||||
Preferences.TEXT_SIZE_NORMAL -> 12f
|
||||
Preferences.TEXT_SIZE_LARGE -> 14f
|
||||
Preferences.TEXT_SIZE_LARGER -> 16f
|
||||
else -> 12f
|
||||
}
|
||||
|
||||
SIZE_TOOLBAR -> textView.textSize = when (textSizePref) {
|
||||
Preferences.TEXT_SIZE_SMALL -> 18f
|
||||
Preferences.TEXT_SIZE_NORMAL -> 20f
|
||||
Preferences.TEXT_SIZE_LARGE -> 22f
|
||||
Preferences.TEXT_SIZE_LARGER -> 26f
|
||||
else -> 20f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.support.annotation.StringRes
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.util.TypedValue
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Toast
|
||||
|
||||
@@ -29,6 +30,23 @@ fun Context.getColorCompat(colorRes: Int): Int {
|
||||
return ContextCompat.getColor(this, colorRes)
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to resolve a resource id from the current theme, based on the [attributeId]
|
||||
*/
|
||||
fun Context.resolveThemeAttribute(attributeId: Int, default: Int = 0): Int {
|
||||
val outValue = TypedValue()
|
||||
val wasResolved = theme.resolveAttribute(attributeId, outValue, true)
|
||||
|
||||
return if (wasResolved) outValue.resourceId else default
|
||||
}
|
||||
|
||||
fun Context.resolveThemeColor(attributeId: Int, default: Int = 0): Int {
|
||||
val outValue = TypedValue()
|
||||
val wasResolved = theme.resolveAttribute(attributeId, outValue, true)
|
||||
|
||||
return if (wasResolved) getColorCompat(outValue.resourceId) else default
|
||||
}
|
||||
|
||||
fun Context.makeToast(@StringRes res: Int, duration: Int = Toast.LENGTH_SHORT) {
|
||||
Toast.makeText(this, res, duration).show()
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.PorterDuff
|
||||
import android.os.Build
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
@@ -94,3 +95,15 @@ fun View.forwardTouches(parent: View) {
|
||||
}
|
||||
}
|
||||
|
||||
fun RecyclerView.scrapViews() {
|
||||
val adapter = adapter
|
||||
val layoutManager = layoutManager
|
||||
|
||||
this.adapter = null
|
||||
this.layoutManager = null
|
||||
|
||||
this.adapter = adapter
|
||||
this.layoutManager = layoutManager
|
||||
|
||||
adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
@@ -25,10 +25,7 @@ import android.telephony.PhoneNumberUtils
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.Navigator
|
||||
import common.util.Colors
|
||||
import common.util.GlideApp
|
||||
@@ -49,6 +46,16 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
* This value can be changes if we should use the theme from a particular conversation
|
||||
*/
|
||||
var threadId: Long = 0
|
||||
set(value) {
|
||||
if (field == value) return
|
||||
field = value
|
||||
|
||||
colors.theme(value).run {
|
||||
setBackgroundTint(theme)
|
||||
initial.setTextColor(textPrimary)
|
||||
icon.setTint(textPrimary)
|
||||
}
|
||||
}
|
||||
|
||||
private var lookupKey: String? = null
|
||||
private var name: String? = null
|
||||
@@ -63,6 +70,16 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
|
||||
setBackgroundResource(R.drawable.circle)
|
||||
clipToOutline = true
|
||||
|
||||
setOnClickListener {
|
||||
if (lookupKey.isNullOrEmpty()) {
|
||||
address?.let { address -> navigator.addContact(address) }
|
||||
} else {
|
||||
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey)
|
||||
ContactsContract.QuickContact.showQuickContact(context, this@AvatarView, uri,
|
||||
ContactsContract.QuickContact.MODE_MEDIUM, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setContact(recipient: Recipient?) {
|
||||
@@ -85,37 +102,16 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
updateView()
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
|
||||
if (!isInEditMode) {
|
||||
colors.themeForConversation(threadId)
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> setBackgroundTint(color) }
|
||||
|
||||
colors.textPrimaryOnThemeForConversation(threadId)
|
||||
.apply { initial.textColorObservable = this }
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> icon.setTint(color) }
|
||||
|
||||
clicks()
|
||||
.autoDisposable(scope())
|
||||
.subscribe {
|
||||
if (lookupKey.isNullOrEmpty()) {
|
||||
address?.let { address -> navigator.addContact(address) }
|
||||
} else {
|
||||
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey)
|
||||
ContactsContract.QuickContact.showQuickContact(context, this@AvatarView, uri,
|
||||
ContactsContract.QuickContact.MODE_MEDIUM, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
|
||||
if (!isInEditMode) {
|
||||
colors.theme(threadId).run {
|
||||
setBackgroundTint(theme)
|
||||
initial.setTextColor(textPrimary)
|
||||
icon.setTint(textPrimary)
|
||||
}
|
||||
|
||||
updateView()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ import com.uber.autodispose.android.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.util.Colors
|
||||
import common.util.extensions.forEach
|
||||
import common.util.extensions.resolveThemeColor
|
||||
import injection.appComponent
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.subjects.BehaviorSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.tab_view.view.*
|
||||
@@ -90,24 +90,19 @@ class PagerTitleView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
intArrayOf(android.R.attr.state_selected),
|
||||
intArrayOf(-android.R.attr.state_selected))
|
||||
|
||||
val theme = threadId
|
||||
threadId
|
||||
.distinctUntilChanged()
|
||||
.switchMap { threadId -> colors.themeForConversation(threadId) }
|
||||
|
||||
Observables
|
||||
.combineLatest(theme, colors.textSecondary, { theme, textSecondary ->
|
||||
ColorStateList(states, intArrayOf(theme, textSecondary))
|
||||
})
|
||||
.switchMap { threadId -> colors.themeObservable(threadId) }
|
||||
.map { theme ->
|
||||
val textSecondary = context.resolveThemeColor(android.R.attr.textColorSecondary)
|
||||
ColorStateList(states, intArrayOf(theme.theme, textSecondary))
|
||||
}
|
||||
.autoDisposable(scope())
|
||||
.subscribe { colorStateList ->
|
||||
childCount.forEach { index ->
|
||||
(getChildAt(index) as? TextView)?.setTextColor(colorStateList)
|
||||
}
|
||||
}
|
||||
|
||||
colors.toolbarColor
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> setBackgroundColor(color) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,20 +25,15 @@ import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.util.Colors
|
||||
import common.util.extensions.getColorCompat
|
||||
import common.util.extensions.resolveThemeAttribute
|
||||
import common.util.extensions.resolveThemeColor
|
||||
import common.util.extensions.setTint
|
||||
import common.util.extensions.setVisible
|
||||
import injection.appComponent
|
||||
import kotlinx.android.synthetic.main.preference_view.view.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class PreferenceView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayoutCompat(context, attrs) {
|
||||
|
||||
@Inject lateinit var colors: Colors
|
||||
|
||||
var title: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
@@ -72,10 +67,13 @@ class PreferenceView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
}
|
||||
|
||||
View.inflate(context, R.layout.preference_view, this)
|
||||
setBackgroundResource(R.drawable.ripple)
|
||||
setBackgroundResource(context.resolveThemeAttribute(R.attr.selectableItemBackground))
|
||||
orientation = HORIZONTAL
|
||||
gravity = Gravity.CENTER_VERTICAL
|
||||
|
||||
val textSecondary = context.resolveThemeColor(android.R.attr.textColorSecondary)
|
||||
icon.setTint(textSecondary)
|
||||
|
||||
context.obtainStyledAttributes(attrs, R.styleable.PreferenceView)?.run {
|
||||
title = getString(R.styleable.PreferenceView_title)
|
||||
summary = getString(R.styleable.PreferenceView_summary)
|
||||
@@ -95,16 +93,4 @@ class PreferenceView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
|
||||
if (isInEditMode) {
|
||||
icon.setTint(context.getColorCompat(R.color.textSecondary))
|
||||
} else {
|
||||
colors.textSecondary
|
||||
.autoDisposable(scope())
|
||||
.subscribe { icon.setTint(it) }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,7 +19,6 @@
|
||||
package common.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import android.os.Build
|
||||
import android.support.v13.view.inputmethod.EditorInfoCompat
|
||||
import android.support.v13.view.inputmethod.InputConnectionCompat
|
||||
@@ -31,22 +30,10 @@ import android.view.inputmethod.InputConnection
|
||||
import android.view.inputmethod.InputConnectionWrapper
|
||||
import android.widget.EditText
|
||||
import com.google.android.mms.ContentType
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.util.Colors
|
||||
import common.util.FontProvider
|
||||
import common.widget.QkTextView.Companion.SIZE_PRIMARY
|
||||
import common.widget.QkTextView.Companion.SIZE_SECONDARY
|
||||
import common.widget.QkTextView.Companion.SIZE_TERTIARY
|
||||
import common.widget.QkTextView.Companion.SIZE_TOOLBAR
|
||||
import common.util.TextViewStyler
|
||||
import injection.appComponent
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.subjects.BehaviorSubject
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import util.Preferences
|
||||
import util.tryOrNull
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -59,132 +46,19 @@ import javax.inject.Inject
|
||||
*/
|
||||
class QkEditText @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : EditText(context, attrs) {
|
||||
|
||||
companion object {
|
||||
const val COLOR_PRIMARY = 0
|
||||
const val COLOR_SECONDARY = 1
|
||||
const val COLOR_TERTIARY = 2
|
||||
const val COLOR_PRIMARY_ON_THEME = 3
|
||||
const val COLOR_SECONDARY_ON_THEME = 4
|
||||
const val COLOR_TERTIARY_ON_THEME = 5
|
||||
|
||||
const val SIZE_PRIMARY = 0
|
||||
const val SIZE_SECONDARY = 1
|
||||
const val SIZE_TERTIARY = 2
|
||||
const val SIZE_TOOLBAR = 3
|
||||
}
|
||||
|
||||
@Inject lateinit var colors: Colors
|
||||
@Inject lateinit var fontProvider: FontProvider
|
||||
@Inject lateinit var prefs: Preferences
|
||||
@Inject lateinit var textViewStyler: TextViewStyler
|
||||
|
||||
val backspaces: Subject<Unit> = PublishSubject.create()
|
||||
val inputContentSelected: Subject<InputContentInfoCompat> = PublishSubject.create()
|
||||
var supportsInputContent: Boolean = false
|
||||
|
||||
private var textColorObservable: Observable<Int>? = null
|
||||
private var textColorHintObservable: Observable<Int>? = null
|
||||
|
||||
private var textSizeAttrSubject: Subject<Int> = BehaviorSubject.create()
|
||||
|
||||
init {
|
||||
if (!isInEditMode) {
|
||||
appComponent.inject(this)
|
||||
|
||||
context.obtainStyledAttributes(attrs, R.styleable.QkEditText)?.run {
|
||||
val colorAttr = getInt(R.styleable.QkEditText_textColor, -1)
|
||||
val colorHintAttr = getInt(R.styleable.QkEditText_textColorHint, -1)
|
||||
val textSizeAttr = getInt(R.styleable.QkEditText_textSize, -1)
|
||||
|
||||
textColorObservable = when (colorAttr) {
|
||||
COLOR_PRIMARY -> colors.textPrimary
|
||||
COLOR_SECONDARY -> colors.textSecondary
|
||||
COLOR_TERTIARY -> colors.textTertiary
|
||||
COLOR_PRIMARY_ON_THEME -> colors.textPrimaryOnTheme
|
||||
COLOR_SECONDARY_ON_THEME -> colors.textSecondaryOnTheme
|
||||
COLOR_TERTIARY_ON_THEME -> colors.textTertiaryOnTheme
|
||||
else -> null
|
||||
}
|
||||
|
||||
textColorHintObservable = when (colorHintAttr) {
|
||||
COLOR_PRIMARY -> colors.textPrimary
|
||||
COLOR_SECONDARY -> colors.textSecondary
|
||||
COLOR_TERTIARY -> colors.textTertiary
|
||||
else -> null
|
||||
}
|
||||
|
||||
setTextSize(textSizeAttr)
|
||||
|
||||
recycle()
|
||||
}
|
||||
textViewStyler.applyAttributes(this, attrs)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SIZE_PRIMARY
|
||||
* @see SIZE_SECONDARY
|
||||
* @see SIZE_TERTIARY
|
||||
* @see SIZE_TOOLBAR
|
||||
*/
|
||||
fun setTextSize(size: Int) {
|
||||
textSizeAttrSubject.onNext(size)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
if (isInEditMode) return
|
||||
|
||||
fontProvider.typeface
|
||||
.autoDisposable(scope())
|
||||
.subscribe { setTypeface(it.value, typeface?.style ?: Typeface.NORMAL) }
|
||||
|
||||
textColorObservable
|
||||
?.autoDisposable(scope())
|
||||
?.subscribe { color -> setTextColor(color) }
|
||||
|
||||
textColorHintObservable
|
||||
?.autoDisposable(scope())
|
||||
?.subscribe { color -> setHintTextColor(color) }
|
||||
|
||||
Observables
|
||||
.combineLatest(prefs.textSize.asObservable(), textSizeAttrSubject, { textSizePref, textSizeAttr ->
|
||||
when (textSizeAttr) {
|
||||
SIZE_PRIMARY -> textSize = when (textSizePref) {
|
||||
Preferences.TEXT_SIZE_SMALL -> 14f
|
||||
Preferences.TEXT_SIZE_NORMAL -> 16f
|
||||
Preferences.TEXT_SIZE_LARGE -> 18f
|
||||
Preferences.TEXT_SIZE_LARGER -> 20f
|
||||
else -> 16f
|
||||
}
|
||||
|
||||
SIZE_SECONDARY -> textSize = when (textSizePref) {
|
||||
Preferences.TEXT_SIZE_SMALL -> 12f
|
||||
Preferences.TEXT_SIZE_NORMAL -> 14f
|
||||
Preferences.TEXT_SIZE_LARGE -> 16f
|
||||
Preferences.TEXT_SIZE_LARGER -> 18f
|
||||
else -> 14f
|
||||
}
|
||||
|
||||
SIZE_TERTIARY -> textSize = when (textSizePref) {
|
||||
Preferences.TEXT_SIZE_SMALL -> 10f
|
||||
Preferences.TEXT_SIZE_NORMAL -> 12f
|
||||
Preferences.TEXT_SIZE_LARGE -> 14f
|
||||
Preferences.TEXT_SIZE_LARGER -> 16f
|
||||
else -> 12f
|
||||
}
|
||||
|
||||
SIZE_TOOLBAR -> textSize = when (textSizePref) {
|
||||
Preferences.TEXT_SIZE_SMALL -> 18f
|
||||
Preferences.TEXT_SIZE_NORMAL -> 20f
|
||||
Preferences.TEXT_SIZE_LARGE -> 22f
|
||||
Preferences.TEXT_SIZE_LARGER -> 26f
|
||||
else -> 20f
|
||||
}
|
||||
}
|
||||
})
|
||||
.autoDisposable(scope())
|
||||
.subscribe()
|
||||
}
|
||||
|
||||
override fun onCreateInputConnection(editorInfo: EditorInfo): InputConnection {
|
||||
|
||||
val inputConnection = object : InputConnectionWrapper(super.onCreateInputConnection(editorInfo), true) {
|
||||
|
||||
@@ -22,17 +22,18 @@ import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.support.v7.widget.SwitchCompat
|
||||
import android.util.AttributeSet
|
||||
import com.uber.autodispose.android.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import com.moez.QKSMS.R
|
||||
import common.util.Colors
|
||||
import common.util.extensions.getColorCompat
|
||||
import common.util.extensions.withAlpha
|
||||
import injection.appComponent
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import util.Preferences
|
||||
import javax.inject.Inject
|
||||
|
||||
class QkSwitch @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : SwitchCompat(context, attrs) {
|
||||
|
||||
@Inject lateinit var colors: Colors
|
||||
@Inject lateinit var prefs: Preferences
|
||||
|
||||
init {
|
||||
if (!isInEditMode) {
|
||||
@@ -49,17 +50,26 @@ class QkSwitch @JvmOverloads constructor(context: Context, attrs: AttributeSet?
|
||||
intArrayOf(android.R.attr.state_checked),
|
||||
intArrayOf())
|
||||
|
||||
Observables.combineLatest(colors.theme, colors.switchThumbEnabled, colors.switchThumbDisabled,
|
||||
{ color, enabled, disabled -> intArrayOf(disabled, color, enabled) })
|
||||
.map { values -> ColorStateList(states, values) }
|
||||
.autoDisposable(scope())
|
||||
.subscribe { tintList -> thumbTintList = tintList }
|
||||
val themeColor = colors.theme().theme
|
||||
|
||||
Observables.combineLatest(colors.theme, colors.switchTrackEnabled, colors.switchTrackDisabled,
|
||||
{ color, enabled, disabled -> intArrayOf(disabled, color.withAlpha(0x4D), enabled) })
|
||||
.map { values -> ColorStateList(states, values) }
|
||||
.autoDisposable(scope())
|
||||
.subscribe { tintList -> trackTintList = tintList }
|
||||
val switchThumbEnabled: Int = prefs.night.get()
|
||||
.let { night -> if (night) R.color.switchThumbEnabledDark else R.color.switchThumbEnabledLight }
|
||||
.let { res -> context.getColorCompat(res) }
|
||||
|
||||
val switchThumbDisabled: Int = prefs.night.get()
|
||||
.let { night -> if (night) R.color.switchThumbDisabledDark else R.color.switchThumbDisabledLight }
|
||||
.let { res -> context.getColorCompat(res) }
|
||||
|
||||
val switchTrackEnabled: Int = prefs.night.get()
|
||||
.let { night -> if (night) R.color.switchTrackEnabledDark else R.color.switchTrackEnabledLight }
|
||||
.let { res -> context.getColorCompat(res) }
|
||||
|
||||
val switchTrackDisabled: Int = prefs.night.get()
|
||||
.let { night -> if (night) R.color.switchTrackDisabledDark else R.color.switchTrackDisabledLight }
|
||||
.let { res -> context.getColorCompat(res) }
|
||||
|
||||
thumbTintList = ColorStateList(states, intArrayOf(switchThumbDisabled, themeColor, switchThumbEnabled))
|
||||
trackTintList = ColorStateList(states, intArrayOf(switchTrackDisabled, themeColor.withAlpha(0x4D), switchTrackEnabled))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,178 +19,27 @@
|
||||
package common.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import android.support.text.emoji.widget.EmojiAppCompatTextView
|
||||
import android.util.AttributeSet
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.util.Colors
|
||||
import common.util.FontProvider
|
||||
import common.util.extensions.getColorCompat
|
||||
import common.util.TextViewStyler
|
||||
import injection.appComponent
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.subjects.BehaviorSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import util.Preferences
|
||||
import javax.inject.Inject
|
||||
|
||||
open class QkTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null)
|
||||
: EmojiAppCompatTextView(context, attrs) {
|
||||
|
||||
companion object {
|
||||
const val COLOR_PRIMARY = 0
|
||||
const val COLOR_SECONDARY = 1
|
||||
const val COLOR_TERTIARY = 2
|
||||
const val COLOR_PRIMARY_ON_THEME = 3
|
||||
const val COLOR_SECONDARY_ON_THEME = 4
|
||||
const val COLOR_TERTIARY_ON_THEME = 5
|
||||
const val COLOR_THEME = 6
|
||||
|
||||
const val SIZE_PRIMARY = 0
|
||||
const val SIZE_SECONDARY = 1
|
||||
const val SIZE_TERTIARY = 2
|
||||
const val SIZE_TOOLBAR = 3
|
||||
}
|
||||
|
||||
@Inject lateinit var colors: Colors
|
||||
@Inject lateinit var fontProvider: FontProvider
|
||||
@Inject lateinit var prefs: Preferences
|
||||
|
||||
var textColorObservable: Observable<Int>? = null
|
||||
set(value) {
|
||||
field = value
|
||||
updateSubscription()
|
||||
}
|
||||
|
||||
private var textColorDisposable: Disposable? = null
|
||||
set(value) {
|
||||
field?.dispose()
|
||||
field = value
|
||||
}
|
||||
|
||||
private var textSizeAttrSubject: Subject<Int> = BehaviorSubject.create()
|
||||
@Inject lateinit var textViewStyler: TextViewStyler
|
||||
|
||||
init {
|
||||
if (!isInEditMode) {
|
||||
appComponent.inject(this)
|
||||
}
|
||||
|
||||
context.obtainStyledAttributes(attrs, R.styleable.QkTextView)?.run {
|
||||
val colorAttr = getInt(R.styleable.QkTextView_textColor, -1)
|
||||
val textSizeAttr = getInt(R.styleable.QkTextView_textSize, -1)
|
||||
|
||||
if (isInEditMode) {
|
||||
setTextColor(context.getColorCompat(when (colorAttr) {
|
||||
COLOR_PRIMARY -> R.color.textPrimary
|
||||
COLOR_SECONDARY -> R.color.textSecondary
|
||||
COLOR_TERTIARY -> R.color.textTertiary
|
||||
COLOR_PRIMARY_ON_THEME -> R.color.textPrimaryDark
|
||||
COLOR_SECONDARY_ON_THEME -> R.color.textSecondaryDark
|
||||
COLOR_TERTIARY_ON_THEME -> R.color.textTertiaryDark
|
||||
COLOR_THEME -> R.color.tools_theme
|
||||
else -> R.color.textPrimary
|
||||
}))
|
||||
|
||||
textSize = when (textSizeAttr) {
|
||||
SIZE_PRIMARY -> 16f
|
||||
SIZE_SECONDARY -> 14f
|
||||
SIZE_TERTIARY -> 12f
|
||||
SIZE_TOOLBAR -> 20f
|
||||
else -> textSize
|
||||
}
|
||||
} else {
|
||||
textColorObservable = when (colorAttr) {
|
||||
COLOR_PRIMARY -> colors.textPrimary
|
||||
COLOR_SECONDARY -> colors.textSecondary
|
||||
COLOR_TERTIARY -> colors.textTertiary
|
||||
COLOR_PRIMARY_ON_THEME -> colors.textPrimaryOnTheme
|
||||
COLOR_SECONDARY_ON_THEME -> colors.textSecondaryOnTheme
|
||||
COLOR_TERTIARY_ON_THEME -> colors.textTertiaryOnTheme
|
||||
COLOR_THEME -> colors.theme
|
||||
else -> null
|
||||
}
|
||||
|
||||
setTextSize(textSizeAttr)
|
||||
}
|
||||
|
||||
recycle()
|
||||
textViewStyler.applyAttributes(this, attrs)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SIZE_PRIMARY
|
||||
* @see SIZE_SECONDARY
|
||||
* @see SIZE_TERTIARY
|
||||
* @see SIZE_TOOLBAR
|
||||
*/
|
||||
fun setTextSize(size: Int) {
|
||||
textSizeAttrSubject.onNext(size)
|
||||
override fun setTextColor(color: Int) {
|
||||
super.setTextColor(color)
|
||||
setLinkTextColor(color)
|
||||
}
|
||||
|
||||
private fun updateSubscription() {
|
||||
if (isAttachedToWindow) {
|
||||
textColorDisposable = textColorObservable?.subscribe { color ->
|
||||
setTextColor(color)
|
||||
setLinkTextColor(color)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
if (isInEditMode) return
|
||||
|
||||
updateSubscription()
|
||||
|
||||
fontProvider.typeface
|
||||
.autoDisposable(scope())
|
||||
.subscribe { setTypeface(it.value, typeface?.style ?: Typeface.NORMAL) }
|
||||
|
||||
Observables
|
||||
.combineLatest(prefs.textSize.asObservable(), textSizeAttrSubject, { textSizePref, textSizeAttr ->
|
||||
when (textSizeAttr) {
|
||||
SIZE_PRIMARY -> textSize = when (textSizePref) {
|
||||
Preferences.TEXT_SIZE_SMALL -> 14f
|
||||
Preferences.TEXT_SIZE_NORMAL -> 16f
|
||||
Preferences.TEXT_SIZE_LARGE -> 18f
|
||||
Preferences.TEXT_SIZE_LARGER -> 20f
|
||||
else -> 16f
|
||||
}
|
||||
|
||||
SIZE_SECONDARY -> textSize = when (textSizePref) {
|
||||
Preferences.TEXT_SIZE_SMALL -> 12f
|
||||
Preferences.TEXT_SIZE_NORMAL -> 14f
|
||||
Preferences.TEXT_SIZE_LARGE -> 16f
|
||||
Preferences.TEXT_SIZE_LARGER -> 18f
|
||||
else -> 14f
|
||||
}
|
||||
|
||||
SIZE_TERTIARY -> textSize = when (textSizePref) {
|
||||
Preferences.TEXT_SIZE_SMALL -> 10f
|
||||
Preferences.TEXT_SIZE_NORMAL -> 12f
|
||||
Preferences.TEXT_SIZE_LARGE -> 14f
|
||||
Preferences.TEXT_SIZE_LARGER -> 16f
|
||||
else -> 12f
|
||||
}
|
||||
|
||||
SIZE_TOOLBAR -> textSize = when (textSizePref) {
|
||||
Preferences.TEXT_SIZE_SMALL -> 18f
|
||||
Preferences.TEXT_SIZE_NORMAL -> 20f
|
||||
Preferences.TEXT_SIZE_LARGE -> 22f
|
||||
Preferences.TEXT_SIZE_LARGER -> 26f
|
||||
else -> 20f
|
||||
}
|
||||
}
|
||||
})
|
||||
.autoDisposable(scope())
|
||||
.subscribe()
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
textColorDisposable?.dispose()
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package common.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.util.Colors
|
||||
import common.util.extensions.getColorCompat
|
||||
import injection.appComponent
|
||||
import javax.inject.Inject
|
||||
|
||||
class Separator @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : View(context, attrs) {
|
||||
|
||||
@Inject lateinit var colors: Colors
|
||||
|
||||
init {
|
||||
if (!isInEditMode) {
|
||||
appComponent.inject(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
|
||||
if (isInEditMode) {
|
||||
setBackgroundColor(context.getColorCompat(R.color.separatorLight))
|
||||
} else {
|
||||
colors.separator
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> setBackgroundColor(color) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,6 @@ import android.arch.lifecycle.ViewModelProviders
|
||||
import android.os.Bundle
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.base.QkThemedActivity
|
||||
import dagger.android.AndroidInjection
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
@@ -53,10 +51,6 @@ class BlockedActivity : QkThemedActivity(), BlockedView {
|
||||
showBackButton(true)
|
||||
viewModel.bindView(this)
|
||||
|
||||
colors.background
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> window.decorView.setBackgroundColor(color) }
|
||||
|
||||
blockedAdapter.emptyView = empty
|
||||
conversations.adapter = blockedAdapter
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package feature.blocked
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.moez.QKSMS.R
|
||||
@@ -29,12 +28,12 @@ import kotlinx.android.synthetic.main.blocked_list_item.view.*
|
||||
import model.Conversation
|
||||
import javax.inject.Inject
|
||||
|
||||
class BlockedAdapter @Inject constructor(private val context: Context) : QkRealmAdapter<Conversation>() {
|
||||
class BlockedAdapter @Inject constructor() : QkRealmAdapter<Conversation>() {
|
||||
|
||||
val unblock: PublishSubject<Long> = PublishSubject.create()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
return QkViewHolder(LayoutInflater.from(context).inflate(R.layout.blocked_list_item, parent, false))
|
||||
return QkViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.blocked_list_item, parent, false))
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||
|
||||
@@ -27,19 +27,14 @@ import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.moez.QKSMS.R
|
||||
import common.base.QkAdapter
|
||||
import common.base.QkViewHolder
|
||||
import common.util.Colors
|
||||
import common.util.extensions.setBackgroundTint
|
||||
import common.util.extensions.setTint
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.attachment_list_item.view.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class AttachmentAdapter @Inject constructor(
|
||||
private val context: Context,
|
||||
private val colors: Colors
|
||||
private val context: Context
|
||||
) : QkAdapter<Attachment>() {
|
||||
|
||||
val attachmentDeleted: Subject<Attachment> = PublishSubject.create()
|
||||
@@ -47,16 +42,10 @@ class AttachmentAdapter @Inject constructor(
|
||||
private val disposables = CompositeDisposable()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
val view = LayoutInflater.from(context).inflate(R.layout.attachment_list_item, parent, false)
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.attachment_list_item, parent, false)
|
||||
|
||||
view.thumbnailBounds.clipToOutline = true
|
||||
|
||||
disposables += colors.bubble
|
||||
.subscribe { color -> view.detach.setBackgroundTint(color) }
|
||||
|
||||
disposables += colors.textSecondary
|
||||
.subscribe { color -> view.detach.setTint(color) }
|
||||
|
||||
return QkViewHolder(view)
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,8 @@ import com.jakewharton.rxbinding2.widget.textChanges
|
||||
import com.moez.QKSMS.R
|
||||
import common.base.QkAdapter
|
||||
import common.base.QkViewHolder
|
||||
import common.util.Colors
|
||||
import common.util.extensions.dpToPx
|
||||
import common.util.extensions.setBackgroundTint
|
||||
import common.util.extensions.resolveThemeColor
|
||||
import common.util.extensions.showKeyboard
|
||||
import common.widget.QkEditText
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
@@ -40,7 +39,7 @@ import kotlinx.android.synthetic.main.contact_chip.view.*
|
||||
import model.Contact
|
||||
import javax.inject.Inject
|
||||
|
||||
class ChipsAdapter @Inject constructor(private val context: Context, private val colors: Colors) : QkAdapter<Contact>() {
|
||||
class ChipsAdapter @Inject constructor(private val context: Context) : QkAdapter<Contact>() {
|
||||
|
||||
companion object {
|
||||
private const val TYPE_EDIT_TEXT = 0
|
||||
@@ -76,13 +75,15 @@ class ChipsAdapter @Inject constructor(private val context: Context, private val
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = when (viewType) {
|
||||
TYPE_EDIT_TEXT -> QkViewHolder(editText)
|
||||
TYPE_EDIT_TEXT -> {
|
||||
editText.setTextColor(parent.context.resolveThemeColor(android.R.attr.textColorPrimary))
|
||||
editText.setHintTextColor(parent.context.resolveThemeColor(android.R.attr.textColorTertiary))
|
||||
QkViewHolder(editText)
|
||||
}
|
||||
|
||||
else -> {
|
||||
val view = LayoutInflater.from(context).inflate(R.layout.contact_chip, parent, false)
|
||||
colors.composeBackground.subscribe { color -> view.content.setBackgroundTint(color) }
|
||||
|
||||
QkViewHolder(view)
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
QkViewHolder(inflater.inflate(R.layout.contact_chip, parent, false))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +103,7 @@ class ChipsAdapter @Inject constructor(private val context: Context, private val
|
||||
contact.numbers.firstOrNull { it.address.isNotBlank() }?.address ?: ""
|
||||
}
|
||||
|
||||
view.setOnClickListener { showDetailedChip(contact) }
|
||||
view.setOnClickListener { showDetailedChip(view.context, contact) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,7 +112,10 @@ class ChipsAdapter @Inject constructor(private val context: Context, private val
|
||||
|
||||
override fun getItemViewType(position: Int) = if (position == itemCount - 1) TYPE_EDIT_TEXT else TYPE_ITEM
|
||||
|
||||
private fun showDetailedChip(contact: Contact) {
|
||||
/**
|
||||
* The [context] has to come from a view, because we're inflating a view that used themed attrs
|
||||
*/
|
||||
private fun showDetailedChip(context: Context, contact: Contact) {
|
||||
val detailedChipView = DetailedChipView(context)
|
||||
detailedChipView.setContact(contact)
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.arch.lifecycle.ViewModelProvider
|
||||
import android.arch.lifecycle.ViewModelProviders
|
||||
import android.content.ContentValues
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.PorterDuff
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
@@ -41,13 +40,13 @@ import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.base.QkThemedActivity
|
||||
import common.util.extensions.autoScrollToStart
|
||||
import common.util.extensions.scrapViews
|
||||
import common.util.extensions.setBackgroundTint
|
||||
import common.util.extensions.setTint
|
||||
import common.util.extensions.setVisible
|
||||
import common.util.extensions.showKeyboard
|
||||
import dagger.android.AndroidInjection
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.compose_activity.*
|
||||
@@ -123,50 +122,12 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
messageBackground.backgroundTintMode = PorterDuff.Mode.MULTIPLY
|
||||
message.supportsInputContent = true
|
||||
|
||||
val states = arrayOf(
|
||||
intArrayOf(android.R.attr.state_enabled),
|
||||
intArrayOf(-android.R.attr.state_enabled))
|
||||
|
||||
val iconEnabled = threadId
|
||||
.distinctUntilChanged()
|
||||
.switchMap { threadId -> colors.textPrimaryOnThemeForConversation(threadId) }
|
||||
|
||||
val iconDisabled = threadId
|
||||
.distinctUntilChanged()
|
||||
.switchMap { threadId -> colors.textTertiaryOnThemeForConversation(threadId) }
|
||||
|
||||
Observables
|
||||
.combineLatest(iconEnabled, iconDisabled, { primary, tertiary ->
|
||||
ColorStateList(states, intArrayOf(primary, tertiary))
|
||||
})
|
||||
.autoDisposable(scope())
|
||||
.subscribe { tintList -> send.imageTintList = tintList }
|
||||
|
||||
theme
|
||||
.doOnNext { send.setBackgroundTint(it.theme) }
|
||||
.doOnNext { send.setTint(it.textPrimary) }
|
||||
.doOnNext { messageAdapter.theme = it }
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> send.setBackgroundTint(color) }
|
||||
|
||||
colors.textSecondary
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color ->
|
||||
attach.setTint(color)
|
||||
camera.setTint(color)
|
||||
gallery.setTint(color)
|
||||
}
|
||||
|
||||
colors.bubble
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> messageBackground.setBackgroundTint(color) }
|
||||
|
||||
colors.background
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> contacts.setBackgroundColor(color) }
|
||||
|
||||
colors.composeBackground
|
||||
.doOnNext { color -> composeBackground.setBackgroundTint(color) }
|
||||
.doOnNext { color -> window.decorView.setBackgroundColor(color) }
|
||||
.autoDisposable(scope())
|
||||
.subscribe()
|
||||
.subscribe { messageList.scrapViews() }
|
||||
|
||||
window.callback = ComposeWindowCallback(window.callback, this)
|
||||
}
|
||||
@@ -236,6 +197,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
counter.setVisible(counter.text.isNotBlank())
|
||||
|
||||
send.isEnabled = state.canSend
|
||||
send.imageAlpha = if (state.canSend) 255 else 128
|
||||
}
|
||||
|
||||
override fun clearSelection() {
|
||||
|
||||
@@ -38,9 +38,8 @@ class ContactAdapter @Inject constructor(private val context: Context) : QkAdapt
|
||||
val contactSelected: Subject<Contact> = PublishSubject.create()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
val layoutRes = R.layout.contact_list_item
|
||||
val layoutInflater = LayoutInflater.from(context)
|
||||
val view = layoutInflater.inflate(layoutRes, parent, false)
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val view = layoutInflater.inflate(R.layout.contact_list_item, parent, false)
|
||||
return QkViewHolder(view)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ import android.view.View
|
||||
import android.view.animation.AlphaAnimation
|
||||
import android.widget.RelativeLayout
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.util.Colors
|
||||
import common.util.extensions.setBackgroundTint
|
||||
import injection.appComponent
|
||||
@@ -47,14 +45,8 @@ class DetailedChipView(context: Context) : RelativeLayout(context) {
|
||||
|
||||
isFocusable = true
|
||||
isFocusableInTouchMode = true
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
|
||||
colors.theme
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> card.setBackgroundTint(color) }
|
||||
card.setBackgroundTint(colors.theme().theme)
|
||||
}
|
||||
|
||||
fun setContact(contact: Contact) {
|
||||
|
||||
@@ -43,13 +43,13 @@ import common.util.DateFormatter
|
||||
import common.util.GlideApp
|
||||
import common.util.extensions.dpToPx
|
||||
import common.util.extensions.forwardTouches
|
||||
import common.util.extensions.resolveThemeColor
|
||||
import common.util.extensions.setBackgroundTint
|
||||
import common.util.extensions.setPadding
|
||||
import common.util.extensions.setTint
|
||||
import common.util.extensions.setVisible
|
||||
import common.widget.BubbleImageView.Style.*
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import io.realm.RealmResults
|
||||
@@ -90,9 +90,7 @@ class MessagesAdapter @Inject constructor(
|
||||
contactCache.clear()
|
||||
|
||||
// Update the theme
|
||||
val threadId = value?.first?.id ?: 0
|
||||
theme = colors.themeForConversation(threadId)
|
||||
textPrimaryOnTheme = colors.textPrimaryOnThemeForConversation(threadId)
|
||||
theme = colors.theme(value?.first?.id ?: 0)
|
||||
|
||||
updateData(value?.second)
|
||||
}
|
||||
@@ -119,8 +117,7 @@ class MessagesAdapter @Inject constructor(
|
||||
private val expanded = HashMap<Long, Boolean>()
|
||||
private val disposables = CompositeDisposable()
|
||||
|
||||
private var theme = colors.theme
|
||||
private var textPrimaryOnTheme = colors.textPrimaryOnTheme
|
||||
var theme: Colors.Theme = colors.theme()
|
||||
|
||||
/**
|
||||
* If the viewType is negative, then the viewHolder has an attachment. We'll consider
|
||||
@@ -135,27 +132,15 @@ class MessagesAdapter @Inject constructor(
|
||||
|
||||
if (viewType == VIEW_TYPE_MESSAGE_OUT) {
|
||||
view = layoutInflater.inflate(R.layout.message_list_item_out, parent, false)
|
||||
disposables += colors.bubble
|
||||
.subscribe { color ->
|
||||
view.body.setBackgroundTint(color)
|
||||
view.findViewById<ProgressBar>(R.id.cancel).setBackgroundTint(color)
|
||||
}
|
||||
disposables += theme
|
||||
.subscribe { color ->
|
||||
view.findViewById<ImageView>(R.id.cancelIcon).setTint(color)
|
||||
view.findViewById<ProgressBar>(R.id.cancel).setTint(color)
|
||||
}
|
||||
view.findViewById<ImageView>(R.id.cancelIcon).setTint(theme.theme)
|
||||
view.findViewById<ProgressBar>(R.id.cancel).setTint(theme.theme)
|
||||
} else {
|
||||
view = layoutInflater.inflate(R.layout.message_list_item_in, parent, false)
|
||||
view.avatar.threadId = conversation?.id ?: 0
|
||||
view.body.textColorObservable = textPrimaryOnTheme
|
||||
disposables += theme
|
||||
.subscribe { color -> view.body.setBackgroundTint(color) }
|
||||
view.body.setTextColor(theme.textPrimary)
|
||||
view.body.setBackgroundTint(theme.theme)
|
||||
}
|
||||
|
||||
disposables += colors.ripple
|
||||
.subscribe { res -> view.setBackgroundResource(res) }
|
||||
|
||||
view.body.forwardTouches(view)
|
||||
|
||||
return QkViewHolder(view)
|
||||
@@ -303,9 +288,9 @@ class MessagesAdapter @Inject constructor(
|
||||
// If we're on API 21, we need to re-tint the background
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
view.body.setBackgroundTint(when (message.isMe()) {
|
||||
true -> colors.bubble
|
||||
false -> theme
|
||||
}.blockingFirst())
|
||||
true -> context.resolveThemeColor(R.attr.bubbleColor)
|
||||
false -> theme.theme
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.Navigator
|
||||
import common.base.QkThemedActivity
|
||||
import common.util.extensions.scrapViews
|
||||
import common.util.extensions.setVisible
|
||||
import dagger.android.AndroidInjection
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
@@ -59,10 +60,6 @@ class ConversationInfoActivity : QkThemedActivity(), ConversationInfoView {
|
||||
viewModel.bindView(this)
|
||||
setTitle(R.string.info_title)
|
||||
|
||||
colors.background
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> window.decorView.setBackgroundColor(color) }
|
||||
|
||||
mediaAdapter.thumbnailClicks
|
||||
.autoDisposable(scope())
|
||||
.subscribe { view -> navigator.showImageAnimated(this, view) }
|
||||
@@ -71,6 +68,10 @@ class ConversationInfoActivity : QkThemedActivity(), ConversationInfoView {
|
||||
|
||||
media.adapter = mediaAdapter
|
||||
media.addItemDecoration(itemDecoration)
|
||||
|
||||
theme
|
||||
.autoDisposable(scope())
|
||||
.subscribe { recipients.scrapViews() }
|
||||
}
|
||||
|
||||
override fun render(state: ConversationInfoState) {
|
||||
@@ -79,8 +80,9 @@ class ConversationInfoActivity : QkThemedActivity(), ConversationInfoView {
|
||||
return
|
||||
}
|
||||
|
||||
recipientAdapter.updateData(state.recipients)
|
||||
threadId.onNext(state.threadId)
|
||||
recipientAdapter.threadId = state.threadId
|
||||
recipientAdapter.updateData(state.recipients)
|
||||
|
||||
notifications.setVisible(!state.blocked)
|
||||
|
||||
|
||||
+3
-2
@@ -1,17 +1,18 @@
|
||||
package feature.conversationinfo
|
||||
|
||||
import android.arch.lifecycle.ViewModel
|
||||
import android.content.Intent
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.multibindings.IntoMap
|
||||
import injection.ViewModelKey
|
||||
import javax.inject.Named
|
||||
|
||||
@Module
|
||||
class ConversationInfoActivityModule {
|
||||
|
||||
@Provides
|
||||
fun provideIntent(activity: ConversationInfoActivity): Intent = activity.intent
|
||||
@Named("threadId")
|
||||
fun provideIntent(activity: ConversationInfoActivity): Long = activity.intent.extras?.getLong("threadId") ?: 0L
|
||||
|
||||
@Provides
|
||||
@IntoMap
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package feature.conversationinfo
|
||||
|
||||
import android.content.Intent
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.Navigator
|
||||
@@ -35,29 +34,24 @@ import model.Conversation
|
||||
import repository.MessageRepository
|
||||
import util.extensions.asObservable
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Named
|
||||
|
||||
class ConversationInfoViewModel @Inject constructor(
|
||||
private val intent: Intent,
|
||||
private val messageRepo: MessageRepository,
|
||||
@Named("threadId") threadId: Long,
|
||||
messageRepo: MessageRepository,
|
||||
private val markArchived: MarkArchived,
|
||||
private val markUnarchived: MarkUnarchived,
|
||||
private val markBlocked: MarkBlocked,
|
||||
private val markUnblocked: MarkUnblocked,
|
||||
private val navigator: Navigator,
|
||||
private val deleteConversations: DeleteConversations
|
||||
) : QkViewModel<ConversationInfoView, ConversationInfoState>(ConversationInfoState()) {
|
||||
|
||||
) : QkViewModel<ConversationInfoView, ConversationInfoState>(
|
||||
ConversationInfoState(threadId = threadId, media = messageRepo.getPartsForConversation(threadId))
|
||||
) {
|
||||
|
||||
private val conversation: Observable<Conversation>
|
||||
|
||||
init {
|
||||
val threadId = intent.extras?.getLong("threadId") ?: 0L
|
||||
|
||||
newState { it.copy(threadId = threadId) }
|
||||
|
||||
// Load the attachments from the conversation
|
||||
newState { it.copy(media = messageRepo.getPartsForConversation(threadId)) }
|
||||
|
||||
conversation = messageRepo.getConversationAsync(threadId)
|
||||
.asObservable<Conversation>()
|
||||
.filter { conversation -> conversation.isLoaded }
|
||||
|
||||
@@ -26,18 +26,15 @@ import android.view.ViewGroup
|
||||
import com.moez.QKSMS.R
|
||||
import common.base.QkRealmAdapter
|
||||
import common.base.QkViewHolder
|
||||
import common.util.Colors
|
||||
import common.util.GlideApp
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import kotlinx.android.synthetic.main.conversation_media_list_item.view.*
|
||||
import model.MmsPart
|
||||
import javax.inject.Inject
|
||||
|
||||
class ConversationMediaAdapter @Inject constructor(
|
||||
private val context: Context,
|
||||
private val colors: Colors
|
||||
private val context: Context
|
||||
) : QkRealmAdapter<MmsPart>() {
|
||||
|
||||
val thumbnailClicks: PublishSubject<View> = PublishSubject.create()
|
||||
@@ -45,10 +42,7 @@ class ConversationMediaAdapter @Inject constructor(
|
||||
private val disposables = CompositeDisposable()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
val view = LayoutInflater.from(context).inflate(R.layout.conversation_media_list_item, parent, false)
|
||||
|
||||
disposables += colors.separator.subscribe { color -> view.setBackgroundColor(color) }
|
||||
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.conversation_media_list_item, parent, false)
|
||||
return QkViewHolder(view)
|
||||
}
|
||||
|
||||
|
||||
+1
-11
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package feature.conversationinfo
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
@@ -26,18 +25,13 @@ import com.moez.QKSMS.R
|
||||
import common.Navigator
|
||||
import common.base.QkRealmAdapter
|
||||
import common.base.QkViewHolder
|
||||
import common.util.Colors
|
||||
import common.util.extensions.setTint
|
||||
import common.util.extensions.setVisible
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import kotlinx.android.synthetic.main.conversation_recipient_list_item.view.*
|
||||
import model.Recipient
|
||||
import javax.inject.Inject
|
||||
|
||||
class ConversationRecipientAdapter @Inject constructor(
|
||||
private val context: Context,
|
||||
private val colors: Colors,
|
||||
private val navigator: Navigator
|
||||
) : QkRealmAdapter<Recipient>() {
|
||||
|
||||
@@ -46,12 +40,8 @@ class ConversationRecipientAdapter @Inject constructor(
|
||||
private val disposables = CompositeDisposable()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(context)
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val view = layoutInflater.inflate(R.layout.conversation_recipient_list_item, parent, false)
|
||||
|
||||
disposables += colors.textSecondary
|
||||
.subscribe { color -> view.add.setTint(color) }
|
||||
|
||||
return QkViewHolder(view)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,52 +20,43 @@ package feature.conversations
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.jakewharton.rxbinding2.view.longClicks
|
||||
import com.moez.QKSMS.R
|
||||
import common.Navigator
|
||||
import common.base.QkRealmAdapter
|
||||
import common.base.QkViewHolder
|
||||
import common.util.Colors
|
||||
import common.util.DateFormatter
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import common.util.extensions.resolveThemeColor
|
||||
import kotlinx.android.synthetic.main.conversation_list_item.view.*
|
||||
import model.Conversation
|
||||
import javax.inject.Inject
|
||||
|
||||
class ConversationsAdapter @Inject constructor(
|
||||
private val context: Context,
|
||||
private val colors: Colors,
|
||||
private val dateFormatter: DateFormatter,
|
||||
private val navigator: Navigator
|
||||
) : QkRealmAdapter<Conversation>() {
|
||||
|
||||
private val disposables = CompositeDisposable()
|
||||
|
||||
init {
|
||||
setHasStableIds(true)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(context)
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val view = layoutInflater.inflate(R.layout.conversation_list_item, parent, false)
|
||||
|
||||
disposables += colors.ripple
|
||||
.subscribe { res -> view.setBackgroundResource(res) }
|
||||
|
||||
if (viewType == 1) {
|
||||
val textColorPrimary = parent.context.resolveThemeColor(android.R.attr.textColorPrimary)
|
||||
|
||||
view.title.setTypeface(view.title.typeface, Typeface.BOLD)
|
||||
|
||||
view.snippet.setTypeface(view.snippet.typeface, Typeface.BOLD)
|
||||
view.snippet.textColorObservable = colors.textPrimary
|
||||
view.snippet.setTextColor(textColorPrimary)
|
||||
view.snippet.maxLines = 5
|
||||
|
||||
view.date.setTypeface(view.date.typeface, Typeface.BOLD)
|
||||
view.date.textColorObservable = colors.textPrimary
|
||||
view.date.setTextColor(textColorPrimary)
|
||||
}
|
||||
|
||||
return QkViewHolder(view)
|
||||
@@ -75,15 +66,16 @@ class ConversationsAdapter @Inject constructor(
|
||||
val conversation = getItem(position)!!
|
||||
val view = viewHolder.itemView
|
||||
|
||||
view.clicks().subscribe {
|
||||
view.setOnClickListener {
|
||||
when (toggleSelection(conversation.id, false)) {
|
||||
true -> view.isSelected = isSelected(conversation.id)
|
||||
false -> navigator.showConversation(conversation.id)
|
||||
}
|
||||
}
|
||||
view.longClicks().subscribe {
|
||||
view.setOnLongClickListener {
|
||||
toggleSelection(conversation.id)
|
||||
view.isSelected = isSelected(conversation.id)
|
||||
true
|
||||
}
|
||||
|
||||
view.isSelected = isSelected(conversation.id)
|
||||
@@ -97,11 +89,6 @@ class ConversationsAdapter @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
|
||||
super.onDetachedFromRecyclerView(recyclerView)
|
||||
disposables.clear()
|
||||
}
|
||||
|
||||
override fun getItemId(index: Int): Long {
|
||||
return getItem(index)!!.id
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ import android.app.AlertDialog
|
||||
import android.arch.lifecycle.ViewModelProvider
|
||||
import android.arch.lifecycle.ViewModelProviders
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.StateListDrawable
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v4.app.ActivityCompat
|
||||
@@ -45,6 +43,8 @@ import common.Navigator
|
||||
import common.base.QkThemedActivity
|
||||
import common.util.extensions.autoScrollToStart
|
||||
import common.util.extensions.dismissKeyboard
|
||||
import common.util.extensions.resolveThemeColor
|
||||
import common.util.extensions.scrapViews
|
||||
import common.util.extensions.setBackgroundTint
|
||||
import common.util.extensions.setTint
|
||||
import common.util.extensions.setVisible
|
||||
@@ -52,7 +52,6 @@ import dagger.android.AndroidInjection
|
||||
import feature.conversations.ConversationItemTouchCallback
|
||||
import feature.conversations.ConversationsAdapter
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.drawer_view.*
|
||||
@@ -125,67 +124,40 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
|
||||
scheduled.isEnabled = false
|
||||
|
||||
colors.background
|
||||
.doOnNext { color -> window.decorView.setBackgroundColor(color) }
|
||||
.doOnNext { color -> drawer.setBackgroundColor(color) }
|
||||
.autoDisposable(scope())
|
||||
.subscribe()
|
||||
|
||||
val states = arrayOf(
|
||||
intArrayOf(android.R.attr.state_selected),
|
||||
intArrayOf(-android.R.attr.state_selected))
|
||||
|
||||
val rowBackground = { separator: Int ->
|
||||
StateListDrawable().apply {
|
||||
addState(intArrayOf(android.R.attr.state_selected), ColorDrawable(separator))
|
||||
addState(intArrayOf(-android.R.attr.state_selected), getDrawable(R.drawable.ripple))
|
||||
mutate()
|
||||
}
|
||||
}
|
||||
|
||||
// Set the theme color tint to the progressbar and FAB
|
||||
colors.theme
|
||||
.doOnNext { color -> syncingProgress.indeterminateTintList = ColorStateList.valueOf(color) }
|
||||
.doOnNext { color -> itemTouchCallback.color = color }
|
||||
.doOnNext { color -> rateIcon.setTint(color) }
|
||||
.doOnNext { color -> compose.setBackgroundTint(color) }
|
||||
.autoDisposable(scope())
|
||||
.subscribe()
|
||||
|
||||
// Set the FAB compose icon color
|
||||
colors.textPrimaryOnTheme
|
||||
.doOnNext { color -> compose.setTint(color) }
|
||||
.doOnNext { color -> itemTouchCallback.iconColor = color }
|
||||
// Set the theme color tint to the recyclerView, progressbar, and FAB
|
||||
colors.themeObservable()
|
||||
.doOnNext { recyclerView.scrapViews() }
|
||||
.doOnNext { theme ->
|
||||
// Set the color for the drawer icons
|
||||
val states = arrayOf(intArrayOf(android.R.attr.state_selected), intArrayOf(-android.R.attr.state_selected))
|
||||
resolveThemeColor(android.R.attr.textColorSecondary)
|
||||
.let { textSecondary -> ColorStateList(states, intArrayOf(theme.theme, textSecondary)) }
|
||||
.let { tintList ->
|
||||
inboxIcon.imageTintList = tintList
|
||||
archivedIcon.imageTintList = tintList
|
||||
scheduledIcon.imageTintList = tintList
|
||||
settingsIcon.imageTintList = tintList
|
||||
plusIcon.imageTintList = tintList
|
||||
helpIcon.imageTintList = tintList
|
||||
}
|
||||
}
|
||||
.doOnNext { theme ->
|
||||
// Miscellaneous views
|
||||
syncingProgress.indeterminateTintList = ColorStateList.valueOf(theme.theme)
|
||||
itemTouchCallback.color = theme.theme
|
||||
rateIcon.setTint(theme.theme)
|
||||
compose.setBackgroundTint(theme.theme)
|
||||
}
|
||||
.doOnNext { theme ->
|
||||
// Set the FAB compose icon color
|
||||
compose.setTint(theme.textPrimary)
|
||||
itemTouchCallback.iconColor = theme.textPrimary
|
||||
}
|
||||
.autoDisposable(scope())
|
||||
.subscribe()
|
||||
|
||||
// Set the hamburger icon color
|
||||
colors.textSecondary
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> toggle.drawerArrowDrawable.color = color }
|
||||
|
||||
// Set the color for the drawer icons
|
||||
Observables
|
||||
.combineLatest(colors.theme, colors.textSecondary, { theme, textSecondary ->
|
||||
ColorStateList(states, intArrayOf(theme, textSecondary))
|
||||
})
|
||||
.doOnNext { tintList -> inboxIcon.imageTintList = tintList }
|
||||
.doOnNext { tintList -> archivedIcon.imageTintList = tintList }
|
||||
.doOnNext { tintList -> scheduledIcon.imageTintList = tintList }
|
||||
.doOnNext { tintList -> settingsIcon.imageTintList = tintList }
|
||||
.doOnNext { tintList -> plusIcon.imageTintList = tintList }
|
||||
.doOnNext { tintList -> helpIcon.imageTintList = tintList }
|
||||
.autoDisposable(scope())
|
||||
.subscribe()
|
||||
|
||||
// Set the background highlight for the drawer options
|
||||
colors.separator
|
||||
.doOnNext { color -> inbox.background = rowBackground(color) }
|
||||
.doOnNext { color -> archived.background = rowBackground(color) }
|
||||
.doOnNext { color -> scheduled.background = rowBackground(color) }
|
||||
.doOnNext { color -> rateLayout.setBackgroundTint(color) }
|
||||
.autoDisposable(scope())
|
||||
.subscribe()
|
||||
toggle.drawerArrowDrawable.color = resolveThemeColor(android.R.attr.textColorSecondary)
|
||||
|
||||
conversationsAdapter.autoScrollToStart(recyclerView)
|
||||
conversationsAdapter.emptyView = empty
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package feature.main
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.text.SpannableString
|
||||
import android.text.Spanned
|
||||
import android.text.style.BackgroundColorSpan
|
||||
@@ -33,8 +32,6 @@ import common.base.QkViewHolder
|
||||
import common.util.Colors
|
||||
import common.util.DateFormatter
|
||||
import common.util.extensions.setVisible
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import kotlinx.android.synthetic.main.search_list_item.view.*
|
||||
import model.SearchResult
|
||||
import javax.inject.Inject
|
||||
@@ -46,12 +43,10 @@ class SearchAdapter @Inject constructor(
|
||||
private val navigator: Navigator
|
||||
) : QkAdapter<SearchResult>() {
|
||||
|
||||
private var highlightColor: Int = 0
|
||||
|
||||
private val disposables = CompositeDisposable()
|
||||
private var highlightColor: Int = colors.theme().highlight
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(context)
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val view = layoutInflater.inflate(R.layout.search_list_item, parent, false)
|
||||
return QkViewHolder(view)
|
||||
}
|
||||
@@ -105,14 +100,4 @@ class SearchAdapter @Inject constructor(
|
||||
old.conversation.id == new.conversation.id // Conversation id is the same
|
||||
&& old.messages == new.messages // Result count is the same
|
||||
}
|
||||
|
||||
override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
|
||||
disposables += colors.highlightColor
|
||||
.doOnNext { color -> highlightColor = color }
|
||||
.subscribe { notifyDataSetChanged() }
|
||||
}
|
||||
|
||||
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
|
||||
disposables.dispose()
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,6 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.QkDialog
|
||||
import common.base.QkThemedActivity
|
||||
import common.util.extensions.setVisible
|
||||
@@ -70,10 +68,6 @@ class NotificationPrefsActivity : QkThemedActivity(), NotificationPrefsView {
|
||||
previewModeDialog.setTitle(R.string.settings_notification_previews_title)
|
||||
previewModeDialog.adapter.setData(R.array.notification_preview_options)
|
||||
|
||||
colors.background
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> window.decorView.setBackgroundColor(color) }
|
||||
|
||||
// Listen to clicks for all of the preferences
|
||||
(0 until preferences.childCount)
|
||||
.map { index -> preferences.getChildAt(index) }
|
||||
@@ -102,7 +96,7 @@ class NotificationPrefsActivity : QkThemedActivity(), NotificationPrefsView {
|
||||
|
||||
override fun showPreviewModeDialog() = previewModeDialog.show(this)
|
||||
|
||||
override fun showRingtonePicker(default: Uri) {
|
||||
override fun showRingtonePicker(default: Uri?) {
|
||||
val intent = Intent(RingtoneManager.ACTION_RINGTONE_PICKER)
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true)
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true)
|
||||
@@ -115,7 +109,7 @@ class NotificationPrefsActivity : QkThemedActivity(), NotificationPrefsView {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (requestCode == 123 && resultCode == Activity.RESULT_OK) {
|
||||
val uri: Uri? = data?.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI)
|
||||
uri?.let { ringtoneSelectedIntent.onNext(uri.toString()) }
|
||||
ringtoneSelectedIntent.onNext(uri?.toString() ?: "")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,5 +31,5 @@ interface NotificationPrefsView : QkView<NotificationPrefsState> {
|
||||
val ringtoneSelectedIntent: Observable<String>
|
||||
|
||||
fun showPreviewModeDialog()
|
||||
fun showRingtonePicker(default: Uri)
|
||||
fun showRingtonePicker(default: Uri?)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.media.RingtoneManager
|
||||
import android.net.Uri
|
||||
import androidx.net.toUri
|
||||
import com.f2prateek.rx.preferences2.Preference
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
@@ -77,8 +76,12 @@ class NotificationPrefsViewModel @Inject constructor(
|
||||
.subscribe { enabled -> newState { it.copy(vibrationEnabled = enabled) } }
|
||||
|
||||
disposables += ringtone.asObservable()
|
||||
.map { uri -> uri.toUri() }
|
||||
.map { uri -> RingtoneManager.getRingtone(context, uri).getTitle(context) }
|
||||
.map { uriString ->
|
||||
uriString.takeIf { it.isNotEmpty() }
|
||||
?.let(Uri::parse)
|
||||
?.let { uri -> RingtoneManager.getRingtone(context, uri) }?.getTitle(context)
|
||||
?: context.getString(R.string.settings_ringtone_none)
|
||||
}
|
||||
.subscribe { title -> newState { it.copy(ringtoneName = title) } }
|
||||
|
||||
disposables += prefs.qkreply.asObservable()
|
||||
@@ -103,7 +106,7 @@ class NotificationPrefsViewModel @Inject constructor(
|
||||
|
||||
R.id.vibration -> vibration.set(!vibration.get())
|
||||
|
||||
R.id.ringtone -> view.showRingtonePicker(Uri.parse(ringtone.get()))
|
||||
R.id.ringtone -> view.showRingtonePicker(ringtone.get().takeIf { it.isNotEmpty() }?.let(Uri::parse))
|
||||
|
||||
R.id.qkreply -> prefs.qkreply.set(!prefs.qkreply.get())
|
||||
|
||||
|
||||
@@ -25,11 +25,10 @@ import android.os.Bundle
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.moez.QKSMS.BuildConfig
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.base.QkThemedActivity
|
||||
import common.util.BillingManager
|
||||
import common.util.FontProvider
|
||||
import common.util.extensions.resolveThemeColor
|
||||
import common.util.extensions.setBackgroundTint
|
||||
import common.util.extensions.setTint
|
||||
import common.util.extensions.setVisible
|
||||
@@ -58,39 +57,22 @@ class PlusActivity : QkThemedActivity(), PlusView {
|
||||
|
||||
free.setVisible(false)
|
||||
|
||||
fontProvider.typeface
|
||||
.autoDisposable(scope())
|
||||
.subscribe { lato ->
|
||||
val typeface = Typeface.create(lato.value, Typeface.BOLD)
|
||||
collapsingToolbar.setCollapsedTitleTypeface(typeface)
|
||||
collapsingToolbar.setExpandedTitleTypeface(typeface)
|
||||
}
|
||||
if (!prefs.systemFont.get()) {
|
||||
fontProvider.getLato { lato ->
|
||||
val typeface = Typeface.create(lato, Typeface.BOLD)
|
||||
collapsingToolbar.setCollapsedTitleTypeface(typeface)
|
||||
collapsingToolbar.setExpandedTitleTypeface(typeface)
|
||||
}
|
||||
}
|
||||
|
||||
colors.textPrimary
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color ->
|
||||
collapsingToolbar.setCollapsedTitleTextColor(color)
|
||||
collapsingToolbar.setExpandedTitleColor(color)
|
||||
}
|
||||
val textPrimary = resolveThemeColor(android.R.attr.textColorPrimary)
|
||||
collapsingToolbar.setCollapsedTitleTextColor(textPrimary)
|
||||
collapsingToolbar.setExpandedTitleColor(textPrimary)
|
||||
|
||||
colors.background
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> window.decorView.setBackgroundColor(color) }
|
||||
|
||||
colors.separator
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color ->
|
||||
upgradeDonate.setBackgroundTint(color)
|
||||
upgraded.setBackgroundTint(color)
|
||||
}
|
||||
|
||||
colors.theme
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color ->
|
||||
donate.setBackgroundTint(color)
|
||||
upgrade.setBackgroundTint(color)
|
||||
thanksIcon.setTint(color)
|
||||
}
|
||||
val theme = colors.theme().theme
|
||||
donate.setBackgroundTint(theme)
|
||||
upgrade.setBackgroundTint(theme)
|
||||
thanksIcon.setTint(theme)
|
||||
}
|
||||
|
||||
override fun render(state: PlusState) {
|
||||
|
||||
@@ -20,7 +20,6 @@ package feature.qkreply
|
||||
|
||||
import android.arch.lifecycle.ViewModelProvider
|
||||
import android.arch.lifecycle.ViewModelProviders
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.Bundle
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.view.Menu
|
||||
@@ -31,25 +30,24 @@ import android.view.WindowManager
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.jakewharton.rxbinding2.widget.textChanges
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.R.id.*
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.base.QkThemedActivity
|
||||
import common.util.extensions.autoScrollToStart
|
||||
import common.util.extensions.setBackgroundTint
|
||||
import common.util.extensions.setTint
|
||||
import common.util.extensions.setVisible
|
||||
import dagger.android.AndroidInjection
|
||||
import feature.compose.MessagesAdapter
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.qkreply_activity.*
|
||||
import util.Preferences
|
||||
import javax.inject.Inject
|
||||
|
||||
class QkReplyActivity : QkThemedActivity(), QkReplyView {
|
||||
|
||||
@Inject lateinit var adapter: MessagesAdapter
|
||||
@Inject lateinit var prefs: Preferences
|
||||
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||
|
||||
override val menuItemIntent: Subject<Int> = PublishSubject.create()
|
||||
@@ -69,39 +67,12 @@ class QkReplyActivity : QkThemedActivity(), QkReplyView {
|
||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
viewModel.bindView(this)
|
||||
|
||||
colors.composeBackground
|
||||
.doOnNext { color -> background.setBackgroundTint(color) }
|
||||
.doOnNext { color -> composeBackground.setBackgroundTint(color) }
|
||||
.doOnNext { color -> composeBackgroundGradient.setBackgroundTint(color) }
|
||||
.autoDisposable(scope())
|
||||
.subscribe()
|
||||
|
||||
colors.bubble
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> message.setBackgroundTint(color) }
|
||||
|
||||
theme
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> send.setBackgroundTint(color) }
|
||||
|
||||
val states = arrayOf(
|
||||
intArrayOf(android.R.attr.state_enabled),
|
||||
intArrayOf(-android.R.attr.state_enabled))
|
||||
|
||||
val iconEnabled = threadId
|
||||
.distinctUntilChanged()
|
||||
.switchMap { threadId -> colors.textPrimaryOnThemeForConversation(threadId) }
|
||||
|
||||
val iconDisabled = threadId
|
||||
.distinctUntilChanged()
|
||||
.switchMap { threadId -> colors.textTertiaryOnThemeForConversation(threadId) }
|
||||
|
||||
Observables
|
||||
.combineLatest(iconEnabled, iconDisabled, { primary, tertiary ->
|
||||
ColorStateList(states, intArrayOf(primary, tertiary))
|
||||
})
|
||||
.autoDisposable(scope())
|
||||
.subscribe { tintList -> send.imageTintList = tintList }
|
||||
.subscribe { theme ->
|
||||
send.setBackgroundTint(theme.theme)
|
||||
send.setTint(theme.textPrimary)
|
||||
}
|
||||
|
||||
toolbar.clipToOutline = true
|
||||
|
||||
@@ -129,6 +100,7 @@ class QkReplyActivity : QkThemedActivity(), QkReplyView {
|
||||
counter.setVisible(counter.text.isNotBlank())
|
||||
|
||||
send.isEnabled = state.canSend
|
||||
send.imageAlpha = if (state.canSend) 255 else 128
|
||||
}
|
||||
|
||||
override fun setDraft(draft: String) {
|
||||
@@ -145,6 +117,10 @@ class QkReplyActivity : QkThemedActivity(), QkReplyView {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getAppThemeResourcesObservable() = colors.appDialogThemeResources
|
||||
override fun getActivityThemeRes(night: Boolean, black: Boolean) = when {
|
||||
night && black -> R.style.AppThemeBlackDialog
|
||||
night && !black -> R.style.AppThemeDarkDialog
|
||||
else -> R.style.AppThemeLightDialog
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import android.text.format.DateFormat
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.moez.QKSMS.BuildConfig
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.AutoDispose.autoDisposable
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.QkDialog
|
||||
@@ -87,10 +88,6 @@ class SettingsActivity : QkThemedActivity(), SettingsView {
|
||||
|
||||
about.summary = getString(R.string.settings_version, BuildConfig.VERSION_NAME)
|
||||
|
||||
colors.background
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> window.decorView.setBackgroundColor(color) }
|
||||
|
||||
// Listen to clicks for all of the preferences
|
||||
(0 until preferences.childCount)
|
||||
.map { index -> preferences.getChildAt(index) }
|
||||
@@ -100,6 +97,11 @@ class SettingsActivity : QkThemedActivity(), SettingsView {
|
||||
preferenceClickIntent.onNext(preference as PreferenceView)
|
||||
}
|
||||
}
|
||||
|
||||
theme
|
||||
.skip(1)
|
||||
.autoDisposable(scope())
|
||||
.subscribe { recreate() }
|
||||
}
|
||||
|
||||
override fun render(state: SettingsState) {
|
||||
|
||||
@@ -49,8 +49,7 @@ class SettingsViewModel @Inject constructor(
|
||||
|
||||
|
||||
init {
|
||||
disposables += colors.theme
|
||||
.subscribe { color -> newState { it.copy(theme = color) } }
|
||||
newState { it.copy(theme = colors.theme().theme) }
|
||||
|
||||
val nightModeLabels = context.resources.getStringArray(R.array.night_modes)
|
||||
disposables += prefs.nightMode.asObservable()
|
||||
|
||||
@@ -6,8 +6,6 @@ import android.os.Bundle
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.moez.QKSMS.BuildConfig
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.base.QkThemedActivity
|
||||
import common.widget.PreferenceView
|
||||
import dagger.android.AndroidInjection
|
||||
@@ -34,10 +32,6 @@ class AboutActivity : QkThemedActivity(), AboutView {
|
||||
|
||||
version.summary = BuildConfig.VERSION_NAME
|
||||
|
||||
colors.background
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> window.decorView.setBackgroundColor(color) }
|
||||
|
||||
// Listen to clicks for all of the preferences
|
||||
(0 until preferences.childCount)
|
||||
.map { index -> preferences.getChildAt(index) }
|
||||
|
||||
@@ -20,26 +20,23 @@ package feature.themepicker
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.google.android.flexbox.FlexDirection
|
||||
import com.google.android.flexbox.FlexWrap
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
import com.moez.QKSMS.R
|
||||
import common.base.QkAdapter
|
||||
import common.base.QkViewHolder
|
||||
import common.util.Colors
|
||||
import common.util.extensions.dpToPx
|
||||
import common.util.extensions.setBackgroundTint
|
||||
import common.util.extensions.setTint
|
||||
import common.util.extensions.setVisible
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.theme_list_item.view.*
|
||||
import kotlinx.android.synthetic.main.theme_palette_list_item.view.*
|
||||
import common.base.QkAdapter
|
||||
import common.base.QkViewHolder
|
||||
import javax.inject.Inject
|
||||
|
||||
class ThemeAdapter @Inject constructor(
|
||||
@@ -47,12 +44,6 @@ class ThemeAdapter @Inject constructor(
|
||||
private val colors: Colors
|
||||
) : QkAdapter<List<Int>>() {
|
||||
|
||||
var threadId: Long = 0
|
||||
set(value) {
|
||||
field = value
|
||||
threadIdChanged()
|
||||
}
|
||||
|
||||
val colorSelected: Subject<Int> = PublishSubject.create()
|
||||
|
||||
var selectedColor: Int = -1
|
||||
@@ -61,16 +52,16 @@ class ThemeAdapter @Inject constructor(
|
||||
val newPosition = data.indexOfFirst { it.contains(value) }
|
||||
|
||||
field = value
|
||||
iconTint = colors.textPrimaryOnThemeForColor(value)
|
||||
|
||||
oldPosition.takeIf { it != -1 }?.let { position -> notifyItemChanged(position) }
|
||||
newPosition.takeIf { it != -1 }?.let { position -> notifyItemChanged(position) }
|
||||
}
|
||||
|
||||
private var iconTint = 0
|
||||
private val disposables = CompositeDisposable()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
val view = LayoutInflater.from(context).inflate(R.layout.theme_palette_list_item, parent, false)
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.theme_palette_list_item, parent, false)
|
||||
view.palette.flexWrap = FlexWrap.WRAP
|
||||
view.palette.flexDirection = FlexDirection.ROW
|
||||
|
||||
@@ -119,15 +110,4 @@ class ThemeAdapter @Inject constructor(
|
||||
.forEach { theme -> view.palette.addView(theme) }
|
||||
}
|
||||
|
||||
private fun threadIdChanged() {
|
||||
disposables.clear()
|
||||
disposables += colors.textPrimaryOnThemeForConversation(threadId)
|
||||
.subscribe { color -> iconTint = color }
|
||||
|
||||
}
|
||||
|
||||
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
|
||||
disposables.clear()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,11 +25,8 @@ import android.support.design.widget.Snackbar
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.base.QkThemedActivity
|
||||
import common.util.extensions.setBackgroundTint
|
||||
import common.util.extensions.setTint
|
||||
import common.util.extensions.setVisible
|
||||
import dagger.android.AndroidInjection
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
@@ -68,14 +65,6 @@ class ThemePickerActivity : QkThemedActivity(), ThemePickerView {
|
||||
|
||||
materialColors.layoutManager = LinearLayoutManager(this)
|
||||
materialColors.adapter = themeAdapter
|
||||
|
||||
colors.background
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> window.decorView.setBackgroundColor(color) }
|
||||
|
||||
colors.textSecondary
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> clear.setTint(color) }
|
||||
}
|
||||
|
||||
override fun showQksmsPlusSnackbar() {
|
||||
@@ -88,8 +77,6 @@ class ThemePickerActivity : QkThemedActivity(), ThemePickerView {
|
||||
override fun render(state: ThemePickerState) {
|
||||
tabs.setThreadId(state.threadId)
|
||||
|
||||
themeAdapter.threadId = state.threadId
|
||||
|
||||
hex.setText(Integer.toHexString(state.newColor).takeLast(6))
|
||||
|
||||
applyGroup.setVisible(state.applyThemeVisible)
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package feature.themepicker
|
||||
|
||||
import android.arch.lifecycle.ViewModel
|
||||
import android.content.Intent
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.multibindings.IntoMap
|
||||
import injection.ViewModelKey
|
||||
import javax.inject.Named
|
||||
|
||||
@Module
|
||||
class ThemePickerActivityModule {
|
||||
|
||||
@Provides
|
||||
fun provideIntent(activity: ThemePickerActivity): Intent = activity.intent
|
||||
@Named("threadId")
|
||||
fun provideThreadId(activity: ThemePickerActivity): Long = activity.intent.extras?.getLong("threadId") ?: 0L
|
||||
|
||||
@Provides
|
||||
@IntoMap
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package feature.themepicker
|
||||
|
||||
import android.content.Intent
|
||||
import com.f2prateek.rx.preferences2.Preference
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
@@ -30,23 +29,17 @@ import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.rxkotlin.withLatestFrom
|
||||
import util.Preferences
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Named
|
||||
|
||||
class ThemePickerViewModel @Inject constructor(
|
||||
private val intent: Intent,
|
||||
@Named("threadId") threadId: Long,
|
||||
private val billingManager: BillingManager,
|
||||
private val colors: Colors,
|
||||
private val navigator: Navigator,
|
||||
private val prefs: Preferences
|
||||
) : QkViewModel<ThemePickerView, ThemePickerState>(ThemePickerState()) {
|
||||
) : QkViewModel<ThemePickerView, ThemePickerState>(ThemePickerState(threadId = threadId)) {
|
||||
|
||||
private val threadId = intent.extras?.getLong("threadId") ?: 0L
|
||||
private val theme: Preference<Int>
|
||||
|
||||
init {
|
||||
newState { it.copy(threadId = threadId) }
|
||||
|
||||
theme = prefs.theme(threadId)
|
||||
}
|
||||
private val theme: Preference<Int> = prefs.theme(threadId)
|
||||
|
||||
override fun bindView(view: ThemePickerView) {
|
||||
super.bindView(view)
|
||||
@@ -63,7 +56,7 @@ class ThemePickerViewModel @Inject constructor(
|
||||
// Update the color of the apply button
|
||||
view.hsvThemeSelectedIntent
|
||||
.doOnNext { color -> newState { it.copy(newColor = color) } }
|
||||
.switchMap { color -> colors.textPrimaryOnThemeForColor(color) }
|
||||
.map { color -> colors.textPrimaryOnThemeForColor(color) }
|
||||
.doOnNext { color -> newState { it.copy(newTextColor = color) } }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
@@ -35,12 +35,14 @@ import common.util.Colors
|
||||
import common.util.DateFormatter
|
||||
import common.util.GlideApp
|
||||
import common.util.extensions.dpToPx
|
||||
import common.util.extensions.getColorCompat
|
||||
import feature.main.MainActivity
|
||||
import injection.appComponent
|
||||
import model.Contact
|
||||
import model.Conversation
|
||||
import model.PhoneNumber
|
||||
import repository.MessageRepository
|
||||
import util.Preferences
|
||||
import javax.inject.Inject
|
||||
|
||||
class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
@@ -53,6 +55,7 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
@Inject lateinit var colors: Colors
|
||||
@Inject lateinit var dateFormatter: DateFormatter
|
||||
@Inject lateinit var messageRepo: MessageRepository
|
||||
@Inject lateinit var prefs: Preferences
|
||||
|
||||
private val appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID)
|
||||
private val smallWidget = intent.getBooleanExtra("small_widget", false)
|
||||
@@ -61,12 +64,19 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
|
||||
// Cache colors, load lazily. This entire class is recreated when the widget is recreated,
|
||||
// so if the theme changes then these values will be correct in the new instance
|
||||
private val theme by lazy { colors.theme.blockingFirst() }
|
||||
private val background by lazy { colors.background.blockingFirst() }
|
||||
private val textPrimary by lazy { colors.textPrimary.blockingFirst() }
|
||||
private val textSecondary by lazy { colors.textSecondary.blockingFirst() }
|
||||
private val textTertiary by lazy { colors.textTertiary.blockingFirst() }
|
||||
private val textPrimaryOnTheme by lazy { colors.textPrimaryOnTheme.blockingFirst() }
|
||||
private val night by lazy { prefs.night.get() }
|
||||
private val black by lazy { prefs.black.get() }
|
||||
private val theme by lazy { colors.theme() }
|
||||
private val background by lazy {
|
||||
context.getColorCompat(when {
|
||||
night && black -> R.color.black
|
||||
night && !black -> R.color.backgroundDark
|
||||
else -> R.color.white
|
||||
})
|
||||
}
|
||||
private val textPrimary by lazy { context.getColorCompat(if (night) R.color.textPrimaryDark else R.color.textPrimary) }
|
||||
private val textSecondary by lazy { context.getColorCompat(if (night) R.color.textSecondaryDark else R.color.textSecondary) }
|
||||
private val textTertiary by lazy { context.getColorCompat(if (night) R.color.textTertiaryDark else R.color.textTertiary) }
|
||||
|
||||
override fun onCreate() {
|
||||
appComponent.inject(this)
|
||||
@@ -103,9 +113,9 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
|
||||
// Avatar
|
||||
remoteViews.setViewVisibility(R.id.avatar, if (smallWidget) View.GONE else View.VISIBLE)
|
||||
remoteViews.setInt(R.id.avatar, "setBackgroundColor", theme)
|
||||
remoteViews.setTextColor(R.id.initial, textPrimaryOnTheme)
|
||||
remoteViews.setInt(R.id.icon, "setColorFilter", textPrimaryOnTheme)
|
||||
remoteViews.setInt(R.id.avatar, "setBackgroundColor", theme.theme)
|
||||
remoteViews.setTextColor(R.id.initial, theme.textPrimary)
|
||||
remoteViews.setInt(R.id.icon, "setColorFilter", theme.textPrimary)
|
||||
remoteViews.setInt(R.id.avatarMask, "setColorFilter", background)
|
||||
|
||||
val contact = conversation.recipients.map { recipient ->
|
||||
|
||||
@@ -30,16 +30,19 @@ import android.os.Bundle
|
||||
import android.widget.RemoteViews
|
||||
import com.moez.QKSMS.R
|
||||
import common.util.Colors
|
||||
import common.util.extensions.getColorCompat
|
||||
import feature.compose.ComposeActivity
|
||||
import feature.main.MainActivity
|
||||
import injection.appComponent
|
||||
import manager.WidgetManager
|
||||
import timber.log.Timber
|
||||
import util.Preferences
|
||||
import javax.inject.Inject
|
||||
|
||||
class WidgetProvider : AppWidgetProvider() {
|
||||
|
||||
@Inject lateinit var colors: Colors
|
||||
@Inject lateinit var prefs: Preferences
|
||||
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
@@ -107,10 +110,27 @@ class WidgetProvider : AppWidgetProvider() {
|
||||
val remoteViews = RemoteViews(context.packageName, R.layout.widget)
|
||||
|
||||
// Apply colors from theme
|
||||
remoteViews.setInt(R.id.background, "setColorFilter", colors.background.blockingFirst())
|
||||
remoteViews.setInt(R.id.toolbar, "setColorFilter", colors.toolbarColor.blockingFirst())
|
||||
remoteViews.setTextColor(R.id.title, colors.textPrimary.blockingFirst())
|
||||
remoteViews.setInt(R.id.compose, "setColorFilter", colors.theme.blockingFirst())
|
||||
val night = prefs.night.get()
|
||||
val black = prefs.black.get()
|
||||
|
||||
remoteViews.setInt(R.id.background, "setColorFilter", context.getColorCompat(when {
|
||||
night && black -> R.color.black
|
||||
night && !black -> R.color.backgroundDark
|
||||
else -> R.color.white
|
||||
}))
|
||||
|
||||
remoteViews.setInt(R.id.toolbar, "setColorFilter", context.getColorCompat(when {
|
||||
night && black -> R.color.black
|
||||
night && !black -> R.color.toolbarDark
|
||||
else -> R.color.toolbarLight
|
||||
}))
|
||||
|
||||
remoteViews.setTextColor(R.id.title, context.getColorCompat(when (night) {
|
||||
true -> R.color.textPrimaryDark
|
||||
false -> R.color.textPrimary
|
||||
}))
|
||||
|
||||
remoteViews.setInt(R.id.compose, "setColorFilter", colors.theme().theme)
|
||||
|
||||
// Set adapter for conversations
|
||||
val intent = Intent(context, WidgetService::class.java)
|
||||
|
||||
@@ -27,7 +27,6 @@ import common.widget.PreferenceView
|
||||
import common.widget.QkEditText
|
||||
import common.widget.QkSwitch
|
||||
import common.widget.QkTextView
|
||||
import common.widget.Separator
|
||||
import dagger.Component
|
||||
import dagger.android.support.AndroidSupportInjectionModule
|
||||
import feature.compose.DetailedChipView
|
||||
@@ -84,6 +83,5 @@ interface AppComponent {
|
||||
fun inject(view: QkEditText)
|
||||
fun inject(view: QkSwitch)
|
||||
fun inject(view: QkTextView)
|
||||
fun inject(view: Separator)
|
||||
|
||||
}
|
||||
@@ -18,22 +18,70 @@
|
||||
*/
|
||||
package receiver
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.ContentUris
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import com.klinker.android.send_message.MmsSentReceiver
|
||||
import android.provider.Telephony
|
||||
import com.google.android.mms.MmsException
|
||||
import com.google.android.mms.util_alt.SqliteWrapper
|
||||
import com.klinker.android.send_message.Transaction
|
||||
import injection.appComponent
|
||||
import interactor.SyncMessage
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
class MmsSentReceiver : MmsSentReceiver() {
|
||||
class MmsSentReceiver : BroadcastReceiver() {
|
||||
|
||||
@Inject lateinit var syncMessage: SyncMessage
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
super.onReceive(context, intent)
|
||||
appComponent.inject(this)
|
||||
|
||||
Timber.v("MMS sending result: $resultCode")
|
||||
val uri = Uri.parse(intent.getStringExtra(Transaction.EXTRA_CONTENT_URI))
|
||||
Timber.v(uri.toString())
|
||||
|
||||
when (resultCode) {
|
||||
Activity.RESULT_OK -> {
|
||||
Timber.v("MMS has finished sending, marking it as so in the database")
|
||||
val values = ContentValues(1)
|
||||
values.put(Telephony.Mms.MESSAGE_BOX, Telephony.Mms.MESSAGE_BOX_SENT)
|
||||
SqliteWrapper.update(context, context.contentResolver, uri, values, null, null)
|
||||
}
|
||||
|
||||
else -> {
|
||||
Timber.v("MMS has failed to send, marking it as so in the database")
|
||||
try {
|
||||
val messageId = ContentUris.parseId(uri)
|
||||
|
||||
val values = ContentValues(1)
|
||||
values.put(Telephony.Mms.MESSAGE_BOX, Telephony.Mms.MESSAGE_BOX_FAILED)
|
||||
SqliteWrapper.update(context, context.contentResolver, Telephony.Mms.CONTENT_URI, values,
|
||||
"${Telephony.Mms._ID} = ?", arrayOf(messageId.toString()))
|
||||
|
||||
// TODO this query isn't able to find any results
|
||||
// Need to figure out why the message isn't appearing in the PendingMessages Uri,
|
||||
// so that we can properly assign the error type
|
||||
val errorTypeValues = ContentValues(1)
|
||||
errorTypeValues.put(Telephony.MmsSms.PendingMessages.ERROR_TYPE, Telephony.MmsSms.ERR_TYPE_GENERIC_PERMANENT)
|
||||
SqliteWrapper.update(context, context.contentResolver, Telephony.MmsSms.PendingMessages.CONTENT_URI,
|
||||
errorTypeValues, "${Telephony.MmsSms.PendingMessages.MSG_ID} = ?", arrayOf(messageId.toString()))
|
||||
|
||||
} catch (e: MmsException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val filePath = intent.getStringExtra(Transaction.EXTRA_FILE_PATH)
|
||||
Timber.v(filePath)
|
||||
File(filePath).delete()
|
||||
|
||||
Uri.parse(intent.getStringExtra("content_uri"))?.let { uri ->
|
||||
val pendingResult = goAsync()
|
||||
syncMessage.execute(uri) { pendingResult.finish() }
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 428 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
@@ -26,8 +26,7 @@
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/Toolbar"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:background="@color/white">
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<common.widget.QkTextView
|
||||
android:id="@+id/toolbarTitle"
|
||||
@@ -110,10 +109,11 @@
|
||||
android:background="@drawable/ab_shadow"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="?android:attr/divider"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -47,8 +47,9 @@
|
||||
android:layout_gravity="top|end"
|
||||
android:layout_margin="2dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="?attr/bubbleColor"
|
||||
android:src="@drawable/ic_cancel_black_24dp"
|
||||
android:tint="@color/textSecondary"
|
||||
android:tint="?android:attr/textColorSecondary"
|
||||
tools:backgroundTint="@color/backgroundLight" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -65,9 +65,10 @@
|
||||
app:title="@string/settings_should_i_answer_title"
|
||||
app:widget="@layout/settings_switch_widget" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp" />
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/divider" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/conversations"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="16dp"
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
android:imeOptions="flagNoExtractUi"
|
||||
android:inputType="textFilter|textNoSuggestions"
|
||||
android:privateImeOptions="nm"
|
||||
android:textColorHint="?android:attr/textColorTertiary"
|
||||
app:textColor="primary"
|
||||
app:textColorHint="tertiary"
|
||||
app:textSize="primary" />
|
||||
@@ -22,8 +22,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
android:orientation="vertical"
|
||||
tools:background="@color/backgroundLight">
|
||||
android:background="?attr/composeBackground"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/messageList"
|
||||
@@ -57,6 +57,7 @@
|
||||
android:id="@+id/contacts"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="?android:attr/windowBackground"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="8dp"
|
||||
@@ -81,16 +82,17 @@
|
||||
android:layout_height="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/compose_bar_background"
|
||||
android:backgroundTint="?attr/composeBackground"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/messageBackground"
|
||||
tools:backgroundTint="@color/backgroundLight" />
|
||||
app:layout_constraintTop_toTopOf="@id/messageBackground" />
|
||||
|
||||
<View
|
||||
android:id="@+id/messageBackground"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="@drawable/rounded_rectangle_shadow"
|
||||
android:backgroundTint="?attr/bubbleColor"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/send"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -123,43 +125,44 @@
|
||||
android:contentDescription="@string/compose_attach_cd"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_add_circle_black_24dp"
|
||||
android:tint="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toBottomOf="@id/message"
|
||||
app:layout_constraintStart_toStartOf="@id/messageBackground"
|
||||
tools:tint="@color/textSecondary" />
|
||||
app:layout_constraintStart_toStartOf="@id/messageBackground" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/camera"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:background="@drawable/ripple"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:contentDescription="@string/compose_camera_cd"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_camera_alt_black_24dp"
|
||||
android:tint="?android:attr/textColorSecondary"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@id/message"
|
||||
app:layout_constraintStart_toEndOf="@id/attach"
|
||||
tools:tint="@color/textSecondary" />
|
||||
app:layout_constraintStart_toEndOf="@id/attach" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/gallery"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@drawable/ripple"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:contentDescription="@string/compose_gallery_cd"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_insert_photo_black_24dp"
|
||||
android:tint="?android:attr/textColorSecondary"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@id/message"
|
||||
app:layout_constraintStart_toEndOf="@id/camera"
|
||||
tools:tint="@color/textSecondary" />
|
||||
app:layout_constraintStart_toEndOf="@id/camera" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:id="@+id/attachSeparator"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="?android:attr/divider"
|
||||
app:layout_constraintBottom_toBottomOf="@id/message"
|
||||
app:layout_constraintStart_toEndOf="@id/gallery"
|
||||
app:layout_constraintTop_toBottomOf="@id/attachments" />
|
||||
@@ -179,10 +182,10 @@
|
||||
android:maxLines="6"
|
||||
android:minHeight="44dp"
|
||||
android:padding="12dp"
|
||||
android:textColorHint="?android:attr/textColorTertiary"
|
||||
app:layout_constraintBottom_toBottomOf="@id/messageBackground"
|
||||
app:layout_constraintEnd_toEndOf="@id/messageBackground"
|
||||
app:layout_constraintStart_toEndOf="@id/attachSeparator"
|
||||
app:textColorHint="tertiary" />
|
||||
app:layout_constraintStart_toEndOf="@id/attachSeparator" />
|
||||
|
||||
<common.widget.QkTextView
|
||||
android:id="@+id/counter"
|
||||
@@ -221,8 +224,7 @@
|
||||
android:gravity="center_vertical"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:background="@color/toolbarLight">
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -264,9 +266,10 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/divider"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -30,6 +30,7 @@
|
||||
android:layout_height="36dp"
|
||||
android:layout_margin="4dp"
|
||||
android:background="@drawable/chip_background"
|
||||
android:backgroundTint="?attr/composeBackground"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<common.widget.AvatarView
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
android:id="@+id/delete"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:background="@drawable/ripple"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_cancel_black_24dp"
|
||||
android:tint="@color/white" />
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
android:id="@+id/primary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple">
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<common.widget.QkTextView
|
||||
android:id="@+id/address"
|
||||
|
||||
@@ -55,10 +55,11 @@
|
||||
tools:layout_height="72dp"
|
||||
tools:listitem="@layout/conversation_recipient_list_item" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="8dp" />
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="?android:attr/divider" />
|
||||
|
||||
<common.widget.PreferenceView
|
||||
android:id="@+id/notifications"
|
||||
@@ -95,11 +96,12 @@
|
||||
app:icon="@drawable/ic_delete_black_24dp"
|
||||
app:title="@string/info_delete" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginTop="8dp" />
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="?android:attr/divider" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/media"
|
||||
@@ -122,9 +124,10 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/divider"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -22,7 +22,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="12dp"
|
||||
|
||||
@@ -22,5 +22,6 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/divider"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@tools:sample/backgrounds/scenic" />
|
||||
@@ -22,7 +22,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="24dp"
|
||||
@@ -64,9 +64,9 @@
|
||||
android:layout_height="40dp"
|
||||
android:padding="8dp"
|
||||
android:src="@drawable/ic_person_add_black_24dp"
|
||||
android:tint="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:tint="@color/textSecondary" />
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -22,9 +22,9 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:attr/windowBackground"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="8dp"
|
||||
tools:background="@color/white">
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/inbox"
|
||||
@@ -50,7 +50,7 @@
|
||||
android:id="@+id/archivedIcon"
|
||||
style="@style/DrawerIcon"
|
||||
android:src="@drawable/ic_archive_black_24dp"
|
||||
tools:tint="@color/textSecondary" />
|
||||
tools:tint="?android:attr/textColorSecondary" />
|
||||
|
||||
<common.widget.QkTextView
|
||||
style="@style/DrawerText"
|
||||
@@ -67,7 +67,7 @@
|
||||
android:id="@+id/scheduledIcon"
|
||||
style="@style/DrawerIcon"
|
||||
android:src="@drawable/ic_event_black_24dp"
|
||||
tools:tint="@color/textSecondary" />
|
||||
tools:tint="?android:attr/textColorSecondary" />
|
||||
|
||||
<common.widget.QkTextView
|
||||
style="@style/DrawerText"
|
||||
@@ -75,10 +75,11 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="8dp" />
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="?android:attr/divider" />
|
||||
|
||||
<common.widget.QkTextView
|
||||
style="@style/TextSecondary"
|
||||
@@ -95,7 +96,7 @@
|
||||
android:id="@+id/settingsIcon"
|
||||
style="@style/DrawerIcon"
|
||||
android:src="@drawable/ic_settings_black_24dp"
|
||||
tools:tint="@color/textSecondary" />
|
||||
tools:tint="?android:attr/textColorSecondary" />
|
||||
|
||||
<common.widget.QkTextView
|
||||
style="@style/DrawerText"
|
||||
@@ -111,7 +112,7 @@
|
||||
android:id="@+id/plusIcon"
|
||||
style="@style/DrawerIcon"
|
||||
android:src="@drawable/ic_star_black_24dp"
|
||||
tools:tint="@color/textSecondary" />
|
||||
tools:tint="?android:attr/textColorSecondary" />
|
||||
|
||||
<common.widget.QkTextView
|
||||
style="@style/DrawerText"
|
||||
@@ -127,7 +128,7 @@
|
||||
android:id="@+id/helpIcon"
|
||||
style="@style/DrawerIcon"
|
||||
android:src="@drawable/ic_help_black_24dp"
|
||||
tools:tint="@color/textSecondary" />
|
||||
tools:tint="?android:attr/textColorSecondary" />
|
||||
|
||||
<common.widget.QkTextView
|
||||
style="@style/DrawerText"
|
||||
@@ -146,7 +147,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:background="@drawable/rounded_rectangle_outline_2dp"
|
||||
android:backgroundTint="@color/separatorLight">
|
||||
android:backgroundTint="?android:attr/divider">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/rateIcon"
|
||||
@@ -206,10 +207,10 @@
|
||||
android:id="@+id/rateOkay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/ripple"
|
||||
android:padding="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:padding="16dp"
|
||||
android:text="@string/rate_okay"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:background="@color/white">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -38,8 +37,7 @@
|
||||
android:focusableInTouchMode="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:background="@color/white">
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<common.widget.QkTextView
|
||||
android:id="@+id/toolbarTitle"
|
||||
@@ -49,7 +47,7 @@
|
||||
android:id="@+id/toolbarSearch"
|
||||
style="@style/ToolbarText"
|
||||
android:hint="@string/title_conversations"
|
||||
app:textColorHint="tertiary"
|
||||
android:textColorHint="?android:attr/textColorTertiary"
|
||||
app:textSize="primary"
|
||||
tools:textSize="16sp" />
|
||||
|
||||
@@ -102,10 +100,11 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:id="@+id/bottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/divider"
|
||||
app:layout_constraintBottom_toTopOf="@id/bottomDivider" />
|
||||
|
||||
<android.support.constraint.Barrier
|
||||
@@ -165,7 +164,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@drawable/ripple"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:padding="16dp"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/tools_theme"
|
||||
@@ -207,7 +206,6 @@
|
||||
layout="@layout/drawer_view"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:background="@color/white" />
|
||||
android:layout_gravity="start" />
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
@@ -20,7 +20,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:src="@drawable/radio_button"
|
||||
tools:tint="@color/textTertiary" />
|
||||
tools:tint="?android:attr/textColorTertiary" />
|
||||
|
||||
<common.widget.QkTextView
|
||||
android:id="@+id/title"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple">
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<common.widget.QkTextView
|
||||
android:id="@+id/timestamp"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple">
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<common.widget.QkTextView
|
||||
android:id="@+id/timestamp"
|
||||
@@ -61,6 +61,7 @@
|
||||
android:layout_marginTop="2dp"
|
||||
android:autoLink="all"
|
||||
android:background="@drawable/message_only"
|
||||
android:backgroundTint="?attr/bubbleColor"
|
||||
android:gravity="start|center_vertical"
|
||||
android:minHeight="36dp"
|
||||
android:paddingBottom="8dp"
|
||||
@@ -82,8 +83,9 @@
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="?attr/bubbleColor"
|
||||
android:elevation="4dp"
|
||||
android:foreground="@drawable/ripple"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
android:indeterminate="false"
|
||||
android:progressDrawable="@drawable/circular_progress_bar"
|
||||
app:layout_constraintBottom_toBottomOf="@id/body"
|
||||
|
||||
@@ -26,8 +26,7 @@
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/Toolbar"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:background="@color/white">
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<common.widget.QkTextView
|
||||
android:id="@+id/toolbarTitle"
|
||||
@@ -87,11 +86,12 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:title="@string/settings_ringtone_title" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp" />
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="?android:attr/divider" />
|
||||
|
||||
<common.widget.QkTextView
|
||||
style="@style/PreferenceCategory"
|
||||
@@ -124,10 +124,11 @@
|
||||
android:background="@drawable/ab_shadow"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="?android:attr/divider"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -21,6 +21,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
tools:parentTag="common.widget.PreferenceView">
|
||||
|
||||
<ImageView
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="24dp"
|
||||
android:background="@drawable/rounded_rectangle_4dp"
|
||||
android:backgroundTint="?attr/composeBackground"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:elevation="8dp"
|
||||
android:maxHeight="320dp"
|
||||
android:maxWidth="320dp"
|
||||
tools:backgroundTint="@color/backgroundLight"
|
||||
tools:context="feature.qkreply.QkReplyActivity">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
@@ -53,21 +53,21 @@
|
||||
android:layout_height="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/compose_bar_background"
|
||||
android:backgroundTint="?attr/composeBackground"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/message"
|
||||
tools:backgroundTint="@color/backgroundLight" />
|
||||
app:layout_constraintTop_toTopOf="@id/message" />
|
||||
|
||||
<View
|
||||
android:id="@+id/composeBackground"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="@drawable/rounded_rectangle_bottom_4dp"
|
||||
android:backgroundTint="?attr/composeBackground"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/composeBackgroundGradient"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
tools:backgroundTint="@color/backgroundLight" />
|
||||
app:layout_constraintTop_toBottomOf="@id/composeBackgroundGradient" />
|
||||
|
||||
<common.widget.QkEditText
|
||||
android:id="@+id/message"
|
||||
@@ -76,6 +76,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/rounded_rectangle_shadow"
|
||||
android:backgroundTint="?attr/bubbleColor"
|
||||
android:backgroundTintMode="multiply"
|
||||
android:gravity="center_vertical"
|
||||
android:hint="@string/compose_hint"
|
||||
@@ -83,12 +84,12 @@
|
||||
android:maxLines="6"
|
||||
android:minHeight="44dp"
|
||||
android:padding="20dp"
|
||||
android:textColorHint="?android:attr/textColorTertiary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@id/messageBackground"
|
||||
app:layout_constraintEnd_toStartOf="@id/send"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/messages"
|
||||
app:textColorHint="tertiary" />
|
||||
app:layout_constraintTop_toBottomOf="@id/messages" />
|
||||
|
||||
<common.widget.QkTextView
|
||||
android:id="@+id/counter"
|
||||
@@ -122,6 +123,7 @@
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/Toolbar"
|
||||
android:background="@drawable/rounded_rectangle_top_4dp"
|
||||
android:backgroundTint="?attr/colorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:background="@color/white">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -96,6 +95,7 @@
|
||||
style="@style/TextButton"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/rounded_rectangle_outline_2dp"
|
||||
android:backgroundTint="?android:attr/divider"
|
||||
android:text="@string/qksms_plus_upgrade_donate"
|
||||
app:textColor="primary"
|
||||
tools:backgroundTint="@color/separatorLight" />
|
||||
@@ -110,6 +110,7 @@
|
||||
android:layout_marginEnd="24dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:background="@drawable/rounded_rectangle_2dp"
|
||||
android:backgroundTint="?android:attr/divider"
|
||||
android:padding="16dp"
|
||||
tools:backgroundTint="@color/separatorLight">
|
||||
|
||||
@@ -173,10 +174,11 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="8dp" />
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="?android:attr/divider" />
|
||||
|
||||
<common.widget.PreferenceView
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
@@ -32,11 +32,12 @@
|
||||
android:visibility="gone"
|
||||
app:constraint_referenced_ids="resultsSeparator, resultsTitle" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:id="@+id/resultsSeparator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="?android:attr/divider"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<common.widget.QkTextView
|
||||
|
||||
@@ -29,8 +29,7 @@
|
||||
style="@style/Toolbar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:background="@color/white">
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<common.widget.QkTextView
|
||||
android:id="@+id/toolbarTitle"
|
||||
@@ -115,11 +114,12 @@
|
||||
app:title="@string/settings_system_font_title"
|
||||
app:widget="@layout/settings_switch_widget" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp" />
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="?android:attr/divider" />
|
||||
|
||||
<common.widget.QkTextView
|
||||
style="@style/PreferenceCategory"
|
||||
@@ -152,8 +152,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:icon="@drawable/ic_av_timer_black_24dp"
|
||||
tools:summary="No delay"
|
||||
app:title="@string/settings_delayed_title" />
|
||||
app:title="@string/settings_delayed_title"
|
||||
tools:summary="No delay" />
|
||||
|
||||
<common.widget.PreferenceView
|
||||
android:id="@+id/delivery"
|
||||
@@ -182,11 +182,12 @@
|
||||
app:title="@string/settings_mms_size_title"
|
||||
tools:summary="100KB" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp" />
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="?android:attr/divider" />
|
||||
|
||||
<common.widget.PreferenceView
|
||||
android:id="@+id/sync"
|
||||
@@ -216,9 +217,10 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/divider"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -22,7 +22,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/ripple"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
android:gravity="center"
|
||||
android:paddingEnd="12dp"
|
||||
|
||||
@@ -28,8 +28,9 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp" />
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/divider" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -30,6 +30,7 @@
|
||||
android:id="@+id/tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:orientation="horizontal"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingStart="12dp" />
|
||||
@@ -62,10 +63,11 @@
|
||||
android:layout_height="8dp"
|
||||
android:background="@drawable/ab_shadow" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="bottom" />
|
||||
android:layout_gravity="bottom"
|
||||
android:background="?android:attr/divider" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
tools:background="@color/white">
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<feature.themepicker.HSVPickerView
|
||||
android:id="@+id/picker"
|
||||
@@ -30,11 +29,12 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/picker" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:id="@+id/hexSeparator"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:background="?android:attr/divider"
|
||||
app:layout_constraintBottom_toBottomOf="@id/hexLabel"
|
||||
app:layout_constraintStart_toEndOf="@id/hexLabel"
|
||||
app:layout_constraintTop_toTopOf="@id/hexLabel" />
|
||||
@@ -76,22 +76,23 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:constraint_referenced_ids="applyDivider, clear, apply" />
|
||||
|
||||
<common.widget.Separator
|
||||
<View
|
||||
android:id="@+id/applyDivider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/divider"
|
||||
app:layout_constraintBottom_toTopOf="@id/clear" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/clear"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:background="@drawable/ripple"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_cancel_black_24dp"
|
||||
android:tint="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:tint="@color/textSecondary" />
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<common.widget.QkTextView
|
||||
android:id="@+id/apply"
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
<android.support.v7.widget.Toolbar android:id="@+id/toolbar"
|
||||
style="@style/Toolbar"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:background="@color/white">
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<common.widget.QkTextView
|
||||
android:id="@+id/toolbarTitle"
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_person_black_24dp"
|
||||
tools:tint="@color/white" />
|
||||
tools:tint="@color/textPrimaryDark" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/photo"
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="14sp"
|
||||
tools:text="Loading..." />
|
||||
|
||||
|
||||
@@ -44,11 +44,6 @@
|
||||
<declare-styleable name="QkEditText">
|
||||
<attr name="textColor" />
|
||||
<attr name="textSize" />
|
||||
<attr name="textColorHint" format="enum">
|
||||
<enum name="primary" value="0" />
|
||||
<enum name="secondary" value="1" />
|
||||
<enum name="tertiary" value="2" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="PreferenceView">
|
||||
|
||||
@@ -34,9 +34,6 @@
|
||||
<color name="backgroundLight">#ECEFF1</color>
|
||||
<color name="backgroundDark">#192025</color>
|
||||
|
||||
<color name="fieldLight">#0C000000</color>
|
||||
<color name="fieldDark">#0CFFFFFF</color>
|
||||
|
||||
<color name="textPrimary">#49555F</color>
|
||||
<color name="textSecondary">#70808D</color>
|
||||
<color name="textTertiary">#B7B9C0</color>
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
<string name="settings_notification_previews_title">Notification previews</string>
|
||||
<string name="settings_vibration_title">Vibration</string>
|
||||
<string name="settings_ringtone_title">Sound</string>
|
||||
<string name="settings_ringtone_none">None</string>
|
||||
<string name="settings_qkreply_title">QK Reply</string>
|
||||
<string name="settings_qkreply_summary">Popup for new messages</string>
|
||||
<string name="settings_qkreply_tap_dismiss_title">Tap to dismiss</string>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
<!-- This needs to be set so that we can tint the toolbar and not change the background
|
||||
resource. This is mainly so that QkReplyActivity can call setClipToOutline -->
|
||||
<item name="android:background">@color/black</item>
|
||||
<item name="android:background">?attr/colorPrimary</item>
|
||||
<item name="android:gravity">center_vertical</item>
|
||||
</style>
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
<style name="DrawerRow">
|
||||
<item name="android:layout_height">48dp</item>
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:background">@drawable/ripple</item>
|
||||
<item name="android:background">?attr/selectableItemBackground</item>
|
||||
<item name="android:gravity">center_vertical</item>
|
||||
<item name="android:paddingStart">16dp</item>
|
||||
<item name="android:paddingEnd">16dp</item>
|
||||
@@ -110,19 +110,4 @@
|
||||
<item name="android:layout_marginEnd">32dp</item>
|
||||
</style>
|
||||
|
||||
<style name="PopupThemeDark" parent="ThemeOverlay.AppCompat">
|
||||
<item name="android:colorBackground">@color/backgroundDark</item>
|
||||
<item name="android:textColor">@color/textPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<style name="PopupThemeBlack" parent="ThemeOverlay.AppCompat">
|
||||
<item name="android:colorBackground">@color/black</item>
|
||||
<item name="android:textColor">@color/textPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<style name="PopupThemeLight" parent="ThemeOverlay.AppCompat.Light">
|
||||
<item name="android:colorBackground">@color/white</item>
|
||||
<item name="android:textColor">@color/textPrimary</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -1,54 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<attr name="bubbleColor" format="reference" />
|
||||
<attr name="composeBackground" format="reference" />
|
||||
|
||||
<style name="AppThemeLight" parent="AppBaseThemeLight" />
|
||||
|
||||
<style name="AppBaseThemeLight" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Light theme -->
|
||||
<style name="AppBaseThemeLight" parent="Theme.AppCompat.Light.NoActionBar">item>
|
||||
<item name="android:divider">@color/separatorLight</item>
|
||||
<item name="android:statusBarColor">@color/black</item>
|
||||
<item name="android:windowBackground">@color/backgroundLight</item>
|
||||
<item name="android:textColorPrimary">@color/textPrimary</item>
|
||||
<item name="android:textColorSecondary">@color/textSecondary</item>
|
||||
<item name="android:textColorTertiary">@color/textTertiary</item>
|
||||
<item name="android:windowBackground">@color/white</item>
|
||||
<item name="android:windowContentTransitions">true</item>
|
||||
<item name="actionBarPopupTheme">@style/PopupThemeLight</item>
|
||||
<item name="colorPrimary">@color/white</item>
|
||||
<item name="bubbleColor">@color/bubbleLight</item>
|
||||
<item name="colorPrimary">@color/toolbarLight</item>
|
||||
<item name="colorPrimaryDark">@color/statusBarLight</item>
|
||||
<item name="composeBackground">@color/backgroundLight</item>
|
||||
<item name="selectableItemBackground">@drawable/ripple</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
</style>
|
||||
|
||||
<style name="AppThemeLightDialog" parent="Theme.AppCompat.Light.Dialog">
|
||||
<item name="android:textColorPrimary">@color/textPrimary</item>
|
||||
<item name="android:textColorSecondary">@color/textSecondary</item>
|
||||
<item name="android:textColorTertiary">@color/textTertiary</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<item name="actionBarPopupTheme">@style/PopupThemeLight</item>
|
||||
<item name="bubbleColor">@color/bubbleLight</item>
|
||||
<item name="colorPrimary">@color/toolbarLight</item>
|
||||
<item name="colorPrimaryDark">@color/statusBarLight</item>
|
||||
<item name="composeBackground">@color/backgroundLight</item>
|
||||
<item name="selectableItemBackground">@drawable/ripple</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
</style>
|
||||
|
||||
<style name="PopupThemeLight" parent="ThemeOverlay.AppCompat.Light">
|
||||
<item name="android:colorBackground">@color/white</item>
|
||||
<item name="android:textColor">@color/textPrimary</item>
|
||||
</style>
|
||||
|
||||
<!-- Dark theme -->
|
||||
<style name="AppThemeDark" parent="Theme.AppCompat.NoActionBar">
|
||||
<item name="android:divider">@color/separatorDark</item>
|
||||
<item name="android:navigationBarColor">@color/backgroundDark</item>
|
||||
<item name="android:statusBarColor">@color/statusBarDark</item>
|
||||
<item name="android:textColorPrimary">@color/textPrimaryDark</item>
|
||||
<item name="android:textColorSecondary">@color/textSecondaryDark</item>
|
||||
<item name="android:textColorTertiary">@color/textTertiaryDark</item>
|
||||
<item name="android:windowBackground">@color/backgroundDark</item>
|
||||
<item name="android:windowContentTransitions">true</item>
|
||||
<item name="actionBarPopupTheme">@style/PopupThemeDark</item>
|
||||
<item name="colorPrimary">@color/backgroundDark</item>
|
||||
<item name="bubbleColor">@color/bubbleDark</item>
|
||||
<item name="colorPrimary">@color/toolbarDark</item>
|
||||
<item name="colorPrimaryDark">@color/statusBarDark</item>
|
||||
<item name="composeBackground">@color/backgroundDark</item>
|
||||
<item name="selectableItemBackground">@drawable/ripple_dark</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
</style>
|
||||
|
||||
<style name="AppThemeDarkDialog" parent="Theme.AppCompat.Dialog">
|
||||
<item name="android:textColorPrimary">@color/textPrimaryDark</item>
|
||||
<item name="android:textColorSecondary">@color/textSecondaryDark</item>
|
||||
<item name="android:textColorTertiary">@color/textTertiaryDark</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<item name="actionBarPopupTheme">@style/PopupThemeDark</item>
|
||||
<item name="bubbleColor">@color/bubbleDark</item>
|
||||
<item name="colorPrimary">@color/toolbarDark</item>
|
||||
<item name="colorPrimaryDark">@color/statusBarDark</item>
|
||||
<item name="composeBackground">@color/backgroundDark</item>
|
||||
<item name="selectableItemBackground">@drawable/ripple_dark</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
</style>
|
||||
|
||||
<style name="AppThemeBlack" parent="Theme.AppCompat.NoActionBar">
|
||||
<style name="PopupThemeDark" parent="ThemeOverlay.AppCompat">
|
||||
<item name="android:colorBackground">@color/backgroundDark</item>
|
||||
<item name="android:textColor">@color/textPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<!-- Black theme -->
|
||||
<style name="AppThemeBlack" parent="AppThemeDark">
|
||||
<item name="android:navigationBarColor">@color/black</item>
|
||||
<item name="android:statusBarColor">@color/black</item>
|
||||
<item name="android:windowBackground">@color/black</item>
|
||||
<item name="android:windowContentTransitions">true</item>
|
||||
<item name="actionBarPopupTheme">@style/PopupThemeDark</item>
|
||||
<item name="colorPrimary">@color/black</item>
|
||||
<item name="colorPrimaryDark">@color/black</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="composeBackground">@color/black</item>
|
||||
</style>
|
||||
|
||||
<style name="AppThemeBlackDialog" parent="Theme.AppCompat.Dialog">
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<style name="AppThemeBlackDialog" parent="AppThemeDarkDialog">
|
||||
<item name="actionBarPopupTheme">@style/PopupThemeBlack</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="colorPrimary">@color/black</item>
|
||||
<item name="colorPrimaryDark">@color/black</item>
|
||||
<item name="composeBackground">@color/black</item>
|
||||
</style>
|
||||
|
||||
<style name="PopupThemeBlack" parent="@style/PopupThemeDark">
|
||||
<item name="android:colorBackground">@color/black</item>
|
||||
<item name="android:textColor">@color/textPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user