Tidied up new user interface (and fixed problem with re-loading only activity from Android Studio)

This commit is contained in:
Graham Jones
2024-01-19 20:49:41 +00:00
parent 65c8a2a12b
commit d8b3582291
8 changed files with 67 additions and 110 deletions

View File

@@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:versionCode="128" android:versionCode="128"
android:versionName="4.2.1l"> android:versionName="4.2.1m">
<!-- android:allowBackup="false" --> <!-- android:allowBackup="false" -->
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

View File

@@ -12,6 +12,7 @@ import android.widget.TextView;
public class FragmentCommon extends FragmentOsdBaseClass { public class FragmentCommon extends FragmentOsdBaseClass {
String TAG = "FragmentCommon"; String TAG = "FragmentCommon";
public FragmentCommon() { public FragmentCommon() {
// Required empty public constructor // Required empty public constructor
} }
@@ -81,37 +82,16 @@ public class FragmentCommon extends FragmentOsdBaseClass {
protected void updateUi() { protected void updateUi() {
//Log.d(TAG,"updateUi()"); //Log.d(TAG,"updateUi()");
TextView tv; TextView tv;
tv = (TextView)mRootView.findViewById(R.id.fragment_common_tv1);
if (mConnection.mBound) {
tv.setText("Bound to Server");
} else {
tv.setText("****NOT BOUND TO SERVER***");
return;
}
if (mUtil.isServerRunning()) { if (mUtil.isServerRunning()) {
//LinearLayout ll = (LinearLayout) findViewById(R.id.statusLayout);
//ll.setBackgroundColor(okColour);
//ll = (LinearLayout) findViewById(R.id.watchStatusLl);
//ll.setBackgroundColor(okColour);
tv = (TextView) mRootView.findViewById(R.id.serverStatusTv); tv = (TextView) mRootView.findViewById(R.id.serverStatusTv);
if (mConnection.mBound) { if (mConnection.mBound) {
if (mConnection.mSdServer.mSdDataSourceName.equals("Phone")) { if (mConnection.mSdServer.mLogNDA)
if (mConnection.mSdServer.mLogNDA) tv.setText(getString(R.string.ServerRunningOK) + " - NDA Logging");
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + "\n" + "(Demo Mode)" + "\nNDA Logging"); else
else tv.setText(getString(R.string.ServerRunningOK));
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + "\n" + "(Demo Mode)"); tv.setBackgroundColor(okColour);
tv.setBackgroundColor(warnColour); tv.setTextColor(okTextColour);
tv.setTextColor(warnTextColour);
} else {
if (mConnection.mSdServer.mLogNDA)
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName + "\nNDA Logging");
else
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName);
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
}
tv = (TextView) mRootView.findViewById(R.id.alarmTv); tv = (TextView) mRootView.findViewById(R.id.alarmTv);
if ((mConnection.mSdServer.mSdData.alarmState == 0) if ((mConnection.mSdServer.mSdData.alarmState == 0)
@@ -146,7 +126,7 @@ public class FragmentCommon extends FragmentOsdBaseClass {
tv = (TextView) mRootView.findViewById(R.id.algsTv); tv = (TextView) mRootView.findViewById(R.id.algsTv);
tv.setText("Algorithms"); tv.setText(R.string.algorithms);
tv.setBackgroundColor(okColour); tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour); tv.setTextColor(okTextColour);
tv = (TextView) mRootView.findViewById(R.id.osdAlgTv); tv = (TextView) mRootView.findViewById(R.id.osdAlgTv);
@@ -168,7 +148,7 @@ public class FragmentCommon extends FragmentOsdBaseClass {
tv.setPaintFlags(tv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG); tv.setPaintFlags(tv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
} else { } else {
tv.setBackgroundColor(okColour); tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour); tv.setTextColor(Color.GRAY);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
} }
tv = (TextView) mRootView.findViewById(R.id.hrAlgTv); tv = (TextView) mRootView.findViewById(R.id.hrAlgTv);
@@ -179,7 +159,7 @@ public class FragmentCommon extends FragmentOsdBaseClass {
tv.setPaintFlags(tv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG); tv.setPaintFlags(tv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
} else { } else {
tv.setBackgroundColor(okColour); tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour); tv.setTextColor(Color.GRAY);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
} }
tv = (TextView) mRootView.findViewById(R.id.o2AlgTv); tv = (TextView) mRootView.findViewById(R.id.o2AlgTv);
@@ -190,7 +170,7 @@ public class FragmentCommon extends FragmentOsdBaseClass {
tv.setPaintFlags(tv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG); tv.setPaintFlags(tv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
} else { } else {
tv.setBackgroundColor(okColour); tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour); tv.setTextColor(Color.GRAY);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
} }
} }
@@ -199,10 +179,25 @@ public class FragmentCommon extends FragmentOsdBaseClass {
tv.setText(R.string.ServerStopped); tv.setText(R.string.ServerStopped);
tv.setBackgroundColor(warnColour); tv.setBackgroundColor(warnColour);
tv.setTextColor(warnTextColour); tv.setTextColor(warnTextColour);
tv = (TextView) mRootView.findViewById(R.id.serverIpTv);
tv.setText("--"); /** FIXME - check this is not needed for this fragment
tv = (TextView) mRootView.findViewById(R.id.serverIpTv);
tv.setText("--");
tv.setBackgroundColor(warnColour);
tv.setTextColor(warnTextColour);
*/
}
tv = (TextView) mRootView.findViewById(R.id.dataSourceInfoTv);
if (mConnection.mSdServer.mSdDataSourceName.equals("Phone")) {
tv.setText(getString(R.string.DataSource) + " = " + "Phone (Demo Mode)");
tv.setBackgroundColor(warnColour); tv.setBackgroundColor(warnColour);
tv.setTextColor(warnTextColour); tv.setTextColor(warnTextColour);
} else {
tv.setText(getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName);
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
} }
// deal with latch alarms button // deal with latch alarms button
@@ -254,6 +249,5 @@ public class FragmentCommon extends FragmentOsdBaseClass {
} }
} }
} }

View File

@@ -44,13 +44,6 @@ public class FragmentOsdAlg extends FragmentOsdBaseClass {
protected void updateUi() { protected void updateUi() {
//Log.d(TAG,"updateUi()"); //Log.d(TAG,"updateUi()");
TextView tv; TextView tv;
tv = (TextView)mRootView.findViewById(R.id.fragment_osdalg_tv1);
if (mConnection.mBound) {
tv.setText("Bound to Server");
} else {
tv.setText("****NOT BOUND TO SERVER***");
return;
}
///////////////////////////////////////////////////// /////////////////////////////////////////////////////

View File

@@ -61,12 +61,10 @@ public class MainActivity2 extends AppCompatActivity {
//int i = 5/0; // Force exception to test handler. //int i = 5/0; // Force exception to test handler.
mUtil = new OsdUtil(getApplicationContext(), serverStatusHandler); mUtil = new OsdUtil(getApplicationContext(), serverStatusHandler);
mConnection = new SdServiceConnection(getApplicationContext()); mConnection = new SdServiceConnection(getApplicationContext());
mUtil.writeToSysLogFile(""); mUtil.writeToSysLogFile("MainActivity2.onCreate()");
mUtil.writeToSysLogFile("* MainActivity Started *");
mUtil.writeToSysLogFile("MainActivity.onCreate()");
mContext = this; mContext = this;
/**
if (savedInstanceState == null) { if (savedInstanceState == null) {
// Instantiate a ViewPager2 and a PagerAdapter. // Instantiate a ViewPager2 and a PagerAdapter.
mFragmentPager = findViewById(R.id.fragment_pager); mFragmentPager = findViewById(R.id.fragment_pager);
@@ -77,6 +75,7 @@ public class MainActivity2 extends AppCompatActivity {
.add(R.id.fragment_common_container_view, FragmentCommon.class, null) .add(R.id.fragment_common_container_view, FragmentCommon.class, null)
.commit(); .commit();
} }
*/
} }
/** /**
@@ -98,7 +97,7 @@ public class MainActivity2 extends AppCompatActivity {
SharedPreferences SP = PreferenceManager SharedPreferences SP = PreferenceManager
.getDefaultSharedPreferences(getBaseContext()); .getDefaultSharedPreferences(getBaseContext());
boolean audibleAlarm = SP.getBoolean("AudibleAlarm", true); boolean audibleAlarm = SP.getBoolean("AudibleAlarm", true);
Log.v(TAG, "onStart - auidbleAlarm = " + audibleAlarm); Log.v(TAG, "onStart - audibleAlarm = " + audibleAlarm);
TextView tv; TextView tv;
tv = (TextView) findViewById(R.id.versionTv); tv = (TextView) findViewById(R.id.versionTv);
@@ -108,11 +107,12 @@ public class MainActivity2 extends AppCompatActivity {
tv.setTextColor(okTextColour); tv.setTextColor(okTextColour);
if (mUtil.isServerRunning()) { if (mUtil.isServerRunning()) {
mUtil.writeToSysLogFile("MainActivity.onStart - Binding to Server"); Log.i(TAG, "MainActivity2.onStart() - Binding to Server");
mUtil.writeToSysLogFile("MainActivity2.onStart - Binding to Server");
mUtil.bindToServer(getApplicationContext(), mConnection); mUtil.bindToServer(getApplicationContext(), mConnection);
} else { } else {
Log.i(TAG, "onStart() - Server Not Running"); Log.i(TAG, "MainActivity2.onStart() - Server Not Running");
mUtil.writeToSysLogFile("MainActivity.onStart - Server Not Running"); mUtil.writeToSysLogFile("MainActivity2.onStart - Server Not Running");
} }
@@ -139,6 +139,15 @@ public class MainActivity2 extends AppCompatActivity {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
Log.i(TAG, "onResume()"); Log.i(TAG, "onResume()");
// Instantiate a ViewPager2 and a PagerAdapter.
mFragmentPager = findViewById(R.id.fragment_pager);
mFragmentStateAdapter = new ScreenSlideFragmentPagerAdapter(this);
mFragmentPager.setAdapter(mFragmentStateAdapter);
getSupportFragmentManager().beginTransaction()
.setReorderingAllowed(true)
.add(R.id.fragment_common_container_view, FragmentCommon.class, null)
.commit();
} }
@@ -182,7 +191,7 @@ public class MainActivity2 extends AppCompatActivity {
Log.i(TAG, "Stopping Server"); Log.i(TAG, "Stopping Server");
mUtil.unbindFromServer(getApplicationContext(), mConnection); mUtil.unbindFromServer(getApplicationContext(), mConnection);
stopServer(); stopServer();
finish(); //finish();
} else { } else {
Log.i(TAG, "Starting Server"); Log.i(TAG, "Starting Server");
startServer(); startServer();

View File

@@ -2,33 +2,28 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
tools:context=".FragmentOsdBaseClass"> tools:context=".FragmentOsdBaseClass">
<!-- TODO: Update blank fragment layout -->
<androidx.appcompat.widget.LinearLayoutCompat <androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="253dp" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:background="@color/okBackgroundColor" android:background="@color/okBackgroundColor"
> >
<TextView <TextView
android:id="@+id/serverStatusTv"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="OpenSeizureDetector Common Components Status" android:text="---" />
android:textColor="@color/okTextColor"
/>
<TextView <TextView
android:id="@+id/versionTv" android:id="@+id/dataSourceInfoTv"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/app_name" android:text="---" />
android:textColor="@color/okTextColor"
/>
<LinearLayout <LinearLayout
android:id="@+id/statusLayout" android:id="@+id/statusLayout"
@@ -36,39 +31,14 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/serverStatusTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="---" />
<TextView
android:id="@+id/alarmTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="---"
android:textSize="32sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<TextView <TextView
android:id="@+id/algsTv" android:id="@+id/algsTv"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Algorithms" /> android:text="Algorithms: " />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -86,12 +56,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="---" /> android:text="---" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView <TextView
android:id="@+id/hrAlgTv" android:id="@+id/hrAlgTv"
@@ -112,10 +76,19 @@
android:text="" android:text=""
android:visibility="gone"/> android:visibility="gone"/>
--> -->
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/alarmTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="---"
android:textSize="32sp" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -144,11 +117,6 @@
android:text="@string/ManualAlarmBtnTxt" /> android:text="@string/ManualAlarmBtnTxt" />
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/fragment_common_tv1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Fragment_System" />
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>

View File

@@ -7,7 +7,7 @@
<androidx.appcompat.widget.LinearLayoutCompat <androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="253dp" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:background="@color/okBackgroundColor"> android:background="@color/okBackgroundColor">
@@ -52,14 +52,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<!--This is not displayed because of match_parent height above -->
<TextView
android:id="@+id/fragment_osdalg_tv1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/okTextColor"
android:text="Fragment_OsdAlg" />
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>
</FrameLayout> </FrameLayout>

View File

@@ -9,7 +9,7 @@
<!-- TODO: Update blank fragment layout --> <!-- TODO: Update blank fragment layout -->
<androidx.appcompat.widget.LinearLayoutCompat <androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="253dp" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:id="@+id/fragment_ll"> android:id="@+id/fragment_ll">

View File

@@ -565,4 +565,5 @@
<string name="heart_rate_algorithm">Heart Rate Algorithm</string> <string name="heart_rate_algorithm">Heart Rate Algorithm</string>
<string name="heart_rate_history_bpm">"Heart Rate History (bpm): "</string> <string name="heart_rate_history_bpm">"Heart Rate History (bpm): "</string>
<string name="minutes">minutes</string> <string name="minutes">minutes</string>
<string name="algorithms">"Algorithms: "</string>
</resources> </resources>