Refactoring ProfileAppearanceFragment

This commit is contained in:
Dima-1 2020-02-21 18:23:31 +02:00
parent aae885d0dd
commit e9fb6fc939

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());
}
@ -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()) &&