Refactoring again - DigitalStyle01 -> DigitalStyle, Use @string as label in manifest

This commit is contained in:
rICTx-T1D 2020-10-31 21:00:46 +01:00 committed by mh
parent 6e996c65df
commit bb6c7bc1a9
18 changed files with 62 additions and 63 deletions

View file

@ -163,16 +163,16 @@
</service> </service>
<service <service
android:name=".watchfaces.DigitalStyle01" android:name=".watchfaces.DigitalStyle"
android:allowEmbedded="true" android:allowEmbedded="true"
android:label="AAPS (DigitalStyle01)" android:label="@string/label_digitalstyle"
android:permission="android.permission.BIND_WALLPAPER"> android:permission="android.permission.BIND_WALLPAPER">
<meta-data <meta-data
android:name="android.service.wallpaper" android:name="android.service.wallpaper"
android:resource="@xml/watch_face" /> android:resource="@xml/watch_face" />
<meta-data <meta-data
android:name="com.google.android.wearable.watchface.preview" android:name="com.google.android.wearable.watchface.preview"
android:resource="@drawable/watchface_digitalstyle01" /> android:resource="@drawable/watchface_digitalstyle" />
<meta-data <meta-data
android:name="com.google.android.wearable.watchface.wearableConfigurationAction" android:name="com.google.android.wearable.watchface.wearableConfigurationAction"
android:value="info.nightscout.androidaps.interaction.configurationActivities.DigitalStyle01ConfigAct" /> android:value="info.nightscout.androidaps.interaction.configurationActivities.DigitalStyle01ConfigAct" />
@ -507,7 +507,7 @@
<activity <activity
android:name=".interaction.actions.TempTargetActivity" android:name=".interaction.actions.TempTargetActivity"
android:label="@string/menu_tempt" /> android:label="@string/menu_tempt" />
<activity android:name=".interaction.configurationActivities.DigitalStyle01ConfigAct"> <activity android:name=".interaction.configurationActivities.DigitalStyleConfigAct">
<intent-filter> <intent-filter>
<action android:name="info.nightscout.androidaps.interaction.configurationActivities.DigitalStyle01ConfigAct" /> <action android:name="info.nightscout.androidaps.interaction.configurationActivities.DigitalStyle01ConfigAct" />

View file

@ -7,13 +7,13 @@ import android.view.ViewGroup;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import preference.WearPreferenceActivity; import preference.WearPreferenceActivity;
public class DigitalStyle01ConfigAct extends WearPreferenceActivity { public class DigitalStyleConfigAct extends WearPreferenceActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setTitle("watchface"); setTitle("watchface");
addPreferencesFromResource(R.xml.watch_face_digitalstyle01_configuration); addPreferencesFromResource(R.xml.watch_face_digitalstyle_configuration);
ViewGroup view = (ViewGroup) getWindow().getDecorView(); ViewGroup view = (ViewGroup) getWindow().getDecorView();
removeBackgroundRecursively(view); removeBackgroundRecursively(view);
view.setBackground(getResources().getDrawable(R.drawable.settings_background)); view.setBackground(getResources().getDrawable(R.drawable.settings_background));

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.watchfaces;
import android.content.Intent; import android.content.Intent;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.os.Vibrator;
import android.support.wearable.watchface.WatchFaceStyle; import android.support.wearable.watchface.WatchFaceStyle;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -12,16 +11,13 @@ import android.widget.TextView;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import com.ustwo.clockwise.common.WatchFaceTime;
import com.ustwo.clockwise.common.WatchMode;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interaction.menus.MainMenuActivity; import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
public class DigitalStyle01 extends BaseWatchFace { public class DigitalStyle extends BaseWatchFace {
private static final long TIME_TAP_THRESHOLD = 800; private static final long TIME_TAP_THRESHOLD = 800;
private long chartTapTime = 0; private long chartTapTime = 0;
private long sgvTapTime = 0; private long sgvTapTime = 0;
@ -30,7 +26,7 @@ public class DigitalStyle01 extends BaseWatchFace {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
layoutView = inflater.inflate(R.layout.activity_digitalstyle01, null); layoutView = inflater.inflate(R.layout.activity_digitalstyle, null);
performViewSetup(); performViewSetup();
} }
@ -103,17 +99,17 @@ public class DigitalStyle01 extends BaseWatchFace {
LinearLayout mShapesElements = layoutView.findViewById(R.id.shapes_elements); LinearLayout mShapesElements = layoutView.findViewById(R.id.shapes_elements);
if (mShapesElements != null) { if (mShapesElements != null) {
String displayFormatType = (mShapesElements.getContentDescription().toString().startsWith("round") ? "round" : "rect"); String displayFormatType = (mShapesElements.getContentDescription().toString().startsWith("round") ? "round" : "rect");
String displayStyle=sharedPrefs.getString("digitalstyle01_frameStyle", "full"); String displayStyle=sharedPrefs.getString("digitalstyle_frameStyle", "full");
String displayFrameColor=sharedPrefs.getString("digitalstyle01_frameColor", "red"); String displayFrameColor=sharedPrefs.getString("digitalstyle_frameColor", "red");
String displayFrameColorSaturation=sharedPrefs.getString("digitalstyle01_frameColorSaturation", "500"); String displayFrameColorSaturation=sharedPrefs.getString("digitalstyle_frameColorSaturation", "500");
String displayFrameColorOpacity=sharedPrefs.getString("digitalstyle01_frameColorOpacity", "1"); String displayFrameColorOpacity=sharedPrefs.getString("digitalstyle_frameColorOpacity", "1");
// Load image with shapes // Load image with shapes
String styleDrawableName = "digitalstyle01_bg_" + displayStyle + "_" + displayFormatType; String styleDrawableName = "digitalstyle_bg_" + displayStyle + "_" + displayFormatType;
try { try {
mShapesElements.setBackground(getResources().getDrawable(getResources().getIdentifier(styleDrawableName, "drawable", getApplicationContext().getPackageName()))); mShapesElements.setBackground(getResources().getDrawable(getResources().getIdentifier(styleDrawableName, "drawable", getApplicationContext().getPackageName())));
} catch (Exception e) { } catch (Exception e) {
Log.e("digitalstyle01_frameStyle", "RESOURCE NOT FOUND >> " + styleDrawableName); Log.e("digitalstyle_frameStyle", "RESOURCE NOT FOUND >> " + styleDrawableName);
} }
// set background-tint-color // set background-tint-color
@ -121,13 +117,13 @@ public class DigitalStyle01 extends BaseWatchFace {
mShapesElements.setBackgroundTintList(null); mShapesElements.setBackgroundTintList(null);
} else { } else {
String strColorName =(( displayFrameColor.equals("white") || displayFrameColor.equals("black") )?displayFrameColor:displayFrameColor+"_"+displayFrameColorSaturation); String strColorName =(( displayFrameColor.equals("white") || displayFrameColor.equals("black") )?displayFrameColor:displayFrameColor+"_"+displayFrameColorSaturation);
Log.v("digitalstyle01_strColorName",strColorName); Log.v("digitalstyle_strColorName",strColorName);
try { try {
ColorStateList colorStateList = ContextCompat.getColorStateList(getApplicationContext(), getResources().getIdentifier(strColorName, "color", getApplicationContext().getPackageName())); ColorStateList colorStateList = ContextCompat.getColorStateList(getApplicationContext(), getResources().getIdentifier(strColorName, "color", getApplicationContext().getPackageName()));
mShapesElements.setBackgroundTintList(colorStateList); mShapesElements.setBackgroundTintList(colorStateList);
} catch (Exception e) { } catch (Exception e) {
mShapesElements.setBackgroundTintList(null); mShapesElements.setBackgroundTintList(null);
Log.e("digitalstyle01_colorName", "COLOR NOT FOUND >> " + strColorName); Log.e("digitalstyle_colorName", "COLOR NOT FOUND >> " + strColorName);
} }
} }

View file

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 65 KiB

View file

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View file

Before

Width:  |  Height:  |  Size: 354 B

After

Width:  |  Height:  |  Size: 354 B

View file

Before

Width:  |  Height:  |  Size: 354 B

After

Width:  |  Height:  |  Size: 354 B

View file

Before

Width:  |  Height:  |  Size: 137 B

After

Width:  |  Height:  |  Size: 137 B

View file

Before

Width:  |  Height:  |  Size: 137 B

After

Width:  |  Height:  |  Size: 137 B

View file

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View file

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 69 KiB

View file

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

View file

@ -7,7 +7,7 @@
android:id="@+id/watch_view_stub" android:id="@+id/watch_view_stub"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:rectLayout="@layout/rect_activity_digitalstyle01" app:rectLayout="@layout/rect_activity_digitalstyle"
app:roundLayout="@layout/round_activity_digitalstyle01" app:roundLayout="@layout/round_activity_digitalstyle"
tools:context=".watchfaces.Home" tools:context=".watchfaces.Home"
tools:deviceIds="wear"/> tools:deviceIds="wear"/>

View file

@ -6,7 +6,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/black" android:background="@color/black"
tools:context=".watchfaces.DigitalStyle01" tools:context=".watchfaces.DigitalStyle"
tools:deviceIds="wear_square"> tools:deviceIds="wear_square">
@ -15,7 +15,7 @@
android:id="@+id/shapes_elements" android:id="@+id/shapes_elements"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/digitalstyle01_bg_full_rect" android:background="@drawable/digitalstyle_bg_full_rect"
android:contentDescription="rect-shape-elements" android:contentDescription="rect-shape-elements"
android:orientation="horizontal" /> android:orientation="horizontal" />

View file

@ -6,7 +6,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/black" android:background="@color/black"
tools:context=".watchfaces.DigitalStyle01" tools:context=".watchfaces.DigitalStyle"
tools:deviceIds="wear_round"> tools:deviceIds="wear_round">
@ -15,7 +15,7 @@
android:id="@+id/shapes_elements" android:id="@+id/shapes_elements"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/digitalstyle01_bg_full_round" android:background="@drawable/digitalstyle_bg_full_round"
android:contentDescription="round-shape-elements" android:contentDescription="round-shape-elements"
android:orientation="horizontal" /> android:orientation="horizontal" />

View file

@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string-array name="digitalstyle01_styles_name"> <string-array name="digitalstyle_styles_name">
<item>@string/style_none</item> <item>@string/digitalstyle_style_none</item>
<item>@string/style_minimal</item> <item>@string/digitalstyle_style_minimal</item>
<item>@string/style_shape</item> <item>@string/digitalstyle_style_shape</item>
<item>@string/style_full</item> <item>@string/digitalstyle_style_full</item>
</string-array> </string-array>
<string-array name="digitalstyle01_styles_values"> <string-array name="digitalstyle_styles_values">
<item>none</item> <item>none</item>
<item>minimal</item> <item>minimal</item>
<item>shape</item> <item>shape</item>
<item>full</item> <item>full</item>
</string-array> </string-array>
<string-array name="digitalstyle01_color_name"> <string-array name="digitalstyle_color_name">
<item>@string/color_name_red</item> <item>@string/color_name_red</item>
<item>@string/color_name_pink</item> <item>@string/color_name_pink</item>
<item>@string/color_name_purple</item> <item>@string/color_name_purple</item>
@ -36,7 +36,7 @@
<item>@string/color_name_white</item> <item>@string/color_name_white</item>
<item>@string/color_name_multicolor</item> <item>@string/color_name_multicolor</item>
</string-array> </string-array>
<string-array name="digitalstyle01_color_values"> <string-array name="digitalstyle_color_values">
<item>red</item> <item>red</item>
<item>pink</item> <item>pink</item>
<item>purple</item> <item>purple</item>
@ -61,7 +61,7 @@
</string-array> </string-array>
<string-array name="digitalstyle01_color_saturation"> <string-array name="digitalstyle_color_saturation">
<item>100</item> <item>100</item>
<item>500</item> <item>500</item>
<item>700</item> <item>700</item>
@ -69,7 +69,7 @@
</string-array> </string-array>
<string-array name="digitalstyle01_color_opacity_name"> <string-array name="digitalstyle_color_opacity_name">
<item>10%</item> <item>10%</item>
<item>20%</item> <item>20%</item>
<item>30%</item> <item>30%</item>
@ -81,7 +81,7 @@
<item>90%</item> <item>90%</item>
<item>100%</item> <item>100%</item>
</string-array> </string-array>
<string-array name="digitalstyle01_color_opacity_value"> <string-array name="digitalstyle_color_opacity_value">
<item>0.1</item> <item>0.1</item>
<item>0.2</item> <item>0.2</item>
<item>0.3</item> <item>0.3</item>

View file

@ -12,6 +12,7 @@
<string name="label_xdrip_v2">AAPSv2</string> <string name="label_xdrip_v2">AAPSv2</string>
<string name="label_xdrip_cockpit">AAPS(Cockpit)</string> <string name="label_xdrip_cockpit">AAPS(Cockpit)</string>
<string name="label_xdrip_steampunk">AAPS(Steampunk)</string> <string name="label_xdrip_steampunk">AAPS(Steampunk)</string>
<string name="label_digitalstyle">AAPS(DigitalStyle)</string>
<string name="label_warning_sync">No data!</string> <string name="label_warning_sync">No data!</string>
<string name="label_warning_old">Old data!</string> <string name="label_warning_old">Old data!</string>
@ -143,17 +144,19 @@
<string name="color_name_multicolor">multicolor</string> <string name="color_name_multicolor">multicolor</string>
<string name="pref_choose_your_style">Choose your style</string>
<string name="style_none">no style</string>
<string name="style_minimal">minimal style</string>
<string name="style_shape">shape style</string>
<string name="style_full">full style</string>
<string name="pref_choose_your_color">Choose your color</string>
<string name="pref_choose_your_color_saturation">Choose your color saturation</string>
<string name="pref_choose_your_color_opacity">Choose your color opacity</string>
<string name="pref_vibrate_hourly">Vibrate hourly</string> <string name="pref_vibrate_hourly">Vibrate hourly</string>
<string name="pref_show_weeknumber">Show Week number</string> <string name="pref_show_weeknumber">Show Week number</string>
<string name="digitalstyle_pref_your_style">Your style:</string>
<string name="digitalstyle_style_none">no style</string>
<string name="digitalstyle_style_minimal">minimal style</string>
<string name="digitalstyle_style_shape">shape style</string>
<string name="digitalstyle_style_full">full style</string>
<string name="digitalstyle_pref_your_color">Your color:</string>
<string name="digitalstyle_pref_your_color_saturation">Your color saturation:</string>
<string name="digitalstyle_pref_your_color_opacity">Your color opacity:</string>
</resources> </resources>

View file

@ -4,31 +4,31 @@
<ListPreference <ListPreference
android:key="digitalstyle01_frameStyle" android:key="digitalstyle_frameStyle"
android:title="@string/pref_choose_your_style" android:title="@string/digitalstyle_pref_your_style"
android:defaultValue="full" android:defaultValue="full"
android:entries="@array/digitalstyle01_styles_name" android:entries="@array/digitalstyle_styles_name"
android:entryValues="@array/digitalstyle01_styles_values"/> android:entryValues="@array/digitalstyle_styles_values"/>
<ListPreference <ListPreference
android:key="digitalstyle01_frameColor" android:key="digitalstyle_frameColor"
android:title="@string/pref_choose_your_color" android:title="@string/digitalstyle_pref_your_color"
android:defaultValue="red" android:defaultValue="red"
android:entries="@array/digitalstyle01_color_name" android:entries="@array/digitalstyle_color_name"
android:entryValues="@array/digitalstyle01_color_values"/> android:entryValues="@array/digitalstyle_color_values"/>
<ListPreference <ListPreference
android:key="digitalstyle01_frameColorSaturation" android:key="digitalstyle_frameColorSaturation"
android:title="@string/pref_choose_your_color_saturation" android:title="@string/digitalstyle_pref_your_color_saturation"
android:defaultValue="700" android:defaultValue="700"
android:entries="@array/digitalstyle01_color_saturation" android:entries="@array/digitalstyle_color_saturation"
android:entryValues="@array/digitalstyle01_color_saturation"/> android:entryValues="@array/digitalstyle_color_saturation"/>
<ListPreference <ListPreference
android:key="digitalstyle01_frameColorOpacity" android:key="digitalstyle_frameColorOpacity"
android:title="@string/pref_choose_your_color_opacity" android:title="@string/digitalstyle_pref_your_color_opacity"
android:defaultValue="1" android:defaultValue="1"
android:entries="@array/digitalstyle01_color_opacity_name" android:entries="@array/digitalstyle_color_opacity_name"
android:entryValues="@array/digitalstyle01_color_opacity_value"/> android:entryValues="@array/digitalstyle_color_opacity_value"/>
<CheckBoxPreference <CheckBoxPreference
android:key="show_date" android:key="show_date"