Merge pull request #8914 from osmandapp/configure_menu_items_fix

Configure menu items fix
This commit is contained in:
max-klaus 2020-05-10 15:37:12 +03:00 committed by GitHub
commit 2b051b8da8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 25 deletions

View file

@ -10,21 +10,21 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/activity_background_basic" android:background="?attr/activity_background_basic"
tools:paddingEnd="56dp"
tools:paddingStart="56dp"
tools:paddingTop="16dp"> tools:paddingTop="16dp">
<ImageView <ImageView
android:id="@+id/device_image" android:id="@+id/device_image"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true" android:adjustViewBounds="true"
tools:src="@drawable/img_settings_device_top_dark" /> tools:src="@drawable/img_settings_device_top_dark" />
<ImageView <ImageView
android:id="@+id/image" android:id="@+id/image"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true" android:adjustViewBounds="true"
tools:src="@drawable/img_settings_customize_configure_map_night" /> tools:src="@drawable/img_settings_customize_configure_map_night" />

View file

@ -9,8 +9,8 @@
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"
android:layout_width="wrap_content" android:layout_width="@dimen/standard_icon_size"
android:layout_height="wrap_content" android:layout_height="@dimen/standard_icon_size"
android:layout_marginStart="@dimen/content_padding" android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding" android:layout_marginLeft="@dimen/content_padding"
android:layout_marginEnd="@dimen/list_content_padding_large" android:layout_marginEnd="@dimen/list_content_padding_large"

View file

@ -85,19 +85,23 @@
</LinearLayout> </LinearLayout>
<ImageView <FrameLayout
android:id="@+id/move_icon" android:id="@+id/move_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:paddingLeft="@dimen/content_padding" android:layout_marginEnd="@dimen/content_padding_half"
android:paddingTop="@dimen/bottom_sheet_icon_margin" android:layout_marginRight="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding" android:padding="@dimen/content_padding_small">
android:paddingBottom="@dimen/bottom_sheet_icon_margin"
android:src="@drawable/ic_action_item_move" <ImageView
android:tint="?attr/secondary_icon_color" android:id="@+id/move_icon"
android:paddingEnd="@dimen/content_padding" android:layout_width="@dimen/standard_icon_size"
android:paddingStart="@dimen/content_padding" /> android:layout_height="@dimen/standard_icon_size"
android:src="@drawable/ic_action_item_move"
android:tint="?attr/secondary_icon_color" />
</FrameLayout>
</LinearLayout> </LinearLayout>

View file

@ -9,6 +9,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -384,11 +385,11 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
} }
} }
}); });
profileViewHolder.moveIcon.setVisibility(mode.isDeleted() ? View.GONE : View.VISIBLE); profileViewHolder.moveButton.setVisibility(mode.isDeleted() ? View.GONE : View.VISIBLE);
if (!mode.isDeleted()) { if (!mode.isDeleted()) {
int removeIconColor = mode.isCustomProfile() ? R.color.color_osm_edit_delete : R.color.icon_color_default_light; int removeIconColor = mode.isCustomProfile() ? R.color.color_osm_edit_delete : R.color.icon_color_default_light;
profileViewHolder.actionIcon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_remove, removeIconColor)); profileViewHolder.actionIcon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_remove, removeIconColor));
profileViewHolder.moveIcon.setOnTouchListener(new View.OnTouchListener() { profileViewHolder.moveButton.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View view, MotionEvent event) { public boolean onTouch(View view, MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
@ -479,6 +480,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
ImageButton actionIcon; ImageButton actionIcon;
ImageView moveIcon; ImageView moveIcon;
View itemsContainer; View itemsContainer;
FrameLayout moveButton;
ProfileViewHolder(View itemView) { ProfileViewHolder(View itemView) {
super(itemView); super(itemView);
@ -487,6 +489,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
actionIcon = itemView.findViewById(R.id.action_icon); actionIcon = itemView.findViewById(R.id.action_icon);
icon = itemView.findViewById(R.id.icon); icon = itemView.findViewById(R.id.icon);
moveIcon = itemView.findViewById(R.id.move_icon); moveIcon = itemView.findViewById(R.id.move_icon);
moveButton = itemView.findViewById(R.id.move_button);
itemsContainer = itemView.findViewById(R.id.selectable_list_item); itemsContainer = itemView.findViewById(R.id.selectable_list_item);
} }

View file

@ -341,6 +341,9 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
} }
} else { } else {
hiddenMenuItems.remove(id); hiddenMenuItems.remove(id);
if (screenType == ScreenType.CONTEXT_MENU_ACTIONS && mainActionItems.size() < MAIN_BUTTONS_QUANTITY) {
mainActionItems.add(id);
}
} }
wasReset = false; wasReset = false;
isChanged = true; isChanged = true;

View file

@ -155,7 +155,7 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
h.description.setText(R.string.divider_descr); h.description.setText(R.string.divider_descr);
h.icon.setVisibility(View.GONE); h.icon.setVisibility(View.GONE);
h.actionIcon.setVisibility(View.GONE); h.actionIcon.setVisibility(View.GONE);
h.moveIcon.setVisibility(View.VISIBLE); h.moveButton.setVisibility(View.VISIBLE);
h.divider.setVisibility(View.VISIBLE); h.divider.setVisibility(View.VISIBLE);
} else if (SHOW_CATEGORY_ID.equals(id) } else if (SHOW_CATEGORY_ID.equals(id)
|| MAP_RENDERING_CATEGORY_ID.equals(id)) { || MAP_RENDERING_CATEGORY_ID.equals(id)) {
@ -165,7 +165,7 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
h.description.setText(R.string.move_inside_category); h.description.setText(R.string.move_inside_category);
h.icon.setVisibility(View.GONE); h.icon.setVisibility(View.GONE);
h.actionIcon.setVisibility(View.GONE); h.actionIcon.setVisibility(View.GONE);
h.moveIcon.setVisibility(View.GONE); h.moveButton.setVisibility(View.GONE);
h.divider.setVisibility(View.VISIBLE); h.divider.setVisibility(View.VISIBLE);
h.movable = false; h.movable = false;
} else { } else {
@ -179,7 +179,7 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
h.title.setTextColor(app.getResources().getColor(textColorRes)); h.title.setTextColor(app.getResources().getColor(textColorRes));
h.description.setText(getDescription(menuItem.getId())); h.description.setText(getDescription(menuItem.getId()));
h.divider.setVisibility(View.GONE); h.divider.setVisibility(View.GONE);
h.moveIcon.setVisibility(View.VISIBLE); h.moveButton.setVisibility(View.VISIBLE);
} }
h.actionIcon.setOnClickListener(new View.OnClickListener() { h.actionIcon.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -190,7 +190,7 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
} }
} }
}); });
h.moveIcon.setOnTouchListener(new View.OnTouchListener() { h.moveButton.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View view, MotionEvent event) { public boolean onTouch(View view, MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
@ -202,11 +202,11 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
if (!menuItem.isHidden() if (!menuItem.isHidden()
&& !id.equals(SHOW_CATEGORY_ID) && !id.equals(SHOW_CATEGORY_ID)
&& !id.equals(MAP_RENDERING_CATEGORY_ID)) { && !id.equals(MAP_RENDERING_CATEGORY_ID)) {
h.moveIcon.setVisibility(View.VISIBLE); h.moveButton.setVisibility(View.VISIBLE);
h.moveIcon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_item_move, nightMode)); h.moveIcon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_item_move, nightMode));
h.actionIcon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_remove, R.color.color_osm_edit_delete)); h.actionIcon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_remove, R.color.color_osm_edit_delete));
} else { } else {
h.moveIcon.setVisibility(View.GONE); h.moveButton.setVisibility(View.GONE);
h.actionIcon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_undo, R.color.color_osm_edit_create)); h.actionIcon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_undo, R.color.color_osm_edit_create));
} }
if (id.equals(MAP_CONTEXT_MENU_MORE_ID)) { if (id.equals(MAP_CONTEXT_MENU_MORE_ID)) {
@ -344,6 +344,7 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
private ImageView icon; private ImageView icon;
private ImageView actionIcon; private ImageView actionIcon;
private ImageView moveIcon; private ImageView moveIcon;
private FrameLayout moveButton;
private View divider; private View divider;
private boolean movable = true; private boolean movable = true;
@ -354,6 +355,7 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
actionIcon = itemView.findViewById(R.id.action_icon); actionIcon = itemView.findViewById(R.id.action_icon);
icon = itemView.findViewById(R.id.icon); icon = itemView.findViewById(R.id.icon);
moveIcon = itemView.findViewById(R.id.move_icon); moveIcon = itemView.findViewById(R.id.move_icon);
moveButton = itemView.findViewById(R.id.move_button);
divider = itemView.findViewById(R.id.divider); divider = itemView.findViewById(R.id.divider);
} }