diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 7521930..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -# These are supported funding model platforms - -github: [martinohanlon] diff --git a/README.rst b/README.rst index 5a75bf6..042660a 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,8 @@ Blue Dot ======== +fork to get the android app working on newer phones + |pypibadge| |docsbadge| .. raw:: html diff --git a/clients/android/app/src/main/AndroidManifest.xml b/clients/android/app/src/main/AndroidManifest.xml index 6967196..56c079f 100644 --- a/clients/android/app/src/main/AndroidManifest.xml +++ b/clients/android/app/src/main/AndroidManifest.xml @@ -2,12 +2,18 @@ - /> + /> + android:maxSdkVersion="30"/> - + + + + + + = android.os.Build.VERSION_CODES.S) { + return ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED && + ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED; + } + return true; + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_devices); - devicelist = (ListView)findViewById(R.id.listView); + devicelist = (ListView) findViewById(R.id.listView); checkPermissions(); //if the device has bluetooth myBluetooth = BluetoothAdapter.getDefaultAdapter(); - if(myBluetooth == null) { + if (myBluetooth == null) { Toast.makeText( getApplicationContext(), "Bluetooth Device Not Available", @@ -79,10 +86,10 @@ protected void onCreate(Bundle savedInstanceState) { this.finish(); System.exit(0); - } else if(!myBluetooth.isEnabled()) { + } else if (!myBluetooth.isEnabled()) { //Ask to the user turn the bluetooth on Intent turnBTon = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); - startActivityForResult(turnBTon,1); + startActivityForResult(turnBTon, 1); } SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); @@ -146,25 +153,34 @@ private void setConnectMsg(SharedPreferences sharedPreferences) { } private void pairedDevicesList() { - pairedDevices = myBluetooth.getBondedDevices(); - ArrayList list = new ArrayList(); - - if (pairedDevices.size()>0) { - // create a list of paired bluetooth devices - for(BluetoothDevice bt : pairedDevices) - { - list.add(bt.getName() + "\n" + bt.getAddress()); //Get the device's name and the address - } - } else { + if (!approvedPermissions()) { Toast.makeText( getApplicationContext(), - "No Paired Bluetooth Devices Found.", + "Bluetooth Permissions Not Granted", Toast.LENGTH_LONG).show(); + checkPermissions(); // Ask for permissions again + } else { + pairedDevices = myBluetooth.getBondedDevices(); + ArrayList list = new ArrayList(); + + if (pairedDevices.size()>0) { + // create a list of paired bluetooth devices + for(BluetoothDevice bt : pairedDevices) + { + list.add(bt.getName() + "\n" + bt.getAddress()); //Get the device's name and the address + } + } else { + Toast.makeText( + getApplicationContext(), + "No Paired Bluetooth Devices Found.", + Toast.LENGTH_LONG).show(); + } + + final ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1, list); + devicelist.setAdapter(adapter); + devicelist.setOnItemClickListener(myListClickListener); //Method called when the device from the list is clicked } - final ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1, list); - devicelist.setAdapter(adapter); - devicelist.setOnItemClickListener(myListClickListener); //Method called when the device from the list is clicked } private AdapterView.OnItemClickListener myListClickListener = new AdapterView.OnItemClickListener()