mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-17 06:04:27 +02:00
- add measurement option to stick a measurement to the card view in the overview page
- add weekday into the date time format
This commit is contained in:
@@ -566,6 +566,7 @@ public abstract class FloatMeasurementView extends MeasurementView {
|
||||
|
||||
@Override
|
||||
public void prepareExtraPreferencesScreen(PreferenceScreen screen) {
|
||||
super.prepareExtraPreferencesScreen(screen);
|
||||
MeasurementViewSettings settings = getSettings();
|
||||
|
||||
CheckBoxPreference rightAxis = new CheckBoxPreference(screen.getContext());
|
||||
|
@@ -45,6 +45,7 @@ import android.widget.TableRow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.preference.CheckBoxPreference;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
@@ -423,8 +424,17 @@ public abstract class MeasurementView extends TableLayout {
|
||||
}
|
||||
|
||||
public String getPreferenceSummary() { return ""; }
|
||||
public boolean hasExtraPreferences() { return false; }
|
||||
public void prepareExtraPreferencesScreen(PreferenceScreen screen) { }
|
||||
public boolean hasExtraPreferences() { return true; }
|
||||
public void prepareExtraPreferencesScreen(PreferenceScreen screen) {
|
||||
MeasurementViewSettings settings = getSettings();
|
||||
|
||||
CheckBoxPreference isSticky = new CheckBoxPreference(screen.getContext());
|
||||
isSticky.setKey(settings.getIsStickyGraphKey());
|
||||
isSticky.setTitle(R.string.label_is_sticky);
|
||||
isSticky.setPersistent(true);
|
||||
isSticky.setDefaultValue(settings.isSticky());
|
||||
screen.addPreference(isSticky);
|
||||
}
|
||||
|
||||
protected abstract View getInputView();
|
||||
protected abstract boolean validateAndSetInput(View view);
|
||||
|
@@ -27,6 +27,7 @@ public class MeasurementViewSettings {
|
||||
private final String key;
|
||||
|
||||
private static final String PREFERENCE_SUFFIX_ENABLE = "Enable";
|
||||
private static final String PREFERENCE_SUFFIX_IS_STICKY = "IsSticky";
|
||||
private static final String PREFERENCE_SUFFIX_IN_OVERVIEW_GRAPH = "InOverviewGraph";
|
||||
private static final String PREFERENCE_SUFFIX_ON_RIGHT_AXIS = "OnRightAxis";
|
||||
private static final String PREFERENCE_SUFFIX_IN_GRAPH = "InGraph";
|
||||
@@ -116,6 +117,26 @@ public class MeasurementViewSettings {
|
||||
return isEnabledIgnoringDependencies() && areDependenciesEnabled();
|
||||
}
|
||||
|
||||
public boolean isSticky() {
|
||||
boolean defaultValue;
|
||||
switch (key) {
|
||||
case WeightMeasurementView.KEY:
|
||||
case WaterMeasurementView.KEY:
|
||||
case MuscleMeasurementView.KEY:
|
||||
case FatMeasurementView.KEY:
|
||||
defaultValue = true;
|
||||
break;
|
||||
default:
|
||||
defaultValue = false;
|
||||
break;
|
||||
}
|
||||
return preferences.getBoolean(getIsStickyGraphKey(), defaultValue);
|
||||
}
|
||||
|
||||
public String getIsStickyGraphKey() {
|
||||
return getPreferenceKey(PREFERENCE_SUFFIX_IS_STICKY);
|
||||
}
|
||||
|
||||
public String getInOverviewGraphKey() {
|
||||
return getPreferenceKey(PREFERENCE_SUFFIX_IN_OVERVIEW_GRAPH);
|
||||
}
|
||||
|
@@ -24,18 +24,16 @@ import com.health.openscale.gui.measurement.TimeMeasurementView;
|
||||
import com.health.openscale.gui.measurement.UserMeasurementView;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
class OverviewAdapter extends RecyclerView.Adapter<OverviewAdapter.ViewHolder> {
|
||||
private Activity activity;
|
||||
private List<ScaleMeasurement> scaleMeasurementList;
|
||||
private int maxMeasurementView;
|
||||
|
||||
|
||||
public OverviewAdapter(Activity activity, List<ScaleMeasurement> scaleMeasurementList) {
|
||||
this.activity = activity;
|
||||
this.scaleMeasurementList = scaleMeasurementList;
|
||||
this.maxMeasurementView = 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,22 +79,22 @@ class OverviewAdapter extends RecyclerView.Adapter<OverviewAdapter.ViewHolder> {
|
||||
}
|
||||
});
|
||||
|
||||
holder.dateView.setText(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT).format(scaleMeasurement.getDateTime()));
|
||||
holder.dateView.setText(DateFormat.getDateInstance(DateFormat.MEDIUM).format(scaleMeasurement.getDateTime()) +
|
||||
" (" + new SimpleDateFormat("EE").format(scaleMeasurement.getDateTime()) + ") "+
|
||||
DateFormat.getTimeInstance(DateFormat.SHORT).format(scaleMeasurement.getDateTime()));
|
||||
|
||||
List<MeasurementView> measurementViewList = MeasurementView.getMeasurementList(activity, MeasurementView.DateTimeOrder.LAST);
|
||||
|
||||
int i = 0;
|
||||
for (MeasurementView measurementView : measurementViewList) {
|
||||
i++;
|
||||
if (measurementView instanceof DateMeasurementView || measurementView instanceof TimeMeasurementView || measurementView instanceof UserMeasurementView) {
|
||||
measurementView.setVisible(false);
|
||||
}
|
||||
else {
|
||||
else if (measurementView.isVisible()) {
|
||||
measurementView.loadFrom(scaleMeasurement, prevScaleMeasurement);
|
||||
|
||||
if (i <= maxMeasurementView) {
|
||||
if (measurementView.getSettings().isSticky()) {
|
||||
holder.measurementHighlightViews.addView(measurementView);
|
||||
} else {
|
||||
} else{
|
||||
holder.measurementViews.addView(measurementView);
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/expandMoreView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
@@ -195,6 +195,7 @@
|
||||
<string name="label_set_default_order">Set default order</string>
|
||||
<string name="label_export_overwrite">Overwrite previous export \"%s\"?</string>
|
||||
<string name="label_is_on_right_axis">Is on right axis</string>
|
||||
<string name="label_is_sticky">Is sticky</string>
|
||||
<string name="label_measurement_in_percent">Measurement in %</string>
|
||||
<string name="label_estimate_measurement">Estimate measurement</string>
|
||||
<string name="label_estimation_formula">Estimation formula</string>
|
||||
|
Reference in New Issue
Block a user