From 0e928bbb9c2a5250b34aea109fc4d7b7aa836e17 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 6 Aug 2021 00:08:49 +0200 Subject: [PATCH] compileSdkVersion 30 --- .../androidaps/dialogs/LoopDialog.kt | 4 ++-- .../general/overview/OverviewFragment.kt | 6 +++--- .../activities/SmsCommunicatorOtpActivity.kt | 2 +- .../androidaps/receivers/BTReceiver.kt | 2 +- .../androidaps/utils/ActivityMonitor.kt | 18 +++++++++--------- .../androidaps/services/LocationService.kt | 14 ++++++-------- core/core_dependencies.gradle | 2 +- .../activities/ErrorHelperActivity.kt | 6 +++--- .../androidaps/utils/locale/LocaleHelper.kt | 2 +- gradle/android_dependencies.gradle | 2 +- wear/build.gradle | 2 +- 11 files changed, 29 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt index 493656f1cf..7bacb0120b 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -63,7 +63,7 @@ class LoopDialog : DaggerDialogFragment() { private var showOkCancel: Boolean = true private var _binding: DialogLoopBinding? = null private var loopHandler = Handler() - private var refreshDialog: Runnable? = null + private lateinit var refreshDialog: Runnable // This property is only valid between onCreateView and // onDestroyView. @@ -415,7 +415,7 @@ class LoopDialog : DaggerDialogFragment() { it.commitAllowingStateLoss() } } catch (e: IllegalStateException) { - aapsLogger.debug(e.localizedMessage) + aapsLogger.debug(e.localizedMessage ?: e.toString()) } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index b387a74495..7c76aa568a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -119,7 +119,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList private var smallHeight = false private lateinit var dm: DisplayMetrics private var axisWidth: Int = 0 - private var refreshLoop: Runnable? = null + private lateinit var refreshLoop: Runnable private lateinit var handler: Handler private val secondaryGraphs = ArrayList() @@ -583,9 +583,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList task = null } } - handler.removeCallbacks(task) + task?.let { handler.removeCallbacks(it) } task = UpdateRunnable() - handler.postDelayed(task, 500) + task?.let { handler.postDelayed(it, 500) } } @Suppress("UNUSED_PARAMETER") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt index bc81bc1f7d..f227a205db 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt @@ -88,7 +88,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() { Runnable { val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager val clip = ClipData.newPlainText("OTP Secret", otp.provisioningSecret()) - clipboard.primaryClip = clip + clipboard.setPrimaryClip(clip) ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_export_successful)) uel.log(Action.OTP_EXPORT, Sources.SMS) }) diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/BTReceiver.kt b/app/src/main/java/info/nightscout/androidaps/receivers/BTReceiver.kt index 37a135b44f..63485fce7b 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/BTReceiver.kt +++ b/app/src/main/java/info/nightscout/androidaps/receivers/BTReceiver.kt @@ -13,7 +13,7 @@ class BTReceiver : DaggerBroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { super.onReceive(context, intent) - val device: BluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE) + val device: BluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE) ?: return when (intent.action) { BluetoothDevice.ACTION_ACL_CONNECTED -> diff --git a/app/src/main/java/info/nightscout/androidaps/utils/ActivityMonitor.kt b/app/src/main/java/info/nightscout/androidaps/utils/ActivityMonitor.kt index 313d82308b..8f45f00b98 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/ActivityMonitor.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/ActivityMonitor.kt @@ -20,8 +20,8 @@ class ActivityMonitor @Inject constructor( private val dateUtil: DateUtil ) : Application.ActivityLifecycleCallbacks { - override fun onActivityPaused(activity: Activity?) { - val name = activity?.javaClass?.simpleName ?: return + override fun onActivityPaused(activity: Activity) { + val name = activity.javaClass.simpleName val resumed = sp.getLong("Monitor_" + name + "_" + "resumed", 0) if (resumed == 0L) { aapsLogger.debug(LTag.UI, "onActivityPaused: $name resumed == 0") @@ -36,25 +36,25 @@ class ActivityMonitor @Inject constructor( aapsLogger.debug(LTag.UI, "onActivityPaused: $name elapsed=$elapsed total=${total + elapsed}") } - override fun onActivityResumed(activity: Activity?) { - val name = activity?.javaClass?.simpleName ?: return + override fun onActivityResumed(activity: Activity) { + val name = activity.javaClass.simpleName aapsLogger.debug(LTag.UI, "onActivityResumed: $name") sp.putLong("Monitor_" + name + "_" + "resumed", dateUtil.now()) } - override fun onActivityStarted(activity: Activity?) { + override fun onActivityStarted(activity: Activity) { } - override fun onActivityDestroyed(activity: Activity?) { + override fun onActivityDestroyed(activity: Activity) { } - override fun onActivitySaveInstanceState(activity: Activity?, outState: Bundle?) { + override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) { } - override fun onActivityStopped(activity: Activity?) { + override fun onActivityStopped(activity: Activity) { } - override fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?) { + override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } private fun toText(): String { diff --git a/automation/src/main/java/info/nightscout/androidaps/services/LocationService.kt b/automation/src/main/java/info/nightscout/androidaps/services/LocationService.kt index 9f5063be77..bd293160db 100644 --- a/automation/src/main/java/info/nightscout/androidaps/services/LocationService.kt +++ b/automation/src/main/java/info/nightscout/androidaps/services/LocationService.kt @@ -148,15 +148,13 @@ class LocationService : DaggerService() { override fun onDestroy() { super.onDestroy() - if (locationManager != null) { - try { - if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - return - } - locationManager!!.removeUpdates(locationListener) - } catch (ex: Exception) { - aapsLogger.error(LTag.LOCATION, "fail to remove location listener, ignore", ex) + try { + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + return } + locationListener?.let { locationManager?.removeUpdates(it) } + } catch (ex: Exception) { + aapsLogger.error(LTag.LOCATION, "fail to remove location listener, ignore", ex) } disposable.clear() } diff --git a/core/core_dependencies.gradle b/core/core_dependencies.gradle index 6fa2e179f9..8e261738bb 100644 --- a/core/core_dependencies.gradle +++ b/core/core_dependencies.gradle @@ -87,7 +87,7 @@ dependencies { api 'com.google.android.gms:play-services-wearable:17.0.0' api 'com.google.android.gms:play-services-location:17.1.0' - api("com.google.android:flexbox:2.0.1") + api 'com.google.android.flexbox:flexbox:3.0.0' api("io.socket:socket.io-client:1.0.0") { // excluding org.json which is provided by Android exclude group: "org.json", module: "json" diff --git a/core/src/main/java/info/nightscout/androidaps/activities/ErrorHelperActivity.kt b/core/src/main/java/info/nightscout/androidaps/activities/ErrorHelperActivity.kt index 0fc25ff143..93b6dc14e0 100644 --- a/core/src/main/java/info/nightscout/androidaps/activities/ErrorHelperActivity.kt +++ b/core/src/main/java/info/nightscout/androidaps/activities/ErrorHelperActivity.kt @@ -25,13 +25,13 @@ class ErrorHelperActivity : DialogAppCompatActivity() { super.onCreate(savedInstanceState) val errorDialog = ErrorDialog() errorDialog.helperActivity = this - errorDialog.status = intent.getStringExtra(STATUS) + errorDialog.status = intent.getStringExtra(STATUS) ?: "" errorDialog.sound = intent.getIntExtra(SOUND_ID, R.raw.error) - errorDialog.title = intent.getStringExtra(TITLE) + errorDialog.title = intent.getStringExtra(TITLE)?: "" errorDialog.show(supportFragmentManager, "Error") if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) - disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(intent.getStringExtra(STATUS))).subscribe() + disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(intent.getStringExtra(STATUS) ?: "")).subscribe() } companion object { diff --git a/core/src/main/java/info/nightscout/androidaps/utils/locale/LocaleHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/locale/LocaleHelper.kt index 29d53e1e53..43da5e85c5 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/locale/LocaleHelper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/locale/LocaleHelper.kt @@ -50,7 +50,7 @@ object LocaleHelper { configuration.setLocale(newLocale) val localeList = LocaleList(newLocale) LocaleList.setDefault(localeList) - configuration.locales = localeList + configuration.setLocales(localeList) val context = ctx.createConfigurationContext(configuration) return ContextWrapper(context) } diff --git a/gradle/android_dependencies.gradle b/gradle/android_dependencies.gradle index b3b28c7edc..264cf88b77 100644 --- a/gradle/android_dependencies.gradle +++ b/gradle/android_dependencies.gradle @@ -1,5 +1,5 @@ android { - compileSdkVersion 28 + compileSdkVersion 30 defaultConfig { minSdkVersion 26 targetSdkVersion 28 diff --git a/wear/build.gradle b/wear/build.gradle index b18138cb08..4850000964 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -46,7 +46,7 @@ def generateGitBuild = { -> } android { - compileSdkVersion 28 + compileSdkVersion 30 defaultConfig { applicationId "info.nightscout.androidaps"