copy of copy base profiles, ui fixes
This commit is contained in:
parent
6b93e03a99
commit
b5f5e0e916
8 changed files with 108 additions and 58 deletions
|
@ -49,11 +49,7 @@
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium" />
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
<include
|
<include layout="@layout/card_bottom_divider" />
|
||||||
android:id="@+id/description_divider"
|
|
||||||
layout="@layout/card_bottom_divider"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
|
|
||||||
<ExpandableListView
|
<ExpandableListView
|
||||||
android:id="@+id/list"
|
android:id="@+id/list"
|
||||||
|
@ -66,6 +62,8 @@
|
||||||
android:groupIndicator="@android:color/transparent"
|
android:groupIndicator="@android:color/transparent"
|
||||||
android:listSelector="@android:color/transparent" />
|
android:listSelector="@android:color/transparent" />
|
||||||
|
|
||||||
|
<include layout="@layout/card_top_divider" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/buttons_container"
|
android:id="@+id/buttons_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -49,9 +49,7 @@
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/description_divider"
|
android:id="@+id/description_divider"
|
||||||
layout="@layout/card_bottom_divider"
|
layout="@layout/card_bottom_divider" />
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/list"
|
android:id="@+id/list"
|
||||||
|
@ -59,6 +57,9 @@
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<include
|
||||||
|
layout="@layout/card_top_divider" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="shared_sting_preparing">Preparing</string>
|
||||||
<string name="shared_sting_poi_types">POI types</string>
|
<string name="shared_sting_poi_types">POI types</string>
|
||||||
<string name="shared_sting_nothing_selected">Nothing selected</string>
|
<string name="shared_sting_nothing_selected">Nothing selected</string>
|
||||||
<string name="shared_sting_quick_actions">Quick actions</string>
|
<string name="shared_sting_quick_actions">Quick actions</string>
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
@ -23,6 +24,7 @@ import net.osmand.plus.ApplicationMode.ApplicationModeBuilder;
|
||||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
|
import net.osmand.plus.profiles.ProfileIcons;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
import net.osmand.plus.quickaction.QuickActionFactory;
|
import net.osmand.plus.quickaction.QuickActionFactory;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -520,15 +522,30 @@ public class SettingsHelper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply() {
|
public void apply() {
|
||||||
if (appMode.isCustomProfile()) {
|
if (!appMode.isCustomProfile() && !shouldReplace) {
|
||||||
if (!shouldReplace && exists()) {
|
ApplicationMode parent = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
|
||||||
|
renameProfile();
|
||||||
|
ApplicationMode.ApplicationModeBuilder builder = ApplicationMode
|
||||||
|
.createCustomMode(parent, modeBean.stringKey, app)
|
||||||
|
.setIconResName(modeBean.iconName)
|
||||||
|
.setUserProfileName(modeBean.userProfileName)
|
||||||
|
.setRoutingProfile(modeBean.routingProfile)
|
||||||
|
.setRouteService(modeBean.routeService)
|
||||||
|
.setIconColor(modeBean.iconColor)
|
||||||
|
.setLocationIcon(modeBean.locIcon)
|
||||||
|
.setNavigationIcon(modeBean.navIcon);
|
||||||
|
app.getSettings().copyPreferencesFromProfile(parent, builder.getApplicationMode());
|
||||||
|
appMode = ApplicationMode.saveProfile(builder, app);
|
||||||
|
} else if (!shouldReplace && exists()) {
|
||||||
renameProfile();
|
renameProfile();
|
||||||
builder = ApplicationMode.fromModeBean(app, modeBean);
|
builder = ApplicationMode.fromModeBean(app, modeBean);
|
||||||
|
appMode = ApplicationMode.saveProfile(builder, app);
|
||||||
|
} else {
|
||||||
|
builder = ApplicationMode.fromModeBean(app, modeBean);
|
||||||
|
appMode = ApplicationMode.saveProfile(builder, app);
|
||||||
}
|
}
|
||||||
appMode = ApplicationMode.saveProfile(builder, getSettings().getContext());
|
|
||||||
ApplicationMode.changeProfileAvailability(appMode, true, app);
|
ApplicationMode.changeProfileAvailability(appMode, true, app);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void writeToJson(@NonNull JSONObject json) throws JSONException {
|
void writeToJson(@NonNull JSONObject json) throws JSONException {
|
||||||
|
@ -1809,6 +1826,7 @@ public class SettingsHelper {
|
||||||
private SettingsExporter exporter;
|
private SettingsExporter exporter;
|
||||||
private File file;
|
private File file;
|
||||||
private SettingsExportListener listener;
|
private SettingsExportListener listener;
|
||||||
|
private ProgressDialog progress;
|
||||||
|
|
||||||
ExportAsyncTask(@NonNull File settingsFile,
|
ExportAsyncTask(@NonNull File settingsFile,
|
||||||
@Nullable SettingsExportListener listener,
|
@Nullable SettingsExportListener listener,
|
||||||
|
@ -1821,6 +1839,12 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
super.onPreExecute();
|
||||||
|
progress = ProgressDialog.show(activity, app.getString(R.string.export_profile), app.getString(R.string.shared_sting_preparing));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(Void... voids) {
|
protected Boolean doInBackground(Void... voids) {
|
||||||
try {
|
try {
|
||||||
|
@ -1836,6 +1860,7 @@ public class SettingsHelper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Boolean success) {
|
protected void onPostExecute(Boolean success) {
|
||||||
|
progress.dismiss();
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onSettingsExportFinished(file, success);
|
listener.onSettingsExportFinished(file, success);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package net.osmand.plus.settings;
|
package net.osmand.plus.settings;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -9,13 +8,16 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.map.ITileSource;
|
import net.osmand.map.ITileSource;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
|
import net.osmand.plus.profiles.ProfileIconColors;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
import net.osmand.plus.render.RenderingIcons;
|
import net.osmand.plus.render.RenderingIcons;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -59,46 +61,54 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
(String) currentItem));
|
(String) currentItem));
|
||||||
((HeaderViewHolder) holder).divider.setVisibility(View.VISIBLE);
|
((HeaderViewHolder) holder).divider.setVisibility(View.VISIBLE);
|
||||||
} else if (holder instanceof ItemViewHolder) {
|
} else if (holder instanceof ItemViewHolder) {
|
||||||
String title = null;
|
if (currentItem instanceof ApplicationMode.ApplicationModeBean) {
|
||||||
String subTitle = null;
|
String profileName = ((ApplicationMode.ApplicationModeBean) currentItem).userProfileName;
|
||||||
Drawable drawable = null;
|
if (Algorithms.isEmpty(profileName)) {
|
||||||
if (currentItem instanceof ApplicationMode) {
|
ApplicationMode appMode = ApplicationMode.valueOfStringKey(((ApplicationMode.ApplicationModeBean) currentItem).stringKey, null);
|
||||||
title = ((ApplicationMode) currentItem).toHumanString();
|
profileName = app.getString(appMode.getNameKeyResource());
|
||||||
subTitle = ((ApplicationMode) currentItem).getRoutingProfile();
|
|
||||||
drawable = app.getUIUtilities().getIcon(
|
|
||||||
((ApplicationMode) currentItem).getIconRes(),
|
|
||||||
((ApplicationMode) currentItem).getIconColorInfo().getColor(nightMode)
|
|
||||||
);
|
|
||||||
} else if (currentItem instanceof QuickAction) {
|
|
||||||
title = ((QuickAction) currentItem).getName(app);
|
|
||||||
drawable = app.getUIUtilities().getIcon(((QuickAction) currentItem).getIconRes(), nightMode);
|
|
||||||
} else if (currentItem instanceof PoiUIFilter) {
|
|
||||||
title = ((PoiUIFilter) currentItem).getName();
|
|
||||||
int iconRes = RenderingIcons.getBigIconResourceId(((PoiUIFilter) currentItem).getIconId());
|
|
||||||
drawable = app.getUIUtilities().getIcon(iconRes != 0 ? iconRes : R.drawable.ic_person, nightMode);
|
|
||||||
} else if (currentItem instanceof ITileSource) {
|
|
||||||
title = ((ITileSource) currentItem).getName();
|
|
||||||
drawable = app.getUIUtilities().getIcon(R.drawable.ic_action_info_dark, nightMode);
|
|
||||||
} else if (currentItem instanceof File) {
|
|
||||||
title = ((File) currentItem).getName();
|
|
||||||
if (((File) currentItem).getName().contains("/rendering/")) {
|
|
||||||
drawable = app.getUIUtilities().getIcon(R.drawable.ic_action_map_style, nightMode);
|
|
||||||
}
|
}
|
||||||
}
|
((ItemViewHolder) holder).title.setText(profileName);
|
||||||
((ItemViewHolder) holder).title.setText(title != null ? title : "");
|
String routingProfile = (((ApplicationMode.ApplicationModeBean) currentItem).routingProfile);
|
||||||
if (subTitle != null) {
|
if (Algorithms.isEmpty(routingProfile)) {
|
||||||
((ItemViewHolder) holder).subTitle.setText(subTitle);
|
|
||||||
((ItemViewHolder) holder).subTitle.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
((ItemViewHolder) holder).subTitle.setVisibility(View.GONE);
|
((ItemViewHolder) holder).subTitle.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
((ItemViewHolder) holder).subTitle.setText(String.format(
|
||||||
|
app.getString(R.string.ltr_or_rtl_combine_via_colon),
|
||||||
|
app.getString(R.string.nav_type_hint),
|
||||||
|
routingProfile));
|
||||||
|
((ItemViewHolder) holder).subTitle.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
if (drawable != null) {
|
int profileIconRes = AndroidUtils.getDrawableId(app, ((ApplicationMode.ApplicationModeBean) currentItem).iconName);
|
||||||
((ItemViewHolder) holder).icon.setImageDrawable(drawable);
|
ProfileIconColors iconColor = ((ApplicationMode.ApplicationModeBean) currentItem).iconColor;
|
||||||
((ItemViewHolder) holder).icon.setImageResource(View.VISIBLE);
|
((ItemViewHolder) holder).icon.setImageDrawable(app.getUIUtilities().getIcon(profileIconRes, iconColor.getColor(nightMode)));
|
||||||
|
((ItemViewHolder) holder).icon.setVisibility(View.VISIBLE);
|
||||||
|
} else if (currentItem instanceof QuickAction) {
|
||||||
|
((ItemViewHolder) holder).title.setText(((QuickAction) currentItem).getName(app.getApplicationContext()));
|
||||||
|
((ItemViewHolder) holder).icon.setImageDrawable(app.getUIUtilities().getIcon(((QuickAction) currentItem).getIconRes(), nightMode));
|
||||||
|
((ItemViewHolder) holder).subTitle.setVisibility(View.GONE);
|
||||||
|
((ItemViewHolder) holder).icon.setVisibility(View.VISIBLE);
|
||||||
|
} else if (currentItem instanceof PoiUIFilter) {
|
||||||
|
((ItemViewHolder) holder).title.setText(((PoiUIFilter) currentItem).getName());
|
||||||
|
int iconRes = RenderingIcons.getBigIconResourceId(((PoiUIFilter) currentItem).getIconId());
|
||||||
|
((ItemViewHolder) holder).icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes != 0 ? iconRes : R.drawable.ic_person, nightMode));
|
||||||
|
((ItemViewHolder) holder).subTitle.setVisibility(View.GONE);
|
||||||
|
((ItemViewHolder) holder).icon.setVisibility(View.VISIBLE);
|
||||||
|
} else if (currentItem instanceof ITileSource) {
|
||||||
|
((ItemViewHolder) holder).title.setText(((ITileSource) currentItem).getName());
|
||||||
|
((ItemViewHolder) holder).icon.setImageResource(R.drawable.ic_action_info_dark);
|
||||||
|
((ItemViewHolder) holder).subTitle.setVisibility(View.GONE);
|
||||||
|
((ItemViewHolder) holder).icon.setVisibility(View.INVISIBLE);
|
||||||
|
} else if (currentItem instanceof File) {
|
||||||
|
((ItemViewHolder) holder).title.setText(((File) currentItem).getName());
|
||||||
|
if (((File) currentItem).getName().contains("/rendering/")) {
|
||||||
|
((ItemViewHolder) holder).icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_map_style, nightMode));
|
||||||
|
((ItemViewHolder) holder).icon.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
((ItemViewHolder) holder).icon.setImageResource(R.drawable.ic_action_info_dark);
|
((ItemViewHolder) holder).icon.setImageResource(R.drawable.ic_action_info_dark);
|
||||||
((ItemViewHolder) holder).icon.setVisibility(View.INVISIBLE);
|
((ItemViewHolder) holder).icon.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
((ItemViewHolder) holder).subTitle.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
((ItemViewHolder) holder).divider.setVisibility(shouldShowDivider(position) ? View.VISIBLE : View.GONE);
|
((ItemViewHolder) holder).divider.setVisibility(shouldShowDivider(position) ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import net.osmand.plus.profiles.AdditionalDataWrapper;
|
||||||
import net.osmand.plus.profiles.ProfileIconColors;
|
import net.osmand.plus.profiles.ProfileIconColors;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
import net.osmand.plus.render.RenderingIcons;
|
import net.osmand.plus.render.RenderingIcons;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -147,12 +148,25 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case PROFILE:
|
case PROFILE:
|
||||||
title.setText(((ApplicationMode.ApplicationModeBean) currentItem).userProfileName);
|
String profileName = ((ApplicationMode.ApplicationModeBean) currentItem).userProfileName;
|
||||||
subText.setText(((ApplicationMode.ApplicationModeBean) currentItem).routingProfile);
|
if (Algorithms.isEmpty(profileName)) {
|
||||||
|
ApplicationMode appMode = ApplicationMode.valueOfStringKey(((ApplicationMode.ApplicationModeBean) currentItem).stringKey, null);
|
||||||
|
profileName = app.getString(appMode.getNameKeyResource());
|
||||||
|
}
|
||||||
|
title.setText(profileName);
|
||||||
|
String routingProfile = (((ApplicationMode.ApplicationModeBean) currentItem).routingProfile);
|
||||||
|
if (Algorithms.isEmpty(routingProfile)) {
|
||||||
|
subText.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
subText.setText(String.format(
|
||||||
|
app.getString(R.string.ltr_or_rtl_combine_via_colon),
|
||||||
|
app.getString(R.string.nav_type_hint),
|
||||||
|
routingProfile));
|
||||||
|
subText.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
int profileIconRes = AndroidUtils.getDrawableId(app, ((ApplicationMode.ApplicationModeBean) currentItem).iconName);
|
int profileIconRes = AndroidUtils.getDrawableId(app, ((ApplicationMode.ApplicationModeBean) currentItem).iconName);
|
||||||
ProfileIconColors iconColor = ((ApplicationMode.ApplicationModeBean) currentItem).iconColor;
|
ProfileIconColors iconColor = ((ApplicationMode.ApplicationModeBean) currentItem).iconColor;
|
||||||
icon.setImageDrawable(app.getUIUtilities().getIcon(profileIconRes, iconColor.getColor(nightMode)));
|
icon.setImageDrawable(app.getUIUtilities().getIcon(profileIconRes, iconColor.getColor(nightMode)));
|
||||||
subText.setVisibility(View.VISIBLE);
|
|
||||||
icon.setVisibility(View.VISIBLE);
|
icon.setVisibility(View.VISIBLE);
|
||||||
break;
|
break;
|
||||||
case QUICK_ACTIONS:
|
case QUICK_ACTIONS:
|
||||||
|
|
|
@ -45,6 +45,7 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
|
||||||
fragment.setDuplicatesList(duplicatesList);
|
fragment.setDuplicatesList(duplicatesList);
|
||||||
fragment.setSettingsItems(settingsItems);
|
fragment.setSettingsItems(settingsItems);
|
||||||
fragment.setFile(file);
|
fragment.setFile(file);
|
||||||
|
fragment.setRetainInstance(true);
|
||||||
fragment.show(fm, TAG);
|
fragment.show(fm, TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
|
||||||
|
|
||||||
private List<Object> prepareDuplicates() {
|
private List<Object> prepareDuplicates() {
|
||||||
List<? super Object> duplicates = new ArrayList<>();
|
List<? super Object> duplicates = new ArrayList<>();
|
||||||
List<ApplicationMode> profiles = new ArrayList<>();
|
List<ApplicationMode.ApplicationModeBean> profiles = new ArrayList<>();
|
||||||
List<QuickAction> actions = new ArrayList<>();
|
List<QuickAction> actions = new ArrayList<>();
|
||||||
List<PoiUIFilter> filters = new ArrayList<>();
|
List<PoiUIFilter> filters = new ArrayList<>();
|
||||||
List<ITileSource> tileSources = new ArrayList<>();
|
List<ITileSource> tileSources = new ArrayList<>();
|
||||||
|
@ -98,8 +99,8 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
|
||||||
List<File> routingFilesList = new ArrayList<>();
|
List<File> routingFilesList = new ArrayList<>();
|
||||||
|
|
||||||
for (Object object : duplicatesList) {
|
for (Object object : duplicatesList) {
|
||||||
if (object instanceof ApplicationMode) {
|
if (object instanceof ApplicationMode.ApplicationModeBean) {
|
||||||
profiles.add((ApplicationMode) object);
|
profiles.add((ApplicationMode.ApplicationModeBean) object);
|
||||||
} else if (object instanceof QuickAction) {
|
} else if (object instanceof QuickAction) {
|
||||||
actions.add((QuickAction) object);
|
actions.add((QuickAction) object);
|
||||||
} else if (object instanceof PoiUIFilter) {
|
} else if (object instanceof PoiUIFilter) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue