import complete screen
This commit is contained in:
parent
5b9c9245fd
commit
72971f3e13
8 changed files with 130 additions and 32 deletions
|
@ -127,6 +127,10 @@
|
|||
|
||||
</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"
|
||||
|
@ -134,6 +138,18 @@
|
|||
android:src="@drawable/preference_activity_action_bar_shadow"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_bar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true"
|
||||
android:minHeight="0dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
|
|
@ -124,18 +124,34 @@
|
|||
android:minHeight="@dimen/toolbar_height"
|
||||
osmand:layout_collapseMode="pin"
|
||||
osmand:layout_scrollFlags="scroll|enterAlways|exitUntilCollapsed"
|
||||
osmand:title="@string/import_duplicates_title">
|
||||
tools:title="@string/import_duplicates_title">
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/shadowView"
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/abp__shadow_height"
|
||||
android:src="@drawable/preference_activity_action_bar_shadow"
|
||||
tools:ignore="ContentDescription" />
|
||||
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
|
||||
android:id="@+id/progress_bar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="0dp"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="shared_string_importing">Importing</string>
|
||||
<string name="checking_for_duplicate_description">OsmAnd check %1$s for duplicates with existing items in the application. It may take some time.</string>
|
||||
<string name="added_one_item">Added: %1$s item</string>
|
||||
<string name="added_two_items">Added: %1$s items</string>
|
||||
<string name="added_five_items">Added: %1$s items</string>
|
||||
|
|
|
@ -140,6 +140,7 @@ import net.osmand.plus.settings.BaseSettingsFragment;
|
|||
import net.osmand.plus.settings.BaseSettingsFragment.SettingsScreenType;
|
||||
import net.osmand.plus.settings.ConfigureProfileFragment;
|
||||
import net.osmand.plus.settings.DataStorageFragment;
|
||||
import net.osmand.plus.settings.ImportCompleteFragment;
|
||||
import net.osmand.plus.settings.ImportSettingsFragment;
|
||||
import net.osmand.plus.settings.ProfileAppearanceFragment;
|
||||
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
|
||||
|
@ -738,6 +739,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
importSettingsFragment.showExitDialog();
|
||||
return;
|
||||
}
|
||||
ImportCompleteFragment importCompleteFragment = getImportCompleteFragment();
|
||||
if (importCompleteFragment != null) {
|
||||
importCompleteFragment.dismissFragment();
|
||||
return;
|
||||
}
|
||||
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
@ -2457,6 +2463,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
return getFragment(ImportSettingsFragment.TAG);
|
||||
}
|
||||
|
||||
public ImportCompleteFragment getImportCompleteFragment() {
|
||||
return getFragment(ImportCompleteFragment.TAG);
|
||||
}
|
||||
|
||||
public void backToConfigureProfileFragment() {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
int backStackEntryCount = fragmentManager.getBackStackEntryCount();
|
||||
|
|
|
@ -114,7 +114,7 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
|
|||
if (file.getName().contains("/rendering/")) {
|
||||
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_map_style, nightMode));
|
||||
itemHolder.icon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
} else if (file.getName().contains("/routing/")) {
|
||||
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_route_distance, nightMode));
|
||||
itemHolder.icon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import net.osmand.plus.search.QuickSearchDialogFragment;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.settings.ImportSettingsFragment.IMPORT_SETTINGS_TAG;
|
||||
import static net.osmand.plus.settings.ImportSettingsFragment.getSettingsToOperate;
|
||||
|
||||
public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||
|
@ -47,7 +48,10 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
|||
ImportCompleteFragment fragment = new ImportCompleteFragment();
|
||||
fragment.setSettingsItems(settingsItems);
|
||||
fragment.setFileName(fileName);
|
||||
fm.beginTransaction().replace(R.id.fragmentContainer, fragment).addToBackStack(null).commit();
|
||||
fm.beginTransaction()
|
||||
.replace(R.id.fragmentContainer, fragment, TAG)
|
||||
.addToBackStack(IMPORT_SETTINGS_TAG)
|
||||
.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,15 +74,18 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
|||
inflater = UiUtilities.getInflater(app, nightMode);
|
||||
View root = inflater.inflate(R.layout.fragment_import_complete, container, false);
|
||||
TextView description = root.findViewById(R.id.description);
|
||||
description.setText(AndroidUtils.getStyledString(
|
||||
String.format(getString(R.string.checking_for_duplicate_description), fileName),
|
||||
fileName,
|
||||
new StyleSpan(Typeface.BOLD),
|
||||
null));
|
||||
|
||||
setupDescription(description);
|
||||
TextView btnClose = root.findViewById(R.id.button_close);
|
||||
btnClose.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
FragmentManager fm = getFragmentManager();
|
||||
if (fm != null) {
|
||||
fm.popBackStackImmediate();
|
||||
}
|
||||
dismissFragment();
|
||||
}
|
||||
});
|
||||
recyclerView = root.findViewById(R.id.list);
|
||||
|
@ -111,6 +118,13 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
|||
outState.putString(FILE_NAME_KEY, fileName);
|
||||
}
|
||||
|
||||
public void dismissFragment() {
|
||||
FragmentManager fm = getFragmentManager();
|
||||
if (fm != null) {
|
||||
getFragmentManager().popBackStack(IMPORT_SETTINGS_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
}
|
||||
}
|
||||
|
||||
private void navigateTo(AdditionalDataWrapper.Type type) {
|
||||
FragmentManager fm = getFragmentManager();
|
||||
if (fm == null) {
|
||||
|
@ -148,16 +162,10 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
|||
default:
|
||||
return;
|
||||
}
|
||||
for (Fragment f : fm.getFragments()) {
|
||||
if (f instanceof NavigationFragment) {
|
||||
continue;
|
||||
} else if (f != null) {
|
||||
fm.beginTransaction().remove(fragment).commit();
|
||||
}
|
||||
}
|
||||
dismissFragment();
|
||||
fm.beginTransaction()
|
||||
.add(R.id.fragmentContainer, fragment, TAG)
|
||||
.commitAllowingStateLoss();
|
||||
.replace(R.id.fragmentContainer, fragment, TAG)
|
||||
.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.map.ITileSource;
|
||||
|
@ -38,6 +39,7 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.settings.ImportSettingsFragment.IMPORT_SETTINGS_TAG;
|
||||
import static net.osmand.plus.settings.ImportSettingsFragment.getDuplicatesData;
|
||||
|
||||
|
||||
|
@ -52,6 +54,8 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment implements View
|
|||
private List<SettingsItem> settingsItems;
|
||||
private File file;
|
||||
private boolean nightMode;
|
||||
private ProgressBar progressBar;
|
||||
private Toolbar toolbar;
|
||||
|
||||
public static void showInstance(@NonNull FragmentManager fm, List<? super Object> duplicatesList,
|
||||
List<SettingsItem> settingsItems, File file) {
|
||||
|
@ -59,7 +63,10 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment implements View
|
|||
fragment.setDuplicatesList(duplicatesList);
|
||||
fragment.setSettingsItems(settingsItems);
|
||||
fragment.setFile(file);
|
||||
fm.beginTransaction().replace(R.id.fragmentContainer, fragment, TAG).addToBackStack(null).commit();
|
||||
fm.beginTransaction()
|
||||
.replace(R.id.fragmentContainer, fragment, TAG)
|
||||
.addToBackStack(IMPORT_SETTINGS_TAG)
|
||||
.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,11 +88,13 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment implements View
|
|||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
inflater = UiUtilities.getInflater(app, nightMode);
|
||||
View root = inflater.inflate(R.layout.fragment_import_duplicates, container, false);
|
||||
setupToolbar((Toolbar) root.findViewById(R.id.toolbar));
|
||||
toolbar = root.findViewById(R.id.toolbar);
|
||||
setupToolbar(toolbar);
|
||||
ComplexButton replaceAllBtn = root.findViewById(R.id.replace_all_btn);
|
||||
ComplexButton keepBothBtn = root.findViewById(R.id.keep_both_btn);
|
||||
buttonsContainer = root.findViewById(R.id.buttons_container);
|
||||
nestedScroll = root.findViewById(R.id.nested_scroll);
|
||||
progressBar = root.findViewById(R.id.progress_bar);
|
||||
keepBothBtn.setIcon(getPaintedContentIcon(R.drawable.ic_action_keep_both,
|
||||
nightMode
|
||||
? getResources().getColor(R.color.icon_color_active_dark)
|
||||
|
@ -211,7 +220,18 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment implements View
|
|||
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
|
||||
}
|
||||
|
||||
private void dismissFragment() {
|
||||
FragmentManager fm = getFragmentManager();
|
||||
if (fm != null) {
|
||||
fm.popBackStack(IMPORT_SETTINGS_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
}
|
||||
}
|
||||
|
||||
private void importItems(boolean shouldReplace) {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
list.setVisibility(View.GONE);
|
||||
buttonsContainer.setVisibility(View.GONE);
|
||||
toolbar.setTitle(getString(R.string.shared_string_importing));
|
||||
for (SettingsItem item : settingsItems) {
|
||||
item.setShouldReplace(shouldReplace);
|
||||
}
|
||||
|
@ -238,6 +258,7 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment implements View
|
|||
}
|
||||
|
||||
private void setupToolbar(Toolbar toolbar) {
|
||||
toolbar.setTitle(R.string.import_duplicates_title);
|
||||
toolbar.setNavigationIcon(getPaintedContentIcon(R.drawable.ic_arrow_back,
|
||||
nightMode
|
||||
? getResources().getColor(R.color.active_buttons_and_links_text_dark)
|
||||
|
@ -249,7 +270,6 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment implements View
|
|||
FragmentManager fm = getFragmentManager();
|
||||
if (fm != null) {
|
||||
fm.popBackStackImmediate();
|
||||
ImportSettingsFragment.showInstance(fm, null, file);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2,15 +2,16 @@ package net.osmand.plus.settings;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -35,6 +36,8 @@ import net.osmand.plus.profiles.AdditionalDataWrapper;
|
|||
import net.osmand.plus.quickaction.QuickAction;
|
||||
import net.osmand.plus.widgets.TextViewEx;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -43,6 +46,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
|||
implements View.OnClickListener {
|
||||
|
||||
public static final String TAG = ImportSettingsFragment.class.getSimpleName();
|
||||
public static final String IMPORT_SETTINGS_TAG = "import_settings_tag";
|
||||
private OsmandApplication app;
|
||||
private ExportImportSettingsAdapter adapter;
|
||||
private ExpandableListView expandableList;
|
||||
|
@ -51,12 +55,17 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
|||
private File file;
|
||||
private boolean allSelected;
|
||||
private boolean nightMode;
|
||||
private Toolbar toolbar;
|
||||
private TextView description;
|
||||
|
||||
public static void showInstance(@NonNull FragmentManager fm, List<SettingsItem> settingsItems, @NonNull File file) {
|
||||
ImportSettingsFragment fragment = new ImportSettingsFragment();
|
||||
fragment.setSettingsItems(settingsItems);
|
||||
fragment.setFile(file);
|
||||
fm.beginTransaction().replace(R.id.fragmentContainer, fragment, TAG).addToBackStack(null).commit();
|
||||
fm.beginTransaction().
|
||||
replace(R.id.fragmentContainer, fragment, TAG)
|
||||
.addToBackStack(IMPORT_SETTINGS_TAG)
|
||||
.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,13 +86,14 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
|||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
inflater = UiUtilities.getInflater(app, nightMode);
|
||||
View root = inflater.inflate(R.layout.fragment_import, container, false);
|
||||
setupToolbar((Toolbar) root.findViewById(R.id.toolbar));
|
||||
toolbar = root.findViewById(R.id.toolbar);
|
||||
setupToolbar(toolbar);
|
||||
TextViewEx continueBtn = root.findViewById(R.id.continue_button);
|
||||
selectBtn = root.findViewById(R.id.select_button);
|
||||
expandableList = root.findViewById(R.id.list);
|
||||
ViewCompat.setNestedScrollingEnabled(expandableList, true);
|
||||
View header = inflater.inflate(R.layout.list_item_description_header, container, false);
|
||||
TextView description = header.findViewById(R.id.description);
|
||||
description = header.findViewById(R.id.description);
|
||||
description.setText(R.string.select_data_to_import);
|
||||
expandableList.addHeaderView(header);
|
||||
continueBtn.setOnClickListener(this);
|
||||
|
@ -122,6 +132,13 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
|||
}
|
||||
|
||||
private void importItems() {
|
||||
description.setText(AndroidUtils.getStyledString(
|
||||
String.format(getString(R.string.checking_for_duplicate_description), file.getName()),
|
||||
file.getName(),
|
||||
new StyleSpan(Typeface.BOLD),
|
||||
null));
|
||||
|
||||
final FragmentManager fm = getFragmentManager();
|
||||
List<SettingsItem> settingsItems = getSettingsItemsFromData(adapter.getDataToOperate());
|
||||
List<Object> duplicateItems = getDuplicatesData(settingsItems);
|
||||
if (duplicateItems.isEmpty()) {
|
||||
|
@ -129,24 +146,32 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
|||
@Override
|
||||
public void onSettingsImportFinished(boolean succeed, boolean empty, @NonNull List<SettingsHelper.SettingsItem> items) {
|
||||
if (succeed) {
|
||||
app.showShortToastMessage(app.getString(R.string.file_imported_successfully, file.getName()));
|
||||
app.getRendererRegistry().updateExternalRenderers();
|
||||
AppInitializer.loadRoutingFiles(app, new AppInitializer.LoadRoutingFilesCallback() {
|
||||
@Override
|
||||
public void onRoutingFilesLoaded() {
|
||||
}
|
||||
});
|
||||
FragmentManager fm = getFragmentManager();
|
||||
if (fm != null) {
|
||||
ImportCompleteFragment.showInstance(fm, items, file.getName());
|
||||
}
|
||||
} else if (empty) {
|
||||
app.showShortToastMessage(app.getString(R.string.file_import_error, file.getName(), app.getString(R.string.shared_string_unexpected_error)));
|
||||
dismissFragment();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ImportDuplicatesFragment.showInstance(requireActivity().getSupportFragmentManager(), duplicateItems, settingsItems, file);
|
||||
if (fm != null) {
|
||||
ImportDuplicatesFragment.showInstance(fm, duplicateItems, settingsItems, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dismissFragment() {
|
||||
FragmentManager fm = getFragmentManager();
|
||||
if (fm != null) {
|
||||
getFragmentManager().popBackStack(IMPORT_SETTINGS_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,7 +341,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
FragmentManager fm = getFragmentManager();
|
||||
if (fm != null) {
|
||||
fm.popBackStackImmediate();
|
||||
fm.popBackStack(IMPORT_SETTINGS_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -334,6 +359,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
|||
showExitDialog();
|
||||
}
|
||||
});
|
||||
toolbar.setTitle(R.string.shared_string_import);
|
||||
}
|
||||
|
||||
public void setFile(File file) {
|
||||
|
|
Loading…
Reference in a new issue