From f6bd47fae2d4264c904a4b780eea5f362655ff95 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Fri, 23 Oct 2015 10:30:40 +0300 Subject: [PATCH] Dialog in progress --- .../fragment_data_storage_place_dialog.xml | 113 ++++++++++++++++++ OsmAnd/res/values/sizes.xml | 2 + OsmAnd/res/values/strings.xml | 3 + OsmAnd/res/values/styles.xml | 16 +++ OsmAnd/src/net/osmand/plus/IconsCache.java | 21 ++-- .../plus/download/DownloadActivity.java | 2 + .../ui/DataStoragePlaceDialogFragment.java | 62 ++++++++++ 7 files changed, 210 insertions(+), 9 deletions(-) create mode 100644 OsmAnd/res/layout/fragment_data_storage_place_dialog.xml create mode 100644 OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java diff --git a/OsmAnd/res/layout/fragment_data_storage_place_dialog.xml b/OsmAnd/res/layout/fragment_data_storage_place_dialog.xml new file mode 100644 index 0000000000..aa774a7968 --- /dev/null +++ b/OsmAnd/res/layout/fragment_data_storage_place_dialog.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 2e2692a9d7..d6bdfc359f 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -109,4 +109,6 @@ 14sp 12sp 23sp + + 20sp \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index cff0ab2cac..c96d2db668 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -2019,4 +2019,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A Update all (%1$s MB) Free downloads used You can set how many free downloads you have used + + + Hello blank fragment diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml index 25b96c53f2..7233aa84cd 100644 --- a/OsmAnd/res/values/styles.xml +++ b/OsmAnd/res/values/styles.xml @@ -284,4 +284,20 @@ wrap_content wrap_content + + diff --git a/OsmAnd/src/net/osmand/plus/IconsCache.java b/OsmAnd/src/net/osmand/plus/IconsCache.java index 271d5e25e0..2b8a9fdbaa 100644 --- a/OsmAnd/src/net/osmand/plus/IconsCache.java +++ b/OsmAnd/src/net/osmand/plus/IconsCache.java @@ -4,6 +4,9 @@ import android.graphics.Bitmap; import android.graphics.PorterDuff; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; +import android.support.annotation.ColorInt; +import android.support.annotation.ColorRes; +import android.support.annotation.DrawableRes; import gnu.trove.map.hash.TLongObjectHashMap; @@ -29,11 +32,11 @@ public class IconsCache { return new BitmapDrawable(app.getResources(), bitmapResized); } - private Drawable getDrawable(int resId, int clrId) { + private Drawable getDrawable(@DrawableRes int resId, @ColorRes int clrId) { return getDrawable(resId, clrId, 0); } - private Drawable getDrawable(int resId, int clrId, float scale) { + private Drawable getDrawable(@DrawableRes int resId, @ColorRes int clrId, float scale) { long hash = ((long)resId << 31l) + clrId + (int)(scale * 10000f); Drawable d = drawable.get(hash); if(d == null) { @@ -51,7 +54,7 @@ public class IconsCache { return d; } - private Drawable getPaintedDrawable(int resId, int color){ + private Drawable getPaintedDrawable(@DrawableRes int resId, @ColorInt int color){ long hash = ((long)resId << 31l) + color; Drawable d = drawable.get(hash); if(d == null) { @@ -63,27 +66,27 @@ public class IconsCache { return d; } - public Drawable getPaintedContentIcon(int id, int color){ + public Drawable getPaintedContentIcon(@DrawableRes int id, @ColorInt int color){ return getPaintedDrawable(id, color); } - public Drawable getIcon(int id, int colorId) { + public Drawable getIcon(@DrawableRes int id, @ColorRes int colorId) { return getDrawable(id, colorId); } - public Drawable getIcon(int id, int colorId, float scale) { + public Drawable getIcon(@DrawableRes int id, @ColorRes int colorId, float scale) { return getDrawable(id, colorId, scale); } - public Drawable getContentIcon(int id) { + public Drawable getContentIcon(@DrawableRes int id) { return getDrawable(id, app.getSettings().isLightContent() ? R.color.icon_color : 0); } - public Drawable getIcon(int id) { + public Drawable getIcon(@DrawableRes int id) { return getDrawable(id, 0); } - public Drawable getIcon(int id, boolean light) { + public Drawable getIcon(@DrawableRes int id, boolean light) { return getDrawable(id, light ? R.color.icon_color : 0); } diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 7738588eb3..fdc9cd318c 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -18,6 +18,7 @@ import net.osmand.plus.activities.TabActivity; import net.osmand.plus.base.BasicProgressAsyncTask; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; 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.LocalIndexesFragment; import net.osmand.plus.download.ui.UpdatesIndexFragment; @@ -125,6 +126,7 @@ public class DownloadActivity extends BaseDownloadActivity { filter = intent.getExtras().getString(FILTER_KEY); filterCat = intent.getExtras().getString(FILTER_CAT); } + new DataStoragePlaceDialogFragment().show(getFragmentManager(), null); } @Override diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java new file mode 100644 index 0000000000..fa5412864a --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java @@ -0,0 +1,62 @@ +package net.osmand.plus.download.ui; + +import android.app.Activity; +import android.app.Dialog; +import android.app.DialogFragment; +import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.os.Bundle; +import android.app.Fragment; +import android.support.annotation.AnyRes; +import android.support.annotation.ColorInt; +import android.support.annotation.ColorRes; +import android.support.annotation.DrawableRes; +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 net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; + +public class DataStoragePlaceDialogFragment extends DialogFragment { + + public DataStoragePlaceDialogFragment() { + // Required empty public constructor + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + final Dialog dialog = new Dialog(getActivity(), R.style.BottomSheet_Dialog); + Window window = dialog.getWindow(); + window.setGravity(Gravity.CENTER); + return dialog; + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + final View view = inflater.inflate(R.layout.fragment_data_storage_place_dialog, container, + false); + ((ImageView) view.findViewById(R.id.folderIconImageView)) + .setImageDrawable(getIcon(R.drawable.ic_action_folder, R.color.map_widget_blue)); + return view; + } + + public OsmandApplication getMyApplication() { + return (OsmandApplication) getActivity().getApplication(); + } + + public Drawable getContentIcon(@DrawableRes int drawableRes) { + return getMyApplication().getIconsCache().getContentIcon(drawableRes); + } + + + public Drawable getIcon(@DrawableRes int drawableRes, @ColorRes int color) { + return getMyApplication().getIconsCache().getIcon(drawableRes, color); + } +}