Skip to content

Commit

Permalink
loadLengthUnitsPref
Browse files Browse the repository at this point in the history
Use the app setting as default for widgets. #506
  • Loading branch information
forrestguice committed Sep 7, 2021
1 parent aaa245f commit 24cd1c3
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,9 @@ public static LengthUnit loadLengthUnitsPref(Context context, int appWidgetId)
{
SharedPreferences prefs = context.getSharedPreferences(PREFS_WIDGET, 0);
String prefs_prefix = PREF_PREFIX_KEY + appWidgetId + PREF_PREFIX_KEY_GENERAL;
return getLengthUnit(prefs.getString(prefs_prefix + PREF_KEY_GENERAL_UNITS_LENGTH, PREF_DEF_GENERAL_UNITS_LENGTH.name()));
String defaultValue = (appWidgetId == 0) ? PREF_DEF_GENERAL_UNITS_LENGTH.name() // prefer the current app setting [0] as the default value
: prefs.getString(PREF_PREFIX_KEY + 0 + PREF_PREFIX_KEY_GENERAL + PREF_KEY_GENERAL_UNITS_LENGTH, PREF_DEF_GENERAL_UNITS_LENGTH.name());
return getLengthUnit(prefs.getString(prefs_prefix + PREF_KEY_GENERAL_UNITS_LENGTH, defaultValue));
}

public static LengthUnit getLengthUnit(String unitName)
Expand Down

0 comments on commit 24cd1c3

Please sign in to comment.