Enter symbol only after ACTION_UP; set pressed state after touch
This commit is contained in:
parent
f1fa303c44
commit
d97b723422
1 changed files with 19 additions and 12 deletions
|
@ -953,20 +953,25 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
|| position == MINUS_BUTTON_POSITION
|
|| position == MINUS_BUTTON_POSITION
|
||||||
|| position == BACKSPACE_BUTTON_POSITION
|
|| position == BACKSPACE_BUTTON_POSITION
|
||||||
|| position == SWITCH_TO_NEXT_INPUT_BUTTON_POSITION;
|
|| position == SWITCH_TO_NEXT_INPUT_BUTTON_POSITION;
|
||||||
setNormalBackground(convertView, controlButton);
|
setupNormalState(convertView, controlButton);
|
||||||
convertView.setOnTouchListener(new View.OnTouchListener() {
|
convertView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
int action = event.getAction();
|
switch (event.getAction()) {
|
||||||
if (action == MotionEvent.ACTION_DOWN) {
|
case MotionEvent.ACTION_DOWN:
|
||||||
v.setBackgroundColor(getResolvedColor(R.color.keyboard_item_bg_pressed));
|
v.setBackgroundColor(getResolvedColor(R.color.keyboard_item_bg_pressed));
|
||||||
|
v.setPressed(true);
|
||||||
v.invalidate();
|
v.invalidate();
|
||||||
return true;
|
return true;
|
||||||
} else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
|
case MotionEvent.ACTION_UP:
|
||||||
setNormalBackground(v, controlButton);
|
setupNormalState(v, controlButton);
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onClick(v);
|
listener.onClick(v);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
case MotionEvent.ACTION_CANCEL:
|
||||||
|
setupNormalState(v, controlButton);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1016,12 +1021,14 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setNormalBackground(View view, boolean controlButton) {
|
private void setupNormalState(View view, boolean controlButton) {
|
||||||
view.setBackgroundColor(
|
view.setBackgroundColor(
|
||||||
controlButton
|
controlButton
|
||||||
? getResolvedColor(lightTheme ? R.color.keyboard_item_control_light_bg : R.color.keyboard_item_control_dark_bg)
|
? getResolvedColor(lightTheme ? R.color.keyboard_item_control_light_bg : R.color.keyboard_item_control_dark_bg)
|
||||||
: getResolvedColor(lightTheme ? R.color.keyboard_item_light_bg : R.color.keyboard_item_dark_bg)
|
: getResolvedColor(lightTheme ? R.color.keyboard_item_light_bg : R.color.keyboard_item_dark_bg)
|
||||||
);
|
);
|
||||||
|
view.setPressed(false);
|
||||||
|
view.invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue