mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-13 20:24:14 +02:00
- use floating action buttons for deletion and edit mode
- add expand all button
This commit is contained in:
@@ -24,6 +24,7 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
compile 'com.android.support:design:25.0.1'
|
||||||
compile "com.android.support:support-v4:${supportLibVersion}"
|
compile "com.android.support:support-v4:${supportLibVersion}"
|
||||||
compile "com.android.support:appcompat-v7:${supportLibVersion}"
|
compile "com.android.support:appcompat-v7:${supportLibVersion}"
|
||||||
compile 'com.github.lecho:hellocharts-library:1.5.8@aar'
|
compile 'com.github.lecho:hellocharts-library:1.5.8@aar'
|
||||||
|
@@ -20,14 +20,13 @@ import android.app.AlertDialog;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TableLayout;
|
import android.widget.TableLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@@ -55,10 +54,9 @@ import java.util.Collections;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
public class DataEntryActivity extends Activity {
|
import lecho.lib.hellocharts.util.ChartUtils;
|
||||||
public static final int ADD_DATA_REQUEST = 0;
|
|
||||||
public static final int EDIT_DATA_REQUEST = 1;
|
|
||||||
|
|
||||||
|
public class DataEntryActivity extends Activity {
|
||||||
private ArrayList<MeasurementView> dataEntryMeasurements;
|
private ArrayList<MeasurementView> dataEntryMeasurements;
|
||||||
private TableLayout tableLayoutDataEntry;
|
private TableLayout tableLayoutDataEntry;
|
||||||
|
|
||||||
@@ -81,22 +79,25 @@ public class DataEntryActivity extends Activity {
|
|||||||
private Button btnCancel;
|
private Button btnCancel;
|
||||||
private Button btnLeft;
|
private Button btnLeft;
|
||||||
private Button btnRight;
|
private Button btnRight;
|
||||||
private ImageView imageViewDelete;
|
private FloatingActionButton imageViewDelete;
|
||||||
private Switch switchEditMode;
|
private FloatingActionButton switchEditMode;
|
||||||
|
private FloatingActionButton expandButton;
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
|
private boolean editMode;
|
||||||
|
private boolean isExpand;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
||||||
|
|
||||||
setContentView(R.layout.activity_dataentry);
|
setContentView(R.layout.activity_dataentry);
|
||||||
|
|
||||||
context = this;
|
context = this;
|
||||||
|
editMode = false;
|
||||||
|
isExpand = false;
|
||||||
|
|
||||||
tableLayoutDataEntry = (TableLayout) findViewById(R.id.tableLayoutDataEntry);
|
tableLayoutDataEntry = (TableLayout) findViewById(R.id.tableLayoutDataEntry);
|
||||||
|
|
||||||
@@ -140,8 +141,9 @@ public class DataEntryActivity extends Activity {
|
|||||||
btnCancel = (Button) findViewById(R.id.btnCancel);
|
btnCancel = (Button) findViewById(R.id.btnCancel);
|
||||||
btnLeft = (Button) findViewById(R.id.btnLeft);
|
btnLeft = (Button) findViewById(R.id.btnLeft);
|
||||||
btnRight = (Button) findViewById(R.id.btnRight);
|
btnRight = (Button) findViewById(R.id.btnRight);
|
||||||
imageViewDelete = (ImageView) findViewById(R.id.imgViewDelete);
|
imageViewDelete = (FloatingActionButton) findViewById(R.id.imgViewDelete);
|
||||||
switchEditMode = (Switch) findViewById(R.id.switchEditMode);
|
switchEditMode = (FloatingActionButton) findViewById(R.id.switchEditMode);
|
||||||
|
expandButton = (FloatingActionButton) findViewById(R.id.expandButton);
|
||||||
|
|
||||||
btnAdd.setOnClickListener(new onClickListenerAdd());
|
btnAdd.setOnClickListener(new onClickListenerAdd());
|
||||||
btnOk.setOnClickListener(new onClickListenerOk());
|
btnOk.setOnClickListener(new onClickListenerOk());
|
||||||
@@ -149,7 +151,8 @@ public class DataEntryActivity extends Activity {
|
|||||||
imageViewDelete.setOnClickListener(new onClickListenerDelete());
|
imageViewDelete.setOnClickListener(new onClickListenerDelete());
|
||||||
btnLeft.setOnClickListener(new onClickListenerLeft());
|
btnLeft.setOnClickListener(new onClickListenerLeft());
|
||||||
btnRight.setOnClickListener(new onClickListenerRight());
|
btnRight.setOnClickListener(new onClickListenerRight());
|
||||||
switchEditMode.setOnCheckedChangeListener(new onCheckedChangeEditMode());
|
switchEditMode.setOnClickListener(new onCheckedChangeEditMode());
|
||||||
|
expandButton.setOnClickListener(new onClickListenerExpand());
|
||||||
|
|
||||||
updateOnView();
|
updateOnView();
|
||||||
}
|
}
|
||||||
@@ -163,14 +166,26 @@ public class DataEntryActivity extends Activity {
|
|||||||
measuremt.updatePreferences(prefs);
|
measuremt.updatePreferences(prefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
id = getIntent().getExtras().getLong("id");
|
if (getIntent().hasExtra("id")) {
|
||||||
|
id = getIntent().getExtras().getLong("id");
|
||||||
|
}
|
||||||
|
|
||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
if (switchEditMode.isChecked()) {
|
// keep edit mode state if we are moving to left or right
|
||||||
|
if (editMode) {
|
||||||
setViewMode(MeasurementView.MeasurementViewMode.EDIT);
|
setViewMode(MeasurementView.MeasurementViewMode.EDIT);
|
||||||
|
switchEditMode.setBackgroundTintList(ColorStateList.valueOf(ChartUtils.COLOR_GREEN));
|
||||||
} else {
|
} else {
|
||||||
setViewMode(MeasurementView.MeasurementViewMode.VIEW);
|
setViewMode(MeasurementView.MeasurementViewMode.VIEW);
|
||||||
|
switchEditMode.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#D3D3D3")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isExpand) {
|
||||||
|
expandButton.setBackgroundTintList(ColorStateList.valueOf(ChartUtils.COLOR_ORANGE));
|
||||||
|
} else {
|
||||||
|
expandButton.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#D3D3D3")));
|
||||||
|
}
|
||||||
|
|
||||||
OpenScale openScale = OpenScale.getInstance(context);
|
OpenScale openScale = OpenScale.getInstance(context);
|
||||||
|
|
||||||
ScaleData selectedScaleData = openScale.getScaleData(id);
|
ScaleData selectedScaleData = openScale.getScaleData(id);
|
||||||
@@ -194,6 +209,7 @@ public class DataEntryActivity extends Activity {
|
|||||||
|
|
||||||
// show selected scale data
|
// show selected scale data
|
||||||
for (MeasurementView measuremt : dataEntryMeasurements) {
|
for (MeasurementView measuremt : dataEntryMeasurements) {
|
||||||
|
measuremt.setExpand(isExpand);
|
||||||
measuremt.updateValue(selectedScaleData);
|
measuremt.updateValue(selectedScaleData);
|
||||||
measuremt.updateDiff(selectedScaleData, lastData);
|
measuremt.updateDiff(selectedScaleData, lastData);
|
||||||
}
|
}
|
||||||
@@ -426,14 +442,21 @@ public class DataEntryActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class onCheckedChangeEditMode implements CompoundButton.OnCheckedChangeListener {
|
private class onCheckedChangeEditMode implements View.OnClickListener {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onClick(View v) {
|
||||||
if (isChecked) {
|
editMode = !editMode;
|
||||||
setViewMode(MeasurementView.MeasurementViewMode.EDIT);
|
|
||||||
} else {
|
updateOnView();
|
||||||
setViewMode(MeasurementView.MeasurementViewMode.VIEW);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class onClickListenerExpand implements View.OnClickListener {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
isExpand = !isExpand;
|
||||||
|
|
||||||
|
updateOnView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -323,7 +323,6 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
long id = scaleData.id;
|
long id = scaleData.id;
|
||||||
|
|
||||||
Intent intent = new Intent(graphView.getContext(), DataEntryActivity.class);
|
Intent intent = new Intent(graphView.getContext(), DataEntryActivity.class);
|
||||||
intent.putExtra("mode", DataEntryActivity.EDIT_DATA_REQUEST);
|
|
||||||
intent.putExtra("id", id);
|
intent.putExtra("id", id);
|
||||||
startActivityForResult(intent, 1);
|
startActivityForResult(intent, 1);
|
||||||
}
|
}
|
||||||
|
@@ -411,7 +411,6 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
|||||||
public void btnOnClickInsertData()
|
public void btnOnClickInsertData()
|
||||||
{
|
{
|
||||||
Intent intent = new Intent(overviewView.getContext(), DataEntryActivity.class);
|
Intent intent = new Intent(overviewView.getContext(), DataEntryActivity.class);
|
||||||
intent.putExtra("mode", DataEntryActivity.ADD_DATA_REQUEST);
|
|
||||||
startActivityForResult(intent, 1);
|
startActivityForResult(intent, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -260,7 +260,6 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
long id = Long.parseLong(idTextView.getText().toString());
|
long id = Long.parseLong(idTextView.getText().toString());
|
||||||
|
|
||||||
Intent intent = new Intent(tableView.getContext(), DataEntryActivity.class);
|
Intent intent = new Intent(tableView.getContext(), DataEntryActivity.class);
|
||||||
intent.putExtra("mode", DataEntryActivity.EDIT_DATA_REQUEST);
|
|
||||||
intent.putExtra("id", id);
|
intent.putExtra("id", id);
|
||||||
startActivityForResult(intent, 1);
|
startActivityForResult(intent, 1);
|
||||||
}
|
}
|
||||||
|
@@ -223,6 +223,14 @@ public abstract class MeasurementView extends TableLayout {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setExpand(boolean state) {
|
||||||
|
if (state && measurementRow.getVisibility() == View.VISIBLE && evaluateSheet(new EvaluationSheet(getScaleUser()), 0.0f) != null) {
|
||||||
|
evaluatorRow.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
evaluatorRow.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void setVisible(boolean isVisible){
|
protected void setVisible(boolean isVisible){
|
||||||
if(isVisible) {
|
if(isVisible) {
|
||||||
measurementRow.setVisibility(View.VISIBLE);
|
measurementRow.setVisibility(View.VISIBLE);
|
||||||
|
BIN
android_app/app/src/main/res/drawable/expand.png
Normal file
BIN
android_app/app/src/main/res/drawable/expand.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 565 B |
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout 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"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
@@ -45,26 +46,43 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<android.support.design.widget.FloatingActionButton
|
||||||
android:id="@+id/imgViewDelete"
|
|
||||||
android:layout_width="25dp"
|
|
||||||
android:layout_height="25dp"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:scaleType="fitCenter"
|
|
||||||
android:src="@drawable/delete" />
|
|
||||||
|
|
||||||
<Switch
|
|
||||||
android:id="@+id/switchEditMode"
|
android:id="@+id/switchEditMode"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
app:backgroundTint="#D3D3D3"
|
||||||
android:text="@string/label_editmode" />
|
android:clickable="true"
|
||||||
|
android:src="@drawable/editable"
|
||||||
|
app:fabSize="mini"
|
||||||
|
android:layout_marginRight="10dp"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
<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
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Reference in New Issue
Block a user