From d220a903b06e75886b7bdb177c5e1a7933b3beba Mon Sep 17 00:00:00 2001 From: rICTx-T1D Date: Mon, 26 Oct 2020 21:12:33 +0100 Subject: [PATCH] Refactoring rICTx_WF01 -> DigitalStyle01 --- wear/src/main/AndroidManifest.xml | 12 ++++---- ...vity.java => DigitalStyle01ConfigAct.java} | 4 +-- .../{RICTxWF01.java => DigitalStyle01.java} | 28 ++++++++++-------- ...ct.png => digitalstyle01_bg_full_rect.png} | Bin ...d.png => digitalstyle01_bg_full_round.png} | Bin ...png => digitalstyle01_bg_minimal_rect.png} | Bin ...ng => digitalstyle01_bg_minimal_round.png} | Bin ...ct.png => digitalstyle01_bg_none_rect.png} | Bin ...d.png => digitalstyle01_bg_none_round.png} | Bin ...t.png => digitalstyle01_bg_shape_rect.png} | Bin ....png => digitalstyle01_bg_shape_round.png} | Bin ...xwf01.png => watchface_digitalstyle01.png} | Bin ...txwf01.xml => activity_digitalstyle01.xml} | 4 +-- ...1.xml => rect_activity_digitalstyle01.xml} | 4 +-- ....xml => round_activity_digitalstyle01.xml} | 4 +-- ...1_arrays.xml => digitalstyle01_arrays.xml} | 14 ++++----- ...tch_face_digitalstyle01_configuration.xml} | 26 ++++++++-------- 17 files changed, 50 insertions(+), 46 deletions(-) rename wear/src/main/java/info/nightscout/androidaps/interaction/configurationActivities/{RICTxWF01ConfigurationActivity.java => DigitalStyle01ConfigAct.java} (87%) rename wear/src/main/java/info/nightscout/androidaps/watchfaces/{RICTxWF01.java => DigitalStyle01.java} (88%) rename wear/src/main/res/drawable/{rictxwf01_bg_full_rect.png => digitalstyle01_bg_full_rect.png} (100%) rename wear/src/main/res/drawable/{rictxwf01_bg_full_round.png => digitalstyle01_bg_full_round.png} (100%) rename wear/src/main/res/drawable/{rictxwf01_bg_minimal_rect.png => digitalstyle01_bg_minimal_rect.png} (100%) rename wear/src/main/res/drawable/{rictxwf01_bg_minimal_round.png => digitalstyle01_bg_minimal_round.png} (100%) rename wear/src/main/res/drawable/{rictxwf01_bg_none_rect.png => digitalstyle01_bg_none_rect.png} (100%) rename wear/src/main/res/drawable/{rictxwf01_bg_none_round.png => digitalstyle01_bg_none_round.png} (100%) rename wear/src/main/res/drawable/{rictxwf01_bg_shape_rect.png => digitalstyle01_bg_shape_rect.png} (100%) rename wear/src/main/res/drawable/{rictxwf01_bg_shape_round.png => digitalstyle01_bg_shape_round.png} (100%) rename wear/src/main/res/drawable/{watchface_rictxwf01.png => watchface_digitalstyle01.png} (100%) rename wear/src/main/res/layout/{activity_rictxwf01.xml => activity_digitalstyle01.xml} (78%) rename wear/src/main/res/layout/{rect_activity_rictxwf01.xml => rect_activity_digitalstyle01.xml} (99%) rename wear/src/main/res/layout/{round_activity_rictxwf01.xml => round_activity_digitalstyle01.xml} (99%) rename wear/src/main/res/values/{rictxwf01_arrays.xml => digitalstyle01_arrays.xml} (87%) rename wear/src/main/res/xml/{rictxwf01configuration.xml => watch_face_digitalstyle01_configuration.xml} (63%) diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index 511266dbf1..d20c090aa4 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -163,19 +163,19 @@ + android:resource="@drawable/watchface_digitalstyle01" /> + android:value="info.nightscout.androidaps.interaction.configurationActivities.DigitalStyle01ConfigAct" /> @@ -507,9 +507,9 @@ - + - + diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/configurationActivities/RICTxWF01ConfigurationActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/configurationActivities/DigitalStyle01ConfigAct.java similarity index 87% rename from wear/src/main/java/info/nightscout/androidaps/interaction/configurationActivities/RICTxWF01ConfigurationActivity.java rename to wear/src/main/java/info/nightscout/androidaps/interaction/configurationActivities/DigitalStyle01ConfigAct.java index 74d08b50b2..c0ced91076 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/configurationActivities/RICTxWF01ConfigurationActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/configurationActivities/DigitalStyle01ConfigAct.java @@ -7,13 +7,13 @@ import android.view.ViewGroup; import info.nightscout.androidaps.R; import preference.WearPreferenceActivity; -public class RICTxWF01ConfigurationActivity extends WearPreferenceActivity { +public class DigitalStyle01ConfigAct extends WearPreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle("watchface"); - addPreferencesFromResource(R.xml.rictxwf01configuration); + addPreferencesFromResource(R.xml.watch_face_digitalstyle01_configuration); ViewGroup view = (ViewGroup) getWindow().getDecorView(); removeBackgroundRecursively(view); view.setBackground(getResources().getDrawable(R.drawable.settings_background)); diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/RICTxWF01.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyle01.java similarity index 88% rename from wear/src/main/java/info/nightscout/androidaps/watchfaces/RICTxWF01.java rename to wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyle01.java index d6ae20cd22..d9ef01d371 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/RICTxWF01.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyle01.java @@ -21,7 +21,8 @@ import java.util.Date; import info.nightscout.androidaps.R; import info.nightscout.androidaps.interaction.menus.MainMenuActivity; -public class RICTxWF01 extends BaseWatchFace { +public class DigitalStyle01 extends BaseWatchFace { + private static final long TIME_TAP_THRESHOLD = 800; private long chartTapTime = 0; private long sgvTapTime = 0; @@ -29,7 +30,7 @@ public class RICTxWF01 extends BaseWatchFace { public void onCreate() { super.onCreate(); LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); - layoutView = inflater.inflate(R.layout.activity_rictxwf01, null); + layoutView = inflater.inflate(R.layout.activity_digitalstyle01, null); performViewSetup(); } @@ -40,7 +41,7 @@ public class RICTxWF01 extends BaseWatchFace { Log.d("onTapCommand: DeviceWidth x DeviceHeight /// x , y, TapType >> ", Integer.toString(getWidth()) + " x " + Integer.toString(getHeight()) + " /// " + Integer.toString(x) + " , " + Integer.toString(y) + " , " + Integer.toString(tapType)); if (tapType == TAP_TYPE_TAP) { - if (eventTime - sgvTapTime < 800) { + if (eventTime - sgvTapTime < TIME_TAP_THRESHOLD) { Intent intent = new Intent(this, MainMenuActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); @@ -93,23 +94,26 @@ public class RICTxWF01 extends BaseWatchFace { basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light); pointSize = 1; setupCharts(); + setWatchfaceStyle(); } + } + private void setWatchfaceStyle(){ /* frame styles*/ LinearLayout mShapesElements = layoutView.findViewById(R.id.shapes_elements); if (mShapesElements != null) { String displayFormatType = (mShapesElements.getContentDescription().toString().startsWith("round") ? "round" : "rect"); - String displayStyle=sharedPrefs.getString("rictxwf01_frameStyle", "full"); - String displayFrameColor=sharedPrefs.getString("rictxwf01_frameColor", "red"); - String displayFrameColorSaturation=sharedPrefs.getString("rictxwf01_frameColorSaturation", "500"); - String displayFrameColorOpacity=sharedPrefs.getString("rictxwf01_frameColorOpacity", "1"); + String displayStyle=sharedPrefs.getString("digitalstyle01_frameStyle", "full"); + String displayFrameColor=sharedPrefs.getString("digitalstyle01_frameColor", "red"); + String displayFrameColorSaturation=sharedPrefs.getString("digitalstyle01_frameColorSaturation", "500"); + String displayFrameColorOpacity=sharedPrefs.getString("digitalstyle01_frameColorOpacity", "1"); // Load image with shapes - String styleDrawableName = "rictxwf01_bg_" + displayStyle + "_" + displayFormatType; + String styleDrawableName = "digitalstyle01_bg_" + displayStyle + "_" + displayFormatType; try { mShapesElements.setBackground(getResources().getDrawable(getResources().getIdentifier(styleDrawableName, "drawable", getApplicationContext().getPackageName()))); } catch (Exception e) { - Log.e("rictxwf01_frameStyle", "RESOURCE NOT FOUND >> " + styleDrawableName); + Log.e("digitalstyle01_frameStyle", "RESOURCE NOT FOUND >> " + styleDrawableName); } // set background-tint-color @@ -117,13 +121,13 @@ public class RICTxWF01 extends BaseWatchFace { mShapesElements.setBackgroundTintList(null); } else { String strColorName =(( displayFrameColor.equals("white") || displayFrameColor.equals("black") )?displayFrameColor:displayFrameColor+"_"+displayFrameColorSaturation); - Log.v("rictxwf01_strColorName",strColorName); + Log.v("digitalstyle01_strColorName",strColorName); try { ColorStateList colorStateList = ContextCompat.getColorStateList(getApplicationContext(), getResources().getIdentifier(strColorName, "color", getApplicationContext().getPackageName())); mShapesElements.setBackgroundTintList(colorStateList); } catch (Exception e) { mShapesElements.setBackgroundTintList(null); - Log.e("rictxwf01_ColorName", "COLOR NOT FOUND >> " + strColorName); + Log.e("digitalstyle01_colorName", "COLOR NOT FOUND >> " + strColorName); } } @@ -181,7 +185,7 @@ public class RICTxWF01 extends BaseWatchFace { super.onTimeChanged(oldTime,newTime); /* hourly vibration*/ - Boolean hourlyVibratePref = sharedPrefs.getBoolean("rictxwf01_vibrateHourly", false); + Boolean hourlyVibratePref = sharedPrefs.getBoolean("vibrate_Hourly", false); if (hourlyVibratePref && layoutSet && newTime.hasHourChanged(oldTime)) { Log.i("hourlyVibratePref", "true --> " + newTime.toString()); Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); diff --git a/wear/src/main/res/drawable/rictxwf01_bg_full_rect.png b/wear/src/main/res/drawable/digitalstyle01_bg_full_rect.png similarity index 100% rename from wear/src/main/res/drawable/rictxwf01_bg_full_rect.png rename to wear/src/main/res/drawable/digitalstyle01_bg_full_rect.png diff --git a/wear/src/main/res/drawable/rictxwf01_bg_full_round.png b/wear/src/main/res/drawable/digitalstyle01_bg_full_round.png similarity index 100% rename from wear/src/main/res/drawable/rictxwf01_bg_full_round.png rename to wear/src/main/res/drawable/digitalstyle01_bg_full_round.png diff --git a/wear/src/main/res/drawable/rictxwf01_bg_minimal_rect.png b/wear/src/main/res/drawable/digitalstyle01_bg_minimal_rect.png similarity index 100% rename from wear/src/main/res/drawable/rictxwf01_bg_minimal_rect.png rename to wear/src/main/res/drawable/digitalstyle01_bg_minimal_rect.png diff --git a/wear/src/main/res/drawable/rictxwf01_bg_minimal_round.png b/wear/src/main/res/drawable/digitalstyle01_bg_minimal_round.png similarity index 100% rename from wear/src/main/res/drawable/rictxwf01_bg_minimal_round.png rename to wear/src/main/res/drawable/digitalstyle01_bg_minimal_round.png diff --git a/wear/src/main/res/drawable/rictxwf01_bg_none_rect.png b/wear/src/main/res/drawable/digitalstyle01_bg_none_rect.png similarity index 100% rename from wear/src/main/res/drawable/rictxwf01_bg_none_rect.png rename to wear/src/main/res/drawable/digitalstyle01_bg_none_rect.png diff --git a/wear/src/main/res/drawable/rictxwf01_bg_none_round.png b/wear/src/main/res/drawable/digitalstyle01_bg_none_round.png similarity index 100% rename from wear/src/main/res/drawable/rictxwf01_bg_none_round.png rename to wear/src/main/res/drawable/digitalstyle01_bg_none_round.png diff --git a/wear/src/main/res/drawable/rictxwf01_bg_shape_rect.png b/wear/src/main/res/drawable/digitalstyle01_bg_shape_rect.png similarity index 100% rename from wear/src/main/res/drawable/rictxwf01_bg_shape_rect.png rename to wear/src/main/res/drawable/digitalstyle01_bg_shape_rect.png diff --git a/wear/src/main/res/drawable/rictxwf01_bg_shape_round.png b/wear/src/main/res/drawable/digitalstyle01_bg_shape_round.png similarity index 100% rename from wear/src/main/res/drawable/rictxwf01_bg_shape_round.png rename to wear/src/main/res/drawable/digitalstyle01_bg_shape_round.png diff --git a/wear/src/main/res/drawable/watchface_rictxwf01.png b/wear/src/main/res/drawable/watchface_digitalstyle01.png similarity index 100% rename from wear/src/main/res/drawable/watchface_rictxwf01.png rename to wear/src/main/res/drawable/watchface_digitalstyle01.png diff --git a/wear/src/main/res/layout/activity_rictxwf01.xml b/wear/src/main/res/layout/activity_digitalstyle01.xml similarity index 78% rename from wear/src/main/res/layout/activity_rictxwf01.xml rename to wear/src/main/res/layout/activity_digitalstyle01.xml index 3db05d2788..da1fadf9b2 100644 --- a/wear/src/main/res/layout/activity_rictxwf01.xml +++ b/wear/src/main/res/layout/activity_digitalstyle01.xml @@ -7,7 +7,7 @@ android:id="@+id/watch_view_stub" android:layout_width="match_parent" android:layout_height="match_parent" - app:rectLayout="@layout/rect_activity_rictxwf01" - app:roundLayout="@layout/round_activity_rictxwf01" + app:rectLayout="@layout/rect_activity_digitalstyle01" + app:roundLayout="@layout/round_activity_digitalstyle01" tools:context=".watchfaces.Home" tools:deviceIds="wear"/> \ No newline at end of file diff --git a/wear/src/main/res/layout/rect_activity_rictxwf01.xml b/wear/src/main/res/layout/rect_activity_digitalstyle01.xml similarity index 99% rename from wear/src/main/res/layout/rect_activity_rictxwf01.xml rename to wear/src/main/res/layout/rect_activity_digitalstyle01.xml index 6d64194238..00626650bd 100644 --- a/wear/src/main/res/layout/rect_activity_rictxwf01.xml +++ b/wear/src/main/res/layout/rect_activity_digitalstyle01.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/black" - tools:context=".watchfaces.RICTxWF01" + tools:context=".watchfaces.DigitalStyle01" tools:deviceIds="wear_square"> @@ -15,7 +15,7 @@ android:id="@+id/shapes_elements" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@drawable/rictxwf01_bg_full_rect" + android:background="@drawable/digitalstyle01_bg_full_rect" android:contentDescription="rect-shape-elements" android:orientation="horizontal" /> diff --git a/wear/src/main/res/layout/round_activity_rictxwf01.xml b/wear/src/main/res/layout/round_activity_digitalstyle01.xml similarity index 99% rename from wear/src/main/res/layout/round_activity_rictxwf01.xml rename to wear/src/main/res/layout/round_activity_digitalstyle01.xml index 9480e342e0..bede24e7d7 100644 --- a/wear/src/main/res/layout/round_activity_rictxwf01.xml +++ b/wear/src/main/res/layout/round_activity_digitalstyle01.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/black" - tools:context=".watchfaces.RICTxWF01" + tools:context=".watchfaces.DigitalStyle01" tools:deviceIds="wear_round"> @@ -15,7 +15,7 @@ android:id="@+id/shapes_elements" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@drawable/rictxwf01_bg_full_round" + android:background="@drawable/digitalstyle01_bg_full_round" android:contentDescription="round-shape-elements" android:orientation="horizontal" /> diff --git a/wear/src/main/res/values/rictxwf01_arrays.xml b/wear/src/main/res/values/digitalstyle01_arrays.xml similarity index 87% rename from wear/src/main/res/values/rictxwf01_arrays.xml rename to wear/src/main/res/values/digitalstyle01_arrays.xml index 09b10f258b..5ba2965286 100644 --- a/wear/src/main/res/values/rictxwf01_arrays.xml +++ b/wear/src/main/res/values/digitalstyle01_arrays.xml @@ -1,19 +1,19 @@ - + @string/style_none @string/style_minimal @string/style_shape @string/style_full - + none minimal shape full - + @string/color_name_red @string/color_name_pink @string/color_name_purple @@ -36,7 +36,7 @@ @string/color_name_white @string/color_name_multicolor - + red pink purple @@ -61,7 +61,7 @@ - + 100 500 700 @@ -69,7 +69,7 @@ - + 10% 20% 30% @@ -81,7 +81,7 @@ 90% 100% - + 0.1 0.2 0.3 diff --git a/wear/src/main/res/xml/rictxwf01configuration.xml b/wear/src/main/res/xml/watch_face_digitalstyle01_configuration.xml similarity index 63% rename from wear/src/main/res/xml/rictxwf01configuration.xml rename to wear/src/main/res/xml/watch_face_digitalstyle01_configuration.xml index cbe86ba872..68725f1bd4 100644 --- a/wear/src/main/res/xml/rictxwf01configuration.xml +++ b/wear/src/main/res/xml/watch_face_digitalstyle01_configuration.xml @@ -4,31 +4,31 @@ + android:entries="@array/digitalstyle01_styles_name" + android:entryValues="@array/digitalstyle01_styles_values"/> + android:entries="@array/digitalstyle01_color_name" + android:entryValues="@array/digitalstyle01_color_values"/> + android:entries="@array/digitalstyle01_color_saturation" + android:entryValues="@array/digitalstyle01_color_saturation"/> + android:entries="@array/digitalstyle01_color_opacity_name" + android:entryValues="@array/digitalstyle01_color_opacity_value"/>