From f22b115736e88471e58f25101b5a282b799246ca Mon Sep 17 00:00:00 2001 From: Dmitriy Krivoruchko Date: Thu, 18 Nov 2021 11:22:54 +0200 Subject: [PATCH] Bug fix, dependency update --- app/build.gradle | 16 +++++++++------- .../info/dvkr/screenstream/ScreenStreamApp.kt | 11 +++++++++++ .../info/dvkr/screenstream/ScreenStreamApp.kt | 11 +++++++++++ .../info/dvkr/screenstream/service/AppService.kt | 2 +- .../ui/fragment/SettingsImageFragment.kt | 10 +++++----- .../screenstream/ui/fragment/StreamFragment.kt | 4 +--- build.gradle | 2 +- data/build.gradle | 5 +++-- 8 files changed, 42 insertions(+), 19 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index af5cb5a9..4b26d2df 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,8 +12,8 @@ android { applicationId = "info.dvkr.screenstream" minSdkVersion(21) targetSdkVersion(31) - versionCode = 30803 - versionName = "3.8.3" + versionCode = 30804 + versionName = "3.8.4" resConfigs("en", "ru", "pt-rBR", "zh-rTW", "fr-rFR", "fa", "it", "pl", "hi", "de", "sk", "es", "ar", "ja", "gl", "ca", "uk", "nl") vectorDrawables.useSupportLibrary = true @@ -21,6 +21,7 @@ android { buildTypes { getByName("debug") { + applicationIdSuffix ".dev" minifyEnabled = false shrinkResources = false proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") @@ -81,6 +82,7 @@ android { kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8.toString() + freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" } } @@ -94,15 +96,15 @@ dependencies { implementation("androidx.core:core-ktx:1.7.0") implementation("androidx.activity:activity-ktx:1.4.0") - implementation("androidx.fragment:fragment-ktx:1.4.0-beta01") + implementation("androidx.fragment:fragment-ktx:1.4.0") implementation("androidx.appcompat:appcompat:1.4.0-rc01") implementation("androidx.constraintlayout:constraintlayout:2.1.1") implementation("androidx.recyclerview:recyclerview:1.2.1") implementation("com.google.android.material:material:1.4.0") - implementation("androidx.window:window:1.0.0-beta03") + implementation("androidx.window:window:1.0.0-beta04") - implementation("androidx.navigation:navigation-fragment-ktx:2.4.0-beta01") - implementation("androidx.navigation:navigation-ui-ktx:2.4.0-beta01") + implementation("androidx.navigation:navigation-fragment-ktx:2.4.0-beta02") + implementation("androidx.navigation:navigation-ui-ktx:2.4.0-beta02") implementation("androidx.lifecycle:lifecycle-livedata:2.4.0") implementation("androidx.lifecycle:lifecycle-common:2.4.0") @@ -128,7 +130,7 @@ dependencies { firebaseImplementation("com.google.firebase:firebase-analytics:20.0.0") firebaseImplementation("com.google.firebase:firebase-crashlytics:18.2.4") firebaseImplementation("com.google.android.gms:play-services-ads:20.4.0") - firebaseImplementation("androidx.work:work-runtime:2.7.0") // Temp fix for AdMob Android 12 + firebaseImplementation("androidx.work:work-runtime:2.7.1") // Temp fix for AdMob Android 12 debugImplementation("com.squareup.leakcanary:leakcanary-android:2.7") } diff --git a/app/src/firebaseDebug/kotlin/info/dvkr/screenstream/ScreenStreamApp.kt b/app/src/firebaseDebug/kotlin/info/dvkr/screenstream/ScreenStreamApp.kt index 114d19f5..f5a8bde1 100644 --- a/app/src/firebaseDebug/kotlin/info/dvkr/screenstream/ScreenStreamApp.kt +++ b/app/src/firebaseDebug/kotlin/info/dvkr/screenstream/ScreenStreamApp.kt @@ -1,6 +1,7 @@ package info.dvkr.screenstream import android.os.StrictMode +import androidx.fragment.app.strictmode.FragmentStrictMode import com.elvishew.xlog.LogConfiguration import com.elvishew.xlog.XLog import com.elvishew.xlog.printer.AndroidPrinter @@ -26,6 +27,16 @@ class ScreenStreamApp : BaseApp() { .build() ) + FragmentStrictMode.defaultPolicy = + FragmentStrictMode.Policy.Builder() + .detectFragmentReuse() + .detectFragmentTagUsage() + .detectRetainInstanceUsage() + .detectSetUserVisibleHint() + .detectTargetFragmentUsage() + .detectWrongFragmentContainer() + .build() + val logConfiguration = LogConfiguration.Builder().tag("SSApp").build() XLog.init(logConfiguration, AndroidPrinter(), filePrinter) } diff --git a/app/src/firebasefreeDebug/kotlin/info/dvkr/screenstream/ScreenStreamApp.kt b/app/src/firebasefreeDebug/kotlin/info/dvkr/screenstream/ScreenStreamApp.kt index 0a3a10d4..6d03f11e 100644 --- a/app/src/firebasefreeDebug/kotlin/info/dvkr/screenstream/ScreenStreamApp.kt +++ b/app/src/firebasefreeDebug/kotlin/info/dvkr/screenstream/ScreenStreamApp.kt @@ -1,6 +1,7 @@ package info.dvkr.screenstream import android.os.StrictMode +import androidx.fragment.app.strictmode.FragmentStrictMode import com.elvishew.xlog.LogConfiguration import com.elvishew.xlog.XLog import com.elvishew.xlog.printer.AndroidPrinter @@ -25,6 +26,16 @@ class ScreenStreamApp : BaseApp() { .build() ) + FragmentStrictMode.defaultPolicy = + FragmentStrictMode.Policy.Builder() + .detectFragmentReuse() + .detectFragmentTagUsage() + .detectRetainInstanceUsage() + .detectSetUserVisibleHint() + .detectTargetFragmentUsage() + .detectWrongFragmentContainer() + .build() + val logConfiguration = LogConfiguration.Builder().tag("SSApp").build() XLog.init(logConfiguration, AndroidPrinter(), filePrinter) } diff --git a/app/src/main/kotlin/info/dvkr/screenstream/service/AppService.kt b/app/src/main/kotlin/info/dvkr/screenstream/service/AppService.kt index 32ac7667..0f72c750 100644 --- a/app/src/main/kotlin/info/dvkr/screenstream/service/AppService.kt +++ b/app/src/main/kotlin/info/dvkr/screenstream/service/AppService.kt @@ -206,7 +206,7 @@ class AppService : Service() { override fun onDestroy() { XLog.d(getLog("onDestroy")) isRunning = false - runBlocking(coroutineScope.coroutineContext) { appStateMachine?.destroy() } + runBlocking(coroutineScope.coroutineContext) { withTimeout(2000) { appStateMachine?.destroy() } } appStateMachine = null coroutineScope.cancel(CancellationException("AppService.destroy")) stopForeground(true) diff --git a/app/src/main/kotlin/info/dvkr/screenstream/ui/fragment/SettingsImageFragment.kt b/app/src/main/kotlin/info/dvkr/screenstream/ui/fragment/SettingsImageFragment.kt index b53b35ea..95376632 100644 --- a/app/src/main/kotlin/info/dvkr/screenstream/ui/fragment/SettingsImageFragment.kt +++ b/app/src/main/kotlin/info/dvkr/screenstream/ui/fragment/SettingsImageFragment.kt @@ -183,7 +183,7 @@ class SettingsImageFragment : Fragment(R.layout.fragment_settings_image) { with(tietDialogSettingsResize) { addTextChangedListener(SimpleTextWatcher { text -> - val isValid = text.length in 2..3 && text.toString().toInt() in 10..150 + val isValid = text.length in 2..3 && text.toString().toIntOrNull() ?: -1 in 10..150 this@Dialog.setActionButtonEnabled(WhichButton.POSITIVE, isValid) val newResizeFactor = (if (isValid) text.toString().toInt() else settings.resizeFactor) / 100f @@ -303,10 +303,10 @@ class SettingsImageFragment : Fragment(R.layout.fragment_settings_image) { dialog: MaterialDialog, topView: EditText, bottomView: EditText, leftView: EditText, rightView: EditText, errorView: TextView ) { - val topCrop = topView.text.let { if (it.isNullOrBlank()) -1 else it.toString().toInt() } - val bottomCrop = bottomView.text.let { if (it.isNullOrBlank()) -1 else it.toString().toInt() } - val leftCrop = leftView.text.let { if (it.isNullOrBlank()) -1 else it.toString().toInt() } - val rightCrop = rightView.text.let { if (it.isNullOrBlank()) -1 else it.toString().toInt() } + val topCrop = topView.text.let { if (it.isNullOrBlank()) -1 else it.toString().toIntOrNull() ?: -1 } + val bottomCrop = bottomView.text.let { if (it.isNullOrBlank()) -1 else it.toString().toIntOrNull() ?: -1 } + val leftCrop = leftView.text.let { if (it.isNullOrBlank()) -1 else it.toString().toIntOrNull() ?: -1 } + val rightCrop = rightView.text.let { if (it.isNullOrBlank()) -1 else it.toString().toIntOrNull() ?: -1 } if (topCrop >= 0 && bottomCrop >= 0 && leftCrop >= 0 && rightCrop >= 0) { dialog.setActionButtonEnabled(WhichButton.POSITIVE, true) diff --git a/app/src/main/kotlin/info/dvkr/screenstream/ui/fragment/StreamFragment.kt b/app/src/main/kotlin/info/dvkr/screenstream/ui/fragment/StreamFragment.kt index e8fab13a..e75c4a0d 100644 --- a/app/src/main/kotlin/info/dvkr/screenstream/ui/fragment/StreamFragment.kt +++ b/app/src/main/kotlin/info/dvkr/screenstream/ui/fragment/StreamFragment.kt @@ -114,9 +114,7 @@ class StreamFragment : AdFragment(R.layout.fragment_stream) { clipboard?.setPrimaryClip( ClipData.newPlainText(tvItemDeviceAddress.text, tvItemDeviceAddress.text) ) - Toast.makeText( - requireContext().applicationContext, R.string.stream_fragment_copied, Toast.LENGTH_LONG - ).show() + Toast.makeText(requireContext(), R.string.stream_fragment_copied, Toast.LENGTH_LONG).show() } ivItemDeviceAddressShare.setOnClickListener { shareAddress(fullAddress) } ivItemDeviceAddressQr.setOnClickListener { showQrCode(fullAddress) } diff --git a/build.gradle b/build.gradle index 46af2fda..9ce411c2 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { dependencies { classpath("com.android.tools.build:gradle:7.0.3") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0") classpath("com.google.gms:google-services:4.3.10") classpath("com.google.firebase:firebase-crashlytics-gradle:2.8.0") } diff --git a/data/build.gradle b/data/build.gradle index e8dd2451..c5f8f4bd 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -21,15 +21,16 @@ android { kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8.toString() + freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" } } dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2") - implementation("org.jetbrains.kotlin:kotlin-reflect:1.5.31") + implementation("org.jetbrains.kotlin:kotlin-reflect:1.6.0") implementation("androidx.core:core:1.7.0") - implementation("androidx.window:window:1.0.0-beta03") + implementation("androidx.window:window:1.0.0-beta04") implementation("io.ktor:ktor-server-cio:1.6.5")