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"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="128"
android:versionName="4.2.1l">
android:versionName="4.2.1m">
<!-- android:allowBackup="false" -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

View File

@@ -12,6 +12,7 @@ import android.widget.TextView;
public class FragmentCommon extends FragmentOsdBaseClass {
String TAG = "FragmentCommon";
public FragmentCommon() {
// Required empty public constructor
}
@@ -81,37 +82,16 @@ public class FragmentCommon extends FragmentOsdBaseClass {
protected void updateUi() {
//Log.d(TAG,"updateUi()");
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()) {
//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);
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) + " - NDA Logging");
else
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + "\n" + "(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");
else
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName);
tv.setText(getString(R.string.ServerRunningOK));
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
}
tv = (TextView) mRootView.findViewById(R.id.alarmTv);
if ((mConnection.mSdServer.mSdData.alarmState == 0)
@@ -146,7 +126,7 @@ public class FragmentCommon extends FragmentOsdBaseClass {
tv = (TextView) mRootView.findViewById(R.id.algsTv);
tv.setText("Algorithms");
tv.setText(R.string.algorithms);
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
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);
} else {
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
tv.setTextColor(Color.GRAY);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
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);
} else {
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
tv.setTextColor(Color.GRAY);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
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);
} else {
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
tv.setTextColor(Color.GRAY);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
}
@@ -199,10 +179,25 @@ public class FragmentCommon extends FragmentOsdBaseClass {
tv.setText(R.string.ServerStopped);
tv.setBackgroundColor(warnColour);
tv.setTextColor(warnTextColour);
/** 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.setTextColor(warnTextColour);
} else {
tv.setText(getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName);
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
}
// 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() {
//Log.d(TAG,"updateUi()");
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.
mUtil = new OsdUtil(getApplicationContext(), serverStatusHandler);
mConnection = new SdServiceConnection(getApplicationContext());
mUtil.writeToSysLogFile("");
mUtil.writeToSysLogFile("* MainActivity Started *");
mUtil.writeToSysLogFile("MainActivity.onCreate()");
mUtil.writeToSysLogFile("MainActivity2.onCreate()");
mContext = this;
/**
if (savedInstanceState == null) {
// Instantiate a ViewPager2 and a PagerAdapter.
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)
.commit();
}
*/
}
/**
@@ -98,7 +97,7 @@ public class MainActivity2 extends AppCompatActivity {
SharedPreferences SP = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
boolean audibleAlarm = SP.getBoolean("AudibleAlarm", true);
Log.v(TAG, "onStart - auidbleAlarm = " + audibleAlarm);
Log.v(TAG, "onStart - audibleAlarm = " + audibleAlarm);
TextView tv;
tv = (TextView) findViewById(R.id.versionTv);
@@ -108,11 +107,12 @@ public class MainActivity2 extends AppCompatActivity {
tv.setTextColor(okTextColour);
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);
} else {
Log.i(TAG, "onStart() - Server Not Running");
mUtil.writeToSysLogFile("MainActivity.onStart - Server Not Running");
Log.i(TAG, "MainActivity2.onStart() - Server Not Running");
mUtil.writeToSysLogFile("MainActivity2.onStart - Server Not Running");
}
@@ -139,6 +139,15 @@ public class MainActivity2 extends AppCompatActivity {
protected void onResume() {
super.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");
mUtil.unbindFromServer(getApplicationContext(), mConnection);
stopServer();
finish();
//finish();
} else {
Log.i(TAG, "Starting Server");
startServer();

View File

@@ -2,45 +2,17 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
tools:context=".FragmentOsdBaseClass">
<!-- TODO: Update blank fragment layout -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="253dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/okBackgroundColor"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="OpenSeizureDetector Common Components Status"
android:textColor="@color/okTextColor"
/>
<TextView
android:id="@+id/versionTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="@color/okTextColor"
/>
<LinearLayout
android:id="@+id/statusLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
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"
@@ -48,27 +20,25 @@
android:text="---" />
<TextView
android:id="@+id/alarmTv"
android:id="@+id/dataSourceInfoTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="---"
android:textSize="32sp" />
</LinearLayout>
android:text="---" />
<LinearLayout
android:layout_width="wrap_content"
android:id="@+id/statusLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
android:orientation="horizontal">
<TextView
android:id="@+id/algsTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Algorithms" />
android:text="Algorithms: " />
<LinearLayout
android:layout_width="wrap_content"
@@ -86,12 +56,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="---" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/hrAlgTv"
@@ -112,9 +76,18 @@
android:text=""
android:visibility="gone"/>
-->
</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
android:layout_width="match_parent"
@@ -144,11 +117,6 @@
android:text="@string/ManualAlarmBtnTxt" />
</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>

View File

@@ -7,7 +7,7 @@
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="253dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/okBackgroundColor">
@@ -52,14 +52,6 @@
android:layout_width="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>
</FrameLayout>

View File

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

View File

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