Merge pull request #11237 from osmandapp/master

update test branch
This commit is contained in:
Hardy 2021-03-23 20:17:05 +01:00 committed by GitHub
commit e14dfff0cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 175 additions and 88 deletions

View file

@ -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 dateFormat = android.text.format.DateFormat.getMediumDateFormat(ctx);
DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(ctx); DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(ctx);
return dateFormat.format(dateTime) + " " + timeFormat.format(dateTime); return dateFormat.format(dateTime) + " " + timeFormat.format(dateTime);

View file

@ -49,7 +49,7 @@ public class SimpleBottomSheetItem extends BaseBottomSheetItem {
} }
public void setTitle(String title) { public void setTitle(CharSequence title) {
this.title = title; this.title = title;
titleTv.setText(title); titleTv.setText(title);
} }

View file

@ -20,15 +20,16 @@ import net.osmand.data.FavouritePoint.BackgroundType;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.WptLocationPoint; import net.osmand.data.WptLocationPoint;
import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.base.PointImageDrawable; import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.itinerary.ItineraryGroup;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener; 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;
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -213,6 +214,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
String description = Algorithms.isEmpty(getDescriptionTextValue()) ? null : getDescriptionTextValue(); String description = Algorithms.isEmpty(getDescriptionTextValue()) ? null : getDescriptionTextValue();
if (editor.isNew()) { if (editor.isNew()) {
doAddWpt(name, category, description); doAddWpt(name, category, description);
wpt = getWpt();
} else { } else {
doUpdateWpt(name, category, description); doUpdateWpt(name, category, description);
} }
@ -222,7 +224,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
} }
MapContextMenu menu = mapActivity.getContextMenu(); 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()); LatLon latLon = new LatLon(wpt.getLatitude(), wpt.getLongitude());
if (menu.getLatLon().equals(latLon)) { if (menu.getLatLon().equals(latLon)) {
menu.update(latLon, new WptLocationPoint(wpt).getPointDescription(mapActivity), wpt); menu.update(latLon, new WptLocationPoint(wpt).getPointDescription(mapActivity), wpt);
@ -402,7 +404,9 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
} }
@Override @Override
public String getAddressInitValue() { return ""; } public String getAddressInitValue() {
return "";
}
@Override @Override
public Drawable getNameIcon() { public Drawable getNameIcon() {
@ -480,6 +484,25 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
return 0; 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<String> hiddenGroups = selectedGpxFile.getHiddenGroups();
return !hiddenGroups.contains(name);
}
return true;
}
private void saveGpx(final OsmandApplication app, final GPXFile gpxFile, final boolean gpxSelected) { private void saveGpx(final OsmandApplication app, final GPXFile gpxFile, final boolean gpxSelected) {
new SaveGpxAsyncTask(new File(gpxFile.path), gpxFile, new SaveGpxListener() { new SaveGpxAsyncTask(new File(gpxFile.path), gpxFile, new SaveGpxListener() {
@Override @Override

View file

@ -30,7 +30,7 @@ public class EnumStringPreference<E extends Enum<E>> extends CommonPreference<E>
@Override @Override
protected String toString(E o) { protected String toString(E o) {
return o.name(); return o == null ? null : o.name();
} }
@Override @Override

View file

@ -900,11 +900,11 @@ public class SettingsHelper {
List<ITileSource> tileSourceTemplates = new ArrayList<>(); List<ITileSource> tileSourceTemplates = new ArrayList<>();
List<File> routingFilesList = new ArrayList<>(); List<File> routingFilesList = new ArrayList<>();
List<File> renderFilesList = new ArrayList<>(); List<File> renderFilesList = new ArrayList<>();
List<File> multimediaFilesList = new ArrayList<>();
List<File> ttsVoiceFilesList = new ArrayList<>(); List<File> ttsVoiceFilesList = new ArrayList<>();
List<File> voiceFilesList = new ArrayList<>(); List<File> voiceFilesList = new ArrayList<>();
List<FileSettingsItem> mapFilesList = new ArrayList<>(); List<FileSettingsItem> mapFilesList = new ArrayList<>();
List<FileSettingsItem> tracksFilesList = new ArrayList<>(); List<FileSettingsItem> tracksFilesList = new ArrayList<>();
List<FileSettingsItem> multimediaFilesList = new ArrayList<>();
List<AvoidRoadInfo> avoidRoads = new ArrayList<>(); List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
List<GlobalSettingsItem> globalSettingsItems = new ArrayList<>(); List<GlobalSettingsItem> globalSettingsItems = new ArrayList<>();
List<OsmNotesPoint> notesPointList = new ArrayList<>(); List<OsmNotesPoint> notesPointList = new ArrayList<>();
@ -927,7 +927,7 @@ public class SettingsHelper {
} else if (fileItem.getSubtype() == FileSubtype.ROUTING_CONFIG) { } else if (fileItem.getSubtype() == FileSubtype.ROUTING_CONFIG) {
routingFilesList.add(fileItem.getFile()); routingFilesList.add(fileItem.getFile());
} else if (fileItem.getSubtype() == FileSubtype.MULTIMEDIA_NOTES) { } else if (fileItem.getSubtype() == FileSubtype.MULTIMEDIA_NOTES) {
multimediaFilesList.add(fileItem.getFile()); multimediaFilesList.add(fileItem);
} else if (fileItem.getSubtype() == FileSubtype.GPX) { } else if (fileItem.getSubtype() == FileSubtype.GPX) {
tracksFilesList.add(fileItem); tracksFilesList.add(fileItem);
} else if (fileItem.getSubtype().isMap()) { } else if (fileItem.getSubtype().isMap()) {

View file

@ -6,8 +6,10 @@ import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ExpandableListView; import android.widget.ExpandableListView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListView;
import androidx.activity.OnBackPressedCallback; import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -18,6 +20,8 @@ import androidx.core.view.ViewCompat;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import com.github.ksoichiro.android.observablescrollview.ScrollUtils;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -129,6 +133,7 @@ public abstract class BaseSettingsListFragment extends BaseOsmAndFragment implem
adapter = new ExportSettingsAdapter(app, exportMode, this, nightMode); adapter = new ExportSettingsAdapter(app, exportMode, this, nightMode);
adapter.updateSettingsItems(dataList, selectedItemsMap); adapter.updateSettingsItems(dataList, selectedItemsMap);
expandableList.setAdapter(adapter); expandableList.setAdapter(adapter);
setupListView(expandableList);
updateAvailableSpace(); updateAvailableSpace();
return root; 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() { protected void updateAvailableSpace() {
long calculatedSize = ExportSettingsAdapter.calculateItemsSize(adapter.getData()); long calculatedSize = ExportSettingsAdapter.calculateItemsSize(adapter.getData());
if (calculatedSize != 0) { if (calculatedSize != 0) {

View file

@ -6,6 +6,10 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; 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.AndroidUtils;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
@ -15,6 +19,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin; 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.AvoidSpecificRoads.AvoidRoadInfo;
import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
@ -36,10 +41,6 @@ import org.apache.commons.logging.Log;
import java.io.File; import java.io.File;
import java.util.List; 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; import static net.osmand.plus.settings.backend.backup.FileSettingsItem.FileSubtype;
public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@ -154,6 +155,7 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
if (iconId == -1) { if (iconId == -1) {
iconId = R.drawable.ic_action_photo_dark; iconId = R.drawable.ic_action_photo_dark;
} }
itemHolder.title.setText(new Recording(file).getName(app, true));
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(iconId, activeColorRes)); itemHolder.icon.setImageDrawable(uiUtilities.getIcon(iconId, activeColorRes));
} else if (fileSubtype.isMap() } else if (fileSubtype.isMap()
|| fileSubtype == FileSubtype.TTS_VOICE || fileSubtype == FileSubtype.TTS_VOICE

View file

@ -6,6 +6,13 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.TextView; 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.AndroidUtils;
import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.GPXUtilities.GPXTrackAnalysis;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
@ -21,6 +28,7 @@ import net.osmand.plus.R;
import net.osmand.plus.SQLiteTileSource; import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
@ -61,13 +69,9 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import androidx.annotation.NonNull; import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.IMG_EXTENSION;
import androidx.annotation.Nullable; import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.MPEG4_EXTENSION;
import androidx.core.content.ContextCompat; import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.THREEGP_EXTENSION;
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.CHECKED;
import static net.osmand.view.ThreeStateCheckbox.State.MISC; import static net.osmand.view.ThreeStateCheckbox.State.MISC;
import static net.osmand.view.ThreeStateCheckbox.State.UNCHECKED; import static net.osmand.view.ThreeStateCheckbox.State.UNCHECKED;
@ -142,15 +146,21 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
selectedItems.remove(item[0].getTag()); selectedItems.remove(item[0].getTag());
} }
updateTitleView(); updateTitleView();
setupBottomSheetItem(item[0], item[0].getTag());
} }
}) })
.setTag(object); .setTag(object);
setupBottomSheetItem(builder, object);
item[0] = builder.create(); item[0] = builder.create();
items.add(item[0]); items.add(item[0]);
} }
} }
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
updateItems();
}
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
@ -177,7 +187,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
selectedItems.clear(); selectedItems.clear();
} }
updateTitleView(); updateTitleView();
updateItems(checked); updateItems();
} }
}); });
setupDescription(view); setupDescription(view);
@ -221,10 +231,12 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
return itemsSize; return itemsSize;
} }
private void updateItems(boolean checked) { private void updateItems() {
for (BaseBottomSheetItem item : items) { for (BaseBottomSheetItem item : items) {
if (item instanceof BottomSheetItemWithCompoundButton) { if (item instanceof BottomSheetItemWithCompoundButton && item.getTag() != null) {
((BottomSheetItemWithCompoundButton) item).setChecked(checked); BottomSheetItemWithCompoundButton bottomSheetItem = (BottomSheetItemWithCompoundButton) item;
setupBottomSheetItem(bottomSheetItem, item.getTag());
bottomSheetItem.setChecked(selectedItems.contains(item.getTag()));
} }
} }
} }
@ -274,7 +286,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
return null; return null;
} }
private void setupBottomSheetItem(Builder builder, Object object) { private void setupBottomSheetItem(BottomSheetItemWithCompoundButton item, Object object) {
if (object instanceof ApplicationModeBean) { if (object instanceof ApplicationModeBean) {
ApplicationModeBean modeBean = (ApplicationModeBean) object; ApplicationModeBean modeBean = (ApplicationModeBean) object;
String profileName = modeBean.userProfileName; String profileName = modeBean.userProfileName;
@ -286,7 +298,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
profileName = StringUtils.capitalize(modeBean.stringKey); profileName = StringUtils.capitalize(modeBean.stringKey);
} }
} }
builder.setTitle(profileName); item.setTitle(profileName);
String routingProfile = ""; String routingProfile = "";
String routingProfileValue = modeBean.routingProfile; String routingProfileValue = modeBean.routingProfile;
@ -300,122 +312,153 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
} }
} }
if (!Algorithms.isEmpty(routingProfile)) { 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 { } 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); int profileIconRes = AndroidUtils.getDrawableId(app, modeBean.iconName);
ProfileIconColors iconColor = modeBean.iconColor; ProfileIconColors iconColor = modeBean.iconColor;
Integer customIconColor = modeBean.customIconColor; Integer customIconColor = modeBean.customIconColor;
int actualIconColor = customIconColor != null ? int actualIconColor;
customIconColor : ContextCompat.getColor(app, iconColor.getColor(nightMode)); if (selectedItems.contains(object)) {
builder.setIcon(uiUtilities.getPaintedIcon(profileIconRes, actualIconColor)); 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) { } else if (object instanceof QuickAction) {
QuickAction quickAction = (QuickAction) object; QuickAction quickAction = (QuickAction) object;
builder.setTitle(quickAction.getName(app)); item.setTitle(quickAction.getName(app));
builder.setIcon(uiUtilities.getIcon(quickAction.getIconRes(), activeColorRes)); item.setIcon(uiUtilities.getIcon(quickAction.getIconRes(), getItemIconColor(object)));
} else if (object instanceof PoiUIFilter) { } else if (object instanceof PoiUIFilter) {
PoiUIFilter poiUIFilter = (PoiUIFilter) object; PoiUIFilter poiUIFilter = (PoiUIFilter) object;
builder.setTitle(poiUIFilter.getName()); item.setTitle(poiUIFilter.getName());
int iconRes = RenderingIcons.getBigIconResourceId(poiUIFilter.getIconId()); 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) { } else if (object instanceof TileSourceTemplate || object instanceof SQLiteTileSource) {
ITileSource tileSource = (ITileSource) object; ITileSource tileSource = (ITileSource) object;
builder.setTitle(tileSource.getName()); item.setTitle(tileSource.getName());
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_map, activeColorRes)); item.setIcon(uiUtilities.getIcon(R.drawable.ic_map, getItemIconColor(object)));
} else if (object instanceof File) { } else if (object instanceof File) {
setupBottomSheetItemForFile(builder, (File) object); setupBottomSheetItemForFile(item, (File) object);
} else if (object instanceof GpxSettingsItem) { } else if (object instanceof GpxSettingsItem) {
GpxSettingsItem item = (GpxSettingsItem) object; GpxSettingsItem settingsItem = (GpxSettingsItem) object;
setupBottomSheetItemForGpx(builder, item.getFile(), item.getAppearanceInfo()); setupBottomSheetItemForGpx(item, settingsItem.getFile(), settingsItem.getAppearanceInfo());
} else if (object instanceof FileSettingsItem) { } else if (object instanceof FileSettingsItem) {
FileSettingsItem item = (FileSettingsItem) object; FileSettingsItem settingsItem = (FileSettingsItem) object;
setupBottomSheetItemForFile(builder, item.getFile()); setupBottomSheetItemForFile(item, settingsItem.getFile());
} else if (object instanceof AvoidRoadInfo) { } else if (object instanceof AvoidRoadInfo) {
AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) object; AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) object;
builder.setTitle(avoidRoadInfo.name); item.setTitle(avoidRoadInfo.name);
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_alert, activeColorRes)); item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_alert, getItemIconColor(object)));
} else if (object instanceof OsmNotesPoint) { } else if (object instanceof OsmNotesPoint) {
OsmNotesPoint osmNotesPoint = (OsmNotesPoint) object; OsmNotesPoint osmNotesPoint = (OsmNotesPoint) object;
builder.setTitle(osmNotesPoint.getText()); item.setTitle(osmNotesPoint.getText());
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_osm_note_add, activeColorRes)); item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_osm_note_add, getItemIconColor(object)));
} else if (object instanceof OpenstreetmapPoint) { } else if (object instanceof OpenstreetmapPoint) {
OpenstreetmapPoint openstreetmapPoint = (OpenstreetmapPoint) object; OpenstreetmapPoint openstreetmapPoint = (OpenstreetmapPoint) object;
builder.setTitle(OsmEditingPlugin.getTitle(openstreetmapPoint, app)); item.setTitle(OsmEditingPlugin.getTitle(openstreetmapPoint, app));
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_info_dark, activeColorRes)); item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_info_dark, getItemIconColor(object)));
} else if (object instanceof FavoriteGroup) { } else if (object instanceof FavoriteGroup) {
FavoriteGroup group = (FavoriteGroup) object; FavoriteGroup group = (FavoriteGroup) object;
builder.setTitle(group.getDisplayName(app)); item.setTitle(group.getDisplayName(app));
int color = group.getColor() == 0 ? ContextCompat.getColor(app, R.color.color_favorite) : group.getColor(); int color;
builder.setIcon(uiUtilities.getPaintedIcon(R.drawable.ic_action_folder, 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(); int points = group.getPoints().size();
String itemsDescr = getString(R.string.shared_string_gpx_points); 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) { } else if (object instanceof GlobalSettingsItem) {
GlobalSettingsItem globalSettingsItem = (GlobalSettingsItem) object; GlobalSettingsItem globalSettingsItem = (GlobalSettingsItem) object;
builder.setTitle(globalSettingsItem.getPublicName(app)); item.setTitle(globalSettingsItem.getPublicName(app));
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_settings, activeColorRes)); item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_settings, getItemIconColor(object)));
} else if (object instanceof ItineraryGroup) { } else if (object instanceof ItineraryGroup) {
ItineraryGroup markersGroup = (ItineraryGroup) object; ItineraryGroup markersGroup = (ItineraryGroup) object;
if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) { if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) {
builder.setTitle(getString(R.string.map_markers)); item.setTitle(getString(R.string.map_markers));
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_flag, activeColorRes)); item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_flag, getItemIconColor(object)));
} else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) { } else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) {
builder.setTitle(getString(R.string.markers_history)); item.setTitle(getString(R.string.markers_history));
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, activeColorRes)); item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, getItemIconColor(object)));
} }
int selectedMarkers = markersGroup.getMarkers().size(); int selectedMarkers = markersGroup.getMarkers().size();
String itemsDescr = getString(R.string.shared_string_items); 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) { } else if (object instanceof HistoryEntry) {
HistoryEntry historyEntry = (HistoryEntry) object; HistoryEntry historyEntry = (HistoryEntry) object;
builder.setTitle(historyEntry.getName().getName()); item.setTitle(historyEntry.getName().getName());
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, activeColorRes)); item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, getItemIconColor(object)));
} else if (object instanceof OnlineRoutingEngine) { } else if (object instanceof OnlineRoutingEngine) {
OnlineRoutingEngine onlineRoutingEngine = (OnlineRoutingEngine) object; OnlineRoutingEngine onlineRoutingEngine = (OnlineRoutingEngine) object;
builder.setTitle(onlineRoutingEngine.getName(app)); item.setTitle(onlineRoutingEngine.getName(app));
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_world_globe_dark, activeColorRes)); 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()); FileSubtype fileSubtype = FileSubtype.getSubtypeByPath(app, file.getPath());
builder.setTitle(file.getName()); item.setTitle(file.getName());
if (file.getAbsolutePath().contains(IndexConstants.RENDERERS_DIR)) { 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)) { } 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)) { } 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)) { } else if (file.getAbsolutePath().contains(IndexConstants.AV_INDEX_DIR)) {
int iconId = AudioVideoNotesPlugin.getIconIdForRecordingFile(file); int iconId = AudioVideoNotesPlugin.getIconIdForRecordingFile(file);
if (iconId == -1) { if (iconId == -1) {
iconId = R.drawable.ic_action_photo_dark; iconId = R.drawable.ic_action_photo_dark;
} }
builder.setIcon(uiUtilities.getIcon(iconId, activeColorRes)); if (item.getTag() instanceof FileSettingsItem) {
builder.setDescription(AndroidUtils.formatSize(app, file.length())); FileSettingsItem settingsItem = (FileSettingsItem) item.getTag();
item.setTitle(getNameForMultimediaFile(settingsItem.getFile(), settingsItem.getLastModified()));
} else {
item.setTitle(new Recording(file).getName(app, true));
}
item.setIcon(uiUtilities.getIcon(iconId, getItemIconColor(item.getTag())));
item.setDescription(AndroidUtils.formatSize(app, file.length()));
} else if (fileSubtype.isMap() } else if (fileSubtype.isMap()
|| fileSubtype == FileSettingsItem.FileSubtype.TTS_VOICE || fileSubtype == FileSettingsItem.FileSubtype.TTS_VOICE
|| fileSubtype == FileSettingsItem.FileSubtype.VOICE) { || fileSubtype == FileSettingsItem.FileSubtype.VOICE) {
builder.setTitle(FileNameTranslationHelper.getFileNameWithRegion(app, file.getName())); item.setTitle(FileNameTranslationHelper.getFileNameWithRegion(app, file.getName()));
builder.setIcon(uiUtilities.getIcon(fileSubtype.getIconId(), activeColorRes)); item.setIcon(uiUtilities.getIcon(fileSubtype.getIconId(), getItemIconColor(item.getTag())));
if (fileSubtype.isMap()) { if (fileSubtype.isMap()) {
String mapDescription = getMapDescription(file); String mapDescription = getMapDescription(file);
String formattedSize = AndroidUtils.formatSize(app, file.length()); String formattedSize = AndroidUtils.formatSize(app, file.length());
if (mapDescription != null) { 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 { } else {
builder.setDescription(formattedSize); item.setDescription(formattedSize);
} }
} }
} }
} }
private void setupBottomSheetItemForGpx(Builder builder, File file, @Nullable GpxAppearanceInfo appearanceInfo) { private void setupBottomSheetItemForGpx(BottomSheetItemWithCompoundButton item, File file, @Nullable GpxAppearanceInfo appearanceInfo) {
builder.setTitle(GpxUiHelper.getGpxTitle(file.getName())); item.setTitle(GpxUiHelper.getGpxTitle(file.getName()));
builder.setDescription(getTrackDescr(file, file.lastModified(), file.length(), appearanceInfo)); item.setDescription(getTrackDescr(file, file.lastModified(), file.length(), appearanceInfo));
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes)); item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, getItemIconColor(item.getTag())));
}
private String getNameForMultimediaFile(@NonNull File file, long lastModified) {
String fileName = file.getName();
if (fileName.endsWith(IMG_EXTENSION)) {
return getString(R.string.shared_string_photo) + " " + Recording.formatDateTime(app, lastModified);
} else if (fileName.endsWith(MPEG4_EXTENSION)) {
return getString(R.string.shared_string_video) + " " + Recording.formatDateTime(app, lastModified);
} else if (fileName.endsWith(THREEGP_EXTENSION)) {
return getString(R.string.shared_string_audio) + " " + Recording.formatDateTime(app, lastModified);
}
return "";
}
private int getItemIconColor(Object object) {
return selectedItems.contains(object) ? activeColorRes : secondaryColorRes;
} }
private final GpxDataItemCallback gpxDataItemCallback = new GpxDataItemCallback() { private final GpxDataItemCallback gpxDataItemCallback = new GpxDataItemCallback() {

View file

@ -58,7 +58,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
private final int secondaryColorRes; private final int secondaryColorRes;
private final int groupViewHeight; private final int groupViewHeight;
private final int childViewHeight; private final int childViewHeight;
private final int listBottomPadding;
ExportSettingsAdapter(OsmandApplication app, boolean exportMode, OnItemSelectedListener listener, boolean nightMode) { ExportSettingsAdapter(OsmandApplication app, boolean exportMode, OnItemSelectedListener listener, boolean nightMode) {
this.app = app; 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; 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); groupViewHeight = app.getResources().getDimensionPixelSize(R.dimen.setting_list_item_group_height);
childViewHeight = app.getResources().getDimensionPixelSize(R.dimen.setting_list_item_large_height); childViewHeight = app.getResources().getDimensionPixelSize(R.dimen.setting_list_item_large_height);
listBottomPadding = app.getResources().getDimensionPixelSize(R.dimen.fab_recycler_view_padding_bottom);
} }
@Override @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); adjustIndicator(app, groupPosition, isExpanded, group, nightMode);
AndroidUiHelper.updateVisibility(group.findViewById(R.id.divider), isExpanded); AndroidUiHelper.updateVisibility(group.findViewById(R.id.divider), isExpanded);
AndroidUiHelper.updateVisibility(group.findViewById(R.id.card_top_divider), true); AndroidUiHelper.updateVisibility(group.findViewById(R.id.card_top_divider), true);
@ -188,8 +183,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
notifyDataSetChanged(); 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); AndroidUiHelper.updateVisibility(child.findViewById(R.id.card_bottom_divider), isLastChild);
return child; return child;

View file

@ -114,6 +114,12 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O
this.selectedGroup = selectedGroup; this.selectedGroup = selectedGroup;
} }
public void updateGroups() {
selectedItems.clear();
selectedGroups.clear();
adapter.synchronizeGroups(getDisplayGroups());
}
public List<GpxDisplayGroup> getGroups() { public List<GpxDisplayGroup> getGroups() {
return adapter.groups; return adapter.groups;
} }
@ -263,9 +269,7 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O
@Override @Override
public void onPointsDeleted() { public void onPointsDeleted() {
selectedItems.clear(); updateGroups();
selectedGroups.clear();
adapter.synchronizeGroups(getDisplayGroups());
} }
public void filter(String text) { public void filter(String text) {

View file

@ -147,6 +147,7 @@ public class AddGpxPointBottomSheetHelper implements OnDismissListener {
private void onClose() { private void onClose() {
TrackMenuFragment fragment = mapActivity.getTrackMenuFragment(); TrackMenuFragment fragment = mapActivity.getTrackMenuFragment();
if (fragment != null) { if (fragment != null) {
fragment.updateContent();
fragment.show(); fragment.show();
} else { } else {
TrackMenuFragment.openTrack(mapActivity, new File(newGpxPoint.getGpx().path), null); TrackMenuFragment.openTrack(mapActivity, new File(newGpxPoint.getGpx().path), null);