prepare importing finish
This commit is contained in:
parent
4a75987051
commit
d9626e216b
6 changed files with 33 additions and 76 deletions
|
@ -128,17 +128,6 @@
|
||||||
|
|
||||||
</android.support.design.widget.CollapsingToolbarLayout>
|
</android.support.design.widget.CollapsingToolbarLayout>
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/shadowView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/abp__shadow_height"
|
|
||||||
android:src="@drawable/preference_activity_action_bar_shadow"
|
|
||||||
tools:ignore="ContentDescription" />
|
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progress_bar"
|
android:id="@+id/progress_bar"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
@ -149,8 +138,6 @@
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
|
|
@ -135,17 +135,6 @@
|
||||||
|
|
||||||
</android.support.design.widget.CollapsingToolbarLayout>
|
</android.support.design.widget.CollapsingToolbarLayout>
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/shadowView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/abp__shadow_height"
|
|
||||||
android:src="@drawable/preference_activity_action_bar_shadow"
|
|
||||||
tools:ignore="ContentDescription" />
|
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progress_bar"
|
android:id="@+id/progress_bar"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
@ -156,8 +145,6 @@
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
|
|
@ -269,6 +269,11 @@ public class SettingsHelper {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public List<T> getDuplicateItems() {
|
||||||
|
return duplicateItems;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public List<T> excludeDuplicateItems() {
|
public List<T> excludeDuplicateItems() {
|
||||||
if (!items.isEmpty()) {
|
if (!items.isEmpty()) {
|
||||||
|
|
|
@ -41,11 +41,11 @@ import static net.osmand.plus.settings.ImportSettingsFragment.getSettingsToOpera
|
||||||
public class ImportCompleteFragment extends BaseOsmAndFragment {
|
public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
public static final String TAG = ImportCompleteFragment.class.getSimpleName();
|
public static final String TAG = ImportCompleteFragment.class.getSimpleName();
|
||||||
private static final String FILE_NAME_KEY = "FILE_NAME_KEY";
|
private static final String FILE_NAME_KEY = "FILE_NAME_KEY";
|
||||||
|
private OsmandApplication app;
|
||||||
|
private RecyclerView recyclerView;
|
||||||
private List<SettingsItem> settingsItems;
|
private List<SettingsItem> settingsItems;
|
||||||
private String fileName;
|
private String fileName;
|
||||||
private OsmandApplication app;
|
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
private RecyclerView recyclerView;
|
|
||||||
|
|
||||||
public static void showInstance(FragmentManager fm, @NonNull List<SettingsItem> settingsItems,
|
public static void showInstance(FragmentManager fm, @NonNull List<SettingsItem> settingsItems,
|
||||||
@NonNull String fileName) {
|
@NonNull String fileName) {
|
||||||
|
@ -68,6 +68,9 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
nightMode = !app.getSettings().isLightContent();
|
nightMode = !app.getSettings().isLightContent();
|
||||||
if (settingsItems == null) {
|
if (settingsItems == null) {
|
||||||
settingsItems = app.getSettingsHelper().getImportedItems();
|
settingsItems = app.getSettingsHelper().getImportedItems();
|
||||||
|
if (settingsItems == null) {
|
||||||
|
dismissFragment();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,20 +81,19 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
inflater = UiUtilities.getInflater(app, nightMode);
|
inflater = UiUtilities.getInflater(app, nightMode);
|
||||||
View root = inflater.inflate(R.layout.fragment_import_complete, container, false);
|
View root = inflater.inflate(R.layout.fragment_import_complete, container, false);
|
||||||
TextView description = root.findViewById(R.id.description);
|
TextView description = root.findViewById(R.id.description);
|
||||||
|
TextView btnClose = root.findViewById(R.id.button_close);
|
||||||
|
recyclerView = root.findViewById(R.id.list);
|
||||||
description.setText(UiUtilities.createSpannableString(
|
description.setText(UiUtilities.createSpannableString(
|
||||||
String.format(getString(R.string.import_complete_description), fileName),
|
String.format(getString(R.string.import_complete_description), fileName),
|
||||||
fileName,
|
fileName,
|
||||||
new StyleSpan(Typeface.BOLD)
|
new StyleSpan(Typeface.BOLD)
|
||||||
));
|
));
|
||||||
|
|
||||||
TextView btnClose = root.findViewById(R.id.button_close);
|
|
||||||
btnClose.setOnClickListener(new View.OnClickListener() {
|
btnClose.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
dismissFragment();
|
dismissFragment();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
recyclerView = root.findViewById(R.id.list);
|
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
AndroidUtils.addStatusBarPadding21v(app, root);
|
AndroidUtils.addStatusBarPadding21v(app, root);
|
||||||
}
|
}
|
||||||
|
@ -128,6 +130,7 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
if (fm != null) {
|
if (fm != null) {
|
||||||
getFragmentManager().popBackStack(IMPORT_SETTINGS_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
getFragmentManager().popBackStack(IMPORT_SETTINGS_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||||
}
|
}
|
||||||
|
app.getSettingsHelper().setImportedItems(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void navigateTo(AdditionalDataWrapper.Type type) {
|
private void navigateTo(AdditionalDataWrapper.Type type) {
|
||||||
|
@ -135,6 +138,7 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
if (fm == null) {
|
if (fm == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
dismissFragment();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CUSTOM_ROUTING:
|
case CUSTOM_ROUTING:
|
||||||
case PROFILE:
|
case PROFILE:
|
||||||
|
@ -152,7 +156,7 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
new QuickSearchDialogFragment().show(fm, QuickSearchDialogFragment.TAG);
|
new QuickSearchDialogFragment().show(fm, QuickSearchDialogFragment.TAG);
|
||||||
break;
|
break;
|
||||||
case MAP_SOURCES:
|
case MAP_SOURCES:
|
||||||
Activity activity = getActivity();
|
Activity activity = requireActivity();
|
||||||
if (activity instanceof MapActivity) {
|
if (activity instanceof MapActivity) {
|
||||||
((MapActivity) activity).getDashboard()
|
((MapActivity) activity).getDashboard()
|
||||||
.setDashboardVisibility(
|
.setDashboardVisibility(
|
||||||
|
@ -169,10 +173,8 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
new AvoidRoadsBottomSheetDialogFragment().show(fm, AvoidRoadsBottomSheetDialogFragment.TAG);
|
new AvoidRoadsBottomSheetDialogFragment().show(fm, AvoidRoadsBottomSheetDialogFragment.TAG);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
// dismissFragment();
|
|
||||||
app.getSettingsHelper().setImportedItems(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -180,7 +182,6 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setSettingsItems(List<SettingsItem> settingsItems) {
|
public void setSettingsItems(List<SettingsItem> settingsItems) {
|
||||||
this.settingsItems = settingsItems;
|
this.settingsItems = settingsItems;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.plus.settings.ImportSettingsFragment.IMPORT_SETTINGS_TAG;
|
import static net.osmand.plus.settings.ImportSettingsFragment.IMPORT_SETTINGS_TAG;
|
||||||
import static net.osmand.plus.settings.ImportSettingsFragment.getDuplicatesData;
|
|
||||||
|
|
||||||
|
|
||||||
public class ImportDuplicatesFragment extends BaseOsmAndFragment implements View.OnClickListener {
|
public class ImportDuplicatesFragment extends BaseOsmAndFragment implements View.OnClickListener {
|
||||||
|
@ -83,11 +82,16 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment implements View
|
||||||
if (settingsItems == null) {
|
if (settingsItems == null) {
|
||||||
settingsItems = app.getSettingsHelper().getSettingsItems();
|
settingsItems = app.getSettingsHelper().getSettingsItems();
|
||||||
if (settingsItems != null) {
|
if (settingsItems != null) {
|
||||||
duplicatesList = getDuplicatesData(settingsItems);
|
// duplicatesList = getDuplicatesData(settingsItems);
|
||||||
|
} else {
|
||||||
|
dismissFragment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
file = app.getSettingsHelper().getSettingsFile();
|
file = app.getSettingsHelper().getSettingsFile();
|
||||||
|
if (file == null) {
|
||||||
|
dismissFragment();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,6 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
private File file;
|
private File file;
|
||||||
private boolean allSelected;
|
private boolean allSelected;
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
private String fileName;
|
|
||||||
private LinearLayout buttonsContainer;
|
private LinearLayout buttonsContainer;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
private CollapsingToolbarLayout toolbarLayout;
|
private CollapsingToolbarLayout toolbarLayout;
|
||||||
|
@ -81,9 +80,15 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
nightMode = !app.getSettings().isLightContent();
|
nightMode = !app.getSettings().isLightContent();
|
||||||
if (settingsItems == null) {
|
if (settingsItems == null) {
|
||||||
settingsItems = app.getSettingsHelper().getSettingsItems();
|
settingsItems = app.getSettingsHelper().getSettingsItems();
|
||||||
|
if (settingsItems == null) {
|
||||||
|
dismissFragment();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
file = app.getSettingsHelper().getSettingsFile();
|
file = app.getSettingsHelper().getSettingsFile();
|
||||||
|
if (file == null) {
|
||||||
|
dismissFragment();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,42 +203,6 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Object> getDuplicatesData(List<SettingsItem> items) {
|
|
||||||
List<Object> duplicateItems = new ArrayList<>();
|
|
||||||
for (SettingsItem item : items) {
|
|
||||||
if (item instanceof SettingsHelper.ProfileSettingsItem) {
|
|
||||||
if (item.exists()) {
|
|
||||||
duplicateItems.add(((SettingsHelper.ProfileSettingsItem) item).getModeBean());
|
|
||||||
}
|
|
||||||
} else if (item instanceof SettingsHelper.QuickActionSettingsItem) {
|
|
||||||
List<QuickAction> duplicates = ((SettingsHelper.QuickActionSettingsItem) item).excludeDuplicateItems();
|
|
||||||
if (!duplicates.isEmpty()) {
|
|
||||||
duplicateItems.addAll(duplicates);
|
|
||||||
}
|
|
||||||
} else if (item instanceof SettingsHelper.PoiUiFilterSettingsItem) {
|
|
||||||
List<PoiUIFilter> duplicates = ((SettingsHelper.PoiUiFilterSettingsItem) item).excludeDuplicateItems();
|
|
||||||
if (!duplicates.isEmpty()) {
|
|
||||||
duplicateItems.addAll(duplicates);
|
|
||||||
}
|
|
||||||
} else if (item instanceof SettingsHelper.MapSourcesSettingsItem) {
|
|
||||||
List<ITileSource> duplicates = ((SettingsHelper.MapSourcesSettingsItem) item).excludeDuplicateItems();
|
|
||||||
if (!duplicates.isEmpty()) {
|
|
||||||
duplicateItems.addAll(duplicates);
|
|
||||||
}
|
|
||||||
} else if (item instanceof SettingsHelper.FileSettingsItem) {
|
|
||||||
if (item.exists()) {
|
|
||||||
duplicateItems.add(((SettingsHelper.FileSettingsItem) item).getFile());
|
|
||||||
}
|
|
||||||
} else if (item instanceof SettingsHelper.AvoidRoadsSettingsItem) {
|
|
||||||
List<AvoidRoadInfo> avoidRoads = ((SettingsHelper.AvoidRoadsSettingsItem) item).excludeDuplicateItems();
|
|
||||||
if (!avoidRoads.isEmpty()) {
|
|
||||||
duplicateItems.addAll(avoidRoads);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return duplicateItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSettingsItems(List<SettingsItem> settingsItems) {
|
public void setSettingsItems(List<SettingsItem> settingsItems) {
|
||||||
this.settingsItems = settingsItems;
|
this.settingsItems = settingsItems;
|
||||||
}
|
}
|
||||||
|
@ -291,10 +260,13 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
profiles.add(((SettingsHelper.ProfileSettingsItem) item).getModeBean());
|
profiles.add(((SettingsHelper.ProfileSettingsItem) item).getModeBean());
|
||||||
} else if (item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION)) {
|
} else if (item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION)) {
|
||||||
quickActions.addAll(((SettingsHelper.QuickActionSettingsItem) item).getItems());
|
quickActions.addAll(((SettingsHelper.QuickActionSettingsItem) item).getItems());
|
||||||
|
quickActions.addAll(((SettingsHelper.QuickActionSettingsItem) item).getDuplicateItems());
|
||||||
} else if (item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS)) {
|
} else if (item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS)) {
|
||||||
poiUIFilters.addAll(((SettingsHelper.PoiUiFilterSettingsItem) item).getItems());
|
poiUIFilters.addAll(((SettingsHelper.PoiUiFilterSettingsItem) item).getItems());
|
||||||
|
poiUIFilters.addAll(((SettingsHelper.PoiUiFilterSettingsItem) item).getDuplicateItems());
|
||||||
} else if (item.getType().equals(SettingsHelper.SettingsItemType.MAP_SOURCES)) {
|
} else if (item.getType().equals(SettingsHelper.SettingsItemType.MAP_SOURCES)) {
|
||||||
tileSourceTemplates.addAll(((SettingsHelper.MapSourcesSettingsItem) item).getItems());
|
tileSourceTemplates.addAll(((SettingsHelper.MapSourcesSettingsItem) item).getItems());
|
||||||
|
tileSourceTemplates.addAll(((SettingsHelper.MapSourcesSettingsItem) item).getDuplicateItems());
|
||||||
} else if (item.getType().equals(SettingsHelper.SettingsItemType.FILE)) {
|
} else if (item.getType().equals(SettingsHelper.SettingsItemType.FILE)) {
|
||||||
if (item.getName().startsWith("/rendering/")) {
|
if (item.getName().startsWith("/rendering/")) {
|
||||||
renderFilesList.add(((SettingsHelper.FileSettingsItem) item).getFile());
|
renderFilesList.add(((SettingsHelper.FileSettingsItem) item).getFile());
|
||||||
|
@ -303,6 +275,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
}
|
}
|
||||||
} else if (item.getType().equals(SettingsHelper.SettingsItemType.AVOID_ROADS)) {
|
} else if (item.getType().equals(SettingsHelper.SettingsItemType.AVOID_ROADS)) {
|
||||||
avoidRoads.addAll(((SettingsHelper.AvoidRoadsSettingsItem) item).getItems());
|
avoidRoads.addAll(((SettingsHelper.AvoidRoadsSettingsItem) item).getItems());
|
||||||
|
avoidRoads.addAll(((SettingsHelper.AvoidRoadsSettingsItem) item).getDuplicateItems());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue