Refactoring ProfileAppearanceFragment

(cherry picked from commit e9fb6fc939)
This commit is contained in:
Dima-1 2020-02-21 18:23:31 +02:00
parent 0fcf07aba2
commit 4eec8bbbca

View file

@ -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());
}
@ -661,7 +661,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))
@ -691,6 +691,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()) &&