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

View File

@@ -1,6 +1,9 @@
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
- Changed auto-start feature to start the SDServer background service rather than the StartUpActvity so it will work
when the phone screen is locked.

BIN
app/app-release-2.3.2.apk Normal file

Binary file not shown.

View File

@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.org.openseizuredetector"
android:versionCode="32"
android:versionName="2.3.1">
<uses-sdk android:minSdkVersion="14" />
android:versionCode="33"
android:versionName="2.3.2">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

View File

@@ -72,8 +72,8 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
String dataSourceStr = SP.getString("DataSource", "Pebble");
Log.v(TAG, "onBuildHeaders DataSource = " + dataSourceStr);
Boolean cameraEnabled = SP.getBoolean("UseIpCamera", false);
Log.v(TAG, "onBuildHeaders cameraEnabled = " + cameraEnabled);
//Boolean cameraEnabled = SP.getBoolean("UseIpCamera", false);
//Log.v(TAG, "onBuildHeaders cameraEnabled = " + cameraEnabled);
for (int i = 0; i < target.size(); i++) {
Header h = target.get(i);
@@ -94,14 +94,14 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
i = i -1;
}
}
if (h.title.toString().equals("Camera Settings")) {
Log.v(TAG, "found Camera Settings Header");
if (!cameraEnabled) {
Log.v(TAG, "Removing camera settings header");
target.remove(i);
i = i-1;
}
}
//if (h.title.toString().equals("Camera Settings")) {
// Log.v(TAG, "found Camera Settings Header");
// if (!cameraEnabled) {
// Log.v(TAG, "Removing camera settings header");
// target.remove(i);
// i = i-1;
// }
//}
}
}
@@ -202,14 +202,14 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
}
}
public static class CameraPrefsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//public static class CameraPrefsFragment extends PreferenceFragment {
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.camera_prefs);
}
}
// addPreferencesFromResource(R.xml.camera_prefs);
// }
//}
}

View File

@@ -25,8 +25,13 @@
package uk.org.openseizuredetector;
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.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
@@ -34,6 +39,9 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
@@ -50,7 +58,7 @@ import java.util.TimerTask;
* starting the main activity.
*/
public class StartupActivity extends Activity {
private String TAG = "StartupActivity";
private static String TAG = "StartupActivity";
private int okColour = Color.BLUE;
private int warnColour = Color.MAGENTA;
private int alarmColour = Color.RED;
@@ -63,6 +71,7 @@ public class StartupActivity extends Activity {
private Timer mUiTimer;
private SdServiceConnection mConnection;
private boolean mStartedMainActivity = false;
private boolean mDialogDisplayed = false;
private Handler mHandler = new Handler(); // used to update ui from mUiTimer
private boolean mUsingPebbleDataSource = true;
private String mPebbleAppPackageName = null;
@@ -75,7 +84,7 @@ public class StartupActivity extends Activity {
Thread.setDefaultUncaughtExceptionHandler(new OsdUncaughtExceptionHandler(StartupActivity.this));
mHandler = new Handler();
mUtil = new OsdUtil(this,mHandler);
mUtil = new OsdUtil(this, mHandler);
mUtil.writeToSysLogFile("");
mUtil.writeToSysLogFile("*******************************");
mUtil.writeToSysLogFile("* StartUpActivity Started *");
@@ -96,7 +105,7 @@ public class StartupActivity extends Activity {
Button b;
b = (Button)findViewById(R.id.installPebbleAppButton);
b = (Button) findViewById(R.id.installPebbleAppButton);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -104,7 +113,7 @@ public class StartupActivity extends Activity {
try {
mUtil.writeToSysLogFile("Installing Pebble App");
Intent intent = new Intent(Intent.ACTION_VIEW)
.setData(Uri.parse("market://details?id="+mUtil.getPreferredPebbleAppPackageName()));
.setData(Uri.parse("market://details?id=" + mUtil.getPreferredPebbleAppPackageName()));
startActivity(intent);
} catch (Exception ex) {
Log.v(TAG, "exception starting play store activity " + ex.toString());
@@ -115,7 +124,7 @@ public class StartupActivity extends Activity {
}
});
b = (Button)findViewById(R.id.settingsButton);
b = (Button) findViewById(R.id.settingsButton);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -134,7 +143,7 @@ public class StartupActivity extends Activity {
}
});
b = (Button)findViewById(R.id.pebbleButton);
b = (Button) findViewById(R.id.pebbleButton);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -144,7 +153,7 @@ public class StartupActivity extends Activity {
}
});
b = (Button)findViewById(R.id.installOsdAppButton);
b = (Button) findViewById(R.id.installOsdAppButton);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -163,15 +172,16 @@ public class StartupActivity extends Activity {
TextView tv;
String versionName = mUtil.getAppVersionName();
tv = (TextView)findViewById(R.id.appNameTv);
tv.setText("OpenSeizureDetector V"+versionName);
tv = (TextView) findViewById(R.id.appNameTv);
tv.setText("OpenSeizureDetector V" + versionName);
// Display the DataSource name
SharedPreferences SP = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());;
String dataSourceName = SP.getString("DataSource","Pebble");
tv = (TextView)findViewById(R.id.dataSourceTextView);
tv.setText("DataSource = "+dataSourceName);
.getDefaultSharedPreferences(getBaseContext());
;
String dataSourceName = SP.getString("DataSource", "Pebble");
tv = (TextView) findViewById(R.id.dataSourceTextView);
tv.setText("DataSource = " + dataSourceName);
// disable pebble configuration buttons if we have not selected the pebble datasource
if (!dataSourceName.equals("Pebble")) {
@@ -198,6 +208,9 @@ public class StartupActivity extends Activity {
mConnection = new SdServiceConnection(this);
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.
mUiTimer = new Timer();
mUiTimer.schedule(new TimerTask() {
@@ -208,6 +221,7 @@ public class StartupActivity extends Activity {
}
}, 0, 1000);
}
@Override
@@ -343,7 +357,7 @@ public class StartupActivity extends Activity {
pb = (ProgressBar) findViewById(R.id.progressBar7);
boolean pebbleAndroidAppInstalled;
mPebbleAppPackageName = mUtil.isPebbleAppInstalled();
if (mPebbleAppPackageName!=null)
if (mPebbleAppPackageName != null)
pebbleAndroidAppInstalled = true;
else
pebbleAndroidAppInstalled = false;
@@ -371,10 +385,10 @@ public class StartupActivity extends Activity {
}
// If all the parameters are ok, close this activity and open the main
// user interface activity instead.
if (allOk) {
if (!mDialogDisplayed) {
if (!mStartedMainActivity) {
Log.v(TAG, "starting main activity...");
mUtil.writeToSysLogFile("StartupActivity.serverStatusRunnable - all checks ok - starting main activity.");
@@ -389,13 +403,123 @@ public class StartupActivity extends Activity {
} catch (Exception ex) {
mStartedMainActivity = false;
Log.v(TAG, "exception starting main activity " + ex.toString());
mUtil.writeToSysLogFile("StartupActivity.serverStatusRunnable - exception starting main activity "+ex.toString());
mUtil.writeToSysLogFile("StartupActivity.serverStatusRunnable - exception starting main activity " + ex.toString());
}
} else {
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");
}
} 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();
}
}

View File

@@ -35,6 +35,13 @@
android:title="Auto Start App on Boot"
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
android:defaultValue="false"
android:key="UseIpCamera"
@@ -42,6 +49,7 @@
android:title="Enable IP Camera"
android:enabled="false"
/>
-->
</PreferenceScreen>

View File

@@ -22,12 +22,12 @@
android:title="Network Datasource"
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:title="Camera Settings"
android:summary="IP Camera Preferences"
android:enabled="false"
/>
/>-->
</preference-headers>