commit
e14dfff0cd
11 changed files with 175 additions and 88 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<String> 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
|
||||
|
|
|
@ -30,7 +30,7 @@ public class EnumStringPreference<E extends Enum<E>> extends CommonPreference<E>
|
|||
|
||||
@Override
|
||||
protected String toString(E o) {
|
||||
return o.name();
|
||||
return o == null ? null : o.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -900,11 +900,11 @@ public class SettingsHelper {
|
|||
List<ITileSource> tileSourceTemplates = new ArrayList<>();
|
||||
List<File> routingFilesList = new ArrayList<>();
|
||||
List<File> renderFilesList = new ArrayList<>();
|
||||
List<File> multimediaFilesList = new ArrayList<>();
|
||||
List<File> ttsVoiceFilesList = new ArrayList<>();
|
||||
List<File> voiceFilesList = new ArrayList<>();
|
||||
List<FileSettingsItem> mapFilesList = new ArrayList<>();
|
||||
List<FileSettingsItem> tracksFilesList = new ArrayList<>();
|
||||
List<FileSettingsItem> multimediaFilesList = new ArrayList<>();
|
||||
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
|
||||
List<GlobalSettingsItem> globalSettingsItems = new ArrayList<>();
|
||||
List<OsmNotesPoint> 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()) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<RecyclerView.ViewHolder> {
|
||||
|
@ -154,6 +155,7 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
|
|||
if (iconId == -1) {
|
||||
iconId = R.drawable.ic_action_photo_dark;
|
||||
}
|
||||
itemHolder.title.setText(new Recording(file).getName(app, true));
|
||||
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(iconId, activeColorRes));
|
||||
} else if (fileSubtype.isMap()
|
||||
|| fileSubtype == FileSubtype.TTS_VOICE
|
||||
|
|
|
@ -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;
|
||||
|
@ -21,6 +28,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.SQLiteTileSource;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
|
||||
|
@ -61,13 +69,9 @@ 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.plus.audionotes.AudioVideoNotesPlugin.IMG_EXTENSION;
|
||||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.MPEG4_EXTENSION;
|
||||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.THREEGP_EXTENSION;
|
||||
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 +146,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 +187,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
selectedItems.clear();
|
||||
}
|
||||
updateTitleView();
|
||||
updateItems(checked);
|
||||
updateItems();
|
||||
}
|
||||
});
|
||||
setupDescription(view);
|
||||
|
@ -221,10 +231,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 +286,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 +298,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 +312,153 @@ 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()));
|
||||
if (item.getTag() instanceof FileSettingsItem) {
|
||||
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()
|
||||
|| 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 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() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -114,6 +114,12 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O
|
|||
this.selectedGroup = selectedGroup;
|
||||
}
|
||||
|
||||
public void updateGroups() {
|
||||
selectedItems.clear();
|
||||
selectedGroups.clear();
|
||||
adapter.synchronizeGroups(getDisplayGroups());
|
||||
}
|
||||
|
||||
public List<GpxDisplayGroup> 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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue