1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-20 23:41:45 +02:00

Don't show soft input by default in input dialog

It takes time to open the soft input and with the new inc/dec buttons
it should not be needed as much. If needed it is quickly summoned by
clicking the input view.

Also it doesn't look nice when the phone is in horizontal mode as then
the soft input takes up the whole screen and one has to push back to
get to the inc/dec buttons.

See discussion in #222.
This commit is contained in:
Erik Johansson
2018-03-08 21:50:55 +01:00
parent 987d2ebf65
commit d0d8ba8e85
5 changed files with 0 additions and 33 deletions

View File

@@ -75,11 +75,6 @@ public class CommentMeasurementView extends MeasurementView {
return comment; return comment;
} }
@Override
protected boolean showSoftInputForInputDialog() {
return true;
}
@Override @Override
protected View getInputView() { protected View getInputView() {
EditText input = new EditText(getContext()); EditText input = new EditText(getContext());
@@ -91,7 +86,6 @@ public class CommentMeasurementView extends MeasurementView {
input.setText(getValueAsString()); input.setText(getValueAsString());
input.setSelectAllOnFocus(true); input.setSelectAllOnFocus(true);
input.requestFocus();
return input; return input;
} }

View File

@@ -91,11 +91,6 @@ public class DateMeasurementView extends MeasurementView {
return dateFormat.format(date); return dateFormat.format(date);
} }
@Override
protected boolean showSoftInputForInputDialog() {
return false;
}
@Override @Override
protected View getInputView() { protected View getInputView() {
DatePicker datePicker = new DatePicker(getContext()); DatePicker datePicker = new DatePicker(getContext());

View File

@@ -404,11 +404,6 @@ public abstract class FloatMeasurementView extends MeasurementView {
showEvaluatorRow(show); showEvaluatorRow(show);
} }
@Override
protected boolean showSoftInputForInputDialog() {
return true;
}
private float validateAndGetInput(View view) { private float validateAndGetInput(View view) {
EditText editText = view.findViewById(R.id.float_input); EditText editText = view.findViewById(R.id.float_input);
String text = editText.getText().toString(); String text = editText.getText().toString();
@@ -441,7 +436,6 @@ public abstract class FloatMeasurementView extends MeasurementView {
final EditText input = view.findViewById(R.id.float_input); final EditText input = view.findViewById(R.id.float_input);
input.setText(formatValue(value)); input.setText(formatValue(value));
input.requestFocus();
final TextView unit = view.findViewById(R.id.float_input_unit); final TextView unit = view.findViewById(R.id.float_input_unit);
unit.setText(getUnit()); unit.setText(getUnit());

View File

@@ -381,7 +381,6 @@ public abstract class MeasurementView extends TableLayout {
return openScale.getSelectedScaleUser(); return openScale.getSelectedScaleUser();
} }
protected abstract boolean showSoftInputForInputDialog();
protected abstract View getInputView(); protected abstract View getInputView();
protected abstract boolean validateAndSetInput(View view); protected abstract boolean validateAndSetInput(View view);
@@ -400,15 +399,6 @@ public abstract class MeasurementView extends TableLayout {
dialog.setTitle(getName()); dialog.setTitle(getName());
dialog.setIcon(getIcon()); dialog.setIcon(getIcon());
final InputMethodManager imm = (InputMethodManager) getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (showSoftInputForInputDialog()) {
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
else if (dialog.getCurrentFocus() != null) {
imm.hideSoftInputFromWindow(dialog.getCurrentFocus().getWindowToken(), 0);
}
final View input = getInputView(); final View input = getInputView();
FrameLayout fl = dialog.findViewById(android.R.id.custom); FrameLayout fl = dialog.findViewById(android.R.id.custom);
@@ -423,7 +413,6 @@ public abstract class MeasurementView extends TableLayout {
&& !validateAndSetInput(input)) { && !validateAndSetInput(input)) {
return; return;
} }
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
dialog.dismiss(); dialog.dismiss();
} }
}; };

View File

@@ -93,11 +93,6 @@ public class TimeMeasurementView extends MeasurementView {
return timeFormat.format(time); return timeFormat.format(time);
} }
@Override
protected boolean showSoftInputForInputDialog() {
return false;
}
@Override @Override
protected View getInputView() { protected View getInputView() {
TimePicker timePicker = new TimePicker(getContext()); TimePicker timePicker = new TimePicker(getContext());