Merge pull request #167 from OpenSeizureDetector/166-v424-notifications-not-displaying-on-android-13-go-edition-moto-e13
166 v424 notifications not displaying on android 13 go edition moto e13
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
OpenSeizureDetector Android App - Change Log
|
||||
============================================
|
||||
|
||||
V4.2.6 - Fixed problem with notifications in Android 13
|
||||
- Improved start-up checks for permissions
|
||||
- Improved system re-start after changing settings (but still not perfect!)
|
||||
V4.2.5 - Set BLE device time if the characteristic is available.
|
||||
V4.2.4 - Added checks and a FAULT condition for Bluetooth errors in Bluetooth Data Source
|
||||
V4.2.3 - Uses 3d accelerometer data to calculate magnitude if vector magnitude is not sent from data source.
|
||||
|
||||
@@ -7,7 +7,7 @@ android {
|
||||
defaultConfig {
|
||||
applicationId "uk.org.openseizuredetector"
|
||||
minSdkVersion 23 // Android 6
|
||||
targetSdkVersion 33 // Android 13
|
||||
targetSdkVersion 33 // Android 13 = 33
|
||||
multiDexEnabled true
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -2,8 +2,9 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:versionCode="139"
|
||||
android:versionName="4.2.5">
|
||||
android:versionName="4.2.6b">
|
||||
<!-- android:allowBackup="false" -->
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
||||
|
||||
@@ -275,6 +275,10 @@ public class BLEScanActivity extends ListActivity {
|
||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences((this));
|
||||
Log.v(TAG, "Check of saved values - Name=" + SP.getString("BLE_Device_Name", "NOT SET") + ", Addr=" + SP.getString("BLE_Device_Addr", "NOT SET"));
|
||||
|
||||
Log.i(TAG, "Restarting start-up activity so change takes effect");
|
||||
Intent i;
|
||||
i = new Intent(this, StartupActivity.class);
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package uk.org.openseizuredetector;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
@@ -80,11 +81,12 @@ public class FragmentOsdAlg extends FragmentOsdBaseClass {
|
||||
pb = ((ProgressBar) mRootView.findViewById(R.id.powerProgressBar));
|
||||
pb.setMax(100);
|
||||
pb.setProgress((int) powerPc);
|
||||
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_blue);
|
||||
pbDrawable = mContext.getDrawable(R.drawable.progress_bar_blue);
|
||||
//pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_blue);
|
||||
if (powerPc > 75)
|
||||
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_yellow);
|
||||
pbDrawable = mContext.getDrawable(R.drawable.progress_bar_yellow);
|
||||
if (powerPc > 100)
|
||||
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_red);
|
||||
pbDrawable = mContext.getDrawable(R.drawable.progress_bar_red);
|
||||
pb.setProgressDrawable(pbDrawable);
|
||||
|
||||
((TextView) mRootView.findViewById(R.id.spectrumTv)).setText(getString(R.string.SpectrumRatioEquals) + specRatio +
|
||||
@@ -93,11 +95,12 @@ public class FragmentOsdAlg extends FragmentOsdBaseClass {
|
||||
pb = ((ProgressBar) mRootView.findViewById(R.id.spectrumProgressBar));
|
||||
pb.setMax(100);
|
||||
pb.setProgress((int) specPc);
|
||||
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_blue);
|
||||
//pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_blue);
|
||||
pbDrawable = mContext.getDrawable(R.drawable.progress_bar_blue);
|
||||
if (specPc > 75)
|
||||
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_yellow);
|
||||
pbDrawable = mContext.getDrawable(R.drawable.progress_bar_yellow);
|
||||
if (specPc > 100)
|
||||
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_red);
|
||||
pbDrawable = mContext.getDrawable(R.drawable.progress_bar_red);
|
||||
pb.setProgressDrawable(pbDrawable);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -86,6 +86,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
private Intent sdServerIntent;
|
||||
|
||||
final Handler serverStatusHandler = new Handler();
|
||||
final Handler mHandler = new Handler();
|
||||
Messenger messenger = new Messenger(new ResponseHandler());
|
||||
Timer mUiTimer;
|
||||
private Context mContext;
|
||||
@@ -275,22 +276,27 @@ public class MainActivity extends AppCompatActivity {
|
||||
mConnection.mSdServer.acceptAlarm();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_start_stop:
|
||||
case R.id.action_exit:
|
||||
// Respond to the start/stop server menu item.
|
||||
Log.i(TAG, "action_sart_stop");
|
||||
if (mConnection.mBound) {
|
||||
Log.i(TAG, "Stopping Server");
|
||||
Log.i(TAG, "action_exit: Stopping Server");
|
||||
mUtil.unbindFromServer(getApplicationContext(), mConnection);
|
||||
stopServer();
|
||||
// we exit the activity when the server is stopped to make it consistent with MainActivity2
|
||||
// We exit this activity as a crude way of forcing the fragments to disconnect from the server
|
||||
// so that the server exits properly - otherwise we end up with multiple threads running.
|
||||
// FIXME - tell the threads to unbind from the serer before calling stopServer as an alternative.
|
||||
finish();
|
||||
} else {
|
||||
Log.i(TAG, "Starting Server");
|
||||
startServer();
|
||||
// and bind to it so we can see its data
|
||||
Log.i(TAG, "Binding to Server");
|
||||
mUtil.bindToServer(getApplicationContext(), mConnection);
|
||||
return true;
|
||||
case R.id.action_start_stop:
|
||||
Log.i(TAG, "action_start_stop: restarting server");
|
||||
mUtil.showToast("Stopping Background Service....");
|
||||
mUtil.stopServer();
|
||||
// Wait 1 second to give the server chance to shutdown, then re-start it
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
mUtil.showToast("Re-Starting Background Service...");
|
||||
mUtil.startServer();
|
||||
}
|
||||
}, 1000);
|
||||
return true;
|
||||
/* fault beep test does not work with fault timer, so disable test option.
|
||||
case R.id.action_test_fault_beep:
|
||||
|
||||
@@ -46,6 +46,7 @@ public class MainActivity2 extends AppCompatActivity {
|
||||
private OsdUtil mUtil;
|
||||
private SdServiceConnection mConnection;
|
||||
final Handler serverStatusHandler = new Handler();
|
||||
private Handler mHandler = new Handler();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -65,8 +66,7 @@ public class MainActivity2 extends AppCompatActivity {
|
||||
mConnection = new SdServiceConnection(getApplicationContext());
|
||||
mUtil.writeToSysLogFile("MainActivity2.onCreate()");
|
||||
mContext = this;
|
||||
|
||||
|
||||
mHandler = new Handler();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,24 +194,27 @@ public class MainActivity2 extends AppCompatActivity {
|
||||
mConnection.mSdServer.acceptAlarm();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_start_stop:
|
||||
case R.id.action_exit:
|
||||
// Respond to the start/stop server menu item.
|
||||
Log.i(TAG, "action_start_stop");
|
||||
if (mConnection.mBound) {
|
||||
Log.i(TAG, "Stopping Server");
|
||||
Log.i(TAG, "action_exit: Stopping Server");
|
||||
mUtil.unbindFromServer(getApplicationContext(), mConnection);
|
||||
stopServer();
|
||||
// We exit this activity as a crude way of forcing the fragments to disconnect from the server
|
||||
// so that the server exits properly - otherwise we end up with multiple threads running.
|
||||
// FIXME - tell the threads to unbind from the serer before calling stopServer as an alternative.
|
||||
finish();
|
||||
} else {
|
||||
Log.i(TAG, "Starting Server");
|
||||
startServer();
|
||||
// and bind to it so we can see its data
|
||||
Log.i(TAG, "Binding to Server");
|
||||
mUtil.bindToServer(getApplicationContext(), mConnection);
|
||||
return true;
|
||||
case R.id.action_start_stop:
|
||||
Log.i(TAG, "action_start_stop: restarting server");
|
||||
mUtil.showToast("Stopping Background Service....");
|
||||
mUtil.stopServer();
|
||||
// Wait 1 second to give the server chance to shutdown, then re-start it
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
mUtil.showToast("Re-Starting Background Service...");
|
||||
mUtil.startServer();
|
||||
}
|
||||
}, 1000);
|
||||
return true;
|
||||
case R.id.action_test_alarm_beep:
|
||||
Log.i(TAG, "action_test_alarm_beep");
|
||||
|
||||
@@ -148,6 +148,7 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
|
||||
// StartUpActivity, so we exit this activity and start start-up activity.
|
||||
if (s.equals("SMSAlarm")) {
|
||||
if (sharedPreferences.getBoolean("SMSAlarm", false) == true) {
|
||||
mUtil.showToast("Restarting OpenSeizureDetector");
|
||||
Log.i(TAG, "onSharedPreferenceChanged(): SMS Alarm Enabled - Restarting start-up activity to check permissions");
|
||||
Intent i;
|
||||
i = new Intent(this, StartupActivity.class);
|
||||
@@ -159,23 +160,44 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
|
||||
Log.i(TAG, "OnSharedPreferenceChanged(): SMS Alarm disabled so do not need permissions");
|
||||
}
|
||||
}
|
||||
// For all other preference changes we just restart SdServer so it is not as alarming for the user!
|
||||
//mUtil.showToast("Setting " + s + " Changed - restarting server");
|
||||
mPrefChanged = true;
|
||||
// If we have changed the data source, re-start the whole system
|
||||
if (s.equals("DataSource")) {
|
||||
Log.i(TAG, "onSharedPreferenceChanged(): Data Source Changed - Restarting start-up activity to check permissions");
|
||||
mUtil.showToast("Restarting OpenSeizureDetector");
|
||||
mUtil.stopServer();
|
||||
// Wait 0.1 second to give the server chance to shutdown, then re-start it
|
||||
// Wait 1 second to give the server chance to shutdown, then re-start it
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
Intent i;
|
||||
Log.i(TAG, "onSharedPreferenceChanged(): Data Source Changed - Restarting start-up activity to check permissions");
|
||||
i = new Intent(getApplicationContext(), StartupActivity.class);
|
||||
startActivity(i);
|
||||
Log.i(TAG, "onSharedPreferenceChanged() - finishing PrefActivity");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
}, 1000);
|
||||
return;
|
||||
} else {
|
||||
// For all other preference changes we just restart SdServer so it is not as alarming for the user!
|
||||
//mUtil.showToast("Setting " + s + " Changed - restarting server");
|
||||
mUtil.showToast("Stopping Background Service...");
|
||||
mPrefChanged = true;
|
||||
mUtil.stopServer();
|
||||
// Wait 1 second to give the server chance to shutdown, then re-start it
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
mUtil.showToast("Re-Starting Background Service...");
|
||||
mUtil.startServer();
|
||||
}
|
||||
}, 100);
|
||||
}, 1000);
|
||||
|
||||
if (s.equals("DataSource") || s.equals("advancedMode")) {
|
||||
if (s.equals("advancedMode")) {
|
||||
Log.i(TAG, "Re-starting PrefActivity to refresh list");
|
||||
finish();
|
||||
startActivity(getIntent());
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,7 +34,6 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
@@ -53,7 +52,6 @@ import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
|
||||
import com.rohitss.uceh.UCEHandler;
|
||||
|
||||
@@ -89,10 +87,12 @@ public class StartupActivity extends AppCompatActivity {
|
||||
private boolean mLocationPermissions2Requested;
|
||||
private boolean mSmsPermissionsRequested;
|
||||
private boolean mPermissionsRequested;
|
||||
private boolean mBindInProgress = false;
|
||||
|
||||
public final String[] REQUIRED_PERMISSIONS = {
|
||||
//Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WAKE_LOCK,
|
||||
Manifest.permission.POST_NOTIFICATIONS,
|
||||
};
|
||||
|
||||
public final String[] SMS_PERMISSIONS_1 = {
|
||||
@@ -112,6 +112,25 @@ public class StartupActivity extends AppCompatActivity {
|
||||
Manifest.permission.ACCESS_BACKGROUND_LOCATION,
|
||||
};
|
||||
|
||||
public final String[] BT_PERMISSIONS = {
|
||||
Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.BLUETOOTH,
|
||||
Manifest.permission.BLUETOOTH_SCAN,
|
||||
Manifest.permission.BLUETOOTH_ADMIN,
|
||||
Manifest.permission.BLUETOOTH_CONNECT,
|
||||
};
|
||||
private boolean mBTPermissionsRequested = false;
|
||||
private String mSdDataSourceName;
|
||||
private String mBleDeviceAddr;
|
||||
private String mBleDeviceName;
|
||||
|
||||
private final int MODE_INIT = 0;
|
||||
private final int MODE_SHUTDOWN_SERVER = 1;
|
||||
private final int MODE_START_SERVER = 2;
|
||||
private final int MODE_CONNECT_SERVER = 3;
|
||||
private final int MODE_WATCH_RUNNING = 4;
|
||||
private final int MODE_SD_DATA_OK = 5;
|
||||
private int mMode = MODE_INIT;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -196,31 +215,28 @@ public class StartupActivity extends AppCompatActivity {
|
||||
// Display the DataSource name
|
||||
SharedPreferences SP = PreferenceManager
|
||||
.getDefaultSharedPreferences(getBaseContext());
|
||||
;
|
||||
String dataSourceName = SP.getString("DataSource", "Pebble");
|
||||
|
||||
mSdDataSourceName = SP.getString("DataSource", "Pebble");
|
||||
mBleDeviceAddr = SP.getString("BLE_Device_Addr", "");
|
||||
mBleDeviceName = SP.getString("BLE_Device_Name", "");
|
||||
tv = (TextView) findViewById(R.id.dataSourceTextView);
|
||||
tv.setText(String.format("%s = %s", getString(R.string.DataSource), dataSourceName));
|
||||
|
||||
if (mSdDataSourceName.equals("BLE")) {
|
||||
tv.setText(String.format("%s = %s (%s - %s)", getString(R.string.DataSource), mSdDataSourceName, mBleDeviceName, mBleDeviceAddr));
|
||||
} else {
|
||||
tv.setText(String.format("%s = %s", getString(R.string.DataSource), mSdDataSourceName));
|
||||
}
|
||||
|
||||
|
||||
if (mUtil.isServerRunning()) {
|
||||
mMode = MODE_SHUTDOWN_SERVER;
|
||||
Log.i(TAG, "onStart() - server running - stopping it - isServerRunning=" + mUtil.isServerRunning());
|
||||
mUtil.writeToSysLogFile("StartupActivity.onStart() - server already running - stopping it.");
|
||||
mUtil.stopServer();
|
||||
} else {
|
||||
mMode = MODE_START_SERVER;
|
||||
Log.i(TAG, "onStart() - server not running - isServerRunning=" + mUtil.isServerRunning());
|
||||
}
|
||||
// Wait 0.1 second to give the server chance to shutdown in case we have just shut it down below, then start it
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
mUtil.writeToSysLogFile("StartupActivity.onStart() - starting server after delay - isServerRunning=" + mUtil.isServerRunning());
|
||||
Log.i(TAG, "onStart() - starting server after delay -isServerRunning=" + mUtil.isServerRunning());
|
||||
mUtil.startServer();
|
||||
// Bind to the service.
|
||||
Log.i(TAG, "onStart() - binding to server");
|
||||
mUtil.writeToSysLogFile("StartupActivity.onStart() - binding to server");
|
||||
mUtil.bindToServer(getApplicationContext(), mConnection);
|
||||
}
|
||||
}, 100);
|
||||
|
||||
// Check power management settings
|
||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
@@ -299,7 +315,33 @@ public class StartupActivity extends AppCompatActivity {
|
||||
tv = (TextView) findViewById(R.id.textItem1);
|
||||
pb = (ProgressBar) findViewById(R.id.progressBar1);
|
||||
if (arePermissionsOK()) {
|
||||
if (smsAlarmsActive && !areSMSPermissions1OK()) {
|
||||
Log.i(TAG,"arePermissionsOK=true");
|
||||
Log.i(TAG,"mSdDataSourceName = "+ mSdDataSourceName);
|
||||
tv.setText(getString(R.string.AppPermissionsOk));
|
||||
tv.setBackgroundColor(okColour);
|
||||
tv.setTextColor(okTextColour);
|
||||
pb.setIndeterminateDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
pb.setProgressDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
|
||||
if (mSdDataSourceName.equals("BLE")) {
|
||||
if (!areBTPermissionsOK()) {
|
||||
Log.i(TAG, "Bluetooth permissions NOT OK");
|
||||
tv.setText(getString(R.string.BTPermissionWarning));
|
||||
tv.setBackgroundColor(alarmColour);
|
||||
tv.setTextColor(alarmTextColour);
|
||||
//pb.setIndeterminateDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
//pb.setProgressDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
requestBTPermissions();
|
||||
allOk = false;
|
||||
} else if (mBleDeviceAddr.equals("")) {
|
||||
Log.i(TAG,"BLE daa source selected, but no device address specified");
|
||||
Intent i;
|
||||
i = new Intent(getApplicationContext(), BLEScanActivity.class);
|
||||
startActivity(i);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
} else if (smsAlarmsActive && !areSMSPermissions1OK()) {
|
||||
Log.i(TAG, "SMS permissions NOT OK");
|
||||
tv.setText(getString(R.string.SmsPermissionWarning));
|
||||
tv.setBackgroundColor(alarmColour);
|
||||
@@ -322,12 +364,6 @@ public class StartupActivity extends AppCompatActivity {
|
||||
tv.setTextColor(alarmTextColour);
|
||||
requestLocationPermissions2();
|
||||
allOk = false;
|
||||
} else {
|
||||
tv.setText(getString(R.string.AppPermissionsOk));
|
||||
tv.setBackgroundColor(okColour);
|
||||
tv.setTextColor(okTextColour);
|
||||
pb.setIndeterminateDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
pb.setProgressDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
}
|
||||
} else {
|
||||
tv.setText(getString(R.string.AppPermissionsWarning));
|
||||
@@ -348,6 +384,41 @@ public class StartupActivity extends AppCompatActivity {
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
if (allOk) {
|
||||
tv = (TextView) findViewById(R.id.textItem1);
|
||||
pb = (ProgressBar) findViewById(R.id.progressBar1);
|
||||
|
||||
if (!mUtil.isServerRunning()) {
|
||||
mUtil.writeToSysLogFile("StartupActivity.onStart() - starting server - isServerRunning=" + mUtil.isServerRunning());
|
||||
Log.i(TAG, "onStart() - starting server -isServerRunning=" + mUtil.isServerRunning());
|
||||
mUtil.startServer();
|
||||
mBindInProgress = false;
|
||||
allOk = false;
|
||||
tv.setText("Starting Server");
|
||||
tv.setBackgroundColor(alarmColour);
|
||||
tv.setTextColor(alarmTextColour);
|
||||
pb.setIndeterminateDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
pb.setProgressDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
mMode = MODE_START_SERVER;
|
||||
} else {
|
||||
tv.setText(getString(R.string.ServerRunningOK));
|
||||
tv.setBackgroundColor(okColour);
|
||||
tv.setTextColor(okTextColour);
|
||||
pb.setIndeterminateDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
pb.setProgressDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
if (mBindInProgress) {
|
||||
Log.i(TAG,"Waiting to bind to server");
|
||||
} else {
|
||||
Log.i(TAG, "ServerStatusRunnable() - not starting server - allOk=" + allOk + ", isServerRunning()=" + mUtil.isServerRunning());
|
||||
// Bind to the service.
|
||||
Log.i(TAG, "ServerStatusRunnable() - binding to server");
|
||||
mUtil.writeToSysLogFile("StartupActivity.onStart() - binding to server");
|
||||
mUtil.bindToServer(getApplicationContext(), mConnection);
|
||||
mBindInProgress = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Are we Bound to the Service
|
||||
tv = (TextView) findViewById(R.id.textItem2);
|
||||
pb = (ProgressBar) findViewById(R.id.progressBar2);
|
||||
@@ -442,6 +513,7 @@ public class StartupActivity extends AppCompatActivity {
|
||||
startActivity(intent);
|
||||
mStartedMainActivity = true;
|
||||
finish();
|
||||
return;
|
||||
} catch (Exception ex) {
|
||||
mStartedMainActivity = false;
|
||||
Log.e(TAG, "exception starting main activity " + ex.toString());
|
||||
@@ -677,6 +749,21 @@ public class StartupActivity extends AppCompatActivity {
|
||||
return allOk;
|
||||
}
|
||||
|
||||
public boolean areBTPermissionsOK() {
|
||||
boolean allOk = true;
|
||||
Log.d(TAG, "areBTPermissions OK()");
|
||||
for (int i = 0; i < BT_PERMISSIONS.length; i++) {
|
||||
if (ContextCompat.checkSelfPermission(this, BT_PERMISSIONS[i])
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
Log.d(TAG, BT_PERMISSIONS[i] + " Permission Not Granted");
|
||||
allOk = false;
|
||||
}
|
||||
}
|
||||
return allOk;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void requestPermissions(AppCompatActivity activity) {
|
||||
if (mPermissionsRequested) {
|
||||
Log.i(TAG, "requestPermissions() - request already sent - not doing anything");
|
||||
@@ -785,15 +872,47 @@ public class StartupActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
public void requestBTPermissions() {
|
||||
if (mBTPermissionsRequested) {
|
||||
Log.i(TAG, "requestBTPermissions() - request already sent - not doing anything");
|
||||
} else {
|
||||
Log.i(TAG, "requestBTPermissions() - requesting permissions");
|
||||
mBTPermissionsRequested = true;
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
|
||||
this);
|
||||
alertDialogBuilder
|
||||
.setTitle(R.string.BTpermissions_required)
|
||||
.setMessage(R.string.BT_permissions_rationale)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.okBtnTxt), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
Log.i(TAG, "requestBTPermissions(): Launching ActivityCompat.requestPermissions()");
|
||||
ActivityCompat.requestPermissions(StartupActivity.this,
|
||||
BT_PERMISSIONS,
|
||||
46);
|
||||
}
|
||||
})
|
||||
//.setNegativeButton(getString(R.string.cancelBtnTxt), new DialogInterface.OnClickListener() {
|
||||
// public void onClick(DialogInterface dialog, int id) {
|
||||
// dialog.cancel();
|
||||
// }
|
||||
//}
|
||||
//)
|
||||
.create().show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode,
|
||||
String permissions[], int[] grantResults) {
|
||||
Log.i(TAG, "onRequestPermissionsResult - Permission" + permissions + " = " + grantResults);
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
Log.i(TAG, "onRequestPermissionsResult - requestCode="+requestCode+" nPermissions="+permissions.length);
|
||||
Log.i(TAG, "onRequestPermissionsResult: "+permissions[0]+": "+grantResults[0]);
|
||||
for (int i = 0; i < permissions.length; i++) {
|
||||
Log.i(TAG, "Permission " + permissions[i] + " = " + grantResults[i]);
|
||||
Log.i(TAG, String.format("onRequestPermissionsResult: i="+i+", Permission " + permissions[i].toString() + " = " + grantResults[i]));
|
||||
//Log.i(TAG,"i="+i);
|
||||
}
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -73,14 +73,13 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="#00FF00"
|
||||
android:drawSelectorOnTop="false" />
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FF0000"
|
||||
android:background="#101010"
|
||||
android:text="No data" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
android:id="@+id/action_start_stop"
|
||||
android:icon="@drawable/stop_server"
|
||||
app:showAsAction="never|withText"
|
||||
android:title="@string/restart_server" />
|
||||
<item
|
||||
android:id="@+id/action_exit"
|
||||
android:icon="@drawable/stop_server"
|
||||
app:showAsAction="never|withText"
|
||||
android:title="@string/start_stop_server" />
|
||||
</group>
|
||||
<group android:id="@+id/grp3">
|
||||
|
||||
@@ -571,4 +571,8 @@
|
||||
<string name="battery_history">Battery History</string>
|
||||
<string name="watch_batt_hist">Watch Battery History (%)</string>
|
||||
<string name="ble_connected_warning_text">NOTE: Devices will not appear on this list if they are already connected - disconnect device from GadgetBridge etc. to allow it to be selected here</string>
|
||||
<string name="BTPermissionWarning">Bluetooth Permissions Not Granted</string>
|
||||
<string name="BTpermissions_required">Bluetooth Permissions Required</string>
|
||||
<string name="BT_permissions_rationale">Bluetooth permissions are required to communicate with the bluetooth (BLE) data source</string>
|
||||
<string name="restart_server">Restart Server</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user