mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-22 00:06:48 +02:00
Merge pull request #213 from erijo/next-v2
Improve measurement input dialog
This commit is contained in:
@@ -20,6 +20,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import com.health.openscale.R;
|
import com.health.openscale.R;
|
||||||
@@ -75,20 +76,29 @@ public class CommentMeasurementView extends MeasurementView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean validateAndSetInput(EditText view) {
|
protected boolean showSoftInputForInputDialog() {
|
||||||
setValue(view.getText().toString(), true);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getInputType() {
|
protected View getInputView() {
|
||||||
return InputType.TYPE_CLASS_TEXT
|
EditText input = new EditText(getContext());
|
||||||
|
|
||||||
|
input.setInputType(InputType.TYPE_CLASS_TEXT
|
||||||
| InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE
|
| InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE
|
||||||
| InputType.TYPE_TEXT_FLAG_MULTI_LINE;
|
| InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
||||||
|
input.setHint(R.string.info_enter_comment);
|
||||||
|
input.setText(getValueAsString());
|
||||||
|
input.setSelectAllOnFocus(true);
|
||||||
|
|
||||||
|
input.requestFocus();
|
||||||
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getHintText() {
|
protected boolean validateAndSetInput(View view) {
|
||||||
return getResources().getString(R.string.info_enter_comment);
|
EditText editText = (EditText) view;
|
||||||
|
setValue(editText.getText().toString(), true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,14 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.health.openscale.gui.views;
|
package com.health.openscale.gui.views;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.DatePickerDialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.DatePicker;
|
import android.widget.DatePicker;
|
||||||
import android.widget.EditText;
|
|
||||||
|
|
||||||
import com.health.openscale.R;
|
import com.health.openscale.R;
|
||||||
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
||||||
@@ -94,37 +92,32 @@ public class DateMeasurementView extends MeasurementView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean validateAndSetInput(EditText view) {
|
protected boolean showSoftInputForInputDialog() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getInputType() {
|
protected View getInputView() {
|
||||||
return 0;
|
DatePicker datePicker = new DatePicker(getContext());
|
||||||
}
|
datePicker.setPadding(0, 15, 0, 0);
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getHintText() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DatePickerDialog.OnDateSetListener datePickerListener = new DatePickerDialog.OnDateSetListener() {
|
|
||||||
@Override
|
|
||||||
public void onDateSet(DatePicker view, int selectedYear, int selectedMonth, int selectedDay) {
|
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.setTime(date);
|
cal.setTime(date);
|
||||||
cal.set(selectedYear, selectedMonth, selectedDay);
|
datePicker.updateDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH),
|
||||||
|
cal.get(Calendar.DAY_OF_MONTH));
|
||||||
|
|
||||||
|
return datePicker;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean validateAndSetInput(View view) {
|
||||||
|
DatePicker datePicker = (DatePicker) view;
|
||||||
|
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.setTime(date);
|
||||||
|
cal.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
|
||||||
setValue(cal.getTime(), true);
|
setValue(cal.getTime(), true);
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
return true;
|
||||||
protected AlertDialog getInputDialog() {
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.setTime(date);
|
|
||||||
|
|
||||||
return new DatePickerDialog(
|
|
||||||
getContext(), datePickerListener, cal.get(Calendar.YEAR),
|
|
||||||
cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,17 +21,18 @@ import android.graphics.Color;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.text.InputType;
|
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.text.style.RelativeSizeSpan;
|
import android.text.style.RelativeSizeSpan;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TableRow;
|
import android.widget.TableRow;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.health.openscale.R;
|
import com.health.openscale.R;
|
||||||
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
||||||
@@ -48,6 +49,7 @@ public abstract class FloatMeasurementView extends MeasurementView {
|
|||||||
|
|
||||||
private static float NO_VALUE = -1.0f;
|
private static float NO_VALUE = -1.0f;
|
||||||
private static float AUTO_VALUE = -2.0f;
|
private static float AUTO_VALUE = -2.0f;
|
||||||
|
private static float INC_DEC_DELTA = 0.1f;
|
||||||
|
|
||||||
private Date dateTime;
|
private Date dateTime;
|
||||||
private float value = NO_VALUE;
|
private float value = NO_VALUE;
|
||||||
@@ -197,10 +199,10 @@ public abstract class FloatMeasurementView extends MeasurementView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void incValue() {
|
private void incValue() {
|
||||||
setValue(clampValue(value + 0.1f), previousValue, true);
|
setValue(clampValue(value + INC_DEC_DELTA), previousValue, true);
|
||||||
}
|
}
|
||||||
private void decValue() {
|
private void decValue() {
|
||||||
setValue(clampValue(value - 0.1f), previousValue, true);
|
setValue(clampValue(value - INC_DEC_DELTA), previousValue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String formatValue(float value) {
|
protected String formatValue(float value) {
|
||||||
@@ -342,15 +344,20 @@ public abstract class FloatMeasurementView extends MeasurementView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean validateAndSetInput(EditText view) {
|
protected boolean showSoftInputForInputDialog() {
|
||||||
final String text = view.getText().toString();
|
return true;
|
||||||
|
}
|
||||||
if (text.isEmpty()) {
|
|
||||||
view.setError(getResources().getString(R.string.error_value_required));
|
private float validateAndGetInput(View view) {
|
||||||
return false;
|
EditText editText = view.findViewById(R.id.float_input);
|
||||||
|
String text = editText.getText().toString();
|
||||||
|
|
||||||
|
float newValue = -1;
|
||||||
|
if (text.isEmpty()) {
|
||||||
|
editText.setError(getResources().getString(R.string.error_value_required));
|
||||||
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
float newValue;
|
|
||||||
try {
|
try {
|
||||||
newValue = Float.valueOf(text.replace(',', '.'));
|
newValue = Float.valueOf(text.replace(',', '.'));
|
||||||
}
|
}
|
||||||
@@ -359,22 +366,70 @@ public abstract class FloatMeasurementView extends MeasurementView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newValue < 0 || newValue > getMaxValue()) {
|
if (newValue < 0 || newValue > getMaxValue()) {
|
||||||
view.setError(getResources().getString(R.string.error_value_range));
|
editText.setError(getResources().getString(R.string.error_value_range));
|
||||||
return false;
|
newValue = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View getInputView() {
|
||||||
|
final LinearLayout view = (LinearLayout) LayoutInflater.from(getContext())
|
||||||
|
.inflate(R.layout.float_input_view, null);
|
||||||
|
|
||||||
|
final EditText input = view.findViewById(R.id.float_input);
|
||||||
|
input.setText(formatValue(value));
|
||||||
|
input.requestFocus();
|
||||||
|
|
||||||
|
final TextView unit = view.findViewById(R.id.float_input_unit);
|
||||||
|
unit.setText(getUnit());
|
||||||
|
|
||||||
|
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View button) {
|
||||||
|
float newValue = validateAndGetInput(view);
|
||||||
|
if (newValue < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (button.getId() == R.id.btn_inc) {
|
||||||
|
newValue += INC_DEC_DELTA;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newValue -= INC_DEC_DELTA;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.setText(formatValue(clampValue(newValue)));
|
||||||
|
input.selectAll();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
RepeatListener repeatListener =
|
||||||
|
new RepeatListener(400, 100, onClickListener);
|
||||||
|
|
||||||
|
final Button inc = view.findViewById(R.id.btn_inc);
|
||||||
|
inc.setText("\u25b2 +" + formatValue(INC_DEC_DELTA));
|
||||||
|
inc.setOnClickListener(onClickListener);
|
||||||
|
inc.setOnTouchListener(repeatListener);
|
||||||
|
|
||||||
|
final Button dec = view.findViewById(R.id.btn_dec);
|
||||||
|
dec.setText("\u25bc -" + formatValue(INC_DEC_DELTA));
|
||||||
|
dec.setOnClickListener(onClickListener);
|
||||||
|
dec.setOnTouchListener(repeatListener);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean validateAndSetInput(View view) {
|
||||||
|
float newValue = validateAndGetInput(view);
|
||||||
|
if (newValue >= 0) {
|
||||||
setValue(newValue, previousValue, true);
|
setValue(newValue, previousValue, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
return false;
|
||||||
protected int getInputType() {
|
|
||||||
return InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getHintText() {
|
|
||||||
return getResources().getString(R.string.info_enter_value_unit) + " " + getUnit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RepeatListener implements OnTouchListener {
|
private class RepeatListener implements OnTouchListener {
|
||||||
|
@@ -31,8 +31,8 @@ import android.view.Gravity;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Space;
|
import android.widget.Space;
|
||||||
@@ -381,90 +381,96 @@ public abstract class MeasurementView extends TableLayout {
|
|||||||
return openScale.getSelectedScaleUser();
|
return openScale.getSelectedScaleUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean validateAndSetInput(EditText view);
|
protected abstract boolean showSoftInputForInputDialog();
|
||||||
protected abstract int getInputType();
|
protected abstract View getInputView();
|
||||||
protected abstract String getHintText();
|
protected abstract boolean validateAndSetInput(View view);
|
||||||
|
|
||||||
protected AlertDialog getInputDialog() {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
||||||
builder.setTitle(getName());
|
|
||||||
builder.setIcon(getIcon());
|
|
||||||
|
|
||||||
final EditText input = new EditText(getContext());
|
|
||||||
|
|
||||||
input.setInputType(getInputType());
|
|
||||||
input.setHint(getHintText());
|
|
||||||
input.setText(getValueAsString());
|
|
||||||
input.setSelectAllOnFocus(true);
|
|
||||||
builder.setView(input);
|
|
||||||
|
|
||||||
|
private MeasurementView getNextView() {
|
||||||
ViewGroup parent = (ViewGroup) getParent();
|
ViewGroup parent = (ViewGroup) getParent();
|
||||||
MeasurementView view = null;
|
|
||||||
for (int i = parent.indexOfChild(this) + 1; i < parent.getChildCount(); ++i) {
|
for (int i = parent.indexOfChild(this) + 1; i < parent.getChildCount(); ++i) {
|
||||||
MeasurementView next = (MeasurementView) parent.getChildAt(i);
|
MeasurementView next = (MeasurementView) parent.getChildAt(i);
|
||||||
if (!next.isEditable() || next instanceof DateMeasurementView || next instanceof TimeMeasurementView) {
|
if (next.isEditable()) {
|
||||||
continue;
|
return next;
|
||||||
}
|
}
|
||||||
view = next;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
final MeasurementView next = view;
|
return null;
|
||||||
|
|
||||||
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();
|
private void prepareInputDialog(final AlertDialog dialog) {
|
||||||
|
dialog.setTitle(getName());
|
||||||
|
dialog.setIcon(getIcon());
|
||||||
|
|
||||||
floatDialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
final View input = getInputView();
|
||||||
public void onShow(DialogInterface dialog) {
|
|
||||||
|
|
||||||
Button positiveButton = floatDialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
FrameLayout fl = dialog.findViewById(android.R.id.custom);
|
||||||
positiveButton.setOnClickListener(new View.OnClickListener() {
|
fl.removeAllViews();
|
||||||
|
fl.addView(input, new LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
|
||||||
|
LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
View.OnClickListener clickListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (validateAndSetInput(input)) {
|
if (view == dialog.getButton(DialogInterface.BUTTON_POSITIVE)
|
||||||
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
&& !validateAndSetInput(input)) {
|
||||||
imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
|
return;
|
||||||
floatDialog.dismiss();
|
|
||||||
}
|
}
|
||||||
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||||
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
Button negativeButton = floatDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
|
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(clickListener);
|
||||||
negativeButton.setOnClickListener(new View.OnClickListener() {
|
dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener(clickListener);
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
|
|
||||||
floatDialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
final MeasurementView next = getNextView();
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
Button neutralButton = floatDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
|
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(new OnClickListener() {
|
||||||
neutralButton.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (validateAndSetInput(input)) {
|
if (validateAndSetInput(input)) {
|
||||||
floatDialog.dismiss();
|
next.prepareInputDialog(dialog);
|
||||||
next.getInputDialog().show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setVisibility(GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showInputDialog() {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
|
|
||||||
|
builder.setTitle(getName());
|
||||||
|
builder.setIcon(getIcon());
|
||||||
|
|
||||||
|
// Dummy view to have the "custom" frame layout being created and show
|
||||||
|
// the soft input (if needed).
|
||||||
|
builder.setView(new EditText(getContext()));
|
||||||
|
|
||||||
|
builder.setPositiveButton(R.string.label_ok, null);
|
||||||
|
builder.setNegativeButton(R.string.label_cancel, null);
|
||||||
|
builder.setNeutralButton(R.string.label_next, null);
|
||||||
|
|
||||||
|
final AlertDialog dialog = builder.create();
|
||||||
|
|
||||||
|
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||||
|
@Override
|
||||||
|
public void onShow(DialogInterface dialogInterface) {
|
||||||
|
prepareInputDialog(dialog);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
dialog.show();
|
||||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
|
|
||||||
|
|
||||||
return floatDialog;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class onClickListenerEvaluation implements View.OnClickListener {
|
private class onClickListenerEvaluation implements View.OnClickListener {
|
||||||
@@ -476,7 +482,7 @@ public abstract class MeasurementView extends TableLayout {
|
|||||||
|
|
||||||
if (getMeasurementMode() == EDIT || getMeasurementMode() == ADD) {
|
if (getMeasurementMode() == EDIT || getMeasurementMode() == ADD) {
|
||||||
if (isEditable()) {
|
if (isEditable()) {
|
||||||
getInputDialog().show();
|
showInputDialog();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -15,13 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.health.openscale.gui.views;
|
package com.health.openscale.gui.views;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.TimePickerDialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.widget.EditText;
|
import android.view.View;
|
||||||
import android.widget.TimePicker;
|
import android.widget.TimePicker;
|
||||||
|
|
||||||
import com.health.openscale.R;
|
import com.health.openscale.R;
|
||||||
@@ -96,43 +94,38 @@ public class TimeMeasurementView extends MeasurementView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean validateAndSetInput(EditText view) {
|
protected boolean showSoftInputForInputDialog() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getInputType() {
|
protected View getInputView() {
|
||||||
return 0;
|
TimePicker timePicker = new TimePicker(getContext());
|
||||||
}
|
timePicker.setPadding(0, 15, 0, 0);
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getHintText() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TimePickerDialog.OnTimeSetListener timePickerListener = new TimePickerDialog.OnTimeSetListener() {
|
|
||||||
@Override
|
|
||||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.setTime(time);
|
cal.setTime(time);
|
||||||
|
|
||||||
cal.set(Calendar.HOUR_OF_DAY, hourOfDay);
|
timePicker.setCurrentHour(cal.get(Calendar.HOUR_OF_DAY));
|
||||||
cal.set(Calendar.MINUTE, minute);
|
timePicker.setCurrentMinute(cal.get(Calendar.MINUTE));
|
||||||
|
timePicker.setIs24HourView(android.text.format.DateFormat.is24HourFormat(getContext()));
|
||||||
|
|
||||||
|
return timePicker;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean validateAndSetInput(View view) {
|
||||||
|
TimePicker timePicker = (TimePicker) view;
|
||||||
|
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.setTime(time);
|
||||||
|
cal.set(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour());
|
||||||
|
cal.set(Calendar.MINUTE, timePicker.getCurrentMinute());
|
||||||
cal.set(Calendar.SECOND, 0);
|
cal.set(Calendar.SECOND, 0);
|
||||||
cal.set(Calendar.MILLISECOND, 0);
|
cal.set(Calendar.MILLISECOND, 0);
|
||||||
|
|
||||||
setValue(cal.getTime(), true);
|
setValue(cal.getTime(), true);
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
return true;
|
||||||
protected AlertDialog getInputDialog() {
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.setTime(time);
|
|
||||||
|
|
||||||
return new TimePickerDialog(
|
|
||||||
getContext(), timePickerListener,
|
|
||||||
cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE),
|
|
||||||
android.text.format.DateFormat.is24HourFormat(getContext()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
48
android_app/app/src/main/res/layout/float_input_view.xml
Normal file
48
android_app/app/src/main/res/layout/float_input_view.xml
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_inc"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.2" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/float_input"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.6"
|
||||||
|
android:ems="10"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:selectAllOnFocus="true" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/float_input_unit"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.2"
|
||||||
|
android:labelFor="@+id/float_input" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_dec"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@@ -79,7 +79,6 @@
|
|||||||
<string name="info_data_exported">Dades exportades a</string>
|
<string name="info_data_exported">Dades exportades a</string>
|
||||||
<string name="info_data_imported">Dades importades de</string>
|
<string name="info_data_imported">Dades importades de</string>
|
||||||
<string name="info_enter_value_cm">Valor en cm</string>
|
<string name="info_enter_value_cm">Valor en cm</string>
|
||||||
<string name="info_enter_value_unit">Valor en</string>
|
|
||||||
<string name="info_enter_comment">Comentari opcional</string>
|
<string name="info_enter_comment">Comentari opcional</string>
|
||||||
<string name="info_enter_initial_weight">Pes inicial en la seua unitat de mesura</string>
|
<string name="info_enter_initial_weight">Pes inicial en la seua unitat de mesura</string>
|
||||||
<string name="info_enter_goal_weight">Pes objectiu en la seua unitat de mesura</string>
|
<string name="info_enter_goal_weight">Pes objectiu en la seua unitat de mesura</string>
|
||||||
|
@@ -77,7 +77,6 @@
|
|||||||
<string name="info_data_exported">Data exportována na</string>
|
<string name="info_data_exported">Data exportována na</string>
|
||||||
<string name="info_data_imported">Data importována z</string>
|
<string name="info_data_imported">Data importována z</string>
|
||||||
<string name="info_enter_value_cm">Zadejte hodnotu v cm</string>
|
<string name="info_enter_value_cm">Zadejte hodnotu v cm</string>
|
||||||
<string name="info_enter_value_unit">Zadejte hodnotu v</string>
|
|
||||||
<string name="info_enter_comment">Zadejte volitelný komentář</string>
|
<string name="info_enter_comment">Zadejte volitelný komentář</string>
|
||||||
<string name="info_is_visible">je viditelné</string>
|
<string name="info_is_visible">je viditelné</string>
|
||||||
<string name="info_is_not_visible">není viditelné</string>
|
<string name="info_is_not_visible">není viditelné</string>
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
<string name="info_enter_comment">Gebe ein optionalen Kommentar ein</string>
|
<string name="info_enter_comment">Gebe ein optionalen Kommentar ein</string>
|
||||||
<string name="info_enter_user_name">Gebe dein Namen ein</string>
|
<string name="info_enter_user_name">Gebe dein Namen ein</string>
|
||||||
<string name="info_enter_value_cm">Gebe dein Wert in cm an</string>
|
<string name="info_enter_value_cm">Gebe dein Wert in cm an</string>
|
||||||
<string name="info_enter_value_unit">Gebe dein Wert an in</string>
|
|
||||||
<string name="info_is_not_visible">ist nicht sichtbar</string>
|
<string name="info_is_not_visible">ist nicht sichtbar</string>
|
||||||
<string name="info_is_visible">ist sichtbar</string>
|
<string name="info_is_visible">ist sichtbar</string>
|
||||||
<string name="info_is_not_available">ist nicht verfügbar</string>
|
<string name="info_is_not_available">ist nicht verfügbar</string>
|
||||||
|
@@ -79,7 +79,6 @@
|
|||||||
<string name="info_data_exported">Datos exportados a</string>
|
<string name="info_data_exported">Datos exportados a</string>
|
||||||
<string name="info_data_imported">Datos importados de</string>
|
<string name="info_data_imported">Datos importados de</string>
|
||||||
<string name="info_enter_value_cm">Introduzca valor en cm</string>
|
<string name="info_enter_value_cm">Introduzca valor en cm</string>
|
||||||
<string name="info_enter_value_unit">Introduzca valor en</string>
|
|
||||||
<string name="info_enter_comment">Introduzca un comentario opcional</string>
|
<string name="info_enter_comment">Introduzca un comentario opcional</string>
|
||||||
<string name="info_enter_initial_weight">Introduzca su peso inicial en su unidad de medida</string>
|
<string name="info_enter_initial_weight">Introduzca su peso inicial en su unidad de medida</string>
|
||||||
<string name="info_enter_goal_weight">Introduzca su peso objetivo en su unidad de medida</string>
|
<string name="info_enter_goal_weight">Introduzca su peso objetivo en su unidad de medida</string>
|
||||||
|
@@ -73,7 +73,6 @@
|
|||||||
<string name="info_data_exported">Données exportées vers</string>
|
<string name="info_data_exported">Données exportées vers</string>
|
||||||
<string name="info_data_imported">Donnéees importées depuis</string>
|
<string name="info_data_imported">Donnéees importées depuis</string>
|
||||||
<string name="info_enter_value_cm">Entrez la valeur en cm</string>
|
<string name="info_enter_value_cm">Entrez la valeur en cm</string>
|
||||||
<string name="info_enter_value_unit">Entrez la valeur en</string>
|
|
||||||
<string name="info_enter_comment">Ajouter un commentaire optionnel</string>
|
<string name="info_enter_comment">Ajouter un commentaire optionnel</string>
|
||||||
<string name="info_enter_goal_weight">Entrez votre objectif de poids dans votre unité d\'échelle</string>
|
<string name="info_enter_goal_weight">Entrez votre objectif de poids dans votre unité d\'échelle</string>
|
||||||
<string name="info_is_visible">est visible</string>
|
<string name="info_is_visible">est visible</string>
|
||||||
|
@@ -62,7 +62,6 @@
|
|||||||
<string name="info_enter_goal_weight">あなたの体重をあなたの単位で入力してください</string>
|
<string name="info_enter_goal_weight">あなたの体重をあなたの単位で入力してください</string>
|
||||||
<string name="info_enter_comment">任意でコメントを入力してください</string>
|
<string name="info_enter_comment">任意でコメントを入力してください</string>
|
||||||
<string name="info_enter_value_cm">あなたの値をcmで入力してください</string>
|
<string name="info_enter_value_cm">あなたの値をcmで入力してください</string>
|
||||||
<string name="info_enter_value_unit">あなたの値を入力してください</string>
|
|
||||||
<string name="question_really_delete_all">あなたは本当にすべてのレコードを削除しますか</string>
|
<string name="question_really_delete_all">あなたは本当にすべてのレコードを削除しますか</string>
|
||||||
<string name="question_really_delete_user">あなたが本当にユーザーを削除しますか</string>
|
<string name="question_really_delete_user">あなたが本当にユーザーを削除しますか</string>
|
||||||
<string name="error_goal_weight_required">目標体重が必要です</string>
|
<string name="error_goal_weight_required">目標体重が必要です</string>
|
||||||
|
@@ -81,7 +81,6 @@
|
|||||||
<string name="info_data_exported">Data geexporteerd naar</string>
|
<string name="info_data_exported">Data geexporteerd naar</string>
|
||||||
<string name="info_data_imported">Data geinporteerd van</string>
|
<string name="info_data_imported">Data geinporteerd van</string>
|
||||||
<string name="info_enter_value_cm">Geef waarde op cm\'s in</string>
|
<string name="info_enter_value_cm">Geef waarde op cm\'s in</string>
|
||||||
<string name="info_enter_value_unit">Geef waaarde op</string>
|
|
||||||
<string name="info_enter_comment">Voeg een optionele opmerking toe.</string>
|
<string name="info_enter_comment">Voeg een optionele opmerking toe.</string>
|
||||||
<string name="info_enter_initial_weight">Voer uw begingewicht in uw weegschaal in</string>
|
<string name="info_enter_initial_weight">Voer uw begingewicht in uw weegschaal in</string>
|
||||||
<string name="info_enter_goal_weight">Voer uw streefgewicht in uw weegschaal in</string>
|
<string name="info_enter_goal_weight">Voer uw streefgewicht in uw weegschaal in</string>
|
||||||
|
@@ -76,7 +76,6 @@
|
|||||||
<string name="info_data_exported">Dane wyeksportowane do</string>
|
<string name="info_data_exported">Dane wyeksportowane do</string>
|
||||||
<string name="info_data_imported">Dane zaimportowane z</string>
|
<string name="info_data_imported">Dane zaimportowane z</string>
|
||||||
<string name="info_enter_value_cm">Wprowadź wartość w cm</string>
|
<string name="info_enter_value_cm">Wprowadź wartość w cm</string>
|
||||||
<string name="info_enter_value_unit">Wprowadź wartość w</string>
|
|
||||||
<string name="info_enter_comment">Wprowadź opcjonlany komentarz</string>
|
<string name="info_enter_comment">Wprowadź opcjonlany komentarz</string>
|
||||||
<string name="info_enter_initial_weight">Wprowadź twoją wagę początkową w wybranej jednostce wagi</string>
|
<string name="info_enter_initial_weight">Wprowadź twoją wagę początkową w wybranej jednostce wagi</string>
|
||||||
<string name="info_enter_goal_weight">Wprowadź twoją wagę docelową w wybranej jednostce wagi</string>
|
<string name="info_enter_goal_weight">Wprowadź twoją wagę docelową w wybranej jednostce wagi</string>
|
||||||
|
@@ -34,7 +34,6 @@
|
|||||||
<string name="info_enter_initial_weight">Digite seu peso inicial na sua medida de peso</string>
|
<string name="info_enter_initial_weight">Digite seu peso inicial na sua medida de peso</string>
|
||||||
<string name="info_enter_user_name">Digite seu nome</string>
|
<string name="info_enter_user_name">Digite seu nome</string>
|
||||||
<string name="info_enter_value_cm">Digite o valor em centímetros</string>
|
<string name="info_enter_value_cm">Digite o valor em centímetros</string>
|
||||||
<string name="info_enter_value_unit">Digite o valor em</string>
|
|
||||||
<string name="info_is_enable">está ativado</string>
|
<string name="info_is_enable">está ativado</string>
|
||||||
<string name="info_is_not_available">não está disponível</string>
|
<string name="info_is_not_available">não está disponível</string>
|
||||||
<string name="info_is_not_enable">está desativado</string>
|
<string name="info_is_not_enable">está desativado</string>
|
||||||
|
@@ -65,7 +65,6 @@
|
|||||||
<string name="info_data_exported">Údaje boli exportované do</string>
|
<string name="info_data_exported">Údaje boli exportované do</string>
|
||||||
<string name="info_data_imported">Údaje boli importované z</string>
|
<string name="info_data_imported">Údaje boli importované z</string>
|
||||||
<string name="info_enter_value_cm">Zadajte hodnotu v cm</string>
|
<string name="info_enter_value_cm">Zadajte hodnotu v cm</string>
|
||||||
<string name="info_enter_value_unit">Zadajte hodnotu v palcoch</string>
|
|
||||||
<string name="info_enter_comment">Zadajte voliteľný komentár</string>
|
<string name="info_enter_comment">Zadajte voliteľný komentár</string>
|
||||||
<string name="info_enter_initial_weight">Zadajte vaša počiatočná hmotnosť v jednotkách stupnice</string>
|
<string name="info_enter_initial_weight">Zadajte vaša počiatočná hmotnosť v jednotkách stupnice</string>
|
||||||
<string name="info_enter_goal_weight">Zadajte vaša cieľovú hmotnosť v jednotkách stupnice</string>
|
<string name="info_enter_goal_weight">Zadajte vaša cieľovú hmotnosť v jednotkách stupnice</string>
|
||||||
|
@@ -81,7 +81,6 @@
|
|||||||
<string name="info_data_exported">Data exporterad till</string>
|
<string name="info_data_exported">Data exporterad till</string>
|
||||||
<string name="info_data_imported">Data importerad från</string>
|
<string name="info_data_imported">Data importerad från</string>
|
||||||
<string name="info_enter_value_cm">Ange värde i cm</string>
|
<string name="info_enter_value_cm">Ange värde i cm</string>
|
||||||
<string name="info_enter_value_unit">Ange värde i</string>
|
|
||||||
<string name="info_enter_comment">Ange en frivillig kommentar</string>
|
<string name="info_enter_comment">Ange en frivillig kommentar</string>
|
||||||
<string name="info_enter_initial_weight">Ange din startvikt i din viktenhet</string>
|
<string name="info_enter_initial_weight">Ange din startvikt i din viktenhet</string>
|
||||||
<string name="info_enter_goal_weight">Ange din målvikt i din viktenhet</string>
|
<string name="info_enter_goal_weight">Ange din målvikt i din viktenhet</string>
|
||||||
|
@@ -77,7 +77,6 @@
|
|||||||
<string name="info_data_exported">Veri dýþarý aktarma</string>
|
<string name="info_data_exported">Veri dýþarý aktarma</string>
|
||||||
<string name="info_data_imported">Veri içeri aktarma</string>
|
<string name="info_data_imported">Veri içeri aktarma</string>
|
||||||
<string name="info_enter_value_cm">Deðeri cm olarak girin</string>
|
<string name="info_enter_value_cm">Deðeri cm olarak girin</string>
|
||||||
<string name="info_enter_value_unit">Ýçine deðer girin</string>
|
|
||||||
<string name="info_enter_comment">Ýsteðebaðlý açýklama girin</string>
|
<string name="info_enter_comment">Ýsteðebaðlý açýklama girin</string>
|
||||||
<string name="info_enter_initial_weight">Kendi baþlangýç aðýrlýðýnýzý girin</string>
|
<string name="info_enter_initial_weight">Kendi baþlangýç aðýrlýðýnýzý girin</string>
|
||||||
<string name="info_enter_goal_weight">Kendi Hedef hedef kilonuzu girin </string>
|
<string name="info_enter_goal_weight">Kendi Hedef hedef kilonuzu girin </string>
|
||||||
|
@@ -89,7 +89,6 @@
|
|||||||
<string name="info_data_exported">Data exported to</string>
|
<string name="info_data_exported">Data exported to</string>
|
||||||
<string name="info_data_imported">Data imported from</string>
|
<string name="info_data_imported">Data imported from</string>
|
||||||
<string name="info_enter_value_cm">Enter value in cm</string>
|
<string name="info_enter_value_cm">Enter value in cm</string>
|
||||||
<string name="info_enter_value_unit">Enter value in</string>
|
|
||||||
<string name="info_enter_comment">Enter an optional comment</string>
|
<string name="info_enter_comment">Enter an optional comment</string>
|
||||||
<string name="info_enter_initial_weight">Enter your initial weight in your scale unit</string>
|
<string name="info_enter_initial_weight">Enter your initial weight in your scale unit</string>
|
||||||
<string name="info_enter_goal_weight">Enter your goal weight in your scale unit</string>
|
<string name="info_enter_goal_weight">Enter your goal weight in your scale unit</string>
|
||||||
|
Reference in New Issue
Block a user