From 1333f8d04725e76141a3f66d12bbe2f444df77c5 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 29 Mar 2022 15:55:51 +0200 Subject: [PATCH] fix resetting password for Dana pumps --- .../java/info/nightscout/androidaps/MainActivity.kt | 13 +++++++++++-- .../main/java/info/nightscout/androidaps/MainApp.kt | 8 ++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index beffbec7c8..479bd6045c 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -34,6 +34,7 @@ import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.databinding.ActivityMainBinding import info.nightscout.androidaps.events.EventAppExit +import info.nightscout.androidaps.events.EventInitializationChanged import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.events.EventRebuildTabs import info.nightscout.androidaps.interfaces.* @@ -51,6 +52,7 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.extensions.isRunningRealPumpTest import info.nightscout.androidaps.utils.locale.LocaleHelper +import info.nightscout.androidaps.utils.protection.PasswordCheck import info.nightscout.androidaps.utils.protection.ProtectionCheck import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.tabs.TabPageAdapter @@ -85,6 +87,7 @@ class MainActivity : NoSplashAppCompatActivity() { @Inject lateinit var config: Config @Inject lateinit var uel: UserEntryLogger @Inject lateinit var profileFunction: ProfileFunction + @Inject lateinit var passwordCheck: PasswordCheck private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle private var pluginPreferencesMenuItem: MenuItem? = null @@ -136,6 +139,12 @@ class MainActivity : NoSplashAppCompatActivity() { .toObservable(EventPreferenceChange::class.java) .observeOn(aapsSchedulers.main) .subscribe({ processPreferenceChange(it) }, fabricPrivacy::logException) + disposable += rxBus + .toObservable(EventInitializationChanged::class.java) + .observeOn(aapsSchedulers.main) + .subscribe({ + passwordCheck.passwordResetCheck(this) + }, fabricPrivacy::logException) if (startWizard() && !isRunningRealPumpTest()) { protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, { startActivity(Intent(this, SetupWizardActivity::class.java)) @@ -258,7 +267,7 @@ class MainActivity : NoSplashAppCompatActivity() { } private fun setDisabledMenuItemColorPluginPreferences() { - if( pluginPreferencesMenuItem?.isEnabled == false){ + if (pluginPreferencesMenuItem?.isEnabled == false) { val spanString = SpannableString(this.menu?.findItem(R.id.nav_plugin_preferences)?.title.toString()) spanString.setSpan(ForegroundColorSpan(rh.gac(R.attr.disabledTextColor)), 0, spanString.length, 0) this.menu?.findItem(R.id.nav_plugin_preferences)?.title = spanString @@ -283,7 +292,7 @@ class MainActivity : NoSplashAppCompatActivity() { } override fun onPanelClosed(featureId: Int, menu: Menu) { - menuOpen = false; + menuOpen = false super.onPanelClosed(featureId, menu) } diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.kt b/app/src/main/java/info/nightscout/androidaps/MainApp.kt index f91f208f97..b78b3084d7 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.kt @@ -7,7 +7,6 @@ import android.net.ConnectivityManager import android.net.wifi.WifiManager import android.os.Build import androidx.lifecycle.ProcessLifecycleOwner -import androidx.appcompat.app.AppCompatDelegate import com.uber.rxdogtag.RxDogTag import dagger.android.AndroidInjector import dagger.android.DaggerApplication @@ -22,8 +21,6 @@ import info.nightscout.androidaps.di.StaticInjector import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.ConfigBuilder import info.nightscout.androidaps.interfaces.PluginBase -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.configBuilder.PluginStore import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils @@ -41,7 +38,8 @@ import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.ProcessLifecycleListener import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.locale.LocaleHelper -import info.nightscout.androidaps.utils.protection.PasswordCheck +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import info.nightscout.shared.sharedPreferences.SP import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.exceptions.UndeliverableException @@ -71,7 +69,6 @@ class MainApp : DaggerApplication() { @Inject lateinit var dateUtil: DateUtil @Inject lateinit var staticInjector: StaticInjector// TODO avoid , here fake only to initialize @Inject lateinit var uel: UserEntryLogger - @Inject lateinit var passwordCheck: PasswordCheck @Inject lateinit var alarmSoundServiceHelper: AlarmSoundServiceHelper @Inject lateinit var notificationStore: NotificationStore @Inject lateinit var processLifecycleListener: ProcessLifecycleListener @@ -124,7 +121,6 @@ class MainApp : DaggerApplication() { keepAliveManager.setAlarm(this) doMigrations() uel.log(UserEntry.Action.START_AAPS, UserEntry.Sources.Aaps) - passwordCheck.passwordResetCheck(this) } private fun setRxErrorHandler() {