Fix ImportCompleteFragment and remove duplicated code
This commit is contained in:
parent
fa4aa8fde5
commit
d0d95e92cc
13 changed files with 38 additions and 70 deletions
|
@ -92,11 +92,6 @@ public class AvoidRoadsSettingsItem extends CollectionSettingsItem<AvoidRoadInfo
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldShowDuplicates() {
|
public boolean shouldShowDuplicates() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -72,6 +72,11 @@ public abstract class CollectionSettingsItem<T> extends SettingsItem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldReadOnCollecting() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean isDuplicate(@NonNull T item);
|
public abstract boolean isDuplicate(@NonNull T item);
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
|
@ -109,11 +109,6 @@ public class FavoritesSettingsItem extends CollectionSettingsItem<FavoriteGroup>
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public FavoriteGroup renameItem(@NonNull FavoriteGroup item) {
|
public FavoriteGroup renameItem(@NonNull FavoriteGroup item) {
|
||||||
|
|
|
@ -103,11 +103,6 @@ public class HistoryMarkersSettingsItem extends CollectionSettingsItem<MapMarker
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public MapMarker renameItem(@NonNull MapMarker item) {
|
public MapMarker renameItem(@NonNull MapMarker item) {
|
||||||
|
|
|
@ -130,11 +130,6 @@ public class MapSourcesSettingsItem extends CollectionSettingsItem<ITileSource>
|
||||||
return "map_sources";
|
return "map_sources";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -103,11 +103,6 @@ public class MarkersSettingsItem extends CollectionSettingsItem<MapMarker> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public MapMarker renameItem(@NonNull MapMarker item) {
|
public MapMarker renameItem(@NonNull MapMarker item) {
|
||||||
|
|
|
@ -87,11 +87,6 @@ public class OnlineRoutingSettingsItem extends CollectionSettingsItem<OnlineRout
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public OnlineRoutingEngine renameItem(@NonNull OnlineRoutingEngine item) {
|
public OnlineRoutingEngine renameItem(@NonNull OnlineRoutingEngine item) {
|
||||||
|
|
|
@ -113,11 +113,6 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem<OpenstreetmapPo
|
||||||
return ctx.getString(R.string.osm_edits);
|
return ctx.getString(R.string.osm_edits);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldShowDuplicates() {
|
public boolean shouldShowDuplicates() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -106,11 +106,6 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem<OsmNotesPoint>
|
||||||
return ctx.getString(R.string.osm_notes);
|
return ctx.getString(R.string.osm_notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldShowDuplicates() {
|
public boolean shouldShowDuplicates() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -105,11 +105,6 @@ public class PoiUiFiltersSettingsItem extends CollectionSettingsItem<PoiUIFilter
|
||||||
return "poi_ui_filters";
|
return "poi_ui_filters";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -89,11 +89,6 @@ public class QuickActionsSettingsItem extends CollectionSettingsItem<QuickAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
@ -148,11 +148,6 @@ public class SearchHistorySettingsItem extends CollectionSettingsItem<HistoryEnt
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public HistoryEntry renameItem(@NonNull HistoryEntry item) {
|
public HistoryEntry renameItem(@NonNull HistoryEntry item) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ 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.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||||
import net.osmand.plus.dialogs.SelectMapStyleBottomSheetDialogFragment;
|
import net.osmand.plus.dialogs.SelectMapStyleBottomSheetDialogFragment;
|
||||||
|
@ -36,6 +37,7 @@ import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||||
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
|
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
||||||
|
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -150,12 +152,11 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
dismissFragment();
|
dismissFragment();
|
||||||
fm.popBackStack(DRAWER_SETTINGS_ID + ".new", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
fm.popBackStack(DRAWER_SETTINGS_ID + ".new", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CUSTOM_ROUTING:
|
case GLOBAL:
|
||||||
case PROFILE:
|
case PROFILE:
|
||||||
BaseSettingsFragment.showInstance(
|
case CUSTOM_ROUTING:
|
||||||
requireActivity(),
|
case ONLINE_ROUTING_ENGINES:
|
||||||
BaseSettingsFragment.SettingsScreenType.MAIN_SETTINGS
|
BaseSettingsFragment.showInstance(requireActivity(), SettingsScreenType.MAIN_SETTINGS);
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case QUICK_ACTIONS:
|
case QUICK_ACTIONS:
|
||||||
fm.beginTransaction()
|
fm.beginTransaction()
|
||||||
|
@ -190,19 +191,13 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
case AVOID_ROADS:
|
case AVOID_ROADS:
|
||||||
new AvoidRoadsBottomSheetDialogFragment().show(fm, AvoidRoadsBottomSheetDialogFragment.TAG);
|
new AvoidRoadsBottomSheetDialogFragment().show(fm, AvoidRoadsBottomSheetDialogFragment.TAG);
|
||||||
break;
|
break;
|
||||||
|
case TRACKS:
|
||||||
case OSM_NOTES:
|
case OSM_NOTES:
|
||||||
case OSM_EDITS:
|
case OSM_EDITS:
|
||||||
OsmAndAppCustomization appCustomization = app.getAppCustomization();
|
|
||||||
final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
|
|
||||||
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
|
||||||
app.getSettings().FAVORITES_TAB.set(OsmEditingPlugin.OSM_EDIT_TAB);
|
|
||||||
startActivity(favorites);
|
|
||||||
break;
|
|
||||||
case FAVORITES:
|
case FAVORITES:
|
||||||
Intent favoritesActivity = new Intent(activity, app.getAppCustomization().getFavoritesActivity());
|
case MULTIMEDIA_NOTES:
|
||||||
favoritesActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
int tabId = getFavoritesTabId(type);
|
||||||
app.getSettings().FAVORITES_TAB.set(FavoritesActivity.FAV_TAB);
|
openFavouritesActivity(activity, tabId);
|
||||||
startActivity(favoritesActivity);
|
|
||||||
break;
|
break;
|
||||||
case SEARCH_HISTORY:
|
case SEARCH_HISTORY:
|
||||||
if (activity instanceof MapActivity) {
|
if (activity instanceof MapActivity) {
|
||||||
|
@ -221,6 +216,29 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void openFavouritesActivity(Activity activity, int tabType) {
|
||||||
|
OsmAndAppCustomization appCustomization = app.getAppCustomization();
|
||||||
|
Intent favoritesActivity = new Intent(activity, appCustomization.getFavoritesActivity());
|
||||||
|
favoritesActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
|
app.getSettings().FAVORITES_TAB.set(tabType);
|
||||||
|
startActivity(favoritesActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getFavoritesTabId(ExportSettingsType type) {
|
||||||
|
switch (type) {
|
||||||
|
case OSM_NOTES:
|
||||||
|
case OSM_EDITS:
|
||||||
|
return OsmEditingPlugin.OSM_EDIT_TAB;
|
||||||
|
case MULTIMEDIA_NOTES:
|
||||||
|
return AudioVideoNotesPlugin.NOTES_TAB;
|
||||||
|
case TRACKS:
|
||||||
|
return FavoritesActivity.GPX_TAB;
|
||||||
|
case FAVORITES:
|
||||||
|
default:
|
||||||
|
return FavoritesActivity.FAV_TAB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStatusBarColorId() {
|
public int getStatusBarColorId() {
|
||||||
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
|
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
|
||||||
|
|
Loading…
Reference in a new issue