Contour lines settings done
This commit is contained in:
parent
763f2ba220
commit
5290218362
13 changed files with 653 additions and 25 deletions
10
OsmAnd/res/drawable/buy_background_light.xml
Normal file
10
OsmAnd/res/drawable/buy_background_light.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="2dp" />
|
||||
<solid android:color="@null" />
|
||||
<stroke android:width="1.5dp" android:color="@color/buy_button_color" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
59
OsmAnd/res/layout/list_group_title_with_descr.xml
Normal file
59
OsmAnd/res/layout/list_group_title_with_descr.xml
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
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"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:minHeight="64dp"
|
||||
android:clickable="false"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/card_bottom_divider"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="6dp"/>
|
||||
|
||||
<include layout="@layout/card_top_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:minHeight="48dp"
|
||||
android:background="?attr/bg_color"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dp"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="Download map"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="4dp"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
android:paddingBottom="10dp"
|
||||
tools:text="For view contour lines on the map, you need to download contour line map of this region."/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -18,8 +18,9 @@
|
|||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:minHeight="48dp"
|
||||
android:background="?attr/bg_color"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
|
@ -31,6 +32,8 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
style="@style/TextAppearance.ListItemCategoryTitle"
|
||||
tools:text="Live updates"/>
|
||||
|
||||
|
|
55
OsmAnd/res/layout/list_group_title_with_switch_light.xml
Normal file
55
OsmAnd/res/layout/list_group_title_with_switch_light.xml
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
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:minHeight="64dp"
|
||||
android:clickable="false"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/card_bottom_divider"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="6dp"/>
|
||||
|
||||
<include layout="@layout/card_top_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:minHeight="48dp"
|
||||
android:background="?attr/bg_color"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
tools:text="Live updates"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/toggle_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
</LinearLayout>
|
97
OsmAnd/res/layout/list_item_icon_and_download.xml
Normal file
97
OsmAnd/res/layout/list_item_icon_and_download.xml
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/list_item_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/list_content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
tools:src="@drawable/ic_map"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/text_wrapper"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="Germany"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="25"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
tools:text="Contour Lines"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/ProgressBar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:visibility="visible"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/secondary_icon"
|
||||
android:layout_width="@dimen/list_item_height"
|
||||
android:layout_height="@dimen/list_item_height"
|
||||
android:scaleType="center"
|
||||
android:visibility="gone"
|
||||
tools:src="@drawable/ic_action_import"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/right_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="33dp"
|
||||
android:minWidth="40dp"
|
||||
android:paddingLeft="18dp"
|
||||
android:paddingRight="18dp"
|
||||
android:background="@drawable/buy_btn_background_light"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/dashFavIconMargin"
|
||||
android:layout_marginRight="8dp"
|
||||
android:textColor="@color/buy_button_color"
|
||||
android:text="@string/buy"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="56dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
</LinearLayout>
|
121
OsmAnd/res/layout/list_item_icon_and_right_btn.xml
Normal file
121
OsmAnd/res/layout/list_item_icon_and_right_btn.xml
Normal file
|
@ -0,0 +1,121 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout
|
||||
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"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:background="?attr/bg_color"
|
||||
android:minHeight="60dp"
|
||||
tools:layout_height="60dp">
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
tools:src="@drawable/ic_action_gabout_dark"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/text_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_toEndOf="@+id/icon"
|
||||
android:layout_toLeftOf="@+id/secondary_icon"
|
||||
android:layout_toRightOf="@+id/icon"
|
||||
android:layout_toStartOf="@+id/secondary_icon"
|
||||
android:minHeight="60dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="Some title text"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
tools:text="Some very long subtitle text, that won't fit into one line"/>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:id="@+id/secondary_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_margin="16dp"
|
||||
android:layout_toLeftOf="@+id/toggle_item"
|
||||
android:layout_toStartOf="@+id/toggle_item"
|
||||
android:visibility="gone"
|
||||
tools:src="@drawable/ic_action_gabout_dark"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/toggle_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toLeftOf="@+id/right_btn"
|
||||
android:layout_toStartOf="@+id/right_btn"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:focusable="false"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/right_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="33dp"
|
||||
android:minWidth="40dp"
|
||||
android:paddingLeft="18dp"
|
||||
android:paddingRight="18dp"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:gravity="center"
|
||||
android:layout_centerVertical="true"
|
||||
android:lines="1"
|
||||
android:background="@drawable/buy_background_light"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:textColor="@color/buy_button_color"
|
||||
android:text="@string/get_plugin"
|
||||
osmand:textAllCapsCompat="true"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignLeft="@+id/text_wrapper"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignStart="@+id/text_wrapper"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -9,6 +9,9 @@
|
|||
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
|
||||
-->
|
||||
<string name="srtm_menu_download_descr">For view contour lines on the map, you need to download contour line map of this region.</string>
|
||||
<string name="shared_string_plugin">Plugin</string>
|
||||
<string name="srtm_purchase_header">To see contour lines on the map, you need to buy and install plugin</string>
|
||||
<string name="srtm_color_scheme">Color scheme</string>
|
||||
<string name="show_from_zoom_level">Display from zoom level</string>
|
||||
<string name="routing_attr_allow_private_name">Allow private access</string>
|
||||
|
|
|
@ -222,7 +222,12 @@ public class ContextMenuAdapter {
|
|||
int secondaryDrawable = item.getSecondaryIcon();
|
||||
if (secondaryDrawable != ContextMenuItem.INVALID_ID) {
|
||||
@ColorRes
|
||||
int colorRes = lightTheme ? R.color.icon_color_light : R.color.dialog_inactive_text_color_dark;
|
||||
int colorRes;
|
||||
if (secondaryDrawable == R.drawable.ic_action_additional_option) {
|
||||
colorRes = lightTheme ? R.color.icon_color_light : R.color.dialog_inactive_text_color_dark;
|
||||
} else {
|
||||
colorRes = lightTheme ? R.color.icon_color : R.color.color_white;
|
||||
}
|
||||
Drawable drawable = mIconsCache.getIcon(item.getSecondaryIcon(), colorRes);
|
||||
ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon);
|
||||
imageView.setImageDrawable(drawable);
|
||||
|
@ -287,19 +292,27 @@ public class ContextMenuAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
if (convertView.findViewById(R.id.ProgressBar) != null) {
|
||||
ProgressBar bar = (ProgressBar) convertView.findViewById(R.id.ProgressBar);
|
||||
View progressBar = convertView.findViewById(R.id.ProgressBar);
|
||||
if (progressBar != null) {
|
||||
ProgressBar bar = (ProgressBar) progressBar;
|
||||
if (item.isLoading()) {
|
||||
int progress = item.getProgress();
|
||||
if (progress == ContextMenuItem.INVALID_ID) {
|
||||
bar.setIndeterminate(true);
|
||||
} else {
|
||||
bar.setIndeterminate(false);
|
||||
bar.setProgress(progress);
|
||||
}
|
||||
bar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
bar.setVisibility(View.INVISIBLE);
|
||||
bar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
View descriptionTextView = convertView.findViewById(R.id.description);
|
||||
if (descriptionTextView != null) {
|
||||
String itemDescr = item.getDescription();
|
||||
if (itemDescr != null) {
|
||||
if (itemDescr != null && (progressBar == null || !item.isLoading())) {
|
||||
((TextView) descriptionTextView).setText(itemDescr);
|
||||
descriptionTextView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
@ -328,7 +341,18 @@ public class ContextMenuAdapter {
|
|||
|
||||
public interface ItemClickListener {
|
||||
//boolean return type needed to desribe if drawer needed to be close or not
|
||||
boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked);
|
||||
boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter,
|
||||
int itemId,
|
||||
int position,
|
||||
boolean isChecked);
|
||||
}
|
||||
|
||||
public interface ProgressListener {
|
||||
boolean onProgressChanged(Object progressObject,
|
||||
int progress,
|
||||
ArrayAdapter<ContextMenuItem> adapter,
|
||||
int itemId,
|
||||
int position);
|
||||
}
|
||||
|
||||
public interface OnIntegerValueChangedListener {
|
||||
|
|
|
@ -20,7 +20,7 @@ public class ContextMenuItem {
|
|||
@ColorRes
|
||||
private int colorRes;
|
||||
@DrawableRes
|
||||
private final int secondaryIcon;
|
||||
private int secondaryIcon;
|
||||
private Boolean selected;
|
||||
private int progress;
|
||||
@LayoutRes
|
||||
|
@ -32,6 +32,7 @@ public class ContextMenuItem {
|
|||
private String description;
|
||||
private final ContextMenuAdapter.ItemClickListener itemClickListener;
|
||||
private final ContextMenuAdapter.OnIntegerValueChangedListener integerListener;
|
||||
private final ContextMenuAdapter.ProgressListener progressListener;
|
||||
private final boolean hideDivider;
|
||||
private final int minHeight;
|
||||
private final int tag;
|
||||
|
@ -50,6 +51,7 @@ public class ContextMenuItem {
|
|||
String description,
|
||||
ContextMenuAdapter.ItemClickListener itemClickListener,
|
||||
ContextMenuAdapter.OnIntegerValueChangedListener integerListener,
|
||||
ContextMenuAdapter.ProgressListener progressListener,
|
||||
boolean hideDivider,
|
||||
int minHeight,
|
||||
int tag) {
|
||||
|
@ -68,6 +70,7 @@ public class ContextMenuItem {
|
|||
this.description = description;
|
||||
this.itemClickListener = itemClickListener;
|
||||
this.integerListener = integerListener;
|
||||
this.progressListener = progressListener;
|
||||
this.hideDivider = hideDivider;
|
||||
this.minHeight = minHeight;
|
||||
this.tag = tag;
|
||||
|
@ -148,6 +151,10 @@ public class ContextMenuItem {
|
|||
return integerListener;
|
||||
}
|
||||
|
||||
public ContextMenuAdapter.ProgressListener getProgressListener() {
|
||||
return progressListener;
|
||||
}
|
||||
|
||||
public boolean shouldSkipPainting() {
|
||||
return skipPaintingWithoutColor;
|
||||
}
|
||||
|
@ -164,6 +171,10 @@ public class ContextMenuItem {
|
|||
this.mIcon = iconId;
|
||||
}
|
||||
|
||||
public void setSecondaryIcon(int secondaryIcon) {
|
||||
this.secondaryIcon = secondaryIcon;
|
||||
}
|
||||
|
||||
public void setColorRes(int colorRes) {
|
||||
this.colorRes = colorRes;
|
||||
}
|
||||
|
@ -216,6 +227,7 @@ public class ContextMenuItem {
|
|||
private String mDescription = null;
|
||||
private ContextMenuAdapter.ItemClickListener mItemClickListener = null;
|
||||
private ContextMenuAdapter.OnIntegerValueChangedListener mIntegerListener = null;
|
||||
private ContextMenuAdapter.ProgressListener mProgressListener = null;
|
||||
private boolean mSkipPaintingWithoutColor;
|
||||
private boolean mHideDivider;
|
||||
private int mMinHeight;
|
||||
|
@ -295,6 +307,11 @@ public class ContextMenuItem {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setProgressListener(ContextMenuAdapter.ProgressListener progressListener) {
|
||||
mProgressListener = progressListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setSkipPaintingWithoutColor(boolean skipPaintingWithoutColor) {
|
||||
mSkipPaintingWithoutColor = skipPaintingWithoutColor;
|
||||
return this;
|
||||
|
@ -322,8 +339,8 @@ public class ContextMenuItem {
|
|||
public ContextMenuItem createItem() {
|
||||
return new ContextMenuItem(mTitleId, mTitle, mIcon, mColorRes, mSecondaryIcon,
|
||||
mSelected, mProgress, mLayout, mLoading, mIsCategory, mSkipPaintingWithoutColor,
|
||||
mPosition, mDescription, mItemClickListener, mIntegerListener, mHideDivider,
|
||||
mMinHeight, mTag);
|
||||
mPosition, mDescription, mItemClickListener, mIntegerListener, mProgressListener,
|
||||
mHideDivider, mMinHeight, mTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1310,6 +1310,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
if (fragmentRef != null) {
|
||||
fragmentRef.get().newDownloadIndexes();
|
||||
}
|
||||
if (dashboardOnMap.isVisible()) {
|
||||
dashboardOnMap.onNewDownloadIndexes();
|
||||
}
|
||||
refreshMap();
|
||||
}
|
||||
|
||||
|
@ -1323,6 +1326,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
if (fragmentRef != null) {
|
||||
fragmentRef.get().downloadInProgress();
|
||||
}
|
||||
if (dashboardOnMap.isVisible()) {
|
||||
dashboardOnMap.onDownloadInProgress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1335,6 +1341,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
if (fragmentRef != null) {
|
||||
fragmentRef.get().downloadHasFinished();
|
||||
}
|
||||
if (dashboardOnMap.isVisible()) {
|
||||
dashboardOnMap.onDownloadHasFinished();
|
||||
}
|
||||
refreshMap();
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@ import net.osmand.plus.dashboard.tools.TransactionBuilder;
|
|||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.dialogs.RasterMapMenu;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadIndexesThread;
|
||||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.MapMarkerDialogHelper;
|
||||
import net.osmand.plus.helpers.MapMarkerDialogHelper.MapMarkersDialogHelperCallbacks;
|
||||
|
@ -86,6 +88,7 @@ import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener;
|
|||
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.DismissCallbacks;
|
||||
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.Undoable;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
|
||||
import net.osmand.search.core.ObjectType;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
|
@ -886,7 +889,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
&& visibleType != DashboardType.MAP_MARKERS
|
||||
&& visibleType != DashboardType.MAP_MARKERS_SELECTION
|
||||
&& visibleType != DashboardType.CONFIGURE_SCREEN
|
||||
&& visibleType != DashboardType.CONFIGURE_MAP) {
|
||||
&& visibleType != DashboardType.CONFIGURE_MAP
|
||||
&& visibleType != DashboardType.CONTOUR_LINES) {
|
||||
listView.setDivider(dividerDrawable);
|
||||
listView.setDividerHeight(dpToPx(1f));
|
||||
} else {
|
||||
|
@ -982,6 +986,37 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
updateListAdapter(listAdapter, listener);
|
||||
}
|
||||
|
||||
public void onNewDownloadIndexes() {
|
||||
if (visibleType == DashboardType.CONTOUR_LINES) {
|
||||
refreshContent(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void onDownloadInProgress() {
|
||||
if (visibleType == DashboardType.CONTOUR_LINES) {
|
||||
DownloadIndexesThread downloadThread = getMyApplication().getDownloadThread();
|
||||
IndexItem downloadIndexItem = downloadThread.getCurrentDownloadingItem();
|
||||
if (downloadIndexItem != null) {
|
||||
int downloadProgress = downloadThread.getCurrentDownloadingItemProgress();
|
||||
ArrayAdapter<ContextMenuItem> adapter = (ArrayAdapter<ContextMenuItem>) listAdapter;
|
||||
for (int i = 0; i < adapter.getCount(); i++) {
|
||||
ContextMenuItem item = adapter.getItem(i);
|
||||
if (item != null && item.getProgressListener() != null) {
|
||||
item.getProgressListener().onProgressChanged(
|
||||
downloadIndexItem, downloadProgress, adapter, (int) adapter.getItemId(i), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onDownloadHasFinished() {
|
||||
if (visibleType == DashboardType.CONTOUR_LINES) {
|
||||
refreshContent(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshContent(boolean force) {
|
||||
if (visibleType == DashboardType.WAYPOINTS
|
||||
|| visibleType == DashboardType.MAP_MARKERS
|
||||
|
@ -989,7 +1024,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
|| visibleType == DashboardType.CONFIGURE_SCREEN
|
||||
|| force) {
|
||||
updateListAdapter();
|
||||
} else if (visibleType == DashboardType.CONFIGURE_MAP || visibleType == DashboardType.ROUTE_PREFERENCES) {
|
||||
} else if (visibleType == DashboardType.CONFIGURE_MAP
|
||||
|| visibleType == DashboardType.ROUTE_PREFERENCES) {
|
||||
int index = listView.getFirstVisiblePosition();
|
||||
View v = listView.getChildAt(0);
|
||||
int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop());
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
package net.osmand.plus.srtmplugin;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import net.osmand.binary.BinaryMapDataObject;
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.map.OsmandRegions;
|
||||
import net.osmand.map.WorldRegion;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -10,11 +16,20 @@ import net.osmand.plus.OsmandPlugin;
|
|||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.activities.PluginActivity;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
import net.osmand.plus.download.DownloadIndexesThread;
|
||||
import net.osmand.plus.download.DownloadValidationManager;
|
||||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.views.GPXLayer;
|
||||
import net.osmand.plus.views.RouteLayer;
|
||||
import net.osmand.render.RenderingRuleProperty;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR;
|
||||
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_DISABLED_VALUE;
|
||||
|
@ -24,6 +39,10 @@ public class ContourLinesMenu {
|
|||
private static final String TAG = "ContourLinesMenu";
|
||||
|
||||
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity) {
|
||||
SRTMPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
|
||||
if (plugin != null && !plugin.isActive() && !plugin.needsInstallation()) {
|
||||
OsmandPlugin.enablePlugin(mapActivity, mapActivity.getMyApplication(), plugin, true);
|
||||
}
|
||||
ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
|
||||
createLayersItems(adapter, mapActivity);
|
||||
|
@ -35,6 +54,7 @@ public class ContourLinesMenu {
|
|||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
final SRTMPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
|
||||
final boolean srtmEnabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null;
|
||||
|
||||
final RenderingRuleProperty contourLinesProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_ATTR);
|
||||
final RenderingRuleProperty colorSchemeProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_SCHEME_ATTR);
|
||||
|
@ -102,6 +122,11 @@ public class ContourLinesMenu {
|
|||
refreshMapComplete(mapActivity);
|
||||
}
|
||||
});
|
||||
} else if (itemId == R.string.srtm_plugin_name) {
|
||||
Intent intent = new Intent(mapActivity, PluginActivity.class);
|
||||
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, plugin.getId());
|
||||
mapActivity.startActivity(intent);
|
||||
closeDashboard(mapActivity);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -122,7 +147,6 @@ public class ContourLinesMenu {
|
|||
.setTitleId(toggleActionStringId, mapActivity)
|
||||
.setIcon(toggleIconId)
|
||||
.setColor(toggleIconColorId)
|
||||
.hideDivider(true)
|
||||
.setListener(l)
|
||||
.setSelected(selected).createItem());
|
||||
if (selected) {
|
||||
|
@ -130,17 +154,130 @@ public class ContourLinesMenu {
|
|||
.setTitleId(showZoomLevelStringId, mapActivity)
|
||||
.setLayout(R.layout.list_item_single_line_descrition_narrow)
|
||||
.setIcon(R.drawable.ic_action_map_magnifier)
|
||||
.hideDivider(true)
|
||||
.setDescription(plugin.getPrefDescription(app, contourLinesProp, pref))
|
||||
.setListener(l).createItem());
|
||||
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(colorSchemeStringId, mapActivity)
|
||||
.setLayout(R.layout.list_item_single_line_descrition_narrow)
|
||||
.setIcon(R.drawable.ic_action_appearance)
|
||||
.hideDivider(true)
|
||||
.setDescription(plugin.getPrefDescription(app, colorSchemeProp, colorPref))
|
||||
.setListener(l).createItem());
|
||||
}
|
||||
|
||||
if (!srtmEnabled) {
|
||||
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.srtm_purchase_header, mapActivity)
|
||||
.setCategory(true).setLayout(R.layout.list_group_title_with_switch_light).createItem());
|
||||
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.srtm_plugin_name, mapActivity)
|
||||
.setLayout(R.layout.list_item_icon_and_right_btn)
|
||||
.setIcon(R.drawable.ic_plugin_srtm)
|
||||
.setColor(R.color.osmand_orange)
|
||||
.setDescription(app.getString(R.string.shared_string_plugin))
|
||||
.setListener(l).createItem());
|
||||
} else {
|
||||
final DownloadIndexesThread downloadThread = app.getDownloadThread();
|
||||
if (!downloadThread.getIndexes().isDownloadedFromInternet) {
|
||||
if (settings.isInternetConnectionAvailable()) {
|
||||
downloadThread.runReloadIndexFiles();
|
||||
}
|
||||
}
|
||||
final boolean downloadIndexes = settings.isInternetConnectionAvailable()
|
||||
&& !downloadThread.getIndexes().isDownloadedFromInternet
|
||||
&& !downloadThread.getIndexes().downloadFromInternetFailed;
|
||||
|
||||
if (downloadIndexes) {
|
||||
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.shared_string_download_map, mapActivity)
|
||||
.setDescription(app.getString(R.string.srtm_menu_download_descr))
|
||||
.setCategory(true)
|
||||
.setLayout(R.layout.list_group_title_with_descr).createItem());
|
||||
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setLayout(R.layout.list_item_icon_and_download)
|
||||
.setTitleId(R.string.downloading_list_indexes, mapActivity)
|
||||
.setLoading(true)
|
||||
.setListener(l).createItem());
|
||||
} else {
|
||||
try {
|
||||
IndexItem currentDownloadingItem = downloadThread.getCurrentDownloadingItem();
|
||||
int currentDownloadingProgress = downloadThread.getCurrentDownloadingItemProgress();
|
||||
List<IndexItem> srtms = findSrtmIndexItems(app, mapActivity.getMapLocation());
|
||||
if (srtms.size() > 0) {
|
||||
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.shared_string_download_map, mapActivity)
|
||||
.setDescription(app.getString(R.string.srtm_menu_download_descr))
|
||||
.setCategory(true)
|
||||
.setLayout(R.layout.list_group_title_with_descr).createItem());
|
||||
for (final IndexItem indexItem : srtms) {
|
||||
ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder()
|
||||
.setLayout(R.layout.list_item_icon_and_download)
|
||||
.setTitle(indexItem.getVisibleName(app, app.getRegions(), false))
|
||||
.setDescription(app.getString(R.string.srtm_plugin_name) + " • " + indexItem.getSizeDescription(app))
|
||||
.setIcon(R.drawable.ic_plugin_srtm)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked) {
|
||||
ContextMenuItem item = adapter.getItem(position);
|
||||
if (downloadThread.isDownloading(indexItem)) {
|
||||
downloadThread.cancelDownload(indexItem);
|
||||
if (item != null) {
|
||||
item.setProgress(ContextMenuItem.INVALID_ID);
|
||||
item.setLoading(false);
|
||||
item.setSecondaryIcon(R.drawable.ic_action_import);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
} else {
|
||||
new DownloadValidationManager(app).startDownload(mapActivity, indexItem);
|
||||
if (item != null) {
|
||||
item.setProgress(ContextMenuItem.INVALID_ID);
|
||||
item.setLoading(true);
|
||||
item.setSecondaryIcon(R.drawable.ic_action_remove_dark);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.setProgressListener(new ContextMenuAdapter.ProgressListener() {
|
||||
@Override
|
||||
public boolean onProgressChanged(Object progressObject, int progress,
|
||||
ArrayAdapter<ContextMenuItem> adapter,
|
||||
int itemId, int position) {
|
||||
if (progressObject != null && progressObject instanceof IndexItem) {
|
||||
IndexItem progressItem = (IndexItem) progressObject;
|
||||
if (indexItem.compareTo(progressItem) == 0) {
|
||||
ContextMenuItem item = adapter.getItem(position);
|
||||
if (item != null) {
|
||||
item.setProgress(progress);
|
||||
item.setLoading(true);
|
||||
item.setSecondaryIcon(R.drawable.ic_action_remove_dark);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (indexItem == currentDownloadingItem) {
|
||||
itemBuilder.setLoading(true)
|
||||
.setProgress(currentDownloadingProgress)
|
||||
.setSecondaryIcon(R.drawable.ic_action_remove_dark);
|
||||
} else {
|
||||
itemBuilder.setSecondaryIcon(R.drawable.ic_action_import);
|
||||
}
|
||||
contextMenuAdapter.addItem(itemBuilder.createItem());
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeDashboard(MapActivity mapActivity) {
|
||||
mapActivity.getDashboard().hideDashboard(false);
|
||||
}
|
||||
|
||||
public static void refreshMapComplete(final MapActivity activity) {
|
||||
|
@ -156,4 +293,53 @@ public class ContourLinesMenu {
|
|||
}
|
||||
activity.getMapView().refreshMap(true);
|
||||
}
|
||||
|
||||
public static List<IndexItem> findSrtmIndexItems(OsmandApplication app, LatLon latLon) throws IOException {
|
||||
|
||||
List<IndexItem> res = new ArrayList<>();
|
||||
OsmandRegions regions = app.getRegions();
|
||||
DownloadIndexesThread downloadThread = app.getDownloadThread();
|
||||
|
||||
int point31x = MapUtils.get31TileNumberX(latLon.getLongitude());
|
||||
int point31y = MapUtils.get31TileNumberY(latLon.getLatitude());
|
||||
|
||||
List<BinaryMapDataObject> mapDataObjects;
|
||||
try {
|
||||
mapDataObjects = regions.queryBbox(point31x, point31x, point31y, point31y);
|
||||
} catch (IOException e) {
|
||||
throw new IOException("Error while calling queryBbox");
|
||||
}
|
||||
if (mapDataObjects != null) {
|
||||
Iterator<BinaryMapDataObject> it = mapDataObjects.iterator();
|
||||
while (it.hasNext()) {
|
||||
BinaryMapDataObject o = it.next();
|
||||
if (o.getTypes() != null) {
|
||||
boolean isRegion = true;
|
||||
for (int i = 0; i < o.getTypes().length; i++) {
|
||||
BinaryMapIndexReader.TagValuePair tp = o.getMapIndex().decodeType(o.getTypes()[i]);
|
||||
if ("boundary".equals(tp.value)) {
|
||||
isRegion = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
WorldRegion downloadRegion = regions.getRegionData(regions.getFullName(o));
|
||||
if (downloadRegion == null || !isRegion || !regions.contain(o, point31x, point31y)) {
|
||||
it.remove();
|
||||
}
|
||||
List<IndexItem> otherIndexItems = new ArrayList<>(downloadThread.getIndexes().getIndexItems(downloadRegion));
|
||||
for (IndexItem indexItem : otherIndexItems) {
|
||||
if (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE
|
||||
&& !res.contains(indexItem)) {
|
||||
if (indexItem.isDownloaded()) {
|
||||
res.clear();
|
||||
return res;
|
||||
}
|
||||
res.add(indexItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,21 +141,29 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
toggleContourLines(mapActivity, isChecked, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ContextMenuItem item = adapter.getItem(position);
|
||||
if (item != null) {
|
||||
RenderingRuleProperty contourLinesProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_ATTR);
|
||||
if (contourLinesProp != null) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
final OsmandSettings.CommonPreference<String> pref =
|
||||
settings.getCustomRenderProperty(contourLinesProp.getAttrName());
|
||||
boolean selected = !pref.get().equals(CONTOUR_LINES_DISABLED_VALUE);
|
||||
RenderingRuleProperty contourLinesProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_ATTR);
|
||||
if (contourLinesProp != null) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
final OsmandSettings.CommonPreference<String> pref =
|
||||
settings.getCustomRenderProperty(contourLinesProp.getAttrName());
|
||||
boolean selected = !pref.get().equals(CONTOUR_LINES_DISABLED_VALUE);
|
||||
|
||||
SRTMPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
|
||||
if (selected && plugin != null && !plugin.isActive() && !plugin.needsInstallation()) {
|
||||
OsmandPlugin.enablePlugin(mapActivity, mapActivity.getMyApplication(), plugin, true);
|
||||
}
|
||||
|
||||
ContextMenuItem item = adapter.getItem(position);
|
||||
if (item != null) {
|
||||
item.setDescription(app.getString(R.string.display_zoom_level,
|
||||
getPrefDescription(app, contourLinesProp, pref)));
|
||||
item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||
item.setSelected(selected);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
ContourLinesMenu.refreshMapComplete(mapActivity);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
} else if (itemId == R.string.layer_hillshade) {
|
||||
|
|
Loading…
Reference in a new issue