1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-27 20:36:51 +01:00

Fossil Hybrid HR: Add choice between hiding text and showing circle on custom widget timeout

This commit is contained in:
Arjan Schrijver 2021-11-22 21:28:47 +01:00
parent d1062a30b2
commit 88218a1273
8 changed files with 67 additions and 4 deletions

View File

@ -0,0 +1,15 @@
LLi   
  6     0   ,   (  $ $      !          
     
                       "      &      %      #  
   !                       
                                               
  
                                                                                                                                                                                                                     
             
                                         
                     !       #  
   %      &      "                        
     
         !      $  $ (   ,   0     6   
  i ˙˙

View File

@ -44,6 +44,7 @@ import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -353,6 +354,8 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
String widgetName = layoutItem.getString("name"); String widgetName = layoutItem.getString("name");
String widgetTimezone = null; String widgetTimezone = null;
int widgetUpdateTimeout = -1; int widgetUpdateTimeout = -1;
boolean widgetTimeoutHideText = true;
boolean widgetTimeoutShowCircle = true;
switch (widgetName) { switch (widgetName) {
case "dateSSE": case "dateSSE":
widgetName = "widgetDate"; widgetName = "widgetDate";
@ -400,11 +403,15 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
widgetName = "widgetCustom"; widgetName = "widgetCustom";
JSONObject widgetData = layoutItem.getJSONObject("data"); JSONObject widgetData = layoutItem.getJSONObject("data");
widgetUpdateTimeout = widgetData.getInt("update_timeout"); widgetUpdateTimeout = widgetData.getInt("update_timeout");
widgetTimeoutHideText = widgetData.getBoolean("timeout_hide_text");
widgetTimeoutShowCircle = widgetData.getBoolean("timeout_show_circle");
widgets.add(new HybridHRWatchfaceWidget(widgetName, widgets.add(new HybridHRWatchfaceWidget(widgetName,
layoutItem.getJSONObject("pos").getInt("x"), layoutItem.getJSONObject("pos").getInt("x"),
layoutItem.getJSONObject("pos").getInt("y"), layoutItem.getJSONObject("pos").getInt("y"),
widgetColor, widgetColor,
widgetUpdateTimeout)); widgetUpdateTimeout,
widgetTimeoutHideText,
widgetTimeoutShowCircle));
} else { } else {
widgets.add(new HybridHRWatchfaceWidget(widgetName, widgets.add(new HybridHRWatchfaceWidget(widgetName,
layoutItem.getJSONObject("pos").getInt("x"), layoutItem.getJSONObject("pos").getInt("x"),
@ -615,6 +622,14 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
if ((widget != null) && (widget.getUpdateTimeout() >= 0)) { if ((widget != null) && (widget.getUpdateTimeout() >= 0)) {
updateTimeout.setText(Integer.toString(widget.getUpdateTimeout())); updateTimeout.setText(Integer.toString(widget.getUpdateTimeout()));
} }
final CheckBox timeoutHideText = layout.findViewById(R.id.watchface_widget_timeout_hide_text);
if ((widget != null) && (widget.getTimeoutHideText())) {
timeoutHideText.setChecked(widget.getTimeoutHideText());
}
final CheckBox timeoutShowCircle = layout.findViewById(R.id.watchface_widget_timeout_show_circle);
if ((widget != null) && (widget.getTimeoutShowCircle())) {
timeoutShowCircle.setChecked(widget.getTimeoutShowCircle());
}
// Show certain input fields only when the relevant TZ widget is selected // Show certain input fields only when the relevant TZ widget is selected
typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
@ -673,11 +688,13 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
LOG.warn("Error parsing input", e); LOG.warn("Error parsing input", e);
return; return;
} }
boolean selectedTimeoutHideText = timeoutHideText.isChecked();
boolean selectedTimeoutShowCircle = timeoutShowCircle.isChecked();
HybridHRWatchfaceWidget widgetConfig; HybridHRWatchfaceWidget widgetConfig;
if (selectedType.equals("widget2ndTZ")) { if (selectedType.equals("widget2ndTZ")) {
widgetConfig = new HybridHRWatchfaceWidget(selectedType, selectedPosX, selectedPosY, colorSpinner.getSelectedItemPosition(), selectedTZ); widgetConfig = new HybridHRWatchfaceWidget(selectedType, selectedPosX, selectedPosY, colorSpinner.getSelectedItemPosition(), selectedTZ);
} else if (selectedType.equals("widgetCustom")) { } else if (selectedType.equals("widgetCustom")) {
widgetConfig = new HybridHRWatchfaceWidget(selectedType, selectedPosX, selectedPosY, colorSpinner.getSelectedItemPosition(), selectedUpdateTimeout); widgetConfig = new HybridHRWatchfaceWidget(selectedType, selectedPosX, selectedPosY, colorSpinner.getSelectedItemPosition(), selectedUpdateTimeout, selectedTimeoutHideText, selectedTimeoutShowCircle);
} else { } else {
widgetConfig = new HybridHRWatchfaceWidget(selectedType, selectedPosX, selectedPosY, colorSpinner.getSelectedItemPosition()); widgetConfig = new HybridHRWatchfaceWidget(selectedType, selectedPosX, selectedPosY, colorSpinner.getSelectedItemPosition());
} }

View File

@ -79,6 +79,8 @@ public class HybridHRWatchfaceFactory {
if (widgetDesc.getUpdateTimeout() >= 0) { if (widgetDesc.getUpdateTimeout() >= 0) {
JSONObject data = new JSONObject(); JSONObject data = new JSONObject();
data.put("update_timeout", widgetDesc.getUpdateTimeout()); data.put("update_timeout", widgetDesc.getUpdateTimeout());
data.put("timeout_hide_text", widgetDesc.getTimeoutHideText());
data.put("timeout_show_circle", widgetDesc.getTimeoutShowCircle());
widget.put("data", data); widget.put("data", data);
} }
break; break;
@ -179,6 +181,7 @@ public class HybridHRWatchfaceFactory {
if (includeWidget("widgetCalories") > 0) icons.put("icCalories", context.getAssets().open("fossil_hr/icCalories.rle")); if (includeWidget("widgetCalories") > 0) icons.put("icCalories", context.getAssets().open("fossil_hr/icCalories.rle"));
if (includeWidget("widgetActiveMins") > 0) icons.put("icActiveMins", context.getAssets().open("fossil_hr/icActiveMins.rle")); if (includeWidget("widgetActiveMins") > 0) icons.put("icActiveMins", context.getAssets().open("fossil_hr/icActiveMins.rle"));
if (includeWidget("widgetChanceOfRain") > 0) icons.put("icRainChance", context.getAssets().open("fossil_hr/icRainChance.rle")); if (includeWidget("widgetChanceOfRain") > 0) icons.put("icRainChance", context.getAssets().open("fossil_hr/icRainChance.rle"));
if (includeWidget("widgetCustom") > 0) icons.put("widget_bg_error.rle", context.getAssets().open("fossil_hr/widget_bg_error.rle"));
} catch (IOException e) { } catch (IOException e) {
LOG.warn("Unable to read asset file", e); LOG.warn("Unable to read asset file", e);
} }

View File

@ -34,6 +34,8 @@ public class HybridHRWatchfaceWidget {
private int color = 0; private int color = 0;
private String timezone; private String timezone;
private int updateTimeout = -1; private int updateTimeout = -1;
private boolean timeoutHideText = true;
private boolean timeoutShowCircle = true;
public static int COLOR_WHITE = 0; public static int COLOR_WHITE = 0;
public static int COLOR_BLACK = 1; public static int COLOR_BLACK = 1;
@ -48,9 +50,11 @@ public class HybridHRWatchfaceWidget {
this(widgetType, posX, posY, color); this(widgetType, posX, posY, color);
this.timezone = timezone; this.timezone = timezone;
} }
public HybridHRWatchfaceWidget(String widgetType, int posX, int posY, int color, int updateTimeout) { public HybridHRWatchfaceWidget(String widgetType, int posX, int posY, int color, int updateTimeout, boolean timeoutHideText, boolean timeoutShowCircle) {
this(widgetType, posX, posY, color); this(widgetType, posX, posY, color);
this.updateTimeout = updateTimeout; this.updateTimeout = updateTimeout;
this.timeoutHideText = timeoutHideText;
this.timeoutShowCircle = timeoutShowCircle;
} }
@ -106,4 +110,10 @@ public class HybridHRWatchfaceWidget {
public int getUpdateTimeout() { public int getUpdateTimeout() {
return updateTimeout; return updateTimeout;
} }
public boolean getTimeoutHideText() {
return timeoutHideText;
}
public boolean getTimeoutShowCircle() {
return timeoutShowCircle;
}
} }

View File

@ -105,6 +105,22 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="number"/> android:inputType="number"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/watchface_dialog_widget_timeout_hide_text" />
<CheckBox
android:id="@+id/watchface_widget_timeout_hide_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/watchface_dialog_widget_timeout_show_circle" />
<CheckBox
android:id="@+id/watchface_widget_timeout_show_circle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -1390,5 +1390,7 @@
<string name="watchface_widget_type_custom">Custom widget</string> <string name="watchface_widget_type_custom">Custom widget</string>
<string name="watchface_dialog_widget_timezone">Time zone:</string> <string name="watchface_dialog_widget_timezone">Time zone:</string>
<string name="watchface_dialog_widget_update_timeout">Update timeout in minutes:</string> <string name="watchface_dialog_widget_update_timeout">Update timeout in minutes:</string>
<string name="watchface_dialog_widget_timeout_hide_text">Hide text on timeout:</string>
<string name="watchface_dialog_widget_timeout_show_circle">Show circle on timeout:</string>
</resources> </resources>

@ -1 +1 @@
Subproject commit 8855d1735b07939f483759cb7e836a8418f30515 Subproject commit 44a70cf7c3a783d07d0fdab8b4b15e677da63af2