Commit b31a17f2 authored by mail@toni-fetzer.de's avatar mail@toni-fetzer.de
Browse files

added a function to pause the plot.

fixed another ui button: one some phones, the "back" button was not visible
parent 3c4b5050
...@@ -6,8 +6,8 @@ android { ...@@ -6,8 +6,8 @@ android {
applicationId "de.tonifetzer.sensorrecorder" applicationId "de.tonifetzer.sensorrecorder"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 28 targetSdkVersion 28
versionCode 5 versionCode 6
versionName "1.2" versionName "1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
......
...@@ -46,6 +46,8 @@ public class MainActivity extends AppCompatActivity { ...@@ -46,6 +46,8 @@ public class MainActivity extends AppCompatActivity {
private Button gravityButton; private Button gravityButton;
private Button gyroscopeButton; private Button gyroscopeButton;
private Button barometerButton; private Button barometerButton;
private Button orientationButton;
private ToggleButton pausePlotButton;
private SimpleXYSeries xBuffer; private SimpleXYSeries xBuffer;
private SimpleXYSeries yBuffer; private SimpleXYSeries yBuffer;
...@@ -88,6 +90,8 @@ public class MainActivity extends AppCompatActivity { ...@@ -88,6 +90,8 @@ public class MainActivity extends AppCompatActivity {
gravityButton = plotView.findViewById(R.id.buttonGravity); gravityButton = plotView.findViewById(R.id.buttonGravity);
gyroscopeButton = plotView.findViewById(R.id.buttonGyro); gyroscopeButton = plotView.findViewById(R.id.buttonGyro);
barometerButton = plotView.findViewById(R.id.buttonBarometer); barometerButton = plotView.findViewById(R.id.buttonBarometer);
orientationButton = plotView.findViewById(R.id.buttonOrientation);
pausePlotButton = plotView.findViewById(R.id.buttonPausePlotting);
//init the plotter data //init the plotter data
xBuffer = new SimpleXYSeries("x"); xBuffer = new SimpleXYSeries("x");
...@@ -202,6 +206,30 @@ public class MainActivity extends AppCompatActivity { ...@@ -202,6 +206,30 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
orientationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cleanPlotterData();
currentSensorToPlot = SensorType.ORIENTATION_NEW;
plotClass.setTitle("Orientation Data");
}
});
pausePlotButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
pausePlotButton.setTextOn("Resume Plot");
redrawer.pause();
}
else{
pausePlotButton.setTextOn("Pause Plot");
redrawer.start();
}
}
});
} }
private void startRecording() { private void startRecording() {
......
...@@ -4,74 +4,121 @@ ...@@ -4,74 +4,121 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:background="#333" android:background="#333"
android:weightSum="2"
xmlns:ap="http://schemas.android.com/apk/res-auto"> xmlns:ap="http://schemas.android.com/apk/res-auto">
<com.androidplot.xy.XYPlot <com.androidplot.xy.XYPlot
style="@style/APDefacto.Dark"
android:id="@+id/plot" android:id="@+id/plot"
style="@style/APDefacto.Dark"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="400dp" android:layout_height="wrap_content"
ap:title="Accelerometer Data" android:layout_weight="1"
ap:rangeTitle="range"
ap:domainTitle="size" ap:domainTitle="size"
ap:lineLabelRotationBottom="-45"
ap:lineLabels="left|bottom" ap:lineLabels="left|bottom"
ap:lineLabelRotationBottom="-45"/> ap:rangeTitle="range"
ap:title="Accelerometer Data" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<Button
android:id="@+id/buttonAcc" <LinearLayout
android:layout_width="120dp" android:layout_width="wrap_content"
android:layout_height="36dp" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:gravity="center"
android:layout_marginTop="10dp" android:orientation="horizontal">
android:text="Accelerometer" />
<Button
<Button android:id="@+id/buttonAcc"
android:id="@+id/buttonLinearAcc" android:layout_width="120dp"
android:layout_width="120dp" android:layout_height="36dp"
android:layout_height="36dp" android:layout_marginLeft="5dp"
android:layout_marginLeft="5dp" android:text="Accelerometer" />
android:layout_marginTop="10dp"
android:text="Linear Acc" /> <Button
android:id="@+id/buttonLinearAcc"
<Button android:layout_width="120dp"
android:id="@+id/buttonGravity" android:layout_height="36dp"
android:layout_width="120dp" android:layout_marginLeft="5dp"
android:layout_height="36dp" android:text="Linear Acc" />
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp" </LinearLayout>
android:text="Gravity" />
<LinearLayout
<Button android:layout_width="wrap_content"
android:id="@+id/buttonGyro" android:layout_height="wrap_content"
android:layout_width="120dp" android:gravity="center"
android:layout_height="36dp" android:orientation="horizontal">
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp" <Button
android:text="Gyroscope" /> android:id="@+id/buttonGravity"
android:layout_width="120dp"
<Button android:layout_height="36dp"
android:id="@+id/buttonBarometer" android:layout_marginLeft="5dp"
android:layout_width="120dp" android:text="Gravity" />
android:layout_height="36dp"
android:layout_marginLeft="5dp" <Button
android:layout_marginTop="10dp" android:id="@+id/buttonGyro"
android:text="Barometer" /> android:layout_width="120dp"
android:layout_height="36dp"
<Button android:layout_marginLeft="5dp"
android:id="@+id/buttonBack" android:text="Gyroscope" />
android:layout_width="120dp"
android:layout_height="36dp" </LinearLayout>
android:layout_marginLeft="250dp"
android:layout_marginTop="10dp" <LinearLayout
android:text="Back" /> android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/buttonBarometer"
android:layout_width="120dp"
android:layout_height="36dp"
android:layout_marginLeft="5dp"
android:text="Barometer" />
<Button
android:id="@+id/buttonOrientation"
android:layout_width="120dp"
android:layout_height="36dp"
android:layout_marginLeft="5dp"
android:text="Orientation" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/buttonBack"
android:layout_width="120dp"
android:layout_height="36dp"
android:layout_marginLeft="5dp"
android:text="Back" />
<ToggleButton
android:id="@+id/buttonPausePlotting"
android:layout_width="120dp"
android:layout_height="36dp"
android:layout_marginLeft="5dp"
android:textOff="Pause Plot"
android:textOn="Resume Plot" />
</LinearLayout>
</LinearLayout> </LinearLayout>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment