Added Ask for World basemap download fragment
This commit is contained in:
parent
cab6c5cd82
commit
3576be3b1c
8 changed files with 308 additions and 21 deletions
119
OsmAnd/res/layout/ask_map_download_fragment.xml
Normal file
119
OsmAnd/res/layout/ask_map_download_fragment.xml
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:background="?attr/bottom_menu_view_bg"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="true"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="56dp"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/titleIconImageView"
|
||||||
|
android:layout_width="56dp"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:scaleType="center"
|
||||||
|
tools:background="@color/color_warning"
|
||||||
|
tools:src="@drawable/ic_map"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/titleTextView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:text="@string/index_item_world_basemap"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="@dimen/dialog_header_text_size"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/closeImageButton"
|
||||||
|
android:layout_width="44dp"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"
|
||||||
|
tools:background="@color/color_warning"
|
||||||
|
android:src="@drawable/ic_action_remove_dark"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/descriptionTextView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:text="@string/world_map_download_descr"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_list_text_size"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/actionButtonOk"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"
|
||||||
|
android:textColor="?attr/contextMenuButtonColor"
|
||||||
|
tools:background="@color/color_warning"
|
||||||
|
android:text="@string/shared_string_download"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/actionButtonCancel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"
|
||||||
|
tools:background="@color/color_warning"
|
||||||
|
android:text="@string/later"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
|
@ -9,6 +9,7 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
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
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="world_map_download_descr">World basemap (covering the whole world at small zooms) is missing or outdated. Please consider downloading World basemap for a complete environment.</string>
|
||||||
<string name="shared_string_qr_code">QR-code</string>
|
<string name="shared_string_qr_code">QR-code</string>
|
||||||
<string name="map_downloaded">Map downloaded</string>
|
<string name="map_downloaded">Map downloaded</string>
|
||||||
<string name="map_downloaded_descr">Map of %1$s has been downloaded. Go back to the map to start using it.</string>
|
<string name="map_downloaded_descr">Map of %1$s has been downloaded. Go back to the map to start using it.</string>
|
||||||
|
|
|
@ -38,8 +38,9 @@ import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
|
||||||
import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType;
|
import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType;
|
||||||
import net.osmand.plus.download.ui.ActiveDownloadsDialogFragment;
|
import net.osmand.plus.download.ui.ActiveDownloadsDialogFragment;
|
||||||
import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment;
|
import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment;
|
||||||
import net.osmand.plus.download.ui.DownloadResourceGroupFragment;
|
import net.osmand.plus.download.ui.popups.AskMapDownloadFragment;
|
||||||
import net.osmand.plus.download.ui.GoToMapFragment;
|
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.LocalIndexesFragment;
|
||||||
import net.osmand.plus.download.ui.UpdatesIndexFragment;
|
import net.osmand.plus.download.ui.UpdatesIndexFragment;
|
||||||
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
|
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
|
||||||
|
@ -559,25 +560,12 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
|
||||||
if(getDownloadThread().getCurrentDownloadingItem() == null) {
|
if(getDownloadThread().getCurrentDownloadingItem() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DownloadResourceGroup worldMaps = getDownloadThread().getIndexes().
|
IndexItem worldMap = getDownloadThread().getIndexes().getWorldBaseMapItem();
|
||||||
getSubGroupById(DownloadResourceGroupType.WORLD_MAPS.getDefaultId());
|
if(!SUGGESTED_TO_DOWNLOAD_BASEMAP && worldMap != null && (!worldMap.isDownloaded() || worldMap.isOutdated()) &&
|
||||||
IndexItem worldMap = null;
|
|
||||||
List<IndexItem> 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()) &&
|
|
||||||
!getDownloadThread().isDownloading(worldMap)) {
|
!getDownloadThread().isDownloading(worldMap)) {
|
||||||
SUGGESTED_TO_DOWNLOAD_BASEMAP = true;
|
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() {
|
private void showFirstTimeExternalStorage() {
|
||||||
|
|
|
@ -25,7 +25,6 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
private Map<String, String> indexActivatedFileNames = new LinkedHashMap<>();
|
private Map<String, String> indexActivatedFileNames = new LinkedHashMap<>();
|
||||||
private List<IndexItem> rawResources;
|
private List<IndexItem> rawResources;
|
||||||
private List<IndexItem> itemsToUpdate = new ArrayList<>();
|
private List<IndexItem> itemsToUpdate = new ArrayList<>();
|
||||||
//public static final String WORLD_BASEMAP_KEY = "world_basemap.obf.zip";
|
|
||||||
public static final String WORLD_SEAMARKS_KEY = "world_seamarks_basemap";
|
public static final String WORLD_SEAMARKS_KEY = "world_seamarks_basemap";
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,6 +38,32 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
return itemsToUpdate;
|
return itemsToUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IndexItem getWorldBaseMapItem() {
|
||||||
|
DownloadResourceGroup worldMaps = getSubGroupById(DownloadResourceGroupType.WORLD_MAPS.getDefaultId());
|
||||||
|
IndexItem worldMap = null;
|
||||||
|
List<IndexItem> 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() {
|
public void updateLoadedFiles() {
|
||||||
initAlreadyLoadedFiles();
|
initAlreadyLoadedFiles();
|
||||||
prepareFilesToUpdate();
|
prepareFilesToUpdate();
|
||||||
|
|
|
@ -20,6 +20,7 @@ import net.osmand.plus.download.DownloadResourceGroup;
|
||||||
import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType;
|
import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType;
|
||||||
import net.osmand.plus.download.DownloadResources;
|
import net.osmand.plus.download.DownloadResources;
|
||||||
import net.osmand.plus.download.IndexItem;
|
import net.osmand.plus.download.IndexItem;
|
||||||
|
import net.osmand.plus.download.ui.popups.DownloadResourceGroupFragment;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.Resources;
|
||||||
import android.content.res.TypedArray;
|
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.DownloadResourceGroup.DownloadResourceGroupType;
|
||||||
import net.osmand.plus.download.DownloadResources;
|
import net.osmand.plus.download.DownloadResources;
|
||||||
import net.osmand.plus.download.IndexItem;
|
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 net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
|
@ -1,4 +1,4 @@
|
||||||
package net.osmand.plus.download.ui;
|
package net.osmand.plus.download.ui.popups;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.DialogFragment;
|
import android.app.DialogFragment;
|
Loading…
Reference in a new issue