Wear: add tile tt and action with config
This commit is contained in:
parent
aab46e0f14
commit
ad43f57f7f
35 changed files with 793 additions and 301 deletions
|
@ -79,7 +79,8 @@ class ActionStringHandler @Inject constructor(
|
|||
private val dateUtil: DateUtil,
|
||||
private val config: Config,
|
||||
private val repository: AppRepository,
|
||||
private val uel: UserEntryLogger
|
||||
private val uel: UserEntryLogger,
|
||||
private val defaultValueHelper: DefaultValueHelper
|
||||
) {
|
||||
|
||||
private val timeout = 65 * 1000
|
||||
|
@ -143,14 +144,45 @@ class ActionStringHandler @Inject constructor(
|
|||
}
|
||||
rAction += "bolus $insulinAfterConstraints $carbsAfterConstraints"
|
||||
} else if ("temptarget" == act[0]) { ///////////////////////////////////////////////////////// TEMPTARGET
|
||||
if ("cancel" == act[1]) {
|
||||
rMessage += rh.gs(R.string.wear_action_tempt_cancel_message)
|
||||
rAction = "temptarget true 0 0 0"
|
||||
} else if ("preset" == act[1]) {
|
||||
val presetIsMGDL = profileFunction.getUnits() == GlucoseUnit.MGDL
|
||||
val preset = act[2]
|
||||
if ("activity" == preset) {
|
||||
val activityTTDuration = defaultValueHelper.determineActivityTTDuration()
|
||||
val activityTT = defaultValueHelper.determineActivityTT()
|
||||
val reason = rh.gs(R.string.activity)
|
||||
rMessage += rh.gs(R.string.wear_action_tempt_preset_message, reason, activityTT, activityTTDuration)
|
||||
rAction = "temptarget $presetIsMGDL $activityTTDuration $activityTT $activityTT"
|
||||
}
|
||||
if ("hypo" == preset) {
|
||||
val hypoTTDuration = defaultValueHelper.determineHypoTTDuration()
|
||||
val hypoTT = defaultValueHelper.determineHypoTT()
|
||||
val reason = rh.gs(R.string.hypo)
|
||||
rMessage += rh.gs(R.string.wear_action_tempt_preset_message, reason, hypoTT, hypoTTDuration)
|
||||
rAction = "temptarget $presetIsMGDL $hypoTTDuration $hypoTT $hypoTT"
|
||||
}
|
||||
if ("eating" == preset) {
|
||||
val eatingSoonTTDuration = defaultValueHelper.determineEatingSoonTTDuration()
|
||||
val eatingSoonTT = defaultValueHelper.determineEatingSoonTT()
|
||||
val reason = rh.gs(R.string.eatingsoon)
|
||||
rMessage += rh.gs(R.string.wear_action_tempt_preset_message, reason, eatingSoonTT, eatingSoonTTDuration)
|
||||
rAction = "temptarget $presetIsMGDL $eatingSoonTTDuration $eatingSoonTT $eatingSoonTT"
|
||||
} else {
|
||||
sendError(rh.gs(R.string.wear_action_tempt_preset_error, preset))
|
||||
return
|
||||
}
|
||||
} else {
|
||||
val isMGDL = java.lang.Boolean.parseBoolean(act[1])
|
||||
if (profileFunction.getUnits() == GlucoseUnit.MGDL != isMGDL) {
|
||||
sendError("Different units used on watch and phone!")
|
||||
sendError(rh.gs(R.string.wear_action_tempt_unit_error))
|
||||
return
|
||||
}
|
||||
val duration = SafeParse.stringToInt(act[2])
|
||||
if (duration == 0) {
|
||||
rMessage += "Zero-Temp-Target - cancelling running Temp-Targets?"
|
||||
rMessage += rh.gs(R.string.wear_action_tempt_zero_message)
|
||||
rAction = "temptarget true 0 0 0"
|
||||
} else {
|
||||
var low = SafeParse.stringToDouble(act[3])
|
||||
|
@ -160,16 +192,18 @@ class ActionStringHandler @Inject constructor(
|
|||
high *= Constants.MMOLL_TO_MGDL
|
||||
}
|
||||
if (low < HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0] || low > HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]) {
|
||||
sendError("Min-BG out of range!")
|
||||
sendError(rh.gs(R.string.wear_action_tempt_min_bg_error))
|
||||
return
|
||||
}
|
||||
if (high < HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[0] || high > HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[1]) {
|
||||
sendError("Max-BG out of range!")
|
||||
sendError(rh.gs(R.string.wear_action_tempt_max_bg_error))
|
||||
return
|
||||
}
|
||||
rMessage += "Temptarget:\nMin: " + act[3] + "\nMax: " + act[4] + "\nDuration: " + act[2]
|
||||
rMessage += if(act[3] === act[4]) rh.gs(R.string.wear_action_tempt_manual_message, act[3], act[2])
|
||||
else rh.gs(R.string.wear_action_tempt_manual_range_message, act[3], act[4], act[2])
|
||||
rAction = actionString
|
||||
}
|
||||
}
|
||||
} else if ("status" == act[0]) { ////////////////////////////////////////////// STATUS
|
||||
rTitle = "STATUS"
|
||||
rAction = "statusmessage"
|
||||
|
|
|
@ -1165,4 +1165,15 @@
|
|||
<string name="a11y_blood_glucose">blood glucose</string>
|
||||
<string name="a11y_bg_outdated">outdated</string>
|
||||
|
||||
<!-- WEAR OS-->
|
||||
<string name="wear_action_tempt_preset_error">Temptarget unknown preset: %1$s</string>
|
||||
<string name="wear_action_tempt_cancel_message">Cancelling running Temp-Targets?</string>
|
||||
<string name="wear_action_tempt_unit_error">Different units used on watch and phone!</string>
|
||||
<string name="wear_action_tempt_zero_message">Zero-Temp-Target - cancelling running Temp-Targets?</string>
|
||||
<string name="wear_action_tempt_min_bg_error">Min-BG out of range!</string>
|
||||
<string name="wear_action_tempt_max_bg_error">Max-BG out of range!</string>
|
||||
<string name="wear_action_tempt_manual_range_message">Temptarget:\nMin: %1$s\nMax: %2$s\nDuration: %3$s</string>
|
||||
<string name="wear_action_tempt_manual_message">Temptarget:\nTarget: %1$s\nDuration: %2$s</string>
|
||||
<string name="wear_action_tempt_preset_message">Temptarget:\Reason: %1$s\nTarget: %2$s\nDuration: %3$s</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -558,4 +558,15 @@
|
|||
<item quantity="other">%1$d minutes</item>
|
||||
</plurals>
|
||||
|
||||
<!-- WEAR OS-->
|
||||
<string name="wear_action_tempt_preset_error">Temptarget unknown preset: %1$s</string>
|
||||
<string name="wear_action_tempt_cancel_message">Cancelling running Temp-Targets?</string>
|
||||
<string name="wear_action_tempt_unit_error">Different units used on watch and phone!</string>
|
||||
<string name="wear_action_tempt_zero_message">Zero-Temp-Target - cancelling running Temp-Targets?</string>
|
||||
<string name="wear_action_tempt_min_bg_error">Min-BG out of range!</string>
|
||||
<string name="wear_action_tempt_max_bg_error">Max-BG out of range!</string>
|
||||
<string name="wear_action_tempt_manual_range_message">Temptarget:\nMin: %1$s\nMax: %2$s\nDuration: %3$s</string>
|
||||
<string name="wear_action_tempt_manual_message">Temptarget:\nTarget: %1$s\nDuration: %2$s</string>
|
||||
<string name="wear_action_tempt_preset_message">Temptarget:\Reason: %1$s\nTarget: %2$s\nDuration: %3$s</string>
|
||||
|
||||
</resources>
|
|
@ -512,17 +512,36 @@
|
|||
|
||||
<service
|
||||
android:name=".tile.ActionsTileService"
|
||||
android:label="Pump Actions"
|
||||
android:label="@string/label_actions_tile"
|
||||
android:permission="com.google.android.wearable.permission.BIND_TILE_PROVIDER">
|
||||
<intent-filter>
|
||||
<action android:name="androidx.wear.tiles.action.BIND_TILE_PROVIDER" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.android.clockwork.tiles.PROVIDER_CONFIG_ACTION"
|
||||
android:value="tile_configuration_activity" />
|
||||
<meta-data
|
||||
android:name="androidx.wear.tiles.PREVIEW"
|
||||
android:resource="@drawable/action_tile_preview" />
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".tile.TempTargetTileService"
|
||||
android:label="@string/label_temp_target_tile"
|
||||
android:permission="com.google.android.wearable.permission.BIND_TILE_PROVIDER">
|
||||
<intent-filter>
|
||||
<action android:name="androidx.wear.tiles.action.BIND_TILE_PROVIDER" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.android.clockwork.tiles.PROVIDER_CONFIG_ACTION"
|
||||
android:value="tile_configuration_tempt" />
|
||||
<meta-data
|
||||
android:name="androidx.wear.tiles.PREVIEW"
|
||||
android:resource="@drawable/temp_target_tile_preview" />
|
||||
</service>
|
||||
|
||||
<receiver android:name=".complications.ComplicationTapBroadcastReceiver" />
|
||||
|
||||
<activity
|
||||
|
@ -587,5 +606,15 @@
|
|||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".interaction.TileConfigurationActivity" android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="tile_configuration_activity" />
|
||||
<action android:name="tile_configuration_tempt" />
|
||||
<category android:name="com.google.android.clockwork.tiles.category.PROVIDER_CONFIG" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -5,6 +5,8 @@ import android.os.Bundle;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import preference.WearPreferenceActivity;
|
||||
|
||||
|
@ -14,21 +16,15 @@ public class AAPSPreferences extends WearPreferenceActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
ViewGroup view = (ViewGroup)getWindow().getDecorView();
|
||||
ViewGroup view = (ViewGroup) getWindow().getDecorView();
|
||||
removeBackgroundRecursively(view);
|
||||
view.setBackground(getResources().getDrawable(R.drawable.settings_background));
|
||||
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;
|
||||
ViewGroup group = (ViewGroup) parent;
|
||||
for (int i = 0; i < group.getChildCount(); i++) {
|
||||
removeBackgroundRecursively(group.getChildAt(i));
|
||||
}
|
||||
|
@ -36,5 +32,4 @@ public class AAPSPreferences extends WearPreferenceActivity {
|
|||
parent.setBackground(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -5,6 +5,9 @@ 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;
|
||||
|
||||
|
@ -14,14 +17,14 @@ public class ConfigurationActivity extends WearPreferenceActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setTitle("Watchface");
|
||||
String configFileName=getIntent().getAction();
|
||||
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));
|
||||
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(getResources().getDrawable(R.drawable.settings_background));
|
||||
view.setBackground(ContextCompat.getDrawable(this, R.drawable.settings_background));
|
||||
view.requestFocus();
|
||||
}
|
||||
|
||||
|
@ -41,5 +44,4 @@ public class ConfigurationActivity extends WearPreferenceActivity {
|
|||
parent.setBackground(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package info.nightscout.androidaps.interaction;
|
||||
|
||||
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 TileConfigurationActivity extends WearPreferenceActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setTitle("Tile");
|
||||
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();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -103,12 +103,9 @@ public class AcceptActivity extends ViewSelectorActivity {
|
|||
} 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(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
confirmbutton.setOnClickListener((View v) -> {
|
||||
ListenerService.confirmAction(AcceptActivity.this, actionstring);
|
||||
finishAffinity();
|
||||
}
|
||||
});
|
||||
container.addView(view);
|
||||
return view;
|
||||
|
|
|
@ -75,16 +75,14 @@ public class BolusActivity extends ViewSelectorActivity {
|
|||
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
|
||||
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
|
||||
confirmbutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
confirmbutton.setOnClickListener((View v) -> {
|
||||
//check if it can happen that the fagment is never created that hold data?
|
||||
// (you have to swipe past them anyways - but still)
|
||||
String actionstring = "bolus " + SafeParse.stringToDouble(editInsulin.editText.getText().toString())
|
||||
+ " " + SafeParse.stringToInt(editCarbs.editText.getText().toString());
|
||||
ListenerService.initiateAction(BolusActivity.this, actionstring);
|
||||
confirmAction(BolusActivity.this, R.string.action_bolus_confirmation);
|
||||
finishAffinity();
|
||||
}
|
||||
});
|
||||
container.addView(view);
|
||||
return view;
|
||||
|
|
|
@ -89,18 +89,15 @@ public class CPPActivity extends ViewSelectorActivity {
|
|||
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
|
||||
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
|
||||
confirmbutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
confirmbutton.setOnClickListener((View v) -> {
|
||||
//check if it can happen that the fagment is never created that hold data?
|
||||
// (you have to swipe past them anyways - but still)
|
||||
|
||||
String actionstring = "cppset " + SafeParse.stringToInt(editTimeshift.editText.getText().toString())
|
||||
+ " " + SafeParse.stringToInt(editPercentage.editText.getText().toString());
|
||||
ListenerService.initiateAction(CPPActivity.this, actionstring);
|
||||
confirmAction(CPPActivity.this, R.string.action_cpp_confirmation);
|
||||
finishAffinity();
|
||||
}
|
||||
});
|
||||
container.addView(view);
|
||||
return view;
|
||||
|
|
|
@ -85,9 +85,7 @@ public class ECarbActivity extends ViewSelectorActivity {
|
|||
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
|
||||
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
|
||||
confirmbutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
confirmbutton.setOnClickListener((View v) -> {
|
||||
|
||||
//check if it can happen that the fagment is never created that hold data?
|
||||
// (you have to swipe past them anyways - but still)
|
||||
|
@ -96,8 +94,9 @@ public class ECarbActivity extends ViewSelectorActivity {
|
|||
+ " " + SafeParse.stringToInt(editStartTime.editText.getText().toString())
|
||||
+ " " + SafeParse.stringToInt(editDuration.editText.getText().toString());
|
||||
ListenerService.initiateAction(ECarbActivity.this, actionstring);
|
||||
confirmAction(ECarbActivity.this, R.string.action_ecarb_confirmation);
|
||||
finishAffinity();
|
||||
}
|
||||
|
||||
});
|
||||
container.addView(view);
|
||||
return view;
|
||||
|
|
|
@ -63,17 +63,14 @@ public class FillActivity extends ViewSelectorActivity {
|
|||
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
|
||||
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
|
||||
confirmbutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
confirmbutton.setOnClickListener((View v) -> {
|
||||
//check if it can happen that the fagment is never created that hold data?
|
||||
// (you have to swipe past them anyways - but still)
|
||||
|
||||
String actionstring = "fill " + SafeParse.stringToDouble(editInsulin.editText.getText().toString());
|
||||
ListenerService.initiateAction(FillActivity.this, actionstring);
|
||||
confirmAction(FillActivity.this, R.string.action_fill_confirmation);
|
||||
finishAffinity();
|
||||
}
|
||||
});
|
||||
container.addView(view);
|
||||
return view;
|
||||
|
|
|
@ -4,11 +4,11 @@ import android.content.SharedPreferences;
|
|||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.wearable.view.GridPagerAdapter;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
|
@ -32,6 +32,9 @@ public class TempTargetActivity extends ViewSelectorActivity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (executeInBackground()){
|
||||
return;
|
||||
}
|
||||
setAdapter(new MyGridViewPagerAdapter());
|
||||
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
@ -39,6 +42,22 @@ public class TempTargetActivity extends ViewSelectorActivity {
|
|||
isSingleTarget = sp.getBoolean("singletarget", true);
|
||||
}
|
||||
|
||||
private boolean executeInBackground() {
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
String actionString = extras.getString("actionString", "");
|
||||
boolean inBackground = extras.getBoolean("inBackground", false);
|
||||
if (inBackground) {
|
||||
Log.i("ASTAG", "TempTargetActivity.onCreate: " + actionString);
|
||||
ListenerService.initiateAction(this, actionString);
|
||||
confirmAction(this, R.string.action_tempt_confirmation);
|
||||
finishAffinity();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
@ -61,8 +80,6 @@ public class TempTargetActivity extends ViewSelectorActivity {
|
|||
|
||||
if (col == 0) {
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
final TextView textView = view.findViewById(R.id.label);
|
||||
textView.setText("duration");
|
||||
if (time == null) {
|
||||
time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 60d, 0d, 24 * 60d, 5d, new DecimalFormat("0"), false);
|
||||
} else {
|
||||
|
@ -118,22 +135,19 @@ public class TempTargetActivity extends ViewSelectorActivity {
|
|||
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
|
||||
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
|
||||
confirmbutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
confirmbutton.setOnClickListener((View v) -> {
|
||||
//check if it can happen that the fagment is never created that hold data?
|
||||
// (you have to swipe past them anyways - but still)
|
||||
|
||||
String actionstring = "temptarget "
|
||||
String actionstring = "temptarget"
|
||||
+ " " + isMGDL
|
||||
+ " " + SafeParse.stringToInt(time.editText.getText().toString())
|
||||
+ " " + SafeParse.stringToDouble(lowRange.editText.getText().toString())
|
||||
+ " " + (isSingleTarget ? SafeParse.stringToDouble(lowRange.editText.getText().toString()) : SafeParse.stringToDouble(highRange.editText.getText().toString()));
|
||||
|
||||
ListenerService.initiateAction(TempTargetActivity.this, actionstring);
|
||||
confirmAction(TempTargetActivity.this, R.string.action_tempt_confirmation);
|
||||
finishAffinity();
|
||||
}
|
||||
});
|
||||
container.addView(view);
|
||||
return view;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.androidaps.interaction.actions;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
|
@ -11,6 +12,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.wear.widget.CurvedTextView;
|
||||
|
||||
|
@ -62,9 +64,9 @@ public class ViewSelectorActivity extends Activity {
|
|||
private void setTitleBasedOnScreenShape() {
|
||||
// intents can inject dynamic titles, otherwise we'll use the default
|
||||
String title = String.valueOf(getTitle());
|
||||
if (getIntent().getExtras() != null)
|
||||
if (getIntent().getExtras() != null) {
|
||||
title = getIntent().getExtras().getString("title", title);
|
||||
|
||||
}
|
||||
CurvedTextView titleViewCurved = findViewById(R.id.title_curved);
|
||||
TextView titleView = findViewById(R.id.title);
|
||||
if (this.getResources().getConfiguration().isScreenRound()) {
|
||||
|
@ -100,4 +102,8 @@ public class ViewSelectorActivity extends Activity {
|
|||
textView.setText(labelText);
|
||||
}
|
||||
|
||||
void confirmAction(Context context, int text) {
|
||||
Toast.makeText(context, getString(text), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,10 +82,7 @@ public class WizardActivity extends ViewSelectorActivity {
|
|||
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
|
||||
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
|
||||
confirmbutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
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)
|
||||
|
||||
|
@ -97,8 +94,8 @@ public class WizardActivity extends ViewSelectorActivity {
|
|||
String actionstring = "wizard2 " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
|
||||
+ " " + percentage;
|
||||
ListenerService.initiateAction(WizardActivity.this, actionstring);
|
||||
confirmAction(WizardActivity.this, R.string.action_wizard_confirmation);
|
||||
finishAffinity();
|
||||
}
|
||||
});
|
||||
container.addView(view);
|
||||
return view;
|
||||
|
|
|
@ -1,48 +1,50 @@
|
|||
package info.nightscout.androidaps.tile
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.TileConfigurationActivity
|
||||
import info.nightscout.androidaps.interaction.actions.BolusActivity
|
||||
import info.nightscout.androidaps.interaction.actions.ECarbActivity
|
||||
import info.nightscout.androidaps.interaction.actions.TempTargetActivity
|
||||
import info.nightscout.androidaps.interaction.actions.WizardActivity
|
||||
|
||||
data class Action(
|
||||
val id: Long,
|
||||
@StringRes val nameRes: Int,
|
||||
val activityClass: String,
|
||||
@DrawableRes val iconRes: Int,
|
||||
)
|
||||
object ActionSource: TileSource {
|
||||
|
||||
object ActionSource {
|
||||
|
||||
fun getActions(): List<Action> {
|
||||
override fun getActions(): List<Action> {
|
||||
return listOf(
|
||||
Action(
|
||||
id = 0,
|
||||
settingName = "wizzard",
|
||||
nameRes = R.string.menu_wizard,
|
||||
iconRes = R.drawable.ic_calculator_green,
|
||||
activityClass = WizardActivity::class.java.getName(),
|
||||
activityClass = TileConfigurationActivity::class.java.getName(),
|
||||
background = false,
|
||||
actionString = "",
|
||||
),
|
||||
Action(
|
||||
id = 1,
|
||||
settingName = "bolus",
|
||||
nameRes = R.string.action_bolus,
|
||||
iconRes = R.drawable.ic_bolus_carbs,
|
||||
activityClass = BolusActivity::class.java.getName(),
|
||||
background = false,
|
||||
actionString = "",
|
||||
),
|
||||
Action(
|
||||
id = 2,
|
||||
settingName = "carbs",
|
||||
nameRes = R.string.action_carbs,
|
||||
iconRes = R.drawable.ic_carbs_orange,
|
||||
activityClass = ECarbActivity::class.java.getName(),
|
||||
background = false,
|
||||
actionString = "",
|
||||
),
|
||||
Action(
|
||||
id = 3,
|
||||
settingName = "temp_target",
|
||||
nameRes = R.string.menu_tempt,
|
||||
iconRes = R.drawable.ic_temptarget_flat,
|
||||
activityClass = TempTargetActivity::class.java.getName(),
|
||||
background = false,
|
||||
actionString = "",
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,172 +1,8 @@
|
|||
package info.nightscout.androidaps.tile
|
||||
|
||||
import androidx.core.content.ContextCompat
|
||||
|
||||
import androidx.wear.tiles.ActionBuilders
|
||||
import androidx.wear.tiles.ColorBuilders.argb
|
||||
import androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
|
||||
import androidx.wear.tiles.DimensionBuilders.dp
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Box
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Column
|
||||
import androidx.wear.tiles.LayoutElementBuilders.FontStyles
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Image
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Layout
|
||||
import androidx.wear.tiles.LayoutElementBuilders.LayoutElement
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Row
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Spacer
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Text
|
||||
import androidx.wear.tiles.ModifiersBuilders.Background
|
||||
import androidx.wear.tiles.ModifiersBuilders.Clickable
|
||||
import androidx.wear.tiles.ModifiersBuilders.Corner
|
||||
import androidx.wear.tiles.ModifiersBuilders.Modifiers
|
||||
import androidx.wear.tiles.ModifiersBuilders.Semantics
|
||||
import androidx.wear.tiles.RequestBuilders
|
||||
import androidx.wear.tiles.RequestBuilders.ResourcesRequest
|
||||
import androidx.wear.tiles.ResourceBuilders.AndroidImageResourceByResId
|
||||
import androidx.wear.tiles.ResourceBuilders.ImageResource
|
||||
import androidx.wear.tiles.ResourceBuilders.Resources
|
||||
import androidx.wear.tiles.TileBuilders.Tile
|
||||
import androidx.wear.tiles.TileService
|
||||
import androidx.wear.tiles.TimelineBuilders.Timeline
|
||||
import androidx.wear.tiles.TimelineBuilders.TimelineEntry
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
|
||||
import info.nightscout.androidaps.R
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.guava.future
|
||||
|
||||
private const val RESOURCES_VERSION = "1"
|
||||
private const val ID_IC_ACTION_PREFIX = "ic_action_"
|
||||
private const val CIRCLE_SIZE = 75f
|
||||
private val ICON_SIZE = dp(25f)
|
||||
private val SPACING_ACTIONS = dp(3f)
|
||||
private const val BUTTON_COLOR = R.color.gray_850
|
||||
|
||||
class ActionsTileService : TileService() {
|
||||
|
||||
private val serviceJob = Job()
|
||||
private val serviceScope = CoroutineScope(Dispatchers.IO + serviceJob)
|
||||
|
||||
override fun onTileRequest(
|
||||
requestParams: RequestBuilders.TileRequest
|
||||
): ListenableFuture<Tile> = serviceScope.future {
|
||||
val actions = ActionSource.getActions().take(4)
|
||||
Tile.Builder()
|
||||
.setResourcesVersion(RESOURCES_VERSION)
|
||||
.setTimeline(
|
||||
Timeline.Builder().addTimelineEntry(
|
||||
TimelineEntry.Builder().setLayout(
|
||||
Layout.Builder().setRoot(layout(actions, requestParams.deviceParameters!!)).build()
|
||||
).build()
|
||||
).build()
|
||||
)
|
||||
.build()
|
||||
}
|
||||
|
||||
override fun onResourcesRequest(
|
||||
requestParams: ResourcesRequest
|
||||
): ListenableFuture<Resources> = serviceScope.future {
|
||||
val actions = ActionSource.getActions().take(4)
|
||||
Resources.Builder()
|
||||
.setVersion(RESOURCES_VERSION)
|
||||
.apply {
|
||||
actions.mapNotNull { action ->
|
||||
addIdToImageMapping(
|
||||
ID_IC_ACTION_PREFIX + action.id,
|
||||
ImageResource.Builder()
|
||||
.setAndroidResourceByResId(
|
||||
AndroidImageResourceByResId.Builder()
|
||||
.setResourceId(action.iconRes)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun layout(actions: List<Action>, deviceParameters: DeviceParameters): LayoutElement =
|
||||
Column.Builder()
|
||||
.addContent(
|
||||
Row.Builder()
|
||||
.addContent(action(actions[0], deviceParameters))
|
||||
.addContent(Spacer.Builder().setWidth(SPACING_ACTIONS).build())
|
||||
.addContent(action(actions[1], deviceParameters))
|
||||
.build()
|
||||
)
|
||||
.addContent(Spacer.Builder().setHeight(SPACING_ACTIONS).build())
|
||||
.addContent(
|
||||
Row.Builder()
|
||||
.addContent(action(actions[2], deviceParameters))
|
||||
.addContent(Spacer.Builder().setWidth(SPACING_ACTIONS).build())
|
||||
.addContent(action(actions[3], deviceParameters))
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
|
||||
private fun action(action: Action, deviceParameters: DeviceParameters) = Box.Builder()
|
||||
.setWidth(dp(CIRCLE_SIZE))
|
||||
.setHeight(dp(CIRCLE_SIZE))
|
||||
.setModifiers(
|
||||
Modifiers.Builder()
|
||||
.setBackground(
|
||||
Background.Builder()
|
||||
.setColor(
|
||||
argb(ContextCompat.getColor(baseContext, BUTTON_COLOR))
|
||||
)
|
||||
.setCorner(
|
||||
Corner.Builder().setRadius(dp(CIRCLE_SIZE / 2)).build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.setSemantics(
|
||||
Semantics.Builder()
|
||||
.setContentDescription(resources.getString(action.nameRes))
|
||||
.build()
|
||||
)
|
||||
.setClickable(
|
||||
Clickable.Builder()
|
||||
.setOnClick(
|
||||
ActionBuilders.LaunchAction.Builder()
|
||||
.setAndroidActivity(
|
||||
ActionBuilders.AndroidActivity.Builder()
|
||||
.setClassName(action.activityClass)
|
||||
.setPackageName(this.packageName)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.addContent(
|
||||
Column.Builder()
|
||||
.addContent(
|
||||
Image.Builder()
|
||||
.setWidth(ICON_SIZE)
|
||||
.setHeight(ICON_SIZE)
|
||||
.setResourceId(ID_IC_ACTION_PREFIX + action.id)
|
||||
.build()
|
||||
).addContent(
|
||||
Text.Builder()
|
||||
.setText(resources.getString(action.nameRes))
|
||||
.setFontStyle(
|
||||
FontStyles
|
||||
.button(deviceParameters)
|
||||
.setColor(
|
||||
argb(ContextCompat.getColor(baseContext, R.color.white))
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
).build()
|
||||
)
|
||||
.build()
|
||||
|
||||
class ActionsTileService : TileBase(){
|
||||
override val preferencePrefix = "tile_action_"
|
||||
override val resourceVersion = "1"
|
||||
override val idIconActionPrefix = "ic_action_"
|
||||
override val source = ActionSource
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package info.nightscout.androidaps.tile
|
||||
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.actions.TempTargetActivity
|
||||
|
||||
object TempTargetSource: TileSource {
|
||||
|
||||
override fun getActions(): List<Action> {
|
||||
return listOf(
|
||||
Action(
|
||||
id = 0,
|
||||
settingName = "activity",
|
||||
nameRes = R.string.temp_target_activity,
|
||||
iconRes = R.drawable.ic_target_activity,
|
||||
activityClass = TempTargetActivity::class.java.getName(),
|
||||
background = true,
|
||||
actionString = "temptarget false 90 8.0 8.0",
|
||||
// actionString = "temptarget preset activity",
|
||||
),
|
||||
Action(
|
||||
id = 1,
|
||||
settingName = "eating_soon",
|
||||
nameRes = R.string.temp_target_eating_soon,
|
||||
iconRes = R.drawable.ic_target_eatingsoon,
|
||||
activityClass = TempTargetActivity::class.java.getName(),
|
||||
background = true,
|
||||
actionString = "temptarget false 45 4.5 4.5",
|
||||
//actionString = "temptarget preset eating",
|
||||
),
|
||||
Action(
|
||||
id = 2,
|
||||
settingName = "hypo",
|
||||
nameRes = R.string.temp_target_hypo,
|
||||
iconRes = R.drawable.ic_target_hypo,
|
||||
activityClass = TempTargetActivity::class.java.getName(),
|
||||
background = true,
|
||||
actionString = "temptarget false 45 7.0 7.0",
|
||||
// actionString = "temptarget preset hypo",
|
||||
),
|
||||
Action(
|
||||
id = 3,
|
||||
settingName = "manual",
|
||||
nameRes = R.string.temp_target_manual,
|
||||
iconRes = R.drawable.ic_target_manual,
|
||||
activityClass = TempTargetActivity::class.java.getName(),
|
||||
actionString = "",
|
||||
background = false,
|
||||
),
|
||||
Action(
|
||||
id = 4,
|
||||
settingName = "cancel",
|
||||
nameRes = R.string.generic_cancel,
|
||||
iconRes = R.drawable.ic_target_cancel,
|
||||
activityClass = TempTargetActivity::class.java.getName(),
|
||||
actionString = "temptarget cancel",
|
||||
background = false,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package info.nightscout.androidaps.tile
|
||||
|
||||
class TempTargetTileService : TileBase(){
|
||||
|
||||
override val preferencePrefix = "tile_tempt_"
|
||||
override val resourceVersion = "1"
|
||||
override val idIconActionPrefix = "ic_tempt_"
|
||||
override val source = TempTargetSource;
|
||||
|
||||
}
|
253
wear/src/main/java/info/nightscout/androidaps/tile/TileBase.kt
Normal file
253
wear/src/main/java/info/nightscout/androidaps/tile/TileBase.kt
Normal file
|
@ -0,0 +1,253 @@
|
|||
package info.nightscout.androidaps.tile
|
||||
|
||||
import android.util.Log
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.core.content.ContextCompat
|
||||
|
||||
import androidx.wear.tiles.ActionBuilders
|
||||
import androidx.wear.tiles.ColorBuilders.argb
|
||||
import androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
|
||||
import androidx.wear.tiles.DimensionBuilders.dp
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Box
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Column
|
||||
import androidx.wear.tiles.LayoutElementBuilders.FontStyles
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Image
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Layout
|
||||
import androidx.wear.tiles.LayoutElementBuilders.LayoutElement
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Row
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Spacer
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Text
|
||||
import androidx.wear.tiles.ModifiersBuilders.Background
|
||||
import androidx.wear.tiles.ModifiersBuilders.Clickable
|
||||
import androidx.wear.tiles.ModifiersBuilders.Corner
|
||||
import androidx.wear.tiles.ModifiersBuilders.Modifiers
|
||||
import androidx.wear.tiles.ModifiersBuilders.Semantics
|
||||
import androidx.wear.tiles.RequestBuilders
|
||||
import androidx.wear.tiles.RequestBuilders.ResourcesRequest
|
||||
import androidx.wear.tiles.ResourceBuilders.AndroidImageResourceByResId
|
||||
import androidx.wear.tiles.ResourceBuilders.ImageResource
|
||||
import androidx.wear.tiles.ResourceBuilders.Resources
|
||||
import androidx.wear.tiles.TileBuilders.Tile
|
||||
import androidx.wear.tiles.TileService
|
||||
import androidx.wear.tiles.TimelineBuilders.Timeline
|
||||
import androidx.wear.tiles.TimelineBuilders.TimelineEntry
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
|
||||
import info.nightscout.androidaps.R
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.guava.future
|
||||
|
||||
private const val CIRCLE_SIZE = 75f
|
||||
private val ICON_SIZE = dp(25f)
|
||||
private val SPACING_ACTIONS = dp(3f)
|
||||
private const val BUTTON_COLOR = R.color.gray_850
|
||||
private var sharedPrefs: SharedPreferences? = null
|
||||
|
||||
interface TileSource {
|
||||
fun getActions(): List<Action>
|
||||
}
|
||||
|
||||
data class Action(
|
||||
val id: Int,
|
||||
val settingName: String,
|
||||
@StringRes val nameRes: Int,
|
||||
val activityClass: String,
|
||||
@DrawableRes val iconRes: Int,
|
||||
val background: Boolean?,
|
||||
val actionString: String?,
|
||||
)
|
||||
|
||||
const val TAG = "ASTAG-tile"
|
||||
|
||||
open class TileBase : TileService(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
open val preferencePrefix = "tile_action_"
|
||||
open val resourceVersion = "1"
|
||||
open val idIconActionPrefix = "ic_action_"
|
||||
open val source: TileSource = ActionSource
|
||||
|
||||
private val serviceJob = Job()
|
||||
private val serviceScope = CoroutineScope(Dispatchers.IO + serviceJob)
|
||||
private val actionsSelected: MutableList<Action> = mutableListOf()
|
||||
private val actionsAll: MutableList<Action> = mutableListOf()
|
||||
|
||||
override fun onCreate() {
|
||||
Log.i(TAG, "onCreate: ")
|
||||
super.onCreate()
|
||||
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
sharedPrefs?.registerOnSharedPreferenceChangeListener(this)
|
||||
actionsAll.addAll(source.getActions())
|
||||
actionsSelected.addAll(getSelectedActions())
|
||||
}
|
||||
|
||||
override fun onTileRequest(
|
||||
requestParams: RequestBuilders.TileRequest
|
||||
): ListenableFuture<Tile> = serviceScope.future {
|
||||
Log.i(TAG, "onTileRequest: ")
|
||||
Tile.Builder()
|
||||
.setResourcesVersion(resourceVersion)
|
||||
.setTimeline(
|
||||
Timeline.Builder().addTimelineEntry(
|
||||
TimelineEntry.Builder().setLayout(
|
||||
Layout.Builder().setRoot(layout(actionsSelected, requestParams.deviceParameters!!)).build()
|
||||
).build()
|
||||
).build()
|
||||
)
|
||||
.build()
|
||||
}
|
||||
|
||||
override fun onResourcesRequest(
|
||||
requestParams: ResourcesRequest
|
||||
): ListenableFuture<Resources> = serviceScope.future {
|
||||
Log.i(TAG, "onResourcesRequest: ")
|
||||
Resources.Builder()
|
||||
.setVersion(resourceVersion)
|
||||
.apply {
|
||||
actionsAll.mapNotNull { action ->
|
||||
addIdToImageMapping(
|
||||
idIconActionPrefix + action.id,
|
||||
ImageResource.Builder()
|
||||
.setAndroidResourceByResId(
|
||||
AndroidImageResourceByResId.Builder()
|
||||
.setResourceId(action.iconRes)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun addRowSingle(action1: Action, deviceParameters: DeviceParameters): LayoutElement =
|
||||
Row.Builder()
|
||||
.addContent(action(action1, deviceParameters))
|
||||
.build()
|
||||
|
||||
private fun addRowDouble(action1: Action, action2: Action, deviceParameters: DeviceParameters): LayoutElement =
|
||||
Row.Builder()
|
||||
.addContent(action(action1, deviceParameters))
|
||||
.addContent(Spacer.Builder().setWidth(SPACING_ACTIONS).build())
|
||||
.addContent(action(action2, deviceParameters))
|
||||
.build()
|
||||
|
||||
private fun layout(actions: List<Action>, deviceParameters: DeviceParameters): LayoutElement {
|
||||
if (actions.isNotEmpty()) {
|
||||
val b = Column.Builder()
|
||||
if (actions.size == 1 || actions.size == 3) {
|
||||
b.addContent(addRowSingle(actions[0], deviceParameters))
|
||||
}
|
||||
if (actions.size == 4 || actions.size == 2) {
|
||||
b.addContent(addRowDouble(actions[0], actions[1], deviceParameters))
|
||||
}
|
||||
if (actions.size == 3) {
|
||||
b.addContent(addRowDouble(actions[1], actions[2], deviceParameters))
|
||||
}
|
||||
if (actions.size == 4) {
|
||||
b.addContent(Spacer.Builder().setHeight(SPACING_ACTIONS).build())
|
||||
.addContent(addRowDouble(actions[2], actions[3], deviceParameters))
|
||||
}
|
||||
return b.build()
|
||||
}
|
||||
return Text.Builder()
|
||||
.setText(resources.getString(R.string.tile_no_config))
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun doAction(action: Action): ActionBuilders.Action {
|
||||
val ab = ActionBuilders.AndroidActivity.Builder()
|
||||
.setClassName(action.activityClass)
|
||||
.setPackageName(this.packageName)
|
||||
if (action.actionString != null) {
|
||||
ab.addKeyToExtraMapping("actionString", ActionBuilders.AndroidStringExtra.Builder().setValue(action.actionString).build())
|
||||
}
|
||||
if (action.background != null) {
|
||||
ab.addKeyToExtraMapping("inBackground", ActionBuilders.AndroidBooleanExtra.Builder().setValue(action.background).build())
|
||||
}
|
||||
return ActionBuilders.LaunchAction.Builder()
|
||||
.setAndroidActivity(ab.build())
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun action(action: Action, deviceParameters: DeviceParameters) = Box.Builder()
|
||||
.setWidth(dp(CIRCLE_SIZE))
|
||||
.setHeight(dp(CIRCLE_SIZE))
|
||||
.setModifiers(
|
||||
Modifiers.Builder()
|
||||
.setBackground(
|
||||
Background.Builder()
|
||||
.setColor(
|
||||
argb(ContextCompat.getColor(baseContext, BUTTON_COLOR))
|
||||
)
|
||||
.setCorner(
|
||||
Corner.Builder().setRadius(dp(CIRCLE_SIZE / 2)).build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.setSemantics(
|
||||
Semantics.Builder()
|
||||
.setContentDescription(resources.getString(action.nameRes))
|
||||
.build()
|
||||
)
|
||||
.setClickable(
|
||||
Clickable.Builder()
|
||||
.setOnClick(doAction(action))
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.addContent(
|
||||
Column.Builder()
|
||||
.addContent(
|
||||
Image.Builder()
|
||||
.setWidth(ICON_SIZE)
|
||||
.setHeight(ICON_SIZE)
|
||||
.setResourceId(idIconActionPrefix + action.id)
|
||||
.build()
|
||||
).addContent(
|
||||
Text.Builder()
|
||||
.setText(resources.getString(action.nameRes))
|
||||
.setFontStyle(
|
||||
FontStyles
|
||||
.button(deviceParameters)
|
||||
.setColor(
|
||||
argb(ContextCompat.getColor(baseContext, R.color.white))
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
).build()
|
||||
)
|
||||
.build()
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
Log.i(TAG, "onSharedPreferenceChanged: ")
|
||||
getUpdater(this).requestUpdate(this::class.java)
|
||||
}
|
||||
|
||||
private fun getSelectedActions(): List<Action> {
|
||||
val actionList: MutableList<Action> = mutableListOf()
|
||||
for (i in 0..4) {
|
||||
val action = getActionFromPreference(i)
|
||||
if (action != null) {
|
||||
actionList.add(action)
|
||||
}
|
||||
}
|
||||
Log.i(TAG, "getSelectedActions: " + actionList.toString())
|
||||
return actionList
|
||||
}
|
||||
|
||||
private fun getActionFromPreference(index: Int): Action? {
|
||||
val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
val actionPref = sharedPrefs.getString(preferencePrefix + index, "none")
|
||||
return actionsAll.find { a -> a.settingName == actionPref }
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 177 KiB After Width: | Height: | Size: 23 KiB |
BIN
wear/src/main/res/drawable-notround-nodpi/temp_target_tile.png
Normal file
BIN
wear/src/main/res/drawable-notround-nodpi/temp_target_tile.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
Binary file not shown.
Before Width: | Height: | Size: 177 KiB After Width: | Height: | Size: 28 KiB |
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
18
wear/src/main/res/drawable/ic_target_activity.xml
Normal file
18
wear/src/main/res/drawable/ic_target_activity.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M18.253,15.869c1.19,0 2.158,-1.02 2.158,-2.274c0,-1.254 -0.968,-2.275 -2.158,-2.275c-1.19,0 -2.158,1.02 -2.158,2.275C16.095,14.849 17.063,15.869 18.253,15.869zM18.253,12.018c0.824,0 1.496,0.707 1.496,1.576c0,0.869 -0.671,1.576 -1.496,1.576s-1.496,-0.707 -1.496,-1.576C16.757,12.725 17.429,12.018 18.253,12.018z"
|
||||
android:fillColor="@color/exercise"/>
|
||||
<path
|
||||
android:pathData="M21.442,18.522c-0.03,-0.043 -0.745,-1.039 -1.801,-1.039c-0.785,0 -1.295,0.514 -1.746,0.969c-0.399,0.402 -0.744,0.75 -1.226,0.75h-0.001c-0.393,0 -0.714,-0.242 -1.034,-0.538l1.665,-1.325l-4.553,-6.356l-4.394,3.496c-0.259,0.242 -0.627,0.87 -0.164,1.515c0.214,0.298 0.463,0.387 0.635,0.41c0.409,0.053 0.738,-0.217 0.765,-0.24l2.759,-2.195l0.676,0.943l-3.964,3.153c-0.371,-0.351 -0.791,-0.637 -1.305,-0.637H7.753c-0.788,0 -1.457,0.64 -2.048,1.205c-0.352,0.337 -0.752,0.72 -0.973,0.72c-0.428,0 -0.982,-0.647 -1.142,-0.874c-0.109,-0.154 -0.316,-0.186 -0.464,-0.071c-0.147,0.115 -0.178,0.333 -0.069,0.488c0.083,0.119 0.837,1.155 1.674,1.155c0.477,0 0.913,-0.417 1.418,-0.9c0.502,-0.48 1.071,-1.024 1.603,-1.024h0c0.469,0 0.879,0.45 1.313,0.927c0.482,0.529 0.981,1.077 1.659,1.077c0.647,0 1.193,-0.472 1.722,-0.929c0.494,-0.427 1.005,-0.868 1.542,-0.868c0.321,0.001 0.622,0.293 0.97,0.631c0.453,0.439 0.965,0.936 1.71,0.936h0.001c0.748,0 1.245,-0.501 1.684,-0.943c0.413,-0.416 0.769,-0.776 1.287,-0.776c0.719,0 1.264,0.751 1.269,0.759c0.11,0.155 0.317,0.184 0.464,0.07C21.52,18.894 21.551,18.677 21.442,18.522zM12.027,18.661c-0.459,0.396 -0.892,0.771 -1.301,0.771c-0.395,-0.001 -0.777,-0.42 -1.181,-0.862c-0.002,-0.003 -0.005,-0.005 -0.007,-0.008l4.415,-3.512l-1.475,-2.059L9.18,15.614c-0.022,0.019 -0.161,0.12 -0.276,0.096c-0.024,-0.003 -0.097,-0.012 -0.186,-0.136c-0.195,-0.273 0.01,-0.509 0.055,-0.555l3.844,-3.058l3.754,5.241l-1.24,0.986c-0.332,-0.301 -0.69,-0.554 -1.143,-0.554C13.214,17.635 12.584,18.18 12.027,18.661z"
|
||||
android:fillColor="@color/exercise"/>
|
||||
<path
|
||||
android:pathData="M5.453,9.325c-0.003,0 -0.006,0 -0.01,0C5.031,9.317 4.661,8.827 4.43,7.979C4.261,7.361 4.108,6.716 3.96,6.092C3.867,5.701 3.774,5.31 3.677,4.924l-0.064,-0.26C3.394,3.77 3.168,2.847 2.577,2.743C2.509,2.731 2.463,2.665 2.475,2.595c0.012,-0.07 0.077,-0.114 0.146,-0.104c0.752,0.133 0.999,1.138 1.237,2.11l0.064,0.259c0.097,0.388 0.19,0.78 0.283,1.172c0.147,0.622 0.3,1.264 0.468,1.878C4.864,8.61 5.168,9.064 5.448,9.069c0.001,0 0.003,0 0.005,0c0.263,0 0.537,-0.394 0.753,-1.083C6.317,7.63 6.413,7.247 6.505,6.877l0.074,-0.293C6.66,6.262 6.737,5.935 6.815,5.609C6.973,4.94 7.137,4.248 7.336,3.608c0.221,-0.71 0.551,-1.103 0.928,-1.106c0.002,0 0.003,0 0.005,0c0.379,0 0.717,0.39 0.951,1.1c0.165,0.5 0.305,1.039 0.439,1.56l0.105,0.403c0.087,0.332 0.171,0.668 0.255,1.004c0.143,0.574 0.29,1.169 0.456,1.729c0.136,0.462 0.367,0.757 0.603,0.769c0.211,0.026 0.432,-0.218 0.6,-0.625c0.161,-0.391 0.309,-0.847 0.451,-1.393c0.198,-0.76 0.385,-1.53 0.572,-2.3c0.086,-0.355 0.173,-0.711 0.26,-1.065c0.167,-0.676 0.481,-1.066 0.961,-1.191c0.066,-0.017 0.136,0.024 0.154,0.092c0.017,0.068 -0.023,0.138 -0.091,0.156c-0.387,0.101 -0.634,0.421 -0.779,1.005c-0.087,0.354 -0.174,0.709 -0.26,1.064c-0.188,0.771 -0.375,1.543 -0.573,2.304c-0.145,0.557 -0.297,1.024 -0.462,1.426c-0.289,0.703 -0.651,0.793 -0.846,0.782c-0.35,-0.018 -0.661,-0.374 -0.832,-0.951c-0.167,-0.565 -0.315,-1.163 -0.459,-1.74c-0.083,-0.335 -0.166,-0.67 -0.253,-1.001L9.415,5.226C9.282,4.709 9.143,4.174 8.981,3.682c-0.192,-0.58 -0.458,-0.926 -0.712,-0.926c-0.001,0 -0.001,0 -0.002,0c-0.252,0.002 -0.51,0.349 -0.69,0.928C7.38,4.316 7.217,5.004 7.06,5.668C6.982,5.996 6.905,6.324 6.823,6.647L6.75,6.939C6.656,7.314 6.56,7.701 6.446,8.063C6.121,9.103 5.728,9.325 5.453,9.325z"
|
||||
android:fillColor="@color/inrange"/>
|
||||
<path
|
||||
android:pathData="M13.949,6.338h-2.831c-0.232,0 -0.421,-0.193 -0.421,-0.431V4.19H5.856l0,1.717c0,0.238 -0.188,0.431 -0.42,0.431h-2.84c-0.232,0 -0.42,-0.193 -0.42,-0.431c0,-0.238 0.188,-0.431 0.42,-0.431h2.42l0,-1.717c0,-0.238 0.188,-0.431 0.42,-0.431h5.682c0.232,0 0.421,0.193 0.421,0.431v1.717h2.411c0.232,0 0.421,0.193 0.421,0.431C14.37,6.145 14.181,6.338 13.949,6.338z"
|
||||
android:fillColor="@color/tempTargetConfirmation"/>
|
||||
</vector>
|
15
wear/src/main/res/drawable/ic_target_cancel.xml
Normal file
15
wear/src/main/res/drawable/ic_target_cancel.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M16.954,15.325l3.851,-3.85c0.314,-0.314 0.314,-0.821 0.001,-1.134c-0.315,-0.315 -0.82,-0.314 -1.134,-0.001l-3.851,3.851l-3.851,-3.851c-0.315,-0.313 -0.821,-0.314 -1.134,0.001c-0.313,0.313 -0.313,0.82 0.001,1.134l3.851,3.85l-3.851,3.851c-0.314,0.313 -0.314,0.82 -0.001,1.133c0.157,0.156 0.362,0.235 0.567,0.235s0.41,-0.078 0.567,-0.235l3.851,-3.85l3.851,3.85c0.157,0.156 0.362,0.235 0.567,0.235c0.205,0 0.411,-0.078 0.567,-0.235c0.313,-0.313 0.313,-0.82 -0.001,-1.133L16.954,15.325z"
|
||||
android:fillColor="@color/tempTargetConfirmation"/>
|
||||
<path
|
||||
android:pathData="M5.453,9.325c-0.003,0 -0.006,0 -0.01,0C5.031,9.317 4.661,8.827 4.43,7.979C4.261,7.361 4.108,6.716 3.96,6.092C3.867,5.701 3.774,5.31 3.677,4.924l-0.064,-0.26C3.394,3.77 3.168,2.847 2.577,2.743C2.509,2.731 2.463,2.665 2.475,2.595c0.012,-0.07 0.077,-0.114 0.146,-0.104c0.752,0.133 0.999,1.138 1.237,2.11l0.064,0.259c0.097,0.388 0.19,0.78 0.283,1.172c0.147,0.622 0.3,1.264 0.468,1.878C4.864,8.61 5.168,9.064 5.448,9.069c0.001,0 0.003,0 0.005,0c0.263,0 0.537,-0.394 0.753,-1.083C6.317,7.63 6.413,7.247 6.505,6.877l0.074,-0.293C6.66,6.262 6.737,5.935 6.815,5.609C6.973,4.94 7.137,4.248 7.336,3.608c0.221,-0.71 0.551,-1.103 0.928,-1.106c0.002,0 0.003,0 0.005,0c0.379,0 0.717,0.39 0.951,1.1c0.165,0.5 0.305,1.039 0.439,1.56l0.105,0.403c0.087,0.332 0.171,0.668 0.255,1.004c0.143,0.574 0.29,1.169 0.456,1.729c0.136,0.462 0.367,0.757 0.603,0.769c0.211,0.026 0.432,-0.218 0.6,-0.625c0.161,-0.391 0.309,-0.847 0.451,-1.393c0.198,-0.76 0.385,-1.53 0.572,-2.3c0.086,-0.355 0.173,-0.711 0.26,-1.065c0.167,-0.676 0.481,-1.066 0.961,-1.191c0.066,-0.017 0.136,0.024 0.154,0.092c0.017,0.068 -0.023,0.138 -0.091,0.156c-0.387,0.101 -0.634,0.421 -0.779,1.005c-0.087,0.354 -0.174,0.709 -0.26,1.064c-0.188,0.771 -0.375,1.543 -0.573,2.304c-0.145,0.557 -0.297,1.024 -0.462,1.426c-0.289,0.703 -0.651,0.793 -0.846,0.782c-0.35,-0.018 -0.661,-0.374 -0.832,-0.951c-0.167,-0.565 -0.315,-1.163 -0.459,-1.74c-0.083,-0.335 -0.166,-0.67 -0.253,-1.001L9.415,5.226C9.282,4.709 9.143,4.174 8.981,3.682c-0.192,-0.58 -0.458,-0.926 -0.712,-0.926c-0.001,0 -0.001,0 -0.002,0c-0.252,0.002 -0.51,0.349 -0.69,0.928C7.38,4.316 7.217,5.004 7.06,5.668C6.982,5.996 6.905,6.324 6.823,6.647L6.75,6.939C6.656,7.314 6.56,7.701 6.446,8.063C6.121,9.103 5.728,9.325 5.453,9.325z"
|
||||
android:fillColor="@color/inrange"/>
|
||||
<path
|
||||
android:pathData="M13.949,6.338H2.595c-0.232,0 -0.42,-0.193 -0.42,-0.431c0,-0.238 0.188,-0.431 0.42,-0.431h11.354c0.232,0 0.421,0.193 0.421,0.431C14.37,6.145 14.181,6.338 13.949,6.338z"
|
||||
android:fillColor="@color/tempTargetConfirmation"/>
|
||||
</vector>
|
21
wear/src/main/res/drawable/ic_target_eatingsoon.xml
Normal file
21
wear/src/main/res/drawable/ic_target_eatingsoon.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M21.107,18.396h-0.515c-0.23,-3.231 -2.587,-5.897 -5.66,-6.605c-0.089,-0.819 -0.777,-1.462 -1.62,-1.462c-0.843,0 -1.531,0.642 -1.62,1.462c-3.073,0.708 -5.429,3.374 -5.66,6.605H5.518c-0.221,0 -0.4,0.179 -0.4,0.4c0,0.221 0.179,0.4 0.4,0.4h15.59c0.221,0 0.4,-0.179 0.4,-0.4C21.507,18.575 21.328,18.396 21.107,18.396zM13.313,10.943c0.461,0 0.836,0.311 0.964,0.73c-0.317,-0.043 -0.637,-0.072 -0.964,-0.072c-0.327,0 -0.648,0.03 -0.965,0.072C12.477,11.254 12.852,10.943 13.313,10.943zM13.313,12.401c3.391,0 6.212,2.654 6.479,5.995H6.834C7.101,15.056 9.922,12.401 13.313,12.401z"
|
||||
android:fillColor="@color/carbs"/>
|
||||
<path
|
||||
android:pathData="M15.428,13.489c-0.588,-0.271 -1.415,-0.457 -2.268,-0.509c-0.221,-0.014 -0.411,0.154 -0.424,0.375c-0.014,0.221 0.154,0.411 0.375,0.424c0.746,0.046 1.487,0.209 1.981,0.437c0.047,0.021 0.095,0.033 0.143,0.036c0.16,0.01 0.317,-0.078 0.388,-0.232C15.717,13.82 15.629,13.582 15.428,13.489z"
|
||||
android:fillColor="@color/carbs"/>
|
||||
<path
|
||||
android:pathData="M8.051,17.801c-0.029,0.001 -0.061,-0.003 -0.095,-0.011c-0.188,-0.047 -0.304,-0.239 -0.257,-0.427c0.43,-1.726 1.665,-3.196 3.304,-3.933c0.043,-0.019 0.088,-0.029 0.135,-0.031c0.143,-0.004 0.273,0.078 0.331,0.208c0.039,0.086 0.042,0.182 0.008,0.271c-0.034,0.088 -0.099,0.158 -0.185,0.196c-1.444,0.649 -2.531,1.942 -2.909,3.458C8.346,17.687 8.209,17.797 8.051,17.801z"
|
||||
android:fillColor="@color/carbs"/>
|
||||
<path
|
||||
android:pathData="M5.453,9.325c-0.003,0 -0.006,0 -0.01,0C5.031,9.317 4.661,8.827 4.43,7.979C4.261,7.361 4.108,6.716 3.96,6.092C3.867,5.701 3.774,5.31 3.677,4.924l-0.064,-0.26C3.394,3.77 3.168,2.847 2.577,2.743C2.509,2.731 2.463,2.665 2.475,2.595c0.012,-0.07 0.077,-0.114 0.146,-0.104c0.752,0.133 0.999,1.138 1.237,2.11l0.064,0.259c0.097,0.388 0.19,0.78 0.283,1.172c0.147,0.622 0.3,1.264 0.468,1.878C4.864,8.61 5.168,9.064 5.448,9.069c0.001,0 0.003,0 0.005,0c0.263,0 0.537,-0.394 0.753,-1.083C6.317,7.63 6.413,7.247 6.505,6.877l0.074,-0.293C6.66,6.262 6.737,5.935 6.815,5.609C6.973,4.94 7.137,4.248 7.336,3.608c0.221,-0.71 0.551,-1.103 0.928,-1.106c0.002,0 0.003,0 0.005,0c0.379,0 0.717,0.39 0.951,1.1c0.165,0.5 0.305,1.039 0.439,1.56l0.105,0.403c0.087,0.332 0.171,0.668 0.255,1.004c0.143,0.574 0.29,1.169 0.456,1.729c0.136,0.462 0.367,0.757 0.603,0.769c0.211,0.026 0.432,-0.218 0.6,-0.625c0.161,-0.391 0.309,-0.847 0.451,-1.393c0.198,-0.76 0.385,-1.53 0.572,-2.3c0.086,-0.355 0.173,-0.711 0.26,-1.065c0.167,-0.676 0.481,-1.066 0.961,-1.191c0.066,-0.017 0.136,0.024 0.154,0.092c0.017,0.068 -0.023,0.138 -0.091,0.156c-0.387,0.101 -0.634,0.421 -0.779,1.005c-0.087,0.354 -0.174,0.709 -0.26,1.064c-0.188,0.771 -0.375,1.543 -0.573,2.304c-0.145,0.557 -0.297,1.024 -0.462,1.426c-0.289,0.703 -0.651,0.793 -0.846,0.782c-0.35,-0.018 -0.661,-0.374 -0.832,-0.951c-0.167,-0.565 -0.315,-1.163 -0.459,-1.74c-0.083,-0.335 -0.166,-0.67 -0.253,-1.001L9.415,5.226C9.282,4.709 9.143,4.174 8.981,3.682c-0.192,-0.58 -0.458,-0.926 -0.712,-0.926c-0.001,0 -0.001,0 -0.002,0c-0.252,0.002 -0.51,0.349 -0.69,0.928C7.38,4.316 7.217,5.004 7.06,5.668C6.982,5.996 6.905,6.324 6.823,6.647L6.75,6.939C6.656,7.314 6.56,7.701 6.446,8.063C6.121,9.103 5.728,9.325 5.453,9.325z"
|
||||
android:fillColor="@color/inrange"/>
|
||||
<path
|
||||
android:pathData="M11.122,8.486H5.436c-0.232,0 -0.42,-0.193 -0.42,-0.431l0,-1.717h-2.42c-0.232,0 -0.42,-0.193 -0.42,-0.431c0,-0.238 0.188,-0.431 0.42,-0.431h2.84c0.232,0 0.42,0.193 0.42,0.431l0,1.717h4.845V5.907c0,-0.238 0.188,-0.431 0.421,-0.431h2.827c0.232,0 0.421,0.193 0.421,0.431c0,0.238 -0.188,0.431 -0.421,0.431h-2.407v1.717C11.542,8.293 11.354,8.486 11.122,8.486z"
|
||||
android:fillColor="@color/tempTargetConfirmation"/>
|
||||
</vector>
|
21
wear/src/main/res/drawable/ic_target_hypo.xml
Normal file
21
wear/src/main/res/drawable/ic_target_hypo.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M8.822,17.137c-0.016,-0.28 0.022,-0.543 0.363,-0.583c0.313,-0.037 0.426,0.189 0.462,0.448c0.135,0.983 0.67,1.563 1.668,1.692c0.292,0.038 0.514,0.167 0.459,0.498c-0.051,0.305 -0.324,0.337 -0.568,0.336C10.03,19.526 8.835,18.321 8.822,17.137z"
|
||||
android:fillColor="@color/low"/>
|
||||
<path
|
||||
android:pathData="M15.21,16.109c-0.631,-2.484 -3.383,-6.32 -3.773,-6.32s-3.151,3.845 -3.779,6.324c-0.42,1.658 0.111,3.081 1.577,4.049c1.43,0.944 2.973,0.929 4.402,-0.013C15.106,19.18 15.634,17.779 15.21,16.109zM13.255,19.568c-0.603,0.397 -1.221,0.599 -1.835,0.599c-0.607,0 -1.213,-0.197 -1.802,-0.586c-1.206,-0.796 -1.639,-1.906 -1.287,-3.298c0.489,-1.929 2.895,-5.336 3.105,-5.336s2.609,3.403 3.1,5.333C14.889,17.668 14.458,18.774 13.255,19.568z"
|
||||
android:fillColor="@color/low"/>
|
||||
<path
|
||||
android:pathData="M19.522,16.771v-6.712h-1.423v6.712h-2.135l2.846,3.82l2.846,-3.82H19.522z"
|
||||
android:fillColor="@color/low"/>
|
||||
<path
|
||||
android:pathData="M5.453,9.325c-0.003,0 -0.006,0 -0.01,0C5.031,9.317 4.661,8.827 4.43,7.979C4.261,7.361 4.108,6.716 3.96,6.092C3.867,5.701 3.774,5.31 3.677,4.924l-0.064,-0.26C3.394,3.77 3.168,2.847 2.577,2.743C2.509,2.731 2.463,2.665 2.475,2.595c0.012,-0.07 0.077,-0.114 0.146,-0.104c0.752,0.133 0.999,1.138 1.237,2.11l0.064,0.259c0.097,0.388 0.19,0.78 0.283,1.172c0.147,0.622 0.3,1.264 0.468,1.878C4.864,8.61 5.168,9.064 5.448,9.069c0.001,0 0.003,0 0.005,0c0.263,0 0.537,-0.394 0.753,-1.083C6.317,7.63 6.413,7.247 6.505,6.877l0.074,-0.293C6.66,6.262 6.737,5.935 6.815,5.609C6.973,4.94 7.137,4.248 7.336,3.608c0.221,-0.71 0.551,-1.103 0.928,-1.106c0.002,0 0.003,0 0.005,0c0.379,0 0.717,0.39 0.951,1.1c0.165,0.5 0.305,1.039 0.439,1.56l0.105,0.403c0.087,0.332 0.171,0.668 0.255,1.004c0.143,0.574 0.29,1.169 0.456,1.729c0.136,0.462 0.367,0.757 0.603,0.769c0.211,0.026 0.432,-0.218 0.6,-0.625c0.161,-0.391 0.309,-0.847 0.451,-1.393c0.198,-0.76 0.385,-1.53 0.572,-2.3c0.086,-0.355 0.173,-0.711 0.26,-1.065c0.167,-0.676 0.481,-1.066 0.961,-1.191c0.066,-0.017 0.136,0.024 0.154,0.092c0.017,0.068 -0.023,0.138 -0.091,0.156c-0.387,0.101 -0.634,0.421 -0.779,1.005c-0.087,0.354 -0.174,0.709 -0.26,1.064c-0.188,0.771 -0.375,1.543 -0.573,2.304c-0.145,0.557 -0.297,1.024 -0.462,1.426c-0.289,0.703 -0.651,0.793 -0.846,0.782c-0.35,-0.018 -0.661,-0.374 -0.832,-0.951c-0.167,-0.565 -0.315,-1.163 -0.459,-1.74c-0.083,-0.335 -0.166,-0.67 -0.253,-1.001L9.415,5.226C9.282,4.709 9.143,4.174 8.981,3.682c-0.192,-0.58 -0.458,-0.926 -0.712,-0.926c-0.001,0 -0.001,0 -0.002,0c-0.252,0.002 -0.51,0.349 -0.69,0.928C7.38,4.316 7.217,5.004 7.06,5.668C6.982,5.996 6.905,6.324 6.823,6.647L6.75,6.939C6.656,7.314 6.56,7.701 6.446,8.063C6.121,9.103 5.728,9.325 5.453,9.325z"
|
||||
android:fillColor="@color/inrange"/>
|
||||
<path
|
||||
android:pathData="M13.949,6.338h-2.831c-0.232,0 -0.421,-0.193 -0.421,-0.431V4.19H5.856l0,1.717c0,0.238 -0.188,0.431 -0.42,0.431h-2.84c-0.232,0 -0.42,-0.193 -0.42,-0.431c0,-0.238 0.188,-0.431 0.42,-0.431h2.42l0,-1.717c0,-0.238 0.188,-0.431 0.42,-0.431h5.682c0.232,0 0.421,0.193 0.421,0.431v1.717h2.411c0.232,0 0.421,0.193 0.421,0.431C14.37,6.145 14.181,6.338 13.949,6.338z"
|
||||
android:fillColor="@color/tempTargetConfirmation"/>
|
||||
</vector>
|
15
wear/src/main/res/drawable/ic_target_manual.xml
Normal file
15
wear/src/main/res/drawable/ic_target_manual.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M16.438,8.901L9.729,15.61c-0.054,0.054 -0.09,0.122 -0.103,0.196L8.825,20.15c-0.022,0.121 0.016,0.245 0.103,0.332s0.211,0.126 0.332,0.103l4.343,-0.801c0.074,-0.014 0.143,-0.05 0.196,-0.103l6.709,-6.709c0.391,-0.391 0.39,-1.029 -0.002,-1.421l-2.648,-2.648C17.467,8.511 16.829,8.51 16.438,8.901zM12.907,18.755c0.085,0.085 0.116,0.211 0.08,0.326c-0.016,0.051 -0.044,0.096 -0.08,0.132c-0.046,0.046 -0.106,0.078 -0.173,0.09l-2.164,0.382c-0.215,-0.007 -0.428,-0.091 -0.592,-0.255c-0.164,-0.164 -0.248,-0.377 -0.255,-0.591l0.382,-2.164c0.021,-0.119 0.107,-0.216 0.222,-0.253c0.115,-0.036 0.241,-0.005 0.326,0.08L12.907,18.755zM19.949,12.025c0.124,0.124 0.124,0.324 0,0.447l-5.929,5.929c-0.124,0.124 -0.324,0.124 -0.447,0l-0.233,-0.233c-0.124,-0.124 -0.124,-0.324 0,-0.447l5.929,-5.929c0.124,-0.124 0.324,-0.124 0.447,0L19.949,12.025zM18.793,10.85c0.124,0.124 0.124,0.324 0,0.447l-5.929,5.929c-0.124,0.124 -0.324,0.124 -0.447,0l-0.233,-0.233c-0.124,-0.124 -0.124,-0.324 0,-0.447l5.929,-5.929c0.124,-0.124 0.324,-0.124 0.447,0L18.793,10.85zM17.637,9.675c0.124,0.124 0.124,0.324 0,0.447l-5.929,5.929c-0.124,0.124 -0.324,0.124 -0.447,0l-0.233,-0.233c-0.124,-0.124 -0.124,-0.324 0,-0.447l5.929,-5.929c0.124,-0.124 0.324,-0.124 0.447,0L17.637,9.675z"
|
||||
android:fillColor="@color/tempTargetConfirmation"/>
|
||||
<path
|
||||
android:pathData="M5.453,9.325c-0.003,0 -0.006,0 -0.01,0C5.031,9.317 4.661,8.827 4.43,7.979C4.261,7.361 4.108,6.716 3.96,6.092C3.867,5.701 3.774,5.31 3.677,4.924l-0.064,-0.26C3.394,3.77 3.168,2.847 2.577,2.743C2.509,2.731 2.463,2.665 2.475,2.595c0.012,-0.07 0.077,-0.114 0.146,-0.104c0.752,0.133 0.999,1.138 1.237,2.11l0.064,0.259c0.097,0.388 0.19,0.78 0.283,1.172c0.147,0.622 0.3,1.264 0.468,1.878C4.864,8.61 5.168,9.064 5.448,9.069c0.001,0 0.003,0 0.005,0c0.263,0 0.537,-0.394 0.753,-1.083C6.317,7.63 6.413,7.247 6.505,6.877l0.074,-0.293C6.66,6.262 6.737,5.935 6.815,5.609C6.973,4.94 7.137,4.248 7.336,3.608c0.221,-0.71 0.551,-1.103 0.928,-1.106c0.002,0 0.003,0 0.005,0c0.379,0 0.717,0.39 0.951,1.1c0.165,0.5 0.305,1.039 0.439,1.56l0.105,0.403c0.087,0.332 0.171,0.668 0.255,1.004c0.143,0.574 0.29,1.169 0.456,1.729c0.136,0.462 0.367,0.757 0.603,0.769c0.211,0.026 0.432,-0.218 0.6,-0.625c0.161,-0.391 0.309,-0.847 0.451,-1.393c0.198,-0.76 0.385,-1.53 0.572,-2.3c0.086,-0.355 0.173,-0.711 0.26,-1.065c0.167,-0.676 0.481,-1.066 0.961,-1.191c0.066,-0.017 0.136,0.024 0.154,0.092c0.017,0.068 -0.023,0.138 -0.091,0.156c-0.387,0.101 -0.634,0.421 -0.779,1.005c-0.087,0.354 -0.174,0.709 -0.26,1.064c-0.188,0.771 -0.375,1.543 -0.573,2.304c-0.145,0.557 -0.297,1.024 -0.462,1.426c-0.289,0.703 -0.651,0.793 -0.846,0.782c-0.35,-0.018 -0.661,-0.374 -0.832,-0.951c-0.167,-0.565 -0.315,-1.163 -0.459,-1.74c-0.083,-0.335 -0.166,-0.67 -0.253,-1.001L9.415,5.226C9.282,4.709 9.143,4.174 8.981,3.682c-0.192,-0.58 -0.458,-0.926 -0.712,-0.926c-0.001,0 -0.001,0 -0.002,0c-0.252,0.002 -0.51,0.349 -0.69,0.928C7.38,4.316 7.217,5.004 7.06,5.668C6.982,5.996 6.905,6.324 6.823,6.647L6.75,6.939C6.656,7.314 6.56,7.701 6.446,8.063C6.121,9.103 5.728,9.325 5.453,9.325z"
|
||||
android:fillColor="@color/inrange"/>
|
||||
<path
|
||||
android:pathData="M13.949,6.338h-2.831c-0.232,0 -0.421,-0.193 -0.421,-0.431V4.19H5.856l0,1.717c0,0.238 -0.188,0.431 -0.42,0.431h-2.84c-0.232,0 -0.42,-0.193 -0.42,-0.431c0,-0.238 0.188,-0.431 0.42,-0.431h2.42l0,-1.717c0,-0.238 0.188,-0.431 0.42,-0.431h5.682c0.232,0 0.421,0.193 0.421,0.431v1.717h2.411c0.232,0 0.421,0.193 0.421,0.431C14.37,6.145 14.181,6.338 13.949,6.338z"
|
||||
android:fillColor="@color/tempTargetConfirmation"/>
|
||||
</vector>
|
|
@ -1,8 +1,7 @@
|
|||
<androidx.wear.widget.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="15dp">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -79,4 +79,38 @@
|
|||
<item>ambient_charging</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="tile_action_names">
|
||||
<item>@string/menu_wizard</item>
|
||||
<item>@string/menu_bolus</item>
|
||||
<item>@string/menu_ecarb</item>
|
||||
<item>@string/menu_tempt</item>
|
||||
<item>@string/tile_none</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="tile_action_values">
|
||||
<item>wizzard</item>
|
||||
<item>bolus</item>
|
||||
<item>carbs</item>
|
||||
<item>temp_target</item>
|
||||
<item>none</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="tile_tempt_names">
|
||||
<item>@string/temp_target_activity</item>
|
||||
<item>@string/temp_target_eating_soon</item>
|
||||
<item>@string/temp_target_hypo</item>
|
||||
<item>@string/temp_target_manual</item>
|
||||
<item>@string/temp_target_cancel</item>
|
||||
<item>@string/tile_none</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="tile_tempt_values">
|
||||
<item>activity</item>
|
||||
<item>eating_soon</item>
|
||||
<item>hypo</item>
|
||||
<item>manual</item>
|
||||
<item>cancel</item>
|
||||
<item>none</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -48,6 +48,9 @@
|
|||
|
||||
|
||||
<color name="inrange">#00FF00</color>
|
||||
<color name="exercise">#67DFE8</color>
|
||||
<color name="carbs">#FFFB8C00</color>
|
||||
<color name="low">#FF0000</color>
|
||||
<color name="tempTargetConfirmation">#77dd77</color>
|
||||
|
||||
<!-- Material Design - Color Palette -->
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<string name="label_xdrip_steampunk">AAPS(Steampunk)</string>
|
||||
<string name="label_digitalstyle">AAPS(DigitalStyle)</string>
|
||||
|
||||
<string name="label_actions_tile">AAPS(Actions)</string>
|
||||
<string name="label_temp_target_tile">AAPS(Temp Target)</string>
|
||||
|
||||
<string name="label_warning_sync">No data!</string>
|
||||
<string name="label_warning_old">Old data!</string>
|
||||
|
@ -70,7 +72,6 @@
|
|||
<string name="pref_moreWatchfaceSettings">more Watchface settings</string>
|
||||
<string name="pref_lookInYourWatchfaceConfiguration">Look into Watchface configuration, please.</string>
|
||||
|
||||
|
||||
<string name="menu_tempt">TempT</string>
|
||||
<string name="menu_wizard">Wizard</string>
|
||||
<string name="menu_bolus">Bolus</string>
|
||||
|
@ -84,10 +85,16 @@
|
|||
<string name="menu_menu">Menu</string>
|
||||
|
||||
<string name="action_duration">duration</string>
|
||||
<string name="action_tempt_confirmation">Temp Target Requested</string>
|
||||
<string name="action_bolus_confirmation">Bolus Requested</string>
|
||||
<string name="action_wizard_confirmation">Updated Requested</string>
|
||||
<string name="action_fill_confirmation">Fill Requested</string>
|
||||
<string name="action_ecarb_confirmation">Carbs Requested</string>
|
||||
<string name="action_cpp_confirmation">CPP Requested</string>
|
||||
<string name="action_target" comment="In temp target menu, single target value">target</string>
|
||||
<string name="action_low" comment="In temp target menu, lower value from range">low</string>
|
||||
<string name="action_high" comment="In temp target menu, higher value from range">high</string>
|
||||
<string name="action_carbs">carbs</string>
|
||||
<string name="action_carbs">Carbs</string>
|
||||
<string name="action_percentage">percentage</string>
|
||||
<string name="action_start_min">start [min]</string>
|
||||
<string name="action_duration_h">duration [h]</string>
|
||||
|
@ -98,7 +105,7 @@
|
|||
<string name="action_free_amount" comment="In prime/fill menu, allows to enter any amount to be used for priming/filling">Free amount</string>
|
||||
<string name="action_confirm">CONFIRM</string>
|
||||
<string name="action_timeshift">timeshift</string>
|
||||
<string name="action_bolus">bolus</string>
|
||||
<string name="action_bolus">Bolus</string>
|
||||
|
||||
<string name="bolus_progress">Bolus Progress</string>
|
||||
<string name="press_to_cancel">press to cancel</string>
|
||||
|
@ -113,7 +120,6 @@
|
|||
<string name="activity_IOB">IOB</string>
|
||||
<string name="activity_no_status">no status</string>
|
||||
|
||||
|
||||
<string name="color_name_red">red</string>
|
||||
<string name="color_name_pink">pink</string>
|
||||
<string name="color_name_purple">purple</string>
|
||||
|
@ -139,7 +145,6 @@
|
|||
<string name="pref_simplify_ui">Simplify UI</string>
|
||||
<string name="pref_simplify_ui_sum">Only show time and BG</string>
|
||||
|
||||
|
||||
<string name="pref_vibrate_hourly">Vibrate hourly</string>
|
||||
<string name="pref_show_weeknumber">Show Week number</string>
|
||||
|
||||
|
@ -161,5 +166,12 @@
|
|||
<string name="simple_ui_charging">During Charging</string>
|
||||
<string name="simple_ui_always_on">Always On Mode</string>
|
||||
<string name="simple_ui_always_on_charging">Always On and Charging</string>
|
||||
<string name="temp_target_eating_soon">Eating</string>
|
||||
<string name="temp_target_hypo">Hypo</string>
|
||||
<string name="temp_target_activity">Activity</string>
|
||||
<string name="temp_target_manual">Manual</string>
|
||||
<string name="temp_target_cancel">Cancel</string>
|
||||
<string name="tile_none">None</string>
|
||||
<string name="tile_no_config">No tile config available</string>
|
||||
|
||||
</resources>
|
||||
|
|
33
wear/src/main/res/xml/tile_configuration_activity.xml
Normal file
33
wear/src/main/res/xml/tile_configuration_activity.xml
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<ListPreference
|
||||
android:key="tile_action_1"
|
||||
android:title="Action 1"
|
||||
android:defaultValue="wizzard"
|
||||
android:entries="@array/tile_action_names"
|
||||
android:entryValues="@array/tile_action_values"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="tile_action_2"
|
||||
android:title="Action 2"
|
||||
android:defaultValue="bolus"
|
||||
android:entries="@array/tile_action_names"
|
||||
android:entryValues="@array/tile_action_values"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="tile_action_3"
|
||||
android:title="Action 3"
|
||||
android:defaultValue="carbs"
|
||||
android:entries="@array/tile_action_names"
|
||||
android:entryValues="@array/tile_action_values"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="tile_action_4"
|
||||
android:title="Action 4"
|
||||
android:defaultValue="temp_target"
|
||||
android:entries="@array/tile_action_names"
|
||||
android:entryValues="@array/tile_action_values"/>
|
||||
|
||||
</PreferenceScreen>
|
33
wear/src/main/res/xml/tile_configuration_tempt.xml
Normal file
33
wear/src/main/res/xml/tile_configuration_tempt.xml
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<ListPreference
|
||||
android:key="tile_tempt_1"
|
||||
android:title="Target 1"
|
||||
android:defaultValue="activity"
|
||||
android:entries="@array/tile_tempt_names"
|
||||
android:entryValues="@array/tile_tempt_values"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="tile_tempt_2"
|
||||
android:title="Target 2"
|
||||
android:defaultValue="eating_soon"
|
||||
android:entries="@array/tile_tempt_names"
|
||||
android:entryValues="@array/tile_tempt_values"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="tile_tempt_3"
|
||||
android:title="Target 3"
|
||||
android:defaultValue="hypo"
|
||||
android:entries="@array/tile_tempt_names"
|
||||
android:entryValues="@array/tile_tempt_values"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="tile_tempt_4"
|
||||
android:title="Target 4"
|
||||
android:defaultValue="manual"
|
||||
android:entries="@array/tile_tempt_names"
|
||||
android:entryValues="@array/tile_tempt_values"/>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
Reference in a new issue