mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
- no camera permission (#10042)
- scan document - approve permission - see scan document activity, previously it was wrong upload image activity Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
c84d09f006
commit
b324f0d784
4 changed files with 17 additions and 5 deletions
|
@ -143,6 +143,8 @@ import de.cotech.hw.fido2.WebViewWebauthnBridge;
|
||||||
import de.cotech.hw.fido2.ui.WebauthnDialogOptions;
|
import de.cotech.hw.fido2.ui.WebauthnDialogOptions;
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
|
import static com.owncloud.android.utils.PermissionUtil.PERMISSIONS_CAMERA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Activity is used to add an ownCloud account to the App
|
* This Activity is used to add an ownCloud account to the App
|
||||||
*/
|
*/
|
||||||
|
@ -1298,7 +1300,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
if (PermissionUtil.checkSelfPermission(this, Manifest.permission.CAMERA)) {
|
if (PermissionUtil.checkSelfPermission(this, Manifest.permission.CAMERA)) {
|
||||||
startQRScanner();
|
startQRScanner();
|
||||||
} else {
|
} else {
|
||||||
PermissionUtil.requestCameraPermission(this);
|
PermissionUtil.requestCameraPermission(this, PERMISSIONS_CAMERA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -394,6 +394,15 @@ public class FileDisplayActivity extends FileActivity
|
||||||
// toggle on is save since this is the only scenario this code gets accessed
|
// toggle on is save since this is the only scenario this code gets accessed
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PermissionUtil.PERMISSIONS_SCAN_DOCUMENT:
|
||||||
|
// If request is cancelled, result arrays are empty.
|
||||||
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
// permission was granted
|
||||||
|
getFileOperationsHelper().scanFromCamera(
|
||||||
|
this,
|
||||||
|
FileDisplayActivity.REQUEST_CODE__UPLOAD_SCAN_DOC_FROM_CAMERA);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case PermissionUtil.PERMISSIONS_CAMERA:
|
case PermissionUtil.PERMISSIONS_CAMERA:
|
||||||
// If request is cancelled, result arrays are empty.
|
// If request is cancelled, result arrays are empty.
|
||||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
|
|
@ -1068,7 +1068,7 @@ public class FileOperationsHelper {
|
||||||
if (PermissionUtil.checkSelfPermission(activity, Manifest.permission.CAMERA)) {
|
if (PermissionUtil.checkSelfPermission(activity, Manifest.permission.CAMERA)) {
|
||||||
activity.startActivityForResult(pictureIntent, requestCode);
|
activity.startActivityForResult(pictureIntent, requestCode);
|
||||||
} else {
|
} else {
|
||||||
PermissionUtil.requestCameraPermission(activity);
|
PermissionUtil.requestCameraPermission(activity, PermissionUtil.PERMISSIONS_CAMERA);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DisplayUtils.showSnackMessage(activity, "No Camera found");
|
DisplayUtils.showSnackMessage(activity, "No Camera found");
|
||||||
|
@ -1084,7 +1084,7 @@ public class FileOperationsHelper {
|
||||||
if (PermissionUtil.checkSelfPermission(activity, Manifest.permission.CAMERA)) {
|
if (PermissionUtil.checkSelfPermission(activity, Manifest.permission.CAMERA)) {
|
||||||
activity.startActivityForResult(scanIntent, requestCode);
|
activity.startActivityForResult(scanIntent, requestCode);
|
||||||
} else {
|
} else {
|
||||||
PermissionUtil.requestCameraPermission(activity);
|
PermissionUtil.requestCameraPermission(activity, PermissionUtil.PERMISSIONS_SCAN_DOCUMENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ object PermissionUtil {
|
||||||
const val PERMISSIONS_CAMERA = 5
|
const val PERMISSIONS_CAMERA = 5
|
||||||
const val PERMISSIONS_READ_CALENDAR_AUTOMATIC = 6
|
const val PERMISSIONS_READ_CALENDAR_AUTOMATIC = 6
|
||||||
const val PERMISSIONS_WRITE_CALENDAR = 7
|
const val PERMISSIONS_WRITE_CALENDAR = 7
|
||||||
|
const val PERMISSIONS_SCAN_DOCUMENT = 6
|
||||||
|
|
||||||
const val REQUEST_CODE_MANAGE_ALL_FILES = 19203
|
const val REQUEST_CODE_MANAGE_ALL_FILES = 19203
|
||||||
|
|
||||||
|
@ -226,10 +227,10 @@ object PermissionUtil {
|
||||||
* @param activity The target activity.
|
* @param activity The target activity.
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun requestCameraPermission(activity: Activity) {
|
fun requestCameraPermission(activity: Activity, requestCode: Int) {
|
||||||
ActivityCompat.requestPermissions(
|
ActivityCompat.requestPermissions(
|
||||||
activity, arrayOf(Manifest.permission.CAMERA),
|
activity, arrayOf(Manifest.permission.CAMERA),
|
||||||
PERMISSIONS_CAMERA
|
requestCode
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue