diff --git a/OsmAnd/res/layout/ask_map_download_fragment.xml b/OsmAnd/res/layout/ask_map_download_fragment.xml
new file mode 100644
index 0000000000..c4df22c9e6
--- /dev/null
+++ b/OsmAnd/res/layout/ask_map_download_fragment.xml
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index a64fcf0949..de156e3d9a 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
+ World basemap (covering the whole world at small zooms) is missing or outdated. Please consider downloading World basemap for a complete environment.
QR-code
Map downloaded
Map of %1$s has been downloaded. Go back to the map to start using it.
diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
index 4f1922e60a..937deae543 100644
--- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
+++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
@@ -38,8 +38,9 @@ import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType;
import net.osmand.plus.download.ui.ActiveDownloadsDialogFragment;
import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment;
-import net.osmand.plus.download.ui.DownloadResourceGroupFragment;
-import net.osmand.plus.download.ui.GoToMapFragment;
+import net.osmand.plus.download.ui.popups.AskMapDownloadFragment;
+import net.osmand.plus.download.ui.popups.DownloadResourceGroupFragment;
+import net.osmand.plus.download.ui.popups.GoToMapFragment;
import net.osmand.plus.download.ui.LocalIndexesFragment;
import net.osmand.plus.download.ui.UpdatesIndexFragment;
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
@@ -559,25 +560,12 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
if(getDownloadThread().getCurrentDownloadingItem() == null) {
return;
}
- DownloadResourceGroup worldMaps = getDownloadThread().getIndexes().
- getSubGroupById(DownloadResourceGroupType.WORLD_MAPS.getDefaultId());
- IndexItem worldMap = null;
- List list = worldMaps.getIndividualResources();
- if(list != null) {
- for(IndexItem ii : list) {
- if(ii.getBasename().equalsIgnoreCase(WorldRegion.WORLD_BASEMAP)) {
- worldMap = ii;
- break;
- }
- }
- }
-
- if(!SUGGESTED_TO_DOWNLOAD_BASEMAP && worldMap != null && (!worldMap.isDownloaded() || worldMap.isOutdated()) &&
+ IndexItem worldMap = getDownloadThread().getIndexes().getWorldBaseMapItem();
+ if(!SUGGESTED_TO_DOWNLOAD_BASEMAP && worldMap != null && (!worldMap.isDownloaded() || worldMap.isOutdated()) &&
!getDownloadThread().isDownloading(worldMap)) {
SUGGESTED_TO_DOWNLOAD_BASEMAP = true;
- // TODO Show dialog Download world map with 2 buttons to download it or no
+ AskMapDownloadFragment.showInstance(worldMap, this);
}
-
}
private void showFirstTimeExternalStorage() {
diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java
index 86a38dcd74..02bfe111aa 100644
--- a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java
+++ b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java
@@ -25,7 +25,6 @@ public class DownloadResources extends DownloadResourceGroup {
private Map indexActivatedFileNames = new LinkedHashMap<>();
private List rawResources;
private List itemsToUpdate = new ArrayList<>();
- //public static final String WORLD_BASEMAP_KEY = "world_basemap.obf.zip";
public static final String WORLD_SEAMARKS_KEY = "world_seamarks_basemap";
@@ -39,6 +38,32 @@ public class DownloadResources extends DownloadResourceGroup {
return itemsToUpdate;
}
+ public IndexItem getWorldBaseMapItem() {
+ DownloadResourceGroup worldMaps = getSubGroupById(DownloadResourceGroupType.WORLD_MAPS.getDefaultId());
+ IndexItem worldMap = null;
+ List list = worldMaps.getIndividualResources();
+ if(list != null) {
+ for(IndexItem ii : list) {
+ if(ii.getBasename().equalsIgnoreCase(WorldRegion.WORLD_BASEMAP)) {
+ worldMap = ii;
+ break;
+ }
+ }
+ }
+ return worldMap;
+ }
+
+ public IndexItem getIndexItem(String fileName) {
+ IndexItem res = null;
+ for (IndexItem item : rawResources) {
+ if (fileName.equals(item.getFileName())) {
+ res = item;
+ break;
+ }
+ }
+ return res;
+ }
+
public void updateLoadedFiles() {
initAlreadyLoadedFiles();
prepareFilesToUpdate();
diff --git a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java
index 761a80b705..3e641d47f7 100644
--- a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java
@@ -20,6 +20,7 @@ import net.osmand.plus.download.DownloadResourceGroup;
import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType;
import net.osmand.plus.download.DownloadResources;
import net.osmand.plus.download.IndexItem;
+import net.osmand.plus.download.ui.popups.DownloadResourceGroupFragment;
import net.osmand.util.Algorithms;
import android.content.res.TypedArray;
import android.os.Bundle;
diff --git a/OsmAnd/src/net/osmand/plus/download/ui/popups/AskMapDownloadFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/popups/AskMapDownloadFragment.java
new file mode 100644
index 0000000000..319951593b
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/download/ui/popups/AskMapDownloadFragment.java
@@ -0,0 +1,151 @@
+package net.osmand.plus.download.ui.popups;
+
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.support.annotation.ColorRes;
+import android.support.annotation.DrawableRes;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import net.osmand.map.WorldRegion;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.OsmandSettings;
+import net.osmand.plus.R;
+import net.osmand.plus.download.DownloadActivity;
+import net.osmand.plus.download.IndexItem;
+
+public class AskMapDownloadFragment extends DialogFragment {
+ public static final String TAG = "AskMapDownloadFragment";
+
+ private static final String KEY_ASK_MAP_DOWNLOAD_ITEM_FILENAME = "key_ask_map_download_item_filename";
+ private IndexItem indexItem;
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ boolean isLightTheme = getMyApplication()
+ .getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
+ int themeId = isLightTheme ? R.style.OsmandLightTheme_BottomSheet
+ : R.style.OsmandDarkTheme_BottomSheet;
+ final Dialog dialog = new Dialog(getActivity(), themeId);
+ dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
+ dialog.getWindow().getAttributes().windowAnimations = R.style.Animations_PopUpMenu_Bottom;
+ return dialog;
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+
+ if (savedInstanceState != null) {
+ String itemFileName = savedInstanceState.getString(KEY_ASK_MAP_DOWNLOAD_ITEM_FILENAME);
+ if (itemFileName != null) {
+ indexItem = getMyApplication().getDownloadThread().getIndexes().getIndexItem(itemFileName);
+ }
+ }
+
+ View view = inflater.inflate(R.layout.ask_map_download_fragment, container, false);
+ ((ImageView) view.findViewById(R.id.titleIconImageView))
+ .setImageDrawable(getIcon(R.drawable.ic_map, R.color.osmand_orange));
+
+ Button actionButtonOk = (Button) view.findViewById(R.id.actionButtonOk);
+
+ String titleText = null;
+ String descriptionText = null;
+
+ if (indexItem != null) {
+ if (indexItem.getBasename().equalsIgnoreCase(WorldRegion.WORLD_BASEMAP)) {
+ titleText = getString(R.string.index_item_world_basemap);
+ descriptionText = getString(R.string.world_map_download_descr);
+ }
+
+ actionButtonOk.setText(getString(R.string.shared_string_download) + " (" + indexItem.getSizeDescription(getActivity()) + ")");
+ }
+
+ if (titleText != null) {
+ ((TextView) view.findViewById(R.id.titleTextView))
+ .setText(titleText);
+ }
+ if (descriptionText != null) {
+ ((TextView) view.findViewById(R.id.descriptionTextView))
+ .setText(descriptionText);
+ }
+
+ final ImageButton closeImageButton = (ImageButton) view.findViewById(R.id.closeImageButton);
+ closeImageButton.setImageDrawable(getContentIcon(R.drawable.ic_action_remove_dark));
+ closeImageButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dismiss();
+ }
+ });
+
+ actionButtonOk.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (indexItem != null) {
+ ((DownloadActivity) getActivity()).startDownload(indexItem);
+ dismiss();
+ }
+ }
+ });
+
+ view.findViewById(R.id.actionButtonCancel)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dismiss();
+ }
+ });
+
+ return view;
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ final Window window = getDialog().getWindow();
+ WindowManager.LayoutParams params = window.getAttributes();
+ params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
+ params.gravity = Gravity.BOTTOM;
+ params.width = ViewGroup.LayoutParams.MATCH_PARENT;
+ window.setAttributes(params);
+ }
+
+ @Override
+ public void onSaveInstanceState(@NonNull Bundle outState) {
+ if (indexItem != null) {
+ outState.putString(KEY_ASK_MAP_DOWNLOAD_ITEM_FILENAME, indexItem.getFileName());
+ }
+ }
+
+ private OsmandApplication getMyApplication() {
+ return (OsmandApplication) getActivity().getApplication();
+ }
+
+ private Drawable getIcon(@DrawableRes int drawableRes, @ColorRes int color) {
+ return getMyApplication().getIconsCache().getIcon(drawableRes, color);
+ }
+
+ private Drawable getContentIcon(@DrawableRes int drawableRes) {
+ return getMyApplication().getIconsCache().getContentIcon(drawableRes);
+ }
+
+ public static void showInstance(IndexItem indexItem, DownloadActivity activity) {
+ AskMapDownloadFragment fragment = new AskMapDownloadFragment();
+ fragment.indexItem = indexItem;
+ fragment.show(activity.getFragmentManager(), TAG);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/popups/DownloadResourceGroupFragment.java
similarity index 98%
rename from OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java
rename to OsmAnd/src/net/osmand/plus/download/ui/popups/DownloadResourceGroupFragment.java
index ee2e593b37..29c83b7018 100644
--- a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java
+++ b/OsmAnd/src/net/osmand/plus/download/ui/popups/DownloadResourceGroupFragment.java
@@ -1,4 +1,4 @@
-package net.osmand.plus.download.ui;
+package net.osmand.plus.download.ui.popups;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -32,6 +32,8 @@ import net.osmand.plus.download.DownloadResourceGroup;
import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType;
import net.osmand.plus.download.DownloadResources;
import net.osmand.plus.download.IndexItem;
+import net.osmand.plus.download.ui.ItemViewHolder;
+import net.osmand.plus.download.ui.SearchDialogFragment;
import net.osmand.util.Algorithms;
import java.util.ArrayList;
diff --git a/OsmAnd/src/net/osmand/plus/download/ui/GoToMapFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/popups/GoToMapFragment.java
similarity index 99%
rename from OsmAnd/src/net/osmand/plus/download/ui/GoToMapFragment.java
rename to OsmAnd/src/net/osmand/plus/download/ui/popups/GoToMapFragment.java
index c188a09ba5..74163b0d98 100644
--- a/OsmAnd/src/net/osmand/plus/download/ui/GoToMapFragment.java
+++ b/OsmAnd/src/net/osmand/plus/download/ui/popups/GoToMapFragment.java
@@ -1,4 +1,4 @@
-package net.osmand.plus.download.ui;
+package net.osmand.plus.download.ui.popups;
import android.app.Dialog;
import android.app.DialogFragment;