1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-07 01:06:57 +02:00

grand access to fine location which includes coarse location access

This commit is contained in:
oliexdev
2019-02-23 12:28:54 +01:00
parent 3b74a8581d
commit 2fd331adc5
6 changed files with 9 additions and 10 deletions

View File

@@ -7,7 +7,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Permission to allow read of data from the database through a ContentProvider.
Marked "dangerous" so that explicit user approval is required to read this data, not

View File

@@ -454,7 +454,7 @@ public abstract class BluetoothCommunication {
// Otherwise the connection almost never succeeds.
LocationManager locationManager = (LocationManager)context.getSystemService(LOCATION_SERVICE);
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION)
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED && (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
|| locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
) {
@@ -474,7 +474,7 @@ public abstract class BluetoothCommunication {
}}, throwable -> setBluetoothStatus(BT_STATUS.NO_DEVICE_FOUND));
}
else {
Timber.d("No coarse location permission, connecting without LE scan");
Timber.d("No location permission, connecting without LE scan");
connectToDevice(macAddress);
}
}

View File

@@ -23,7 +23,6 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.widget.EditText;
import com.health.openscale.R;
import com.health.openscale.gui.preferences.BackupPreferences;
@@ -106,7 +105,7 @@ public class SettingsActivity extends PreferenceActivity
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
// TODO HACK to call RequestPermissionResult(...) in PreferenceFragment otherwise API level > 23 is required
switch(requestCode) {
case PermissionHelper.PERMISSIONS_REQUEST_ACCESS_COARSE_LOCATION:
case PermissionHelper.PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION:
BluetoothPreferences bluetoothPreferences = (BluetoothPreferences)currentFragment;
bluetoothPreferences.onMyOwnRequestPermissionsResult(requestCode, permissions, grantResults);
break;

View File

@@ -325,7 +325,7 @@ public class BluetoothPreferences extends PreferenceFragment {
public void onMyOwnRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) {
case PermissionHelper.PERMISSIONS_REQUEST_ACCESS_COARSE_LOCATION: {
case PermissionHelper.PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (PermissionHelper.requestLocationServicePermission(getActivity())) {
startBluetoothDiscovery();

View File

@@ -37,7 +37,7 @@ import androidx.core.app.ActivityCompat;
import static android.content.Context.LOCATION_SERVICE;
public class PermissionHelper {
public final static int PERMISSIONS_REQUEST_ACCESS_COARSE_LOCATION = 1;
public final static int PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION = 1;
public final static int PERMISSIONS_REQUEST_ACCESS_READ_STORAGE = 2;
public final static int PERMISSIONS_REQUEST_ACCESS_WRITE_STORAGE = 3;
@@ -63,7 +63,7 @@ public class PermissionHelper {
return false;
}
if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage(R.string.permission_bluetooth_info)
@@ -72,7 +72,7 @@ public class PermissionHelper {
.setPositiveButton(R.string.label_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, PERMISSIONS_REQUEST_ACCESS_COARSE_LOCATION);
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION);
}
});

View File

@@ -198,7 +198,7 @@
<string name="label_measurement_bar">Measurement bar</string>
<string name="permission_not_granted">Permission not granted</string>
<string name="permission_bluetooth_info">Coarse location permission needed to search for Bluetooth devices. It can be revoked after the device is found.</string>
<string name="permission_bluetooth_info">Location permission needed to search for Bluetooth devices. It can be revoked after the device is found.</string>
<string name="permission_location_service_info">Grant location access in the Android settings to search for Bluetooth devices. Optionally revoke it afterwards.</string>
<string name="permission_bluetooth_info_title">Info</string>
<string name="permission_read_write_data_description">read/write openScale data, including user information and all saved measurements</string>