wip
This commit is contained in:
parent
ee4c34ac09
commit
ab77ea143c
5 changed files with 121 additions and 75 deletions
|
@ -22,9 +22,10 @@
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/title_tv"
|
android:id="@+id/title_tv"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:textAppearance="@style/TextAppearance.ListItemCategoryTitle"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
tools:text="Quick actions" />
|
tools:text="Quick actions" />
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatCheckBox
|
<android.support.v7.widget.AppCompatCheckBox
|
||||||
|
@ -41,7 +42,7 @@
|
||||||
android:id="@+id/divider"
|
android:id="@+id/divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="?attr/divider_color_basic"
|
android:background="?attr/list_divider"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_vertical"
|
||||||
android:minHeight="66dp"
|
android:minHeight="66dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
@ -30,14 +30,14 @@
|
||||||
android:id="@+id/title_tv"
|
android:id="@+id/title_tv"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="@style/TextAppearance.ListItemCategoryTitle"
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
tools:text="Quick actions" />
|
tools:text="Quick actions" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/sub_text_tv"
|
android:id="@+id/sub_text_tv"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
|
||||||
android:textColor="?android:textColorSecondary"
|
android:textColor="?android:textColorSecondary"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
tools:text="8 of 4" />
|
tools:text="8 of 4" />
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="@dimen/content_padding"
|
android:layout_marginTop="@dimen/content_padding"
|
||||||
android:layout_marginBottom="@dimen/content_padding"
|
android:layout_marginBottom="@dimen/content_padding"
|
||||||
android:background="?attr/divider_color_basic" />
|
android:background="?attr/list_divider" />
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatCheckBox
|
<android.support.v7.widget.AppCompatCheckBox
|
||||||
android:id="@+id/check_box"
|
android:id="@+id/check_box"
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
android:id="@+id/divider"
|
android:id="@+id/divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="?attr/divider_color_basic"
|
android:background="?attr/list_divider"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,6 @@ public class AdditionalDataWrapper {
|
||||||
POI_TYPES,
|
POI_TYPES,
|
||||||
MAP_SOURCES,
|
MAP_SOURCES,
|
||||||
CUSTOM_RENDER_STYLE,
|
CUSTOM_RENDER_STYLE,
|
||||||
ROUTING
|
CUSTOM_ROUTING
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.widget.CompoundButtonCompat;
|
import android.support.v4.widget.CompoundButtonCompat;
|
||||||
import android.support.v4.widget.NestedScrollView;
|
|
||||||
import android.support.v7.widget.SwitchCompat;
|
import android.support.v7.widget.SwitchCompat;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -21,7 +20,6 @@ import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ExpandableListView;
|
import android.widget.ExpandableListView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -31,7 +29,6 @@ import net.osmand.PlatformUtil;
|
||||||
import net.osmand.map.TileSourceManager;
|
import net.osmand.map.TileSourceManager;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.SettingsHelper;
|
import net.osmand.plus.SettingsHelper;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
|
@ -52,6 +49,7 @@ import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -64,30 +62,26 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
|
|
||||||
private static final String STATE_KEY = "EXPORT_IMPORT_DIALOG_STATE_KEY";
|
private static final String STATE_KEY = "EXPORT_IMPORT_DIALOG_STATE_KEY";
|
||||||
|
|
||||||
private OsmandApplication app;
|
|
||||||
|
|
||||||
private Context context;
|
|
||||||
|
|
||||||
private OsmandSettings settings;
|
|
||||||
|
|
||||||
private ApplicationMode profile;
|
|
||||||
|
|
||||||
private boolean includeAdditionalData = false;
|
private boolean includeAdditionalData = false;
|
||||||
|
|
||||||
private boolean containsAdditionalData = false;
|
private boolean containsAdditionalData = false;
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
|
||||||
|
private ApplicationMode profile;
|
||||||
|
|
||||||
private State state;
|
private State state;
|
||||||
|
|
||||||
private List<AdditionalDataWrapper> dataList = new ArrayList<>();
|
private List<AdditionalDataWrapper> dataList = new ArrayList<>();
|
||||||
|
|
||||||
private ExpandableListView listView;
|
|
||||||
|
|
||||||
private ProfileAdditionalDataAdapter adapter;
|
|
||||||
|
|
||||||
private List<? super Object> dataToOperate = new ArrayList<>();
|
private List<? super Object> dataToOperate = new ArrayList<>();
|
||||||
|
|
||||||
private List<SettingsHelper.SettingsItem> settingsItems;
|
private List<SettingsHelper.SettingsItem> settingsItems;
|
||||||
|
|
||||||
|
private ExpandableListView listView;
|
||||||
|
|
||||||
|
private ProfileAdditionalDataAdapter adapter;
|
||||||
|
|
||||||
private SettingsHelper.ProfileSettingsItem profileSettingsItem;
|
private SettingsHelper.ProfileSettingsItem profileSettingsItem;
|
||||||
|
|
||||||
private File file;
|
private File file;
|
||||||
|
@ -96,8 +90,6 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
app = requiredMyApplication();
|
app = requiredMyApplication();
|
||||||
context = requireContext();
|
|
||||||
settings = app.getSettings();
|
|
||||||
Bundle bundle = getArguments();
|
Bundle bundle = getArguments();
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
this.state = (State) getArguments().getSerializable(STATE_KEY);
|
this.state = (State) getArguments().getSerializable(STATE_KEY);
|
||||||
|
@ -118,8 +110,9 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
|
||||||
|
|
||||||
profile = state == State.IMPORT ? getAppModeFromItems() : getAppMode();
|
profile = state == State.IMPORT ? getAppModeFromSettingsItems() : getAppMode();
|
||||||
|
|
||||||
int profileColor = profile.getIconColorInfo().getColor(nightMode);
|
int profileColor = profile.getIconColorInfo().getColor(nightMode);
|
||||||
int colorNoAlpha = ContextCompat.getColor(context, profileColor);
|
int colorNoAlpha = ContextCompat.getColor(context, profileColor);
|
||||||
|
@ -152,9 +145,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
.create();
|
.create();
|
||||||
items.add(descriptionItem);
|
items.add(descriptionItem);
|
||||||
|
|
||||||
|
final View additionalDataView = inflater.inflate(R.layout.bottom_sheet_item_additional_data, null);
|
||||||
final View additionalDataView = View.inflate(new ContextThemeWrapper(context, themeRes),
|
|
||||||
R.layout.bottom_sheet_item_additional_data, null);
|
|
||||||
listView = additionalDataView.findViewById(R.id.list);
|
listView = additionalDataView.findViewById(R.id.list);
|
||||||
SwitchCompat switchItem = additionalDataView.findViewById(R.id.switchItem);
|
SwitchCompat switchItem = additionalDataView.findViewById(R.id.switchItem);
|
||||||
switchItem.setTextColor(getResources().getColor(nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light));
|
switchItem.setTextColor(getResources().getColor(nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light));
|
||||||
|
@ -166,7 +157,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
listView.setVisibility(includeAdditionalData ?
|
listView.setVisibility(includeAdditionalData ?
|
||||||
View.VISIBLE : View.GONE);
|
View.VISIBLE : View.GONE);
|
||||||
if (includeAdditionalData && state == State.IMPORT) {
|
if (includeAdditionalData && state == State.IMPORT) {
|
||||||
updateDataFromSettingsItems();
|
updateDataToOperateFromSettingsItems();
|
||||||
}
|
}
|
||||||
setupHeightAndBackground(getView());
|
setupHeightAndBackground(getView());
|
||||||
}
|
}
|
||||||
|
@ -212,7 +203,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApplicationMode getAppModeFromItems() {
|
private ApplicationMode getAppModeFromSettingsItems() {
|
||||||
for (SettingsHelper.SettingsItem item : settingsItems) {
|
for (SettingsHelper.SettingsItem item : settingsItems) {
|
||||||
if (item.getType().equals(SettingsHelper.SettingsItemType.PROFILE)) {
|
if (item.getType().equals(SettingsHelper.SettingsItemType.PROFILE)) {
|
||||||
profileSettingsItem = ((SettingsHelper.ProfileSettingsItem) item);
|
profileSettingsItem = ((SettingsHelper.ProfileSettingsItem) item);
|
||||||
|
@ -226,10 +217,10 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
List<AdditionalDataWrapper> dataList = new ArrayList<>();
|
List<AdditionalDataWrapper> dataList = new ArrayList<>();
|
||||||
|
|
||||||
QuickActionFactory factory = new QuickActionFactory();
|
QuickActionFactory factory = new QuickActionFactory();
|
||||||
List<QuickAction> quickActions = factory.parseActiveActionsList(settings.QUICK_ACTION_LIST.get());
|
List<QuickAction> actionsList = factory.parseActiveActionsList(app.getSettings().QUICK_ACTION_LIST.get());
|
||||||
if (!quickActions.isEmpty()) {
|
if (!actionsList.isEmpty()) {
|
||||||
dataList.add(new AdditionalDataWrapper(
|
dataList.add(new AdditionalDataWrapper(
|
||||||
AdditionalDataWrapper.Type.QUICK_ACTIONS, quickActions));
|
AdditionalDataWrapper.Type.QUICK_ACTIONS, actionsList));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PoiUIFilter> poiList = app.getPoiFilters().getUserDefinedPoiFilters(false);
|
List<PoiUIFilter> poiList = app.getPoiFilters().getUserDefinedPoiFilters(false);
|
||||||
|
@ -240,29 +231,49 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<TileSourceManager.TileSourceTemplate> mapSourceWrapperList = new ArrayList<>();
|
List<TileSourceManager.TileSourceTemplate> tileSourceTemplates = new ArrayList<>();
|
||||||
final LinkedHashMap<String, String> entriesMap = new LinkedHashMap<>(settings.getTileSourceEntries(false));
|
final LinkedHashMap<String, String> tileSourceEntries = new LinkedHashMap<>(app.getSettings().getTileSourceEntries(false));
|
||||||
for (Map.Entry<String, String> entry : entriesMap.entrySet()) {
|
for (Map.Entry<String, String> entry : tileSourceEntries.entrySet()) {
|
||||||
File f = app.getAppPath(IndexConstants.TILES_INDEX_DIR + entry.getKey());
|
File f = app.getAppPath(IndexConstants.TILES_INDEX_DIR + entry.getKey());
|
||||||
|
if (f != null) {
|
||||||
TileSourceManager.TileSourceTemplate template = TileSourceManager.createTileSourceTemplate(f);
|
TileSourceManager.TileSourceTemplate template = TileSourceManager.createTileSourceTemplate(f);
|
||||||
if (template != null) {
|
if (template != null) {
|
||||||
mapSourceWrapperList.add(template);
|
tileSourceTemplates.add(template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mapSourceWrapperList.isEmpty()) {
|
}
|
||||||
|
if (!tileSourceTemplates.isEmpty()) {
|
||||||
dataList.add(new AdditionalDataWrapper(
|
dataList.add(new AdditionalDataWrapper(
|
||||||
AdditionalDataWrapper.Type.MAP_SOURCES,
|
AdditionalDataWrapper.Type.MAP_SOURCES,
|
||||||
mapSourceWrapperList
|
tileSourceTemplates
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, File> externalRenderers = app.getRendererRegistry().getExternalRenderers();
|
||||||
|
if (!externalRenderers.isEmpty()) {
|
||||||
|
dataList.add(new AdditionalDataWrapper(
|
||||||
|
AdditionalDataWrapper.Type.CUSTOM_RENDER_STYLE,
|
||||||
|
new ArrayList<>(externalRenderers.values())
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
File routingProfilesFolder = app.getAppPath(IndexConstants.ROUTING_PROFILES_DIR);
|
||||||
|
if (routingProfilesFolder.exists() && routingProfilesFolder.isDirectory()) {
|
||||||
|
File[] fl = routingProfilesFolder.listFiles();
|
||||||
|
if (fl != null && fl.length > 0) {
|
||||||
|
dataList.add(new AdditionalDataWrapper(
|
||||||
|
AdditionalDataWrapper.Type.CUSTOM_ROUTING,
|
||||||
|
Arrays.asList(fl)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return dataList;
|
return dataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SettingsHelper.SettingsItem> prepareSettingsItems() {
|
private List<SettingsHelper.SettingsItem> prepareSettingsItemsForExport() {
|
||||||
List<SettingsHelper.SettingsItem> settingsItems = new ArrayList<>();
|
List<SettingsHelper.SettingsItem> settingsItems = new ArrayList<>();
|
||||||
settingsItems.add(new SettingsHelper.ProfileSettingsItem(app.getSettings(), profile));
|
settingsItems.add(new SettingsHelper.ProfileSettingsItem(app.getSettings(), profile));
|
||||||
|
|
||||||
if (includeAdditionalData) {
|
if (includeAdditionalData) {
|
||||||
settingsItems.addAll(prepareAdditionalSettingsItems());
|
settingsItems.addAll(prepareAdditionalSettingsItems());
|
||||||
}
|
}
|
||||||
|
@ -273,14 +284,16 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
List<SettingsHelper.SettingsItem> settingsItems = new ArrayList<>();
|
List<SettingsHelper.SettingsItem> settingsItems = new ArrayList<>();
|
||||||
List<QuickAction> quickActions = new ArrayList<>();
|
List<QuickAction> quickActions = new ArrayList<>();
|
||||||
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
||||||
List<TileSourceManager.TileSourceTemplate> mapSourceWrappers = new ArrayList<>();
|
List<TileSourceManager.TileSourceTemplate> tileSourceTemplates = new ArrayList<>();
|
||||||
for (Object object : dataToOperate) {
|
for (Object object : dataToOperate) {
|
||||||
if (object instanceof QuickAction) {
|
if (object instanceof QuickAction) {
|
||||||
quickActions.add((QuickAction) object);
|
quickActions.add((QuickAction) object);
|
||||||
} else if (object instanceof PoiUIFilter) {
|
} else if (object instanceof PoiUIFilter) {
|
||||||
poiUIFilters.add((PoiUIFilter) object);
|
poiUIFilters.add((PoiUIFilter) object);
|
||||||
} else if (object instanceof TileSourceManager.TileSourceTemplate) {
|
} else if (object instanceof TileSourceManager.TileSourceTemplate) {
|
||||||
mapSourceWrappers.add((TileSourceManager.TileSourceTemplate) object);
|
tileSourceTemplates.add((TileSourceManager.TileSourceTemplate) object);
|
||||||
|
} else if (object instanceof File) {
|
||||||
|
settingsItems.add(new SettingsHelper.FileSettingsItem(app, (File) object));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!quickActions.isEmpty()) {
|
if (!quickActions.isEmpty()) {
|
||||||
|
@ -289,8 +302,8 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
if (!poiUIFilters.isEmpty()) {
|
if (!poiUIFilters.isEmpty()) {
|
||||||
settingsItems.add(new SettingsHelper.PoiUiFilterSettingsItem(app, poiUIFilters));
|
settingsItems.add(new SettingsHelper.PoiUiFilterSettingsItem(app, poiUIFilters));
|
||||||
}
|
}
|
||||||
if (!mapSourceWrappers.isEmpty()) {
|
if (!tileSourceTemplates.isEmpty()) {
|
||||||
settingsItems.add(new SettingsHelper.MapSourcesSettingsItem(app.getSettings(), mapSourceWrappers));
|
settingsItems.add(new SettingsHelper.MapSourcesSettingsItem(app.getSettings(), tileSourceTemplates));
|
||||||
}
|
}
|
||||||
return settingsItems;
|
return settingsItems;
|
||||||
}
|
}
|
||||||
|
@ -300,7 +313,8 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
for (SettingsHelper.SettingsItem item : settingsItems) {
|
for (SettingsHelper.SettingsItem item : settingsItems) {
|
||||||
containsData = item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION)
|
containsData = item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION)
|
||||||
|| item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS)
|
|| item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS)
|
||||||
|| item.getType().equals(SettingsHelper.SettingsItemType.MAP_SOURCES);
|
|| item.getType().equals(SettingsHelper.SettingsItemType.MAP_SOURCES)
|
||||||
|
|| item.getType().equals(SettingsHelper.SettingsItemType.FILE);
|
||||||
if (containsData) {
|
if (containsData) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -308,38 +322,62 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
return containsData;
|
return containsData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDataFromSettingsItems() {
|
private void updateDataToOperateFromSettingsItems() {
|
||||||
List<AdditionalDataWrapper> dataList = new ArrayList<>();
|
List<AdditionalDataWrapper> dataList = new ArrayList<>();
|
||||||
List<QuickAction> quickActions = new ArrayList<>();
|
List<QuickAction> quickActions = new ArrayList<>();
|
||||||
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
||||||
List<TileSourceManager.TileSourceTemplate> mapSourceWrappers = new ArrayList<>();
|
List<TileSourceManager.TileSourceTemplate> tileSourceTemplates = new ArrayList<>();
|
||||||
|
List<File> routingFilesList = new ArrayList<>();
|
||||||
|
List<File> renderFilesList = new ArrayList<>();
|
||||||
|
|
||||||
for (SettingsHelper.SettingsItem item : settingsItems) {
|
for (SettingsHelper.SettingsItem item : settingsItems) {
|
||||||
if (item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION)) {
|
if (item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION)) {
|
||||||
quickActions.addAll(((SettingsHelper.QuickActionSettingsItem) item).getQuickActions());
|
quickActions.addAll(((SettingsHelper.QuickActionSettingsItem) item).getQuickActions());
|
||||||
} else if (item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS)) {
|
} else if (item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS)) {
|
||||||
poiUIFilters.addAll(((SettingsHelper.PoiUiFilterSettingsItem) item).getPoiUIFilters());
|
poiUIFilters.addAll(((SettingsHelper.PoiUiFilterSettingsItem) item).getPoiUIFilters());
|
||||||
} else if (item.getType().equals(SettingsHelper.SettingsItemType.MAP_SOURCES)) {
|
} else if (item.getType().equals(SettingsHelper.SettingsItemType.MAP_SOURCES)) {
|
||||||
mapSourceWrappers.addAll(((SettingsHelper.MapSourcesSettingsItem) item).getMapSources());
|
tileSourceTemplates.addAll(((SettingsHelper.MapSourcesSettingsItem) item).getMapSources());
|
||||||
|
} else if (item.getType().equals(SettingsHelper.SettingsItemType.FILE)) {
|
||||||
|
if (item.getName().startsWith("/rendering/")) {
|
||||||
|
renderFilesList.add(((SettingsHelper.FileSettingsItem) item).getFile());
|
||||||
|
} else if (item.getName().startsWith("/routing/")) {
|
||||||
|
routingFilesList.add(((SettingsHelper.FileSettingsItem) item).getFile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!quickActions.isEmpty()) {
|
if (!quickActions.isEmpty()) {
|
||||||
dataList.add(new AdditionalDataWrapper(
|
dataList.add(new AdditionalDataWrapper(
|
||||||
AdditionalDataWrapper.Type.QUICK_ACTIONS,
|
AdditionalDataWrapper.Type.QUICK_ACTIONS,
|
||||||
quickActions));
|
quickActions));
|
||||||
|
dataToOperate.addAll(quickActions);
|
||||||
}
|
}
|
||||||
if (!poiUIFilters.isEmpty()) {
|
if (!poiUIFilters.isEmpty()) {
|
||||||
dataList.add(new AdditionalDataWrapper(
|
dataList.add(new AdditionalDataWrapper(
|
||||||
AdditionalDataWrapper.Type.POI_TYPES,
|
AdditionalDataWrapper.Type.POI_TYPES,
|
||||||
poiUIFilters));
|
poiUIFilters));
|
||||||
|
dataToOperate.addAll(poiUIFilters);
|
||||||
}
|
}
|
||||||
if (!mapSourceWrappers.isEmpty()) {
|
if (!tileSourceTemplates.isEmpty()) {
|
||||||
dataList.add(new AdditionalDataWrapper(
|
dataList.add(new AdditionalDataWrapper(
|
||||||
AdditionalDataWrapper.Type.MAP_SOURCES,
|
AdditionalDataWrapper.Type.MAP_SOURCES,
|
||||||
mapSourceWrappers
|
tileSourceTemplates
|
||||||
));
|
));
|
||||||
|
dataToOperate.addAll(tileSourceTemplates);
|
||||||
}
|
}
|
||||||
for (AdditionalDataWrapper dataWrapper : dataList) {
|
if (!renderFilesList.isEmpty()) {
|
||||||
dataToOperate.addAll(dataWrapper.getItems());
|
dataList.add(new AdditionalDataWrapper(
|
||||||
|
AdditionalDataWrapper.Type.CUSTOM_RENDER_STYLE,
|
||||||
|
renderFilesList
|
||||||
|
));
|
||||||
|
dataToOperate.addAll(renderFilesList);
|
||||||
|
}
|
||||||
|
if (!routingFilesList.isEmpty()) {
|
||||||
|
dataList.add(new AdditionalDataWrapper(
|
||||||
|
AdditionalDataWrapper.Type.CUSTOM_ROUTING,
|
||||||
|
routingFilesList
|
||||||
|
));
|
||||||
|
dataToOperate.addAll(routingFilesList);
|
||||||
}
|
}
|
||||||
adapter.updateList(dataList);
|
adapter.updateList(dataList);
|
||||||
}
|
}
|
||||||
|
@ -375,13 +413,12 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
app.showToastMessage(R.string.export_profile_failed);
|
app.showToastMessage(R.string.export_profile_failed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, prepareSettingsItems());
|
}, prepareSettingsItemsForExport());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void shareProfile(@NonNull File file, @NonNull ApplicationMode profile) {
|
private void shareProfile(@NonNull File file, @NonNull ApplicationMode profile) {
|
||||||
try {
|
try {
|
||||||
Context ctx = requireContext();
|
|
||||||
final Intent sendIntent = new Intent();
|
final Intent sendIntent = new Intent();
|
||||||
sendIntent.setAction(Intent.ACTION_SEND);
|
sendIntent.setAction(Intent.ACTION_SEND);
|
||||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.exported_osmand_profile, profile.toHumanString()));
|
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.exported_osmand_profile, profile.toHumanString()));
|
||||||
|
@ -391,7 +428,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
startActivity(sendIntent);
|
startActivity(sendIntent);
|
||||||
dismiss();
|
dismiss();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Toast.makeText(context, R.string.export_profile_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(requireContext(), R.string.export_profile_failed, Toast.LENGTH_SHORT).show();
|
||||||
LOG.error("Share profile error", e);
|
LOG.error("Share profile error", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -444,17 +481,6 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isContainsInDataToOperate(AdditionalDataWrapper.Type type, Object object) {
|
|
||||||
return dataToOperate.contains(object);
|
|
||||||
|
|
||||||
// for (AdditionalDataWrapper data : dataList) {
|
|
||||||
// if (data.getType() == type) {
|
|
||||||
// return data.getItems().contains(object);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
EXPORT,
|
EXPORT,
|
||||||
IMPORT
|
IMPORT
|
||||||
|
@ -518,7 +544,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
||||||
View group = convertView;
|
View group = convertView;
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
|
||||||
group = inflater.inflate(R.layout.profile_data_list_item_group, parent, false);
|
group = inflater.inflate(R.layout.profile_data_list_item_group, parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,7 +571,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
|
|
||||||
if (checkBox.isChecked()) {
|
if (checkBox.isChecked()) {
|
||||||
for (Object object : listItems) {
|
for (Object object : listItems) {
|
||||||
if (!isContainsInDataToOperate(type, object)) {
|
if (!dataToOperate.contains(object)) {
|
||||||
dataToOperate.add(object);
|
dataToOperate.add(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -565,7 +591,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
||||||
View child = convertView;
|
View child = convertView;
|
||||||
if (child == null) {
|
if (child == null) {
|
||||||
LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
|
||||||
child = inflater.inflate(R.layout.profile_data_list_item_child, parent, false);
|
child = inflater.inflate(R.layout.profile_data_list_item_child, parent, false);
|
||||||
}
|
}
|
||||||
final Object currentItem = list.get(groupPosition).getItems().get(childPosition);
|
final Object currentItem = list.get(groupPosition).getItems().get(childPosition);
|
||||||
|
@ -582,7 +608,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
divider.setVisibility(isLastChild && !isLastGroup ? View.VISIBLE : View.GONE);
|
divider.setVisibility(isLastChild && !isLastGroup ? View.VISIBLE : View.GONE);
|
||||||
CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, profileColor)));
|
CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, profileColor)));
|
||||||
|
|
||||||
checkBox.setChecked(isContainsInDataToOperate(type, currentItem));
|
checkBox.setChecked(dataToOperate.contains(currentItem));
|
||||||
checkBox.setOnClickListener(new View.OnClickListener() {
|
checkBox.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -591,6 +617,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
} else {
|
} else {
|
||||||
dataToOperate.remove(currentItem);
|
dataToOperate.remove(currentItem);
|
||||||
}
|
}
|
||||||
|
notifyDataSetInvalidated();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -611,6 +638,20 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
icon.setVisibility(View.INVISIBLE);
|
icon.setVisibility(View.INVISIBLE);
|
||||||
icon.setImageResource(R.drawable.ic_action_info_dark);
|
icon.setImageResource(R.drawable.ic_action_info_dark);
|
||||||
break;
|
break;
|
||||||
|
case CUSTOM_RENDER_STYLE:
|
||||||
|
String renderName = ((File) currentItem).getName();
|
||||||
|
renderName = renderName.replace('_', ' ').replaceAll(".render.xml", "");
|
||||||
|
title.setText(renderName);
|
||||||
|
icon.setVisibility(View.INVISIBLE);
|
||||||
|
icon.setImageResource(R.drawable.ic_action_info_dark);
|
||||||
|
break;
|
||||||
|
case CUSTOM_ROUTING:
|
||||||
|
String routingName = ((File) currentItem).getName();
|
||||||
|
routingName = routingName.replace('_', ' ').replaceAll(".xml", "");
|
||||||
|
title.setText(routingName);
|
||||||
|
icon.setVisibility(View.INVISIBLE);
|
||||||
|
icon.setImageResource(R.drawable.ic_action_info_dark);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
@ -632,7 +673,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
return R.string.quick_action_map_source_title;
|
return R.string.quick_action_map_source_title;
|
||||||
case CUSTOM_RENDER_STYLE:
|
case CUSTOM_RENDER_STYLE:
|
||||||
return R.string.shared_string_custom_rendering_style;
|
return R.string.shared_string_custom_rendering_style;
|
||||||
case ROUTING:
|
case CUSTOM_ROUTING:
|
||||||
return R.string.shared_string_routing;
|
return R.string.shared_string_routing;
|
||||||
default:
|
default:
|
||||||
return R.string.access_empty_list;
|
return R.string.access_empty_list;
|
||||||
|
|
|
@ -343,4 +343,8 @@ public class RendererRegistry {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, File> getExternalRenderers() {
|
||||||
|
return externalRenderers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue