Small context menu fixes

This commit is contained in:
Alexey Kulish 2015-11-12 18:51:44 +03:00
parent 076d73b01c
commit df6d9bd033
11 changed files with 61 additions and 65 deletions

View file

@ -47,7 +47,7 @@
android:layout_height="@dimen/standard_icon_size"
android:layout_marginLeft="16dp"
android:layout_marginStart="12dp"
android:layout_marginTop="18dp"
android:layout_marginTop="17dp"
android:src="@drawable/ic_action_building_number"/>
</LinearLayout>
@ -60,13 +60,13 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginLeft="30dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginTop="14dp"
android:layout_weight="1">
<TextView
@ -105,7 +105,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="4dp">
<ImageView
@ -144,7 +144,7 @@
android:id="@+id/title_button_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="44dp"
android:paddingLeft="62dp"
android:paddingRight="2dp"
android:layout_marginTop="-16dp"
android:paddingBottom="4dp"
@ -195,7 +195,7 @@
android:id="@+id/title_progress_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="54dp"
android:paddingLeft="72dp"
android:paddingRight="2dp"
android:minHeight="52dp"
android:gravity="center_vertical"

View file

@ -83,6 +83,11 @@ public abstract class BaseMenuController {
return iconsCache.getIcon(iconId, colorId);
}
protected Drawable getPaintedIcon(int iconId, int color) {
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache();
return iconsCache.getPaintedContentIcon(iconId, color);
}
protected Drawable getIcon(int iconId, int colorLightId, int colorDarkId) {
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache();
return iconsCache.getIcon(iconId, isLight() ? colorLightId : colorDarkId);

View file

@ -70,6 +70,8 @@ public class MenuBuilder {
if (needBuildPlainMenuItems()) {
buildPlainMenuItems(view);
}
buildInternal(view);
buildAfter(view);
}
protected void buildPlainMenuItems(View view) {
@ -82,6 +84,13 @@ public class MenuBuilder {
return true;
}
protected void buildInternal(View view) {
}
protected void buildAfter(View view) {
buildRowDivider(view, false);
}
protected boolean isFirstRow() {
return firstRow;
}
@ -95,6 +104,11 @@ public class MenuBuilder {
}
protected View buildRow(final View view, Drawable icon, String text, int textColor, boolean needLinks, int textLinesLimit) {
if (!isFirstRow()) {
buildRowDivider(view, false);
}
LinearLayout ll = new LinearLayout(view.getContext());
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
@ -149,15 +163,6 @@ public class MenuBuilder {
((LinearLayout) view).addView(ll);
View horizontalLine = new View(view.getContext());
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
llHorLineParams.gravity = Gravity.BOTTOM;
horizontalLine.setLayoutParams(llHorLineParams);
horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
((LinearLayout) view).addView(horizontalLine);
rowBuilt();
return ll;
@ -168,6 +173,7 @@ public class MenuBuilder {
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(llParams);
ll.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
// Empty
LinearLayout llIcon = new LinearLayout(view.getContext());
@ -183,7 +189,6 @@ public class MenuBuilder {
ll.addView(llButton);
Button buttonView = new Button(view.getContext());
buttonView.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
LinearLayout.LayoutParams llBtnParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
buttonView.setLayoutParams(llBtnParams);
buttonView.setPadding(dpToPx(10f), 0, dpToPx(10f), 0);
@ -196,15 +201,27 @@ public class MenuBuilder {
buttonView.setCompoundDrawablesWithIntrinsicBounds(buttonIcon, null, null, null);
buttonView.setCompoundDrawablePadding(dpToPx(8f));
}
buttonView.setOnClickListener(onClickListener);
llButton.addView(buttonView);
((LinearLayout) view).addView(ll);
ll.setOnClickListener(onClickListener);
rowBuilt();
}
protected void buildRowDivider(View view, boolean matchWidth) {
View horizontalLine = new View(view.getContext());
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
llHorLineParams.gravity = Gravity.BOTTOM;
if (!matchWidth) {
llHorLineParams.setMargins(dpToPx(72f), 0, 0, 0);
}
horizontalLine.setLayoutParams(llHorLineParams);
horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
((LinearLayout) view).addView(horizontalLine);
}
public void addPlainMenuItem(int iconId, String text, boolean needLinks) {
plainMenuItems.add(new PlainMenuItem(iconId, text, needLinks));
}

View file

@ -41,6 +41,10 @@ public class AmenityMenuBuilder extends MenuBuilder {
protected void buildRow(final View view, Drawable icon, final String text, final String textPrefix, int textColor, boolean isWiki, boolean isText, boolean needLinks) {
boolean light = app.getSettings().isLightContent();
if (!isFirstRow()) {
buildRowDivider(view, false);
}
LinearLayout ll = new LinearLayout(view.getContext());
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
@ -103,15 +107,6 @@ public class AmenityMenuBuilder extends MenuBuilder {
((LinearLayout) view).addView(ll);
View horizontalLine = new View(view.getContext());
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
llHorLineParams.gravity = Gravity.BOTTOM;
horizontalLine.setLayoutParams(llHorLineParams);
horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
((LinearLayout) view).addView(horizontalLine);
if (isWiki) {
ll.setOnClickListener(new View.OnClickListener() {
@Override
@ -132,9 +127,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
}
@Override
public void build(View view) {
super.build(view);
public void buildInternal(View view) {
boolean hasWiki = false;
MapPoiTypes poiTypes = app.getPoiTypes();
for (Map.Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {

View file

@ -35,9 +35,7 @@ public class AudioVideoNoteMenuBuilder extends MenuBuilder {
}
@Override
public void build(View view) {
super.build(view);
public void buildInternal(View view) {
File file = recording.getFile();
if (file != null) {

View file

@ -34,6 +34,10 @@ public class EditPOIMenuBuilder extends MenuBuilder {
protected void buildRow(final View view, Drawable icon, String text) {
boolean light = app.getSettings().isLightContent();
if (!isFirstRow()) {
buildRowDivider(view, false);
}
LinearLayout ll = new LinearLayout(view.getContext());
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
@ -78,22 +82,11 @@ public class EditPOIMenuBuilder extends MenuBuilder {
((LinearLayout) view).addView(ll);
View horizontalLine = new View(view.getContext());
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
llHorLineParams.gravity = Gravity.BOTTOM;
horizontalLine.setLayoutParams(llHorLineParams);
horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
((LinearLayout) view).addView(horizontalLine);
rowBuilt();
}
@Override
public void build(View view) {
super.build(view);
public void buildInternal(View view) {
if (osmPoint instanceof OsmNotesPoint) {
OsmNotesPoint notes = (OsmNotesPoint) osmPoint;

View file

@ -23,9 +23,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
}
@Override
public void build(View view) {
super.build(view);
public void buildInternal(View view) {
if (!Algorithms.isEmpty(fav.getDescription())) {
buildRow(view, R.drawable.ic_action_note_dark, fav.getDescription(), 0, true, 0);
}

View file

@ -28,9 +28,7 @@ public class WptPtMenuBuilder extends MenuBuilder {
}
@Override
public void build(View view) {
super.build(view);
public void buildInternal(View view) {
if (wpt.time > 0) {
DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(view.getContext());
DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext());

View file

@ -5,6 +5,7 @@ import android.support.v4.app.Fragment;
import net.osmand.data.FavouritePoint;
import net.osmand.data.PointDescription;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -55,7 +56,7 @@ public class FavouritePointMenuController extends MenuController {
@Override
public Drawable getLeftIcon() {
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), fav.getColor(), false);
return getPaintedIcon(R.drawable.ic_action_fav_dark, fav.getColor());
}
@Override

View file

@ -2,7 +2,6 @@ package net.osmand.plus.mapcontextmenu.editors;
import android.app.Activity;
import android.content.DialogInterface;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
@ -15,10 +14,8 @@ import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.util.Algorithms;
@ -210,7 +207,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
if (group != null) {
color = group.color;
}
return FavoriteImageDrawable.getOrCreate(getMapActivity(), color, false);
return getPaintedIcon(R.drawable.ic_action_fav_dark, color);
}
@Override
@ -222,14 +219,6 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
if (color == 0) {
color = defaultColor;
}
return getIcon(R.drawable.ic_action_folder_stroke, color);
}
public Drawable getIcon(int resId, int color) {
OsmandApplication app = getMyApplication();
Drawable d = app.getResources().getDrawable(resId).mutate();
d.clearColorFilter();
d.setColorFilter(color, PorterDuff.Mode.SRC_IN);
return d;
return getPaintedIcon(R.drawable.ic_action_folder_stroke, color);
}
}

View file

@ -337,4 +337,8 @@ public abstract class PointEditorFragment extends Fragment {
);
}
protected Drawable getPaintedIcon(int iconId, int color) {
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache();
return iconsCache.getPaintedContentIcon(iconId, color);
}
}