From e9fb6fc939147a582e1f7f6ba85ce321fdca1a07 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 21 Feb 2020 18:23:31 +0200 Subject: [PATCH] Refactoring ProfileAppearanceFragment --- .../osmand/plus/settings/ProfileAppearanceFragment.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java index e349563e52..eddd1d6ccc 100644 --- a/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java @@ -112,7 +112,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment { if (baseModeForNewProfile != null) { setupAppProfileObjectFromAppMode(baseModeForNewProfile); profile.parent = baseModeForNewProfile; - profile.stringKey = baseModeForNewProfile.getStringKey() + "_" + System.currentTimeMillis(); + profile.stringKey = getUniqueStringKey(baseModeForNewProfile); } else { setupAppProfileObjectFromAppMode(getSelectedAppMode()); } @@ -657,7 +657,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment { return false; } if (isNewProfile) { - changedProfile.stringKey = changedProfile.parent.getStringKey() + "_" + System.currentTimeMillis(); + changedProfile.stringKey = getUniqueStringKey(changedProfile.parent); ApplicationMode.ApplicationModeBuilder builder = ApplicationMode .createCustomMode(changedProfile.parent, changedProfile.stringKey, app) .setIconResName(ProfileIcons.getResStringByResId(changedProfile.iconRes)) @@ -687,6 +687,10 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment { return true; } + private String getUniqueStringKey(ApplicationMode mode) { + return mode.getStringKey() + "_" + System.currentTimeMillis(); + } + private boolean hasNameDuplicate() { for (ApplicationMode m : ApplicationMode.allPossibleValues()) { if (m.toHumanString().trim().equals(changedProfile.name.trim()) &&