From 927db19ace9e7432d4309ee6f7eb3a583d445ffe Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Mon, 12 Dec 2022 15:24:45 -0500 Subject: [PATCH 01/32] Upgrade to Target SDK 33 --- build.gradle | 4 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- presentation/build.gradle | 5 ++-- presentation/src/main/AndroidManifest.xml | 26 +++++++++++++++---- .../QKSMS/feature/compose/ComposeActivity.kt | 4 +-- .../feature/compose/ComposeWindowCallback.kt | 2 +- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index f7a1e2c8f..17dbcf733 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.androidx_appcompat_version = '1.1.0' + ext.androidx_appcompat_version = '1.3.1' ext.androidx_constraintlayout_version = '1.1.3' ext.androidx_core_version = '1.1.0' ext.androidx_emoji_version = '1.0.0' @@ -42,7 +42,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.4' + classpath 'com.android.tools.build:gradle:4.2.2' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1' classpath 'com.google.gms:google-services:4.2.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4b9cec46b..5f1431468 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip diff --git a/presentation/build.gradle b/presentation/build.gradle index 7dee8d3c8..46a92ca42 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -23,14 +23,13 @@ apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' android { - compileSdkVersion 29 - buildToolsVersion "29.0.3" + compileSdkVersion 33 flavorDimensions "analytics" defaultConfig { applicationId "com.moez.QKSMS" minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 33 versionCode 2218 versionName "3.9.4" setProperty("archivesBaseName", "QKSMS-v${versionName}") diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 796dc6a33..d52d05032 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -48,6 +48,7 @@ @@ -59,6 +60,7 @@ @@ -118,12 +120,16 @@ - + - + @@ -131,6 +137,7 @@ @@ -138,6 +145,7 @@ @@ -161,13 +169,18 @@ - + + - + @@ -184,6 +197,7 @@ + @@ -201,8 +215,10 @@ + @@ -229,4 +245,4 @@ - \ No newline at end of file + diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt index 3b42535b6..1993c4b79 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt @@ -392,8 +392,8 @@ class ComposeActivity : QkThemedActivity(), ComposeView { super.onSaveInstanceState(outState) } - override fun onRestoreInstanceState(savedInstanceState: Bundle?) { - cameraDestination = savedInstanceState?.getParcelable(CameraDestinationKey) + override fun onRestoreInstanceState(savedInstanceState: Bundle) { + cameraDestination = savedInstanceState.getParcelable(CameraDestinationKey) super.onRestoreInstanceState(savedInstanceState) } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeWindowCallback.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeWindowCallback.kt index 0ea9eab79..c3fac4b97 100755 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeWindowCallback.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeWindowCallback.kt @@ -83,7 +83,7 @@ class ComposeWindowCallback( return localCallback.onCreatePanelMenu(i, menu) } - override fun onPreparePanel(i: Int, view: View, menu: Menu): Boolean { + override fun onPreparePanel(i: Int, view: View?, menu: Menu): Boolean { return localCallback.onPreparePanel(i, view, menu) } -- GitLab From 96e14a88fa50a328bbc67aa58cfa1cd0f5b36c09 Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Mon, 12 Dec 2022 15:39:25 -0500 Subject: [PATCH 02/32] Upgrade to Kotlin v1.7.20 --- android-smsmms/build.gradle | 9 ++++----- android-smsmms/src/main/AndroidManifest.xml | 4 +--- build.gradle | 8 ++++---- common/build.gradle | 1 + common/src/main/AndroidManifest.xml | 2 +- data/build.gradle | 1 + data/src/main/AndroidManifest.xml | 2 +- domain/build.gradle | 1 + domain/src/main/AndroidManifest.xml | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- presentation/build.gradle | 7 ++++--- presentation/src/main/AndroidManifest.xml | 3 +-- .../java/com/moez/QKSMS/feature/main/MainViewModel.kt | 2 ++ .../feature/plus/experiment/UpgradeButtonExperiment.kt | 2 +- 14 files changed, 24 insertions(+), 22 deletions(-) diff --git a/android-smsmms/build.gradle b/android-smsmms/build.gradle index 505404cb3..d49b9a3db 100644 --- a/android-smsmms/build.gradle +++ b/android-smsmms/build.gradle @@ -25,15 +25,14 @@ android { defaultConfig { minSdkVersion 21 targetSdkVersion 25 - versionCode 1 - versionName "1.0" } - lintOptions { - abortOnError false - } useLibrary 'org.apache.http.legacy' + lint { + abortOnError false + } + namespace 'com.klinker.android.send_message' } dependencies { diff --git a/android-smsmms/src/main/AndroidManifest.xml b/android-smsmms/src/main/AndroidManifest.xml index c87baa9a5..3af6653c9 100755 --- a/android-smsmms/src/main/AndroidManifest.xml +++ b/android-smsmms/src/main/AndroidManifest.xml @@ -1,7 +1,5 @@ - + diff --git a/build.gradle b/build.gradle index 17dbcf733..6d44edf80 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { ext.exoplayer_version = "2.8.1" ext.glide_version = "4.8.0" ext.junit_version = '4.12' - ext.kotlin_version = '1.3.60' + ext.kotlin_version = '1.7.20' ext.lifecycle_version = '2.1.0' ext.material_version = '1.0.0' ext.mockito_version = '2.18.3' @@ -42,9 +42,9 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.2.2' - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1' - classpath 'com.google.gms:google-services:4.2.0' + classpath 'com.android.tools.build:gradle:7.3.1' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2' + classpath 'com.google.gms:google-services:4.3.10' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "io.realm:realm-gradle-plugin:$realm_version" } diff --git a/common/build.gradle b/common/build.gradle index a893d1c18..3f8be346c 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -28,6 +28,7 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } + namespace 'com.moez.QKSMS.common' } dependencies { diff --git a/common/src/main/AndroidManifest.xml b/common/src/main/AndroidManifest.xml index 969a751c5..21edd1fd3 100644 --- a/common/src/main/AndroidManifest.xml +++ b/common/src/main/AndroidManifest.xml @@ -16,4 +16,4 @@ ~ You should have received a copy of the GNU General Public License ~ along with QKSMS. If not, see . --> - + diff --git a/data/build.gradle b/data/build.gradle index a76aff2b4..74ac944cb 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -42,6 +42,7 @@ android { withAnalytics { dimension "analytics" } noAnalytics { dimension "analytics" } } + namespace 'com.moez.QKSMS.data' } dependencies { diff --git a/data/src/main/AndroidManifest.xml b/data/src/main/AndroidManifest.xml index 3c6184a70..21edd1fd3 100644 --- a/data/src/main/AndroidManifest.xml +++ b/data/src/main/AndroidManifest.xml @@ -16,4 +16,4 @@ ~ You should have received a copy of the GNU General Public License ~ along with QKSMS. If not, see . --> - + diff --git a/domain/build.gradle b/domain/build.gradle index 85a69fd8d..6cb92629f 100644 --- a/domain/build.gradle +++ b/domain/build.gradle @@ -34,6 +34,7 @@ android { minSdkVersion 21 targetSdkVersion 29 } + namespace 'com.moez.QKSMS.domain' } dependencies { diff --git a/domain/src/main/AndroidManifest.xml b/domain/src/main/AndroidManifest.xml index 00485b51a..21edd1fd3 100644 --- a/domain/src/main/AndroidManifest.xml +++ b/domain/src/main/AndroidManifest.xml @@ -16,4 +16,4 @@ ~ You should have received a copy of the GNU General Public License ~ along with QKSMS. If not, see . --> - + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5f1431468..345d3af5b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/presentation/build.gradle b/presentation/build.gradle index 46a92ca42..28deafaaf 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -60,14 +60,15 @@ android { jvmTarget = "1.8" } - lintOptions { - abortOnError false - } productFlavors { withAnalytics { dimension "analytics" } noAnalytics { dimension "analytics" } } + lint { + abortOnError false + } + namespace 'com.moez.QKSMS' if (System.getenv("CI") == "true") { signingConfigs.release.storeFile = file("../keystore") diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index d52d05032..fbf57deae 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -17,8 +17,7 @@ ~ You should have received a copy of the GNU General Public License ~ along with QKSMS. If not, see . --> - + diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt index e4fec32bd..a285c4328 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt @@ -408,6 +408,8 @@ class MainViewModel @Inject constructor( val page = state.page.copy(addContact = add, markPinned = pin, markRead = read, selected = selected) newState { copy(page = page) } } + + is Searching -> {} // Ignore } } .autoDisposable(view.scope()) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/plus/experiment/UpgradeButtonExperiment.kt b/presentation/src/main/java/com/moez/QKSMS/feature/plus/experiment/UpgradeButtonExperiment.kt index c954a5592..e5727c0c4 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/plus/experiment/UpgradeButtonExperiment.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/plus/experiment/UpgradeButtonExperiment.kt @@ -29,7 +29,7 @@ import javax.inject.Inject class UpgradeButtonExperiment @Inject constructor( context: Context, analytics: AnalyticsManager -) : Experiment<@StringRes Int>(context, analytics) { +) : Experiment(context, analytics) { override val key: String = "Upgrade Button" -- GitLab From 89a6a27cb5ca86c1d393e80affa6ba2b2ac70138 Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Mon, 12 Dec 2022 15:44:45 -0500 Subject: [PATCH 03/32] Upgrade to Realm v10.13.0 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6d44edf80..c280a57e6 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ buildscript { ext.mockito_version = '2.18.3' ext.moshi_version = '1.8.0' ext.okhttp3_version = '4.1.0' - ext.realm_version = '5.8.0' + ext.realm_version = '10.13.0' ext.realm_adapters_version = '3.1.0' ext.rxandroid_version = '2.0.1' ext.rxdogtag_version = '0.2.0' -- GitLab From 322f34c75e736d791270879d4f160ad399c057cb Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Mon, 12 Dec 2022 16:47:39 -0500 Subject: [PATCH 04/32] Update minSdkVersion for all modules to 33 --- common/build.gradle | 2 +- data/build.gradle | 2 +- domain/build.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index 3f8be346c..179100bb1 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -24,7 +24,7 @@ android { defaultConfig { minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 33 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/data/build.gradle b/data/build.gradle index 74ac944cb..e7be1b2dc 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -32,7 +32,7 @@ android { defaultConfig { minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 33 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" buildConfigField "String", "AMPLITUDE_API_KEY", "\"${System.getenv("AMPLITUDE_API_KEY")}\"" diff --git a/domain/build.gradle b/domain/build.gradle index 6cb92629f..dcfb26630 100644 --- a/domain/build.gradle +++ b/domain/build.gradle @@ -32,7 +32,7 @@ android { defaultConfig { minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 33 } namespace 'com.moez.QKSMS.domain' } -- GitLab From 2c332c06b696af5c6f63d24ee979b41a0246fd19 Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Mon, 12 Dec 2022 16:47:57 -0500 Subject: [PATCH 05/32] Bump minSdkVersion to 23 --- android-smsmms/build.gradle | 2 +- common/build.gradle | 2 +- data/build.gradle | 2 +- domain/build.gradle | 2 +- presentation/build.gradle | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/android-smsmms/build.gradle b/android-smsmms/build.gradle index d49b9a3db..c3c028253 100644 --- a/android-smsmms/build.gradle +++ b/android-smsmms/build.gradle @@ -23,7 +23,7 @@ android { compileSdkVersion 25 defaultConfig { - minSdkVersion 21 + minSdkVersion 23 targetSdkVersion 25 } diff --git a/common/build.gradle b/common/build.gradle index 179100bb1..613e62349 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -23,7 +23,7 @@ android { compileSdkVersion 29 defaultConfig { - minSdkVersion 21 + minSdkVersion 23 targetSdkVersion 33 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/data/build.gradle b/data/build.gradle index e7be1b2dc..2c59ee1a0 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -31,7 +31,7 @@ android { } defaultConfig { - minSdkVersion 21 + minSdkVersion 23 targetSdkVersion 33 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/domain/build.gradle b/domain/build.gradle index dcfb26630..f1d35702b 100644 --- a/domain/build.gradle +++ b/domain/build.gradle @@ -31,7 +31,7 @@ android { } defaultConfig { - minSdkVersion 21 + minSdkVersion 23 targetSdkVersion 33 } namespace 'com.moez.QKSMS.domain' diff --git a/presentation/build.gradle b/presentation/build.gradle index 28deafaaf..9c2c90f7c 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -28,7 +28,7 @@ android { defaultConfig { applicationId "com.moez.QKSMS" - minSdkVersion 21 + minSdkVersion 23 targetSdkVersion 33 versionCode 2218 versionName "3.9.4" -- GitLab From 634f04b7aa8ec1e2f2feafc01de1ed93eaa2e635 Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Mon, 12 Dec 2022 18:25:46 -0500 Subject: [PATCH 06/32] Explicitly define mutability for PendingIntents --- .../mms/transaction/DownloadManager.java | 2 +- .../mms/transaction/RetryScheduler.java | 2 +- .../android/send_message/Transaction.kt | 2 +- .../moez/QKSMS/manager/AlarmManagerImpl.kt | 2 +- .../QKSMS/repository/MessageRepositoryImpl.kt | 6 +++--- .../com/moez/QKSMS/util/NightModeManager.kt | 4 ++-- .../common/util/NotificationManagerImpl.kt | 20 +++++++++---------- .../QKSMS/feature/widget/WidgetProvider.kt | 6 +++--- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/android-smsmms/src/main/java/com/android/mms/transaction/DownloadManager.java b/android-smsmms/src/main/java/com/android/mms/transaction/DownloadManager.java index 698817ca6..a8f6de5ff 100755 --- a/android-smsmms/src/main/java/com/android/mms/transaction/DownloadManager.java +++ b/android-smsmms/src/main/java/com/android/mms/transaction/DownloadManager.java @@ -73,7 +73,7 @@ public class DownloadManager { download.putExtra(MmsReceivedReceiver.EXTRA_TRIGGER_PUSH, byPush); download.putExtra(MmsReceivedReceiver.EXTRA_URI, uri); final PendingIntent pendingIntent = PendingIntent.getBroadcast( - context, 0, download, PendingIntent.FLAG_CANCEL_CURRENT); + context, 0, download, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE); final SmsManager smsManager = SmsManagerFactory.INSTANCE.createSmsManager(subscriptionId); Bundle configOverrides = new Bundle(); diff --git a/android-smsmms/src/main/java/com/android/mms/transaction/RetryScheduler.java b/android-smsmms/src/main/java/com/android/mms/transaction/RetryScheduler.java index 455581810..414f14e7e 100755 --- a/android-smsmms/src/main/java/com/android/mms/transaction/RetryScheduler.java +++ b/android-smsmms/src/main/java/com/android/mms/transaction/RetryScheduler.java @@ -309,7 +309,7 @@ public class RetryScheduler implements Observer { Intent service = new Intent(TransactionService.ACTION_ONALARM, null, context, TransactionService.class); PendingIntent operation = PendingIntent.getService( - context, 0, service, PendingIntent.FLAG_ONE_SHOT); + context, 0, service, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE); AlarmManager am = (AlarmManager) context.getSystemService( Context.ALARM_SERVICE); am.set(AlarmManager.RTC, retryAt, operation); diff --git a/android-smsmms/src/main/java/com/klinker/android/send_message/Transaction.kt b/android-smsmms/src/main/java/com/klinker/android/send_message/Transaction.kt index e7169cbef..2650c67d9 100755 --- a/android-smsmms/src/main/java/com/klinker/android/send_message/Transaction.kt +++ b/android-smsmms/src/main/java/com/klinker/android/send_message/Transaction.kt @@ -101,7 +101,7 @@ class Transaction @JvmOverloads constructor(private val context: Context, settin sentIntent.putExtra(EXTRA_CONTENT_URI, messageUri.toString()) sentIntent.putExtra(EXTRA_FILE_PATH, sendFile.path) - val sentPI = PendingIntent.getBroadcast(context, 0, sentIntent, PendingIntent.FLAG_CANCEL_CURRENT) + val sentPI = PendingIntent.getBroadcast(context, 0, sentIntent, PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE) val updatedIntent = Intent(MMS_UPDATED).putExtra("uri", messageUri.toString()) BroadcastUtils.addClassName(context, updatedIntent, MMS_UPDATED) diff --git a/data/src/main/java/com/moez/QKSMS/manager/AlarmManagerImpl.kt b/data/src/main/java/com/moez/QKSMS/manager/AlarmManagerImpl.kt index 526d5d0ac..a41f6119b 100644 --- a/data/src/main/java/com/moez/QKSMS/manager/AlarmManagerImpl.kt +++ b/data/src/main/java/com/moez/QKSMS/manager/AlarmManagerImpl.kt @@ -29,7 +29,7 @@ class AlarmManagerImpl @Inject constructor(private val context: Context) : Alarm override fun getScheduledMessageIntent(id: Long): PendingIntent { val intent = Intent(context, SendScheduledMessageReceiver::class.java).putExtra("id", id) - return PendingIntent.getBroadcast(context, id.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT) + return PendingIntent.getBroadcast(context, id.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } override fun setAlarm(date: Long, intent: PendingIntent) { diff --git a/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt b/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt index a5438d346..006598923 100644 --- a/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt +++ b/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt @@ -445,13 +445,13 @@ class MessageRepositoryImpl @Inject constructor( val sentIntents = parts.map { val intent = Intent(context, SmsSentReceiver::class.java).putExtra("id", message.id) - PendingIntent.getBroadcast(context, message.id.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT) + PendingIntent.getBroadcast(context, message.id.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } val deliveredIntents = parts.map { val intent = Intent(context, SmsDeliveredReceiver::class.java).putExtra("id", message.id) val pendingIntent = PendingIntent - .getBroadcast(context, message.id.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT) + .getBroadcast(context, message.id.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) if (prefs.delivery.get()) pendingIntent else null } @@ -495,7 +495,7 @@ class MessageRepositoryImpl @Inject constructor( private fun getIntentForDelayedSms(id: Long): PendingIntent { val intent = Intent(context, SendSmsReceiver::class.java).putExtra("id", id) - return PendingIntent.getBroadcast(context, id.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT) + return PendingIntent.getBroadcast(context, id.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } override fun insertSentSms(subId: Int, threadId: Long, address: String, body: String, date: Long): Message { diff --git a/data/src/main/java/com/moez/QKSMS/util/NightModeManager.kt b/data/src/main/java/com/moez/QKSMS/util/NightModeManager.kt index 243bfb53c..6cb000767 100644 --- a/data/src/main/java/com/moez/QKSMS/util/NightModeManager.kt +++ b/data/src/main/java/com/moez/QKSMS/util/NightModeManager.kt @@ -99,11 +99,11 @@ class NightModeManager @Inject constructor( private fun updateAlarms() { val dayCalendar = createCalendar(prefs.nightEnd.get()) val day = Intent(context, NightModeReceiver::class.java) - val dayIntent = PendingIntent.getBroadcast(context, 0, day, 0) + val dayIntent = PendingIntent.getBroadcast(context, 0, day, PendingIntent.FLAG_IMMUTABLE) val nightCalendar = createCalendar(prefs.nightStart.get()) val night = Intent(context, NightModeReceiver::class.java) - val nightIntent = PendingIntent.getBroadcast(context, 1, night, 0) + val nightIntent = PendingIntent.getBroadcast(context, 1, night, PendingIntent.FLAG_IMMUTABLE) context.sendBroadcast(day) context.sendBroadcast(night) diff --git a/presentation/src/main/java/com/moez/QKSMS/common/util/NotificationManagerImpl.kt b/presentation/src/main/java/com/moez/QKSMS/common/util/NotificationManagerImpl.kt index f94eb3d34..4e767f1fe 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/util/NotificationManagerImpl.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/util/NotificationManagerImpl.kt @@ -114,11 +114,11 @@ class NotificationManagerImpl @Inject constructor( val taskStackBuilder = TaskStackBuilder.create(context) .addParentStack(ComposeActivity::class.java) .addNextIntent(contentIntent) - val contentPI = taskStackBuilder.getPendingIntent(threadId.toInt(), PendingIntent.FLAG_UPDATE_CURRENT) + val contentPI = taskStackBuilder.getPendingIntent(threadId.toInt(), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) val seenIntent = Intent(context, MarkSeenReceiver::class.java).putExtra("threadId", threadId) val seenPI = PendingIntent.getBroadcast(context, threadId.toInt(), seenIntent, - PendingIntent.FLAG_UPDATE_CURRENT) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) // 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() @@ -233,7 +233,7 @@ class NotificationManagerImpl @Inject constructor( Preferences.NOTIFICATION_ACTION_ARCHIVE -> { val intent = Intent(context, MarkArchivedReceiver::class.java).putExtra("threadId", threadId) val pi = PendingIntent.getBroadcast(context, threadId.toInt(), intent, - PendingIntent.FLAG_UPDATE_CURRENT) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) NotificationCompat.Action.Builder(R.drawable.ic_archive_white_24dp, actionLabels[action], pi) .setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_ARCHIVE).build() } @@ -244,7 +244,7 @@ class NotificationManagerImpl @Inject constructor( .putExtra("threadId", threadId) .putExtra("messageIds", messageIds) val pi = PendingIntent.getBroadcast(context, threadId.toInt(), intent, - PendingIntent.FLAG_UPDATE_CURRENT) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) NotificationCompat.Action.Builder(R.drawable.ic_delete_white_24dp, actionLabels[action], pi) .setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_DELETE).build() } @@ -252,7 +252,7 @@ class NotificationManagerImpl @Inject constructor( Preferences.NOTIFICATION_ACTION_BLOCK -> { val intent = Intent(context, BlockThreadReceiver::class.java).putExtra("threadId", threadId) val pi = PendingIntent.getBroadcast(context, threadId.toInt(), intent, - PendingIntent.FLAG_UPDATE_CURRENT) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) NotificationCompat.Action.Builder(R.drawable.ic_block_white_24dp, actionLabels[action], pi) .setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MUTE).build() } @@ -260,7 +260,7 @@ class NotificationManagerImpl @Inject constructor( Preferences.NOTIFICATION_ACTION_READ -> { val intent = Intent(context, MarkReadReceiver::class.java).putExtra("threadId", threadId) val pi = PendingIntent.getBroadcast(context, threadId.toInt(), intent, - PendingIntent.FLAG_UPDATE_CURRENT) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) NotificationCompat.Action.Builder(R.drawable.ic_check_white_24dp, actionLabels[action], pi) .setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ).build() } @@ -271,7 +271,7 @@ class NotificationManagerImpl @Inject constructor( } else { val intent = Intent(context, QkReplyActivity::class.java).putExtra("threadId", threadId) val pi = PendingIntent.getActivity(context, threadId.toInt(), intent, - PendingIntent.FLAG_UPDATE_CURRENT) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) NotificationCompat.Action .Builder(R.drawable.ic_reply_white_24dp, actionLabels[action], pi) .setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_REPLY).build() @@ -283,7 +283,7 @@ class NotificationManagerImpl @Inject constructor( val intentAction = if (permissions.hasCalling()) Intent.ACTION_CALL else Intent.ACTION_DIAL val intent = Intent(intentAction, Uri.parse("tel:$address")) val pi = PendingIntent.getActivity(context, threadId.toInt(), intent, - PendingIntent.FLAG_UPDATE_CURRENT) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) NotificationCompat.Action.Builder(R.drawable.ic_call_white_24dp, actionLabels[action], pi) .setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_CALL).build() } @@ -337,7 +337,7 @@ class NotificationManagerImpl @Inject constructor( val taskStackBuilder = TaskStackBuilder.create(context) .addParentStack(ComposeActivity::class.java) .addNextIntent(contentIntent) - val contentPI = taskStackBuilder.getPendingIntent(threadId.toInt(), PendingIntent.FLAG_UPDATE_CURRENT) + val contentPI = taskStackBuilder.getPendingIntent(threadId.toInt(), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) val notification = NotificationCompat.Builder(context, getChannelIdForNotification(threadId)) .setContentTitle(context.getString(R.string.notification_message_failed_title)) @@ -357,7 +357,7 @@ class NotificationManagerImpl @Inject constructor( private fun getReplyAction(threadId: Long): NotificationCompat.Action { val replyIntent = Intent(context, RemoteMessagingReceiver::class.java).putExtra("threadId", threadId) val replyPI = PendingIntent.getBroadcast(context, threadId.toInt(), replyIntent, - PendingIntent.FLAG_UPDATE_CURRENT) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE) val title = context.resources.getStringArray(R.array.notification_actions)[ Preferences.NOTIFICATION_ACTION_REPLY] diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetProvider.kt b/presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetProvider.kt index 696823f16..bfa0525b6 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetProvider.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetProvider.kt @@ -140,17 +140,17 @@ class WidgetProvider : AppWidgetProvider() { // Main intent val mainIntent = Intent(context, MainActivity::class.java) - val mainPI = PendingIntent.getActivity(context, 0, mainIntent, PendingIntent.FLAG_UPDATE_CURRENT) + val mainPI = PendingIntent.getActivity(context, 0, mainIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) remoteViews.setOnClickPendingIntent(R.id.title, mainPI) // Compose intent val composeIntent = Intent(context, ComposeActivity::class.java) - val composePI = PendingIntent.getActivity(context, 0, composeIntent, PendingIntent.FLAG_UPDATE_CURRENT) + val composePI = PendingIntent.getActivity(context, 0, composeIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) remoteViews.setOnClickPendingIntent(R.id.compose, composePI) // Conversation intent val startActivityIntent = Intent(context, MainActivity::class.java) - val startActivityPendingIntent = PendingIntent.getActivity(context, 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT) + val startActivityPendingIntent = PendingIntent.getActivity(context, 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) remoteViews.setPendingIntentTemplate(R.id.conversations, startActivityPendingIntent) AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, remoteViews) -- GitLab From 3c8aad58218607e982f0ff9e90ac453300cff69c Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Mon, 12 Dec 2022 18:26:17 -0500 Subject: [PATCH 07/32] Add permissions for posting alarms and notifications --- presentation/src/main/AndroidManifest.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index fbf57deae..171f14d08 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -24,12 +24,14 @@ + + -- GitLab From ce9ba1b9f95da191d6c7d4a6334d9a485ce9f074 Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Mon, 12 Dec 2022 19:25:18 -0500 Subject: [PATCH 08/32] Export components --- presentation/src/main/AndroidManifest.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 171f14d08..7b94573f0 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -123,14 +123,14 @@ + android:exported="true"> + android:exported="true"> @@ -138,7 +138,7 @@ @@ -146,7 +146,7 @@ @@ -172,7 +172,7 @@ + android:exported="true"> @@ -181,7 +181,7 @@ + android:exported="true"> -- GitLab From 4f2d4954ede6426b9b682253926833dd61ec8c42 Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Mon, 12 Dec 2022 20:30:04 -0500 Subject: [PATCH 09/32] Remove obsolete checks for API 23 --- .../android/mms/service_alt/MmsConfig.java | 26 ++---- .../mms/service_alt/MmsConfigManager.java | 83 +++++++++---------- .../mms/service_alt/MmsNetworkManager.java | 17 ++-- .../android/mms/service_alt/MmsRequest.java | 20 +---- .../service_alt/SubscriptionIdChecker.java | 28 +++---- .../mms/transaction/TransactionService.java | 5 -- .../android/mms/pdu_alt/PduPersister.java | 4 +- .../android/send_message/SmsManagerFactory.kt | 2 +- .../klinker/android/send_message/Utils.java | 31 +------ .../com/moez/QKSMS/compat/TelephonyCompat.kt | 23 +---- .../QKSMS/compat/SubscriptionInfoCompat.kt | 1 - .../QKSMS/compat/SubscriptionManagerCompat.kt | 17 ++-- .../moez/QKSMS/manager/AlarmManagerImpl.kt | 6 +- .../QKSMS/repository/MessageRepositoryImpl.kt | 6 +- .../common/util/QkChooserTargetService.kt | 1 - .../common/util/extensions/ViewExtensions.kt | 3 - .../QKSMS/feature/compose/ComposeActivity.kt | 5 -- .../feature/compose/ComposeWindowCallback.kt | 2 - .../QKSMS/feature/compose/MessagesAdapter.kt | 4 +- .../feature/compose/editing/ChipsAdapter.kt | 5 -- .../feature/contacts/ContactsActivity.kt | 5 -- .../moez/QKSMS/feature/main/MainActivity.kt | 5 -- .../QKSMS/feature/qkreply/QkReplyActivity.kt | 9 -- .../src/main/res/values-night-v23/themes.xml | 27 ------ .../src/main/res/values-night/themes.xml | 4 +- .../src/main/res/values-v23/themes.xml | 28 ------- presentation/src/main/res/values/themes.xml | 5 +- 27 files changed, 89 insertions(+), 283 deletions(-) delete mode 100644 presentation/src/main/res/values-night-v23/themes.xml delete mode 100644 presentation/src/main/res/values-v23/themes.xml diff --git a/android-smsmms/src/main/java/com/android/mms/service_alt/MmsConfig.java b/android-smsmms/src/main/java/com/android/mms/service_alt/MmsConfig.java index 00eb2357a..597826ac2 100755 --- a/android-smsmms/src/main/java/com/android/mms/service_alt/MmsConfig.java +++ b/android-smsmms/src/main/java/com/android/mms/service_alt/MmsConfig.java @@ -551,15 +551,11 @@ public class MmsConfig { final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService( 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(); - } 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 = ""; - 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"); - } 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); diff --git a/android-smsmms/src/main/java/com/android/mms/service_alt/MmsConfigManager.java b/android-smsmms/src/main/java/com/android/mms/service_alt/MmsConfigManager.java index 1f1aca0ab..a95170df8 100755 --- a/android-smsmms/src/main/java/com/android/mms/service_alt/MmsConfigManager.java +++ b/android-smsmms/src/main/java/com/android/mms/service_alt/MmsConfigManager.java @@ -73,24 +73,19 @@ public class MmsConfigManager { public void init(final Context 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. - IntentFilter intentFilterLoaded = - new IntentFilter("LOADED"); + // TODO: When this object "finishes" we should unregister. + IntentFilter intentFilterLoaded = new IntentFilter("LOADED"); - try { - context.registerReceiver(mReceiver, intentFilterLoaded); - } catch (Exception e) { + try { + context.registerReceiver(mReceiver, intentFilterLoaded); + } catch (Exception e) { - } - - load(context); - } else { - load(context); } + load(context); + // TODO: When this object "finishes" we should unregister by invoking // SubscriptionManager.getInstance(mContext).unregister(mOnSubscriptionsChangedListener); // This is not strictly necessary because it will be unregistered if the @@ -151,39 +146,37 @@ public class MmsConfigManager { * */ private void load(Context context) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { - List subs = mSubscriptionManager.getActiveSubscriptionInfoList(); - if (subs == null || subs.size() < 1) { - Timber.e("MmsConfigManager.load -- empty getActiveSubInfoList"); - return; - } - // 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. - final Map newConfigMap = new ArrayMap(); - for (SubscriptionInfo sub : subs) { - Configuration configuration = new Configuration(); - if (sub.getMcc() == 0 && sub.getMnc() == 0) { - Configuration config = mContext.getResources().getConfiguration(); - configuration.mcc = config.mcc; - configuration.mnc = config.mnc; - Timber.i("MmsConfigManager.load -- no mcc/mnc for sub: " + sub + - " using mcc/mnc from main context: " + configuration.mcc + "/" + - configuration.mnc); - } else { - Timber.i("MmsConfigManager.load -- mcc/mnc for sub: " + sub); - - configuration.mcc = sub.getMcc(); - configuration.mnc = sub.getMnc(); - } - Context subContext = context.createConfigurationContext(configuration); - - int subId = sub.getSubscriptionId(); - newConfigMap.put(subId, new MmsConfig(subContext, subId)); - } - synchronized (mSubIdConfigMap) { - mSubIdConfigMap.clear(); - mSubIdConfigMap.putAll(newConfigMap); + List subs = mSubscriptionManager.getActiveSubscriptionInfoList(); + if (subs == null || subs.size() < 1) { + Timber.e("MmsConfigManager.load -- empty getActiveSubInfoList"); + return; + } + // 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. + final Map newConfigMap = new ArrayMap(); + for (SubscriptionInfo sub : subs) { + Configuration configuration = new Configuration(); + if (sub.getMcc() == 0 && sub.getMnc() == 0) { + Configuration config = mContext.getResources().getConfiguration(); + configuration.mcc = config.mcc; + configuration.mnc = config.mnc; + Timber.i("MmsConfigManager.load -- no mcc/mnc for sub: " + sub + + " using mcc/mnc from main context: " + configuration.mcc + "/" + + configuration.mnc); + } else { + Timber.i("MmsConfigManager.load -- mcc/mnc for sub: " + sub); + + configuration.mcc = sub.getMcc(); + configuration.mnc = sub.getMnc(); } + Context subContext = context.createConfigurationContext(configuration); + + int subId = sub.getSubscriptionId(); + newConfigMap.put(subId, new MmsConfig(subContext, subId)); + } + synchronized (mSubIdConfigMap) { + mSubIdConfigMap.clear(); + mSubIdConfigMap.putAll(newConfigMap); } } diff --git a/android-smsmms/src/main/java/com/android/mms/service_alt/MmsNetworkManager.java b/android-smsmms/src/main/java/com/android/mms/service_alt/MmsNetworkManager.java index ce3fe460e..e3092499d 100755 --- a/android-smsmms/src/main/java/com/android/mms/service_alt/MmsNetworkManager.java +++ b/android-smsmms/src/main/java/com/android/mms/service_alt/MmsNetworkManager.java @@ -87,18 +87,11 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network { mSubId = subId; if (!MmsRequest.useWifi(context)) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { - mNetworkRequest = new NetworkRequest.Builder() - .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) - .addCapability(NetworkCapabilities.NET_CAPABILITY_MMS) - .setNetworkSpecifier(Integer.toString(mSubId)) - .build(); - } else { - mNetworkRequest = new NetworkRequest.Builder() - .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) - .addCapability(NetworkCapabilities.NET_CAPABILITY_MMS) - .build(); - } + mNetworkRequest = new NetworkRequest.Builder() + .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) + .addCapability(NetworkCapabilities.NET_CAPABILITY_MMS) + .setNetworkSpecifier(Integer.toString(mSubId)) + .build(); } else { mNetworkRequest = new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) diff --git a/android-smsmms/src/main/java/com/android/mms/service_alt/MmsRequest.java b/android-smsmms/src/main/java/com/android/mms/service_alt/MmsRequest.java index 7ba80c072..a583060d1 100755 --- a/android-smsmms/src/main/java/com/android/mms/service_alt/MmsRequest.java +++ b/android-smsmms/src/main/java/com/android/mms/service_alt/MmsRequest.java @@ -104,12 +104,8 @@ public abstract class MmsRequest { private boolean ensureMmsConfigLoaded() { if (mMmsConfig == null) { final MmsConfig config; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { - // Not yet retrieved from mms config manager. Try getting it. - config = MmsConfigManager.getInstance().getMmsConfigBySubId(mSubId); - } else { - config = MmsConfigManager.getInstance().getMmsConfig(); - } + // Not yet retrieved from mms config manager. Try getting it. + config = MmsConfigManager.getInstance().getMmsConfigBySubId(mSubId); if (config != null) { mMmsConfig = new MmsConfig.Overridden(config, mMmsConfigOverrides); @@ -167,11 +163,7 @@ public abstract class MmsRequest { result = SmsManager.MMS_ERROR_IO_ERROR; } else if (!isDataNetworkAvailable(context, mSubId)) { 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; - } else { - result = 8; - } + result = SmsManager.MMS_ERROR_NO_DATA_NETWORK; } else { // Execute long retryDelaySecs = 2; // Try multiple times of MMS HTTP request @@ -268,11 +260,7 @@ public abstract class MmsRequest { fillIn.putExtra("uri", messageUri.toString()); } 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); - } else { - fillIn.putExtra("android.telephony.extra.MMS_HTTP_STATUS", httpStatusCode); - } + fillIn.putExtra(SmsManager.EXTRA_MMS_HTTP_STATUS, httpStatusCode); } try { if (!succeeded) { diff --git a/android-smsmms/src/main/java/com/android/mms/service_alt/SubscriptionIdChecker.java b/android-smsmms/src/main/java/com/android/mms/service_alt/SubscriptionIdChecker.java index afff0de0b..611b9509b 100755 --- a/android-smsmms/src/main/java/com/android/mms/service_alt/SubscriptionIdChecker.java +++ b/android-smsmms/src/main/java/com/android/mms/service_alt/SubscriptionIdChecker.java @@ -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. private void check(Context context) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { - Cursor c = null; - try { - c = SqliteWrapper.query(context, context.getContentResolver(), - Telephony.Mms.CONTENT_URI, - new String[]{Telephony.Mms.SUBSCRIPTION_ID}, null, null, null); - if (c != null) { - mCanUseSubscriptionId = true; - } - } catch (SQLiteException e) { - Timber.e("SubscriptionIdChecker.check() fail"); - } finally { - if (c != null) { - c.close(); - } + Cursor c = null; + try { + c = SqliteWrapper.query(context, context.getContentResolver(), + Telephony.Mms.CONTENT_URI, + new String[]{Telephony.Mms.SUBSCRIPTION_ID}, null, null, null); + if (c != null) { + mCanUseSubscriptionId = true; + } + } catch (SQLiteException e) { + Timber.e("SubscriptionIdChecker.check() fail"); + } finally { + if (c != null) { + c.close(); } } } diff --git a/android-smsmms/src/main/java/com/android/mms/transaction/TransactionService.java b/android-smsmms/src/main/java/com/android/mms/transaction/TransactionService.java index 78146c9ea..6344aec8c 100755 --- a/android-smsmms/src/main/java/com/android/mms/transaction/TransactionService.java +++ b/android-smsmms/src/main/java/com/android/mms/transaction/TransactionService.java @@ -539,11 +539,6 @@ public class TransactionService extends Service implements Observer { // cancel timer for renewal of lease mServiceHandler.removeMessages(EVENT_CONTINUE_MMS_CONNECTIVITY); - if (mConnMgr != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - mConnMgr.stopUsingNetworkFeature( - ConnectivityManager.TYPE_MOBILE, - "enableMMS"); - } } finally { releaseWakeLock(); } diff --git a/android-smsmms/src/main/java/com/google/android/mms/pdu_alt/PduPersister.java b/android-smsmms/src/main/java/com/google/android/mms/pdu_alt/PduPersister.java index 07bcb551f..10ea303eb 100755 --- a/android-smsmms/src/main/java/com/google/android/mms/pdu_alt/PduPersister.java +++ b/android-smsmms/src/main/java/com/google/android/mms/pdu_alt/PduPersister.java @@ -1604,8 +1604,6 @@ public class PduPersister { * Check if read permissions for SMS have been granted */ private boolean checkReadSmsPermissions() { - return Build.VERSION.SDK_INT < Build.VERSION_CODES.M || - mContext.checkSelfPermission(Manifest.permission.READ_SMS) == - PackageManager.PERMISSION_GRANTED; + return mContext.checkSelfPermission(Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED; } } diff --git a/android-smsmms/src/main/java/com/klinker/android/send_message/SmsManagerFactory.kt b/android-smsmms/src/main/java/com/klinker/android/send_message/SmsManagerFactory.kt index 10d078e43..2af11234c 100755 --- a/android-smsmms/src/main/java/com/klinker/android/send_message/SmsManagerFactory.kt +++ b/android-smsmms/src/main/java/com/klinker/android/send_message/SmsManagerFactory.kt @@ -8,7 +8,7 @@ object SmsManagerFactory { fun createSmsManager(subscriptionId: Int): SmsManager { var manager: SmsManager? = null - if (subscriptionId != -1 && Build.VERSION.SDK_INT >= 22) { + if (subscriptionId != -1) { try { manager = SmsManager.getSmsManagerForSubscriptionId(subscriptionId) } catch (e: Exception) { diff --git a/android-smsmms/src/main/java/com/klinker/android/send_message/Utils.java b/android-smsmms/src/main/java/com/klinker/android/send_message/Utils.java index 2fc446932..1b1f6b39b 100755 --- a/android-smsmms/src/main/java/com/klinker/android/send_message/Utils.java +++ b/android-smsmms/src/main/java/com/klinker/android/send_message/Utils.java @@ -59,14 +59,9 @@ public class Utils { } public static T ensureRouteToMmsNetwork(Context context, String url, String proxy, Task task) throws IOException { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - return ensureRouteToMmsNetworkMarshmallow(context, task); - } else { - return ensureRouteToMmsNetworkLollipop(context, task); - } + return ensureRouteToMmsNetworkMarshmallow(context, task); } - @TargetApi(Build.VERSION_CODES.M) private static T ensureRouteToMmsNetworkMarshmallow(Context context, Task task) throws IOException { final MmsNetworkManager networkManager = new MmsNetworkManager(context.getApplicationContext(), Utils.getDefaultSubscriptionId()); final ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); @@ -85,24 +80,6 @@ public class Utils { } } - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - private static T ensureRouteToMmsNetworkLollipop(Context context, Task 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 * @@ -381,10 +358,6 @@ public class Utils { } public static int getDefaultSubscriptionId() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { - return SmsManager.getDefaultSmsSubscriptionId(); - } else { - return DEFAULT_SUBSCRIPTION_ID; - } + return SmsManager.getDefaultSmsSubscriptionId(); } } diff --git a/common/src/main/java/com/moez/QKSMS/compat/TelephonyCompat.kt b/common/src/main/java/com/moez/QKSMS/compat/TelephonyCompat.kt index c8fa84bdb..9f88e83a1 100644 --- a/common/src/main/java/com/moez/QKSMS/compat/TelephonyCompat.kt +++ b/common/src/main/java/com/moez/QKSMS/compat/TelephonyCompat.kt @@ -42,28 +42,7 @@ object TelephonyCompat { } fun getOrCreateThreadId(context: Context, recipients: Collection): Long { - return if (Build.VERSION.SDK_INT >= 23) { - 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.") - } + return Telephony.Threads.getOrCreateThreadId(context, recipients.toSet()) } fun extractAddrSpec(address: String): String { diff --git a/data/src/main/java/com/moez/QKSMS/compat/SubscriptionInfoCompat.kt b/data/src/main/java/com/moez/QKSMS/compat/SubscriptionInfoCompat.kt index f6674e4c6..c18561b98 100644 --- a/data/src/main/java/com/moez/QKSMS/compat/SubscriptionInfoCompat.kt +++ b/data/src/main/java/com/moez/QKSMS/compat/SubscriptionInfoCompat.kt @@ -22,7 +22,6 @@ import android.annotation.TargetApi import android.os.Build import android.telephony.SubscriptionInfo -@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1) data class SubscriptionInfoCompat(private val subscriptionInfo: SubscriptionInfo) { val subscriptionId get() = subscriptionInfo.subscriptionId diff --git a/data/src/main/java/com/moez/QKSMS/compat/SubscriptionManagerCompat.kt b/data/src/main/java/com/moez/QKSMS/compat/SubscriptionManagerCompat.kt index fb6174ff4..4a2e4a2b3 100644 --- a/data/src/main/java/com/moez/QKSMS/compat/SubscriptionManagerCompat.kt +++ b/data/src/main/java/com/moez/QKSMS/compat/SubscriptionManagerCompat.kt @@ -31,36 +31,29 @@ class SubscriptionManagerCompat @Inject constructor(context: Context, private va val activeSubscriptionInfoList: List get() { - return if (Build.VERSION.SDK_INT >= 22) { - subscriptionManager?.activeSubscriptionInfoList?.map { SubscriptionInfoCompat(it) } ?: listOf() - } else listOf() + return subscriptionManager?.activeSubscriptionInfoList?.map { SubscriptionInfoCompat(it) } ?: listOf() } init { - subscriptionManager = if (Build.VERSION.SDK_INT >= 22) SubscriptionManager.from(context) else null + subscriptionManager = SubscriptionManager.from(context) } fun addOnSubscriptionsChangedListener(listener: OnSubscriptionsChangedListener) { - if (Build.VERSION.SDK_INT >= 22) { - subscriptionManager?.addOnSubscriptionsChangedListener(listener.listener) - } + subscriptionManager?.addOnSubscriptionsChangedListener(listener.listener) } fun removeOnSubscriptionsChangedListener(listener: OnSubscriptionsChangedListener) { - if (Build.VERSION.SDK_INT >= 22) { - subscriptionManager?.removeOnSubscriptionsChangedListener(listener.listener) - } + subscriptionManager?.removeOnSubscriptionsChangedListener(listener.listener) } abstract class OnSubscriptionsChangedListener { - val listener: SubscriptionManager.OnSubscriptionsChangedListener? = if (Build.VERSION.SDK_INT >= 22) { + val listener: SubscriptionManager.OnSubscriptionsChangedListener? = object : SubscriptionManager.OnSubscriptionsChangedListener() { override fun onSubscriptionsChanged() { this@OnSubscriptionsChangedListener.onSubscriptionsChanged() } } - } else null abstract fun onSubscriptionsChanged() diff --git a/data/src/main/java/com/moez/QKSMS/manager/AlarmManagerImpl.kt b/data/src/main/java/com/moez/QKSMS/manager/AlarmManagerImpl.kt index a41f6119b..1d9280421 100644 --- a/data/src/main/java/com/moez/QKSMS/manager/AlarmManagerImpl.kt +++ b/data/src/main/java/com/moez/QKSMS/manager/AlarmManagerImpl.kt @@ -34,11 +34,7 @@ class AlarmManagerImpl @Inject constructor(private val context: Context) : Alarm override fun setAlarm(date: Long, intent: PendingIntent) { 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) - } else { - alarmManager.setExact(android.app.AlarmManager.RTC_WAKEUP, date, intent) - } + alarmManager.setExactAndAllowWhileIdle(android.app.AlarmManager.RTC_WAKEUP, date, intent) } } \ No newline at end of file diff --git a/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt b/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt index 006598923..207e5415a 100644 --- a/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt +++ b/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt @@ -328,11 +328,7 @@ class MessageRepositoryImpl @Inject constructor( val intent = getIntentForDelayedSms(message.id) 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) - } else { - alarmManager.setExact(AlarmManager.RTC_WAKEUP, sendTime, intent) - } + alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, sendTime, intent) } else { // No delay val message = insertSentSms(subId, threadId, addresses.first(), strippedBody, now()) sendSms(message) diff --git a/presentation/src/main/java/com/moez/QKSMS/common/util/QkChooserTargetService.kt b/presentation/src/main/java/com/moez/QKSMS/common/util/QkChooserTargetService.kt index 13cd86b0c..84e141bf7 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/util/QkChooserTargetService.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/util/QkChooserTargetService.kt @@ -35,7 +35,6 @@ import com.moez.QKSMS.util.GlideApp import com.moez.QKSMS.util.tryOrNull import javax.inject.Inject -@RequiresApi(Build.VERSION_CODES.M) class QkChooserTargetService : ChooserTargetService() { @Inject lateinit var conversationRepo: ConversationRepository diff --git a/presentation/src/main/java/com/moez/QKSMS/common/util/extensions/ViewExtensions.kt b/presentation/src/main/java/com/moez/QKSMS/common/util/extensions/ViewExtensions.kt index f2bf92d17..862f27b31 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/util/extensions/ViewExtensions.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/util/extensions/ViewExtensions.kt @@ -63,9 +63,6 @@ fun ProgressBar.setTint(color: Int) { fun View.setBackgroundTint(color: Int) { // 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) } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt index 1993c4b79..1918fb9c1 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt @@ -155,11 +155,6 @@ class ComposeActivity : QkThemedActivity(), ComposeView { .subscribe() 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() { diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeWindowCallback.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeWindowCallback.kt index c3fac4b97..494b6e5bc 100755 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeWindowCallback.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeWindowCallback.kt @@ -123,7 +123,6 @@ class ComposeWindowCallback( return localCallback.onSearchRequested() } - @RequiresApi(api = Build.VERSION_CODES.M) override fun onSearchRequested(searchEvent: SearchEvent): Boolean { return localCallback.onSearchRequested(searchEvent) } @@ -132,7 +131,6 @@ class ComposeWindowCallback( return localCallback.onWindowStartingActionMode(callback) } - @RequiresApi(api = Build.VERSION_CODES.M) override fun onWindowStartingActionMode(callback: ActionMode.Callback, i: Int): ActionMode? { return localCallback.onWindowStartingActionMode(callback, i) } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt index d892224b6..5576352fd 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt @@ -152,9 +152,7 @@ class MessagesAdapter @Inject constructor( 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() partsAdapter.clicks.subscribe(partClicks) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/editing/ChipsAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/editing/ChipsAdapter.kt index b415d32f3..b81a1a980 100755 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/editing/ChipsAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/editing/ChipsAdapter.kt @@ -44,11 +44,6 @@ class ChipsAdapter @Inject constructor() : QkAdapter() { val inflater = LayoutInflater.from(parent.context) val view = inflater.inflate(R.layout.contact_chip, parent, false) 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 { val chip = getItem(adapterPosition) showDetailedChip(view.context, chip) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/contacts/ContactsActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/contacts/ContactsActivity.kt index f5ca9f71d..58f1db08d 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/contacts/ContactsActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/contacts/ContactsActivity.kt @@ -88,11 +88,6 @@ class ContactsActivity : QkThemedActivity(), ContactsContract { viewModel.bindView(this) 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) { diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt index 362f66a6d..e84c758c1 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt @@ -185,11 +185,6 @@ class MainActivity : QkThemedActivity(), MainView { // Set the FAB compose icon color 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?) { diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/qkreply/QkReplyActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/qkreply/QkReplyActivity.kt index 392196d41..f8fec2ae3 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/qkreply/QkReplyActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/qkreply/QkReplyActivity.kt @@ -74,15 +74,6 @@ class QkReplyActivity : QkThemedActivity(), QkReplyView { messages.adapter?.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { 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) { diff --git a/presentation/src/main/res/values-night-v23/themes.xml b/presentation/src/main/res/values-night-v23/themes.xml deleted file mode 100644 index 3adbc7c01..000000000 --- a/presentation/src/main/res/values-night-v23/themes.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - diff --git a/presentation/src/main/res/values-night/themes.xml b/presentation/src/main/res/values-night/themes.xml index b26faa8b7..51338febb 100644 --- a/presentation/src/main/res/values-night/themes.xml +++ b/presentation/src/main/res/values-night/themes.xml @@ -19,7 +19,9 @@ --> - - - diff --git a/presentation/src/main/res/values/themes.xml b/presentation/src/main/res/values/themes.xml index 16db69160..2ced1618c 100644 --- a/presentation/src/main/res/values/themes.xml +++ b/presentation/src/main/res/values/themes.xml @@ -31,7 +31,10 @@ @color/backgroundDark -