committed by
Duncan McNamara
16 changed files with 1205 additions and 0 deletions
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,56 @@ |
|||
<!-- |
|||
~ ************************************************************************* |
|||
~ ic_permission_media_audio.xml |
|||
~ ************************************************************************** |
|||
~ Copyright © 2024 VLC authors and VideoLAN |
|||
~ Author: Nicolas POMEPUY |
|||
~ This program is free software; you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation; either version 2 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ along with this program; if not, write to the Free Software |
|||
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|||
~ *************************************************************************** |
|||
~ |
|||
~ |
|||
--> |
|||
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:aapt="http://schemas.android.com/aapt" |
|||
android:width="32dp" |
|||
android:height="32dp" |
|||
android:viewportWidth="32" |
|||
android:viewportHeight="32"> |
|||
<path |
|||
android:pathData="M16,16m-14,0a14,14 0,1 1,28 0a14,14 0,1 1,-28 0" |
|||
android:strokeWidth="0.294741" |
|||
android:fillColor="@color/grey600"/> |
|||
<path |
|||
android:pathData="M25,25m-6,0a6,6 135,1 1,12 0a6,6 135,1 1,-12 0" |
|||
android:strokeWidth="0.141" |
|||
android:fillColor="?attr/colorPrimary" |
|||
android:strokeColor="#00000000" |
|||
android:fillType="nonZero"/> |
|||
<path |
|||
android:pathData="m24.143,27.572 l4.723,-4.723 -0.606,-0.606 -4.117,4.117 -1.818,-1.818 -0.606,0.606z" |
|||
android:strokeLineJoin="round" |
|||
android:strokeWidth="2.492" |
|||
android:fillColor="@color/white" |
|||
android:strokeColor="#00000000" |
|||
android:fillType="nonZero" |
|||
android:strokeLineCap="round"/> |
|||
<path |
|||
android:pathData="M18.134,6.25C16.95,6.268 16,7.233 16,8.417v2.167,7.081c-0.659,-0.38 -1.406,-0.581 -2.167,-0.581 -2.393,0 -4.333,1.94 -4.333,4.333 0,2.393 1.94,4.333 4.333,4.333 2.393,0 4.333,-1.94 4.333,-4.333L18.167,10.583L20.366,10.583C21.55,10.565 22.5,9.601 22.5,8.417L22.5,6.25ZM13.801,19.25c0.011,-0 0.022,-0 0.033,0 1.197,0 2.167,0.97 2.167,2.167 0,1.197 -0.97,2.167 -2.167,2.167 -1.197,0 -2.167,-0.97 -2.167,-2.167 -0,-1.184 0.95,-2.149 2.134,-2.167z" |
|||
android:strokeLineJoin="round" |
|||
android:strokeWidth="2.12898" |
|||
android:fillColor="@color/white" |
|||
android:strokeColor="#00000000" |
|||
android:strokeLineCap="butt"/> |
|||
</vector> |
|||
@ -0,0 +1,55 @@ |
|||
<!-- |
|||
~ ************************************************************************* |
|||
~ ic_permission_media_audio.xml |
|||
~ ************************************************************************** |
|||
~ Copyright © 2024 VLC authors and VideoLAN |
|||
~ Author: Nicolas POMEPUY |
|||
~ This program is free software; you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation; either version 2 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ along with this program; if not, write to the Free Software |
|||
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|||
~ *************************************************************************** |
|||
~ |
|||
~ |
|||
--> |
|||
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:width="32dp" |
|||
android:height="32dp" |
|||
android:viewportWidth="32" |
|||
android:viewportHeight="32"> |
|||
<path |
|||
android:fillColor="@color/grey400" |
|||
android:pathData="M16,16m-14,0a14,14 0,1 1,28 0a14,14 0,1 1,-28 0" |
|||
android:strokeWidth="0.294741" /> |
|||
<path |
|||
android:fillColor="@color/grey300" |
|||
android:fillType="nonZero" |
|||
android:pathData="M25,25m-6,0a6,6 135,1 1,12 0a6,6 135,1 1,-12 0" |
|||
android:strokeWidth="0.141" |
|||
android:strokeColor="#00000000" /> |
|||
<path |
|||
android:fillColor="@color/white" |
|||
android:fillType="nonZero" |
|||
android:pathData="m24.143,27.572 l4.723,-4.723 -0.606,-0.606 -4.117,4.117 -1.818,-1.818 -0.606,0.606z" |
|||
android:strokeWidth="2.492" |
|||
android:strokeColor="#00000000" |
|||
android:strokeLineCap="round" |
|||
android:strokeLineJoin="round" /> |
|||
<path |
|||
android:fillColor="@color/white" |
|||
android:pathData="M18.134,6.25C16.95,6.268 16,7.233 16,8.417v2.167,7.081c-0.659,-0.38 -1.406,-0.581 -2.167,-0.581 -2.393,0 -4.333,1.94 -4.333,4.333 0,2.393 1.94,4.333 4.333,4.333 2.393,0 4.333,-1.94 4.333,-4.333L18.167,10.583L20.366,10.583C21.55,10.565 22.5,9.601 22.5,8.417L22.5,6.25ZM13.801,19.25c0.011,-0 0.022,-0 0.033,0 1.197,0 2.167,0.97 2.167,2.167 0,1.197 -0.97,2.167 -2.167,2.167 -1.197,0 -2.167,-0.97 -2.167,-2.167 -0,-1.184 0.95,-2.149 2.134,-2.167z" |
|||
android:strokeWidth="2.12898" |
|||
android:strokeColor="#00000000" |
|||
android:strokeLineCap="butt" |
|||
android:strokeLineJoin="round" /> |
|||
</vector> |
|||
@ -0,0 +1,30 @@ |
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:aapt="http://schemas.android.com/aapt" |
|||
android:width="32dp" |
|||
android:height="32dp" |
|||
android:viewportWidth="32" |
|||
android:viewportHeight="32"> |
|||
<path |
|||
android:pathData="M16,16m-14,0a14,14 0,1 1,28 0a14,14 0,1 1,-28 0" |
|||
android:strokeWidth="0.294741" |
|||
android:fillColor="@color/grey600"/> |
|||
<path |
|||
android:pathData="m11,11c-0.825,0 -1.5,0.675 -1.5,1.5v7c0,0.825 0.675,1.5 1.5,1.5h10c0.825,0 1.5,-0.675 1.5,-1.5L22.5,11.75C22.5,11.337 22.163,11 21.75,11L20,11l0.82,1.639c0.082,0.166 -0.038,0.36 -0.223,0.361h-0.98c-0.379,0 -0.725,-0.214 -0.895,-0.553L18,11h-1l0.82,1.639c0.082,0.166 -0.038,0.36 -0.223,0.361h-0.98c-0.379,0 -0.725,-0.214 -0.895,-0.553L15,11h-1l0.82,1.639c0.082,0.166 -0.038,0.36 -0.223,0.361h-0.98c-0.379,0 -0.725,-0.214 -0.895,-0.553L12,11ZM11.5,13 L12.223,14.447C12.392,14.786 12.738,15 13.117,15L13.5,15h7v4h-9z" |
|||
android:strokeLineJoin="round" |
|||
android:fillColor="@color/white" |
|||
android:strokeLineCap="round"/> |
|||
<path |
|||
android:pathData="M25,25m-6,0a6,6 135,1 1,12 0a6,6 135,1 1,-12 0" |
|||
android:strokeWidth="0.141" |
|||
android:fillColor="?attr/colorPrimary" |
|||
android:strokeColor="#00000000" |
|||
android:fillType="nonZero"/> |
|||
<path |
|||
android:pathData="m24.143,27.572 l4.723,-4.723 -0.606,-0.606 -4.117,4.117 -1.818,-1.818 -0.606,0.606z" |
|||
android:strokeLineJoin="round" |
|||
android:strokeWidth="2.492" |
|||
android:fillColor="#fafafa" |
|||
android:strokeColor="#00000000" |
|||
android:fillType="nonZero" |
|||
android:strokeLineCap="round"/> |
|||
</vector> |
|||
@ -0,0 +1,30 @@ |
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:aapt="http://schemas.android.com/aapt" |
|||
android:width="32dp" |
|||
android:height="32dp" |
|||
android:viewportWidth="32" |
|||
android:viewportHeight="32"> |
|||
<path |
|||
android:pathData="M16,16m-14,0a14,14 0,1 1,28 0a14,14 0,1 1,-28 0" |
|||
android:strokeWidth="0.294741" |
|||
android:fillColor="@color/grey400"/> |
|||
<path |
|||
android:pathData="m11,11c-0.825,0 -1.5,0.675 -1.5,1.5v7c0,0.825 0.675,1.5 1.5,1.5h10c0.825,0 1.5,-0.675 1.5,-1.5L22.5,11.75C22.5,11.337 22.163,11 21.75,11L20,11l0.82,1.639c0.082,0.166 -0.038,0.36 -0.223,0.361h-0.98c-0.379,0 -0.725,-0.214 -0.895,-0.553L18,11h-1l0.82,1.639c0.082,0.166 -0.038,0.36 -0.223,0.361h-0.98c-0.379,0 -0.725,-0.214 -0.895,-0.553L15,11h-1l0.82,1.639c0.082,0.166 -0.038,0.36 -0.223,0.361h-0.98c-0.379,0 -0.725,-0.214 -0.895,-0.553L12,11ZM11.5,13 L12.223,14.447C12.392,14.786 12.738,15 13.117,15L13.5,15h7v4h-9z" |
|||
android:strokeLineJoin="round" |
|||
android:fillColor="@color/white" |
|||
android:strokeLineCap="round"/> |
|||
<path |
|||
android:pathData="M25,25m-6,0a6,6 135,1 1,12 0a6,6 135,1 1,-12 0" |
|||
android:strokeWidth="0.141" |
|||
android:fillColor="@color/grey300" |
|||
android:strokeColor="#00000000" |
|||
android:fillType="nonZero"/> |
|||
<path |
|||
android:pathData="m24.143,27.572 l4.723,-4.723 -0.606,-0.606 -4.117,4.117 -1.818,-1.818 -0.606,0.606z" |
|||
android:strokeLineJoin="round" |
|||
android:strokeWidth="2.492" |
|||
android:fillColor="#fafafa" |
|||
android:strokeColor="#00000000" |
|||
android:fillType="nonZero" |
|||
android:strokeLineCap="round"/> |
|||
</vector> |
|||
@ -0,0 +1,9 @@ |
|||
<shape |
|||
xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:shape="rectangle"> |
|||
<solid android:color="?attr/permission_explanation_background"> |
|||
</solid> |
|||
<corners android:radius="8dp"> |
|||
</corners> |
|||
|
|||
</shape> |
|||
@ -0,0 +1,187 @@ |
|||
<?xml version="1.0" encoding="utf-8"?><!-- |
|||
~ ************************************************************************* |
|||
~ dialog_permissions.xml |
|||
~ ************************************************************************** |
|||
~ Copyright © 2024 VLC authors and VideoLAN |
|||
~ Author: Nicolas POMEPUY |
|||
~ This program is free software; you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation; either version 2 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ along with this program; if not, write to the Free Software |
|||
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|||
~ *************************************************************************** |
|||
~ |
|||
~ |
|||
--> |
|||
|
|||
<layout 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"> |
|||
|
|||
<androidx.core.widget.NestedScrollView |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent"> |
|||
|
|||
<androidx.constraintlayout.widget.ConstraintLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:gravity="center_horizontal" |
|||
android:orientation="vertical"> |
|||
|
|||
<TextView |
|||
android:id="@+id/permission_title" |
|||
style="@style/Theme.VLC.BottomSheetTitle" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginStart="16dp" |
|||
android:layout_marginTop="16dp" |
|||
android:minHeight="0dp" |
|||
android:text="@string/permissions" |
|||
app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintTop_toTopOf="parent" /> |
|||
|
|||
<TextView |
|||
android:id="@+id/textView37" |
|||
style="@style/Theme.VLC.BottomSheetTitle" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginStart="16dp" |
|||
android:layout_marginTop="24dp" |
|||
android:text="@string/manage_storage_permission" |
|||
android:textColor="?attr/colorPrimary" |
|||
android:textSize="16sp" |
|||
app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintTop_toBottomOf="@+id/permission_title" /> |
|||
|
|||
<TextView |
|||
android:id="@+id/file_access_explanation" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginStart="16dp" |
|||
android:layout_marginTop="8dp" |
|||
android:layout_marginEnd="16dp" |
|||
android:background="@drawable/rounded_corners_permissions_explanation" |
|||
android:drawablePadding="16dp" |
|||
android:fontFamily="sans-serif-medium" |
|||
android:gravity="center_vertical" |
|||
android:padding="16dp" |
|||
android:text="@string/permission_onboarding_perm_all" |
|||
android:textColor="?attr/font_default" |
|||
android:textSize="18sp" |
|||
app:drawableTint="?attr/font_default" |
|||
app:layout_constraintEnd_toEndOf="parent" |
|||
app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintTop_toBottomOf="@+id/textView37" /> |
|||
|
|||
<TextView |
|||
android:id="@+id/all_access_warning" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginStart="16dp" |
|||
android:layout_marginTop="16dp" |
|||
android:layout_marginEnd="16dp" |
|||
android:layout_marginBottom="8dp" |
|||
android:background="@drawable/rounded_corners_permissions_warning" |
|||
android:padding="12dp" |
|||
android:textSize="16sp" |
|||
android:text="@string/permission_all_warning" |
|||
android:textColor="?attr/font_default" |
|||
android:visibility="invisible" |
|||
app:layout_constraintBottom_toBottomOf="parent" |
|||
app:layout_constraintEnd_toEndOf="parent" |
|||
app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintTop_toBottomOf="@+id/manage_all_perms_check" |
|||
tools:visibility="visible" /> |
|||
|
|||
|
|||
<RadioButton |
|||
android:id="@+id/no_access_check" |
|||
android:layout_width="0dp" |
|||
android:layout_height="match_parent" |
|||
android:layout_marginStart="16dp" |
|||
android:layout_marginEnd="16dp" |
|||
android:layout_weight="1" |
|||
android:enabled="true" |
|||
android:paddingStart="16dp" |
|||
android:text="@string/permission_no_access" |
|||
android:textColor="?attr/font_default" |
|||
android:textSize="16sp" |
|||
app:layout_constraintEnd_toEndOf="parent" |
|||
app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintTop_toBottomOf="@+id/file_access_explanation" /> |
|||
|
|||
|
|||
<RadioButton |
|||
android:id="@+id/manage_media_perms_check" |
|||
android:layout_width="0dp" |
|||
android:layout_height="match_parent" |
|||
android:layout_marginStart="16dp" |
|||
android:layout_marginEnd="16dp" |
|||
android:layout_weight="1" |
|||
android:enabled="true" |
|||
android:paddingStart="16dp" |
|||
android:text="@string/permission_media_title" |
|||
android:textColor="?attr/font_default" |
|||
android:textSize="16sp" |
|||
app:layout_constraintEnd_toStartOf="@+id/manage_media_audio" |
|||
app:layout_constraintHorizontal_bias="0.5" |
|||
app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintTop_toBottomOf="@+id/no_access_check" /> |
|||
|
|||
|
|||
<ImageView |
|||
android:id="@+id/manage_media_audio" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:padding="8dp" |
|||
android:background="?attr/selectableItemBackgroundBorderless" |
|||
app:layout_constraintBottom_toBottomOf="@+id/manage_media_perms_check" |
|||
app:layout_constraintEnd_toStartOf="@+id/manage_media_video" |
|||
app:layout_constraintHorizontal_bias="0.5" |
|||
app:layout_constraintStart_toEndOf="@+id/manage_media_perms_check" |
|||
app:layout_constraintTop_toTopOf="@+id/manage_media_perms_check" |
|||
app:srcCompat="@drawable/ic_permission_media_audio" /> |
|||
|
|||
<ImageView |
|||
android:id="@+id/manage_media_video" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:padding="8dp" |
|||
android:background="?attr/selectableItemBackgroundBorderless" |
|||
app:layout_constraintBottom_toBottomOf="@+id/manage_media_perms_check" |
|||
app:layout_constraintEnd_toEndOf="parent" |
|||
app:layout_constraintHorizontal_bias="0.5" |
|||
app:layout_constraintStart_toEndOf="@+id/manage_media_audio" |
|||
app:layout_constraintTop_toTopOf="@+id/manage_media_perms_check" |
|||
app:srcCompat="@drawable/ic_permission_media_video" /> |
|||
|
|||
|
|||
<RadioButton |
|||
android:id="@+id/manage_all_perms_check" |
|||
android:layout_width="0dp" |
|||
android:layout_height="match_parent" |
|||
android:layout_marginStart="16dp" |
|||
android:layout_marginEnd="16dp" |
|||
android:layout_weight="1" |
|||
android:enabled="true" |
|||
android:paddingStart="16dp" |
|||
android:text="@string/permission_all_title" |
|||
android:textColor="?attr/font_default" |
|||
android:textSize="16sp" |
|||
app:layout_constraintEnd_toEndOf="parent" |
|||
app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintTop_toBottomOf="@+id/manage_media_perms_check" /> |
|||
|
|||
|
|||
</androidx.constraintlayout.widget.ConstraintLayout> |
|||
</androidx.core.widget.NestedScrollView> |
|||
|
|||
</layout> |
|||
@ -0,0 +1,246 @@ |
|||
/* |
|||
* ************************************************************************ |
|||
* PermissionListDialog.kt |
|||
* ************************************************************************* |
|||
* Copyright © 2024 VLC authors and VideoLAN |
|||
* Author: Nicolas POMEPUY |
|||
* This program is free software; you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation; either version 2 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, write to the Free Software |
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|||
* ************************************************************************** |
|||
* |
|||
* |
|||
*/ |
|||
package org.videolan.vlc.gui.dialogs |
|||
|
|||
import android.Manifest |
|||
import android.content.Intent |
|||
import android.net.Uri |
|||
import android.os.Bundle |
|||
import android.util.TypedValue |
|||
import android.view.LayoutInflater |
|||
import android.view.View |
|||
import android.view.ViewGroup |
|||
import android.widget.RadioButton |
|||
import androidx.core.app.ActivityCompat |
|||
import androidx.core.content.ContextCompat |
|||
import androidx.lifecycle.lifecycleScope |
|||
import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED |
|||
import kotlinx.coroutines.launch |
|||
import org.videolan.resources.SCHEME_PACKAGE |
|||
import org.videolan.tools.dp |
|||
import org.videolan.tools.setGone |
|||
import org.videolan.tools.setInvisible |
|||
import org.videolan.tools.setVisible |
|||
import org.videolan.vlc.R |
|||
import org.videolan.vlc.databinding.DialogPermissionsBinding |
|||
import org.videolan.vlc.util.Permissions |
|||
|
|||
|
|||
/** |
|||
* Dialog showing the info of the current version |
|||
*/ |
|||
class PermissionListDialog : VLCBottomSheetDialogFragment() { |
|||
|
|||
private lateinit var binding: DialogPermissionsBinding |
|||
private val defaultBackground: Int |
|||
get() { |
|||
val outValue = TypedValue() |
|||
requireActivity().theme.resolveAttribute( |
|||
android.R.attr.selectableItemBackground, |
|||
outValue, |
|||
true |
|||
) |
|||
return outValue.resourceId |
|||
} |
|||
|
|||
companion object { |
|||
|
|||
fun newInstance(): PermissionListDialog { |
|||
return PermissionListDialog() |
|||
} |
|||
} |
|||
|
|||
override fun getDefaultState(): Int { |
|||
return STATE_EXPANDED |
|||
} |
|||
|
|||
override fun needToManageOrientation(): Boolean { |
|||
return false |
|||
} |
|||
|
|||
override fun initialFocusedView(): View = binding.permissionTitle |
|||
|
|||
override fun onCreateView( |
|||
inflater: LayoutInflater, container: ViewGroup?, |
|||
savedInstanceState: Bundle? |
|||
): View? { |
|||
binding = DialogPermissionsBinding.inflate(layoutInflater, container, false) |
|||
return binding.root |
|||
} |
|||
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|||
super.onViewCreated(view, savedInstanceState) |
|||
|
|||
} |
|||
|
|||
override fun onResume() { |
|||
super.onResume() |
|||
updateStorageState() |
|||
} |
|||
|
|||
private fun updateStorageState() { |
|||
|
|||
|
|||
// radio states |
|||
arrayOf( |
|||
binding.noAccessCheck, |
|||
binding.manageAllPermsCheck, |
|||
binding.manageMediaPermsCheck |
|||
).forEach { |
|||
it.isChecked = false |
|||
} |
|||
|
|||
when { |
|||
Permissions.hasAllAccess(requireActivity()) -> binding.manageAllPermsCheck.isChecked = true |
|||
Permissions.hasAnyFileFineAccess(requireActivity()) -> binding.manageMediaPermsCheck.isChecked = true |
|||
else -> binding.noAccessCheck.isChecked = true |
|||
} |
|||
|
|||
// media permission states |
|||
binding.manageMediaVideo.isEnabled = !Permissions.hasAllAccess(requireActivity()) && !Permissions.hasVideoPermission(requireActivity()) |
|||
binding.manageMediaAudio.isEnabled = !Permissions.hasAllAccess(requireActivity()) && !Permissions.hasAudioPermission(requireActivity()) |
|||
|
|||
//backgrounds |
|||
binding.manageMediaPermsCheck.setBackgroundResource(defaultBackground) |
|||
|
|||
|
|||
// explanation text state |
|||
binding.fileAccessExplanation.text = when { |
|||
Permissions.hasAllAccess(requireActivity()) -> getString(R.string.permission_onboarding_perm_all) |
|||
Permissions.hasAnyFileFineAccess(requireActivity()) -> getString(R.string.permission_onboarding_perm_media) |
|||
else -> getString(R.string.permission_expanation_no_allow) |
|||
} |
|||
binding.fileAccessExplanation.setCompoundDrawablesRelativeWithIntrinsicBounds(when { |
|||
Permissions.hasAllAccess(requireActivity()) -> ContextCompat.getDrawable(requireActivity(), R.drawable.ic_perm_all) |
|||
Permissions.hasAnyFileFineAccess(requireActivity()) -> ContextCompat.getDrawable(requireActivity(), R.drawable.ic_perm_media) |
|||
else -> ContextCompat.getDrawable(requireActivity(), R.drawable.ic_perm_none) |
|||
}, null, null, null) |
|||
|
|||
|
|||
//warning visibility |
|||
binding.allAccessWarning.setInvisible() |
|||
binding.allAccessWarning.text = when { |
|||
Permissions.hasAllAccess(requireActivity()) -> getString(R.string.permission_media_warning) |
|||
Permissions.hasAnyFileFineAccess(requireActivity()) -> getString(R.string.permission_all_warning) |
|||
else -> "" |
|||
} |
|||
|
|||
|
|||
//media permission icons |
|||
binding.manageMediaVideo.setImageDrawable( |
|||
ContextCompat.getDrawable( |
|||
requireActivity(), |
|||
if (Permissions.hasVideoPermission(requireActivity())) R.drawable.ic_permission_media_video else R.drawable.ic_permission_media_video_denied |
|||
) |
|||
) |
|||
binding.manageMediaAudio.setImageDrawable( |
|||
ContextCompat.getDrawable( |
|||
requireActivity(), |
|||
if (Permissions.hasAudioPermission(requireActivity())) R.drawable.ic_permission_media_audio else R.drawable.ic_permission_media_audio_denied |
|||
) |
|||
) |
|||
|
|||
//click listeners |
|||
binding.noAccessCheck.setOnClickListener { |
|||
if (Permissions.hasAllAccess(requireActivity()) || Permissions.hasAnyFileFineAccess( |
|||
requireActivity() |
|||
) |
|||
) { |
|||
(it as RadioButton).isChecked = false |
|||
when { |
|||
Permissions.hasAllAccess(requireActivity()) -> binding.manageAllPermsCheck |
|||
else -> binding.manageMediaPermsCheck |
|||
}.background = ContextCompat.getDrawable(requireActivity(), R.drawable.rounded_corners_permissions_warning) |
|||
showWarning() |
|||
} |
|||
} |
|||
|
|||
binding.manageAllPermsCheck.setOnClickListener { |
|||
if (Permissions.hasAnyFileFineAccess(requireActivity())) { |
|||
(it as RadioButton).isChecked = false |
|||
binding.manageMediaPermsCheck.background = ContextCompat.getDrawable(requireActivity(), R.drawable.rounded_corners_permissions_warning) |
|||
showWarning() |
|||
} else |
|||
requireActivity().lifecycleScope.launch { |
|||
val uri = Uri.fromParts(SCHEME_PACKAGE, requireContext().packageName, null) |
|||
val intent = Intent( |
|||
android.provider.Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, |
|||
uri |
|||
) |
|||
startActivity(intent) |
|||
} |
|||
} |
|||
|
|||
binding.manageMediaPermsCheck.setOnClickListener { |
|||
if (Permissions.hasAnyFileFineAccess(requireActivity())) { |
|||
Permissions.showAppSettingsPage(requireActivity()) |
|||
(it as RadioButton).isChecked = false |
|||
} else if (Permissions.hasAllAccess(requireActivity())) { |
|||
(it as RadioButton).isChecked = false |
|||
binding.manageAllPermsCheck.background = ContextCompat.getDrawable(requireActivity(), R.drawable.rounded_corners_permissions_warning) |
|||
showWarning() |
|||
} else |
|||
ActivityCompat.requestPermissions( |
|||
requireActivity(), arrayOf( |
|||
Manifest.permission.READ_MEDIA_VIDEO, |
|||
Manifest.permission.READ_MEDIA_AUDIO |
|||
), Permissions.FINE_STORAGE_PERMISSION_REQUEST_CODE |
|||
) |
|||
} |
|||
|
|||
binding.manageMediaAudio.setOnClickListener { |
|||
if (!Permissions.hasAllAccess(requireActivity()) && !Permissions.hasAudioPermission(requireActivity())) { |
|||
ActivityCompat.requestPermissions( |
|||
requireActivity(), arrayOf( |
|||
Manifest.permission.READ_MEDIA_AUDIO |
|||
), Permissions.FINE_STORAGE_PERMISSION_REQUEST_CODE |
|||
) |
|||
} |
|||
} |
|||
|
|||
binding.manageMediaVideo.setOnClickListener { |
|||
if (!Permissions.hasAllAccess(requireActivity()) && !Permissions.hasVideoPermission(requireActivity())) { |
|||
ActivityCompat.requestPermissions( |
|||
requireActivity(), arrayOf( |
|||
Manifest.permission.READ_MEDIA_VIDEO |
|||
), Permissions.FINE_STORAGE_PERMISSION_REQUEST_CODE |
|||
) |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
private fun showWarning() { |
|||
binding.allAccessWarning.translationY = 100.dp.toFloat() |
|||
binding.allAccessWarning.setVisible() |
|||
binding.allAccessWarning.animate().translationY(0F).setDuration(300).start() |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Loading…
Reference in new issue