compileSdkVersion 30

This commit is contained in:
Milos Kozak 2021-08-06 00:08:49 +02:00
parent 776d85ec90
commit 0e928bbb9c
11 changed files with 29 additions and 31 deletions

View file

@ -63,7 +63,7 @@ class LoopDialog : DaggerDialogFragment() {
private var showOkCancel: Boolean = true private var showOkCancel: Boolean = true
private var _binding: DialogLoopBinding? = null private var _binding: DialogLoopBinding? = null
private var loopHandler = Handler() private var loopHandler = Handler()
private var refreshDialog: Runnable? = null private lateinit var refreshDialog: Runnable
// This property is only valid between onCreateView and // This property is only valid between onCreateView and
// onDestroyView. // onDestroyView.
@ -415,7 +415,7 @@ class LoopDialog : DaggerDialogFragment() {
it.commitAllowingStateLoss() it.commitAllowingStateLoss()
} }
} catch (e: IllegalStateException) { } catch (e: IllegalStateException) {
aapsLogger.debug(e.localizedMessage) aapsLogger.debug(e.localizedMessage ?: e.toString())
} }
} }
} }

View file

@ -119,7 +119,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
private var smallHeight = false private var smallHeight = false
private lateinit var dm: DisplayMetrics private lateinit var dm: DisplayMetrics
private var axisWidth: Int = 0 private var axisWidth: Int = 0
private var refreshLoop: Runnable? = null private lateinit var refreshLoop: Runnable
private lateinit var handler: Handler private lateinit var handler: Handler
private val secondaryGraphs = ArrayList<GraphView>() private val secondaryGraphs = ArrayList<GraphView>()
@ -583,9 +583,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
task = null task = null
} }
} }
handler.removeCallbacks(task) task?.let { handler.removeCallbacks(it) }
task = UpdateRunnable() task = UpdateRunnable()
handler.postDelayed(task, 500) task?.let { handler.postDelayed(it, 500) }
} }
@Suppress("UNUSED_PARAMETER") @Suppress("UNUSED_PARAMETER")

View file

@ -88,7 +88,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() {
Runnable { Runnable {
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip = ClipData.newPlainText("OTP Secret", otp.provisioningSecret()) 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)) ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_export_successful))
uel.log(Action.OTP_EXPORT, Sources.SMS) uel.log(Action.OTP_EXPORT, Sources.SMS)
}) })

View file

@ -13,7 +13,7 @@ class BTReceiver : DaggerBroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
super.onReceive(context, 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) { when (intent.action) {
BluetoothDevice.ACTION_ACL_CONNECTED -> BluetoothDevice.ACTION_ACL_CONNECTED ->

View file

@ -20,8 +20,8 @@ class ActivityMonitor @Inject constructor(
private val dateUtil: DateUtil private val dateUtil: DateUtil
) : Application.ActivityLifecycleCallbacks { ) : Application.ActivityLifecycleCallbacks {
override fun onActivityPaused(activity: Activity?) { override fun onActivityPaused(activity: Activity) {
val name = activity?.javaClass?.simpleName ?: return val name = activity.javaClass.simpleName
val resumed = sp.getLong("Monitor_" + name + "_" + "resumed", 0) val resumed = sp.getLong("Monitor_" + name + "_" + "resumed", 0)
if (resumed == 0L) { if (resumed == 0L) {
aapsLogger.debug(LTag.UI, "onActivityPaused: $name resumed == 0") 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}") aapsLogger.debug(LTag.UI, "onActivityPaused: $name elapsed=$elapsed total=${total + elapsed}")
} }
override fun onActivityResumed(activity: Activity?) { override fun onActivityResumed(activity: Activity) {
val name = activity?.javaClass?.simpleName ?: return val name = activity.javaClass.simpleName
aapsLogger.debug(LTag.UI, "onActivityResumed: $name") aapsLogger.debug(LTag.UI, "onActivityResumed: $name")
sp.putLong("Monitor_" + name + "_" + "resumed", dateUtil.now()) 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 { private fun toText(): String {

View file

@ -148,16 +148,14 @@ class LocationService : DaggerService() {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
if (locationManager != null) {
try { try {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return return
} }
locationManager!!.removeUpdates(locationListener) locationListener?.let { locationManager?.removeUpdates(it) }
} catch (ex: Exception) { } catch (ex: Exception) {
aapsLogger.error(LTag.LOCATION, "fail to remove location listener, ignore", ex) aapsLogger.error(LTag.LOCATION, "fail to remove location listener, ignore", ex)
} }
}
disposable.clear() disposable.clear()
} }

View file

@ -87,7 +87,7 @@ dependencies {
api 'com.google.android.gms:play-services-wearable:17.0.0' 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.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") { api("io.socket:socket.io-client:1.0.0") {
// excluding org.json which is provided by Android // excluding org.json which is provided by Android
exclude group: "org.json", module: "json" exclude group: "org.json", module: "json"

View file

@ -25,13 +25,13 @@ class ErrorHelperActivity : DialogAppCompatActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val errorDialog = ErrorDialog() val errorDialog = ErrorDialog()
errorDialog.helperActivity = this errorDialog.helperActivity = this
errorDialog.status = intent.getStringExtra(STATUS) errorDialog.status = intent.getStringExtra(STATUS) ?: ""
errorDialog.sound = intent.getIntExtra(SOUND_ID, R.raw.error) errorDialog.sound = intent.getIntExtra(SOUND_ID, R.raw.error)
errorDialog.title = intent.getStringExtra(TITLE) errorDialog.title = intent.getStringExtra(TITLE)?: ""
errorDialog.show(supportFragmentManager, "Error") errorDialog.show(supportFragmentManager, "Error")
if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) 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 { companion object {

View file

@ -50,7 +50,7 @@ object LocaleHelper {
configuration.setLocale(newLocale) configuration.setLocale(newLocale)
val localeList = LocaleList(newLocale) val localeList = LocaleList(newLocale)
LocaleList.setDefault(localeList) LocaleList.setDefault(localeList)
configuration.locales = localeList configuration.setLocales(localeList)
val context = ctx.createConfigurationContext(configuration) val context = ctx.createConfigurationContext(configuration)
return ContextWrapper(context) return ContextWrapper(context)
} }

View file

@ -1,5 +1,5 @@
android { android {
compileSdkVersion 28 compileSdkVersion 30
defaultConfig { defaultConfig {
minSdkVersion 26 minSdkVersion 26
targetSdkVersion 28 targetSdkVersion 28

View file

@ -46,7 +46,7 @@ def generateGitBuild = { ->
} }
android { android {
compileSdkVersion 28 compileSdkVersion 30
defaultConfig { defaultConfig {
applicationId "info.nightscout.androidaps" applicationId "info.nightscout.androidaps"