1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-12 03:34:09 +02:00

show and hide individual diagram lines

This commit is contained in:
OliE
2017-04-09 10:12:10 +02:00
parent 934ae36e78
commit df32f19319
8 changed files with 247 additions and 114 deletions

View File

@@ -24,7 +24,7 @@ ext {
}
dependencies {
compile 'com.android.support:design:25.0.1'
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile 'com.github.lecho:hellocharts-library:1.5.8@aar'

View File

@@ -20,9 +20,11 @@ import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.view.GestureDetector;
import android.view.LayoutInflater;
@@ -65,6 +67,12 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
private ColumnChartView chartBottom;
private Viewport defaultTopViewport;
private TextView txtYear;
private FloatingActionButton diagramWeight;
private FloatingActionButton diagramFat;
private FloatingActionButton diagramWater;
private FloatingActionButton diagramMuscle;
private FloatingActionButton diagramWaist;
private FloatingActionButton diagramHip;
private SharedPreferences prefs;
private OpenScale openScale;
@@ -94,6 +102,46 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
txtYear = (TextView) graphView.findViewById(R.id.txtYear);
txtYear.setText(Integer.toString(calYears.get(Calendar.YEAR)));
diagramWeight = (FloatingActionButton) graphView.findViewById(R.id.diagramWeight);
diagramFat = (FloatingActionButton) graphView.findViewById(R.id.diagramFat);
diagramWater = (FloatingActionButton) graphView.findViewById(R.id.diagramWater);
diagramMuscle = (FloatingActionButton) graphView.findViewById(R.id.diagramMuscle);
diagramWaist = (FloatingActionButton) graphView.findViewById(R.id.diagramWaist);
diagramHip = (FloatingActionButton) graphView.findViewById(R.id.diagramHip);
diagramWeight.setOnClickListener(new onClickListenerDiagramLines());
diagramFat.setOnClickListener(new onClickListenerDiagramLines());
diagramWater.setOnClickListener(new onClickListenerDiagramLines());
diagramMuscle.setOnClickListener(new onClickListenerDiagramLines());
diagramWaist.setOnClickListener(new onClickListenerDiagramLines());
diagramHip.setOnClickListener(new onClickListenerDiagramLines());
prefs = PreferenceManager.getDefaultSharedPreferences(graphView.getContext());
if(!prefs.getBoolean("weightEnable", true)) {
diagramWeight.setVisibility(View.GONE);
}
if(!prefs.getBoolean("fatEnable", true)) {
diagramFat.setVisibility(View.GONE);
}
if(!prefs.getBoolean("waterEnable", true)) {
diagramWater.setVisibility(View.GONE);
}
if(!prefs.getBoolean("muscleEnable", true)) {
diagramMuscle.setVisibility(View.GONE);
}
if(!prefs.getBoolean("waistEnable", false)) {
diagramWaist.setVisibility(View.GONE);
}
if(!prefs.getBoolean("hipEnable", false)) {
diagramHip.setVisibility(View.GONE);
}
graphView.findViewById(R.id.btnLeftYear).setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
calYears.roll(Calendar.YEAR, false);
@@ -110,8 +158,6 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
}
});
prefs = PreferenceManager.getDefaultSharedPreferences(graphView.getContext());
openScale = OpenScale.getInstance(graphView.getContext());
openScale.registerFragment(this);
@@ -201,27 +247,27 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
setFormatter(new SimpleLineChartValueFormatter(1));
if(prefs.getBoolean("weightEnable", true)) {
if(prefs.getBoolean("weightEnable", true) && diagramWeight.getBackgroundTintList().getDefaultColor() != Color.parseColor("#d3d3d3")) {
lines.add(lineWeight);
}
if(prefs.getBoolean("fatEnable", true)) {
if(prefs.getBoolean("fatEnable", true) && diagramFat.getBackgroundTintList().getDefaultColor() != Color.parseColor("#d3d3d3")) {
lines.add(lineFat);
}
if(prefs.getBoolean("waterEnable", true)) {
if(prefs.getBoolean("waterEnable", true) && diagramWater.getBackgroundTintList().getDefaultColor() != Color.parseColor("#d3d3d3")) {
lines.add(lineWater);
}
if(prefs.getBoolean("muscleEnable", true)) {
if(prefs.getBoolean("muscleEnable", true) && diagramMuscle.getBackgroundTintList().getDefaultColor() != Color.parseColor("#d3d3d3")) {
lines.add(lineMuscle);
}
if(prefs.getBoolean("waistEnable", true)) {
if(prefs.getBoolean("waistEnable", false) && diagramWaist.getBackgroundTintList().getDefaultColor() != Color.parseColor("#d3d3d3")) {
lines.add(lineWaist);
}
if(prefs.getBoolean("hipEnable", true)) {
if(prefs.getBoolean("hipEnable", false) && diagramHip.getBackgroundTintList().getDefaultColor() != Color.parseColor("#d3d3d3")) {
lines.add(lineHip);
}
@@ -341,4 +387,19 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
if(a != null) a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
}
}
private class onClickListenerDiagramLines implements View.OnClickListener {
@Override
public void onClick(View v) {
FloatingActionButton actionButton = (FloatingActionButton) v;
if (actionButton.getBackgroundTintList().getDefaultColor() != Color.parseColor("#d3d3d3")) {
actionButton.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#d3d3d3")));
} else {
actionButton.setBackgroundTintList(ColorStateList.valueOf(actionButton.getRippleColor()));
}
generateColumnData();
}
}
}

View File

@@ -3,15 +3,55 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp">
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="?attr/colorPrimary"
android:gravity="right"
android:orientation="horizontal"
android:padding="5dp">
<android.support.design.widget.FloatingActionButton
android:id="@+id/switchEditMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/editable"
app:backgroundTint="#D3D3D3"
app:fabSize="mini" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/expandButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/expand"
app:backgroundTint="#D3D3D3"
app:fabSize="mini" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/imgViewDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/delete"
app:backgroundTint="#FF4444"
app:fabSize="mini" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:gravity="center"
android:orientation="horizontal">
android:orientation="horizontal"
android:padding="5dp">
<Button
android:id="@+id/btnLeft"
@@ -32,6 +72,7 @@
android:gravity="center"
android:text="date/time"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<Button
@@ -46,44 +87,6 @@
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:orientation="horizontal">
<android.support.design.widget.FloatingActionButton
android:id="@+id/switchEditMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:backgroundTint="#D3D3D3"
android:clickable="true"
android:src="@drawable/editable"
app:fabSize="mini"
android:layout_marginRight="10dp"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/expandButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:backgroundTint="#D3D3D3"
android:clickable="true"
android:src="@drawable/expand"
app:fabSize="mini"
android:layout_marginRight="10dp"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/imgViewDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:backgroundTint="#FF4444"
android:clickable="true"
android:src="@drawable/delete"
app:fabSize="mini"
android:layout_marginRight="10dp"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
@@ -91,7 +94,7 @@
<TableLayout
android:id="@+id/tableLayoutDataEntry"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content" />
</ScrollView>
@@ -99,7 +102,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:gravity="bottom">
android:gravity="bottom"
android:padding="5dp">
<Button
android:id="@+id/btnCancel"

View File

@@ -1,69 +1,141 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp" >
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/linearLayout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:orientation="horizontal"
android:gravity="center"
android:padding="5dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center">
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramWeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/weight"
app:backgroundTint="#AA66CC"
app:fabSize="mini"
app:rippleColor="#AA66CC" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:text="&lt;"
android:id="@+id/btnLeftYear"
android:background="@drawable/flat_selector"
android:textColor="@android:color/white" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramFat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/fat"
app:backgroundTint="#FFBB33"
app:fabSize="mini"
app:rippleColor="#FFBB33" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="year"
android:id="@+id/txtYear"
android:gravity="center"
android:layout_weight="0"
android:textStyle="bold"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramWater"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/water"
app:backgroundTint="#33B5E5"
app:fabSize="mini"
app:rippleColor="#33B5E5" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:text=">"
android:id="@+id/btnRightYear"
android:background="@drawable/flat_selector"
android:textColor="@android:color/white"
android:layout_weight="0" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramMuscle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/muscle"
app:backgroundTint="#99CC00"
app:fabSize="mini"
app:rippleColor="#99CC00" />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramWaist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/waist"
app:backgroundTint="#D3D3D3"
app:fabSize="mini"
app:rippleColor="#FF00FF" />
<lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart_top"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramHip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/hip"
app:backgroundTint="#D3D3D3"
app:fabSize="mini"
app:rippleColor="#FFFF00" />
<lecho.lib.hellocharts.view.ColumnChartView
android:id="@+id/chart_bottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="10dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="?attr/colorPrimary"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp">
</RelativeLayout>
<Button
android:id="@+id/btnLeftYear"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:background="@drawable/flat_selector"
android:text="&lt;"
android:textColor="@android:color/white" />
<TextView
android:id="@+id/txtYear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_weight="0"
android:gravity="center"
android:text="year"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<Button
android:id="@+id/btnRightYear"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_weight="0"
android:background="@drawable/flat_selector"
android:text=">"
android:textColor="@android:color/white" />
</LinearLayout>
<lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart_top"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7" />
<lecho.lib.hellocharts.view.ColumnChartView
android:id="@+id/chart_bottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:layout_weight="0.3" />
</LinearLayout>

View File

@@ -35,7 +35,6 @@
<string name="label_bluetooth_title">Bluetooth</string>
<string name="label_bmi">BMI</string>
<string name="label_body_height">Körpergröße</string>
<string name="label_cancel">Abbrechen</string>
<string name="label_comment">Kommentar</string>
<string name="label_date">Datum</string>
<string name="label_days">Tage</string>
@@ -116,6 +115,6 @@
<string name="Sunday">Sonntag</string>
<string name="error_value_range">Fehler beim Wertebereich</string>
<string name="error_value_required">Wert ist erforderlich</string>
<string name="label_editmode">Bearbeiten</string>
<string name="title_statistics">Statistiken</string>
<string name="label_cancel">Abbrechen</string>
</resources>

View File

@@ -135,6 +135,5 @@
<string name="Friday">Vendredi</string>
<string name="Saturday">Samedi</string>
<string name="Sunday">Dimanche</string>
<string name="label_editmode">Modifier</string>
<string name="title_statistics">Statistiques</string>
</resources>

View File

@@ -116,6 +116,5 @@
<string name="Sunday">日曜日</string>
<string name="error_value_required">値が必要です</string>
<string name="error_value_range">エラー値の範囲</string>
<string name="label_editmode">編集</string>
<string name="title_statistics">統計</string>
</resources>

View File

@@ -33,7 +33,6 @@
<string name="label_whtr">Waist-to-height ratio</string>
<string name="label_whr">Waist-hip ratio</string>
<string name="label_smartUserAssign">Smart User assignment</string>
<string name="label_editmode">Edit</string>
<string name="label_days">days</string>
<string name="label_measures">measures</string>