diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml
index cafa9ae3ed..d7041e76cb 100644
--- a/wear/src/main/AndroidManifest.xml
+++ b/wear/src/main/AndroidManifest.xml
@@ -569,8 +569,8 @@
android:exported="true"
android:label="@string/action_insulin" />
+ android:name=".interaction.actions.ProfileSwitchActivity"
+ android:label="@string/status_profile_switch" />
aapsLogger.debug(LTag.WEAR, "ActionProfileSwitchOpenActivity received from ${event.sourceNodeId}")
- context.startActivity(Intent(context, CPPActivity::class.java).apply {
+ context.startActivity(Intent(context, ProfileSwitchActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
putExtras(Bundle().also { bundle ->
bundle.putInt("percentage", event.percentage)
diff --git a/wear/src/main/java/info/nightscout/androidaps/di/WearActivitiesModule.kt b/wear/src/main/java/info/nightscout/androidaps/di/WearActivitiesModule.kt
index 295dc638e7..18a63adb66 100644
--- a/wear/src/main/java/info/nightscout/androidaps/di/WearActivitiesModule.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/di/WearActivitiesModule.kt
@@ -23,7 +23,7 @@ abstract class WearActivitiesModule {
@ContributesAndroidInjector abstract fun contributesAcceptActivity(): AcceptActivity
@ContributesAndroidInjector abstract fun contributesBolusActivity(): BolusActivity
@ContributesAndroidInjector abstract fun contributesCarbActivity(): CarbActivity
- @ContributesAndroidInjector abstract fun contributesCPPActivity(): CPPActivity
+ @ContributesAndroidInjector abstract fun contributesProfileSwitchActivity(): ProfileSwitchActivity
@ContributesAndroidInjector abstract fun contributesECarbActivity(): ECarbActivity
@ContributesAndroidInjector abstract fun contributesFillActivity(): FillActivity
@ContributesAndroidInjector abstract fun contributesTempTargetActivity(): TempTargetActivity
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 f872266bc6..ccf19933fb 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/TileConfigurationActivity.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/TileConfigurationActivity.kt
@@ -35,12 +35,12 @@ class TileConfigurationActivity : WearPreferenceActivity() {
// Note that TileService updates are hard limited to once every 20 seconds.
when {
configFileName === "tile_configuration_activity" -> {
- aapsLogger.info(LTag.WEAR, "onDestroy a: requestUpdate!!")
+ aapsLogger.info(LTag.WEAR, "onDestroy a: requestUpdate")
TileService.getUpdater(this).requestUpdate(ActionsTileService::class.java)
}
configFileName === "tile_configuration_tempt" -> {
- aapsLogger.info(LTag.WEAR, "onDestroy tt: requestUpdate!!")
+ aapsLogger.info(LTag.WEAR, "onDestroy tt: requestUpdate")
TileService.getUpdater(this).requestUpdate(TempTargetTileService::class.java)
}
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.kt
index 4a612697ac..47b4aca051 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.kt
@@ -33,10 +33,10 @@ class AcceptActivity : ViewSelectorActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
dismissThread = DismissThread()
- dismissThread!!.start()
+ dismissThread?.start()
val extras = intent.extras
- message = extras!!.getString("message", "")
- actionKey = extras.getString(DataLayerListenerServiceWear.KEY_ACTION_DATA, "")
+ message = extras?.getString("message", "") ?: ""
+ actionKey = extras?.getString(DataLayerListenerServiceWear.KEY_ACTION_DATA, "") ?: ""
if (message.isEmpty() || actionKey.isEmpty()) {
finish()
return
@@ -117,19 +117,16 @@ class AcceptActivity : ViewSelectorActivity() {
override fun run() {
SystemClock.sleep((60 * 1000L))
- synchronized(this) {
- if (valid) finish()
- }
+ synchronized(this) { if (valid) finish() }
}
}
@Synchronized override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
- if (dismissThread != null) dismissThread!!.invalidate()
- val extras = intent.extras
- val msgIntent = Intent(this, AcceptActivity::class.java)
- msgIntent.putExtras(extras!!)
- startActivity(msgIntent)
- finish()
+ dismissThread?.invalidate()
+ intent.extras?.let {
+ startActivity(Intent(this, AcceptActivity::class.java).apply { putExtras(it) })
+ finish()
+ }
}
}
\ No newline at end of file
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java
deleted file mode 100644
index c0b6cedb33..0000000000
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package info.nightscout.androidaps.interaction.actions;
-
-import android.os.Bundle;
-import android.support.wearable.view.GridPagerAdapter;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-
-import java.text.DecimalFormat;
-
-import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.events.EventWearToMobile;
-import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
-import info.nightscout.shared.SafeParse;
-import info.nightscout.shared.weardata.EventData;
-
-/**
- * Created by adrian on 09/02/17.
- */
-
-public class CPPActivity extends ViewSelectorActivity {
-
- PlusMinusEditText editPercentage;
- PlusMinusEditText editTimeshift;
-
- int percentage = -1;
- int timeshift = -25;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Bundle extras = getIntent().getExtras();
- percentage = extras.getInt("percentage", -1);
- timeshift = extras.getInt("timeshift", -1);
-
- if (percentage == -1 || timeshift == -25) {
- finish();
- return;
- }
-
- if (timeshift < 0) timeshift += 24;
-
- setAdapter(new MyGridViewPagerAdapter());
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- finish();
- }
-
- @SuppressWarnings("deprecation")
- private class MyGridViewPagerAdapter extends GridPagerAdapter {
- @Override
- public int getColumnCount(int arg0) {
- return 3;
- }
-
- @Override
- public int getRowCount() {
- return 1;
- }
-
- @Override
- public Object instantiateItem(ViewGroup container, int row, int col) {
-
- if (col == 0) {
- final View view = getInflatedPlusMinusView(container);
- double def = timeshift;
- if (editTimeshift != null) {
- def = SafeParse.stringToDouble(editTimeshift.editText.getText().toString());
- }
- editTimeshift = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 23d, 1d, new DecimalFormat("0"), true, true);
- setLabelToPlusMinusView(view, getString(R.string.action_timeshift));
- container.addView(view);
- view.requestFocus();
- return view;
- } else if (col == 1) {
- final View view = getInflatedPlusMinusView(container);
- double def = percentage;
- if (editPercentage != null) {
- def = SafeParse.stringToDouble(editPercentage.editText.getText().toString());
- }
- editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 30d, 250d, 1d, new DecimalFormat("0"), false);
- setLabelToPlusMinusView(view, getString(R.string.action_percentage));
- container.addView(view);
- return view;
- } else {
-
- final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
- final ImageView confirmButton = view.findViewById(R.id.confirmbutton);
- confirmButton.setOnClickListener((View v) -> {
- //check if it can happen that the fragment is never created that hold data?
- // (you have to swipe past them anyways - but still)
- EventData.ActionProfileSwitchPreCheck ps =
- new EventData.ActionProfileSwitchPreCheck(SafeParse.stringToInt(editTimeshift.editText.getText().toString()), SafeParse.stringToInt(editPercentage.editText.getText().toString()));
- rxBus.send(new EventWearToMobile(ps));
- showToast(CPPActivity.this, R.string.action_cpp_confirmation);
- finishAffinity();
- });
- container.addView(view);
- return view;
- }
- }
-
- @Override
- public void destroyItem(ViewGroup container, int row, int col, Object view) {
- // Handle this to get the data before the view is destroyed?
- // Object should still be kept by this, just setup for re-init?
- container.removeView((View) view);
- }
-
- @Override
- public boolean isViewFromObject(View view, Object object) {
- return view == object;
- }
-
- }
-}
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ProfileSwitchActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ProfileSwitchActivity.kt
new file mode 100644
index 0000000000..0ee7ec7ba3
--- /dev/null
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ProfileSwitchActivity.kt
@@ -0,0 +1,94 @@
+@file:Suppress("DEPRECATION")
+
+package info.nightscout.androidaps.interaction.actions
+
+import android.os.Bundle
+import android.support.wearable.view.GridPagerAdapter
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import info.nightscout.androidaps.R
+import info.nightscout.androidaps.events.EventWearToMobile
+import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
+import info.nightscout.shared.SafeParse
+import info.nightscout.shared.weardata.EventData.ActionProfileSwitchPreCheck
+import java.text.DecimalFormat
+
+class ProfileSwitchActivity : ViewSelectorActivity() {
+
+ var editPercentage: PlusMinusEditText? = null
+ var editTimeshift: PlusMinusEditText? = null
+ var percentage = -1
+ var timeshift = -25
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ percentage = intent.extras?.getInt("percentage", -1) ?: -1
+ timeshift = intent.extras?.getInt("timeshift", -25) ?: -25
+ if (percentage == -1 || timeshift == -25) {
+ finish()
+ return
+ }
+ if (timeshift < 0) timeshift += 24
+ setAdapter(MyGridViewPagerAdapter())
+ }
+
+ override fun onPause() {
+ super.onPause()
+ finish()
+ }
+
+ private inner class MyGridViewPagerAdapter : GridPagerAdapter() {
+
+ override fun getColumnCount(arg0: Int): Int = 3
+ override fun getRowCount(): Int = 1
+
+ override fun instantiateItem(container: ViewGroup, row: Int, col: Int): Any {
+ return if (col == 0) {
+ val view = getInflatedPlusMinusView(container)
+ var def = timeshift.toDouble()
+ if (editTimeshift != null) {
+ def = SafeParse.stringToDouble(editTimeshift?.editText?.text.toString())
+ }
+ editTimeshift = PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0.0, 23.0, 1.0, DecimalFormat("0"), true, true)
+ setLabelToPlusMinusView(view, getString(R.string.action_timeshift))
+ container.addView(view)
+ view.requestFocus()
+ view
+ } else if (col == 1) {
+ val view = getInflatedPlusMinusView(container)
+ var def = percentage.toDouble()
+ if (editPercentage != null) {
+ def = SafeParse.stringToDouble(editPercentage?.editText?.text.toString())
+ }
+ editPercentage = PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 30.0, 250.0, 1.0, DecimalFormat("0"), false)
+ setLabelToPlusMinusView(view, getString(R.string.action_percentage))
+ container.addView(view)
+ view
+ } else {
+ val view = LayoutInflater.from(applicationContext).inflate(R.layout.action_send_item, container, false)
+ val confirmButton = view.findViewById(R.id.confirmbutton)
+ confirmButton.setOnClickListener {
+ //check if it can happen that the fragment is never created that hold data?
+ // (you have to swipe past them anyways - but still)
+ val ps = ActionProfileSwitchPreCheck(SafeParse.stringToInt(editTimeshift?.editText?.text.toString()), SafeParse.stringToInt(editPercentage?.editText?.text.toString()))
+ rxBus.send(EventWearToMobile(ps))
+ showToast(this@ProfileSwitchActivity, R.string.action_profile_switch_confirmation)
+ finishAffinity()
+ }
+ container.addView(view)
+ view
+ }
+ }
+
+ override fun destroyItem(container: ViewGroup, row: Int, col: Int, view: Any) {
+ // Handle this to get the data before the view is destroyed?
+ // Object should still be kept by this, just setup for re-init?
+ container.removeView(view as View)
+ }
+
+ override fun isViewFromObject(view: View, `object`: Any): Boolean {
+ return view === `object`
+ }
+ }
+}
\ 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 e0091b1392..9cc84c832c 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
@@ -32,7 +32,7 @@ class MainMenuActivity : MenuListActivity() {
add(MenuItem(R.drawable.ic_e_carbs, getString(R.string.menu_ecarb)))
add(MenuItem(R.drawable.ic_treatment, getString(R.string.menu_treatment)))
add(MenuItem(R.drawable.ic_temptarget, getString(R.string.menu_tempt)))
- add(MenuItem(R.drawable.ic_status, getString(R.string.status_cpp)))
+ add(MenuItem(R.drawable.ic_status, getString(R.string.status_profile_switch)))
add(MenuItem(R.drawable.ic_settings, getString(R.string.menu_settings)))
add(MenuItem(R.drawable.ic_status, getString(R.string.menu_status)))
if (sp.getBoolean(R.string.key_prime_fill, false))
@@ -42,15 +42,15 @@ class MainMenuActivity : MenuListActivity() {
override fun doAction(action: String) {
when (action) {
- 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) })
- getString(R.string.menu_treatment) -> startActivity(Intent(this, TreatmentActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
- getString(R.string.menu_wizard) -> startActivity(Intent(this, WizardActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
- getString(R.string.menu_status) -> startActivity(Intent(this, StatusMenuActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
- getString(R.string.menu_prime_fill) -> startActivity(Intent(this, FillMenuActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
- getString(R.string.menu_ecarb) -> startActivity(Intent(this, ECarbActivity::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_profile_switch) -> 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) })
+ getString(R.string.menu_treatment) -> startActivity(Intent(this, TreatmentActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
+ getString(R.string.menu_wizard) -> startActivity(Intent(this, WizardActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
+ getString(R.string.menu_status) -> startActivity(Intent(this, StatusMenuActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
+ getString(R.string.menu_prime_fill) -> startActivity(Intent(this, FillMenuActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
+ getString(R.string.menu_ecarb) -> startActivity(Intent(this, ECarbActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
}
}
}
\ No newline at end of file
diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml
index b4f91135a5..648f1745e2 100644
--- a/wear/src/main/res/values/strings.xml
+++ b/wear/src/main/res/values/strings.xml
@@ -98,7 +98,7 @@
Calculation Requested
Fill Requested
Carbs Requested
- CPP Requested
+ Profile Switch Requested
Target
Low
High
@@ -122,7 +122,7 @@
Pump
Loop
- CPP
+ Profile switch
TDD
Carb