copy of copy profiles, action, filters
This commit is contained in:
parent
a19e6a3576
commit
6b93e03a99
7 changed files with 48 additions and 28 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -11,7 +11,6 @@
|
|||
android:id="@+id/toolbar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
@ -40,7 +39,6 @@
|
|||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/toolbar_layout"
|
||||
android:background="?attr/bg_color"
|
||||
android:paddingStart="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/list_header_settings_top_margin"
|
||||
|
@ -55,15 +53,13 @@
|
|||
android:id="@+id/description_divider"
|
||||
layout="@layout/card_bottom_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/description" />
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<ExpandableListView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/description_divider"
|
||||
android:layout_marginBottom="@dimen/dialog_button_ex_height"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:divider="@null"
|
||||
android:dividerHeight="0dp"
|
||||
android:drawSelectorOnTop="false"
|
||||
|
@ -74,7 +70,6 @@
|
|||
android:id="@+id/buttons_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dialog_button_ex_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="?attr/bg_color"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
|
@ -140,4 +135,4 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
|
@ -47,14 +47,17 @@
|
|||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
||||
<include layout="@layout/list_item_divider" />
|
||||
<include
|
||||
android:id="@+id/description_divider"
|
||||
layout="@layout/card_bottom_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/list_background_color" />
|
||||
android:layout_weight="1" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -93,6 +93,7 @@ public class SettingsHelper {
|
|||
public static final String SETTINGS_VERSION_KEY = "settings_version";
|
||||
|
||||
private static final String COPY_PREFIX = "copy_";
|
||||
private static final String COPY_SUFFIX = "_copy";
|
||||
private static final Log LOG = PlatformUtil.getLog(SettingsHelper.class);
|
||||
private static final int BUFFER = 1024;
|
||||
|
||||
|
@ -509,12 +510,19 @@ public class SettingsHelper {
|
|||
return builder != null && ApplicationMode.valueOfStringKey(getName(), null) != null;
|
||||
}
|
||||
|
||||
private void renameProfile() {
|
||||
modeBean.stringKey = COPY_PREFIX + modeBean.stringKey;
|
||||
modeBean.userProfileName = COPY_PREFIX + modeBean.userProfileName;
|
||||
if (ApplicationMode.valueOfStringKey(modeBean.stringKey, null) != null) {
|
||||
renameProfile();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
if (appMode.isCustomProfile()) {
|
||||
if (!shouldReplace) {
|
||||
modeBean.stringKey = COPY_PREFIX + modeBean.stringKey;
|
||||
modeBean.userProfileName = COPY_PREFIX + modeBean.userProfileName;
|
||||
if (!shouldReplace && exists()) {
|
||||
renameProfile();
|
||||
builder = ApplicationMode.fromModeBean(app, modeBean);
|
||||
}
|
||||
appMode = ApplicationMode.saveProfile(builder, getSettings().getContext());
|
||||
|
@ -748,10 +756,6 @@ public class SettingsHelper {
|
|||
if (shouldReplace || !file.exists()) {
|
||||
output = new FileOutputStream(file);
|
||||
} else {
|
||||
// String path = file.getAbsolutePath();
|
||||
// String copyName = path.replaceAll(file.getName(), COPY_PREFIX + file.getName());
|
||||
// File copyFile = new File(copyName);
|
||||
// output = new FileOutputStream(copyFile);
|
||||
output = new FileOutputStream(renameFile(file));
|
||||
}
|
||||
byte[] buffer = new byte[BUFFER];
|
||||
|
@ -805,6 +809,24 @@ public class SettingsHelper {
|
|||
return quickActions;
|
||||
}
|
||||
|
||||
private void renameAction(QuickAction quickAction) {
|
||||
quickAction.setName(COPY_PREFIX + quickAction.getName(app));
|
||||
if (duplicateExists(quickAction)) {
|
||||
renameAction(quickAction);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean duplicateExists(QuickAction quickAction) {
|
||||
QuickActionFactory factory = new QuickActionFactory();
|
||||
List<QuickAction> savedActions = factory.parseActiveActionsList(getSettings().QUICK_ACTION_LIST.get());
|
||||
for (QuickAction action : savedActions) {
|
||||
if (action.getName(app).equals(quickAction.getName(app))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
if (!quickActions.isEmpty() || !duplicates.isEmpty()) {
|
||||
|
@ -822,7 +844,7 @@ public class SettingsHelper {
|
|||
}
|
||||
} else {
|
||||
for (QuickAction action : duplicates) {
|
||||
action.setName(COPY_PREFIX + action.getName(app));
|
||||
renameAction(action);
|
||||
}
|
||||
}
|
||||
newActions.addAll(duplicates);
|
||||
|
@ -979,7 +1001,6 @@ public class SettingsHelper {
|
|||
for (PoiUIFilter duplicate : duplicates) {
|
||||
if (!shouldReplace) {
|
||||
renamePoiFilter(duplicate);
|
||||
// duplicate.setName(COPY_PREFIX + duplicate.getName());
|
||||
}
|
||||
poiUIFilters.add(duplicate);
|
||||
}
|
||||
|
@ -992,6 +1013,7 @@ public class SettingsHelper {
|
|||
|
||||
private void renamePoiFilter(PoiUIFilter poiUIFilter) {
|
||||
poiUIFilter.setName(COPY_PREFIX + poiUIFilter.getName());
|
||||
poiUIFilter.setFilterId(poiUIFilter.getFilterId() + COPY_SUFFIX);
|
||||
if (duplicateExists(poiUIFilter)) {
|
||||
renamePoiFilter(poiUIFilter);
|
||||
}
|
||||
|
|
|
@ -726,6 +726,10 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
|
|||
return filterId;
|
||||
}
|
||||
|
||||
public void setFilterId(String filterId) {
|
||||
this.filterId = filterId;
|
||||
}
|
||||
|
||||
public Map<String, PoiType> getPoiAdditionals() {
|
||||
return poiAdditionals;
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
|
|||
((ItemViewHolder) holder).icon.setImageResource(View.VISIBLE);
|
||||
} else {
|
||||
((ItemViewHolder) holder).icon.setImageResource(R.drawable.ic_action_info_dark);
|
||||
((ItemViewHolder) holder).icon.setVisibility(View.GONE);
|
||||
((ItemViewHolder) holder).icon.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
((ItemViewHolder) holder).divider.setVisibility(shouldShowDivider(position) ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
|
|
@ -169,10 +169,6 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
|
|||
}
|
||||
}
|
||||
});
|
||||
// if (getFragmentManager() != null) {
|
||||
// ImportSettingsFragment fragment = (ImportSettingsFragment) getFragmentManager().findFragmentByTag(ImportSettingsFragment.TAG);
|
||||
// fragment.dismiss();
|
||||
// }
|
||||
dismiss();
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue