Chnaged main screen graph to bar chart.
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
OpenSeizureDetector Android App - Change Log
|
||||
============================================
|
||||
|
||||
V2.0.4 - 09 May 2016
|
||||
Improved handling of watch app settings to make sure
|
||||
they are loaded correctly without having to re-start app.
|
||||
Added watch app to Andid phone app package so watch app can be
|
||||
installed directly from phone rather than using pebble store.
|
||||
Changed main screen graph to bar chart.
|
||||
|
||||
V2.0.3 - 23 April 2016
|
||||
Further modification to beep code to avoid occasional crashes
|
||||
if system tries to beep during a re-start.
|
||||
|
||||
@@ -54,10 +54,16 @@ import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
//MPAndroidChart
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
static final String TAG = "MainActivity";
|
||||
@@ -162,6 +168,9 @@ public class MainActivity extends Activity {
|
||||
Log.v(TAG, "action_launch_pebble_app");
|
||||
mUtil.startPebbleApp();
|
||||
return true;
|
||||
case R.id.action_instal_watch_app:
|
||||
Log.v(TAG, "action_install_watch_app");
|
||||
mConnection.mSdServer.mSdDataSource.installWatchApp();
|
||||
|
||||
case R.id.action_accept_alarm:
|
||||
Log.v(TAG, "action_accept_alarm");
|
||||
@@ -499,33 +508,56 @@ public class MainActivity extends Activity {
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Produce graph
|
||||
LineChart mChart = (LineChart) findViewById(R.id.chart1);
|
||||
mChart.setDescription("");
|
||||
BarChart mChart = (BarChart) findViewById(R.id.chart1);
|
||||
mChart.setDescription("Simple Spectrum");
|
||||
mChart.setDrawBarShadow(false);
|
||||
mChart.setNoDataTextDescription("You need to provide data for the chart.");
|
||||
// X Values
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
xVals.add((i) + "");
|
||||
}
|
||||
XAxis xAxis = mChart.getXAxis();
|
||||
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
|
||||
xAxis.setTextSize(10f);
|
||||
xAxis.setDrawAxisLine(true);
|
||||
xAxis.setDrawLabels(true);
|
||||
xAxis.setEnabled(true);
|
||||
// Y Values
|
||||
ArrayList<Entry> yVals = new ArrayList<Entry>();
|
||||
//ArrayList<Entry> yVals = new ArrayList<Entry>();
|
||||
ArrayList<BarEntry> yBarVals = new ArrayList<BarEntry>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (mConnection.mSdServer != null)
|
||||
yVals.add(new Entry(mConnection.mSdServer.mSdData.simpleSpec[i], i));
|
||||
else
|
||||
yVals.add(new Entry(i, i));
|
||||
if (mConnection.mSdServer != null) {
|
||||
//yVals.add(new Entry(mConnection.mSdServer.mSdData.simpleSpec[i], i));
|
||||
yBarVals.add(new BarEntry(mConnection.mSdServer.mSdData.simpleSpec[i], i));
|
||||
}
|
||||
else {
|
||||
//yVals.add(new Entry(i, i));
|
||||
yBarVals.add(new BarEntry(i,i));
|
||||
}
|
||||
}
|
||||
|
||||
// create a dataset and give it a type
|
||||
LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
|
||||
set1.setColor(Color.BLACK);
|
||||
set1.setLineWidth(1f);
|
||||
//LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
|
||||
//set1.setColor(Color.BLACK);
|
||||
//set1.setLineWidth(1f);
|
||||
|
||||
//ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
|
||||
//dataSets.add(set1); // add the datasets
|
||||
//LineData data = new LineData(xVals, dataSets);
|
||||
|
||||
BarDataSet barDataSet = new BarDataSet(yBarVals,"Spectrum");
|
||||
barDataSet.setColor(Color.GRAY);
|
||||
barDataSet.setBarSpacePercent(20f);
|
||||
barDataSet.setBarShadowColor(Color.WHITE);
|
||||
ArrayList<BarDataSet> barDataSets = new ArrayList<BarDataSet>();
|
||||
barDataSets.add(barDataSet);
|
||||
BarData barData = new BarData(xVals,barDataSets);
|
||||
mChart.setData(barData);
|
||||
|
||||
|
||||
ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
|
||||
dataSets.add(set1); // add the datasets
|
||||
LineData data = new LineData(xVals, dataSets);
|
||||
//data.setValueTextSize(10f);
|
||||
mChart.setData(data);
|
||||
//mChart.setData(data);
|
||||
mChart.invalidate();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -148,6 +148,8 @@ public class SdData implements Parcelable {
|
||||
jsonObj.put("haveSettings", haveSettings);
|
||||
jsonObj.put("alarmState", alarmState);
|
||||
jsonObj.put("alarmPhrase", alarmPhrase);
|
||||
jsonObj.put("alarmFreqMin",alarmFreqMin);
|
||||
jsonObj.put("alarmFreqMax",alarmFreqMax);
|
||||
jsonObj.put("alarmThresh", alarmThresh);
|
||||
jsonObj.put("alarmRatioThresh", alarmRatioThresh);
|
||||
JSONArray arr = new JSONArray();
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
android:text="Cancel Audible (temporarily)" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.github.mikephil.charting.charts.LineChart
|
||||
<com.github.mikephil.charting.charts.BarChart
|
||||
android:id="@+id/chart1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
@@ -5,12 +5,6 @@
|
||||
android:title="Accept Alarm" />
|
||||
|
||||
|
||||
<item
|
||||
android:id="@+id/action_launch_pebble_app"
|
||||
android:icon="@drawable/stop_server"
|
||||
android:showAsAction="never|withText"
|
||||
android:title="Launch Pebble App" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_start_stop"
|
||||
android:icon="@drawable/stop_server"
|
||||
@@ -24,6 +18,16 @@
|
||||
android:showAsAction="never|withText"
|
||||
android:title="Test Fault Beep" />
|
||||
-->
|
||||
<item
|
||||
android:id="@+id/action_launch_pebble_app"
|
||||
android:showAsAction="never|withText"
|
||||
android:title="Launch Pebble App" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_instal_watch_app"
|
||||
android:showAsAction="never|withText"
|
||||
android:title="Install Watch App" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_test_alarm_beep"
|
||||
android:icon="@drawable/stop_server"
|
||||
|
||||
Reference in New Issue
Block a user