mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-29 19:20:36 +02:00
Add next button to input dialog for moving directly to next measurement
This fixes the last part of #81 (and #164) (together with #198).
This commit is contained in:
@@ -28,6 +28,7 @@ import android.text.SpannableStringBuilder;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
@@ -349,9 +350,25 @@ public abstract class MeasurementView extends TableLayout {
|
||||
input.setSelectAllOnFocus(true);
|
||||
builder.setView(input);
|
||||
|
||||
ViewGroup parent = (ViewGroup) getParent();
|
||||
MeasurementView view = null;
|
||||
for (int i = parent.indexOfChild(this) + 1; i < parent.getChildCount(); ++i) {
|
||||
MeasurementView next = (MeasurementView) parent.getChildAt(i);
|
||||
if (!next.isEditable() || next instanceof DateMeasurementView || next instanceof TimeMeasurementView) {
|
||||
continue;
|
||||
}
|
||||
view = next;
|
||||
break;
|
||||
}
|
||||
final MeasurementView next = view;
|
||||
|
||||
builder.setPositiveButton(getResources().getString(R.string.label_ok), null);
|
||||
builder.setNegativeButton(getResources().getString(R.string.label_cancel), null);
|
||||
|
||||
if (next != null) {
|
||||
builder.setNeutralButton(R.string.label_next, null);
|
||||
}
|
||||
|
||||
final AlertDialog floatDialog = builder.create();
|
||||
|
||||
floatDialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
@@ -361,7 +378,6 @@ public abstract class MeasurementView extends TableLayout {
|
||||
|
||||
Button positiveButton = floatDialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
positiveButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (validateAndSetInput(input)) {
|
||||
@@ -381,6 +397,19 @@ public abstract class MeasurementView extends TableLayout {
|
||||
floatDialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
if (next != null) {
|
||||
Button neutralButton = floatDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
|
||||
neutralButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (validateAndSetInput(input)) {
|
||||
floatDialog.dismiss();
|
||||
next.getInputDialog().show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -221,5 +221,6 @@
|
||||
<string name="permission_not_granted">Permission not granted</string>
|
||||
<string name="permission_bluetooth_info">openScale requires permission to access the coarse location to search for Bluetooth devices</string>
|
||||
<string name="permission_bluetooth_info_title">Information</string>
|
||||
<string name="label_next">Next</string>
|
||||
|
||||
</resources>
|
||||
|
Reference in New Issue
Block a user