diff --git a/app/release/app-release-4.2.1n.apk b/app/release/app-release-4.2.1m.apk similarity index 82% rename from app/release/app-release-4.2.1n.apk rename to app/release/app-release-4.2.1m.apk index 2a504e1..e702352 100644 Binary files a/app/release/app-release-4.2.1n.apk and b/app/release/app-release-4.2.1m.apk differ diff --git a/app/src/main/java/uk/org/openseizuredetector/FragmentCommon.java b/app/src/main/java/uk/org/openseizuredetector/FragmentCommon.java index 4030ada..80c0dca 100644 --- a/app/src/main/java/uk/org/openseizuredetector/FragmentCommon.java +++ b/app/src/main/java/uk/org/openseizuredetector/FragmentCommon.java @@ -185,6 +185,22 @@ public class FragmentCommon extends FragmentOsdBaseClass { tv.setTextColor(Color.GRAY); tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } + + tv = (TextView) mRootView.findViewById(R.id.dataSourceInfoTv); + tv.setBackgroundColor(okColour); + tv.setTextColor(okTextColour); + if (mConnection.mSdServer.mSdDataSourceName.equals("Phone")) { + tv.setText(getString(R.string.DataSource) + " = " + "Phone (Demo Mode)"); + tv.setBackgroundColor(warnColour); + tv.setTextColor(warnTextColour); + } else if (mConnection.mSdServer.mSdDataSourceName.equals("BLE")) { + tv.setText(getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName + + " ("+ mConnection.mSdServer.mSdData.watchSdName + ", " + + mConnection.mSdServer.mSdData.watchPartNo+")"); + } else { + tv.setText(getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName); + } + } } else { tv = (TextView) mRootView.findViewById(R.id.serverStatusTv); @@ -200,20 +216,6 @@ public class FragmentCommon extends FragmentOsdBaseClass { */ } - tv = (TextView) mRootView.findViewById(R.id.dataSourceInfoTv); - tv.setBackgroundColor(okColour); - tv.setTextColor(okTextColour); - if (mConnection.mSdServer.mSdDataSourceName.equals("Phone")) { - tv.setText(getString(R.string.DataSource) + " = " + "Phone (Demo Mode)"); - tv.setBackgroundColor(warnColour); - tv.setTextColor(warnTextColour); - } else if (mConnection.mSdServer.mSdDataSourceName.equals("BLE")) { - tv.setText(getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName - + " ("+ mConnection.mSdServer.mSdData.watchSdName + ", " - + mConnection.mSdServer.mSdData.watchPartNo+")"); - } else { - tv.setText(getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName); - } // deal with latch alarms button Button acceptAlarmButton = (Button) mRootView.findViewById(R.id.acceptAlarmButton); diff --git a/app/src/main/java/uk/org/openseizuredetector/FragmentOsdAlg.java b/app/src/main/java/uk/org/openseizuredetector/FragmentOsdAlg.java index 19b65b7..e38d5c7 100644 --- a/app/src/main/java/uk/org/openseizuredetector/FragmentOsdAlg.java +++ b/app/src/main/java/uk/org/openseizuredetector/FragmentOsdAlg.java @@ -46,143 +46,143 @@ public class FragmentOsdAlg extends FragmentOsdBaseClass { //Log.d(TAG,"updateUi()"); TextView tv; + if (mConnection.mBound) { + ///////////////////////////////////////////////////// + // Set ProgressBars to show margin to alarm. + long powerPc; + if (mConnection.mSdServer.mSdData.alarmThresh != 0) + powerPc = mConnection.mSdServer.mSdData.roiPower * 100 / + mConnection.mSdServer.mSdData.alarmThresh; + else + powerPc = 0; - ///////////////////////////////////////////////////// - // Set ProgressBars to show margin to alarm. - long powerPc; - if (mConnection.mSdServer.mSdData.alarmThresh != 0) - powerPc = mConnection.mSdServer.mSdData.roiPower * 100 / - mConnection.mSdServer.mSdData.alarmThresh; - else - powerPc = 0; + long specPc; + if (mConnection.mSdServer.mSdData.specPower != 0 && + mConnection.mSdServer.mSdData.alarmRatioThresh != 0) + specPc = 100 * (mConnection.mSdServer.mSdData.roiPower * 10 / + mConnection.mSdServer.mSdData.specPower) / + mConnection.mSdServer.mSdData.alarmRatioThresh; + else + specPc = 0; - long specPc; - if (mConnection.mSdServer.mSdData.specPower != 0 && - mConnection.mSdServer.mSdData.alarmRatioThresh != 0) - specPc = 100 * (mConnection.mSdServer.mSdData.roiPower * 10 / - mConnection.mSdServer.mSdData.specPower) / - mConnection.mSdServer.mSdData.alarmRatioThresh; - else - specPc = 0; + long specRatio; + if (mConnection.mSdServer.mSdData.specPower != 0) { + specRatio = 10 * mConnection.mSdServer.mSdData.roiPower / + mConnection.mSdServer.mSdData.specPower; + } else + specRatio = 0; - long specRatio; - if (mConnection.mSdServer.mSdData.specPower != 0) { - specRatio = 10 * mConnection.mSdServer.mSdData.roiPower / - mConnection.mSdServer.mSdData.specPower; - } else - specRatio = 0; + ((TextView) mRootView.findViewById(R.id.powerTv)).setText(getString(R.string.PowerEquals) + mConnection.mSdServer.mSdData.roiPower + + " (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmThresh + ")"); - ((TextView) mRootView.findViewById(R.id.powerTv)).setText(getString(R.string.PowerEquals) + mConnection.mSdServer.mSdData.roiPower + - " (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmThresh + ")"); + ProgressBar pb; + Drawable pbDrawable; + pb = ((ProgressBar) mRootView.findViewById(R.id.powerProgressBar)); + pb.setMax(100); + pb.setProgress((int) powerPc); + pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_blue); + if (powerPc > 75) + pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_yellow); + if (powerPc > 100) + pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_red); + pb.setProgressDrawable(pbDrawable); - ProgressBar pb; - Drawable pbDrawable; - pb = ((ProgressBar) mRootView.findViewById(R.id.powerProgressBar)); - pb.setMax(100); - pb.setProgress((int) powerPc); - pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_blue); - if (powerPc > 75) - pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_yellow); - if (powerPc > 100) - pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_red); - pb.setProgressDrawable(pbDrawable); + ((TextView) mRootView.findViewById(R.id.spectrumTv)).setText(getString(R.string.SpectrumRatioEquals) + specRatio + + " (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmRatioThresh + ")"); - ((TextView) mRootView.findViewById(R.id.spectrumTv)).setText(getString(R.string.SpectrumRatioEquals) + specRatio + - " (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmRatioThresh + ")"); + pb = ((ProgressBar) mRootView.findViewById(R.id.spectrumProgressBar)); + pb.setMax(100); + pb.setProgress((int) specPc); + pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_blue); + if (specPc > 75) + pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_yellow); + if (specPc > 100) + pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_red); + pb.setProgressDrawable(pbDrawable); - pb = ((ProgressBar) mRootView.findViewById(R.id.spectrumProgressBar)); - pb.setMax(100); - pb.setProgress((int) specPc); - pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_blue); - if (specPc > 75) - pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_yellow); - if (specPc > 100) - pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_red); - pb.setProgressDrawable(pbDrawable); + //////////////////////////////////////////////////////////// + // Produce graph + BarChart mChart = (BarChart) mRootView.findViewById(R.id.chart1); + mChart.setDrawBarShadow(false); + mChart.setNoDataTextDescription("You need to provide data for the chart."); + mChart.setDescription(""); - //////////////////////////////////////////////////////////// - // Produce graph - BarChart mChart = (BarChart) mRootView.findViewById(R.id.chart1); - mChart.setDrawBarShadow(false); - mChart.setNoDataTextDescription("You need to provide data for the chart."); - mChart.setDescription(""); - - // X and Y Values - ArrayList xVals = new ArrayList(); - ArrayList yBarVals = new ArrayList(); - for (int i = 0; i < 10; i++) { - xVals.add(i + "-" + (i + 1) + " Hz"); - if (mConnection.mSdServer != null) { - yBarVals.add(new BarEntry(mConnection.mSdServer.mSdData.simpleSpec[i], i)); - } else { - yBarVals.add(new BarEntry(i, i)); - } - } - - // create a dataset and give it a type - BarDataSet barDataSet = new BarDataSet(yBarVals, "Spectrum"); - try { - int[] barColours = new int[10]; + // X and Y Values + ArrayList xVals = new ArrayList(); + ArrayList yBarVals = new ArrayList(); for (int i = 0; i < 10; i++) { - if ((i < mConnection.mSdServer.mSdData.alarmFreqMin) || - (i > mConnection.mSdServer.mSdData.alarmFreqMax)) { - barColours[i] = Color.GRAY; + xVals.add(i + "-" + (i + 1) + " Hz"); + if (mConnection.mSdServer != null) { + yBarVals.add(new BarEntry(mConnection.mSdServer.mSdData.simpleSpec[i], i)); } else { - barColours[i] = Color.RED; + yBarVals.add(new BarEntry(i, i)); } } - barDataSet.setColors(barColours); - } catch (NullPointerException e) { - Log.e(TAG, "Null pointer exception setting bar colours"); - } - barDataSet.setBarSpacePercent(20f); - barDataSet.setBarShadowColor(Color.WHITE); - BarData barData = new BarData(xVals, barDataSet); - barData.setValueFormatter(new ValueFormatter() { - @Override - public String getFormattedValue(float v) { - DecimalFormat format = new DecimalFormat("####"); - return format.format(v); + + // create a dataset and give it a type + BarDataSet barDataSet = new BarDataSet(yBarVals, "Spectrum"); + try { + int[] barColours = new int[10]; + for (int i = 0; i < 10; i++) { + if ((i < mConnection.mSdServer.mSdData.alarmFreqMin) || + (i > mConnection.mSdServer.mSdData.alarmFreqMax)) { + barColours[i] = Color.GRAY; + } else { + barColours[i] = Color.RED; + } + } + barDataSet.setColors(barColours); + } catch (NullPointerException e) { + Log.e(TAG, "Null pointer exception setting bar colours"); } - }); - mChart.setData(barData); + barDataSet.setBarSpacePercent(20f); + barDataSet.setBarShadowColor(Color.WHITE); + BarData barData = new BarData(xVals, barDataSet); + barData.setValueFormatter(new ValueFormatter() { + @Override + public String getFormattedValue(float v) { + DecimalFormat format = new DecimalFormat("####"); + return format.format(v); + } + }); + mChart.setData(barData); - // format the axes - XAxis xAxis = mChart.getXAxis(); - xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); - xAxis.setTextSize(10f); - xAxis.setDrawAxisLine(true); - xAxis.setDrawLabels(true); - // Note: the default text colour is BLACK, so does not show up on black background!!! - // This took a lot of finding.... - xAxis.setTextColor(Color.WHITE); - xAxis.setDrawGridLines(false); + // format the axes + XAxis xAxis = mChart.getXAxis(); + xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); + xAxis.setTextSize(10f); + xAxis.setDrawAxisLine(true); + xAxis.setDrawLabels(true); + // Note: the default text colour is BLACK, so does not show up on black background!!! + // This took a lot of finding.... + xAxis.setTextColor(Color.WHITE); + xAxis.setDrawGridLines(false); - YAxis yAxis = mChart.getAxisLeft(); - yAxis.setAxisMinValue(0f); - yAxis.setAxisMaxValue(3000f); - yAxis.setDrawGridLines(true); - yAxis.setDrawLabels(true); - yAxis.setTextColor(Color.WHITE); - yAxis.setValueFormatter(new ValueFormatter() { - @Override - public String getFormattedValue(float v) { - DecimalFormat format = new DecimalFormat("#####"); - return format.format(v); + YAxis yAxis = mChart.getAxisLeft(); + yAxis.setAxisMinValue(0f); + yAxis.setAxisMaxValue(3000f); + yAxis.setDrawGridLines(true); + yAxis.setDrawLabels(true); + yAxis.setTextColor(Color.WHITE); + yAxis.setValueFormatter(new ValueFormatter() { + @Override + public String getFormattedValue(float v) { + DecimalFormat format = new DecimalFormat("#####"); + return format.format(v); + } + }); + + YAxis yAxis2 = mChart.getAxisRight(); + yAxis2.setDrawGridLines(false); + + try { + mChart.getLegend().setEnabled(false); + } catch (NullPointerException e) { + Log.e(TAG, "Null Pointer Exception setting legend"); } - }); - YAxis yAxis2 = mChart.getAxisRight(); - yAxis2.setDrawGridLines(false); + mChart.invalidate(); - try { - mChart.getLegend().setEnabled(false); - } catch (NullPointerException e) { - Log.e(TAG, "Null Pointer Exception setting legend"); } - - mChart.invalidate(); - - } } diff --git a/app/src/main/java/uk/org/openseizuredetector/FragmentSystem.java b/app/src/main/java/uk/org/openseizuredetector/FragmentSystem.java index 4c34f24..ef6d18f 100644 --- a/app/src/main/java/uk/org/openseizuredetector/FragmentSystem.java +++ b/app/src/main/java/uk/org/openseizuredetector/FragmentSystem.java @@ -74,14 +74,14 @@ public class FragmentSystem extends FragmentOsdBaseClass { if (mConnection.mBound) { if (mConnection.mSdServer.mSdDataSourceName.equals("Phone")) { if (mConnection.mSdServer.mLogNDA) - tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + "\n" + "(Demo Mode)" + "\nNDA Logging"); + tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + " " + "(Demo Mode)" + "\nNDA Logging"); else - tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + "\n" + "(Demo Mode)"); + tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + " " + "(Demo Mode)"); tv.setBackgroundColor(warnColour); tv.setTextColor(warnTextColour); } else { if (mConnection.mSdServer.mLogNDA) - tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName + "\nNDA Logging"); + tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName + ": NDA Logging"); else tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName); tv.setBackgroundColor(okColour);