Dialog in progress

This commit is contained in:
GaidamakUA 2015-10-23 10:30:40 +03:00
parent fa4e42f3c3
commit f6bd47fae2
7 changed files with 210 additions and 9 deletions

View file

@ -0,0 +1,113 @@
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
tools:background="@color/color_warning"
tools:context="net.osmand.plus.download.ui.DataStoragePlaceDialogFragment">
<ImageView
android:id="@+id/folderIconImageView"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
android:scaleType="center"
tools:src="@drawable/ic_action_folder"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_columnSpan="2"
android:layout_columnWeight="1"
android:layout_gravity="fill_horizontal"
android:layout_marginTop="22dp"
android:text="Data storage folder"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="@dimen/dialog_header_text_size"/>
<ImageButton
android:id="@+id/crossIconImageView"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="44dp"
android:layout_height="44dp"
android:src="@drawable/ic_action_remove_dark"/>
<TextView
android:layout_width="0dp"
android:layout_column="1"
android:layout_columnSpan="2"
android:layout_gravity="fill_horizontal"
android:layout_marginBottom="24dp"
android:layout_row="1"
android:text="Choose where you want to save map files."
android:textSize="16sp"/>
<ImageView
android:id="@+id/deviceMemoryImageView"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_column="1"
android:layout_row="2"
android:layout_rowSpan="2"
android:paddingRight="16dp"
android:scaleType="center"
android:src="@drawable/ic_sdcard"/>
<TextView
android:id="@+id/deviceMemoryTitle"
android:layout_width="0dp"
android:layout_column="2"
android:layout_gravity="fill_horizontal"
android:layout_marginTop="8dp"
android:layout_row="2"
android:gravity="center_vertical"
android:text="Device memory"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:id="@+id/deviceMemoryDescription"
android:layout_width="0dp"
android:layout_column="2"
android:layout_gravity="fill_horizontal"
android:layout_row="3"
android:text="Free: 568 Mb"/>
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_column="1"
android:layout_columnSpan="3"
android:layout_gravity="fill_horizontal"
android:layout_row="4"
android:background="#FFF"/>
<ImageView
android:id="@+id/memoryStickImageView"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_column="1"
android:layout_row="5"
android:layout_rowSpan="2"
android:paddingRight="16dp"
android:scaleType="center"
android:src="@drawable/ic_sdcard"/>
<TextView
android:id="@+id/memoryStickTitle"
android:layout_width="0dp"
android:layout_column="2"
android:layout_gravity="fill_horizontal"
android:layout_marginTop="8dp"
android:layout_row="5"
android:text="Memory stick"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:layout_width="0dp"
android:layout_column="2"
android:layout_gravity="fill_horizontal"
android:layout_row="6"
android:text="Free: 9 Gb"
android:id="@+id/memoryStickDescription"/>
</GridLayout>

View file

@ -109,4 +109,6 @@
<dimen name="default_desc_text_size">14sp</dimen> <dimen name="default_desc_text_size">14sp</dimen>
<dimen name="default_sub_text_size">12sp</dimen> <dimen name="default_sub_text_size">12sp</dimen>
<dimen name="welcome_header_text_size">23sp</dimen> <dimen name="welcome_header_text_size">23sp</dimen>
<dimen name="dialog_header_text_size">20sp</dimen>
</resources> </resources>

View file

@ -2019,4 +2019,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="update_all">Update all (%1$s MB)</string> <string name="update_all">Update all (%1$s MB)</string>
<string name="free_downloads_used">Free downloads used</string> <string name="free_downloads_used">Free downloads used</string>
<string name="free_downloads_used_description">You can set how many free downloads you have used</string> <string name="free_downloads_used_description">You can set how many free downloads you have used</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>

View file

@ -284,4 +284,20 @@
<item name="android:layout_width">wrap_content</item> <item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
</style> </style>
<style name="BottomSheet.Dialog" parent="android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:textColor">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:backgroundDimAmount">0.3</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:textColorPrimary">#DD000000</item>
<item name="android:textColorSecondary">#8A000000</item>
<item name="android:textColorHint">#42000000</item>
</style>
</resources> </resources>

View file

@ -4,6 +4,9 @@ import android.graphics.Bitmap;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; 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; import gnu.trove.map.hash.TLongObjectHashMap;
@ -29,11 +32,11 @@ public class IconsCache {
return new BitmapDrawable(app.getResources(), bitmapResized); 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); 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); long hash = ((long)resId << 31l) + clrId + (int)(scale * 10000f);
Drawable d = drawable.get(hash); Drawable d = drawable.get(hash);
if(d == null) { if(d == null) {
@ -51,7 +54,7 @@ public class IconsCache {
return d; return d;
} }
private Drawable getPaintedDrawable(int resId, int color){ private Drawable getPaintedDrawable(@DrawableRes int resId, @ColorInt int color){
long hash = ((long)resId << 31l) + color; long hash = ((long)resId << 31l) + color;
Drawable d = drawable.get(hash); Drawable d = drawable.get(hash);
if(d == null) { if(d == null) {
@ -63,27 +66,27 @@ public class IconsCache {
return d; return d;
} }
public Drawable getPaintedContentIcon(int id, int color){ public Drawable getPaintedContentIcon(@DrawableRes int id, @ColorInt int color){
return getPaintedDrawable(id, 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); 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); 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); 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); 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); return getDrawable(id, light ? R.color.icon_color : 0);
} }

View file

@ -18,6 +18,7 @@ import net.osmand.plus.activities.TabActivity;
import net.osmand.plus.base.BasicProgressAsyncTask; import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
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.DownloadResourceGroupFragment; import net.osmand.plus.download.ui.DownloadResourceGroupFragment;
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;
@ -125,6 +126,7 @@ public class DownloadActivity extends BaseDownloadActivity {
filter = intent.getExtras().getString(FILTER_KEY); filter = intent.getExtras().getString(FILTER_KEY);
filterCat = intent.getExtras().getString(FILTER_CAT); filterCat = intent.getExtras().getString(FILTER_CAT);
} }
new DataStoragePlaceDialogFragment().show(getFragmentManager(), null);
} }
@Override @Override

View file

@ -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);
}
}