Context menu fixes, change fav action icon to Edit
This commit is contained in:
parent
e1d62c0d5f
commit
78595c3ffa
5 changed files with 43 additions and 11 deletions
|
@ -45,6 +45,8 @@ public class MapContextMenu {
|
|||
private Drawable secondLineIcon;
|
||||
private String streetStr;
|
||||
|
||||
private int favActionIconId;
|
||||
|
||||
private static final String KEY_CTX_MENU_OBJECT = "key_ctx_menu_object";
|
||||
private static final String KEY_CTX_MENU_ACTIVE = "key_ctx_menu_active";
|
||||
private static final String KEY_CTX_MENU_LATLON = "key_ctx_menu_latlon";
|
||||
|
@ -222,6 +224,10 @@ public class MapContextMenu {
|
|||
return leftIconId;
|
||||
}
|
||||
|
||||
public int getFavActionIconId() {
|
||||
return favActionIconId;
|
||||
}
|
||||
|
||||
public Drawable getLeftIcon() {
|
||||
return leftIcon;
|
||||
}
|
||||
|
@ -249,6 +255,7 @@ public class MapContextMenu {
|
|||
|
||||
private void acquireIcons() {
|
||||
leftIconId = 0;
|
||||
favActionIconId = 0;
|
||||
leftIcon = null;
|
||||
secondLineIcon = null;
|
||||
|
||||
|
@ -256,6 +263,8 @@ public class MapContextMenu {
|
|||
leftIconId = menuController.getLeftIconId();
|
||||
leftIcon = menuController.getLeftIcon();
|
||||
secondLineIcon = menuController.getSecondLineIcon();
|
||||
|
||||
favActionIconId = menuController.getFavActionIconId();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ import android.widget.TextView;
|
|||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -296,6 +295,16 @@ public class MapContextMenuFragment extends Fragment {
|
|||
});
|
||||
|
||||
// Action buttons
|
||||
final ImageButton buttonFavorite = (ImageButton) view.findViewById(R.id.context_menu_fav_button);
|
||||
buttonFavorite.setImageDrawable(iconsCache.getIcon(menu.getFavActionIconId(),
|
||||
light ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
|
||||
buttonFavorite.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
menu.buttonFavoritePressed();
|
||||
}
|
||||
});
|
||||
|
||||
final ImageButton buttonWaypoint = (ImageButton) view.findViewById(R.id.context_menu_route_button);
|
||||
buttonWaypoint.setImageDrawable(iconsCache.getIcon(R.drawable.map_action_waypoints,
|
||||
light ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
|
||||
|
@ -306,16 +315,6 @@ public class MapContextMenuFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
final ImageButton buttonFavorite = (ImageButton) view.findViewById(R.id.context_menu_fav_button);
|
||||
buttonFavorite.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_fav_dark,
|
||||
light ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
|
||||
buttonFavorite.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
menu.buttonFavoritePressed();
|
||||
}
|
||||
});
|
||||
|
||||
final ImageButton buttonShare = (ImageButton) view.findViewById(R.id.context_menu_share_button);
|
||||
buttonShare.setImageDrawable(iconsCache.getIcon(R.drawable.abc_ic_menu_share_mtrl_alpha,
|
||||
light ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
|
||||
|
|
|
@ -63,6 +63,11 @@ public class FavouritePointMenuController extends MenuController {
|
|||
return getIcon(R.drawable.ic_small_group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFavActionIconId() {
|
||||
return R.drawable.ic_action_edit_dark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
return fav.getCategory().length() == 0 ?
|
||||
|
|
|
@ -160,6 +160,8 @@ public abstract class MenuController {
|
|||
|
||||
public Drawable getSecondLineIcon() { return null; }
|
||||
|
||||
public int getFavActionIconId() { return R.drawable.ic_action_fav_dark; }
|
||||
|
||||
public String getTypeStr() { return ""; }
|
||||
|
||||
public String getNameStr() { return ""; }
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
package net.osmand.plus.mapcontextmenu.editors;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
|
@ -104,6 +108,7 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
nameEdit.setText(getNameInitValue());
|
||||
AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
|
||||
categoryEdit.setText(getCategoryInitValue());
|
||||
categoryEdit.setFocusable(false);
|
||||
categoryEdit.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(final View v, MotionEvent event) {
|
||||
|
@ -149,6 +154,7 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
hideKeyboard();
|
||||
getMapActivity().getContextMenu().setBaseFragmentVisibility(true);
|
||||
}
|
||||
|
||||
|
@ -162,6 +168,17 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
getActivity().findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void hideKeyboard() {
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
View currentFocus = getActivity().getCurrentFocus();
|
||||
if (currentFocus != null) {
|
||||
IBinder windowToken = currentFocus.getWindowToken();
|
||||
if (windowToken != null) {
|
||||
inputMethodManager.hideSoftInputFromWindow(windowToken, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void savePressed() {
|
||||
save(true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue