Skip to content

Commit

Permalink
Merge pull request #21459 from osmandapp/volume_units_behavior
Browse files Browse the repository at this point in the history
Volume unit behavior as units of length
  • Loading branch information
alex-osm authored Dec 20, 2024
2 parents eda6649 + 42d99d2 commit a405491
Showing 1 changed file with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,49 @@ public T get() {

@Override
public final void resetToDefault() {
T o = getProfileDefaultValue(getApplicationMode());
set(o);
if (global) {
T oldValue = get();
Object prefs = getPreferences();
if (getSettingsAPI().edit(prefs).remove(getId()).commit()) {
T newValue = get();
boolean changed = !Algorithms.objectEquals(oldValue, newValue);
if (changed && lastModifiedTimeStored) {
setLastModifiedTime(prefs, System.currentTimeMillis());
}
if (changed && isShared()) {
if (PluginsHelper.isDevelopment()) {
Log.d("CommonPreference", "RESET_TO_DEFAULT id=" + getId()
+ " value=" + newValue + " cached=" + cachedValue);
}
settings.updateLastPreferencesEditTime(prefs);
}
cachedValue = newValue;
cachedPreference = prefs;
fireEvent(newValue);
}
} else {
resetModeToDefault(getApplicationMode());
}
}

@Override
public final void resetModeToDefault(ApplicationMode mode) {
if (global) {
resetToDefault();
} else {
T o = getProfileDefaultValue(mode);
setModeValue(mode, o);
} else if (mode != null) {
T oldValue = getModeValue(mode);
Object prefs = settings.getProfilePreferences(mode);
if (getSettingsAPI().edit(prefs).remove(getId()).commit()) {
T newValue = getModeValue(mode);
boolean changed = !Algorithms.objectEquals(oldValue, newValue);
if (changed) {
settings.updateLastPreferencesEditTime(prefs);
}
if (cache && cachedPreference == prefs) {
cachedValue = newValue;
}
fireEvent(newValue);
}
}
}

Expand Down

0 comments on commit a405491

Please sign in to comment.