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"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
||||
<include
|
||||
android:id="@+id/description_divider"
|
||||
layout="@layout/card_bottom_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
<include layout="@layout/card_bottom_divider" />
|
||||
|
||||
<ExpandableListView
|
||||
android:id="@+id/list"
|
||||
|
@ -66,6 +62,8 @@
|
|||
android:groupIndicator="@android:color/transparent"
|
||||
android:listSelector="@android:color/transparent" />
|
||||
|
||||
<include layout="@layout/card_top_divider" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttons_container"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -49,9 +49,7 @@
|
|||
|
||||
<include
|
||||
android:id="@+id/description_divider"
|
||||
layout="@layout/card_bottom_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
layout="@layout/card_bottom_divider" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
|
@ -59,6 +57,9 @@
|
|||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<include
|
||||
layout="@layout/card_top_divider" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="shared_sting_preparing">Preparing</string>
|
||||
<string name="shared_sting_poi_types">POI types</string>
|
||||
<string name="shared_sting_nothing_selected">Nothing selected</string>
|
||||
<string name="shared_sting_quick_actions">Quick actions</string>
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -23,6 +24,7 @@ import net.osmand.plus.ApplicationMode.ApplicationModeBuilder;
|
|||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.profiles.ProfileIcons;
|
||||
import net.osmand.plus.quickaction.QuickAction;
|
||||
import net.osmand.plus.quickaction.QuickActionFactory;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -520,15 +522,30 @@ public class SettingsHelper {
|
|||
|
||||
@Override
|
||||
public void apply() {
|
||||
if (appMode.isCustomProfile()) {
|
||||
if (!shouldReplace && exists()) {
|
||||
if (!appMode.isCustomProfile() && !shouldReplace) {
|
||||
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();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void writeToJson(@NonNull JSONObject json) throws JSONException {
|
||||
|
@ -1809,6 +1826,7 @@ public class SettingsHelper {
|
|||
private SettingsExporter exporter;
|
||||
private File file;
|
||||
private SettingsExportListener listener;
|
||||
private ProgressDialog progress;
|
||||
|
||||
ExportAsyncTask(@NonNull File settingsFile,
|
||||
@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
|
||||
protected Boolean doInBackground(Void... voids) {
|
||||
try {
|
||||
|
@ -1836,6 +1860,7 @@ public class SettingsHelper {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean success) {
|
||||
progress.dismiss();
|
||||
if (listener != null) {
|
||||
listener.onSettingsExportFinished(file, success);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -9,13 +8,16 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.profiles.ProfileIconColors;
|
||||
import net.osmand.plus.quickaction.QuickAction;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
|
@ -59,46 +61,54 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
|
|||
(String) currentItem));
|
||||
((HeaderViewHolder) holder).divider.setVisibility(View.VISIBLE);
|
||||
} else if (holder instanceof ItemViewHolder) {
|
||||
String title = null;
|
||||
String subTitle = null;
|
||||
Drawable drawable = null;
|
||||
if (currentItem instanceof ApplicationMode) {
|
||||
title = ((ApplicationMode) currentItem).toHumanString();
|
||||
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);
|
||||
if (currentItem instanceof ApplicationMode.ApplicationModeBean) {
|
||||
String profileName = ((ApplicationMode.ApplicationModeBean) currentItem).userProfileName;
|
||||
if (Algorithms.isEmpty(profileName)) {
|
||||
ApplicationMode appMode = ApplicationMode.valueOfStringKey(((ApplicationMode.ApplicationModeBean) currentItem).stringKey, null);
|
||||
profileName = app.getString(appMode.getNameKeyResource());
|
||||
}
|
||||
}
|
||||
((ItemViewHolder) holder).title.setText(title != null ? title : "");
|
||||
if (subTitle != null) {
|
||||
((ItemViewHolder) holder).subTitle.setText(subTitle);
|
||||
((ItemViewHolder) holder).subTitle.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
((ItemViewHolder) holder).title.setText(profileName);
|
||||
String routingProfile = (((ApplicationMode.ApplicationModeBean) currentItem).routingProfile);
|
||||
if (Algorithms.isEmpty(routingProfile)) {
|
||||
((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) {
|
||||
((ItemViewHolder) holder).icon.setImageDrawable(drawable);
|
||||
((ItemViewHolder) holder).icon.setImageResource(View.VISIBLE);
|
||||
int profileIconRes = AndroidUtils.getDrawableId(app, ((ApplicationMode.ApplicationModeBean) currentItem).iconName);
|
||||
ProfileIconColors iconColor = ((ApplicationMode.ApplicationModeBean) currentItem).iconColor;
|
||||
((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 {
|
||||
((ItemViewHolder) holder).icon.setImageResource(R.drawable.ic_action_info_dark);
|
||||
((ItemViewHolder) holder).icon.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
((ItemViewHolder) holder).subTitle.setVisibility(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.quickaction.QuickAction;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -147,12 +148,25 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
|
||||
switch (type) {
|
||||
case PROFILE:
|
||||
title.setText(((ApplicationMode.ApplicationModeBean) currentItem).userProfileName);
|
||||
subText.setText(((ApplicationMode.ApplicationModeBean) currentItem).routingProfile);
|
||||
String profileName = ((ApplicationMode.ApplicationModeBean) currentItem).userProfileName;
|
||||
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);
|
||||
ProfileIconColors iconColor = ((ApplicationMode.ApplicationModeBean) currentItem).iconColor;
|
||||
icon.setImageDrawable(app.getUIUtilities().getIcon(profileIconRes, iconColor.getColor(nightMode)));
|
||||
subText.setVisibility(View.VISIBLE);
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case QUICK_ACTIONS:
|
||||
|
|
|
@ -45,6 +45,7 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
|
|||
fragment.setDuplicatesList(duplicatesList);
|
||||
fragment.setSettingsItems(settingsItems);
|
||||
fragment.setFile(file);
|
||||
fragment.setRetainInstance(true);
|
||||
fragment.show(fm, TAG);
|
||||
}
|
||||
|
||||
|
@ -90,7 +91,7 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
|
|||
|
||||
private List<Object> prepareDuplicates() {
|
||||
List<? super Object> duplicates = new ArrayList<>();
|
||||
List<ApplicationMode> profiles = new ArrayList<>();
|
||||
List<ApplicationMode.ApplicationModeBean> profiles = new ArrayList<>();
|
||||
List<QuickAction> actions = new ArrayList<>();
|
||||
List<PoiUIFilter> filters = new ArrayList<>();
|
||||
List<ITileSource> tileSources = new ArrayList<>();
|
||||
|
@ -98,8 +99,8 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
|
|||
List<File> routingFilesList = new ArrayList<>();
|
||||
|
||||
for (Object object : duplicatesList) {
|
||||
if (object instanceof ApplicationMode) {
|
||||
profiles.add((ApplicationMode) object);
|
||||
if (object instanceof ApplicationMode.ApplicationModeBean) {
|
||||
profiles.add((ApplicationMode.ApplicationModeBean) object);
|
||||
} else if (object instanceof QuickAction) {
|
||||
actions.add((QuickAction) object);
|
||||
} else if (object instanceof PoiUIFilter) {
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue