Resources fix

This commit is contained in:
Alexey Kulish 2015-09-10 16:50:47 +03:00
parent 326de731b3
commit 89186bd2b3
9 changed files with 211 additions and 165 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bottom_shadow" />
<nine-patch android:src="@drawable/bg_contextmenu_dots_light" />
</item>
<item>
<shape>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bottom_shadow" />
<nine-patch android:src="@drawable/bg_contextmenu_dots_light" />
</item>
<item>
<shape>

View file

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/context_menu_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/context_menu_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/context_menu_shadow_view"
@ -18,150 +19,165 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/bg_map_context_menu"
android:orientation="vertical">
<LinearLayout
android:id="@+id/context_menu_top_view"
android:baselineAligned="false"
android:id="@+id/context_menu_top_shadow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_height="20dp"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/context_menu_icon_layout"
android:orientation="horizontal"
android:layout_width="42dp"
android:layout_height="match_parent">
<ImageView
android:id="@+id/context_menu_icon_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="center"
android:layout_marginStart="12dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="18dp"
android:src="@drawable/ic_action_building_number"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="15dp"
android:layout_marginBottom="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/context_menu_line1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/search_address_building"
android:textSize="@dimen/default_list_text_size_large"
android:textColor="?android:textColorPrimary"/>
<TextView
android:id="@+id/context_menu_line2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="4dp"
android:text="@string/other_location"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
<LinearLayout
android:id="@+id/context_menu_close_btn_layout"
android:orientation="horizontal"
android:layout_width="32dp"
android:layout_height="match_parent">
<ImageView
android:id="@+id/context_menu_close_btn_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="12dp"
android:scaleType="center"
android:src="@drawable/ic_action_remove_dark"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:id="@+id/context_menu_buttons"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="54dp">
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_map_context_menu"
android:orientation="vertical">
<ImageButton
android:id="@+id/context_menu_route_button"
<LinearLayout
android:id="@+id/context_menu_top_view"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:scaleType="center"
android:background="?attr/dashboard_button"
android:src="@drawable/map_directions"/>
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/context_menu_icon_layout"
android:layout_width="42dp"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/context_menu_icon_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="18dp"
android:scaleType="center"
android:src="@drawable/ic_action_building_number"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/context_menu_line1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/search_address_building"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size_large"/>
<TextView
android:id="@+id/context_menu_line2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="4dp"
android:text="@string/other_location"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
<LinearLayout
android:id="@+id/context_menu_close_btn_layout"
android:layout_width="32dp"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/context_menu_close_btn_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="12dp"
android:scaleType="center"
android:src="@drawable/ic_action_remove_dark"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_height="match_parent"
android:layout_width="1dp"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<ImageButton
android:id="@+id/context_menu_fav_button"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:scaleType="center"
android:background="?attr/dashboard_button"
android:src="@drawable/ic_action_fav_dark"/>
<LinearLayout
android:id="@+id/context_menu_buttons"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="54dp">
<View
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="?attr/dashboard_divider"/>
<ImageButton
android:id="@+id/context_menu_route_button"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="?attr/dashboard_button"
android:scaleType="center"
android:src="@drawable/map_directions"/>
<ImageButton
android:id="@+id/context_menu_share_button"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:scaleType="center"
android:background="?attr/dashboard_button"
android:src="@drawable/abc_ic_menu_share_mtrl_alpha"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/>
<View
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="?attr/dashboard_divider"/>
<ImageButton
android:id="@+id/context_menu_fav_button"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="?attr/dashboard_button"
android:scaleType="center"
android:src="@drawable/ic_action_fav_dark"/>
<ImageButton
android:id="@+id/context_menu_more_button"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:scaleType="center"
android:background="?attr/dashboard_button"
android:src="@drawable/ic_overflow_menu_white"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/>
<ImageButton
android:id="@+id/context_menu_share_button"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="?attr/dashboard_button"
android:scaleType="center"
android:src="@drawable/abc_ic_menu_share_mtrl_alpha"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/>
<ImageButton
android:id="@+id/context_menu_more_button"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="?attr/dashboard_button"
android:scaleType="center"
android:src="@drawable/ic_overflow_menu_white"/>
</LinearLayout>
</LinearLayout>
@ -169,14 +185,8 @@
android:id="@+id/context_menu_bottom_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="?attr/ctx_menu_info_view_bg">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
android:background="?attr/ctx_menu_info_view_bg"
android:orientation="vertical">
</LinearLayout>

View file

@ -25,6 +25,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.sections.MenuController;
import net.osmand.plus.views.OsmandMapTileView;
import org.apache.commons.logging.Log;
@ -45,6 +46,7 @@ public class MapContextMenuFragment extends Fragment {
MenuController menuController;
private int menuTopHeight;
private int menuTopShadowHeight;
private int menuButtonsHeight;
private int menuBottomViewHeight;
private int menuFullHeight;
@ -97,6 +99,7 @@ public class MapContextMenuFragment extends Fragment {
public void onGlobalLayout() {
menuTopHeight = view.findViewById(R.id.context_menu_top_view).getHeight();
menuTopShadowHeight = view.findViewById(R.id.context_menu_top_shadow).getHeight();
menuButtonsHeight = view.findViewById(R.id.context_menu_buttons).getHeight();
menuBottomViewHeight = view.findViewById(R.id.context_menu_bottom_view).getHeight();
menuFullHeight = view.findViewById(R.id.context_menu_main).getHeight();
@ -130,11 +133,9 @@ public class MapContextMenuFragment extends Fragment {
}
});
View topView = view.findViewById(R.id.context_menu_top_view);
mainView = view.findViewById(R.id.context_menu_main);
topView.setOnTouchListener(new View.OnTouchListener() {
View.OnTouchListener slideTouchListener = new View.OnTouchListener() {
private float dy;
private float dyMain;
private int destinationState;
@ -144,11 +145,29 @@ public class MapContextMenuFragment extends Fragment {
private float velocityY;
private float startX;
private float startY;
private long lastTouchDown;
private final int CLICK_ACTION_THRESHHOLD = 200;
private boolean isClick(float endX, float endY) {
float differenceX = Math.abs(startX - endX);
float differenceY = Math.abs(startY - endY);
if (differenceX > 3 || differenceY > 3 || System.currentTimeMillis() - lastTouchDown > CLICK_ACTION_THRESHHOLD) {
return false;
}
return true;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
startX = event.getX();
startY = event.getY();
lastTouchDown = System.currentTimeMillis();
dy = event.getY();
dyMain = mainView.getY();
velocity = VelocityTracker.obtain();
@ -177,6 +196,8 @@ public class MapContextMenuFragment extends Fragment {
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
float endX = event.getX();
float endY = event.getY();
slidingUp = Math.abs(velocityY) > 500 && (mainView.getY() - dyMain) < -50;
slidingDown = Math.abs(velocityY) > 500 && (mainView.getY() - dyMain) > 50;
@ -203,7 +224,7 @@ public class MapContextMenuFragment extends Fragment {
posY = view.getHeight() - menuFullHeight;
break;
case MenuController.MenuState.FULL_SCREEN:
posY = 0;
posY = -menuTopShadowHeight;
break;
default:
break;
@ -222,20 +243,24 @@ public class MapContextMenuFragment extends Fragment {
bottomBorder.animate().y(posY + menuFullHeight).setDuration(200).setInterpolator(new DecelerateInterpolator()).start();
}
/*
lp = shadowView.getLayoutParams();
lp.height = view.getHeight() - (int)posY;
shadowView.setLayoutParams(lp);
shadowView.requestLayout();
*/
// OnClick event
if (isClick(endX, endY)) {
OsmandMapTileView mapView = getMapActivity().getMapView();
mapView.getAnimatedDraggingThread().startMoving(getCtxMenu().getPointDescription().getLat(), getCtxMenu().getPointDescription().getLon(),
mapView.getZoom(), true);
}
break;
}
return true;
}
});
};
View topView = view.findViewById(R.id.context_menu_top_view);
topView.setOnTouchListener(slideTouchListener);
View topShadowView = view.findViewById(R.id.context_menu_top_shadow);
topShadowView.setOnTouchListener(slideTouchListener);
// Left icon
IconsCache iconsCache = getMyApplication().getIconsCache();
@ -357,7 +382,7 @@ public class MapContextMenuFragment extends Fragment {
break;
case MenuController.MenuState.FULL_SCREEN:
shadowViewHeight = 0;
bottomBorderHeight = view.getHeight() - menuFullHeight;
bottomBorderHeight = view.getHeight() - menuFullHeight + menuTopShadowHeight;
break;
default:
break;
@ -376,6 +401,8 @@ public class MapContextMenuFragment extends Fragment {
lp.height = menuFullHeight;
mainView.setLayoutParams(lp);
mainView.bringToFront();
}
public void dismissMenu() {

View file

@ -26,6 +26,8 @@ import static android.util.TypedValue.COMPLEX_UNIT_DIP;
public class AmenityInfoMenuBuilder extends MenuBuilder {
private static float SHADOW_HEIGHT = 6f; // in dp
private final Amenity amenity;
public AmenityInfoMenuBuilder(OsmandApplication app, final Amenity amenity) {
@ -33,7 +35,7 @@ public class AmenityInfoMenuBuilder extends MenuBuilder {
this.amenity = amenity;
}
private void buildRow(View view, int iconId, String text) {
private void buildRow(View view, int iconId, String text, boolean firstRow) {
boolean light = app.getSettings().isLightContent();
LinearLayout ll = new LinearLayout(view.getContext());
@ -45,13 +47,13 @@ public class AmenityInfoMenuBuilder extends MenuBuilder {
// Icon
LinearLayout llIcon = new LinearLayout(view.getContext());
llIcon.setOrientation(LinearLayout.HORIZONTAL);
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), dpToPx(48f)));
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), firstRow ? dpToPx(48f) - dpToPx(SHADOW_HEIGHT) : dpToPx(48f)));
llIcon.setGravity(Gravity.CENTER_VERTICAL);
ll.addView(llIcon);
ImageView icon = new ImageView(view.getContext());
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) ;
llIconParams.setMargins(dpToPx(16f), dpToPx(12f), dpToPx(32f), dpToPx(12f));
llIconParams.setMargins(dpToPx(16f), firstRow ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT) : dpToPx(12f), dpToPx(32f), dpToPx(12f));
llIconParams.gravity = Gravity.CENTER_VERTICAL;
icon.setLayoutParams(llIconParams);
icon.setScaleType(ImageView.ScaleType.CENTER);
@ -65,18 +67,22 @@ public class AmenityInfoMenuBuilder extends MenuBuilder {
TextView textView = new TextView(view.getContext());
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llTextParams.setMargins(0, dpToPx(8f), 0, dpToPx(8f));
llTextParams.setMargins(0, firstRow ? dpToPx(8f) - dpToPx(SHADOW_HEIGHT) : dpToPx(8f), 0, dpToPx(8f));
textView.setLayoutParams(llTextParams);
textView.setTextSize(18); // todo: create constant
textView.setTextSize(16); // todo: create constant
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
SpannableString spannable = new SpannableString(text);
Linkify.addLinks(spannable, Linkify.ALL);
textView.setClickable(true);
textView.setMovementMethod(LinkMovementMethod.getInstance());
//text = "http://ru.wikipedia.org/wiki/Храм Святого Розария (Владимир)";
//SpannableString spannable = new SpannableString(text);
//Linkify.addLinks(spannable, Linkify.ALL);
//textView.setClickable(true);
//textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setAutoLinkMask(Linkify.ALL);
//textView.setSingleLine();
textView.setLinksClickable(true);
textView.setText(spannable);
textView.setText(text);
//textView.setText("sdf dsaf fsdasdfg adsf asdsfd asdf sdf adsfg asdf sdfa sdf dsf agsfdgd fgsfd sdf asdf adg adf sdf asdf dfgdfsg sdfg adsf asdf asdf sdf SDF ASDF ADSF ASDF ASDF DAF SDAF dfg dsfg dfg sdfg rg rth sfghs dfgs dfgsdfg adfg dfg sdfg dfs ");
LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
@ -109,6 +115,8 @@ public class AmenityInfoMenuBuilder extends MenuBuilder {
@Override
public void build(View view) {
boolean firstRow = true;
MapPoiTypes poiTypes = app.getPoiTypes();
for(Map.Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {
int iconId;
@ -141,7 +149,8 @@ public class AmenityInfoMenuBuilder extends MenuBuilder {
}
}
buildRow(view, iconId, vl);
buildRow(view, iconId, vl, firstRow);
firstRow = false;
}
}
}