From 490d42f3340a7e1cd9cfdffcdd1bcca4bb2ace0a Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sun, 21 Mar 2021 23:17:16 +0200 Subject: [PATCH 1/4] Fix last view visibility --- .../fragments/BaseSettingsListFragment.java | 21 +++++++++++++++++++ .../fragments/ExportSettingsAdapter.java | 7 ------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsListFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsListFragment.java index 70cc3e95e0..6e2129deab 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsListFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsListFragment.java @@ -6,8 +6,10 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AbsListView; import android.widget.ExpandableListView; import android.widget.LinearLayout; +import android.widget.ListView; import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; @@ -18,6 +20,8 @@ import androidx.core.view.ViewCompat; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; +import com.github.ksoichiro.android.observablescrollview.ScrollUtils; + import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -129,6 +133,7 @@ public abstract class BaseSettingsListFragment extends BaseOsmAndFragment implem adapter = new ExportSettingsAdapter(app, exportMode, this, nightMode); adapter.updateSettingsItems(dataList, selectedItemsMap); expandableList.setAdapter(adapter); + setupListView(expandableList); updateAvailableSpace(); return root; @@ -195,6 +200,22 @@ public abstract class BaseSettingsListFragment extends BaseOsmAndFragment implem }); } + private void setupListView(@NonNull final ListView listView) { + if (listView.getFooterViewsCount() == 0) { + int padding = getResources().getDimensionPixelSize(R.dimen.toolbar_height_expanded); + + View emptyView = new View(listView.getContext()); + emptyView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, padding)); + listView.addFooterView(emptyView); + ScrollUtils.addOnGlobalLayoutListener(listView, new Runnable() { + @Override + public void run() { + listView.requestLayout(); + } + }); + } + } + protected void updateAvailableSpace() { long calculatedSize = ExportSettingsAdapter.calculateItemsSize(adapter.getData()); if (calculatedSize != 0) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java index 634d317b05..360f786b77 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java @@ -58,7 +58,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter { private final int secondaryColorRes; private final int groupViewHeight; private final int childViewHeight; - private final int listBottomPadding; ExportSettingsAdapter(OsmandApplication app, boolean exportMode, OnItemSelectedListener listener, boolean nightMode) { this.app = app; @@ -71,7 +70,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter { secondaryColorRes = nightMode ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light; groupViewHeight = app.getResources().getDimensionPixelSize(R.dimen.setting_list_item_group_height); childViewHeight = app.getResources().getDimensionPixelSize(R.dimen.setting_list_item_large_height); - listBottomPadding = app.getResources().getDimensionPixelSize(R.dimen.fab_recycler_view_padding_bottom); } @Override @@ -118,9 +116,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter { } }); - boolean addPadding = !isExpanded && groupPosition == getGroupCount() - 1; - group.setPadding(0, 0, 0, addPadding ? listBottomPadding : 0); - adjustIndicator(app, groupPosition, isExpanded, group, nightMode); AndroidUiHelper.updateVisibility(group.findViewById(R.id.divider), isExpanded); AndroidUiHelper.updateVisibility(group.findViewById(R.id.card_top_divider), true); @@ -188,8 +183,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter { notifyDataSetChanged(); } }); - boolean addPadding = isLastChild && groupPosition == getGroupCount() - 1; - child.setPadding(0, 0, 0, addPadding ? listBottomPadding : 0); AndroidUiHelper.updateVisibility(child.findViewById(R.id.card_bottom_divider), isLastChild); return child; From 83870f0f458092809450f713115564887ebb77e7 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 22 Mar 2021 00:21:35 +0200 Subject: [PATCH 2/4] Fix unselected item icon color --- .../SimpleBottomSheetItem.java | 2 +- .../fragments/ExportItemsBottomSheet.java | 153 ++++++++++-------- 2 files changed, 88 insertions(+), 67 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java index bb93494214..b1cdaa6963 100644 --- a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java @@ -49,7 +49,7 @@ public class SimpleBottomSheetItem extends BaseBottomSheetItem { } - public void setTitle(String title) { + public void setTitle(CharSequence title) { this.title = title; titleTv.setText(title); } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java index 5bfed7996f..c3e318b35b 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java @@ -6,6 +6,13 @@ 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.GPXUtilities.GPXTrackAnalysis; import net.osmand.IndexConstants; @@ -61,13 +68,6 @@ import java.io.File; import java.util.ArrayList; import java.util.List; -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 static net.osmand.view.ThreeStateCheckbox.State.CHECKED; import static net.osmand.view.ThreeStateCheckbox.State.MISC; import static net.osmand.view.ThreeStateCheckbox.State.UNCHECKED; @@ -142,15 +142,21 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { selectedItems.remove(item[0].getTag()); } updateTitleView(); + setupBottomSheetItem(item[0], item[0].getTag()); } }) .setTag(object); - setupBottomSheetItem(builder, object); item[0] = builder.create(); items.add(item[0]); } } + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + updateItems(); + } + @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); @@ -177,7 +183,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { selectedItems.clear(); } updateTitleView(); - updateItems(checked); + updateItems(); } }); setupDescription(view); @@ -221,10 +227,12 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { return itemsSize; } - private void updateItems(boolean checked) { + private void updateItems() { for (BaseBottomSheetItem item : items) { - if (item instanceof BottomSheetItemWithCompoundButton) { - ((BottomSheetItemWithCompoundButton) item).setChecked(checked); + if (item instanceof BottomSheetItemWithCompoundButton && item.getTag() != null) { + BottomSheetItemWithCompoundButton bottomSheetItem = (BottomSheetItemWithCompoundButton) item; + setupBottomSheetItem(bottomSheetItem, item.getTag()); + bottomSheetItem.setChecked(selectedItems.contains(item.getTag())); } } } @@ -274,7 +282,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { return null; } - private void setupBottomSheetItem(Builder builder, Object object) { + private void setupBottomSheetItem(BottomSheetItemWithCompoundButton item, Object object) { if (object instanceof ApplicationModeBean) { ApplicationModeBean modeBean = (ApplicationModeBean) object; String profileName = modeBean.userProfileName; @@ -286,7 +294,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { profileName = StringUtils.capitalize(modeBean.stringKey); } } - builder.setTitle(profileName); + item.setTitle(profileName); String routingProfile = ""; String routingProfileValue = modeBean.routingProfile; @@ -300,122 +308,135 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { } } if (!Algorithms.isEmpty(routingProfile)) { - builder.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, getString(R.string.nav_type_hint), routingProfile)); + item.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_osmand_string)); + item.setDescription(getString(R.string.profile_type_osmand_string)); } int profileIconRes = AndroidUtils.getDrawableId(app, modeBean.iconName); ProfileIconColors iconColor = modeBean.iconColor; Integer customIconColor = modeBean.customIconColor; - int actualIconColor = customIconColor != null ? - customIconColor : ContextCompat.getColor(app, iconColor.getColor(nightMode)); - builder.setIcon(uiUtilities.getPaintedIcon(profileIconRes, actualIconColor)); + int actualIconColor; + if (selectedItems.contains(object)) { + actualIconColor = customIconColor != null ? customIconColor : ContextCompat.getColor(app, iconColor.getColor(nightMode)); + } else { + actualIconColor = ContextCompat.getColor(app, secondaryColorRes); + } + item.setIcon(uiUtilities.getPaintedIcon(profileIconRes, actualIconColor)); } else if (object instanceof QuickAction) { QuickAction quickAction = (QuickAction) object; - builder.setTitle(quickAction.getName(app)); - builder.setIcon(uiUtilities.getIcon(quickAction.getIconRes(), activeColorRes)); + item.setTitle(quickAction.getName(app)); + item.setIcon(uiUtilities.getIcon(quickAction.getIconRes(), getItemIconColor(object))); } else if (object instanceof PoiUIFilter) { PoiUIFilter poiUIFilter = (PoiUIFilter) object; - builder.setTitle(poiUIFilter.getName()); + item.setTitle(poiUIFilter.getName()); int iconRes = RenderingIcons.getBigIconResourceId(poiUIFilter.getIconId()); - builder.setIcon(uiUtilities.getIcon(iconRes != 0 ? iconRes : R.drawable.ic_action_user, activeColorRes)); + item.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)); + item.setTitle(tileSource.getName()); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_map, getItemIconColor(object))); } else if (object instanceof File) { - setupBottomSheetItemForFile(builder, (File) object); + setupBottomSheetItemForFile(item, (File) object); } else if (object instanceof GpxSettingsItem) { - GpxSettingsItem item = (GpxSettingsItem) object; - setupBottomSheetItemForGpx(builder, item.getFile(), item.getAppearanceInfo()); + GpxSettingsItem settingsItem = (GpxSettingsItem) object; + setupBottomSheetItemForGpx(item, settingsItem.getFile(), settingsItem.getAppearanceInfo()); } else if (object instanceof FileSettingsItem) { - FileSettingsItem item = (FileSettingsItem) object; - setupBottomSheetItemForFile(builder, item.getFile()); + FileSettingsItem settingsItem = (FileSettingsItem) object; + setupBottomSheetItemForFile(item, settingsItem.getFile()); } else if (object instanceof AvoidRoadInfo) { AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) object; - builder.setTitle(avoidRoadInfo.name); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_alert, activeColorRes)); + item.setTitle(avoidRoadInfo.name); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_alert, getItemIconColor(object))); } 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)); + item.setTitle(osmNotesPoint.getText()); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_osm_note_add, getItemIconColor(object))); } 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)); + item.setTitle(OsmEditingPlugin.getTitle(openstreetmapPoint, app)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_info_dark, getItemIconColor(object))); } 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)); + item.setTitle(group.getDisplayName(app)); + int color; + if (selectedItems.contains(object)) { + color = group.getColor() == 0 ? ContextCompat.getColor(app, R.color.color_favorite) : group.getColor(); + } else { + color = ContextCompat.getColor(app, secondaryColorRes); + } + item.setIcon(uiUtilities.getPaintedIcon(R.drawable.ic_action_folder, color)); int points = group.getPoints().size(); String itemsDescr = getString(R.string.shared_string_gpx_points); - builder.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, itemsDescr, points)); + item.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, itemsDescr, points)); } else if (object instanceof GlobalSettingsItem) { GlobalSettingsItem globalSettingsItem = (GlobalSettingsItem) object; - builder.setTitle(globalSettingsItem.getPublicName(app)); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_settings, activeColorRes)); + item.setTitle(globalSettingsItem.getPublicName(app)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_settings, getItemIconColor(object))); } else if (object instanceof ItineraryGroup) { ItineraryGroup markersGroup = (ItineraryGroup) 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)); + item.setTitle(getString(R.string.map_markers)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_flag, getItemIconColor(object))); } else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) { - builder.setTitle(getString(R.string.markers_history)); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, activeColorRes)); + item.setTitle(getString(R.string.markers_history)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, getItemIconColor(object))); } int selectedMarkers = markersGroup.getMarkers().size(); String itemsDescr = getString(R.string.shared_string_items); - builder.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, itemsDescr, selectedMarkers)); + item.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, itemsDescr, selectedMarkers)); } else if (object instanceof HistoryEntry) { HistoryEntry historyEntry = (HistoryEntry) object; - builder.setTitle(historyEntry.getName().getName()); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, activeColorRes)); + item.setTitle(historyEntry.getName().getName()); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, getItemIconColor(object))); } else if (object instanceof OnlineRoutingEngine) { OnlineRoutingEngine onlineRoutingEngine = (OnlineRoutingEngine) object; - builder.setTitle(onlineRoutingEngine.getName(app)); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_world_globe_dark, activeColorRes)); + item.setTitle(onlineRoutingEngine.getName(app)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_world_globe_dark, getItemIconColor(object))); } } - private void setupBottomSheetItemForFile(Builder builder, File file) { + private void setupBottomSheetItemForFile(BottomSheetItemWithCompoundButton item, File file) { FileSubtype fileSubtype = FileSubtype.getSubtypeByPath(app, file.getPath()); - builder.setTitle(file.getName()); + item.setTitle(file.getName()); if (file.getAbsolutePath().contains(IndexConstants.RENDERERS_DIR)) { - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_map_style, activeColorRes)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_map_style, getItemIconColor(item.getTag()))); } else if (file.getAbsolutePath().contains(IndexConstants.ROUTING_PROFILES_DIR)) { - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, getItemIconColor(item.getTag()))); } else if (file.getAbsolutePath().contains(IndexConstants.GPX_INDEX_DIR)) { - setupBottomSheetItemForGpx(builder, file, null); + setupBottomSheetItemForGpx(item, file, null); } 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)); - builder.setDescription(AndroidUtils.formatSize(app, file.length())); + item.setIcon(uiUtilities.getIcon(iconId, getItemIconColor(item.getTag()))); + item.setDescription(AndroidUtils.formatSize(app, file.length())); } 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)); + item.setTitle(FileNameTranslationHelper.getFileNameWithRegion(app, file.getName())); + item.setIcon(uiUtilities.getIcon(fileSubtype.getIconId(), getItemIconColor(item.getTag()))); if (fileSubtype.isMap()) { String mapDescription = getMapDescription(file); String formattedSize = AndroidUtils.formatSize(app, file.length()); if (mapDescription != null) { - builder.setDescription(getString(R.string.ltr_or_rtl_combine_via_bold_point, mapDescription, formattedSize)); + item.setDescription(getString(R.string.ltr_or_rtl_combine_via_bold_point, mapDescription, formattedSize)); } else { - builder.setDescription(formattedSize); + item.setDescription(formattedSize); } } } } - private void setupBottomSheetItemForGpx(Builder builder, File file, @Nullable GpxAppearanceInfo appearanceInfo) { - builder.setTitle(GpxUiHelper.getGpxTitle(file.getName())); - builder.setDescription(getTrackDescr(file, file.lastModified(), file.length(), appearanceInfo)); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes)); + private void setupBottomSheetItemForGpx(BottomSheetItemWithCompoundButton item, File file, @Nullable GpxAppearanceInfo appearanceInfo) { + item.setTitle(GpxUiHelper.getGpxTitle(file.getName())); + item.setDescription(getTrackDescr(file, file.lastModified(), file.length(), appearanceInfo)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, getItemIconColor(item.getTag()))); + } + + private int getItemIconColor(Object object) { + return selectedItems.contains(object) ? activeColorRes : secondaryColorRes; } private final GpxDataItemCallback gpxDataItemCallback = new GpxDataItemCallback() { From a8c732df4ec4212dd823daa31b4bef713df9a479 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 22 Mar 2021 10:52:49 +0200 Subject: [PATCH 3/4] Fix multimedia files export UI --- .../audionotes/AudioVideoNotesPlugin.java | 2 +- .../backend/backup/SettingsHelper.java | 4 ++-- .../fragments/DuplicatesSettingsAdapter.java | 10 +++++---- .../fragments/ExportItemsBottomSheet.java | 22 +++++++++++++++++++ 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index f6d5f5c287..0bf4bb55fb 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -317,7 +317,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { } } - private String formatDateTime(Context ctx, long dateTime) { + public static String formatDateTime(Context ctx, long dateTime) { DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(ctx); DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(ctx); return dateFormat.format(dateTime) + " " + timeFormat.format(dateTime); diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java index 0e3b9612cc..61a429f05f 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java @@ -900,11 +900,11 @@ public class SettingsHelper { List tileSourceTemplates = new ArrayList<>(); List routingFilesList = new ArrayList<>(); List renderFilesList = new ArrayList<>(); - List multimediaFilesList = new ArrayList<>(); List ttsVoiceFilesList = new ArrayList<>(); List voiceFilesList = new ArrayList<>(); List mapFilesList = new ArrayList<>(); List tracksFilesList = new ArrayList<>(); + List multimediaFilesList = new ArrayList<>(); List avoidRoads = new ArrayList<>(); List globalSettingsItems = new ArrayList<>(); List notesPointList = new ArrayList<>(); @@ -927,7 +927,7 @@ public class SettingsHelper { } else if (fileItem.getSubtype() == FileSubtype.ROUTING_CONFIG) { routingFilesList.add(fileItem.getFile()); } else if (fileItem.getSubtype() == FileSubtype.MULTIMEDIA_NOTES) { - multimediaFilesList.add(fileItem.getFile()); + multimediaFilesList.add(fileItem); } else if (fileItem.getSubtype() == FileSubtype.GPX) { tracksFilesList.add(fileItem); } else if (fileItem.getSubtype().isMap()) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java index 4b8e40f1a0..12a046339a 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java @@ -6,6 +6,10 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.RecyclerView; + import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; @@ -15,6 +19,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; +import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.GpxUiHelper; @@ -36,10 +41,6 @@ import org.apache.commons.logging.Log; import java.io.File; import java.util.List; -import androidx.annotation.NonNull; -import androidx.core.content.ContextCompat; -import androidx.recyclerview.widget.RecyclerView; - import static net.osmand.plus.settings.backend.backup.FileSettingsItem.FileSubtype; public class DuplicatesSettingsAdapter extends RecyclerView.Adapter { @@ -154,6 +155,7 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter Date: Mon, 22 Mar 2021 10:54:44 +0200 Subject: [PATCH 4/4] Fix possible npe --- .../net/osmand/plus/settings/backend/EnumStringPreference.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/EnumStringPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/EnumStringPreference.java index a88a17fed3..662c773172 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/EnumStringPreference.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/EnumStringPreference.java @@ -30,7 +30,7 @@ public class EnumStringPreference> extends CommonPreference @Override protected String toString(E o) { - return o.name(); + return o == null ? null : o.name(); } @Override