Always show the "show/hide keyboard" button near the keyboard

This commit is contained in:
Alexander Sytnyk 2018-02-20 14:30:52 +02:00
parent 322c0c6732
commit cef8967238
2 changed files with 37 additions and 8 deletions

View file

@ -26,15 +26,28 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp"> android:layout_height="56dp">
<android.support.v7.widget.AppCompatTextView <ImageView
android:id="@+id/add_marker_button" android:id="@+id/show_hide_keyboard_icon_left"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginBottom="@dimen/route_info_button_go_margin" android:layout_marginBottom="@dimen/route_info_button_go_margin"
android:layout_marginLeft="@dimen/route_info_button_go_margin" android:layout_marginLeft="@dimen/route_info_button_go_margin"
android:layout_marginStart="@dimen/route_info_button_go_margin" android:layout_marginStart="@dimen/route_info_button_go_margin"
android:layout_marginTop="@dimen/route_info_button_go_margin" android:layout_marginTop="@dimen/route_info_button_go_margin"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/coords_input_show_hide_keyboard_btn_padding"
android:paddingRight="@dimen/coords_input_show_hide_keyboard_btn_padding"
android:visibility="gone"
tools:src="@drawable/ic_action_keyboard_hide"
tools:visibility="visible"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/add_marker_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_margin="@dimen/route_info_button_go_margin"
android:layout_weight="1" android:layout_weight="1"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center" android:gravity="center"
@ -47,11 +60,14 @@
tools:background="@drawable/route_info_go_btn_bg_dark"/> tools:background="@drawable/route_info_go_btn_bg_dark"/>
<ImageView <ImageView
android:id="@+id/show_hide_keyboard_icon" android:id="@+id/show_hide_keyboard_icon_right"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_margin="@dimen/route_info_button_go_margin" android:layout_marginBottom="@dimen/route_info_button_go_margin"
android:layout_marginEnd="@dimen/route_info_button_go_margin"
android:layout_marginRight="@dimen/route_info_button_go_margin"
android:layout_marginTop="@dimen/route_info_button_go_margin"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/coords_input_show_hide_keyboard_btn_padding" android:paddingLeft="@dimen/coords_input_show_hide_keyboard_btn_padding"
android:paddingRight="@dimen/coords_input_show_hide_keyboard_btn_padding" android:paddingRight="@dimen/coords_input_show_hide_keyboard_btn_padding"

View file

@ -95,6 +95,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
private View mainView; private View mainView;
private final List<EditTextEx> editTexts = new ArrayList<>(); private final List<EditTextEx> editTexts = new ArrayList<>();
private CoordinateInputAdapter adapter; private CoordinateInputAdapter adapter;
private ImageView showHideKeyboardIcon;
private boolean lightTheme; private boolean lightTheme;
private boolean orientationPortrait; private boolean orientationPortrait;
@ -225,6 +226,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
ImageView lonBackspaceBtn = (ImageView) mainView.findViewById(R.id.lon_backspace_btn); ImageView lonBackspaceBtn = (ImageView) mainView.findViewById(R.id.lon_backspace_btn);
lonBackspaceBtn.setImageDrawable(getActiveIcon(R.drawable.ic_action_clear_all_fields)); lonBackspaceBtn.setImageDrawable(getActiveIcon(R.drawable.ic_action_clear_all_fields));
lonBackspaceBtn.setOnClickListener(backspaceOnClickListener); lonBackspaceBtn.setOnClickListener(backspaceOnClickListener);
showHideKeyboardIcon = (ImageView) mainView.findViewById(R.id.show_hide_keyboard_icon);
} else { } else {
boolean rightHand = getMyApplication().getSettings().COORDS_INPUT_USE_RIGHT_SIDE.get(); boolean rightHand = getMyApplication().getSettings().COORDS_INPUT_USE_RIGHT_SIDE.get();
LinearLayout handContainer = (LinearLayout) mainView.findViewById(R.id.hand_container); LinearLayout handContainer = (LinearLayout) mainView.findViewById(R.id.hand_container);
@ -236,6 +239,16 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
((FrameLayout) handContainer.findViewById(R.id.left_container)).addView(rightHand ? dataAreaView : keyboardAndListView, 0); ((FrameLayout) handContainer.findViewById(R.id.left_container)).addView(rightHand ? dataAreaView : keyboardAndListView, 0);
((FrameLayout) handContainer.findViewById(R.id.right_container)).addView(rightHand ? keyboardAndListView : dataAreaView, 0); ((FrameLayout) handContainer.findViewById(R.id.right_container)).addView(rightHand ? keyboardAndListView : dataAreaView, 0);
if (rightHand) {
showHideKeyboardIcon = (ImageView) dataAreaView.findViewById(R.id.show_hide_keyboard_icon_right);
showHideKeyboardIcon.setVisibility(View.VISIBLE);
dataAreaView.findViewById(R.id.show_hide_keyboard_icon_left).setVisibility(View.GONE);
} else {
showHideKeyboardIcon = (ImageView) dataAreaView.findViewById(R.id.show_hide_keyboard_icon_left);
showHideKeyboardIcon.setVisibility(View.VISIBLE);
dataAreaView.findViewById(R.id.show_hide_keyboard_icon_right).setVisibility(View.GONE);
}
handContainer.findViewById(R.id.input_area_top_padding).setVisibility(View.VISIBLE); handContainer.findViewById(R.id.input_area_top_padding).setVisibility(View.VISIBLE);
handContainer.findViewById(R.id.point_name_top_space).setVisibility(View.VISIBLE); handContainer.findViewById(R.id.point_name_top_space).setVisibility(View.VISIBLE);
handContainer.findViewById(R.id.right_shadow).setVisibility(rightHand ? View.VISIBLE : View.GONE); handContainer.findViewById(R.id.right_shadow).setVisibility(rightHand ? View.VISIBLE : View.GONE);
@ -338,7 +351,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} }
}); });
final ImageView showHideKeyboardIcon = (ImageView) mainView.findViewById(R.id.show_hide_keyboard_icon);
showHideKeyboardIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_keyboard_hide)); showHideKeyboardIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_keyboard_hide));
showHideKeyboardIcon.setOnClickListener(new View.OnClickListener() { showHideKeyboardIcon.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -712,8 +724,9 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} else { } else {
mainView.findViewById(R.id.keyboard_layout).setVisibility(visibility); mainView.findViewById(R.id.keyboard_layout).setVisibility(visibility);
} }
((ImageView) mainView.findViewById(R.id.show_hide_keyboard_icon)).setImageDrawable(getActiveIcon(show showHideKeyboardIcon.setImageDrawable(
? R.drawable.ic_action_keyboard_hide : R.drawable.ic_action_keyboard_show)); getActiveIcon(show ? R.drawable.ic_action_keyboard_hide : R.drawable.ic_action_keyboard_show)
);
} }
private void switchEditText(int currentId, boolean toNext) { private void switchEditText(int currentId, boolean toNext) {