Merge pull request #10235 from osmandapp/markers_export_fixes
Export/Import: Subitems Bottom Sheet
This commit is contained in:
commit
62eb37cb34
14 changed files with 623 additions and 188 deletions
108
OsmAnd/res/layout/settings_group_title.xml
Normal file
108
OsmAnd/res/layout/settings_group_title.xml
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="@dimen/bottom_sheet_title_height"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingTop="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/wikilink_bottom_sheet_padding"
|
||||||
|
android:paddingBottom="@dimen/wikilink_bottom_sheet_padding">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:minHeight="@dimen/default_title_line_height"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
app:lineHeight="@dimen/default_title_line_height"
|
||||||
|
app:typeface="@string/font_roboto_medium"
|
||||||
|
tools:text="Some title" />
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/description"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:letterSpacing="@dimen/description_letter_spacing"
|
||||||
|
android:minHeight="@dimen/default_desc_line_height"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
app:lineHeight="@dimen/default_desc_line_height"
|
||||||
|
app:typeface="@string/font_roboto_regular"
|
||||||
|
tools:text="Some description" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/selected_size"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:minHeight="@dimen/default_title_line_height"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
app:lineHeight="@dimen/default_title_line_height"
|
||||||
|
app:typeface="@string/font_roboto_regular"
|
||||||
|
tools:text="5/6" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/select_all_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingTop="@dimen/content_padding_small"
|
||||||
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:paddingBottom="@dimen/content_padding_small">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:minHeight="@dimen/default_title_line_height"
|
||||||
|
android:text="@string/shared_string_select_all"
|
||||||
|
android:textColor="?attr/active_color_basic"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
app:lineHeight="@dimen/default_title_line_height"
|
||||||
|
app:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
|
<net.osmand.view.ThreeStateCheckbox
|
||||||
|
android:id="@+id/check_box"
|
||||||
|
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
|
||||||
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:clickable="false"
|
||||||
|
android:enabled="false"
|
||||||
|
android:focusable="false" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -11,6 +11,8 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="select_items_for_import">Select items that will be imported.</string>
|
||||||
|
<string name="select_groups_for_import">Select groups that will be imported.</string>
|
||||||
<string name="export_not_enough_space">There is not enough space</string>
|
<string name="export_not_enough_space">There is not enough space</string>
|
||||||
<string name="export_not_enough_space_descr">Your device only has %1$s free. Please free up some space or unselect some items to export.</string>
|
<string name="export_not_enough_space_descr">Your device only has %1$s free. Please free up some space or unselect some items to export.</string>
|
||||||
<string name="file_size_needed_for_import">Needed for import</string>
|
<string name="file_size_needed_for_import">Needed for import</string>
|
||||||
|
|
|
@ -1083,6 +1083,7 @@ public class MapMarkersHelper {
|
||||||
String creationDateStr = point.getExtensionsToRead().get(CREATION_DATE);
|
String creationDateStr = point.getExtensionsToRead().get(CREATION_DATE);
|
||||||
marker.visitedDate = parseTime(visitedDateStr, format);
|
marker.visitedDate = parseTime(visitedDateStr, format);
|
||||||
marker.creationDate = parseTime(creationDateStr, format);
|
marker.creationDate = parseTime(creationDateStr, format);
|
||||||
|
marker.history = history;
|
||||||
marker.nextKey = history ? MapMarkersDbHelper.HISTORY_NEXT_VALUE : MapMarkersDbHelper.TAIL_NEXT_VALUE;
|
marker.nextKey = history ? MapMarkersDbHelper.HISTORY_NEXT_VALUE : MapMarkersDbHelper.TAIL_NEXT_VALUE;
|
||||||
|
|
||||||
mapMarkers.add(marker);
|
mapMarkers.add(marker);
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class HistoryMarkersSettingsItem extends CollectionSettingsItem<MapMarker
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MapMarker marker : appliedItems) {
|
for (MapMarker marker : appliedItems) {
|
||||||
markersHelper.moveMapMarkerToHistory(marker);
|
markersHelper.addMarker(marker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class HistoryMarkersSettingsItem extends CollectionSettingsItem<MapMarker
|
||||||
public boolean isDuplicate(@NonNull MapMarker mapMarker) {
|
public boolean isDuplicate(@NonNull MapMarker mapMarker) {
|
||||||
for (MapMarker marker : existingItems) {
|
for (MapMarker marker : existingItems) {
|
||||||
if (marker.equals(mapMarker)
|
if (marker.equals(mapMarker)
|
||||||
&& Algorithms.objectEquals(marker.getOriginalPointDescription(), mapMarker.getOriginalPointDescription())) {
|
&& Algorithms.objectEquals(marker.getOnlyName(), mapMarker.getOnlyName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,10 +114,13 @@ public class HistoryMarkersSettingsItem extends CollectionSettingsItem<MapMarker
|
||||||
int number = 0;
|
int number = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
number++;
|
number++;
|
||||||
String name = item.getOnlyName() + "_" + number;
|
String name = item.getOnlyName() + " " + number;
|
||||||
PointDescription description = new PointDescription(PointDescription.POINT_TYPE_LOCATION, name);
|
PointDescription description = new PointDescription(PointDescription.POINT_TYPE_LOCATION, name);
|
||||||
MapMarker renamedMarker = new MapMarker(item.point, description, item.getColor(), item.selected, item.index);
|
MapMarker renamedMarker = new MapMarker(item.point, description, item.colorIndex, item.selected, item.index);
|
||||||
if (!isDuplicate(renamedMarker)) {
|
if (!isDuplicate(renamedMarker)) {
|
||||||
|
renamedMarker.history = true;
|
||||||
|
renamedMarker.visitedDate = item.visitedDate;
|
||||||
|
renamedMarker.creationDate = item.creationDate;
|
||||||
renamedMarker.nextKey = MapMarkersDbHelper.HISTORY_NEXT_VALUE;
|
renamedMarker.nextKey = MapMarkersDbHelper.HISTORY_NEXT_VALUE;
|
||||||
return renamedMarker;
|
return renamedMarker;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class MarkersSettingsItem extends CollectionSettingsItem<MapMarker> {
|
||||||
public boolean isDuplicate(@NonNull MapMarker mapMarker) {
|
public boolean isDuplicate(@NonNull MapMarker mapMarker) {
|
||||||
for (MapMarker marker : existingItems) {
|
for (MapMarker marker : existingItems) {
|
||||||
if (marker.equals(mapMarker)
|
if (marker.equals(mapMarker)
|
||||||
&& Algorithms.objectEquals(marker.getOriginalPointDescription(), mapMarker.getOriginalPointDescription())) {
|
&& Algorithms.objectEquals(marker.getOnlyName(), mapMarker.getOnlyName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,10 +114,13 @@ public class MarkersSettingsItem extends CollectionSettingsItem<MapMarker> {
|
||||||
int number = 0;
|
int number = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
number++;
|
number++;
|
||||||
String name = item.getOnlyName() + "_" + number;
|
String name = item.getOnlyName() + " " + number;
|
||||||
PointDescription description = new PointDescription(PointDescription.POINT_TYPE_LOCATION, name);
|
PointDescription description = new PointDescription(PointDescription.POINT_TYPE_LOCATION, name);
|
||||||
MapMarker renamedMarker = new MapMarker(item.point, description, item.getColor(), item.selected, item.index);
|
MapMarker renamedMarker = new MapMarker(item.point, description, item.colorIndex, item.selected, item.index);
|
||||||
if (!isDuplicate(renamedMarker)) {
|
if (!isDuplicate(renamedMarker)) {
|
||||||
|
renamedMarker.history = false;
|
||||||
|
renamedMarker.visitedDate = item.visitedDate;
|
||||||
|
renamedMarker.creationDate = item.creationDate;
|
||||||
renamedMarker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE;
|
renamedMarker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE;
|
||||||
return renamedMarker;
|
return renamedMarker;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
||||||
import net.osmand.plus.settings.backend.ExportSettingsCategory;
|
import net.osmand.plus.settings.backend.ExportSettingsCategory;
|
||||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||||
import net.osmand.plus.settings.fragments.ExportDataObject;
|
import net.osmand.plus.settings.fragments.SettingsCategoryItems;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -472,13 +472,11 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SettingsItem> getFilteredSettingsItems(List<ExportSettingsType> settingsTypes, boolean globalExport) {
|
public List<SettingsItem> getFilteredSettingsItems(List<ExportSettingsType> settingsTypes, boolean globalExport) {
|
||||||
Map<ExportSettingsCategory, List<ExportDataObject>> dataList = getAdditionalData(globalExport);
|
|
||||||
Map<ExportSettingsType, List<?>> typesMap = new HashMap<>();
|
Map<ExportSettingsType, List<?>> typesMap = new HashMap<>();
|
||||||
for (List<ExportDataObject> objects : dataList.values()) {
|
typesMap.putAll(getSettingsItems(globalExport));
|
||||||
for (ExportDataObject exportObject : objects) {
|
typesMap.putAll(getMyPlacesItems());
|
||||||
typesMap.put(exportObject.getType(), exportObject.getItems());
|
typesMap.putAll(getResourcesItems());
|
||||||
}
|
|
||||||
}
|
|
||||||
return getFilteredSettingsItems(typesMap, settingsTypes);
|
return getFilteredSettingsItems(typesMap, settingsTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,67 +497,64 @@ public class SettingsHelper {
|
||||||
return settingsItems;
|
return settingsItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<ExportSettingsCategory, List<ExportDataObject>> getAdditionalData(boolean globalExport) {
|
public Map<ExportSettingsCategory, SettingsCategoryItems> getAdditionalData(boolean globalExport) {
|
||||||
Map<ExportSettingsCategory, List<ExportDataObject>> dataList = new LinkedHashMap<>();
|
Map<ExportSettingsCategory, SettingsCategoryItems> dataList = new LinkedHashMap<>();
|
||||||
|
|
||||||
List<ExportDataObject> settingsItems = getSettingsItems(globalExport);
|
Map<ExportSettingsType, List<?>> settingsItems = getSettingsItems(globalExport);
|
||||||
List<ExportDataObject> myPlacesItems = getMyPlacesItems();
|
Map<ExportSettingsType, List<?>> myPlacesItems = getMyPlacesItems();
|
||||||
List<ExportDataObject> resourcesItems = getResourcesItems();
|
Map<ExportSettingsType, List<?>> resourcesItems = getResourcesItems();
|
||||||
|
|
||||||
if (!settingsItems.isEmpty()) {
|
if (!settingsItems.isEmpty()) {
|
||||||
sortExportSettingsObjects(settingsItems);
|
dataList.put(ExportSettingsCategory.SETTINGS, new SettingsCategoryItems(settingsItems));
|
||||||
dataList.put(ExportSettingsCategory.SETTINGS, settingsItems);
|
|
||||||
}
|
}
|
||||||
if (!myPlacesItems.isEmpty()) {
|
if (!myPlacesItems.isEmpty()) {
|
||||||
sortExportSettingsObjects(myPlacesItems);
|
dataList.put(ExportSettingsCategory.MY_PLACES, new SettingsCategoryItems(myPlacesItems));
|
||||||
dataList.put(ExportSettingsCategory.MY_PLACES, myPlacesItems);
|
|
||||||
}
|
}
|
||||||
if (!resourcesItems.isEmpty()) {
|
if (!resourcesItems.isEmpty()) {
|
||||||
sortExportSettingsObjects(resourcesItems);
|
dataList.put(ExportSettingsCategory.RESOURCES, new SettingsCategoryItems(resourcesItems));
|
||||||
dataList.put(ExportSettingsCategory.RESOURCES, resourcesItems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dataList;
|
return dataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ExportDataObject> getSettingsItems(boolean globalExport) {
|
private Map<ExportSettingsType, List<?>> getSettingsItems(boolean globalExport) {
|
||||||
List<ExportDataObject> settingsItems = new ArrayList<>();
|
Map<ExportSettingsType, List<?>> settingsItems = new LinkedHashMap<>();
|
||||||
|
|
||||||
if (globalExport) {
|
if (globalExport) {
|
||||||
List<ApplicationModeBean> appModeBeans = new ArrayList<>();
|
List<ApplicationModeBean> appModeBeans = new ArrayList<>();
|
||||||
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
|
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
|
||||||
appModeBeans.add(mode.toModeBean());
|
appModeBeans.add(mode.toModeBean());
|
||||||
}
|
}
|
||||||
settingsItems.add(new ExportDataObject(ExportSettingsType.PROFILE, appModeBeans));
|
settingsItems.put(ExportSettingsType.PROFILE, appModeBeans);
|
||||||
}
|
}
|
||||||
settingsItems.add(new ExportDataObject(ExportSettingsType.GLOBAL, Collections.singletonList(new GlobalSettingsItem(app.getSettings()))));
|
settingsItems.put(ExportSettingsType.GLOBAL, Collections.singletonList(new GlobalSettingsItem(app.getSettings())));
|
||||||
|
|
||||||
QuickActionRegistry registry = app.getQuickActionRegistry();
|
QuickActionRegistry registry = app.getQuickActionRegistry();
|
||||||
List<QuickAction> actionsList = registry.getQuickActions();
|
List<QuickAction> actionsList = registry.getQuickActions();
|
||||||
if (!actionsList.isEmpty()) {
|
if (!actionsList.isEmpty()) {
|
||||||
settingsItems.add(new ExportDataObject(ExportSettingsType.QUICK_ACTIONS, actionsList));
|
settingsItems.put(ExportSettingsType.QUICK_ACTIONS, actionsList);
|
||||||
}
|
}
|
||||||
List<PoiUIFilter> poiList = app.getPoiFilters().getUserDefinedPoiFilters(false);
|
List<PoiUIFilter> poiList = app.getPoiFilters().getUserDefinedPoiFilters(false);
|
||||||
if (!poiList.isEmpty()) {
|
if (!poiList.isEmpty()) {
|
||||||
settingsItems.add(new ExportDataObject(ExportSettingsType.POI_TYPES, poiList));
|
settingsItems.put(ExportSettingsType.POI_TYPES, poiList);
|
||||||
}
|
}
|
||||||
List<HistoryEntry> historyEntries = SearchHistoryHelper.getInstance(app).getHistoryEntries(false);
|
List<HistoryEntry> historyEntries = SearchHistoryHelper.getInstance(app).getHistoryEntries(false);
|
||||||
if (!historyEntries.isEmpty()) {
|
if (!historyEntries.isEmpty()) {
|
||||||
settingsItems.add(new ExportDataObject(ExportSettingsType.SEARCH_HISTORY, historyEntries));
|
settingsItems.put(ExportSettingsType.SEARCH_HISTORY, historyEntries);
|
||||||
}
|
}
|
||||||
Map<LatLon, AvoidRoadInfo> impassableRoads = app.getAvoidSpecificRoads().getImpassableRoads();
|
Map<LatLon, AvoidRoadInfo> impassableRoads = app.getAvoidSpecificRoads().getImpassableRoads();
|
||||||
if (!impassableRoads.isEmpty()) {
|
if (!impassableRoads.isEmpty()) {
|
||||||
settingsItems.add(new ExportDataObject(ExportSettingsType.AVOID_ROADS, new ArrayList<>(impassableRoads.values())));
|
settingsItems.put(ExportSettingsType.AVOID_ROADS, new ArrayList<>(impassableRoads.values()));
|
||||||
}
|
}
|
||||||
return settingsItems;
|
return settingsItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ExportDataObject> getMyPlacesItems() {
|
private Map<ExportSettingsType, List<?>> getMyPlacesItems() {
|
||||||
List<ExportDataObject> myPlacesItems = new ArrayList<>();
|
Map<ExportSettingsType, List<?>> myPlacesItems = new LinkedHashMap<>();
|
||||||
|
|
||||||
List<FavoriteGroup> favoriteGroups = app.getFavorites().getFavoriteGroups();
|
List<FavoriteGroup> favoriteGroups = app.getFavorites().getFavoriteGroups();
|
||||||
if (!favoriteGroups.isEmpty()) {
|
if (!favoriteGroups.isEmpty()) {
|
||||||
myPlacesItems.add(new ExportDataObject(ExportSettingsType.FAVORITES, favoriteGroups));
|
myPlacesItems.put(ExportSettingsType.FAVORITES, favoriteGroups);
|
||||||
}
|
}
|
||||||
File gpxDir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
File gpxDir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||||
List<GPXInfo> gpxInfoList = GpxUiHelper.getSortedGPXFilesInfo(gpxDir, null, true);
|
List<GPXInfo> gpxInfoList = GpxUiHelper.getSortedGPXFilesInfo(gpxDir, null, true);
|
||||||
|
@ -572,18 +567,18 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!files.isEmpty()) {
|
if (!files.isEmpty()) {
|
||||||
myPlacesItems.add(new ExportDataObject(ExportSettingsType.TRACKS, files));
|
myPlacesItems.put(ExportSettingsType.TRACKS, files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
if (osmEditingPlugin != null) {
|
if (osmEditingPlugin != null) {
|
||||||
List<OsmNotesPoint> notesPointList = osmEditingPlugin.getDBBug().getOsmbugsPoints();
|
List<OsmNotesPoint> notesPointList = osmEditingPlugin.getDBBug().getOsmbugsPoints();
|
||||||
if (!notesPointList.isEmpty()) {
|
if (!notesPointList.isEmpty()) {
|
||||||
myPlacesItems.add(new ExportDataObject(ExportSettingsType.OSM_NOTES, notesPointList));
|
myPlacesItems.put(ExportSettingsType.OSM_NOTES, notesPointList);
|
||||||
}
|
}
|
||||||
List<OpenstreetmapPoint> editsPointList = osmEditingPlugin.getDBPOI().getOpenstreetmapPoints();
|
List<OpenstreetmapPoint> editsPointList = osmEditingPlugin.getDBPOI().getOpenstreetmapPoints();
|
||||||
if (!editsPointList.isEmpty()) {
|
if (!editsPointList.isEmpty()) {
|
||||||
myPlacesItems.add(new ExportDataObject(ExportSettingsType.OSM_EDITS, editsPointList));
|
myPlacesItems.put(ExportSettingsType.OSM_EDITS, editsPointList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
|
AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
|
||||||
|
@ -596,7 +591,7 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!files.isEmpty()) {
|
if (!files.isEmpty()) {
|
||||||
myPlacesItems.add(new ExportDataObject(ExportSettingsType.MULTIMEDIA_NOTES, files));
|
myPlacesItems.put(ExportSettingsType.MULTIMEDIA_NOTES, files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<MapMarker> mapMarkers = app.getMapMarkersHelper().getMapMarkersFromDefaultGroups(false);
|
List<MapMarker> mapMarkers = app.getMapMarkersHelper().getMapMarkersFromDefaultGroups(false);
|
||||||
|
@ -605,7 +600,7 @@ public class SettingsHelper {
|
||||||
String groupId = ExportSettingsType.ACTIVE_MARKERS.name();
|
String groupId = ExportSettingsType.ACTIVE_MARKERS.name();
|
||||||
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, MapMarkersGroup.ANY_TYPE);
|
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, MapMarkersGroup.ANY_TYPE);
|
||||||
markersGroup.setMarkers(mapMarkers);
|
markersGroup.setMarkers(mapMarkers);
|
||||||
myPlacesItems.add(new ExportDataObject(ExportSettingsType.ACTIVE_MARKERS, Collections.singletonList(markersGroup)));
|
myPlacesItems.put(ExportSettingsType.ACTIVE_MARKERS, Collections.singletonList(markersGroup));
|
||||||
}
|
}
|
||||||
List<MapMarker> markersHistory = app.getMapMarkersHelper().getMapMarkersFromDefaultGroups(true);
|
List<MapMarker> markersHistory = app.getMapMarkersHelper().getMapMarkersFromDefaultGroups(true);
|
||||||
if (!markersHistory.isEmpty()) {
|
if (!markersHistory.isEmpty()) {
|
||||||
|
@ -613,23 +608,23 @@ public class SettingsHelper {
|
||||||
String groupId = ExportSettingsType.HISTORY_MARKERS.name();
|
String groupId = ExportSettingsType.HISTORY_MARKERS.name();
|
||||||
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, MapMarkersGroup.ANY_TYPE);
|
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, MapMarkersGroup.ANY_TYPE);
|
||||||
markersGroup.setMarkers(markersHistory);
|
markersGroup.setMarkers(markersHistory);
|
||||||
myPlacesItems.add(new ExportDataObject(ExportSettingsType.HISTORY_MARKERS, Collections.singletonList(markersGroup)));
|
myPlacesItems.put(ExportSettingsType.HISTORY_MARKERS, Collections.singletonList(markersGroup));
|
||||||
}
|
}
|
||||||
return myPlacesItems;
|
return myPlacesItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ExportDataObject> getResourcesItems() {
|
private Map<ExportSettingsType, List<?>> getResourcesItems() {
|
||||||
List<ExportDataObject> resourcesItems = new ArrayList<>();
|
Map<ExportSettingsType, List<?>> resourcesItems = new LinkedHashMap<>();
|
||||||
|
|
||||||
Map<String, File> externalRenderers = app.getRendererRegistry().getExternalRenderers();
|
Map<String, File> externalRenderers = app.getRendererRegistry().getExternalRenderers();
|
||||||
if (!externalRenderers.isEmpty()) {
|
if (!externalRenderers.isEmpty()) {
|
||||||
resourcesItems.add(new ExportDataObject(ExportSettingsType.CUSTOM_RENDER_STYLE, new ArrayList<>(externalRenderers.values())));
|
resourcesItems.put(ExportSettingsType.CUSTOM_RENDER_STYLE, new ArrayList<>(externalRenderers.values()));
|
||||||
}
|
}
|
||||||
File routingProfilesFolder = app.getAppPath(IndexConstants.ROUTING_PROFILES_DIR);
|
File routingProfilesFolder = app.getAppPath(IndexConstants.ROUTING_PROFILES_DIR);
|
||||||
if (routingProfilesFolder.exists() && routingProfilesFolder.isDirectory()) {
|
if (routingProfilesFolder.exists() && routingProfilesFolder.isDirectory()) {
|
||||||
File[] fl = routingProfilesFolder.listFiles();
|
File[] fl = routingProfilesFolder.listFiles();
|
||||||
if (fl != null && fl.length > 0) {
|
if (fl != null && fl.length > 0) {
|
||||||
resourcesItems.add(new ExportDataObject(ExportSettingsType.CUSTOM_ROUTING, Arrays.asList(fl)));
|
resourcesItems.put(ExportSettingsType.CUSTOM_ROUTING, Arrays.asList(fl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<ITileSource> iTileSources = new ArrayList<>();
|
List<ITileSource> iTileSources = new ArrayList<>();
|
||||||
|
@ -649,22 +644,22 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!iTileSources.isEmpty()) {
|
if (!iTileSources.isEmpty()) {
|
||||||
resourcesItems.add(new ExportDataObject(ExportSettingsType.MAP_SOURCES, iTileSources));
|
resourcesItems.put(ExportSettingsType.MAP_SOURCES, iTileSources);
|
||||||
}
|
}
|
||||||
List<LocalIndexInfo> localIndexInfoList = getLocalIndexData();
|
List<LocalIndexInfo> localIndexInfoList = getLocalIndexData();
|
||||||
List<File> files = getFilesByType(localIndexInfoList, LocalIndexType.MAP_DATA, LocalIndexType.TILES_DATA,
|
List<File> files = getFilesByType(localIndexInfoList, LocalIndexType.MAP_DATA, LocalIndexType.TILES_DATA,
|
||||||
LocalIndexType.SRTM_DATA, LocalIndexType.WIKI_DATA);
|
LocalIndexType.SRTM_DATA, LocalIndexType.WIKI_DATA);
|
||||||
if (!files.isEmpty()) {
|
if (!files.isEmpty()) {
|
||||||
sortLocalFiles(files);
|
sortLocalFiles(files);
|
||||||
resourcesItems.add(new ExportDataObject(ExportSettingsType.OFFLINE_MAPS, files));
|
resourcesItems.put(ExportSettingsType.OFFLINE_MAPS, files);
|
||||||
}
|
}
|
||||||
files = getFilesByType(localIndexInfoList, LocalIndexType.TTS_VOICE_DATA);
|
files = getFilesByType(localIndexInfoList, LocalIndexType.TTS_VOICE_DATA);
|
||||||
if (!files.isEmpty()) {
|
if (!files.isEmpty()) {
|
||||||
resourcesItems.add(new ExportDataObject(ExportSettingsType.TTS_VOICE, files));
|
resourcesItems.put(ExportSettingsType.TTS_VOICE, files);
|
||||||
}
|
}
|
||||||
files = getFilesByType(localIndexInfoList, LocalIndexType.VOICE_DATA);
|
files = getFilesByType(localIndexInfoList, LocalIndexType.VOICE_DATA);
|
||||||
if (!files.isEmpty()) {
|
if (!files.isEmpty()) {
|
||||||
resourcesItems.add(new ExportDataObject(ExportSettingsType.VOICE, files));
|
resourcesItems.put(ExportSettingsType.VOICE, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourcesItems;
|
return resourcesItems;
|
||||||
|
@ -793,35 +788,32 @@ public class SettingsHelper {
|
||||||
return settingsItems;
|
return settingsItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<ExportSettingsCategory, List<ExportDataObject>> getSettingsToOperateByCategory(List<SettingsItem> items, boolean importComplete) {
|
public static Map<ExportSettingsCategory, SettingsCategoryItems> getSettingsToOperateByCategory(List<SettingsItem> items, boolean importComplete) {
|
||||||
Map<ExportSettingsCategory, List<ExportDataObject>> exportMap = new LinkedHashMap<>();
|
Map<ExportSettingsCategory, SettingsCategoryItems> exportMap = new LinkedHashMap<>();
|
||||||
Map<ExportSettingsType, List<?>> settingsToOperate = getSettingsToOperate(items, importComplete);
|
Map<ExportSettingsType, List<?>> settingsToOperate = getSettingsToOperate(items, importComplete);
|
||||||
|
|
||||||
List<ExportDataObject> settingsItems = new ArrayList<>();
|
Map<ExportSettingsType, List<?>> settingsItems = new LinkedHashMap<>();
|
||||||
List<ExportDataObject> myPlacesItems = new ArrayList<>();
|
Map<ExportSettingsType, List<?>> myPlacesItems = new LinkedHashMap<>();
|
||||||
List<ExportDataObject> resourcesItems = new ArrayList<>();
|
Map<ExportSettingsType, List<?>> resourcesItems = new LinkedHashMap<>();
|
||||||
|
|
||||||
for (Map.Entry<ExportSettingsType, List<?>> entry : settingsToOperate.entrySet()) {
|
for (Map.Entry<ExportSettingsType, List<?>> entry : settingsToOperate.entrySet()) {
|
||||||
ExportSettingsType type = entry.getKey();
|
ExportSettingsType type = entry.getKey();
|
||||||
if (type.isSettingsCategory()) {
|
if (type.isSettingsCategory()) {
|
||||||
settingsItems.add(new ExportDataObject(type, entry.getValue()));
|
settingsItems.put(type, entry.getValue());
|
||||||
} else if (type.isMyPlacesCategory()) {
|
} else if (type.isMyPlacesCategory()) {
|
||||||
myPlacesItems.add(new ExportDataObject(type, entry.getValue()));
|
myPlacesItems.put(type, entry.getValue());
|
||||||
} else if (type.isResourcesCategory()) {
|
} else if (type.isResourcesCategory()) {
|
||||||
resourcesItems.add(new ExportDataObject(type, entry.getValue()));
|
resourcesItems.put(type, entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!settingsItems.isEmpty()) {
|
if (!settingsItems.isEmpty()) {
|
||||||
sortExportSettingsObjects(settingsItems);
|
exportMap.put(ExportSettingsCategory.SETTINGS, new SettingsCategoryItems(settingsItems));
|
||||||
exportMap.put(ExportSettingsCategory.SETTINGS, settingsItems);
|
|
||||||
}
|
}
|
||||||
if (!myPlacesItems.isEmpty()) {
|
if (!myPlacesItems.isEmpty()) {
|
||||||
sortExportSettingsObjects(myPlacesItems);
|
exportMap.put(ExportSettingsCategory.MY_PLACES, new SettingsCategoryItems(myPlacesItems));
|
||||||
exportMap.put(ExportSettingsCategory.MY_PLACES, myPlacesItems);
|
|
||||||
}
|
}
|
||||||
if (!resourcesItems.isEmpty()) {
|
if (!resourcesItems.isEmpty()) {
|
||||||
sortExportSettingsObjects(resourcesItems);
|
exportMap.put(ExportSettingsCategory.RESOURCES, new SettingsCategoryItems(resourcesItems));
|
||||||
exportMap.put(ExportSettingsCategory.RESOURCES, resourcesItems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return exportMap;
|
return exportMap;
|
||||||
|
@ -1017,15 +1009,4 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sortExportSettingsObjects(List<ExportDataObject> items) {
|
|
||||||
Collections.sort(items, new Comparator<ExportDataObject>() {
|
|
||||||
@Override
|
|
||||||
public int compare(ExportDataObject lhs, ExportDataObject rhs) {
|
|
||||||
int order1 = lhs.getType().ordinal();
|
|
||||||
int order2 = rhs.getType().ordinal();
|
|
||||||
return (order1 < order2) ? -1 : ((order1 == order2) ? 0 : 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -14,22 +14,22 @@ import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.map.ITileSource;
|
import net.osmand.map.ITileSource;
|
||||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
|
||||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
|
||||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||||
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
|
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||||
|
import net.osmand.plus.mapmarkers.MapMarker;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
import net.osmand.plus.profiles.ProfileIconColors;
|
import net.osmand.plus.profiles.ProfileIconColors;
|
||||||
import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources;
|
import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources;
|
||||||
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.plus.settings.backend.ApplicationMode;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -157,9 +157,9 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
} else if (currentItem instanceof FavoriteGroup) {
|
} else if (currentItem instanceof FavoriteGroup) {
|
||||||
itemHolder.title.setText(((FavoriteGroup) currentItem).getDisplayName(app));
|
itemHolder.title.setText(((FavoriteGroup) currentItem).getDisplayName(app));
|
||||||
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_favorite, activeColorRes));
|
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_favorite, activeColorRes));
|
||||||
} else if (currentItem instanceof MapMarkersGroup) {
|
} else if (currentItem instanceof MapMarker) {
|
||||||
MapMarkersGroup markersGroup = (MapMarkersGroup) currentItem;
|
MapMarker mapMarker = (MapMarker) currentItem;
|
||||||
itemHolder.title.setText(markersGroup.getName());
|
itemHolder.title.setText(mapMarker.getName(app));
|
||||||
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_flag, activeColorRes));
|
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_flag, activeColorRes));
|
||||||
} else if (currentItem instanceof HistoryEntry) {
|
} else if (currentItem instanceof HistoryEntry) {
|
||||||
itemHolder.title.setText(((HistoryEntry) currentItem).getName().getName());
|
itemHolder.title.setText(((HistoryEntry) currentItem).getName().getName());
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package net.osmand.plus.settings.fragments;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ExportDataObject {
|
|
||||||
|
|
||||||
private ExportSettingsType type;
|
|
||||||
private List<?> items;
|
|
||||||
|
|
||||||
public ExportDataObject(@NonNull ExportSettingsType type, @NonNull List<?> items) {
|
|
||||||
this.type = type;
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExportSettingsType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<?> getItems() {
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,321 @@
|
||||||
|
package net.osmand.plus.settings.fragments;
|
||||||
|
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.core.widget.CompoundButtonCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.IndexConstants;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.map.ITileSource;
|
||||||
|
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||||
|
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.SQLiteTileSource;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton.Builder;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.SimpleDividerItem;
|
||||||
|
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||||
|
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||||
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
|
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||||
|
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
||||||
|
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||||
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
|
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||||
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
|
import net.osmand.plus.profiles.ProfileIconColors;
|
||||||
|
import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources;
|
||||||
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
|
import net.osmand.plus.render.RenderingIcons;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
||||||
|
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||||
|
import net.osmand.plus.settings.backend.backup.FileSettingsItem;
|
||||||
|
import net.osmand.plus.settings.backend.backup.GlobalSettingsItem;
|
||||||
|
import net.osmand.plus.settings.fragments.ExportSettingsAdapter.OnItemSelectedListener;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
import net.osmand.view.ThreeStateCheckbox;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.osmand.view.ThreeStateCheckbox.State.CHECKED;
|
||||||
|
import static net.osmand.view.ThreeStateCheckbox.State.MISC;
|
||||||
|
import static net.osmand.view.ThreeStateCheckbox.State.UNCHECKED;
|
||||||
|
|
||||||
|
public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
public static final String TAG = ExportItemsBottomSheet.class.getSimpleName();
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(ExportItemsBottomSheet.class);
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
private UiUtilities uiUtilities;
|
||||||
|
|
||||||
|
private ExportSettingsType type;
|
||||||
|
private List<Object> allItems;
|
||||||
|
private List<Object> selectedItems = new ArrayList<>();
|
||||||
|
|
||||||
|
private TextView selectedSize;
|
||||||
|
private ThreeStateCheckbox checkBox;
|
||||||
|
|
||||||
|
private int activeColorRes;
|
||||||
|
private int secondaryColorRes;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
|
app = requiredMyApplication();
|
||||||
|
uiUtilities = app.getUIUtilities();
|
||||||
|
activeColorRes = nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light;
|
||||||
|
secondaryColorRes = nightMode ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light;
|
||||||
|
|
||||||
|
items.add(createTitleItem());
|
||||||
|
items.add(new SimpleDividerItem(app));
|
||||||
|
|
||||||
|
for (Object object : allItems) {
|
||||||
|
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
|
||||||
|
Builder builder = (BottomSheetItemWithCompoundButton.Builder) new Builder()
|
||||||
|
.setChecked(selectedItems.contains(object))
|
||||||
|
.setButtonTintList(AndroidUtils.createCheckedColorStateList(app, secondaryColorRes, activeColorRes))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_checkbox_56dp)
|
||||||
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
boolean checked = !item[0].isChecked();
|
||||||
|
item[0].setChecked(checked);
|
||||||
|
if (checked) {
|
||||||
|
selectedItems.add(item[0].getTag());
|
||||||
|
} else {
|
||||||
|
selectedItems.remove(item[0].getTag());
|
||||||
|
}
|
||||||
|
updateTitleView();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setTag(object);
|
||||||
|
setupBottomSheetItem(builder, object);
|
||||||
|
item[0] = (BottomSheetItemWithCompoundButton) builder.create();
|
||||||
|
items.add(item[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private BaseBottomSheetItem createTitleItem() {
|
||||||
|
LayoutInflater themedInflater = UiUtilities.getInflater(requireContext(), nightMode);
|
||||||
|
View view = themedInflater.inflate(R.layout.settings_group_title, null);
|
||||||
|
|
||||||
|
checkBox = view.findViewById(R.id.check_box);
|
||||||
|
selectedSize = view.findViewById(R.id.selected_size);
|
||||||
|
TextView textView = view.findViewById(R.id.title);
|
||||||
|
textView.setText(type.getTitleId());
|
||||||
|
view.findViewById(R.id.select_all_button).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
checkBox.performClick();
|
||||||
|
boolean checked = checkBox.getState() == CHECKED;
|
||||||
|
if (checked) {
|
||||||
|
selectedItems.addAll(allItems);
|
||||||
|
} else {
|
||||||
|
selectedItems.clear();
|
||||||
|
}
|
||||||
|
updateTitleView();
|
||||||
|
updateItems(checked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setupDescription(view);
|
||||||
|
updateTitleView();
|
||||||
|
|
||||||
|
return new SimpleBottomSheetItem.Builder().setCustomView(view).create();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTitleView() {
|
||||||
|
if (Algorithms.isEmpty(selectedItems)) {
|
||||||
|
checkBox.setState(UNCHECKED);
|
||||||
|
} else {
|
||||||
|
checkBox.setState(selectedItems.containsAll(allItems) ? CHECKED : MISC);
|
||||||
|
}
|
||||||
|
int checkBoxColor = checkBox.getState() == UNCHECKED ? secondaryColorRes : activeColorRes;
|
||||||
|
CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, checkBoxColor)));
|
||||||
|
|
||||||
|
selectedSize.setText(getString(R.string.ltr_or_rtl_combine_via_slash, selectedItems.size(), allItems.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateItems(boolean checked) {
|
||||||
|
for (BaseBottomSheetItem item : items) {
|
||||||
|
if (item instanceof BottomSheetItemWithCompoundButton) {
|
||||||
|
((BottomSheetItemWithCompoundButton) item).setChecked(checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDismissButtonTextId() {
|
||||||
|
return R.string.shared_string_cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getRightBottomButtonTextId() {
|
||||||
|
return R.string.shared_string_apply;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRightBottomButtonClick() {
|
||||||
|
Fragment target = getTargetFragment();
|
||||||
|
if (target instanceof OnItemSelectedListener) {
|
||||||
|
OnItemSelectedListener listener = (OnItemSelectedListener) target;
|
||||||
|
listener.onItemsSelected(type, selectedItems);
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showInstance(@NonNull ExportSettingsType type, List<Object> selectedItems, List<?> allItems, @NonNull FragmentManager fm, @Nullable Fragment target) {
|
||||||
|
try {
|
||||||
|
if (!fm.isStateSaved() && fm.findFragmentByTag(TAG) == null) {
|
||||||
|
ExportItemsBottomSheet fragment = new ExportItemsBottomSheet();
|
||||||
|
fragment.type = type;
|
||||||
|
fragment.allItems = (List<Object>) allItems;
|
||||||
|
if (selectedItems != null) {
|
||||||
|
fragment.selectedItems.addAll(selectedItems);
|
||||||
|
}
|
||||||
|
fragment.setTargetFragment(target, 0);
|
||||||
|
fragment.show(fm, TAG);
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
LOG.error("showInstance", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String setupDescription(View view) {
|
||||||
|
TextView description = view.findViewById(R.id.description);
|
||||||
|
if (type == ExportSettingsType.FAVORITES) {
|
||||||
|
description.setText(R.string.select_groups_for_import);
|
||||||
|
} else {
|
||||||
|
description.setText(R.string.select_items_for_import);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupBottomSheetItem(BottomSheetItemWithCompoundButton.Builder builder, Object object) {
|
||||||
|
if (object instanceof ApplicationModeBean) {
|
||||||
|
ApplicationModeBean modeBean = (ApplicationModeBean) object;
|
||||||
|
String profileName = modeBean.userProfileName;
|
||||||
|
if (Algorithms.isEmpty(profileName)) {
|
||||||
|
ApplicationMode appMode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
|
||||||
|
profileName = getString(appMode.getNameKeyResource());
|
||||||
|
}
|
||||||
|
builder.setTitle(profileName);
|
||||||
|
|
||||||
|
String routingProfile = "";
|
||||||
|
String routingProfileValue = modeBean.routingProfile;
|
||||||
|
if (!routingProfileValue.isEmpty()) {
|
||||||
|
try {
|
||||||
|
routingProfile = getString(RoutingProfilesResources.valueOf(routingProfileValue.toUpperCase()).getStringRes());
|
||||||
|
routingProfile = Algorithms.capitalizeFirstLetterAndLowercase(routingProfile);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
routingProfile = Algorithms.capitalizeFirstLetterAndLowercase(routingProfileValue);
|
||||||
|
LOG.error("Error trying to get routing resource for " + routingProfileValue + "\n" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!Algorithms.isEmpty(routingProfile)) {
|
||||||
|
builder.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, getString(R.string.nav_type_hint), routingProfile));
|
||||||
|
} else {
|
||||||
|
builder.setDescription(getString(R.string.profile_type_base_string));
|
||||||
|
}
|
||||||
|
int profileIconRes = AndroidUtils.getDrawableId(app, modeBean.iconName);
|
||||||
|
ProfileIconColors iconColor = modeBean.iconColor;
|
||||||
|
builder.setIcon(uiUtilities.getIcon(profileIconRes, iconColor.getColor(nightMode)));
|
||||||
|
} else if (object instanceof QuickAction) {
|
||||||
|
QuickAction quickAction = (QuickAction) object;
|
||||||
|
builder.setTitle(quickAction.getName(app));
|
||||||
|
builder.setIcon(uiUtilities.getIcon(quickAction.getIconRes(), activeColorRes));
|
||||||
|
} else if (object instanceof PoiUIFilter) {
|
||||||
|
PoiUIFilter poiUIFilter = (PoiUIFilter) object;
|
||||||
|
builder.setTitle(poiUIFilter.getName());
|
||||||
|
int iconRes = RenderingIcons.getBigIconResourceId(poiUIFilter.getIconId());
|
||||||
|
builder.setIcon(uiUtilities.getIcon(iconRes != 0 ? iconRes : R.drawable.ic_action_user, activeColorRes));
|
||||||
|
} else if (object instanceof TileSourceTemplate || object instanceof SQLiteTileSource) {
|
||||||
|
ITileSource tileSource = (ITileSource) object;
|
||||||
|
builder.setTitle(tileSource.getName());
|
||||||
|
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_map, activeColorRes));
|
||||||
|
} else if (object instanceof File) {
|
||||||
|
setupBottomSheetItemForFile(builder, (File) object);
|
||||||
|
} else if (object instanceof FileSettingsItem) {
|
||||||
|
FileSettingsItem fileSettingsItem = (FileSettingsItem) object;
|
||||||
|
setupBottomSheetItemForFile(builder, fileSettingsItem.getFile());
|
||||||
|
} else if (object instanceof AvoidRoadInfo) {
|
||||||
|
AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) object;
|
||||||
|
builder.setTitle(avoidRoadInfo.name);
|
||||||
|
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_alert, activeColorRes));
|
||||||
|
} else if (object instanceof OsmNotesPoint) {
|
||||||
|
OsmNotesPoint osmNotesPoint = (OsmNotesPoint) object;
|
||||||
|
builder.setTitle(osmNotesPoint.getText());
|
||||||
|
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_osm_note_add, activeColorRes));
|
||||||
|
} else if (object instanceof OpenstreetmapPoint) {
|
||||||
|
OpenstreetmapPoint openstreetmapPoint = (OpenstreetmapPoint) object;
|
||||||
|
builder.setTitle(OsmEditingPlugin.getTitle(openstreetmapPoint, app));
|
||||||
|
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_info_dark, activeColorRes));
|
||||||
|
} else if (object instanceof FavoriteGroup) {
|
||||||
|
FavoriteGroup group = (FavoriteGroup) object;
|
||||||
|
builder.setTitle(group.getDisplayName(app));
|
||||||
|
int color = group.getColor() == 0 ? ContextCompat.getColor(app, R.color.color_favorite) : group.getColor();
|
||||||
|
builder.setIcon(uiUtilities.getPaintedIcon(R.drawable.ic_action_folder, color));
|
||||||
|
} else if (object instanceof GlobalSettingsItem) {
|
||||||
|
GlobalSettingsItem globalSettingsItem = (GlobalSettingsItem) object;
|
||||||
|
builder.setTitle(globalSettingsItem.getPublicName(app));
|
||||||
|
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_settings, activeColorRes));
|
||||||
|
} else if (object instanceof MapMarkersGroup) {
|
||||||
|
MapMarkersGroup markersGroup = (MapMarkersGroup) object;
|
||||||
|
if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) {
|
||||||
|
builder.setTitle(getString(R.string.map_markers));
|
||||||
|
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_flag, activeColorRes));
|
||||||
|
} else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) {
|
||||||
|
builder.setTitle(getString(R.string.map_markers));
|
||||||
|
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, activeColorRes));
|
||||||
|
}
|
||||||
|
} else if (object instanceof HistoryEntry) {
|
||||||
|
HistoryEntry historyEntry = (HistoryEntry) object;
|
||||||
|
builder.setTitle(historyEntry.getName().getName());
|
||||||
|
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, activeColorRes));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupBottomSheetItemForFile(Builder builder, File file) {
|
||||||
|
FileSettingsItem.FileSubtype fileSubtype = FileSettingsItem.FileSubtype.getSubtypeByPath(app, file.getPath());
|
||||||
|
builder.setTitle(file.getName());
|
||||||
|
if (file.getAbsolutePath().contains(IndexConstants.RENDERERS_DIR)) {
|
||||||
|
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_map_style, activeColorRes));
|
||||||
|
} else if (file.getAbsolutePath().contains(IndexConstants.ROUTING_PROFILES_DIR)) {
|
||||||
|
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
|
||||||
|
} else if (file.getAbsolutePath().contains(IndexConstants.GPX_INDEX_DIR)) {
|
||||||
|
builder.setTitle(GpxUiHelper.getGpxTitle(file.getName()));
|
||||||
|
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
|
||||||
|
} else if (file.getAbsolutePath().contains(IndexConstants.AV_INDEX_DIR)) {
|
||||||
|
int iconId = AudioVideoNotesPlugin.getIconIdForRecordingFile(file);
|
||||||
|
if (iconId == -1) {
|
||||||
|
iconId = R.drawable.ic_action_photo_dark;
|
||||||
|
}
|
||||||
|
builder.setIcon(uiUtilities.getIcon(iconId, activeColorRes));
|
||||||
|
} else if (fileSubtype.isMap()
|
||||||
|
|| fileSubtype == FileSettingsItem.FileSubtype.TTS_VOICE
|
||||||
|
|| fileSubtype == FileSettingsItem.FileSubtype.VOICE) {
|
||||||
|
builder.setTitle(FileNameTranslationHelper.getFileNameWithRegion(app, file.getName()));
|
||||||
|
builder.setIcon(uiUtilities.getIcon(fileSubtype.getIconId(), activeColorRes));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ import net.osmand.plus.helpers.FontCache;
|
||||||
import net.osmand.plus.settings.backend.ExportSettingsCategory;
|
import net.osmand.plus.settings.backend.ExportSettingsCategory;
|
||||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||||
import net.osmand.plus.settings.backend.backup.FileSettingsItem;
|
import net.osmand.plus.settings.backend.backup.FileSettingsItem;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.view.ThreeStateCheckbox;
|
import net.osmand.view.ThreeStateCheckbox;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -28,8 +29,6 @@ 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.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -44,9 +43,9 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
private final OsmandApplication app;
|
private final OsmandApplication app;
|
||||||
private final UiUtilities uiUtilities;
|
private final UiUtilities uiUtilities;
|
||||||
|
|
||||||
private List<ExportSettingsCategory> itemsTypes = new ArrayList<>();
|
private List<ExportSettingsCategory> itemsTypes;
|
||||||
private Map<ExportSettingsType, List<?>> selectedItemsMap = new HashMap<>();
|
private Map<ExportSettingsType, List<?>> selectedItemsMap;
|
||||||
private Map<ExportSettingsCategory, List<ExportDataObject>> itemsMap = new LinkedHashMap<>();
|
private Map<ExportSettingsCategory, SettingsCategoryItems> itemsMap;
|
||||||
|
|
||||||
private final OnItemSelectedListener listener;
|
private final OnItemSelectedListener listener;
|
||||||
|
|
||||||
|
@ -73,7 +72,7 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
group = themedInflater.inflate(R.layout.profile_data_list_item_group, parent, false);
|
group = themedInflater.inflate(R.layout.profile_data_list_item_group, parent, false);
|
||||||
}
|
}
|
||||||
final ExportSettingsCategory category = itemsTypes.get(groupPosition);
|
final ExportSettingsCategory category = itemsTypes.get(groupPosition);
|
||||||
final List<ExportDataObject> items = itemsMap.get(category);
|
final SettingsCategoryItems items = itemsMap.get(category);
|
||||||
|
|
||||||
String title = app.getString(category.getTitleId());
|
String title = app.getString(category.getTitleId());
|
||||||
TextView titleTv = group.findViewById(R.id.title_tv);
|
TextView titleTv = group.findViewById(R.id.title_tv);
|
||||||
|
@ -83,9 +82,8 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
subTextTv.setText(getCategoryDescr(category));
|
subTextTv.setText(getCategoryDescr(category));
|
||||||
|
|
||||||
int selectedTypes = 0;
|
int selectedTypes = 0;
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (ExportSettingsType type : items.getTypes()) {
|
||||||
ExportDataObject object = items.get(i);
|
if (!Algorithms.isEmpty(selectedItemsMap.get(type))) {
|
||||||
if (selectedItemsMap.containsKey(object.getType())) {
|
|
||||||
selectedTypes++;
|
selectedTypes++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +91,7 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
if (selectedTypes == 0) {
|
if (selectedTypes == 0) {
|
||||||
checkBox.setState(UNCHECKED);
|
checkBox.setState(UNCHECKED);
|
||||||
} else {
|
} else {
|
||||||
checkBox.setState(selectedTypes == items.size() ? CHECKED : MISC);
|
checkBox.setState(selectedTypes == items.getTypes().size() ? CHECKED : MISC);
|
||||||
}
|
}
|
||||||
int checkBoxColor = checkBox.getState() == UNCHECKED ? secondaryColorRes : activeColorRes;
|
int checkBoxColor = checkBox.getState() == UNCHECKED ? secondaryColorRes : activeColorRes;
|
||||||
CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, checkBoxColor)));
|
CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, checkBoxColor)));
|
||||||
|
@ -103,17 +101,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
checkBox.performClick();
|
checkBox.performClick();
|
||||||
boolean selected = checkBox.getState() == CHECKED;
|
boolean selected = checkBox.getState() == CHECKED;
|
||||||
if (selected) {
|
|
||||||
for (ExportDataObject object : items) {
|
|
||||||
if (!selectedItemsMap.containsKey(object.getType())) {
|
|
||||||
selectedItemsMap.put(object.getType(), object.getItems());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (ExportDataObject object : items) {
|
|
||||||
selectedItemsMap.remove(object.getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onCategorySelected(category, selected);
|
listener.onCategorySelected(category, selected);
|
||||||
}
|
}
|
||||||
|
@ -136,26 +123,29 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
if (child == null) {
|
if (child == null) {
|
||||||
child = themedInflater.inflate(R.layout.profile_data_list_item_group, parent, false);
|
child = themedInflater.inflate(R.layout.profile_data_list_item_group, parent, false);
|
||||||
}
|
}
|
||||||
final ExportDataObject currentItem = itemsMap.get(itemsTypes.get(groupPosition)).get(childPosition);
|
final ExportSettingsCategory category = itemsTypes.get(groupPosition);
|
||||||
List<?> selectedItems = selectedItemsMap.get(currentItem.getType());
|
final SettingsCategoryItems categoryItems = itemsMap.get(category);
|
||||||
|
final ExportSettingsType type = categoryItems.getTypes().get(childPosition);
|
||||||
|
final List<?> items = categoryItems.getItemsForType(type);
|
||||||
|
List<?> selectedItems = selectedItemsMap.get(type);
|
||||||
|
|
||||||
TextView titleTv = child.findViewById(R.id.title_tv);
|
TextView titleTv = child.findViewById(R.id.title_tv);
|
||||||
titleTv.setText(currentItem.getType().getTitleId());
|
titleTv.setText(type.getTitleId());
|
||||||
|
|
||||||
TextView subTextTv = child.findViewById(R.id.sub_text_tv);
|
TextView subTextTv = child.findViewById(R.id.sub_text_tv);
|
||||||
subTextTv.setText(getSelectedTypeDescr(currentItem));
|
subTextTv.setText(getSelectedTypeDescr(type, items));
|
||||||
|
|
||||||
ImageView icon = child.findViewById(R.id.explist_indicator);
|
ImageView icon = child.findViewById(R.id.explist_indicator);
|
||||||
setupIcon(icon, currentItem.getType().getIconRes(), selectedItems != null);
|
setupIcon(icon, type.getIconRes(), !Algorithms.isEmpty(selectedItems));
|
||||||
|
|
||||||
final ThreeStateCheckbox checkBox = child.findViewById(R.id.check_box);
|
final ThreeStateCheckbox checkBox = child.findViewById(R.id.check_box);
|
||||||
if (selectedItems == null) {
|
if (selectedItems == null) {
|
||||||
checkBox.setState(UNCHECKED);
|
checkBox.setState(UNCHECKED);
|
||||||
} else if (selectedItems.containsAll(currentItem.getItems())) {
|
} else if (selectedItems.containsAll(items)) {
|
||||||
checkBox.setState(CHECKED);
|
checkBox.setState(CHECKED);
|
||||||
} else {
|
} else {
|
||||||
boolean contains = false;
|
boolean contains = false;
|
||||||
for (Object object : currentItem.getItems()) {
|
for (Object object : items) {
|
||||||
if (selectedItems.contains(object)) {
|
if (selectedItems.contains(object)) {
|
||||||
contains = true;
|
contains = true;
|
||||||
break;
|
break;
|
||||||
|
@ -163,7 +153,14 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
}
|
}
|
||||||
checkBox.setState(contains ? MISC : UNCHECKED);
|
checkBox.setState(contains ? MISC : UNCHECKED);
|
||||||
}
|
}
|
||||||
|
child.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onTypeClicked(category, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
int checkBoxColor = checkBox.getState() == UNCHECKED ? secondaryColorRes : activeColorRes;
|
int checkBoxColor = checkBox.getState() == UNCHECKED ? secondaryColorRes : activeColorRes;
|
||||||
CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, checkBoxColor)));
|
CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, checkBoxColor)));
|
||||||
child.findViewById(R.id.check_box_container).setOnClickListener(new View.OnClickListener() {
|
child.findViewById(R.id.check_box_container).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -171,13 +168,8 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
checkBox.performClick();
|
checkBox.performClick();
|
||||||
boolean selected = checkBox.getState() == CHECKED;
|
boolean selected = checkBox.getState() == CHECKED;
|
||||||
if (selected) {
|
|
||||||
selectedItemsMap.put(currentItem.getType(), currentItem.getItems());
|
|
||||||
} else {
|
|
||||||
selectedItemsMap.remove(currentItem.getType());
|
|
||||||
}
|
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onTypeSelected(currentItem.getType(), selected);
|
listener.onItemsSelected(type, selected ? items : new ArrayList<>());
|
||||||
}
|
}
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -195,7 +187,7 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getChildrenCount(int i) {
|
public int getChildrenCount(int i) {
|
||||||
return itemsMap.get(itemsTypes.get(i)).size();
|
return itemsMap.get(itemsTypes.get(i)).getTypes().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -205,7 +197,9 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getChild(int groupPosition, int childPosition) {
|
public Object getChild(int groupPosition, int childPosition) {
|
||||||
return itemsMap.get(itemsTypes.get(groupPosition)).get(childPosition);
|
SettingsCategoryItems categoryItems = itemsMap.get(itemsTypes.get(groupPosition));
|
||||||
|
ExportSettingsType type = categoryItems.getTypes().get(groupPosition);
|
||||||
|
return categoryItems.getItemsForType(type).get(childPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -237,19 +231,15 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSettingsList(Map<ExportSettingsCategory, List<ExportDataObject>> itemsMap) {
|
public void updateSettingsItems(Map<ExportSettingsCategory, SettingsCategoryItems> itemsMap,
|
||||||
|
Map<ExportSettingsType, List<?>> selectedItemsMap) {
|
||||||
this.itemsMap = itemsMap;
|
this.itemsMap = itemsMap;
|
||||||
this.itemsTypes = new ArrayList<>(itemsMap.keySet());
|
this.itemsTypes = new ArrayList<>(itemsMap.keySet());
|
||||||
|
this.selectedItemsMap = selectedItemsMap;
|
||||||
Collections.sort(itemsTypes);
|
Collections.sort(itemsTypes);
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearSettingsList() {
|
|
||||||
this.itemsMap.clear();
|
|
||||||
this.itemsTypes.clear();
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasSelectedData() {
|
public boolean hasSelectedData() {
|
||||||
return !selectedItemsMap.isEmpty();
|
return !selectedItemsMap.isEmpty();
|
||||||
}
|
}
|
||||||
|
@ -265,21 +255,20 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
private String getCategoryDescr(ExportSettingsCategory category) {
|
private String getCategoryDescr(ExportSettingsCategory category) {
|
||||||
long itemsSize = 0;
|
long itemsSize = 0;
|
||||||
int selectedTypes = 0;
|
int selectedTypes = 0;
|
||||||
List<ExportDataObject> items = itemsMap.get(category);
|
SettingsCategoryItems items = itemsMap.get(category);
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (ExportSettingsType type : items.getTypes()) {
|
||||||
ExportDataObject object = items.get(i);
|
if (!Algorithms.isEmpty(selectedItemsMap.get(type))) {
|
||||||
if (selectedItemsMap.containsKey(object.getType())) {
|
|
||||||
selectedTypes++;
|
selectedTypes++;
|
||||||
itemsSize += calculateItemsSize(object.getItems());
|
itemsSize += calculateItemsSize(items.getItemsForType(type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String description;
|
String description;
|
||||||
if (selectedTypes == 0) {
|
if (selectedTypes == 0) {
|
||||||
description = app.getString(R.string.shared_string_none);
|
description = app.getString(R.string.shared_string_none);
|
||||||
} else if (selectedTypes == items.size()) {
|
} else if (selectedTypes == items.getTypes().size()) {
|
||||||
description = app.getString(R.string.shared_string_all);
|
description = app.getString(R.string.shared_string_all);
|
||||||
} else {
|
} else {
|
||||||
description = app.getString(R.string.ltr_or_rtl_combine_via_slash, String.valueOf(selectedTypes), String.valueOf(items.size()));
|
description = app.getString(R.string.ltr_or_rtl_combine_via_slash, String.valueOf(selectedTypes), String.valueOf(items.getTypes().size()));
|
||||||
}
|
}
|
||||||
String formattedSize = AndroidUtils.formatSize(app, itemsSize);
|
String formattedSize = AndroidUtils.formatSize(app, itemsSize);
|
||||||
return itemsSize == 0 ? description : app.getString(R.string.ltr_or_rtl_combine_via_comma, description, formattedSize);
|
return itemsSize == 0 ? description : app.getString(R.string.ltr_or_rtl_combine_via_comma, description, formattedSize);
|
||||||
|
@ -297,12 +286,11 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
return itemsSize;
|
return itemsSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSelectedTypeDescr(ExportDataObject dataObject) {
|
private String getSelectedTypeDescr(ExportSettingsType type, List<?> items) {
|
||||||
long itemsSize = 0;
|
long itemsSize = 0;
|
||||||
int selectedTypes = 0;
|
int selectedTypes = 0;
|
||||||
|
|
||||||
List<?> items = dataObject.getItems();
|
List<?> selectedItems = selectedItemsMap.get(type);
|
||||||
List<?> selectedItems = selectedItemsMap.get(dataObject.getType());
|
|
||||||
if (selectedItems != null) {
|
if (selectedItems != null) {
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (int i = 0; i < items.size(); i++) {
|
||||||
Object object = items.get(i);
|
Object object = items.get(i);
|
||||||
|
@ -333,9 +321,11 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
|
|
||||||
interface OnItemSelectedListener {
|
interface OnItemSelectedListener {
|
||||||
|
|
||||||
|
void onItemsSelected(ExportSettingsType type, List<?> selectedItems);
|
||||||
|
|
||||||
void onCategorySelected(ExportSettingsCategory type, boolean selected);
|
void onCategorySelected(ExportSettingsCategory type, boolean selected);
|
||||||
|
|
||||||
void onTypeSelected(ExportSettingsType type, boolean selected);
|
void onTypeClicked(ExportSettingsCategory category, ExportSettingsType type);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -50,7 +50,10 @@ import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -74,7 +77,9 @@ public class ExportSettingsFragment extends BaseOsmAndFragment implements OnItem
|
||||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd-MM-yy", Locale.US);
|
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd-MM-yy", Locale.US);
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private Map<ExportSettingsCategory, List<ExportDataObject>> dataList;
|
|
||||||
|
private Map<ExportSettingsType, List<?>> selectedItemsMap = new HashMap<>();
|
||||||
|
private Map<ExportSettingsCategory, SettingsCategoryItems> dataList = new LinkedHashMap<>();
|
||||||
|
|
||||||
private ProgressDialog progress;
|
private ProgressDialog progress;
|
||||||
private ApplicationMode appMode;
|
private ApplicationMode appMode;
|
||||||
|
@ -179,7 +184,7 @@ public class ExportSettingsFragment extends BaseOsmAndFragment implements OnItem
|
||||||
});
|
});
|
||||||
|
|
||||||
adapter = new ExportSettingsAdapter(app, this, nightMode);
|
adapter = new ExportSettingsAdapter(app, this, nightMode);
|
||||||
adapter.updateSettingsList(dataList);
|
adapter.updateSettingsItems(dataList, selectedItemsMap);
|
||||||
expandableList.setAdapter(adapter);
|
expandableList.setAdapter(adapter);
|
||||||
|
|
||||||
CollapsingToolbarLayout toolbarLayout = root.findViewById(R.id.toolbar_layout);
|
CollapsingToolbarLayout toolbarLayout = root.findViewById(R.id.toolbar_layout);
|
||||||
|
@ -292,15 +297,32 @@ public class ExportSettingsFragment extends BaseOsmAndFragment implements OnItem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCategorySelected(ExportSettingsCategory type, boolean selected) {
|
public void onCategorySelected(ExportSettingsCategory category, boolean selected) {
|
||||||
|
SettingsCategoryItems categoryItems = dataList.get(category);
|
||||||
|
for (ExportSettingsType type : categoryItems.getTypes()) {
|
||||||
|
List<?> selectedItems = selected ? categoryItems.getItemsForType(type) : new ArrayList<>();
|
||||||
|
selectedItemsMap.put(type, selectedItems);
|
||||||
|
}
|
||||||
updateAvailableSpace();
|
updateAvailableSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTypeSelected(ExportSettingsType type, boolean selected) {
|
public void onItemsSelected(ExportSettingsType type, List<?> selectedItems) {
|
||||||
|
selectedItemsMap.put(type, selectedItems);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
updateAvailableSpace();
|
updateAvailableSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTypeClicked(ExportSettingsCategory category, ExportSettingsType type) {
|
||||||
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
|
if (fragmentManager != null && type != ExportSettingsType.GLOBAL && type != ExportSettingsType.SEARCH_HISTORY) {
|
||||||
|
List<Object> items = (List<Object>) dataList.get(category).getItemsForType(type);
|
||||||
|
List<Object> selectedItems = (List<Object>) selectedItemsMap.get(type);
|
||||||
|
ExportItemsBottomSheet.showInstance(type, selectedItems, items, fragmentManager, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void prepareFile() {
|
private void prepareFile() {
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
exportingStarted = true;
|
exportingStarted = true;
|
||||||
|
|
|
@ -33,13 +33,12 @@ import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
import net.osmand.plus.mapmarkers.MapMarker;
|
||||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||||
import net.osmand.plus.osmedit.OsmNotesPoint;
|
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportAsyncTask;
|
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportAsyncTask;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportType;
|
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportType;
|
||||||
|
@ -203,8 +202,8 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
|
||||||
List<File> ttsVoiceFilesList = new ArrayList<>();
|
List<File> ttsVoiceFilesList = new ArrayList<>();
|
||||||
List<File> voiceFilesList = new ArrayList<>();
|
List<File> voiceFilesList = new ArrayList<>();
|
||||||
List<File> mapFilesList = new ArrayList<>();
|
List<File> mapFilesList = new ArrayList<>();
|
||||||
List<MapMarkersGroup> markersGroups = new ArrayList<>();
|
List<MapMarker> mapMarkers = new ArrayList<>();
|
||||||
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
|
List<MapMarker> mapMarkersGroups = new ArrayList<>();
|
||||||
List<HistoryEntry> historyEntries = new ArrayList<>();
|
List<HistoryEntry> historyEntries = new ArrayList<>();
|
||||||
|
|
||||||
for (Object object : duplicatesList) {
|
for (Object object : duplicatesList) {
|
||||||
|
@ -242,12 +241,12 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
|
||||||
osmNotesPointList.add((OsmNotesPoint) object);
|
osmNotesPointList.add((OsmNotesPoint) object);
|
||||||
} else if (object instanceof OpenstreetmapPoint) {
|
} else if (object instanceof OpenstreetmapPoint) {
|
||||||
osmEditsPointList.add((OpenstreetmapPoint) object);
|
osmEditsPointList.add((OpenstreetmapPoint) object);
|
||||||
} else if (object instanceof MapMarkersGroup) {
|
} else if (object instanceof MapMarker) {
|
||||||
MapMarkersGroup markersGroup = (MapMarkersGroup) object;
|
MapMarker mapMarker = (MapMarker) object;
|
||||||
if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) {
|
if (mapMarker.history) {
|
||||||
markersGroups.add(markersGroup);
|
mapMarkers.add(mapMarker);
|
||||||
} else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) {
|
} else {
|
||||||
markersHistoryGroups.add(markersGroup);
|
mapMarkersGroups.add(mapMarker);
|
||||||
}
|
}
|
||||||
} else if (object instanceof HistoryEntry) {
|
} else if (object instanceof HistoryEntry) {
|
||||||
historyEntries.add((HistoryEntry) object);
|
historyEntries.add((HistoryEntry) object);
|
||||||
|
@ -313,13 +312,13 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
|
||||||
duplicates.add(getString(R.string.local_indexes_cat_voice));
|
duplicates.add(getString(R.string.local_indexes_cat_voice));
|
||||||
duplicates.addAll(voiceFilesList);
|
duplicates.addAll(voiceFilesList);
|
||||||
}
|
}
|
||||||
if (!markersGroups.isEmpty()) {
|
if (!mapMarkers.isEmpty()) {
|
||||||
duplicates.add(getString(R.string.map_markers));
|
duplicates.add(getString(R.string.map_markers));
|
||||||
duplicates.addAll(markersGroups);
|
duplicates.addAll(mapMarkers);
|
||||||
}
|
}
|
||||||
if (!markersHistoryGroups.isEmpty()) {
|
if (!mapMarkersGroups.isEmpty()) {
|
||||||
duplicates.add(getString(R.string.markers_history));
|
duplicates.add(getString(R.string.markers_history));
|
||||||
duplicates.addAll(markersHistoryGroups);
|
duplicates.addAll(mapMarkersGroups);
|
||||||
}
|
}
|
||||||
return duplicates;
|
return duplicates;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.SQLiteTileSource;
|
import net.osmand.plus.SQLiteTileSource;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||||
|
@ -54,7 +55,6 @@ import net.osmand.plus.settings.backend.backup.AvoidRoadsSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.FavoritesSettingsItem;
|
import net.osmand.plus.settings.backend.backup.FavoritesSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.FileSettingsItem;
|
import net.osmand.plus.settings.backend.backup.FileSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.GlobalSettingsItem;
|
import net.osmand.plus.settings.backend.backup.GlobalSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.SearchHistorySettingsItem;
|
|
||||||
import net.osmand.plus.settings.backend.backup.HistoryMarkersSettingsItem;
|
import net.osmand.plus.settings.backend.backup.HistoryMarkersSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.MapSourcesSettingsItem;
|
import net.osmand.plus.settings.backend.backup.MapSourcesSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.MarkersSettingsItem;
|
import net.osmand.plus.settings.backend.backup.MarkersSettingsItem;
|
||||||
|
@ -63,12 +63,12 @@ import net.osmand.plus.settings.backend.backup.OsmNotesSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.PoiUiFiltersSettingsItem;
|
import net.osmand.plus.settings.backend.backup.PoiUiFiltersSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.ProfileSettingsItem;
|
import net.osmand.plus.settings.backend.backup.ProfileSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.QuickActionsSettingsItem;
|
import net.osmand.plus.settings.backend.backup.QuickActionsSettingsItem;
|
||||||
|
import net.osmand.plus.settings.backend.backup.SearchHistorySettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportAsyncTask;
|
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportAsyncTask;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportType;
|
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportType;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsItemType;
|
import net.osmand.plus.settings.backend.backup.SettingsItemType;
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -134,7 +134,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment {
|
||||||
inflater = UiUtilities.getInflater(app, nightMode);
|
inflater = UiUtilities.getInflater(app, nightMode);
|
||||||
View root = inflater.inflate(R.layout.fragment_import, container, false);
|
View root = inflater.inflate(R.layout.fragment_import, container, false);
|
||||||
Toolbar toolbar = root.findViewById(R.id.toolbar);
|
Toolbar toolbar = root.findViewById(R.id.toolbar);
|
||||||
TextViewEx continueBtn = root.findViewById(R.id.continue_button);
|
View continueBtn = root.findViewById(R.id.continue_button);
|
||||||
toolbarLayout = root.findViewById(R.id.toolbar_layout);
|
toolbarLayout = root.findViewById(R.id.toolbar_layout);
|
||||||
expandableList = root.findViewById(R.id.list);
|
expandableList = root.findViewById(R.id.list);
|
||||||
buttonsContainer = root.findViewById(R.id.buttons_container);
|
buttonsContainer = root.findViewById(R.id.buttons_container);
|
||||||
|
@ -145,6 +145,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment {
|
||||||
description = header.findViewById(R.id.description);
|
description = header.findViewById(R.id.description);
|
||||||
description.setText(R.string.select_data_to_import);
|
description.setText(R.string.select_data_to_import);
|
||||||
expandableList.addHeaderView(header);
|
expandableList.addHeaderView(header);
|
||||||
|
UiUtilities.setupDialogButton(nightMode, continueBtn, DialogButtonType.PRIMARY, getString(R.string.shared_string_continue));
|
||||||
continueBtn.setOnClickListener(new View.OnClickListener() {
|
continueBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package net.osmand.plus.settings.fragments;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SettingsCategoryItems {
|
||||||
|
|
||||||
|
private final Map<ExportSettingsType, List<?>> itemsMap;
|
||||||
|
|
||||||
|
public SettingsCategoryItems(@NonNull Map<ExportSettingsType, List<?>> itemsMap) {
|
||||||
|
this.itemsMap = itemsMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ExportSettingsType> getTypes() {
|
||||||
|
return new ArrayList<>(itemsMap.keySet());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<?> getItemsForType(ExportSettingsType type) {
|
||||||
|
return itemsMap.get(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<ExportSettingsType, List<?>> getItemsMap() {
|
||||||
|
return itemsMap;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue