From 4ae42ab338638296cb643a43f71de1e6ed5fe7f6 Mon Sep 17 00:00:00 2001 From: Graham Jones Date: Wed, 4 Oct 2023 22:38:31 +0100 Subject: [PATCH] Added option to use the new or the old user interface --- app/src/main/AndroidManifest.xml | 2 +- .../uk/org/openseizuredetector/SdServer.java | 24 ++++++++++++++++--- .../openseizuredetector/StartupActivity.java | 15 +++++++++--- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/general_prefs.xml | 5 ++++ 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fa81d97..59172fa 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ + android:versionName="4.2.1f"> diff --git a/app/src/main/java/uk/org/openseizuredetector/SdServer.java b/app/src/main/java/uk/org/openseizuredetector/SdServer.java index 09902f2..2d7b46f 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdServer.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdServer.java @@ -157,6 +157,7 @@ public class SdServer extends Service implements SdDataReceiver { private final IBinder mBinder = new SdBinder(); public LogManager mLm; + private boolean mUseNewUi; /** * class to handle binding the MainApp activity to this service @@ -517,7 +518,12 @@ public class SdServer extends Service implements SdDataReceiver { soundUri = null; } - Intent i = new Intent(getApplicationContext(), MainActivity2.class); + Intent i; + if (mUseNewUi) { + i = new Intent(getApplicationContext(), MainActivity2.class); + } else { + i = new Intent(getApplicationContext(), MainActivity.class); + } i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); PendingIntent contentIntent = PendingIntent.getActivity(this, @@ -569,7 +575,12 @@ public class SdServer extends Service implements SdDataReceiver { mUtil.writeToSysLogFile("SdServer.showMainActivity - Activity is already shown on top, not doing anything"); } else { Log.i(TAG, "showMainActivity(): Showing Main Activity"); - Intent i = new Intent(getApplicationContext(), MainActivity2.class); + Intent i; + if (mUseNewUi) { + i = new Intent(getApplicationContext(), MainActivity2.class); + } else { + i = new Intent(getApplicationContext(), MainActivity.class); + } i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); this.startActivity(i); } @@ -1285,6 +1296,8 @@ public class SdServer extends Service implements SdDataReceiver { mOSDUrl = SP.getString("OSDUrl", "http://openseizuredetector.org.uk/webApi"); Log.v(TAG, "updatePrefs() - mOSDUrl = " + mOSDUrl); mUtil.writeToSysLogFile("updatePrefs() - mOSDUrl = " + mOSDUrl); + + mUseNewUi = SP.getBoolean("UseNewUi", false); } catch (Exception ex) { Log.v(TAG, "updatePrefs() - Problem parsing preferences!"); mUtil.writeToSysLogFile("SdServer.updatePrefs() - Error " + ex.toString()); @@ -1733,7 +1746,12 @@ public class SdServer extends Service implements SdDataReceiver { iconId = R.drawable.datasharing_fault_24x24; titleStr = getString(R.string.datasharing_notification_title); - Intent i = new Intent(getApplicationContext(), MainActivity2.class); + Intent i; + if (mUseNewUi) { + i = new Intent(getApplicationContext(), MainActivity2.class); + } else { + i = new Intent(getApplicationContext(), MainActivity.class); + } i.putExtra("action", "showDataSharingDialog"); i.setAction("showDataSharingDialog"); i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); diff --git a/app/src/main/java/uk/org/openseizuredetector/StartupActivity.java b/app/src/main/java/uk/org/openseizuredetector/StartupActivity.java index 18f6fb5..9467b7c 100644 --- a/app/src/main/java/uk/org/openseizuredetector/StartupActivity.java +++ b/app/src/main/java/uk/org/openseizuredetector/StartupActivity.java @@ -181,6 +181,7 @@ public class StartupActivity extends AppCompatActivity { }); mConnection = new SdServiceConnection(getApplicationContext()); + } @Override @@ -428,9 +429,17 @@ public class StartupActivity extends AppCompatActivity { Log.i(TAG, "serverStatusRunnable() - starting main activity..."); mUtil.writeToSysLogFile("StartupActivity.serverStatusRunnable - all checks ok - starting main activity."); try { - Intent intent = new Intent( - getApplicationContext(), - MainActivity2.class); + Boolean useNewUi = SP.getBoolean("UseNewUi", false); + Intent intent; + if (useNewUi) { + intent = new Intent( + getApplicationContext(), + MainActivity2.class); + } else { + intent = new Intent( + getApplicationContext(), + MainActivity.class); + } intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent); mStartedMainActivity = true; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1b782d7..3797d8f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -560,4 +560,6 @@ Tab 2 Hello blank fragment + Use new swipeable user interface + Use New User Interface diff --git a/app/src/main/res/xml/general_prefs.xml b/app/src/main/res/xml/general_prefs.xml index d8ae61a..7e12f63 100644 --- a/app/src/main/res/xml/general_prefs.xml +++ b/app/src/main/res/xml/general_prefs.xml @@ -8,6 +8,11 @@ android:entryValues="@array/datasource_list_values" android:defaultValue="Phone" android:dialogTitle="@string/select_datasource_title" /> +