Added preference to acess all files permission
This commit is contained in:
parent
2669f2e44f
commit
224c22a5ff
5 changed files with 40 additions and 2 deletions
|
|
@ -320,7 +320,7 @@
|
||||||
<PersistentState>
|
<PersistentState>
|
||||||
<option name="values">
|
<option name="values">
|
||||||
<map>
|
<map>
|
||||||
<entry key="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/icons/material/materialicons/select_all/baseline_select_all_24.xml" />
|
<entry key="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/icons/material/materialicons/rule_folder/baseline_rule_folder_24.xml" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
</PersistentState>
|
</PersistentState>
|
||||||
|
|
@ -330,7 +330,7 @@
|
||||||
</option>
|
</option>
|
||||||
<option name="values">
|
<option name="values">
|
||||||
<map>
|
<map>
|
||||||
<entry key="outputName" value="ic_select_all" />
|
<entry key="outputName" value="ic_access_folder" />
|
||||||
<entry key="sourceFile" value="C:\Users\denis\Desktop\adaptiveproduct_youtube_foreground_color_108 (1).svg" />
|
<entry key="sourceFile" value="C:\Users\denis\Desktop\adaptiveproduct_youtube_foreground_color_108 (1).svg" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,20 @@
|
||||||
package com.deniscerri.ytdlnis.ui.more.settings
|
package com.deniscerri.ytdlnis.ui.more.settings
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Environment
|
||||||
|
import android.provider.Settings
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.os.LocaleListCompat
|
import androidx.core.os.LocaleListCompat
|
||||||
import androidx.preference.*
|
import androidx.preference.*
|
||||||
import com.deniscerri.ytdlnis.BuildConfig
|
import com.deniscerri.ytdlnis.BuildConfig
|
||||||
|
|
@ -22,6 +28,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
private var musicPath: Preference? = null
|
private var musicPath: Preference? = null
|
||||||
private var videoPath: Preference? = null
|
private var videoPath: Preference? = null
|
||||||
private var commandPath: Preference? = null
|
private var commandPath: Preference? = null
|
||||||
|
private var accessAllFiles : Preference? = null
|
||||||
private var incognito: SwitchPreferenceCompat? = null
|
private var incognito: SwitchPreferenceCompat? = null
|
||||||
private var preferredDownloadType : ListPreference? = null
|
private var preferredDownloadType : ListPreference? = null
|
||||||
private var downloadCard: SwitchPreferenceCompat? = null
|
private var downloadCard: SwitchPreferenceCompat? = null
|
||||||
|
|
@ -64,6 +71,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
musicPath = findPreference("music_path")
|
musicPath = findPreference("music_path")
|
||||||
videoPath = findPreference("video_path")
|
videoPath = findPreference("video_path")
|
||||||
commandPath = findPreference("command_path")
|
commandPath = findPreference("command_path")
|
||||||
|
accessAllFiles = findPreference("access_all_files")
|
||||||
incognito = findPreference("incognito")
|
incognito = findPreference("incognito")
|
||||||
preferredDownloadType = findPreference("preferred_download_type")
|
preferredDownloadType = findPreference("preferred_download_type")
|
||||||
downloadCard = findPreference("download_card")
|
downloadCard = findPreference("download_card")
|
||||||
|
|
@ -112,6 +120,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
if (preferences.getString("command_path", "")!!.isEmpty()) {
|
if (preferences.getString("command_path", "")!!.isEmpty()) {
|
||||||
editor.putString("command_path", getString(R.string.command_path))
|
editor.putString("command_path", getString(R.string.command_path))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((Build.VERSION.SDK_INT >= 30 && Environment.isExternalStorageManager()) ||
|
||||||
|
Build.VERSION.SDK_INT < 30) {
|
||||||
|
accessAllFiles!!.isVisible = false
|
||||||
|
}
|
||||||
|
|
||||||
editor.putBoolean("incognito", incognito!!.isChecked)
|
editor.putBoolean("incognito", incognito!!.isChecked)
|
||||||
editor.putString("preferred_download_type", preferredDownloadType!!.value)
|
editor.putString("preferred_download_type", preferredDownloadType!!.value)
|
||||||
editor.putBoolean("download_card", downloadCard!!.isChecked)
|
editor.putBoolean("download_card", downloadCard!!.isChecked)
|
||||||
|
|
@ -182,6 +196,15 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
commandPathResultLauncher.launch(intent)
|
commandPathResultLauncher.launch(intent)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
accessAllFiles!!.onPreferenceClickListener =
|
||||||
|
Preference.OnPreferenceClickListener {
|
||||||
|
val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
|
||||||
|
val uri = Uri.parse("package:" + requireContext().packageName)
|
||||||
|
intent.data = uri
|
||||||
|
startActivity(intent)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
incognito!!.onPreferenceChangeListener =
|
incognito!!.onPreferenceChangeListener =
|
||||||
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
|
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
|
||||||
val enable = newValue as Boolean
|
val enable = newValue as Boolean
|
||||||
|
|
|
||||||
5
app/src/main/res/drawable/ic_access_folder.xml
Normal file
5
app/src/main/res/drawable/ic_access_folder.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<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:colorAccent" android:pathData="M20,6h-8l-2,-2H4C2.9,4 2.01,4.9 2.01,6L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8C22,6.9 21.1,6 20,6zM7.83,16L5,13.17l1.41,-1.41l1.41,1.41l3.54,-3.54l1.41,1.41L7.83,16zM17.41,13L19,14.59L17.59,16L16,14.41L14.41,16L13,14.59L14.59,13L13,11.41L14.41,10L16,11.59L17.59,10L19,11.41L17.41,13z"/>
|
||||||
|
</vector>
|
||||||
|
|
@ -206,4 +206,6 @@
|
||||||
<string name="select">Select</string>
|
<string name="select">Select</string>
|
||||||
<string name="selected">Selected</string>
|
<string name="selected">Selected</string>
|
||||||
<string name="all_items_selected">All items selected</string>
|
<string name="all_items_selected">All items selected</string>
|
||||||
|
<string name="access_all_directories">Allow access to all directories</string>
|
||||||
|
<string name="access_all_directories_summary">Let the app download on directories that are restricted by default</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
app:title="@string/language" />
|
app:title="@string/language" />
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/directories">
|
<PreferenceCategory android:title="@string/directories">
|
||||||
|
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
app:icon="@drawable/ic_music_downloaded"
|
app:icon="@drawable/ic_music_downloaded"
|
||||||
app:key="music_path"
|
app:key="music_path"
|
||||||
|
|
@ -28,6 +30,12 @@
|
||||||
app:defaultValue="@string/command_path"
|
app:defaultValue="@string/command_path"
|
||||||
app:title="@string/command_directory" />
|
app:title="@string/command_directory" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
app:icon="@drawable/ic_access_folder"
|
||||||
|
app:key="access_all_files"
|
||||||
|
android:summary="@string/access_all_directories_summary"
|
||||||
|
app:title="@string/access_all_directories" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory app:title="@string/downloading">
|
<PreferenceCategory app:title="@string/downloading">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue