Add setupBottomSheetItemForGpx

This commit is contained in:
Vitaliy 2020-12-06 17:55:32 +02:00
parent ebbdb2d12f
commit e1856ef7ba

View file

@ -315,14 +315,13 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
builder.setTitle(tileSource.getName()); builder.setTitle(tileSource.getName());
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_map, activeColorRes)); builder.setIcon(uiUtilities.getIcon(R.drawable.ic_map, activeColorRes));
} else if (object instanceof File) { } else if (object instanceof File) {
File file = (File) object; setupBottomSheetItemForFile(builder, (File) object);
setupBottomSheetItemForFile(builder, file, file.lastModified(), file.length(), null);
} else if (object instanceof GpxSettingsItem) { } else if (object instanceof GpxSettingsItem) {
GpxSettingsItem item = (GpxSettingsItem) object; GpxSettingsItem item = (GpxSettingsItem) object;
setupBottomSheetItemForFile(builder, item.getFile(), item.getLastModified(), item.getSize(), item.getAppearanceInfo()); setupBottomSheetItemForGpx(builder, item.getFile(), item.getAppearanceInfo());
} else if (object instanceof FileSettingsItem) { } else if (object instanceof FileSettingsItem) {
FileSettingsItem item = (FileSettingsItem) object; FileSettingsItem item = (FileSettingsItem) object;
setupBottomSheetItemForFile(builder, item.getFile(), item.getLastModified(), item.getSize(), null); setupBottomSheetItemForFile(builder, item.getFile());
} else if (object instanceof AvoidRoadInfo) { } else if (object instanceof AvoidRoadInfo) {
AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) object; AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) object;
builder.setTitle(avoidRoadInfo.name); builder.setTitle(avoidRoadInfo.name);
@ -366,8 +365,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
} }
} }
private void setupBottomSheetItemForFile(Builder builder, File file, long lastModified, long size, private void setupBottomSheetItemForFile(Builder builder, File file) {
GpxAppearanceInfo appearanceInfo) {
FileSubtype fileSubtype = FileSubtype.getSubtypeByPath(app, file.getPath()); FileSubtype fileSubtype = FileSubtype.getSubtypeByPath(app, file.getPath());
builder.setTitle(file.getName()); builder.setTitle(file.getName());
if (file.getAbsolutePath().contains(IndexConstants.RENDERERS_DIR)) { if (file.getAbsolutePath().contains(IndexConstants.RENDERERS_DIR)) {
@ -375,9 +373,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
} 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)); builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
} else if (file.getAbsolutePath().contains(IndexConstants.GPX_INDEX_DIR)) { } else if (file.getAbsolutePath().contains(IndexConstants.GPX_INDEX_DIR)) {
builder.setTitle(GpxUiHelper.getGpxTitle(file.getName())); setupBottomSheetItemForGpx(builder, file, null);
builder.setDescription(getTrackDescr(file, lastModified, size, appearanceInfo));
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
} 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) {
@ -392,7 +388,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
if (fileSubtype.isMap()) { if (fileSubtype.isMap()) {
String mapDescription = getMapDescription(file); String mapDescription = getMapDescription(file);
String formattedSize = AndroidUtils.formatSize(app, size); String formattedSize = AndroidUtils.formatSize(app, file.length());
if (mapDescription != null) { if (mapDescription != null) {
builder.setDescription(getString(R.string.ltr_or_rtl_combine_via_star, mapDescription, formattedSize)); builder.setDescription(getString(R.string.ltr_or_rtl_combine_via_star, mapDescription, formattedSize));
} else { } else {
@ -402,6 +398,12 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
} }
} }
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 final GpxDataItemCallback gpxDataItemCallback = new GpxDataItemCallback() { private final GpxDataItemCallback gpxDataItemCallback = new GpxDataItemCallback() {
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {