1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-17 22:27:46 +01:00

Fossil Hybrid HR: Make 2nd TZ widget clock duration configurable

This commit is contained in:
Arjan Schrijver 2022-07-07 22:16:52 +02:00
parent d03ec5518b
commit 6649f1941a
6 changed files with 31 additions and 1 deletions

View File

@ -571,6 +571,13 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
} else {
tzSpinner.setSelection(Arrays.asList(timezonesList).indexOf("Etc/UTC"));
}
// Set timezone clock timeout
final LinearLayout timezoneTimeoutLayout = layout.findViewById(R.id.watchface_widget_timezone_timeout_layout);
timezoneTimeoutLayout.setVisibility(View.GONE);
final EditText timezoneTimeout = layout.findViewById(R.id.watchface_widget_timezone_timeout);
if ((widget != null) && (widget.getExtraConfigInt("timeout_secs", -1) >= 0)) {
timezoneTimeout.setText(Integer.toString(widget.getExtraConfigInt("timeout_secs", -1)));
}
// Set update timeout value
final LinearLayout updateTimeoutLayout = layout.findViewById(R.id.watchface_widget_update_timeout_layout);
updateTimeoutLayout.setVisibility(View.GONE);
@ -593,8 +600,10 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
String selectedType = widgetTypesArray.get(typeSpinner.getSelectedItemPosition());
if (selectedType.equals("widget2ndTZ")) {
timezoneLayout.setVisibility(View.VISIBLE);
timezoneTimeoutLayout.setVisibility(View.VISIBLE);
} else {
timezoneLayout.setVisibility(View.GONE);
timezoneTimeoutLayout.setVisibility(View.GONE);
}
if (selectedType.equals("widgetCustom")) {
sizeLayout.setVisibility(View.VISIBLE);
@ -644,6 +653,7 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
}
String selectedType = widgetTypesArray.get(typeSpinner.getSelectedItemPosition());
String selectedTZ = tzSpinner.getSelectedItem().toString();
int selectedTZtimeout = Integer.parseInt(timezoneTimeout.getText().toString());
int selectedUpdateTimeout = 0;
if (selectedType.equals("widgetCustom")) {
try {
@ -661,6 +671,7 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
JSONObject extraConfig = new JSONObject();
try {
extraConfig.put("tzName", selectedTZ);
extraConfig.put("timeout_secs", selectedTZtimeout);
} catch (JSONException e) {
LOG.warn("JSON error", e);
}

View File

@ -102,6 +102,7 @@ public class HybridHRWatchfaceFactory {
data.put("tzName", widgetDesc.getExtraConfigString("tzName", null));
data.put("loc", tzShortName);
data.put("utc", tzOffsetMins);
data.put("timeout_secs", widgetDesc.getExtraConfigInt("timeout_secs", 0));
widget.put("data", data);
}
break;

View File

@ -108,6 +108,23 @@
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="@+id/watchface_widget_timezone_timeout_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/watchface_dialog_widget_timezone_duration" />
<EditText
android:id="@+id/watchface_widget_timezone_timeout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:text="15"/>
</LinearLayout>
<LinearLayout
android:id="@+id/watchface_widget_update_timeout_layout"
android:layout_width="match_parent"

View File

@ -1638,6 +1638,7 @@
<string name="sony_button_mode_volume_control">Volume Control</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_duration">Clock visibility duration (in seconds):</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>

@ -1 +1 @@
Subproject commit 7c46ccf890b5e6ee30e3711c2f8ed181e4b3f0c6
Subproject commit 3b35b2a0a6bc0e8a5262e7b61154cdf487fa94a6