Merge pull request #8671 from osmandapp/import_export_fixes
Import export fixes
This commit is contained in:
commit
f3f323ce7c
7 changed files with 92 additions and 36 deletions
|
@ -16,7 +16,6 @@
|
|||
android:focusable="false"
|
||||
android:groupIndicator="@android:color/transparent"
|
||||
android:listSelector="@android:color/transparent"
|
||||
android:paddingBottom="@dimen/dialog_button_ex_height"
|
||||
osmand:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
|
@ -100,6 +101,9 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height_expanded"
|
||||
android:background="?attr/colorPrimary"
|
||||
osmand:expandedTitleMarginBottom="@dimen/content_padding_small"
|
||||
osmand:expandedTitleMarginEnd="@dimen/content_padding"
|
||||
osmand:expandedTitleMarginStart="@dimen/content_padding"
|
||||
osmand:collapsedTitleTextAppearance="@style/AppBarTitle"
|
||||
osmand:expandedTitleGravity="start|bottom"
|
||||
osmand:expandedTitleTextAppearance="@style/AppBarTitle"
|
||||
|
@ -110,6 +114,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:minHeight="@dimen/toolbar_height"
|
||||
osmand:titleMarginEnd="0dp"
|
||||
osmand:titleMarginStart="0dp"
|
||||
osmand:layout_collapseMode="pin"
|
||||
osmand:layout_scrollFlags="scroll|enterAlways|exitUntilCollapsed"
|
||||
osmand:title="@string/shared_string_import_complete"/>
|
||||
|
|
|
@ -36,12 +36,16 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
|
|||
private OsmandApplication app;
|
||||
private UiUtilities uiUtilities;
|
||||
private List<? super Object> items;
|
||||
private int activeColorRes;
|
||||
|
||||
DuplicatesSettingsAdapter(OsmandApplication app, List<? super Object> items, boolean nightMode) {
|
||||
this.app = app;
|
||||
this.items = items;
|
||||
this.nightMode = nightMode;
|
||||
this.uiUtilities = app.getUIUtilities();
|
||||
uiUtilities = app.getUIUtilities();
|
||||
activeColorRes = nightMode
|
||||
? R.color.icon_color_active_dark
|
||||
: R.color.icon_color_active_light;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -90,41 +94,34 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
|
|||
int profileIconRes = AndroidUtils.getDrawableId(app, modeBean.iconName);
|
||||
ProfileIconColors iconColor = modeBean.iconColor;
|
||||
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(profileIconRes, iconColor.getColor(nightMode)));
|
||||
itemHolder.icon.setVisibility(View.VISIBLE);
|
||||
} else if (currentItem instanceof QuickAction) {
|
||||
QuickAction action = (QuickAction) currentItem;
|
||||
itemHolder.title.setText(action.getName(app));
|
||||
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(action.getIconRes(), nightMode));
|
||||
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(action.getIconRes(), activeColorRes));
|
||||
itemHolder.subTitle.setVisibility(View.GONE);
|
||||
itemHolder.icon.setVisibility(View.VISIBLE);
|
||||
} else if (currentItem instanceof PoiUIFilter) {
|
||||
PoiUIFilter filter = (PoiUIFilter) currentItem;
|
||||
itemHolder.title.setText(filter.getName());
|
||||
int iconRes = RenderingIcons.getBigIconResourceId(filter.getIconId());
|
||||
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(iconRes != 0 ? iconRes : R.drawable.ic_person, nightMode));
|
||||
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(iconRes != 0 ? iconRes : R.drawable.ic_person, activeColorRes));
|
||||
itemHolder.subTitle.setVisibility(View.GONE);
|
||||
itemHolder.icon.setVisibility(View.VISIBLE);
|
||||
} else if (currentItem instanceof ITileSource) {
|
||||
itemHolder.title.setText(((ITileSource) currentItem).getName());
|
||||
itemHolder.icon.setImageResource(R.drawable.ic_action_info_dark);
|
||||
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_map, activeColorRes));
|
||||
itemHolder.subTitle.setVisibility(View.GONE);
|
||||
itemHolder.icon.setVisibility(View.INVISIBLE);
|
||||
} else if (currentItem instanceof File) {
|
||||
File file = (File) currentItem;
|
||||
itemHolder.title.setText(file.getName());
|
||||
if (file.getName().contains(IndexConstants.RENDERERS_DIR)) {
|
||||
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_map_style, nightMode));
|
||||
itemHolder.icon.setVisibility(View.VISIBLE);
|
||||
} else if (file.getName().contains(IndexConstants.ROUTING_PROFILES_DIR)) {
|
||||
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_route_distance, nightMode));
|
||||
itemHolder.icon.setVisibility(View.VISIBLE);
|
||||
if (file.getAbsolutePath().contains(IndexConstants.RENDERERS_DIR)) {
|
||||
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_map_style, activeColorRes));
|
||||
} else if (file.getAbsolutePath().contains(IndexConstants.ROUTING_PROFILES_DIR)) {
|
||||
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
|
||||
}
|
||||
itemHolder.subTitle.setVisibility(View.GONE);
|
||||
} else if (currentItem instanceof AvoidRoadInfo) {
|
||||
itemHolder.title.setText(((AvoidRoadInfo) currentItem).name);
|
||||
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_alert, nightMode));
|
||||
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_alert, activeColorRes));
|
||||
itemHolder.subTitle.setVisibility(View.GONE);
|
||||
itemHolder.icon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
itemHolder.divider.setVisibility(shouldShowDivider(position) ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
|
|
@ -42,12 +42,13 @@ import static net.osmand.view.ThreeStateCheckbox.State.UNCHECKED;
|
|||
class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||
|
||||
private OsmandApplication app;
|
||||
private UiUtilities uiUtilities;
|
||||
private List<? super Object> dataToOperate;
|
||||
private Map<Type, List<?>> itemsMap;
|
||||
private List<Type> itemsTypes;
|
||||
private boolean nightMode;
|
||||
private boolean importState;
|
||||
private int profileColor;
|
||||
private int activeColorRes;
|
||||
|
||||
ExportImportSettingsAdapter(OsmandApplication app, boolean nightMode, boolean importState) {
|
||||
this.app = app;
|
||||
|
@ -56,7 +57,11 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
this.itemsMap = new HashMap<>();
|
||||
this.itemsTypes = new ArrayList<>();
|
||||
this.dataToOperate = new ArrayList<>();
|
||||
this.profileColor = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode);
|
||||
dataToOperate = new ArrayList<>();
|
||||
uiUtilities = app.getUIUtilities();
|
||||
activeColorRes = nightMode
|
||||
? R.color.icon_color_active_dark
|
||||
: R.color.icon_color_active_light;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,7 +88,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
lineDivider.setVisibility(importState || isExpanded || isLastGroup ? View.GONE : View.VISIBLE);
|
||||
cardTopDivider.setVisibility(importState ? View.VISIBLE : View.GONE);
|
||||
cardBottomDivider.setVisibility(importState && !isExpanded ? View.VISIBLE : View.GONE);
|
||||
CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, profileColor)));
|
||||
CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, activeColorRes)));
|
||||
|
||||
final List<?> listItems = itemsMap.get(type);
|
||||
subTextTv.setText(String.valueOf(listItems.size()));
|
||||
|
@ -130,6 +135,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
final Object currentItem = itemsMap.get(itemsTypes.get(groupPosition)).get(childPosition);
|
||||
|
||||
boolean isLastGroup = groupPosition == getGroupCount() - 1;
|
||||
boolean itemSelected = dataToOperate.contains(currentItem);
|
||||
final Type type = itemsTypes.get(groupPosition);
|
||||
|
||||
TextView title = child.findViewById(R.id.title_tv);
|
||||
|
@ -141,9 +147,9 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
|
||||
lineDivider.setVisibility(!importState && isLastChild && !isLastGroup ? View.VISIBLE : View.GONE);
|
||||
cardBottomDivider.setVisibility(importState && isLastChild ? View.VISIBLE : View.GONE);
|
||||
CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, profileColor)));
|
||||
CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, activeColorRes)));
|
||||
|
||||
checkBox.setChecked(dataToOperate.contains(currentItem));
|
||||
checkBox.setChecked(itemSelected);
|
||||
checkBox.setClickable(false);
|
||||
child.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -177,49 +183,42 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
}
|
||||
int profileIconRes = AndroidUtils.getDrawableId(app, ((ApplicationMode.ApplicationModeBean) currentItem).iconName);
|
||||
ProfileIconColors iconColor = ((ApplicationMode.ApplicationModeBean) currentItem).iconColor;
|
||||
icon.setImageDrawable(app.getUIUtilities().getIcon(profileIconRes, iconColor.getColor(nightMode)));
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
icon.setImageDrawable(uiUtilities.getIcon(profileIconRes, iconColor.getColor(nightMode)));
|
||||
break;
|
||||
case QUICK_ACTIONS:
|
||||
title.setText(((QuickAction) currentItem).getName(app.getApplicationContext()));
|
||||
icon.setImageDrawable(app.getUIUtilities().getIcon(((QuickAction) currentItem).getIconRes(), nightMode));
|
||||
setupIcon(icon, ((QuickAction) currentItem).getIconRes(), itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case POI_TYPES:
|
||||
title.setText(((PoiUIFilter) currentItem).getName());
|
||||
int iconRes = RenderingIcons.getBigIconResourceId(((PoiUIFilter) currentItem).getIconId());
|
||||
icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes != 0 ? iconRes : R.drawable.ic_person, profileColor));
|
||||
setupIcon(icon, iconRes != 0 ? iconRes : R.drawable.ic_person, itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case MAP_SOURCES:
|
||||
title.setText(((ITileSource) currentItem).getName());
|
||||
icon.setImageResource(R.drawable.ic_action_info_dark);
|
||||
setupIcon(icon, R.drawable.ic_map, itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
icon.setVisibility(View.INVISIBLE);
|
||||
break;
|
||||
case CUSTOM_RENDER_STYLE:
|
||||
String renderName = ((File) currentItem).getName();
|
||||
renderName = renderName.replace('_', ' ').replaceAll(IndexConstants.RENDERER_INDEX_EXT, "");
|
||||
title.setText(renderName);
|
||||
icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_map_style, nightMode));
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
setupIcon(icon, R.drawable.ic_action_map_style, itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
break;
|
||||
case CUSTOM_ROUTING:
|
||||
String routingName = ((File) currentItem).getName();
|
||||
routingName = routingName.replace('_', ' ').replaceAll(".xml", "");
|
||||
title.setText(routingName);
|
||||
icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_route_distance, nightMode));
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
setupIcon(icon, R.drawable.ic_action_route_distance, itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
break;
|
||||
case AVOID_ROADS:
|
||||
AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) currentItem;
|
||||
title.setText(avoidRoadInfo.name);
|
||||
icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_alert, nightMode));
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
setupIcon(icon, R.drawable.ic_action_alert, itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
break;
|
||||
default:
|
||||
|
@ -289,6 +288,14 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
private void setupIcon(ImageView icon, int iconRes, boolean itemSelected) {
|
||||
if (itemSelected) {
|
||||
icon.setImageDrawable(uiUtilities.getIcon(iconRes, activeColorRes));
|
||||
} else {
|
||||
icon.setImageDrawable(uiUtilities.getIcon(iconRes, nightMode));
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSettingsList(Map<Type, List<?>> itemsMap) {
|
||||
this.itemsMap = itemsMap;
|
||||
this.itemsTypes = new ArrayList<>(itemsMap.keySet());
|
||||
|
|
|
@ -8,6 +8,8 @@ import android.text.style.StyleSpan;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -71,6 +73,7 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
|||
View root = inflater.inflate(R.layout.fragment_import_complete, container, false);
|
||||
TextView description = root.findViewById(R.id.description);
|
||||
TextView btnClose = root.findViewById(R.id.button_close);
|
||||
final LinearLayout buttonContainer = root.findViewById(R.id.button_container);
|
||||
recyclerView = root.findViewById(R.id.list);
|
||||
description.setText(UiUtilities.createSpannableString(
|
||||
String.format(getString(R.string.import_complete_description), fileName),
|
||||
|
@ -86,6 +89,20 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
|||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
AndroidUtils.addStatusBarPadding21v(app, root);
|
||||
}
|
||||
ViewTreeObserver treeObserver = buttonContainer.getViewTreeObserver();
|
||||
treeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
ViewTreeObserver vts = buttonContainer.getViewTreeObserver();
|
||||
int height = buttonContainer.getMeasuredHeight();
|
||||
recyclerView.setPadding(0, 0, 0, height);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
vts.removeOnGlobalLayoutListener(this);
|
||||
} else {
|
||||
vts.removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
return root;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import android.widget.TextView;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
@ -122,6 +123,7 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment implements View
|
|||
keepBothBtn.setOnClickListener(this);
|
||||
replaceAllBtn.setOnClickListener(this);
|
||||
list = root.findViewById(R.id.list);
|
||||
ViewCompat.setNestedScrollingEnabled(list, false);
|
||||
ViewTreeObserver treeObserver = buttonsContainer.getViewTreeObserver();
|
||||
treeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Typeface;
|
||||
|
@ -9,6 +10,7 @@ import android.text.style.StyleSpan;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
@ -36,6 +38,7 @@ import net.osmand.plus.SQLiteTileSource;
|
|||
import net.osmand.plus.SettingsHelper;
|
||||
import net.osmand.plus.SettingsHelper.*;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
|
@ -119,6 +122,22 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
|||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
AndroidUtils.addStatusBarPadding21v(app, root);
|
||||
}
|
||||
ViewTreeObserver treeObserver = buttonsContainer.getViewTreeObserver();
|
||||
treeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
if (buttonsContainer != null) {
|
||||
ViewTreeObserver vts = buttonsContainer.getViewTreeObserver();
|
||||
int height = buttonsContainer.getMeasuredHeight();
|
||||
expandableList.setPadding(0, 0, 0, height);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
vts.removeOnGlobalLayoutListener(this);
|
||||
} else {
|
||||
vts.removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return root;
|
||||
}
|
||||
|
||||
|
@ -167,6 +186,15 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
|||
outState.putLong(DUPLICATES_START_TIME_KEY, duplicateStartTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
Activity activity = getActivity();
|
||||
if (activity instanceof MapActivity) {
|
||||
((MapActivity) activity).closeDrawer();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
|
|
Loading…
Reference in a new issue