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/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/mapcontextmenu/editors/WptPtEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java index 0e583392ba..827151a691 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java @@ -20,15 +20,16 @@ import net.osmand.data.FavouritePoint.BackgroundType; import net.osmand.data.LatLon; import net.osmand.data.WptLocationPoint; import net.osmand.plus.GpxSelectionHelper; +import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.base.PointImageDrawable; +import net.osmand.plus.itinerary.ItineraryGroup; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener; -import net.osmand.plus.itinerary.ItineraryGroup; import net.osmand.plus.track.SaveGpxAsyncTask; import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.util.Algorithms; @@ -213,6 +214,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { String description = Algorithms.isEmpty(getDescriptionTextValue()) ? null : getDescriptionTextValue(); if (editor.isNew()) { doAddWpt(name, category, description); + wpt = getWpt(); } else { doUpdateWpt(name, category, description); } @@ -222,7 +224,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { } MapContextMenu menu = mapActivity.getContextMenu(); - if (menu.getLatLon() != null && menu.isActive()) { + if (menu.getLatLon() != null && menu.isActive() && wpt != null) { LatLon latLon = new LatLon(wpt.getLatitude(), wpt.getLongitude()); if (menu.getLatLon().equals(latLon)) { menu.update(latLon, new WptLocationPoint(wpt).getPointDescription(mapActivity), wpt); @@ -402,7 +404,9 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { } @Override - public String getAddressInitValue() { return ""; } + public String getAddressInitValue() { + return ""; + } @Override public Drawable getNameIcon() { @@ -480,6 +484,25 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { return 0; } + @Override + protected boolean isCategoryVisible(String name) { + WptPtEditor editor = getWptPtEditor(); + if (selectedGpxHelper == null || editor == null || editor.getGpxFile() == null) { + return true; + } + SelectedGpxFile selectedGpxFile; + if (editor.getGpxFile().showCurrentTrack) { + selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); + } else { + selectedGpxFile = selectedGpxHelper.getSelectedFileByPath(editor.getGpxFile().path); + } + if (selectedGpxFile != null) { + Set hiddenGroups = selectedGpxFile.getHiddenGroups(); + return !hiddenGroups.contains(name); + } + return true; + } + private void saveGpx(final OsmandApplication app, final GPXFile gpxFile, final boolean gpxSelected) { new SaveGpxAsyncTask(new File(gpxFile.path), gpxFile, new SaveGpxListener() { @Override 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 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/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/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 getGroups() { return adapter.groups; } @@ -263,9 +269,7 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O @Override public void onPointsDeleted() { - selectedItems.clear(); - selectedGroups.clear(); - adapter.synchronizeGroups(getDisplayGroups()); + updateGroups(); } public void filter(String text) { diff --git a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java index f525c60fbd..d5da3f9c6d 100644 --- a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java +++ b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java @@ -147,6 +147,7 @@ public class AddGpxPointBottomSheetHelper implements OnDismissListener { private void onClose() { TrackMenuFragment fragment = mapActivity.getTrackMenuFragment(); if (fragment != null) { + fragment.updateContent(); fragment.show(); } else { TrackMenuFragment.openTrack(mapActivity, new File(newGpxPoint.getGpx().path), null);