Added map download popup

This commit is contained in:
Alexey Kulish 2015-10-27 17:40:44 +03:00
parent eb54fc093c
commit d7c1636460
5 changed files with 236 additions and 1 deletions

View file

@ -0,0 +1,100 @@
<?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"
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/map_downloaded"
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/map_downloaded_descr"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"/>
<Button
android:id="@+id/actionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
style="@style/Widget.AppCompat.Button.Borderless"
android:textColor="?attr/contextMenuButtonColor"
tools:background="@color/color_warning"
android:text="@string/go_to_map"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>

View file

@ -9,6 +9,9 @@
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="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="go_to_map">Go to the map</string>
<string name="simulate_initial_startup_descr">"Sets the flag indicating first app startup, keeps all other settings unchanged"</string> <string name="simulate_initial_startup_descr">"Sets the flag indicating first app startup, keeps all other settings unchanged"</string>
<string name="simulate_initial_startup">Simulate first app start</string> <string name="simulate_initial_startup">Simulate first app start</string>
<string name="share_geo">geo:</string> <string name="share_geo">geo:</string>

View file

@ -283,6 +283,11 @@
<item name="@android:windowExitAnimation">@anim/shrink_from_top</item> <item name="@android:windowExitAnimation">@anim/shrink_from_top</item>
</style> </style>
<style name="Animations.PopUpMenu.Bottom">
<item name="@android:windowEnterAnimation">@anim/slide_in_bottom</item>
<item name="@android:windowExitAnimation">@anim/slide_out_bottom</item>
</style>
<style name="create_poi_text_field"> <style name="create_poi_text_field">
<item name="android:layout_marginTop">8dp</item> <item name="android:layout_marginTop">8dp</item>
<item name="android:layout_marginRight">16dp</item> <item name="android:layout_marginRight">16dp</item>

View file

@ -38,6 +38,7 @@ 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.DownloadResourceGroupFragment;
import net.osmand.plus.download.ui.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.views.controls.PagerSlidingTabStrip; import net.osmand.plus.views.controls.PagerSlidingTabStrip;
@ -213,7 +214,9 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
@UiThread @UiThread
public void downloadHasFinished() { public void downloadHasFinished() {
visibleBanner.updateBannerInProgress(); visibleBanner.updateBannerInProgress();
if(downloadItem != null && !WorldRegion.WORLD_BASEMAP.equals(downloadItem.getRegionDownloadNameLC())) { if(downloadItem != null && downloadItem != getMyApplication().getRegions().getWorldRegion()
&& !WorldRegion.WORLD_BASEMAP.equals(downloadItem.getRegionDownloadNameLC())) {
boolean firstMap = !getMyApplication().getSettings().FIRST_MAP_IS_DOWNLOADED.get(); boolean firstMap = !getMyApplication().getSettings().FIRST_MAP_IS_DOWNLOADED.get();
if(firstMap) { if(firstMap) {
initSettingsFirstMap(downloadItem); initSettingsFirstMap(downloadItem);
@ -540,6 +543,8 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
private void showGoToMap(WorldRegion worldRegion) { private void showGoToMap(WorldRegion worldRegion) {
// TODO Show dialog go to map (coordinates to open take from WorldRegion.getCenter) // TODO Show dialog go to map (coordinates to open take from WorldRegion.getCenter)
GoToMapFragment.showInstance(worldRegion, this);
LOG.warn("111 - region=" + worldRegion.getRegionId());
} }

View file

@ -0,0 +1,122 @@
package net.osmand.plus.download.ui;
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.ImageView;
import android.widget.TextView;
import net.osmand.data.LatLon;
import net.osmand.map.WorldRegion;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.download.DownloadActivity;
public class GoToMapFragment extends DialogFragment {
public static final String TAG = "GoToMapFragment";
private static final String KEY_GOTO_MAP_REGION_CENTER = "key_goto_map_region_center";
private static final String KEY_GOTO_MAP_REGION_NAME = "key_goto_map_region_name";
private LatLon regionCenter;
private String regionName;
@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) {
regionName = savedInstanceState.getString(KEY_GOTO_MAP_REGION_NAME, "");
Object rCenterObj = savedInstanceState.getSerializable(KEY_GOTO_MAP_REGION_CENTER);
if (rCenterObj != null) {
regionCenter = (LatLon) rCenterObj;
} else {
regionCenter = new LatLon(0, 0);
}
}
View view = inflater.inflate(R.layout.go_to_map_fragment, container, false);
((ImageView) view.findViewById(R.id.titleIconImageView))
.setImageDrawable(getIcon(R.drawable.ic_map, R.color.osmand_orange));
((TextView) view.findViewById(R.id.descriptionTextView))
.setText(getActivity().getString(R.string.map_downloaded_descr, regionName));
view.findViewById(R.id.closeImageButton)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
view.findViewById(R.id.actionButton)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
OsmandApplication app = (OsmandApplication) getActivity().getApplication();
app.getSettings().setMapLocationToShow(regionCenter.getLatitude(), regionCenter.getLongitude(), 5, null);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
});
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) {
outState.putString(KEY_GOTO_MAP_REGION_NAME, regionName);
outState.putSerializable(KEY_GOTO_MAP_REGION_CENTER, regionCenter);
}
private OsmandApplication getMyApplication() {
return (OsmandApplication) getActivity().getApplication();
}
private Drawable getIcon(@DrawableRes int drawableRes, @ColorRes int color) {
return getMyApplication().getIconsCache().getIcon(drawableRes, color);
}
public static void showInstance(WorldRegion region, DownloadActivity activity) {
GoToMapFragment fragment = new GoToMapFragment();
fragment.regionCenter = region.getRegionCenter();
fragment.regionName = region.getLocaleName();
fragment.show(activity.getFragmentManager(), TAG);
}
}