Rework permission messages. Close #364
This commit is contained in:
parent
f87e7dbcc4
commit
7f1c9b8b16
@ -29,11 +29,12 @@ import androidx.camera.lifecycle.ProcessCameraProvider
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.setPadding
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.pixeldroid.app.R
|
||||
@ -216,6 +217,7 @@ class CameraFragment : BaseFragment() {
|
||||
) {
|
||||
updateGalleryThumbnail()
|
||||
}
|
||||
//TODO check if we can get rid of this filePermissionDialogLaunched check (& the variable)
|
||||
else if (!filePermissionDialogLaunched) {
|
||||
// Ask for external storage permission.
|
||||
updateGalleryThumbnailPermissionLauncher.launch(
|
||||
@ -268,10 +270,8 @@ class CameraFragment : BaseFragment() {
|
||||
) { isGranted: Boolean ->
|
||||
if (isGranted) {
|
||||
updateGalleryThumbnail()
|
||||
} else if(!filePermissionDialogLaunched){
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setMessage(getString(R.string.no_storage_permission))
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->}.show()
|
||||
} else {
|
||||
//TODO should we show the user some message like we did until 75ae26fa4755530794267041de1038f3302ec306 ?
|
||||
filePermissionDialogLaunched = true
|
||||
}
|
||||
}
|
||||
@ -349,11 +349,10 @@ class CameraFragment : BaseFragment() {
|
||||
private val bindCameraPermissionLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()
|
||||
) { isGranted: Boolean ->
|
||||
if (isGranted) {
|
||||
binding.cameraPermissionErrorCard.isVisible = false
|
||||
bindCameraUseCases()
|
||||
} else {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setMessage(R.string.no_camera_permission)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->}.show()
|
||||
binding.cameraPermissionErrorCard.isVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
<vector android:height="24dp"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-2h2v2zM13,13h-2L11,7h2v6z"/>
|
||||
|
@ -14,9 +14,9 @@
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/camera_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layoutDirection="ltr"
|
||||
@ -29,6 +29,47 @@
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:visibility="invisible"
|
||||
style="?attr/materialCardViewElevatedStyle"
|
||||
app:cardBackgroundColor="?attr/colorSecondaryContainer"
|
||||
tools:visibility="visible"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:id="@+id/camera_permission_error_card"
|
||||
android:layout_margin="20dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="8dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/checkMarkStabilize"
|
||||
app:tint="?attr/colorOnSecondaryContainer"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="match_parent"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@drawable/error"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="@id/checkMarkStabilize"
|
||||
app:layout_constraintTop_toTopOf="@id/checkMarkStabilize"
|
||||
app:layout_constraintStart_toEndOf="@id/checkMarkStabilize"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="@string/no_camera_permission" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<!-- Camera control and gallery buttons -->
|
||||
<ImageButton
|
||||
android:id="@+id/camera_switch_button"
|
||||
|
Loading…
x
Reference in New Issue
Block a user