Wear: ConfigurationActivities cleanup
This commit is contained in:
parent
3311a1a6f6
commit
9a90400f37
8 changed files with 56 additions and 58 deletions
|
@ -548,7 +548,7 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".interaction.AAPSPreferences"
|
||||
android:name=".interaction.WatchfaceConfigurationActivity"
|
||||
android:label="@string/menu_settings" />
|
||||
<activity
|
||||
android:name=".interaction.actions.WizardActivity"
|
||||
|
|
|
@ -17,7 +17,7 @@ import androidx.wear.tiles.TileService
|
|||
import com.google.android.gms.wearable.WearableListenerService
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.events.EventWearToMobile
|
||||
import info.nightscout.androidaps.interaction.AAPSPreferences
|
||||
import info.nightscout.androidaps.interaction.WatchfaceConfigurationActivity
|
||||
import info.nightscout.androidaps.interaction.actions.AcceptActivity
|
||||
import info.nightscout.androidaps.interaction.actions.CPPActivity
|
||||
import info.nightscout.androidaps.interaction.utils.Persistence
|
||||
|
@ -94,7 +94,7 @@ class DataHandlerWear @Inject constructor(
|
|||
.observeOn(aapsSchedulers.io)
|
||||
.subscribe {
|
||||
aapsLogger.debug(LTag.WEAR, "ActionOpenSettings received from ${it.sourceNodeId}")
|
||||
context.startActivity(Intent(context, AAPSPreferences::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
|
||||
context.startActivity(Intent(context, WatchfaceConfigurationActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
|
||||
}
|
||||
disposable += rxBus
|
||||
.toObservable(EventData.ActionProfileSwitchOpenActivity::class.java)
|
||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.di
|
|||
|
||||
import dagger.Module
|
||||
import dagger.android.ContributesAndroidInjector
|
||||
import info.nightscout.androidaps.interaction.ConfigurationActivity
|
||||
import info.nightscout.androidaps.interaction.TileConfigurationActivity
|
||||
import info.nightscout.androidaps.interaction.actions.*
|
||||
import info.nightscout.androidaps.interaction.menus.FillMenuActivity
|
||||
|
@ -14,6 +15,7 @@ import info.nightscout.androidaps.interaction.utils.MenuListActivity
|
|||
abstract class WearActivitiesModule {
|
||||
|
||||
@ContributesAndroidInjector abstract fun contributesTileConfigurationActivity(): TileConfigurationActivity
|
||||
@ContributesAndroidInjector abstract fun contributesConfigurationActivity(): ConfigurationActivity
|
||||
|
||||
@ContributesAndroidInjector abstract fun contributesBackgroundActionActivity(): BackgroundActionActivity
|
||||
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
package info.nightscout.androidaps.interaction;
|
||||
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import preference.WearPreferenceActivity;
|
||||
|
||||
public class ConfigurationActivity extends WearPreferenceActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setTitle("Watchface");
|
||||
String configFileName = getIntent().getAction();
|
||||
int resXmlId = getResources().getIdentifier(configFileName, "xml", getApplicationContext().getPackageName());
|
||||
Log.d("ConfigurationActivity::onCreate --->> 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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) })
|
||||
|
|
Loading…
Reference in a new issue