From bca7e433d47c55b1d1b1654e2aa1ab53128e4d65 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 10 Dec 2021 15:27:09 +0100 Subject: [PATCH] Aaps -> kt --- .../java/info/nightscout/androidaps/Aaps.java | 44 ------------------- .../java/info/nightscout/androidaps/Aaps.kt | 29 ++++++++++++ 2 files changed, 29 insertions(+), 44 deletions(-) delete mode 100644 wear/src/main/java/info/nightscout/androidaps/Aaps.java create mode 100644 wear/src/main/java/info/nightscout/androidaps/Aaps.kt diff --git a/wear/src/main/java/info/nightscout/androidaps/Aaps.java b/wear/src/main/java/info/nightscout/androidaps/Aaps.java deleted file mode 100644 index d9aa8fab2e..0000000000 --- a/wear/src/main/java/info/nightscout/androidaps/Aaps.java +++ /dev/null @@ -1,44 +0,0 @@ -package info.nightscout.androidaps; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; - -import androidx.localbroadcastmanager.content.LocalBroadcastManager; - -import dagger.android.AndroidInjector; -import dagger.android.DaggerApplication; -import info.nightscout.androidaps.di.DaggerAppComponent; - -/** - * Created for xDrip+ by Emma Black on 3/21/15. - * Adapted for AAPS by dlvoy 2019-11-06. - */ - -public class Aaps extends DaggerApplication implements SharedPreferences.OnSharedPreferenceChangeListener { - - @Override - public void onCreate() { - SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); - sharedPrefs.registerOnSharedPreferenceChangeListener(this); - super.onCreate(); - } - - @Override - protected AndroidInjector applicationInjector() { - return DaggerAppComponent - .builder() - .application(this) - .build(); - } - - @Override - public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { - // we trigger update on Complications - Intent messageIntent = new Intent(); - messageIntent.setAction(Intent.ACTION_SEND); - LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent); - } -} diff --git a/wear/src/main/java/info/nightscout/androidaps/Aaps.kt b/wear/src/main/java/info/nightscout/androidaps/Aaps.kt new file mode 100644 index 0000000000..06049167b3 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/Aaps.kt @@ -0,0 +1,29 @@ +package info.nightscout.androidaps + +import android.content.Intent +import android.content.SharedPreferences +import android.content.SharedPreferences.OnSharedPreferenceChangeListener +import androidx.localbroadcastmanager.content.LocalBroadcastManager +import androidx.preference.PreferenceManager +import dagger.android.AndroidInjector +import dagger.android.DaggerApplication +import info.nightscout.androidaps.di.DaggerAppComponent + +class Aaps : DaggerApplication(), OnSharedPreferenceChangeListener { + + override fun onCreate() { + super.onCreate() + PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this) + } + + override fun applicationInjector(): AndroidInjector = + DaggerAppComponent + .builder() + .application(this) + .build() + + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + // we trigger update on Complications + LocalBroadcastManager.getInstance(this).sendBroadcast(Intent(Intent.ACTION_SEND)) + } +} \ No newline at end of file