diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index cd0fd89207..cafa9ae3ed 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -548,7 +548,7 @@ > getIntent().getAction()", configFileName); - Log.d("ConfigurationActivity::onCreate --->> resXmlId", String.valueOf(resXmlId)); - addPreferencesFromResource(resXmlId); - ViewGroup view = (ViewGroup) getWindow().getDecorView(); - removeBackgroundRecursively(view); - view.setBackground(ContextCompat.getDrawable(this, R.drawable.settings_background)); - view.requestFocus(); - } - - @Override - protected void onPause() { - super.onPause(); - finish(); - } - - void removeBackgroundRecursively(View parent) { - if (parent instanceof ViewGroup) { - ViewGroup group = (ViewGroup) parent; - for (int i = 0; i < group.getChildCount(); i++) { - removeBackgroundRecursively(group.getChildAt(i)); - } - } - parent.setBackground(null); - } - -} diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/ConfigurationActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/ConfigurationActivity.kt new file mode 100644 index 0000000000..5c0cee4e8f --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/ConfigurationActivity.kt @@ -0,0 +1,44 @@ +package info.nightscout.androidaps.interaction + +import preference.WearPreferenceActivity +import android.os.Bundle +import android.view.View +import android.view.ViewGroup +import androidx.core.content.ContextCompat +import dagger.android.AndroidInjection +import info.nightscout.androidaps.R +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag +import javax.inject.Inject + +class ConfigurationActivity : WearPreferenceActivity() { + + @Inject lateinit var aapsLogger: AAPSLogger + + override fun onCreate(savedInstanceState: Bundle?) { + AndroidInjection.inject(this) + super.onCreate(savedInstanceState) + title = "Watchface" + val configFileName = intent.action + val resXmlId = resources.getIdentifier(configFileName, "xml", applicationContext.packageName) + aapsLogger.debug(LTag.WEAR, "ConfigurationActivity::onCreate --->> getIntent().getAction() $configFileName") + aapsLogger.debug(LTag.WEAR, "ConfigurationActivity::onCreate --->> resXmlId $resXmlId") + addPreferencesFromResource(resXmlId) + val view = window.decorView as ViewGroup + removeBackgroundRecursively(view) + view.background = ContextCompat.getDrawable(this, R.drawable.settings_background) + view.requestFocus() + } + + override fun onPause() { + super.onPause() + finish() + } + + private fun removeBackgroundRecursively(parent: View) { + if (parent is ViewGroup) + for (i in 0 until parent.childCount) + removeBackgroundRecursively(parent.getChildAt(i)) + parent.background = null + } +} \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/TileConfigurationActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/TileConfigurationActivity.kt index 8a7591e957..f872266bc6 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/TileConfigurationActivity.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/TileConfigurationActivity.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.interaction import android.os.Bundle import android.view.ViewGroup import androidx.wear.tiles.TileService +import dagger.android.AndroidInjection import info.nightscout.androidaps.tile.ActionsTileService import info.nightscout.androidaps.tile.TempTargetTileService import info.nightscout.shared.logging.AAPSLogger @@ -17,6 +18,7 @@ class TileConfigurationActivity : WearPreferenceActivity() { private var configFileName: String? = null override fun onCreate(savedInstanceState: Bundle?) { + AndroidInjection.inject(this) super.onCreate(savedInstanceState) title = "Tile" configFileName = intent.action diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/WatchfaceConfigurationActivity.kt similarity index 82% rename from wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.kt rename to wear/src/main/java/info/nightscout/androidaps/interaction/WatchfaceConfigurationActivity.kt index e02f3fb2ad..2b06023155 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/WatchfaceConfigurationActivity.kt @@ -7,7 +7,7 @@ import androidx.core.content.ContextCompat import info.nightscout.androidaps.R import preference.WearPreferenceActivity -class AAPSPreferences : WearPreferenceActivity() { +class WatchfaceConfigurationActivity : WearPreferenceActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -19,11 +19,9 @@ class AAPSPreferences : WearPreferenceActivity() { } private fun removeBackgroundRecursively(parent: View) { - if (parent is ViewGroup) { - for (i in 0 until parent.childCount) { + if (parent is ViewGroup) + for (i in 0 until parent.childCount) removeBackgroundRecursively(parent.getChildAt(i)) - } - } parent.background = null } } \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.kt index d3c5b1b7f8..e0091b1392 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.kt @@ -4,8 +4,7 @@ import android.content.Intent import android.os.Bundle import info.nightscout.androidaps.R import info.nightscout.androidaps.events.EventWearToMobile -import info.nightscout.androidaps.interaction.AAPSPreferences -import info.nightscout.androidaps.interaction.actions.BolusActivity +import info.nightscout.androidaps.interaction.WatchfaceConfigurationActivity import info.nightscout.androidaps.interaction.actions.ECarbActivity import info.nightscout.androidaps.interaction.actions.TempTargetActivity import info.nightscout.androidaps.interaction.actions.TreatmentActivity @@ -43,7 +42,7 @@ class MainMenuActivity : MenuListActivity() { override fun doAction(action: String) { when (action) { - getString(R.string.menu_settings) -> startActivity(Intent(this, AAPSPreferences::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) + getString(R.string.menu_settings) -> startActivity(Intent(this, WatchfaceConfigurationActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) getString(R.string.menu_resync) -> rxBus.send(EventWearToMobile(ActionResendData("Re-Sync"))) getString(R.string.status_cpp) -> rxBus.send(EventWearToMobile(EventData.ActionProfileSwitchSendInitialData(System.currentTimeMillis()))) getString(R.string.menu_tempt) -> startActivity(Intent(this, TempTargetActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })