diff --git a/app/build.gradle b/app/build.gradle index f1d6e4a864..5944f8c9a1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -310,7 +310,6 @@ dependencies { implementation "nl.komponents.kovenant:kovenant:$kovenantVersion" implementation "nl.komponents.kovenant:kovenant-android:$kovenantVersion" implementation "com.jakewharton.rxbinding3:rxbinding:3.1.0" - implementation "com.github.tbruyelle:rxpermissions:0.10.2" implementation "com.github.ybq:Android-SpinKit:1.4.0" implementation "com.opencsv:opencsv:4.6" testImplementation "junit:junit:$junitVersion" @@ -366,7 +365,7 @@ dependencies { debugImplementation "androidx.compose.ui:ui-test-manifest:$composeVersion" implementation "com.google.accompanist:accompanist-themeadapter-appcompat:0.33.1-alpha" - implementation "com.google.accompanist:accompanist-permissions:0.33.1-alpha" + implementation "com.google.accompanist:accompanist-permissions:0.36.0" implementation "com.google.accompanist:accompanist-drawablepainter:0.33.1-alpha" implementation "androidx.camera:camera-camera2:1.3.2" diff --git a/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt index 69bcef2242..9fdc6b1063 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt @@ -89,9 +89,9 @@ class WebRtcCallActivity : PassphraseRequiredActionBarActivity() { return super.onOptionsItemSelected(item) } - override fun onNewIntent(intent: Intent?) { + override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) - if (intent?.action == ACTION_ANSWER) { + if (intent.action == ACTION_ANSWER) { val answerIntent = WebRtcCallService.acceptCallIntent(this) answerIntent.flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT ContextCompat.startForegroundService(this, answerIntent) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/AttachmentManager.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/AttachmentManager.java index 78b15d3c71..c3961223e0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/AttachmentManager.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/AttachmentManager.java @@ -317,10 +317,6 @@ public class AttachmentManager { .put(APP_NAME_KEY, context.getString(R.string.app_name)) .format().toString(); - String requireCameraPermissionTxt = Phrase.from(context, R.string.cameraGrantAccessDescription) - .put(APP_NAME_KEY, context.getString(R.string.app_name)) - .format().toString(); - Permissions.with(activity) .request(Manifest.permission.CAMERA) .withPermanentDenialDialog(cameraPermissionDeniedTxt) diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt index 6f0bda8c96..eb8ff4ba3c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt @@ -5,6 +5,10 @@ import android.content.Context import androidx.compose.runtime.Composable import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment +import com.google.accompanist.permissions.ExperimentalPermissionsApi +import com.google.accompanist.permissions.PermissionState +import com.google.accompanist.permissions.isGranted +import com.google.accompanist.permissions.shouldShowRationale import com.squareup.phrase.Phrase import org.thoughtcrime.securesms.ui.theme.SessionMaterialTheme @@ -39,3 +43,8 @@ fun ComposeView.setThemedContent(content: @Composable () -> Unit) = setContent { content() } } + +@ExperimentalPermissionsApi +fun PermissionState.isPermanentlyDenied(): Boolean { + return !status.shouldShowRationale && !status.isGranted +} diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/QR.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/QR.kt index de59f463e3..55af472f68 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/QR.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/QR.kt @@ -68,6 +68,8 @@ import org.session.libsignal.utilities.Log import org.thoughtcrime.securesms.ui.AlertDialog import org.thoughtcrime.securesms.ui.DialogButtonModel import org.thoughtcrime.securesms.ui.GetString +import org.thoughtcrime.securesms.ui.getSubbedString +import org.thoughtcrime.securesms.ui.isPermanentlyDenied import org.thoughtcrime.securesms.ui.theme.LocalColors import org.thoughtcrime.securesms.ui.theme.LocalDimensions import org.thoughtcrime.securesms.ui.theme.LocalType @@ -119,7 +121,7 @@ fun QRScannerScreen( modifier = Modifier.fillMaxWidth(), onClick = { // if the permission has been denied permanently, ask the user to go to the settings - if (cameraPermissionState.status.shouldShowRationale){ + if (cameraPermissionState.isPermanentlyDenied()){ showCameraPermissionDialog = true } // otherwise ask for permission @@ -134,10 +136,13 @@ fun QRScannerScreen( // camera permission denied permanently dialog if(showCameraPermissionDialog){ + val context = LocalContext.current + AlertDialog( onDismissRequest = { showCameraPermissionDialog = false }, title = stringResource(R.string.permissionsRequired), - text = stringResource(R.string.permissionsCameraDenied), + text = context.getSubbedString(R.string.permissionsCameraDenied, + APP_NAME_KEY to context.getString(R.string.app_name)), buttons = listOf( DialogButtonModel( text = GetString(stringResource(id = R.string.sessionSettings)),