Remove obsolete checks for API 23

This commit is contained in:
Moez Bhatti
2022-12-12 20:30:04 -05:00
parent ce9ba1b9f9
commit 4f2d4954ed
27 changed files with 88 additions and 282 deletions
@@ -551,15 +551,11 @@ public class MmsConfig {
final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService( final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(
Context.TELEPHONY_SERVICE); Context.TELEPHONY_SERVICE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { try {
Method method = telephonyManager.getClass().getMethod("getLine1NumberForSubscriber", int.class);
return (String) method.invoke(telephonyManager, subId);
} catch (Exception e) {
return telephonyManager.getLine1Number(); return telephonyManager.getLine1Number();
} else {
try {
Method method = telephonyManager.getClass().getMethod("getLine1NumberForSubscriber", int.class);
return (String) method.invoke(telephonyManager, subId);
} catch (Exception e) {
return telephonyManager.getLine1Number();
}
} }
} }
@@ -581,16 +577,12 @@ public class MmsConfig {
String nai = ""; String nai = "";
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { try {
Method method = telephonyManager.getClass().getMethod("getNai", int.class);
Method getSlotId = SubscriptionManager.class.getMethod("getSlotId", int.class);
nai = (String) method.invoke(telephonyManager, getSlotId.invoke(null, subId));
} catch (Exception e) {
nai = SystemPropertiesProxy.get(context, "persist.radio.cdma.nai"); nai = SystemPropertiesProxy.get(context, "persist.radio.cdma.nai");
} else {
try {
Method method = telephonyManager.getClass().getMethod("getNai", int.class);
Method getSlotId = SubscriptionManager.class.getMethod("getSlotId", int.class);
nai = (String) method.invoke(telephonyManager, getSlotId.invoke(null, subId));
} catch (Exception e) {
nai = SystemPropertiesProxy.get(context, "persist.radio.cdma.nai");
}
} }
Timber.v("MmsConfig.getNai: nai=" + nai); Timber.v("MmsConfig.getNai: nai=" + nai);
@@ -73,24 +73,19 @@ public class MmsConfigManager {
public void init(final Context context) { public void init(final Context context) {
mContext = context; mContext = context;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { mSubscriptionManager = SubscriptionManager.from(context);
mSubscriptionManager = SubscriptionManager.from(context);
// TODO: When this object "finishes" we should unregister. // TODO: When this object "finishes" we should unregister.
IntentFilter intentFilterLoaded = IntentFilter intentFilterLoaded = new IntentFilter("LOADED");
new IntentFilter("LOADED");
try { try {
context.registerReceiver(mReceiver, intentFilterLoaded); context.registerReceiver(mReceiver, intentFilterLoaded);
} catch (Exception e) { } catch (Exception e) {
}
load(context);
} else {
load(context);
} }
load(context);
// TODO: When this object "finishes" we should unregister by invoking // TODO: When this object "finishes" we should unregister by invoking
// SubscriptionManager.getInstance(mContext).unregister(mOnSubscriptionsChangedListener); // SubscriptionManager.getInstance(mContext).unregister(mOnSubscriptionsChangedListener);
// This is not strictly necessary because it will be unregistered if the // This is not strictly necessary because it will be unregistered if the
@@ -151,39 +146,37 @@ public class MmsConfigManager {
* *
*/ */
private void load(Context context) { private void load(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { List<SubscriptionInfo> subs = mSubscriptionManager.getActiveSubscriptionInfoList();
List<SubscriptionInfo> subs = mSubscriptionManager.getActiveSubscriptionInfoList(); if (subs == null || subs.size() < 1) {
if (subs == null || subs.size() < 1) { Timber.e("MmsConfigManager.load -- empty getActiveSubInfoList");
Timber.e("MmsConfigManager.load -- empty getActiveSubInfoList"); return;
return; }
} // Load all the mms_config.xml files in a separate map and then swap with the
// Load all the mms_config.xml files in a separate map and then swap with the // real map at the end so we don't block anyone sync'd on the real map.
// real map at the end so we don't block anyone sync'd on the real map. final Map<Integer, MmsConfig> newConfigMap = new ArrayMap<Integer, MmsConfig>();
final Map<Integer, MmsConfig> newConfigMap = new ArrayMap<Integer, MmsConfig>(); for (SubscriptionInfo sub : subs) {
for (SubscriptionInfo sub : subs) { Configuration configuration = new Configuration();
Configuration configuration = new Configuration(); if (sub.getMcc() == 0 && sub.getMnc() == 0) {
if (sub.getMcc() == 0 && sub.getMnc() == 0) { Configuration config = mContext.getResources().getConfiguration();
Configuration config = mContext.getResources().getConfiguration(); configuration.mcc = config.mcc;
configuration.mcc = config.mcc; configuration.mnc = config.mnc;
configuration.mnc = config.mnc; Timber.i("MmsConfigManager.load -- no mcc/mnc for sub: " + sub +
Timber.i("MmsConfigManager.load -- no mcc/mnc for sub: " + sub + " using mcc/mnc from main context: " + configuration.mcc + "/" +
" using mcc/mnc from main context: " + configuration.mcc + "/" + configuration.mnc);
configuration.mnc); } else {
} else { Timber.i("MmsConfigManager.load -- mcc/mnc for sub: " + sub);
Timber.i("MmsConfigManager.load -- mcc/mnc for sub: " + sub);
configuration.mcc = sub.getMcc(); configuration.mcc = sub.getMcc();
configuration.mnc = sub.getMnc(); configuration.mnc = sub.getMnc();
} }
Context subContext = context.createConfigurationContext(configuration); Context subContext = context.createConfigurationContext(configuration);
int subId = sub.getSubscriptionId(); int subId = sub.getSubscriptionId();
newConfigMap.put(subId, new MmsConfig(subContext, subId)); newConfigMap.put(subId, new MmsConfig(subContext, subId));
} }
synchronized (mSubIdConfigMap) { synchronized (mSubIdConfigMap) {
mSubIdConfigMap.clear(); mSubIdConfigMap.clear();
mSubIdConfigMap.putAll(newConfigMap); mSubIdConfigMap.putAll(newConfigMap);
}
} }
} }
@@ -87,18 +87,11 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network {
mSubId = subId; mSubId = subId;
if (!MmsRequest.useWifi(context)) { if (!MmsRequest.useWifi(context)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { mNetworkRequest = new NetworkRequest.Builder()
mNetworkRequest = new NetworkRequest.Builder() .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) .addCapability(NetworkCapabilities.NET_CAPABILITY_MMS)
.addCapability(NetworkCapabilities.NET_CAPABILITY_MMS) .setNetworkSpecifier(Integer.toString(mSubId))
.setNetworkSpecifier(Integer.toString(mSubId)) .build();
.build();
} else {
mNetworkRequest = new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
.addCapability(NetworkCapabilities.NET_CAPABILITY_MMS)
.build();
}
} else { } else {
mNetworkRequest = new NetworkRequest.Builder() mNetworkRequest = new NetworkRequest.Builder()
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
@@ -104,12 +104,8 @@ public abstract class MmsRequest {
private boolean ensureMmsConfigLoaded() { private boolean ensureMmsConfigLoaded() {
if (mMmsConfig == null) { if (mMmsConfig == null) {
final MmsConfig config; final MmsConfig config;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { // Not yet retrieved from mms config manager. Try getting it.
// Not yet retrieved from mms config manager. Try getting it. config = MmsConfigManager.getInstance().getMmsConfigBySubId(mSubId);
config = MmsConfigManager.getInstance().getMmsConfigBySubId(mSubId);
} else {
config = MmsConfigManager.getInstance().getMmsConfig();
}
if (config != null) { if (config != null) {
mMmsConfig = new MmsConfig.Overridden(config, mMmsConfigOverrides); mMmsConfig = new MmsConfig.Overridden(config, mMmsConfigOverrides);
@@ -167,11 +163,7 @@ public abstract class MmsRequest {
result = SmsManager.MMS_ERROR_IO_ERROR; result = SmsManager.MMS_ERROR_IO_ERROR;
} else if (!isDataNetworkAvailable(context, mSubId)) { } else if (!isDataNetworkAvailable(context, mSubId)) {
Timber.e("MmsRequest: in airplane mode or mobile data disabled"); Timber.e("MmsRequest: in airplane mode or mobile data disabled");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { result = SmsManager.MMS_ERROR_NO_DATA_NETWORK;
result = SmsManager.MMS_ERROR_NO_DATA_NETWORK;
} else {
result = 8;
}
} else { // Execute } else { // Execute
long retryDelaySecs = 2; long retryDelaySecs = 2;
// Try multiple times of MMS HTTP request // Try multiple times of MMS HTTP request
@@ -268,11 +260,7 @@ public abstract class MmsRequest {
fillIn.putExtra("uri", messageUri.toString()); fillIn.putExtra("uri", messageUri.toString());
} }
if (result == SmsManager.MMS_ERROR_HTTP_FAILURE && httpStatusCode != 0) { if (result == SmsManager.MMS_ERROR_HTTP_FAILURE && httpStatusCode != 0) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { fillIn.putExtra(SmsManager.EXTRA_MMS_HTTP_STATUS, httpStatusCode);
fillIn.putExtra(SmsManager.EXTRA_MMS_HTTP_STATUS, httpStatusCode);
} else {
fillIn.putExtra("android.telephony.extra.MMS_HTTP_STATUS", httpStatusCode);
}
} }
try { try {
if (!succeeded) { if (!succeeded) {
@@ -16,21 +16,19 @@ class SubscriptionIdChecker {
// I met a device which does not have Telephony.Mms.SUBSCRIPTION_ID event if it's API Level is 22. // I met a device which does not have Telephony.Mms.SUBSCRIPTION_ID event if it's API Level is 22.
private void check(Context context) { private void check(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { Cursor c = null;
Cursor c = null; try {
try { c = SqliteWrapper.query(context, context.getContentResolver(),
c = SqliteWrapper.query(context, context.getContentResolver(), Telephony.Mms.CONTENT_URI,
Telephony.Mms.CONTENT_URI, new String[]{Telephony.Mms.SUBSCRIPTION_ID}, null, null, null);
new String[]{Telephony.Mms.SUBSCRIPTION_ID}, null, null, null); if (c != null) {
if (c != null) { mCanUseSubscriptionId = true;
mCanUseSubscriptionId = true; }
} } catch (SQLiteException e) {
} catch (SQLiteException e) { Timber.e("SubscriptionIdChecker.check() fail");
Timber.e("SubscriptionIdChecker.check() fail"); } finally {
} finally { if (c != null) {
if (c != null) { c.close();
c.close();
}
} }
} }
} }
@@ -539,11 +539,6 @@ public class TransactionService extends Service implements Observer {
// cancel timer for renewal of lease // cancel timer for renewal of lease
mServiceHandler.removeMessages(EVENT_CONTINUE_MMS_CONNECTIVITY); mServiceHandler.removeMessages(EVENT_CONTINUE_MMS_CONNECTIVITY);
if (mConnMgr != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
mConnMgr.stopUsingNetworkFeature(
ConnectivityManager.TYPE_MOBILE,
"enableMMS");
}
} finally { } finally {
releaseWakeLock(); releaseWakeLock();
} }
@@ -1604,8 +1604,6 @@ public class PduPersister {
* Check if read permissions for SMS have been granted * Check if read permissions for SMS have been granted
*/ */
private boolean checkReadSmsPermissions() { private boolean checkReadSmsPermissions() {
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M || return mContext.checkSelfPermission(Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED;
mContext.checkSelfPermission(Manifest.permission.READ_SMS) ==
PackageManager.PERMISSION_GRANTED;
} }
} }
@@ -8,7 +8,7 @@ object SmsManagerFactory {
fun createSmsManager(subscriptionId: Int): SmsManager { fun createSmsManager(subscriptionId: Int): SmsManager {
var manager: SmsManager? = null var manager: SmsManager? = null
if (subscriptionId != -1 && Build.VERSION.SDK_INT >= 22) { if (subscriptionId != -1) {
try { try {
manager = SmsManager.getSmsManagerForSubscriptionId(subscriptionId) manager = SmsManager.getSmsManagerForSubscriptionId(subscriptionId)
} catch (e: Exception) { } catch (e: Exception) {
@@ -59,14 +59,9 @@ public class Utils {
} }
public static <T> T ensureRouteToMmsNetwork(Context context, String url, String proxy, Task<T> task) throws IOException { public static <T> T ensureRouteToMmsNetwork(Context context, String url, String proxy, Task<T> task) throws IOException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return ensureRouteToMmsNetworkMarshmallow(context, task);
return ensureRouteToMmsNetworkMarshmallow(context, task);
} else {
return ensureRouteToMmsNetworkLollipop(context, task);
}
} }
@TargetApi(Build.VERSION_CODES.M)
private static <T> T ensureRouteToMmsNetworkMarshmallow(Context context, Task<T> task) throws IOException { private static <T> T ensureRouteToMmsNetworkMarshmallow(Context context, Task<T> task) throws IOException {
final MmsNetworkManager networkManager = new MmsNetworkManager(context.getApplicationContext(), Utils.getDefaultSubscriptionId()); final MmsNetworkManager networkManager = new MmsNetworkManager(context.getApplicationContext(), Utils.getDefaultSubscriptionId());
final ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); final ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
@@ -85,24 +80,6 @@ public class Utils {
} }
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static <T> T ensureRouteToMmsNetworkLollipop(Context context, Task<T> task) throws IOException {
final MmsNetworkManager networkManager = new MmsNetworkManager(context.getApplicationContext(), Utils.getDefaultSubscriptionId());
Network network = null;
try {
network = networkManager.acquireNetwork();
ConnectivityManager.setProcessDefaultNetwork(network);
return task.run();
} catch (MmsNetworkException e) {
throw new IOException(e);
} finally {
if (network != null) {
ConnectivityManager.setProcessDefaultNetwork(null);
}
networkManager.releaseNetwork();
}
}
/** /**
* Ensures that the host MMSC is reachable * Ensures that the host MMSC is reachable
* *
@@ -381,10 +358,6 @@ public class Utils {
} }
public static int getDefaultSubscriptionId() { public static int getDefaultSubscriptionId() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { return SmsManager.getDefaultSmsSubscriptionId();
return SmsManager.getDefaultSmsSubscriptionId();
} else {
return DEFAULT_SUBSCRIPTION_ID;
}
} }
} }
@@ -42,28 +42,7 @@ object TelephonyCompat {
} }
fun getOrCreateThreadId(context: Context, recipients: Collection<String>): Long { fun getOrCreateThreadId(context: Context, recipients: Collection<String>): Long {
return if (Build.VERSION.SDK_INT >= 23) { return Telephony.Threads.getOrCreateThreadId(context, recipients.toSet())
Telephony.Threads.getOrCreateThreadId(context, recipients.toSet())
} else {
val uriBuilder = THREAD_ID_CONTENT_URI.buildUpon()
recipients
.map { recipient -> if (isEmailAddress(recipient)) extractAddrSpec(recipient) else recipient }
.forEach { recipient -> uriBuilder.appendQueryParameter("recipient", recipient) }
val uri = uriBuilder.build()
SqliteWrapper.query(context, context.contentResolver, uri, ID_PROJECTION, null, null, null)?.use { cursor ->
if (cursor.moveToFirst()) {
return cursor.getLong(0)
} else {
Timber.e("getOrCreateThreadId returned no rows!")
}
}
Timber.e("getOrCreateThreadId failed with " + recipients.size + " recipients")
throw IllegalArgumentException("Unable to find or allocate a thread ID.")
}
} }
fun extractAddrSpec(address: String): String { fun extractAddrSpec(address: String): String {
@@ -22,7 +22,6 @@ import android.annotation.TargetApi
import android.os.Build import android.os.Build
import android.telephony.SubscriptionInfo import android.telephony.SubscriptionInfo
@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
data class SubscriptionInfoCompat(private val subscriptionInfo: SubscriptionInfo) { data class SubscriptionInfoCompat(private val subscriptionInfo: SubscriptionInfo) {
val subscriptionId get() = subscriptionInfo.subscriptionId val subscriptionId get() = subscriptionInfo.subscriptionId
@@ -31,36 +31,29 @@ class SubscriptionManagerCompat @Inject constructor(context: Context, private va
val activeSubscriptionInfoList: List<SubscriptionInfoCompat> val activeSubscriptionInfoList: List<SubscriptionInfoCompat>
get() { get() {
return if (Build.VERSION.SDK_INT >= 22) { return subscriptionManager?.activeSubscriptionInfoList?.map { SubscriptionInfoCompat(it) } ?: listOf()
subscriptionManager?.activeSubscriptionInfoList?.map { SubscriptionInfoCompat(it) } ?: listOf()
} else listOf()
} }
init { init {
subscriptionManager = if (Build.VERSION.SDK_INT >= 22) SubscriptionManager.from(context) else null subscriptionManager = SubscriptionManager.from(context)
} }
fun addOnSubscriptionsChangedListener(listener: OnSubscriptionsChangedListener) { fun addOnSubscriptionsChangedListener(listener: OnSubscriptionsChangedListener) {
if (Build.VERSION.SDK_INT >= 22) { subscriptionManager?.addOnSubscriptionsChangedListener(listener.listener)
subscriptionManager?.addOnSubscriptionsChangedListener(listener.listener)
}
} }
fun removeOnSubscriptionsChangedListener(listener: OnSubscriptionsChangedListener) { fun removeOnSubscriptionsChangedListener(listener: OnSubscriptionsChangedListener) {
if (Build.VERSION.SDK_INT >= 22) { subscriptionManager?.removeOnSubscriptionsChangedListener(listener.listener)
subscriptionManager?.removeOnSubscriptionsChangedListener(listener.listener)
}
} }
abstract class OnSubscriptionsChangedListener { abstract class OnSubscriptionsChangedListener {
val listener: SubscriptionManager.OnSubscriptionsChangedListener? = if (Build.VERSION.SDK_INT >= 22) { val listener: SubscriptionManager.OnSubscriptionsChangedListener? =
object : SubscriptionManager.OnSubscriptionsChangedListener() { object : SubscriptionManager.OnSubscriptionsChangedListener() {
override fun onSubscriptionsChanged() { override fun onSubscriptionsChanged() {
this@OnSubscriptionsChangedListener.onSubscriptionsChanged() this@OnSubscriptionsChangedListener.onSubscriptionsChanged()
} }
} }
} else null
abstract fun onSubscriptionsChanged() abstract fun onSubscriptionsChanged()
@@ -34,11 +34,7 @@ class AlarmManagerImpl @Inject constructor(private val context: Context) : Alarm
override fun setAlarm(date: Long, intent: PendingIntent) { override fun setAlarm(date: Long, intent: PendingIntent) {
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as android.app.AlarmManager val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as android.app.AlarmManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { alarmManager.setExactAndAllowWhileIdle(android.app.AlarmManager.RTC_WAKEUP, date, intent)
alarmManager.setExactAndAllowWhileIdle(android.app.AlarmManager.RTC_WAKEUP, date, intent)
} else {
alarmManager.setExact(android.app.AlarmManager.RTC_WAKEUP, date, intent)
}
} }
} }
@@ -328,11 +328,7 @@ class MessageRepositoryImpl @Inject constructor(
val intent = getIntentForDelayedSms(message.id) val intent = getIntentForDelayedSms(message.id)
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, sendTime, intent)
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, sendTime, intent)
} else {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, sendTime, intent)
}
} else { // No delay } else { // No delay
val message = insertSentSms(subId, threadId, addresses.first(), strippedBody, now()) val message = insertSentSms(subId, threadId, addresses.first(), strippedBody, now())
sendSms(message) sendSms(message)
@@ -35,7 +35,6 @@ import com.moez.QKSMS.util.GlideApp
import com.moez.QKSMS.util.tryOrNull import com.moez.QKSMS.util.tryOrNull
import javax.inject.Inject import javax.inject.Inject
@RequiresApi(Build.VERSION_CODES.M)
class QkChooserTargetService : ChooserTargetService() { class QkChooserTargetService : ChooserTargetService() {
@Inject lateinit var conversationRepo: ConversationRepository @Inject lateinit var conversationRepo: ConversationRepository
@@ -63,9 +63,6 @@ fun ProgressBar.setTint(color: Int) {
fun View.setBackgroundTint(color: Int) { fun View.setBackgroundTint(color: Int) {
// API 21 doesn't support this // API 21 doesn't support this
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
background?.setColorFilter(color, PorterDuff.Mode.SRC_IN)
}
backgroundTintList = ColorStateList.valueOf(color) backgroundTintList = ColorStateList.valueOf(color)
} }
@@ -155,11 +155,6 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
.subscribe() .subscribe()
window.callback = ComposeWindowCallback(window.callback, this) window.callback = ComposeWindowCallback(window.callback, this)
// These theme attributes don't apply themselves on API 21
if (Build.VERSION.SDK_INT <= 22) {
messageBackground.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
}
} }
override fun onStart() { override fun onStart() {
@@ -123,7 +123,6 @@ class ComposeWindowCallback(
return localCallback.onSearchRequested() return localCallback.onSearchRequested()
} }
@RequiresApi(api = Build.VERSION_CODES.M)
override fun onSearchRequested(searchEvent: SearchEvent): Boolean { override fun onSearchRequested(searchEvent: SearchEvent): Boolean {
return localCallback.onSearchRequested(searchEvent) return localCallback.onSearchRequested(searchEvent)
} }
@@ -132,7 +131,6 @@ class ComposeWindowCallback(
return localCallback.onWindowStartingActionMode(callback) return localCallback.onWindowStartingActionMode(callback)
} }
@RequiresApi(api = Build.VERSION_CODES.M)
override fun onWindowStartingActionMode(callback: ActionMode.Callback, i: Int): ActionMode? { override fun onWindowStartingActionMode(callback: ActionMode.Callback, i: Int): ActionMode? {
return localCallback.onWindowStartingActionMode(callback, i) return localCallback.onWindowStartingActionMode(callback, i)
} }
@@ -152,9 +152,7 @@ class MessagesAdapter @Inject constructor(
view = layoutInflater.inflate(R.layout.message_list_item_in, parent, false) view = layoutInflater.inflate(R.layout.message_list_item_in, parent, false)
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { view.body.hyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE
view.body.hyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE
}
val partsAdapter = partsAdapterProvider.get() val partsAdapter = partsAdapterProvider.get()
partsAdapter.clicks.subscribe(partClicks) partsAdapter.clicks.subscribe(partClicks)
@@ -44,11 +44,6 @@ class ChipsAdapter @Inject constructor() : QkAdapter<Recipient>() {
val inflater = LayoutInflater.from(parent.context) val inflater = LayoutInflater.from(parent.context)
val view = inflater.inflate(R.layout.contact_chip, parent, false) val view = inflater.inflate(R.layout.contact_chip, parent, false)
return QkViewHolder(view).apply { return QkViewHolder(view).apply {
// These theme attributes don't apply themselves on API 21
if (Build.VERSION.SDK_INT <= 22) {
content.setBackgroundTint(view.context.resolveThemeColor(R.attr.bubbleColor))
}
view.setOnClickListener { view.setOnClickListener {
val chip = getItem(adapterPosition) val chip = getItem(adapterPosition)
showDetailedChip(view.context, chip) showDetailedChip(view.context, chip)
@@ -88,11 +88,6 @@ class ContactsActivity : QkThemedActivity(), ContactsContract {
viewModel.bindView(this) viewModel.bindView(this)
contacts.adapter = contactsAdapter contacts.adapter = contactsAdapter
// These theme attributes don't apply themselves on API 21
if (Build.VERSION.SDK_INT <= 22) {
search.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
}
} }
override fun render(state: ContactsState) { override fun render(state: ContactsState) {
@@ -185,11 +185,6 @@ class MainActivity : QkThemedActivity(), MainView {
// Set the FAB compose icon color // Set the FAB compose icon color
compose.setTint(theme.textPrimary) compose.setTint(theme.textPrimary)
} }
// These theme attributes don't apply themselves on API 21
if (Build.VERSION.SDK_INT <= 22) {
toolbarSearch.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
}
} }
override fun onNewIntent(intent: Intent?) { override fun onNewIntent(intent: Intent?) {
@@ -74,15 +74,6 @@ class QkReplyActivity : QkThemedActivity(), QkReplyView {
messages.adapter?.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { messages.adapter?.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
override fun onChanged() = messages.scrollToPosition(adapter.itemCount - 1) override fun onChanged() = messages.scrollToPosition(adapter.itemCount - 1)
}) })
// These theme attributes don't apply themselves on API 21
if (Build.VERSION.SDK_INT <= 22) {
toolbar.setBackgroundTint(resolveThemeColor(R.attr.colorPrimary))
background.setBackgroundTint(resolveThemeColor(android.R.attr.windowBackground))
messageBackground.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
composeBackgroundGradient.setBackgroundTint(resolveThemeColor(android.R.attr.windowBackground))
composeBackgroundSolid.setBackgroundTint(resolveThemeColor(android.R.attr.windowBackground))
}
} }
override fun render(state: QkReplyState) { override fun render(state: QkReplyState) {
@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2019 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/>.
-->
<resources>
<!-- On Marshmallow, explicitly don't use the light status bar -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowLightStatusBar">false</item>
</style>
</resources>
@@ -19,7 +19,9 @@
--> -->
<resources> <resources>
<style name="AppTheme" parent="AppBaseTheme" /> <style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowLightStatusBar">false</item>
</style>
<style name="AppBaseTheme" parent="Theme.AppCompat.NoActionBar"> <style name="AppBaseTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:divider">@color/separatorDark</item> <item name="android:divider">@color/separatorDark</item>
@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2019 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/>.
-->
<resources>
<!-- On Marshmallow, use the light status bar -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:statusBarColor">@color/backgroundLight</item>
<item name="android:windowLightStatusBar">true</item>
</style>
</resources>
+4 -1
View File
@@ -31,7 +31,10 @@
<item name="android:windowBackground">@color/backgroundDark</item> <item name="android:windowBackground">@color/backgroundDark</item>
</style> </style>
<style name="AppTheme" parent="AppBaseTheme" /> <style name="AppTheme" parent="AppBaseTheme">
<item name="android:statusBarColor">@color/backgroundLight</item>
<item name="android:windowLightStatusBar">true</item>
</style>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar"> <style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:divider">@color/separatorLight</item> <item name="android:divider">@color/separatorLight</item>