V2.3.2 - Added first run dialog box and removed preferences for non-functional camera settings.

This commit is contained in:
Graham Jones
2016-12-26 22:25:59 +00:00
parent 4baed5ea97
commit 00c335f70b
7 changed files with 188 additions and 55 deletions
+3
View File
@@ -1,6 +1,9 @@
OpenSeizureDetector Android App - Change Log OpenSeizureDetector Android App - Change Log
============================================ ============================================
V2.3.2 - 26 Dec 2016
- Added first run dialog with message to StartUpActivity.
V2.3.1 - 19 Dec 2016 V2.3.1 - 19 Dec 2016
- Changed auto-start feature to start the SDServer background service rather than the StartUpActvity so it will work - Changed auto-start feature to start the SDServer background service rather than the StartUpActvity so it will work
when the phone screen is locked. when the phone screen is locked.
Binary file not shown.
+2 -4
View File
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.org.openseizuredetector" package="uk.org.openseizuredetector"
android:versionCode="32" android:versionCode="33"
android:versionName="2.3.1"> android:versionName="2.3.2">
<uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
@@ -72,8 +72,8 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
String dataSourceStr = SP.getString("DataSource", "Pebble"); String dataSourceStr = SP.getString("DataSource", "Pebble");
Log.v(TAG, "onBuildHeaders DataSource = " + dataSourceStr); Log.v(TAG, "onBuildHeaders DataSource = " + dataSourceStr);
Boolean cameraEnabled = SP.getBoolean("UseIpCamera", false); //Boolean cameraEnabled = SP.getBoolean("UseIpCamera", false);
Log.v(TAG, "onBuildHeaders cameraEnabled = " + cameraEnabled); //Log.v(TAG, "onBuildHeaders cameraEnabled = " + cameraEnabled);
for (int i = 0; i < target.size(); i++) { for (int i = 0; i < target.size(); i++) {
Header h = target.get(i); Header h = target.get(i);
@@ -94,14 +94,14 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
i = i -1; i = i -1;
} }
} }
if (h.title.toString().equals("Camera Settings")) { //if (h.title.toString().equals("Camera Settings")) {
Log.v(TAG, "found Camera Settings Header"); // Log.v(TAG, "found Camera Settings Header");
if (!cameraEnabled) { // if (!cameraEnabled) {
Log.v(TAG, "Removing camera settings header"); // Log.v(TAG, "Removing camera settings header");
target.remove(i); // target.remove(i);
i = i-1; // i = i-1;
} // }
} //}
} }
} }
@@ -202,14 +202,14 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
} }
} }
public static class CameraPrefsFragment extends PreferenceFragment { //public static class CameraPrefsFragment extends PreferenceFragment {
@Override // @Override
public void onCreate(Bundle savedInstanceState) { // public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); // super.onCreate(savedInstanceState);
// Load the preferences from an XML resource // Load the preferences from an XML resource
addPreferencesFromResource(R.xml.camera_prefs); // addPreferencesFromResource(R.xml.camera_prefs);
} // }
} //}
} }
@@ -25,8 +25,13 @@
package uk.org.openseizuredetector; package uk.org.openseizuredetector;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@@ -34,6 +39,9 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
@@ -50,7 +58,7 @@ import java.util.TimerTask;
* starting the main activity. * starting the main activity.
*/ */
public class StartupActivity extends Activity { public class StartupActivity extends Activity {
private String TAG = "StartupActivity"; private static String TAG = "StartupActivity";
private int okColour = Color.BLUE; private int okColour = Color.BLUE;
private int warnColour = Color.MAGENTA; private int warnColour = Color.MAGENTA;
private int alarmColour = Color.RED; private int alarmColour = Color.RED;
@@ -63,6 +71,7 @@ public class StartupActivity extends Activity {
private Timer mUiTimer; private Timer mUiTimer;
private SdServiceConnection mConnection; private SdServiceConnection mConnection;
private boolean mStartedMainActivity = false; private boolean mStartedMainActivity = false;
private boolean mDialogDisplayed = false;
private Handler mHandler = new Handler(); // used to update ui from mUiTimer private Handler mHandler = new Handler(); // used to update ui from mUiTimer
private boolean mUsingPebbleDataSource = true; private boolean mUsingPebbleDataSource = true;
private String mPebbleAppPackageName = null; private String mPebbleAppPackageName = null;
@@ -168,7 +177,8 @@ public class StartupActivity extends Activity {
// Display the DataSource name // Display the DataSource name
SharedPreferences SP = PreferenceManager SharedPreferences SP = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());; .getDefaultSharedPreferences(getBaseContext());
;
String dataSourceName = SP.getString("DataSource", "Pebble"); String dataSourceName = SP.getString("DataSource", "Pebble");
tv = (TextView) findViewById(R.id.dataSourceTextView); tv = (TextView) findViewById(R.id.dataSourceTextView);
tv.setText("DataSource = " + dataSourceName); tv.setText("DataSource = " + dataSourceName);
@@ -198,6 +208,9 @@ public class StartupActivity extends Activity {
mConnection = new SdServiceConnection(this); mConnection = new SdServiceConnection(this);
mUtil.bindToServer(this, mConnection); mUtil.bindToServer(this, mConnection);
// Check to see if this is the first time the app has been run, and display welcome dialog if it is.
checkFirstRun();
// start timer to refresh user interface every second. // start timer to refresh user interface every second.
mUiTimer = new Timer(); mUiTimer = new Timer();
mUiTimer.schedule(new TimerTask() { mUiTimer.schedule(new TimerTask() {
@@ -208,6 +221,7 @@ public class StartupActivity extends Activity {
} }
}, 0, 1000); }, 0, 1000);
} }
@Override @Override
@@ -371,10 +385,10 @@ public class StartupActivity extends Activity {
} }
// If all the parameters are ok, close this activity and open the main // If all the parameters are ok, close this activity and open the main
// user interface activity instead. // user interface activity instead.
if (allOk) { if (allOk) {
if (!mDialogDisplayed) {
if (!mStartedMainActivity) { if (!mStartedMainActivity) {
Log.v(TAG, "starting main activity..."); Log.v(TAG, "starting main activity...");
mUtil.writeToSysLogFile("StartupActivity.serverStatusRunnable - all checks ok - starting main activity."); mUtil.writeToSysLogFile("StartupActivity.serverStatusRunnable - all checks ok - starting main activity.");
@@ -395,7 +409,117 @@ public class StartupActivity extends Activity {
Log.v(TAG, "allOk, but already started MainActivity so not doing anything"); Log.v(TAG, "allOk, but already started MainActivity so not doing anything");
mUtil.writeToSysLogFile("StartupActivity.serverStatusRunnable - allOk, but already started MainActivity so not doing anything"); mUtil.writeToSysLogFile("StartupActivity.serverStatusRunnable - allOk, but already started MainActivity so not doing anything");
} }
} else {
Log.v(TAG, "allok, but dialog displayted so not starting MainActivity");
}
} }
} }
}; };
/**
* getVersionName - returns the version name (e.g. 2.3.2) for this application.
*
* @param context
* @param cls - a class from which to determine the version mame.
* @return the string version name specified in AndroidManifest.xml
*/
public static String getVersionName(Context context, Class cls) {
try {
ComponentName comp = new ComponentName(context, cls);
PackageInfo pinfo = context.getPackageManager().getPackageInfo(
comp.getPackageName(), 0);
return "Version: " + pinfo.versionName;
} catch (android.content.pm.PackageManager.NameNotFoundException e) {
Log.e(TAG, "getVersionName Exception - " + e.toString());
return null;
}
}
/**
* checkFirstRun - checks to see if this is the first run of the app after installation or upgrade.
* if it is, the relevant dialog message is displayed. If not, the routine just exists so start-up can continue.
*/
public void checkFirstRun() {
String storedVersionName = "";
String versionName;
AlertDialog UpdateDialog;
AlertDialog FirstRunDialog;
SharedPreferences prefs;
versionName = this.getVersionName(this, StartupActivity.class);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
storedVersionName = (prefs.getString("AppVersionName", null));
Log.v(TAG,"storedVersionName="+storedVersionName+", versionName="+versionName);
// CHeck for new installation
if (storedVersionName == null || storedVersionName.length() == 0) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
this);
final SpannableString s = new SpannableString(
"OpenSeizureDetector does not collect any personal data. "
+ "This does mean that it is not possible for me to contact users if I find an "
+ "issue with the app that you should be aware of. \nPlease subscribe to updates at "
+ "http://openseizuredetector.org.uk, or the app Facebook page at https://www.facebook.com/openseizuredetector. "
+ "so I can get in touch if necessary.\nThank you! Graham \ngraham@openseizuredetector.org.uk "
+ "\n\nChanges in this version:"
+ "\n- Update to Detection Algorithm: You will need to increase the AlarmRatioThresh setting from the previous "
+ "default of around 30 to a value of 50-60 to avoid excessive false alarms"
+ "\n- Added GPS Location to SMS Alarms"
+ "\n- Added auto-start on boot capability"
);
// This makes the links display as links, but they do not respond to clicks for some reason...
Linkify.addLinks(s, Linkify.ALL);
alertDialogBuilder
.setTitle("Welcome to OpenSeizureDetector")
.setMessage(s)
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
mDialogDisplayed = false;
//MainActivity.this.finish();
}
});
FirstRunDialog = alertDialogBuilder.create();
Log.v(TAG, "Displaying First Run Dialog");
FirstRunDialog.show();
mDialogDisplayed = true;
} else if (!storedVersionName.equals(versionName)) {
// Check for update of installed application
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
this);
final SpannableString s = new SpannableString(
"OpenSeizureDetector does not collect any personal data. "
+ "This does mean that it is not possible for me to contact users if I find an "
+ "issue with the app that you should be aware of. \nPlease subscribe to updates at "
+ "http://openseizuredetector.org.uk, or the app Facebook page at https://www.facebook.com/openseizuredetector. "
+ "so I can get in touch if necessary.\nThank you! Graham \ngraham@openseizuredetector.org.uk "
+ "\n\nChanges in this version:"
+ "\n- Update to Detection Algorithm: You will need to increase the AlarmRatioThresh setting from the previous "
+ "default of around 30 to a value of 50-60 to avoid excessive false alarms"
+ "\n- Added GPS Location to SMS Alarms"
+ "\n- Added auto-start on boot capability"
);
// This makes the links display as links, but they do not respond to clicks for some reason...
Linkify.addLinks(s, Linkify.ALL);
alertDialogBuilder
.setTitle("Thank you for Updating OpenSeizureDetector")
.setMessage(s)
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
mDialogDisplayed = false;
}
});
UpdateDialog = alertDialogBuilder.create();
Log.v(TAG, "Displaying Update Dialog");
UpdateDialog.show();
mDialogDisplayed = true;
} else {
Log.v(TAG, "App has already been run - not showing dialog.");
}
Log.v(TAG, "Setting AppVersionName to" + versionName);
prefs.edit().putString("AppVersionName", versionName).commit();
}
} }
+8
View File
@@ -35,6 +35,13 @@
android:title="Auto Start App on Boot" android:title="Auto Start App on Boot"
android:enabled="true" android:enabled="true"
/> />
<EditTextPreference
android:defaultValue=""
android:key="AppVersionName"
android:summary="App Version Number - used to decide whether to display the welcome message or not."
android:title="App Version Number" />
<!--
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:key="UseIpCamera" android:key="UseIpCamera"
@@ -42,6 +49,7 @@
android:title="Enable IP Camera" android:title="Enable IP Camera"
android:enabled="false" android:enabled="false"
/> />
-->
</PreferenceScreen> </PreferenceScreen>
+2 -2
View File
@@ -22,12 +22,12 @@
android:title="Network Datasource" android:title="Network Datasource"
android:summary="Network Datasource Preferences" /> android:summary="Network Datasource Preferences" />
<header android:fragment="uk.org.openseizuredetector.PrefActivity$CameraPrefsFragment" <!--<header android:fragment="uk.org.openseizuredetector.PrefActivity$CameraPrefsFragment"
android:icon="@drawable/icon_24x24" android:icon="@drawable/icon_24x24"
android:title="Camera Settings" android:title="Camera Settings"
android:summary="IP Camera Preferences" android:summary="IP Camera Preferences"
android:enabled="false" android:enabled="false"
/> />-->
</preference-headers> </preference-headers>