SDK checking cleanup 2
This commit is contained in:
parent
c9d1cc6a24
commit
81eeb66538
4 changed files with 30 additions and 42 deletions
|
@ -11,11 +11,7 @@ class RequestDexcomPermissionActivity : AppCompatActivity() {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
requestPermissions(arrayOf(SourceDexcomPlugin.PERMISSION), requestCode)
|
requestPermissions(arrayOf(SourceDexcomPlugin.PERMISSION), requestCode)
|
||||||
} else {
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.dialog;
|
package info.nightscout.androidaps.plugins.pump.common.dialog;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
@ -21,7 +11,6 @@ import android.bluetooth.le.ScanSettings;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.ParcelUuid;
|
import android.os.ParcelUuid;
|
||||||
|
@ -41,6 +30,16 @@ import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
|
@ -171,15 +170,10 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
|
||||||
Toast.makeText(this, R.string.rileylink_scanner_ble_not_enabled, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.rileylink_scanner_ble_not_enabled, Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
// Will request that GPS be enabled for devices running Marshmallow or newer.
|
// Will request that GPS be enabled for devices running Marshmallow or newer.
|
||||||
if (!LocationHelper.isLocationEnabled(this)) {
|
if (!LocationHelper.isLocationEnabled(this)) {
|
||||||
LocationHelper.requestLocationForBluetooth(this);
|
LocationHelper.requestLocationForBluetooth(this);
|
||||||
}
|
}
|
||||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
||||||
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
|
|
||||||
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
|
|
||||||
}
|
|
||||||
|
|
||||||
mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
|
mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
|
||||||
settings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
|
settings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
|
||||||
|
|
|
@ -69,10 +69,8 @@ public class LocationHelper {
|
||||||
*/
|
*/
|
||||||
public static void requestLocationForBluetooth(Activity activity) {
|
public static void requestLocationForBluetooth(Activity activity) {
|
||||||
// Location needs to be enabled for Bluetooth discovery on Marshmallow.
|
// Location needs to be enabled for Bluetooth discovery on Marshmallow.
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
LocationHelper.requestLocation(activity);
|
LocationHelper.requestLocation(activity);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// public static Boolean locationPermission(ActivityWithMenu act) {
|
// public static Boolean locationPermission(ActivityWithMenu act) {
|
||||||
// return ActivityCompat.checkSelfPermission(act, Manifest.permission.ACCESS_FINE_LOCATION) ==
|
// return ActivityCompat.checkSelfPermission(act, Manifest.permission.ACCESS_FINE_LOCATION) ==
|
||||||
|
|
|
@ -44,7 +44,7 @@ object SourceDexcomPlugin : PluginBase(PluginDescription()
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(MainApp.instance(), PERMISSION) != PackageManager.PERMISSION_GRANTED) {
|
if (ContextCompat.checkSelfPermission(MainApp.instance(), PERMISSION) != PackageManager.PERMISSION_GRANTED) {
|
||||||
val intent = Intent(MainApp.instance(), RequestDexcomPermissionActivity::class.java)
|
val intent = Intent(MainApp.instance(), RequestDexcomPermissionActivity::class.java)
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
MainApp.instance().startActivity(intent)
|
MainApp.instance().startActivity(intent)
|
||||||
|
|
Loading…
Reference in a new issue