Reduce resource files as background images for shapes and use color tint method instead. Now a combination of 73 colors and 4 styles are possible.

This commit is contained in:
rICTx-T1D 2020-10-08 19:48:50 +02:00 committed by mh
parent b74118bbca
commit cd91d6a3a5
26 changed files with 247 additions and 60 deletions

View file

@ -16,6 +16,7 @@ public class RICTxWF01ConfigurationActivity extends WearPreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("watchface");
addPreferencesFromResource(R.xml.rictxwf01configuration);
ViewGroup view = (ViewGroup) getWindow().getDecorView();
removeBackgroundRecursively(view);

View file

@ -1,12 +1,14 @@
package info.nightscout.androidaps.watchfaces;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.os.Vibrator;
import android.support.wearable.watchface.WatchFaceStyle;
import android.util.Log;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import androidx.core.content.ContextCompat;
import com.ustwo.clockwise.common.WatchFaceTime;
import com.ustwo.clockwise.common.WatchMode;
import info.nightscout.androidaps.R;
@ -101,19 +103,34 @@ public class RICTxWF01 extends BaseWatchFace {
LinearLayout mShapesElements = layoutView.findViewById(R.id.shapes_elements);
if (mShapesElements != null) {
String displayFormatType = (mShapesElements.getContentDescription().toString().startsWith("round") ? "round" : "rect");
String styleDrawableName = "rictxwf01_bg_" + sharedPrefs.getString("rictxwf01_frameStyle", "red") + "_" + displayFormatType;
Log.d("rictxwf01_frameStyle", styleDrawableName);
String displayStyle=sharedPrefs.getString("rictxwf01_frameStyle", "full");
String displayFrameColor=sharedPrefs.getString("rictxwf01_frameColor", "red");
String displayFrameColorSaturation=sharedPrefs.getString("rictxwf01_frameColorSaturation", "500");
// Load image with shapes
String styleDrawableName = "rictxwf01_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);
}
// set background-tint-color
if (displayStyle.equalsIgnoreCase("rainbow") || displayStyle.equalsIgnoreCase("none")) {
mShapesElements.setBackgroundTintList(null);
} else {
String strColorName =(( displayFrameColor.equals("white") || displayFrameColor.equals("black") )?displayFrameColor:displayFrameColor+"_"+displayFrameColorSaturation);
Log.v("rictxwf01_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);
}
}
}
/* ToDo Implement a configurable background image
* layoutView.setBackground();
*/
}
protected void setColorLowRes() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

View file

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

View file

@ -2,12 +2,12 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".watchfaces.Home2"
tools:deviceIds="wear_square"
android:background="@color/black"
android:id="@+id/main_layout">
tools:context=".watchfaces.RICTxWF01"
tools:deviceIds="wear_square">
<!-- background-image with shapes elements-->
@ -15,7 +15,7 @@
android:id="@+id/shapes_elements"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/rictxwf01_bg_red_rect"
android:background="@drawable/rictxwf01_bg_full_rect"
android:contentDescription="rect-shape-elements"
android:orientation="horizontal" />

View file

@ -15,7 +15,7 @@
android:id="@+id/shapes_elements"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/rictxwf01_bg_red_round"
android:background="@drawable/rictxwf01_bg_full_round"
android:contentDescription="round-shape-elements"
android:orientation="horizontal" />

View file

@ -42,37 +42,138 @@
<color name="basal_dark_lowres">@color/grey_500</color>
<!-- Material Design - Color Palette -->
<!-- https://designguidelines.withgoogle.com/wearos/style/color.html#color-dark-color-palette-for-wear-os -->
<!-- https://material.io/design/color/the-color-system.html#tools-for-picking-colors -->
<!-- Red -->
<color name="red_100">#FFCDD2</color>
<color name="red_500">#F44336</color>
<color name="red_600">#E53935</color>
<color name="red_700">#D32F2F</color>
<color name="red_900">#B71C1C</color>
<color name="RED">#FF0000</color>
<!-- Red -->
<!-- Pink -->
<color name="pink_100">#F8BBD0</color>
<color name="pink_500">#E91E63</color>
<color name="pink_700">#C2185B</color>
<color name="pink_900">#880E4F</color>
<!-- Purple -->
<color name="purple_100">#E1BEE7</color>
<color name="purple_500">#9C27B0</color>
<color name="purple_700">#7B1FA2</color>
<color name="purple_900">#4A148C</color>
<!-- Deepe Purple -->
<color name="deeppurple_100">#D1C4E9</color>
<color name="deeppurple_500">#673AB7</color>
<color name="deeppurple_700">#512DA8</color>
<color name="deeppurple_900">#311B92</color>
<!-- Indigo -->
<color name="indigo_100">#C5CAE9</color>
<color name="indigo_500">#3F51B5</color>
<color name="indigo_700">#303F9F</color>
<color name="indigo_900">#1A237E</color>
<!-- Blue -->
<color name="blue_100">#BBDEFB</color>
<color name="blue_300">#64B5F6</color>
<!-- Blue -->
<color name="blue_500">#2196F3</color>
<color name="blue_700">#1976D2</color>
<color name="blue_900">#0D47A1</color>
<color name="BLUE">#0000FF</color>
<!-- Light Blue -->
<color name="lightblue_100">#B3E5FC</color>
<color name="lightblue_500">#03A9F4</color>
<color name="lightblue_700">#0288D1</color>
<color name="lightblue_900">#01579B</color>
<!-- Cyan -->
<color name="cyan_100">#B2EBF2</color>
<color name="cyan_500">#00BCD4</color>
<color name="cyan_700">#0097A7</color>
<color name="cyan_900">#006064</color>
<!-- Teal -->
<color name="teal_100">#B2DFDB</color>
<color name="teal_500">#009688</color>
<color name="teal_700">#00796B</color>
<color name="teal_900">#004D40</color>
<!-- Green -->
<color name="green_100">#C8E6C9</color>
<color name="green_500">#4CAF50</color>
<color name="green_700">#388E3C</color>
<color name="green_900">#1B5E20</color>
<!-- Light Green -->
<color name="lightgreen_100">#DCEDC8</color>
<color name="lightgreen_500">#8BC34A</color>
<color name="lightgreen_700">#689F38</color>
<color name="lightgreen_900">#33691E</color>
<!-- Lime -->
<color name="lime_100">#F0F4C3</color>
<color name="lime_500">#CDDC39</color>
<color name="lime_700">#AFB42B</color>
<color name="lime_900">#827717</color>
<!-- Yellow -->
<color name="yellow_100">#FFF9C4</color>
<color name="yellow_500">#FFEB3B</color>
<color name="yellow_700">#FBC02D</color>
<color name="yellow_900">#F57F17</color>
<color name="yellow_A200">#FFFF00</color>
<!-- Yellow -->
<!-- Grey -->
<!-- Amber -->
<color name="amber_100">#FFECB3</color>
<color name="amber_500">#FFC107</color>
<color name="amber_700">#FFA000</color>
<color name="amber_900">#FF6F00</color>
<!-- Orange -->
<color name="orange_100">#FFE0B2</color>
<color name="orange_500">#FF9800</color>
<color name="orange_700">#F57C00</color>
<color name="orange_900">#E65100</color>
<!-- Deep Orange -->
<color name="deeporange_100">#FFCCBC</color>
<color name="deeporange_500">#FF5722</color>
<color name="deeporange_700">#E64A19</color>
<color name="deeporange_900">#BF360C</color>
<!-- Brown -->
<color name="brown_100">#D7CCC8</color>
<color name="brown_500">#795548</color>
<color name="brown_700">#5D4037</color>
<color name="brown_900">#3E2723</color>
<!-- Gray / Grey -->
<!-- @ToDo Replace all usage from grey to gray, because that's the official color name in https://material.io/deign/color/ -->
<color name="grey_50">#FAFAFA</color>
<color name="gray_100">#F5F5F5</color>
<color name="grey_300">#E0E0E0</color>
<color name="grey_500">#9E9E9E</color>
<color name="gray_500">#9E9E9E</color> <!-- needed because rICTxWF01 generate color-names as grAy -->
<color name="gray_700">#616161</color>
<color name="gray_900">#212121</color>
<color name="grey_steampunk">#333333</color>
<!-- Grey -->
<!-- Blue Grey -->
<color name="BLUE">#0000FF</color>
<!-- Blue Grey -->
<!-- Blue Gray -->
<color name="bluegray_100">#CFD8DC</color>
<color name="bluegray_500">#607D8B</color>
<color name="bluegray_700">#455A64</color>
<color name="bluegray_900">#263238</color>
<!-- Black -->
<!-- Black / White-->
<color name="black">#000000</color>
<!-- Black -->
<!-- White -->
<color name="white">#FFFFFF</color>
<!-- White -->
</resources>

View file

@ -1,27 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="rictxwf01_styles_name">
<item>@string/color_name_red</item>
<item>@string/color_name_deeppurple</item>
<item>@string/color_name_indigo</item>
<item>@string/color_name_lightblue</item>
<item>@string/color_name_lime</item>
<item>@string/color_name_orange</item>
<item>@string/color_name_bluegray</item>
<item>@string/style_rainbowstyle</item>
<item>@string/style_simplestyle</item>
<item>@string/style_nostyle</item>
<item>@string/style_none</item>
<item>@string/style_minimal</item>
<item>@string/style_full</item>
<item>@string/style_rainbow</item>
</string-array>
<string-array name="rictxwf01_styles_values">
<item>none</item>
<item>minimal</item>
<item>full</item>
<item>rainbow</item>
</string-array>
<string-array name="rictxwf01_color_name">
<item>@string/color_name_red</item>
<item>@string/color_name_pink</item>
<item>@string/color_name_purple</item>
<item>@string/color_name_deeppurple</item>
<item>@string/color_name_indigo</item>
<item>@string/color_name_blue</item>
<item>@string/color_name_lightblue</item>
<item>@string/color_name_cyan</item>
<item>@string/color_name_teal</item>
<item>@string/color_name_green</item>
<item>@string/color_name_lightgreen</item>
<item>@string/color_name_lime</item>
<item>@string/color_name_yellow</item>
<item>@string/color_name_amber</item>
<item>@string/color_name_orange</item>
<item>@string/color_name_deeporange</item>
<item>@string/color_name_brown</item>
<item>@string/color_name_gray</item>
<item>@string/color_name_bluegray</item>
<item>@string/color_name_white</item>
</string-array>
<string-array name="rictxwf01_color_values">
<item>red</item>
<item>pink</item>
<item>purple</item>
<item>deeppurple</item>
<item>indigo</item>
<item>blue</item>
<item>lightblue</item>
<item>cyan</item>
<item>teal</item>
<item>green</item>
<item>lightgreen</item>
<item>lime</item>
<item>yellow</item>
<item>amber</item>
<item>orange</item>
<item>deeporange</item>
<item>brown</item>
<item>gray</item>
<item>bluegray</item>
<item>rainbow</item>
<item>simplestyle</item>
<item>nostyle</item>
<item>white</item>
</string-array>
<string-array name="rictxwf01_color_saturation">
<item>100</item>
<item>500</item>
<item>700</item>
<item>900</item>
</string-array>
</resources>

View file

@ -117,18 +117,40 @@
<string name="unit_h" comment="One letter shortcut for: Hour" maxLength="1">h</string>
<string name="unit_d" comment="One letter shortcut for: Day" maxLength="1">d</string>
<string name="unit_w" comment="One letter shortcut for: Week" maxLength="1">w</string>
<string name="pref_choose_your_style">Choose your style</string>
<string name="pref_vibrate_hourly">vibrate hourly</string>
<string name="color_name_deeppurple">deep purple</string>
<string name="color_name_red">red</string>
<string name="color_name_orange">orange</string>
<string name="color_name_lime">lime</string>
<string name="color_name_indigo">indigo</string>
<string name="style_nostyle">no style</string>
<string name="style_simplestyle">simple style</string>
<string name="color_name_bluegray">blue gray</string>
<string name="color_name_lightblue">light blue</string>
<string name="style_rainbowstyle">rainbow style</string>
<string name="color_name_red">red</string>
<string name="color_name_pink">pink</string>
<string name="color_name_purple">purple</string>
<string name="color_name_deeppurple">deep purple</string>
<string name="color_name_indigo">indigo</string>
<string name="color_name_blue">blue</string>
<string name="color_name_lightblue">light blue</string>
<string name="color_name_cyan">cyan</string>
<string name="color_name_teal">teal</string>
<string name="color_name_green">green</string>
<string name="color_name_lightgreen">light green</string>
<string name="color_name_lime">lime</string>
<string name="color_name_yellow">yellow</string>
<string name="color_name_amber">amber</string>
<string name="color_name_orange">orange</string>
<string name="color_name_deeporange">deep orange</string>
<string name="color_name_brown">brown</string>
<string name="color_name_gray">gray</string>
<string name="color_name_bluegray">blue gray</string>
<string name="color_name_white">white</string>
<string name="color_name_black">black</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_full">full style</string>
<string name="style_rainbow">rainbow 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_vibrate_hourly">vibrate hourly</string>
</resources>

View file

@ -6,10 +6,23 @@
<ListPreference
android:key="rictxwf01_frameStyle"
android:title="@string/pref_choose_your_style"
android:defaultValue="red"
android:defaultValue="full"
android:entries="@array/rictxwf01_styles_name"
android:entryValues="@array/rictxwf01_styles_values"/>
<ListPreference
android:key="rictxwf01_frameColor"
android:title="@string/pref_choose_your_color"
android:defaultValue="red"
android:entries="@array/rictxwf01_color_name"
android:entryValues="@array/rictxwf01_color_values"/>
<ListPreference
android:key="rictxwf01_frameColorSaturation"
android:title="@string/pref_choose_your_color_saturation"
android:defaultValue="700"
android:entries="@array/rictxwf01_color_saturation"
android:entryValues="@array/rictxwf01_color_saturation"/>
<CheckBoxPreference
android:key="show_date"
android:title="@string/pref_show_date"
@ -17,15 +30,6 @@
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<!-- Idea for future implementation @ToDo Implement Background-Images
<ListPreference
android:key="rictxwf01_backgroundImage"
android:title="Background Image"
android:defaultValue="red"
android:entries="@array/rictxwf01_backgroundimage_name"
android:entryValues="@array/rictxwf01_backgroundimage_values" />
-->
<CheckBoxPreference
android:key="rictxwf01_vibrateHourly"
android:title="@string/pref_vibrate_hourly"