diff --git a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt index 7467304b22..f4c9584e58 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt @@ -236,7 +236,8 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang if (filter != "") updateFilterVisibility(filter, preferenceScreen) } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + key ?: return rxBus.send(EventPreferenceChange(key)) if (key == rh.gs(info.nightscout.core.ui.R.string.key_language)) { rxBus.send(EventRebuildTabs(true)) diff --git a/core/main/android_dependencies.gradle b/core/main/android_dependencies.gradle index 4250b6d567..b89931830f 100644 --- a/core/main/android_dependencies.gradle +++ b/core/main/android_dependencies.gradle @@ -1,5 +1,5 @@ android { - compileSdk 33 + compileSdk 34 defaultConfig { minSdkVersion 28 targetSdkVersion 28 diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/activities/InsightPairingInformationActivity.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/activities/InsightPairingInformationActivity.java index 53208e5073..494851429e 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/activities/InsightPairingInformationActivity.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/activities/InsightPairingInformationActivity.java @@ -40,7 +40,7 @@ public class InsightPairingInformationActivity extends DaggerAppCompatActivity { } else { serialNumber.setText(connectionService.getPumpSystemIdentification().getSerialNumber()); manufacturingDate.setText(connectionService.getPumpSystemIdentification().getManufacturingDate()); - systemIdAppendix.setText(connectionService.getPumpSystemIdentification().getSystemIdAppendix() + ""); + systemIdAppendix.setText(String.valueOf(connectionService.getPumpSystemIdentification().getSystemIdAppendix())); releaseSWVersion.setText(connectionService.getPumpFirmwareVersions().getReleaseSWVersion()); uiProcSWVersion.setText(connectionService.getPumpFirmwareVersions().getUiProcSWVersion()); pcProcSWVersion.setText(connectionService.getPumpFirmwareVersions().getPcProcSWVersion()); diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/AppLayerMessage.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/AppLayerMessage.java index 7783abe063..f78a0a5171 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/AppLayerMessage.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/AppLayerMessage.java @@ -57,7 +57,7 @@ public class AppLayerMessage implements Comparable { Class clazz = AppCommandIDs.IDS.getType(command); if (clazz == null) throw new UnknownAppCommandException(); if (version != VERSION) throw new IncompatibleAppVersionException(); - AppLayerMessage message = clazz.newInstance(); + AppLayerMessage message = clazz.getDeclaredConstructor().newInstance(); if (ServiceIDs.IDS.getType(service) == null) throw new UnknownServiceException(); if (error != 0) { Class exceptionClass = AppErrorIDs.IDS.getType(error); diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/ReadParameterBlockMessage.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/ReadParameterBlockMessage.java index 221cf80462..8526fa2c27 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/ReadParameterBlockMessage.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/ReadParameterBlockMessage.java @@ -33,7 +33,7 @@ public class ReadParameterBlockMessage extends AppLayerMessage { @Override protected void parse(ByteBuf byteBuf) throws Exception { - parameterBlock = ParameterBlockIDs.IDS.getType(byteBuf.readUInt16LE()).newInstance(); + parameterBlock = ParameterBlockIDs.IDS.getType(byteBuf.readUInt16LE()).getDeclaredConstructor().newInstance(); byteBuf.shift(2); //Restriction level parameterBlock.parse(byteBuf); } diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/history/history_events/HistoryEvent.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/history/history_events/HistoryEvent.java index 896f2ec21e..eddcf66387 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/history/history_events/HistoryEvent.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/history/history_events/HistoryEvent.java @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history_events; +import java.lang.reflect.InvocationTargetException; + import info.nightscout.androidaps.plugins.pump.insight.ids.HistoryEventIDs; import info.nightscout.androidaps.plugins.pump.insight.utils.BOCUtil; import info.nightscout.androidaps.plugins.pump.insight.utils.ByteBuf; @@ -22,8 +24,8 @@ public class HistoryEvent implements Comparable { if (eventClass == null) event = new HistoryEvent(); else { try { - event = eventClass.newInstance(); - } catch (IllegalAccessException | InstantiationException e) { + event = eventClass.getDeclaredConstructor().newInstance(); + } catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { //log.error("Unhandled exception", e); } } diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/satl/SatlMessage.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/satl/SatlMessage.java index eba9601068..dd5d3ca1fb 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/satl/SatlMessage.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/satl/SatlMessage.java @@ -107,7 +107,7 @@ public abstract class SatlMessage { if (clazz == null) throw new InvalidSatlCommandException(); SatlMessage message = null; try { - message = clazz.newInstance(); + message = clazz.getDeclaredConstructor().newInstance(); } catch (Exception ignored) { } message.parse(ByteBuf.from(payload)); @@ -137,7 +137,7 @@ public abstract class SatlMessage { if (clazz == null) throw new InvalidSatlCommandException(); SatlMessage message = null; try { - message = clazz.newInstance(); + message = clazz.getDeclaredConstructor().newInstance(); } catch (Exception ignored) { } message.parse(ByteBuf.from(payload)); diff --git a/plugins/configuration/src/main/java/info/nightscout/configuration/setupwizard/elements/SWPreference.kt b/plugins/configuration/src/main/java/info/nightscout/configuration/setupwizard/elements/SWPreference.kt index ba6fd41780..aa30235406 100644 --- a/plugins/configuration/src/main/java/info/nightscout/configuration/setupwizard/elements/SWPreference.kt +++ b/plugins/configuration/src/main/java/info/nightscout/configuration/setupwizard/elements/SWPreference.kt @@ -25,7 +25,7 @@ class SWPreference(injector: HasAndroidInjector, private val definition: SWDefin } private fun addConfiguration(layout: LinearLayout, xml: Int) { - (Class.forName(uiInteraction.myPreferenceFragment.name).newInstance() as Fragment).also { fragment -> + (Class.forName(uiInteraction.myPreferenceFragment.name).getDeclaredConstructor().newInstance() as Fragment).also { fragment -> fragment.arguments = Bundle().also { it.putInt("id", xml) } definition.activity.supportFragmentManager.beginTransaction().run { replace(layout.id, fragment) diff --git a/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/alarm/AlarmRegistry.kt b/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/alarm/AlarmRegistry.kt index ae020d1ccf..108c7845ed 100644 --- a/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/alarm/AlarmRegistry.kt +++ b/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/alarm/AlarmRegistry.kt @@ -120,10 +120,11 @@ class AlarmRegistry @Inject constructor() : IAlarmRegistry { private fun registerOsAlarm(alarmCode: AlarmCode, triggerTime: Long): Maybe { return Maybe.fromCallable { cancelOsAlarmInternal(alarmCode) - val pendingIntent = createPendingIntent(alarmCode, 0) - aapsLogger.debug("[${alarmCode}] OS Alarm added. ${DateUtil(mContext).toISOString(triggerTime)}") - mOsAlarmManager.setAlarmClock(AlarmClockInfo(triggerTime, pendingIntent), pendingIntent) - alarmCode + createPendingIntent(alarmCode, 0)?.let { pendingIntent -> + aapsLogger.debug("[${alarmCode}] OS Alarm added. ${DateUtil(mContext).toISOString(triggerTime)}") + mOsAlarmManager.setAlarmClock(AlarmClockInfo(triggerTime, pendingIntent), pendingIntent) + alarmCode + } } } diff --git a/ui/src/main/java/info/nightscout/ui/activities/TreatmentsActivity.kt b/ui/src/main/java/info/nightscout/ui/activities/TreatmentsActivity.kt index f53797d513..41d3c94554 100644 --- a/ui/src/main/java/info/nightscout/ui/activities/TreatmentsActivity.kt +++ b/ui/src/main/java/info/nightscout/ui/activities/TreatmentsActivity.kt @@ -54,7 +54,7 @@ class TreatmentsActivity : TranslatedDaggerAppCompatActivity() { 5 -> TreatmentsCareportalFragment::class.java else -> TreatmentsUserEntryFragment::class.java } - setFragment(fragment.newInstance()) + setFragment(fragment.getDeclaredConstructor().newInstance()) supportActionBar?.title = tab.contentDescription } diff --git a/wear/build.gradle b/wear/build.gradle index 63e0e09964..b26ab97963 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -43,7 +43,7 @@ def generateGitBuild = { -> } android { - compileSdk 33 + compileSdk 34 defaultConfig { minSdkVersion 25 diff --git a/wear/src/main/java/info/nightscout/androidaps/WearApp.kt b/wear/src/main/java/info/nightscout/androidaps/WearApp.kt index a2a28818d5..600cbf7d13 100644 --- a/wear/src/main/java/info/nightscout/androidaps/WearApp.kt +++ b/wear/src/main/java/info/nightscout/androidaps/WearApp.kt @@ -21,6 +21,7 @@ class WearApp : DaggerApplication(), OnSharedPreferenceChangeListener { @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var rxBus: RxBus + @Suppress("unused") @Inject lateinit var dataHandlerWear: DataHandlerWear // instantiate only @Inject lateinit var exceptionHandlerWear: ExceptionHandlerWear @@ -38,7 +39,8 @@ class WearApp : DaggerApplication(), OnSharedPreferenceChangeListener { .application(this) .build() - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + key ?: return // We trigger update on Complications LocalBroadcastManager.getInstance(this).sendBroadcast(Intent(DataLayerListenerServiceWear.INTENT_NEW_DATA)) rxBus.send(EventWearPreferenceChange(key))