mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-10 10:44:47 +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 {
|
||||
compile 'com.android.support:design:25.0.1'
|
||||
compile "com.android.support:support-v4:${supportLibVersion}"
|
||||
compile "com.android.support:appcompat-v7:${supportLibVersion}"
|
||||
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.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
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.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@@ -55,10 +54,9 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.ListIterator;
|
||||
|
||||
public class DataEntryActivity extends Activity {
|
||||
public static final int ADD_DATA_REQUEST = 0;
|
||||
public static final int EDIT_DATA_REQUEST = 1;
|
||||
import lecho.lib.hellocharts.util.ChartUtils;
|
||||
|
||||
public class DataEntryActivity extends Activity {
|
||||
private ArrayList<MeasurementView> dataEntryMeasurements;
|
||||
private TableLayout tableLayoutDataEntry;
|
||||
|
||||
@@ -81,22 +79,25 @@ public class DataEntryActivity extends Activity {
|
||||
private Button btnCancel;
|
||||
private Button btnLeft;
|
||||
private Button btnRight;
|
||||
private ImageView imageViewDelete;
|
||||
private Switch switchEditMode;
|
||||
private FloatingActionButton imageViewDelete;
|
||||
private FloatingActionButton switchEditMode;
|
||||
private FloatingActionButton expandButton;
|
||||
|
||||
private long id;
|
||||
|
||||
private Context context;
|
||||
private boolean editMode;
|
||||
private boolean isExpand;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
setContentView(R.layout.activity_dataentry);
|
||||
|
||||
context = this;
|
||||
editMode = false;
|
||||
isExpand = false;
|
||||
|
||||
tableLayoutDataEntry = (TableLayout) findViewById(R.id.tableLayoutDataEntry);
|
||||
|
||||
@@ -140,8 +141,9 @@ public class DataEntryActivity extends Activity {
|
||||
btnCancel = (Button) findViewById(R.id.btnCancel);
|
||||
btnLeft = (Button) findViewById(R.id.btnLeft);
|
||||
btnRight = (Button) findViewById(R.id.btnRight);
|
||||
imageViewDelete = (ImageView) findViewById(R.id.imgViewDelete);
|
||||
switchEditMode = (Switch) findViewById(R.id.switchEditMode);
|
||||
imageViewDelete = (FloatingActionButton) findViewById(R.id.imgViewDelete);
|
||||
switchEditMode = (FloatingActionButton) findViewById(R.id.switchEditMode);
|
||||
expandButton = (FloatingActionButton) findViewById(R.id.expandButton);
|
||||
|
||||
btnAdd.setOnClickListener(new onClickListenerAdd());
|
||||
btnOk.setOnClickListener(new onClickListenerOk());
|
||||
@@ -149,7 +151,8 @@ public class DataEntryActivity extends Activity {
|
||||
imageViewDelete.setOnClickListener(new onClickListenerDelete());
|
||||
btnLeft.setOnClickListener(new onClickListenerLeft());
|
||||
btnRight.setOnClickListener(new onClickListenerRight());
|
||||
switchEditMode.setOnCheckedChangeListener(new onCheckedChangeEditMode());
|
||||
switchEditMode.setOnClickListener(new onCheckedChangeEditMode());
|
||||
expandButton.setOnClickListener(new onClickListenerExpand());
|
||||
|
||||
updateOnView();
|
||||
}
|
||||
@@ -163,14 +166,26 @@ public class DataEntryActivity extends Activity {
|
||||
measuremt.updatePreferences(prefs);
|
||||
}
|
||||
|
||||
id = getIntent().getExtras().getLong("id");
|
||||
if (getIntent().hasExtra("id")) {
|
||||
id = getIntent().getExtras().getLong("id");
|
||||
}
|
||||
|
||||
if (id > 0) {
|
||||
if (switchEditMode.isChecked()) {
|
||||
// keep edit mode state if we are moving to left or right
|
||||
if (editMode) {
|
||||
setViewMode(MeasurementView.MeasurementViewMode.EDIT);
|
||||
switchEditMode.setBackgroundTintList(ColorStateList.valueOf(ChartUtils.COLOR_GREEN));
|
||||
} else {
|
||||
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);
|
||||
|
||||
ScaleData selectedScaleData = openScale.getScaleData(id);
|
||||
@@ -194,6 +209,7 @@ public class DataEntryActivity extends Activity {
|
||||
|
||||
// show selected scale data
|
||||
for (MeasurementView measuremt : dataEntryMeasurements) {
|
||||
measuremt.setExpand(isExpand);
|
||||
measuremt.updateValue(selectedScaleData);
|
||||
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
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
setViewMode(MeasurementView.MeasurementViewMode.EDIT);
|
||||
} else {
|
||||
setViewMode(MeasurementView.MeasurementViewMode.VIEW);
|
||||
}
|
||||
public void onClick(View v) {
|
||||
editMode = !editMode;
|
||||
|
||||
updateOnView();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
Intent intent = new Intent(graphView.getContext(), DataEntryActivity.class);
|
||||
intent.putExtra("mode", DataEntryActivity.EDIT_DATA_REQUEST);
|
||||
intent.putExtra("id", id);
|
||||
startActivityForResult(intent, 1);
|
||||
}
|
||||
|
@@ -411,7 +411,6 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
||||
public void btnOnClickInsertData()
|
||||
{
|
||||
Intent intent = new Intent(overviewView.getContext(), DataEntryActivity.class);
|
||||
intent.putExtra("mode", DataEntryActivity.ADD_DATA_REQUEST);
|
||||
startActivityForResult(intent, 1);
|
||||
}
|
||||
|
||||
|
@@ -260,7 +260,6 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
|
||||
long id = Long.parseLong(idTextView.getText().toString());
|
||||
|
||||
Intent intent = new Intent(tableView.getContext(), DataEntryActivity.class);
|
||||
intent.putExtra("mode", DataEntryActivity.EDIT_DATA_REQUEST);
|
||||
intent.putExtra("id", id);
|
||||
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){
|
||||
if(isVisible) {
|
||||
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"?>
|
||||
<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_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
@@ -45,26 +46,43 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
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.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/switchEditMode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="@string/label_editmode" />
|
||||
app:backgroundTint="#D3D3D3"
|
||||
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
|
||||
android:layout_width="match_parent"
|
||||
|
Reference in New Issue
Block a user