From 16c733d72605a5753972d196c9eb71b275a94a3d Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 17:02:33 +0200 Subject: [PATCH] Display size in map download controller and change buttons --- .../res/layout/map_context_menu_fragment.xml | 4 +- .../controllers/MapDataMenuController.java | 74 ++++++++++++++----- 2 files changed, 56 insertions(+), 22 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index 1a06c0837a..1966edc6b6 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -271,7 +271,7 @@ android:gravity="center_vertical" android:paddingLeft="@dimen/context_menu_button_padding_x" android:paddingRight="@dimen/context_menu_button_padding_x" - android:text="@string/shared_string_delete" + android:text="@string/shared_string_others" tools:textColor="?attr/ctx_menu_controller_text_color" android:textSize="@dimen/default_desc_text_size"/> @@ -306,7 +306,7 @@ android:gravity="center_vertical" android:paddingLeft="@dimen/context_menu_button_padding_x" android:paddingRight="@dimen/context_menu_button_padding_x" - android:text="@string/shared_string_others" + android:text="@string/shared_string_delete" android:textAllCaps="true" tools:textColor="?attr/ctx_menu_controller_text_color" android:textSize="@dimen/default_desc_text_size" diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java index 4cb6cf67fb..62e5f9ff0f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java @@ -118,23 +118,6 @@ public class MapDataMenuController extends MenuController { leftDownloadButtonController.leftIconId = R.drawable.ic_action_import; rightDownloadButtonController = new TitleButtonController() { - @Override - public void buttonPressed() { - if (indexItem != null) { - if (backuped) { - deleteItem(indexItem.getBackupFile(app)); - } else { - deleteItem(indexItem.getTargetFile(app)); - } - } else if (localIndexInfo != null) { - deleteItem(new File(localIndexInfo.getPathToData())); - } - } - }; - rightDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_delete); - rightDownloadButtonController.leftIconId = R.drawable.ic_action_delete_dark; - - bottomTitleButtonController = new TitleButtonController() { @Override public void buttonPressed() { getMapActivity().getContextMenu().close(); @@ -158,7 +141,25 @@ public class MapDataMenuController extends MenuController { mapActivity.getContextMenu().getLatLon(), selectedObjects); } }; - bottomTitleButtonController.caption = getMapActivity().getString(R.string.download_select_map_types); + rightDownloadButtonController.caption = getMapActivity().getString(R.string.download_select_map_types); + rightDownloadButtonController.leftIconId = R.drawable.ic_plugin_srtm; + + bottomTitleButtonController = new TitleButtonController() { + @Override + public void buttonPressed() { + if (indexItem != null) { + if (backuped) { + deleteItem(indexItem.getBackupFile(app)); + } else { + deleteItem(indexItem.getTargetFile(app)); + } + } else if (localIndexInfo != null) { + deleteItem(new File(localIndexInfo.getPathToData())); + } + } + }; + bottomTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_delete); + bottomTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark; titleProgressController = new TitleProgressController() { @Override @@ -178,6 +179,39 @@ public class MapDataMenuController extends MenuController { updateData(); } + @Override + public boolean displayDistanceDirection() { + return true; + } + + @Override + public int getAdditionalInfoColor() { + return R.color.icon_color; + } + + @Override + public String getAdditionalInfoStr() { + double mb = 0; + if (backuped) { + if (localIndexInfo != null) { + mb = localIndexInfo.getSize(); + } else if (indexItem != null) { + mb = indexItem.getArchiveSizeMB(); + } + } else if (indexItem != null) { + mb = indexItem.getArchiveSizeMB(); + } + if (mb != 0) { + return getMapActivity().getString(R.string.file_size_in_mb, mb); + } + return ""; + } + + @Override + public int getAdditionalInfoIconRes() { + return R.drawable.ic_sdcard_16; + } + @Override protected void setObject(Object object) { if (object instanceof DownloadMapObject) { @@ -349,8 +383,8 @@ public class MapDataMenuController extends MenuController { leftDownloadButtonController.visible = false; } - rightDownloadButtonController.visible = downloaded; - bottomTitleButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0) + bottomTitleButtonController.visible = downloaded; + rightDownloadButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0) || (otherLocalIndexInfos != null && otherLocalIndexInfos.size() > 0); boolean internetConnectionAvailable =