Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
F
FileManager
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yanglin
FileManager
Commits
38b12d9c
Commit
38b12d9c
authored
Apr 22, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理储存权限
parent
290dd04c
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
416 additions
and
157 deletions
+416
-157
build.gradle
app/build.gradle
+3
-6
HomeActivity.kt
...src/main/java/com/xm/test/myfile/activity/HomeActivity.kt
+70
-47
FileManagerFragment.kt
...n/java/com/xm/test/myfile/fragment/FileManagerFragment.kt
+13
-13
HomeFragment.kt
...src/main/java/com/xm/test/myfile/fragment/HomeFragment.kt
+13
-15
ActivityLauncher.kt
...src/main/java/com/xm/test/myfile/util/ActivityLauncher.kt
+47
-0
PermissionUtil.kt
app/src/main/java/com/xm/test/myfile/util/PermissionUtil.kt
+25
-21
StorePermissionEx.kt
.../xm/test/myfile/util/storePermission/StorePermissionEx.kt
+72
-0
StorePermissionVersion.kt
...est/myfile/util/storePermission/StorePermissionVersion.kt
+24
-0
ManageStorageDialog.kt
.../main/java/com/xm/test/myfile/view/ManageStorageDialog.kt
+33
-0
QuitDialog.kt
app/src/main/java/com/xm/test/myfile/view/QuitDialog.kt
+0
-1
bg_corners_286efd.xml
app/src/main/res/drawable/bg_corners_286efd.xml
+6
-0
bg_corners_white_tlf.xml
app/src/main/res/drawable/bg_corners_white_tlf.xml
+7
-0
bottom_bar_layout.xml
app/src/main/res/layout/bottom_bar_layout.xml
+2
-2
dialog_manage_storage.xml
app/src/main/res/layout/dialog_manage_storage.xml
+51
-0
start_app_layout.xml
app/src/main/res/layout/start_app_layout.xml
+5
-2
title_bar_layout.xml
app/src/main/res/layout/title_bar_layout.xml
+45
-40
permissions.png
app/src/main/res/mipmap-hdpi/permissions.png
+0
-0
permissions.png
app/src/main/res/mipmap-mdpi/permissions.png
+0
-0
permissions.png
app/src/main/res/mipmap-xhdpi/permissions.png
+0
-0
permissions.png
app/src/main/res/mipmap-xxhdpi/permissions.png
+0
-0
permissions.png
app/src/main/res/mipmap-xxxhdpi/permissions.png
+0
-0
build.gradle
build.gradle
+0
-10
No files found.
app/build.gradle
View file @
38b12d9c
plugins
{
alias
(
libs
.
plugins
.
androidApplication
)
alias
(
libs
.
plugins
.
jetbrainsKotlinAndroid
)
id
'applovin-quality-service'
}
applovin
{
apiKey
"7M6t_fBDFPKdlDdekL1bw1OntM7gd4Vk5yK_p7yEdl9BCKCfGZpmZMvL2LDHcuNGWIHLXPD0w_SFDDv94WMaSw"
}
android
{
namespace
'com.xm.test.myfile'
...
...
@@ -66,7 +63,9 @@ dependencies {
androidTestImplementation
libs
.
androidx
.
junit
androidTestImplementation
libs
.
androidx
.
espresso
.
core
//noinspection GradleDependency
implementation
'androidx.viewpager2:viewpager2:1.0.0'
//Lottie动画
implementation
"com.airbnb.android:lottie:3.6.0"
...
...
@@ -106,7 +105,5 @@ dependencies {
implementation
(
"androidx.datastore:datastore-preferences:1.0.0"
)
implementation
(
"com.facebook.android:facebook-android-sdk:[8,9)"
)
}
app/src/main/java/com/xm/test/myfile/activity/HomeActivity.kt
View file @
38b12d9c
...
...
@@ -3,10 +3,9 @@ package com.xm.test.myfile.activity
import
android.Manifest
import
android.os.Build
import
android.os.Bundle
import
android.os.Environment
import
android.view.View
import
android.widget.RadioButton
import
android.widget.RadioGroup
import
androidx.activity.OnBackPressedCallback
import
androidx.activity.addCallback
import
androidx.activity.enableEdgeToEdge
import
androidx.appcompat.app.AppCompatActivity
...
...
@@ -15,20 +14,23 @@ import androidx.core.view.WindowInsetsCompat
import
androidx.fragment.app.Fragment
import
androidx.viewpager2.adapter.FragmentStateAdapter
import
androidx.viewpager2.widget.ViewPager2
import
com.permissionx.guolindev.PermissionX
import
com.xm.test.myfile.R
import
com.xm.test.myfile.databinding.ActivityHomeBinding
import
com.xm.test.myfile.fragment.FileManagerFragment
import
com.xm.test.myfile.fragment.HomeFragment
import
com.xm.test.myfile.fragment.InternalStorageFragment
import
com.xm.test.myfile.
notification.NotificationHelper.postNotification
import
com.xm.test.myfile.
util.ActivityLauncher
import
com.xm.test.myfile.util.PermissionUtil
import
com.xm.test.myfile.util.storePermission.StorePermissionEx.requestStorePermission
import
com.xm.test.myfile.util.storePermission.StorePermissionVersion
import
com.xm.test.myfile.view.ManageStorageDialog.showManageStorageDialog
import
com.xm.test.myfile.view.QuitDialog.showQuitDialog
class
HomeActivity
:
AppCompatActivity
()
{
var
mViewPage
:
ViewPager2
?
=
null
private
lateinit
var
binding
:
ActivityHomeBinding
private
lateinit
var
launcher
:
ActivityLauncher
companion
object
{
var
isPermission
=
false
...
...
@@ -42,6 +44,7 @@ class HomeActivity : AppCompatActivity() {
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
enableEdgeToEdge
()
launcher
=
ActivityLauncher
(
this
)
binding
=
ActivityHomeBinding
.
inflate
(
layoutInflater
)
setContentView
(
binding
.
root
)
ViewCompat
.
setOnApplyWindowInsetsListener
(
findViewById
(
R
.
id
.
main
))
{
v
,
insets
->
...
...
@@ -60,10 +63,6 @@ class HomeActivity : AppCompatActivity() {
list
.
add
(
HomeFragment
())
list
.
add
(
InternalStorageFragment
())
list
.
add
(
FileManagerFragment
())
getPermission
()
postNotification
(
11001
)
this
.
mViewPage
?.
adapter
=
object
:
FragmentStateAdapter
(
this
)
{
override
fun
getItemCount
():
Int
{
return
list
.
size
...
...
@@ -76,21 +75,26 @@ class HomeActivity : AppCompatActivity() {
this
.
mViewPage
?.
registerOnPageChangeCallback
(
object
:
ViewPager2
.
OnPageChangeCallback
()
{
override
fun
onPageSelected
(
position
:
Int
)
{
super
.
onPageSelected
(
position
)
if
(
position
==
0
)
{
findViewById
<
RadioButton
>(
R
.
id
.
radio_home_btn
).
isChecked
=
true
findViewById
<
RadioButton
>(
R
.
id
.
radio_file_manage_btn
).
isChecked
=
false
findViewById
<
RadioButton
>(
R
.
id
.
radio_view_btn
).
isChecked
=
false
}
else
if
(
position
==
1
)
{
findViewById
<
RadioButton
>(
R
.
id
.
radio_home_btn
).
isChecked
=
false
findViewById
<
RadioButton
>(
R
.
id
.
radio_view_btn
).
isChecked
=
true
findViewById
<
RadioButton
>(
R
.
id
.
radio_file_manage_btn
).
isChecked
=
false
}
else
if
(
position
==
2
)
{
findViewById
<
RadioButton
>(
R
.
id
.
radio_home_btn
).
isChecked
=
false
findViewById
<
RadioButton
>(
R
.
id
.
radio_view_btn
).
isChecked
=
false
findViewById
<
RadioButton
>(
R
.
id
.
radio_file_manage_btn
).
isChecked
=
true
when
(
position
)
{
0
->
{
findViewById
<
RadioButton
>(
R
.
id
.
radio_home_btn
).
isChecked
=
true
findViewById
<
RadioButton
>(
R
.
id
.
radio_file_manage_btn
).
isChecked
=
false
findViewById
<
RadioButton
>(
R
.
id
.
radio_view_btn
).
isChecked
=
false
}
1
->
{
findViewById
<
RadioButton
>(
R
.
id
.
radio_home_btn
).
isChecked
=
false
findViewById
<
RadioButton
>(
R
.
id
.
radio_view_btn
).
isChecked
=
true
findViewById
<
RadioButton
>(
R
.
id
.
radio_file_manage_btn
).
isChecked
=
false
}
2
->
{
findViewById
<
RadioButton
>(
R
.
id
.
radio_home_btn
).
isChecked
=
false
findViewById
<
RadioButton
>(
R
.
id
.
radio_view_btn
).
isChecked
=
false
findViewById
<
RadioButton
>(
R
.
id
.
radio_file_manage_btn
).
isChecked
=
true
}
}
}
...
...
@@ -118,41 +122,60 @@ class HomeActivity : AppCompatActivity() {
finish
()
}
}
storePermission
()
}
fun
getPermission
()
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
TIRAMISU
)
{
isPermission
=
false
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
R
&&
!
isPermission
)
{
PermissionX
.
init
(
this
).
permissions
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
).
request
{
allGranted
,
grantedList
,
deniedList
->
if
(
allGranted
)
{
isPermission
=
true
}
else
{
isPermission
=
false
private
fun
storePermission
()
{
requestStorePermission
(
launcher
,
object
:
StorePermissionVersion
{
override
fun
version13Action
(
manage
:
Boolean
,
haveRequest
:
Boolean
,
requestManager
:
()
->
Unit
)
{
when
{
manage
->
{
isPermission
=
true
}
!
manage
&&
!
haveRequest
->
{
showManageStorageDialog
{
requestManager
.
invoke
()
}
}
}
}
}
else
{
PermissionX
.
init
(
this
).
permissions
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
).
request
{
allGranted
,
grantedList
,
deniedList
->
if
(
allGranted
)
{
isPermission
=
true
}
else
{
isPermission
=
false
override
fun
version11Action
(
storage
:
Boolean
,
manage
:
Boolean
,
haveRequest
:
Boolean
,
requestManager
:
()
->
Unit
)
{
when
{
storage
&&
!
manage
&&
!
haveRequest
->
{
showManageStorageDialog
{
requestManager
.
invoke
()
}
}
storage
&&
manage
->
{
isPermission
=
true
}
}
}
}
override
fun
version11BelowAction
(
result
:
Boolean
)
{
isPermission
=
result
}
})
}
override
fun
onResume
()
{
super
.
onResume
()
if
(
PermissionUtil
.
checkGrantedPermission
(
this
))
{
isPermission
=
true
}
storePermission
()
}
}
\ No newline at end of file
app/src/main/java/com/xm/test/myfile/fragment/FileManagerFragment.kt
View file @
38b12d9c
...
...
@@ -128,19 +128,19 @@ class FileManagerFragment : Fragment(), View.OnClickListener {
}
private
fun
checkPermission
():
Boolean
{
if
(!
PermissionUtil
.
checkGrantedPermission
(
activity
))
{
val
customDialog
=
CustomDialog
(
context
)
customDialog
.
setsConfirm
(
View
.
OnClickListener
{
PermissionUtil
.
requestPermission
(
context
)
customDialog
.
dismiss
()
}).
setsCancel
(
View
.
OnClickListener
{
customDialog
.
dismiss
()
}).
show
()
customDialog
.
isShowEditText
(
false
)
customDialog
.
setsTitle
(
"not permission"
)
customDialog
.
setsHint
(
"Please grant file management permissions"
)
return
false
}
//
if (!PermissionUtil.checkGrantedPermission(activity)) {
//
val customDialog = CustomDialog(context)
//
customDialog.setsConfirm(View.OnClickListener {
//
PermissionUtil.requestPermission(context)
//
customDialog.dismiss()
//
}).setsCancel(View.OnClickListener {
//
customDialog.dismiss()
//
}).show()
//
customDialog.isShowEditText(false)
//
customDialog.setsTitle("not permission")
//
customDialog.setsHint("Please grant file management permissions")
//
return false
//
}
return
true
}
...
...
app/src/main/java/com/xm/test/myfile/fragment/HomeFragment.kt
View file @
38b12d9c
...
...
@@ -49,8 +49,6 @@ class HomeFragment : Fragment(), OnClickListener {
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
}
override
fun
onCreateView
(
...
...
@@ -124,19 +122,19 @@ class HomeFragment : Fragment(), OnClickListener {
}
private
fun
checkPermission
():
Boolean
{
if
(!
PermissionUtil
.
checkGrantedPermission
(
activity
))
{
val
customDialog
=
CustomDialog
(
context
)
customDialog
.
setsConfirm
(
OnClickListener
{
PermissionUtil
.
requestPermission
(
context
)
customDialog
.
dismiss
()
}).
setsCancel
(
OnClickListener
{
customDialog
.
dismiss
()
}).
show
()
customDialog
.
isShowEditText
(
false
)
customDialog
.
setsTitle
(
"not permission"
)
customDialog
.
setsHint
(
"Please grant fileAll management permissions"
)
return
false
}
//
if (!PermissionUtil.checkGrantedPermission(activity)) {
//
val customDialog = CustomDialog(context)
//
customDialog.setsConfirm(OnClickListener {
//
PermissionUtil.requestPermission(context)
//
customDialog.dismiss()
//
}).setsCancel(OnClickListener {
//
customDialog.dismiss()
//
}).show()
//
customDialog.isShowEditText(false)
//
customDialog.setsTitle("not permission")
//
customDialog.setsHint("Please grant fileAll management permissions")
//
return false
//
}
return
true
}
...
...
app/src/main/java/com/xm/test/myfile/util/ActivityLauncher.kt
0 → 100644
View file @
38b12d9c
package
com.xm.test.myfile.util
import
android.content.Intent
import
androidx.activity.result.ActivityResult
import
androidx.activity.result.ActivityResultCallback
import
androidx.activity.result.ActivityResultCaller
import
androidx.activity.result.contract.ActivityResultContracts
class
ActivityLauncher
(
activityResultCaller
:
ActivityResultCaller
)
{
//region 权限
private
var
permissionCallback
:
ActivityResultCallback
<
Map
<
String
,
Boolean
>>?
=
null
private
val
permissionLauncher
=
activityResultCaller
.
registerForActivityResult
(
ActivityResultContracts
.
RequestMultiplePermissions
())
{
result
:
Map
<
String
,
Boolean
>
->
permissionCallback
?.
onActivityResult
(
result
)
}
fun
launch
(
permissionArray
:
Array
<
String
>,
permissionCallback
:
ActivityResultCallback
<
Map
<
String
,
Boolean
>>?
)
{
this
.
permissionCallback
=
permissionCallback
permissionLauncher
.
launch
(
permissionArray
)
}
//endregion
//region intent跳转
private
var
activityResultCallback
:
ActivityResultCallback
<
ActivityResult
>?
=
null
private
val
intentLauncher
=
activityResultCaller
.
registerForActivityResult
(
ActivityResultContracts
.
StartActivityForResult
())
{
activityResult
:
ActivityResult
->
activityResultCallback
?.
onActivityResult
(
activityResult
)
}
/**
* it.resultCode == Activity.RESULT_OK
*/
fun
launch
(
intent
:
Intent
,
activityResultCallback
:
ActivityResultCallback
<
ActivityResult
>?
=
null
)
{
this
.
activityResultCallback
=
activityResultCallback
intentLauncher
.
launch
(
intent
)
}
//endregion
}
\ No newline at end of file
app/src/main/java/com/xm/test/myfile/util/PermissionUtil.kt
View file @
38b12d9c
...
...
@@ -18,22 +18,22 @@ import com.xm.test.myfile.activity.HomeActivity
object
PermissionUtil
{
var
LOCATION_PERMISSION
=
false
fun
requestPermission
(
context
:
Context
?){
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
TIRAMISU
){
fun
requestPermission
(
context
:
Context
?)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
TIRAMISU
)
{
val
intent
=
Intent
().
apply
{
action
=
Settings
.
ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
data
=
Uri
.
fromParts
(
"package"
,
context
?.
packageName
,
null
)
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
}
context
?.
startActivity
(
intent
)
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
R
)
{
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
R
)
{
val
intent
=
Intent
().
apply
{
action
=
Settings
.
ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
data
=
Uri
.
fromParts
(
"package"
,
context
?.
packageName
,
null
)
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
}
context
?.
startActivity
(
intent
)
}
else
{
}
else
{
val
intent
=
Intent
().
apply
{
action
=
Settings
.
ACTION_APPLICATION_DETAILS_SETTINGS
data
=
Uri
.
fromParts
(
"package"
,
context
?.
packageName
,
null
)
...
...
@@ -42,30 +42,34 @@ object PermissionUtil {
}
}
fun
checkGrantedPermission
(
activity
:
ComponentActivity
?)
:
Boolean
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
TIRAMISU
){
//TODO android 14以上
HomeActivity
.
isPermission
=
Environment
.
isExternalStorageManager
()
return
HomeActivity
.
isPermission
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
R
)
{
HomeActivity
.
isPermission
=
Environment
.
isExternalStorageManager
()
&&
ActivityCompat
.
checkSelfPermission
(
activity
!!
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
)
==
PackageManager
.
PERMISSION_GRANTED
return
HomeActivity
.
isPermission
}
else
{
HomeActivity
.
isPermission
=
ActivityCompat
.
checkSelfPermission
(
activity
!!
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
)
==
PackageManager
.
PERMISSION_GRANTED
return
HomeActivity
.
isPermission
fun
checkGrantedPermission
(
activity
:
ComponentActivity
):
Boolean
{
HomeActivity
.
isPermission
=
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
TIRAMISU
)
{
Environment
.
isExternalStorageManager
()
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
R
)
{
val
flag1
=
Environment
.
isExternalStorageManager
()
val
flag2
=
ActivityCompat
.
checkSelfPermission
(
activity
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
)
==
PackageManager
.
PERMISSION_GRANTED
flag1
&&
flag2
}
else
{
ActivityCompat
.
checkSelfPermission
(
activity
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
)
==
PackageManager
.
PERMISSION_GRANTED
}
return
HomeActivity
.
isPermission
}
fun
requestLocationPermission
(
context
:
FragmentActivity
?){
fun
requestLocationPermission
(
context
:
FragmentActivity
?)
{
PermissionX
.
init
(
context
!!
).
permissions
(
Manifest
.
permission
.
ACCESS_FINE_LOCATION
,
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
,
).
request
(
RequestCallback
{
allGranted
,
grantedList
,
deniedList
->
if
(
allGranted
){
).
request
(
RequestCallback
{
allGranted
,
grantedList
,
deniedList
->
if
(
allGranted
)
{
LOCATION_PERMISSION
=
true
}
else
{
}
else
{
LOCATION_PERMISSION
=
false
}
})
...
...
app/src/main/java/com/xm/test/myfile/util/storePermission/StorePermissionEx.kt
0 → 100644
View file @
38b12d9c
package
com.xm.test.myfile.util.storePermission
import
android.Manifest
import
android.content.Context
import
android.content.Intent
import
android.net.Uri
import
android.os.Build
import
android.os.Environment
import
android.provider.Settings
import
androidx.annotation.RequiresApi
import
com.xm.test.myfile.util.ActivityLauncher
object
StorePermissionEx
{
@RequiresApi
(
Build
.
VERSION_CODES
.
R
)
fun
settingManageExternalStorage
(
uri
:
Uri
?
=
null
):
Intent
{
val
intent
=
Intent
(
Settings
.
ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
,
uri
)
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
return
intent
}
fun
Context
.
requestStorePermission
(
activityLauncher
:
ActivityLauncher
,
storePermissionVersion
:
StorePermissionVersion
,
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
TIRAMISU
)
{
val
requestManager
=
{
val
uri
=
Uri
.
parse
(
"package:$packageName"
)
val
intent
=
settingManageExternalStorage
(
uri
)
activityLauncher
.
launch
(
intent
)
{
val
flag
=
Environment
.
isExternalStorageManager
()
storePermissionVersion
.
version13Action
(
flag
,
true
)
{}
}
}
val
flag
=
Environment
.
isExternalStorageManager
()
storePermissionVersion
.
version13Action
(
flag
,
false
,
requestManager
)
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
R
)
{
activityLauncher
.
launch
(
arrayOf
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
)
{
map
->
val
allGranted
=
map
.
values
.
all
{
it
}
val
manage
=
Environment
.
isExternalStorageManager
()
val
requestManager
=
{
val
uri
=
Uri
.
parse
(
"package:$packageName"
)
val
intent
=
settingManageExternalStorage
(
uri
)
activityLauncher
.
launch
(
intent
)
{
val
flag
=
Environment
.
isExternalStorageManager
()
storePermissionVersion
.
version11Action
(
true
,
flag
,
true
)
{}
}
}
storePermissionVersion
.
version11Action
(
allGranted
,
manage
,
false
,
requestManager
)
}
}
else
{
activityLauncher
.
launch
(
arrayOf
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
)
{
map
->
val
allGranted
=
map
.
values
.
all
{
it
}
storePermissionVersion
.
version11BelowAction
(
allGranted
)
}
}
}
}
\ No newline at end of file
app/src/main/java/com/xm/test/myfile/util/storePermission/StorePermissionVersion.kt
0 → 100644
View file @
38b12d9c
package
com.xm.test.myfile.util.storePermission
interface
StorePermissionVersion
{
/**
* Android 13回调
*/
abstract
fun
version13Action
(
manage
:
Boolean
,
haveRequest
:
Boolean
,
requestManager
:
()
->
Unit
)
/**
* Android 11回调
*/
abstract
fun
version11Action
(
storage
:
Boolean
,
manage
:
Boolean
,
haveRequest
:
Boolean
,
requestManager
:
()
->
Unit
)
/**
* Android 11以下回调
*/
abstract
fun
version11BelowAction
(
result
:
Boolean
)
}
\ No newline at end of file
app/src/main/java/com/xm/test/myfile/view/ManageStorageDialog.kt
0 → 100644
View file @
38b12d9c
package
com.xm.test.myfile.view
import
android.app.Activity
import
android.content.Context
import
android.view.Gravity
import
android.view.LayoutInflater
import
android.view.ViewGroup
import
androidx.appcompat.app.AlertDialog
import
com.xm.test.myfile.databinding.DialogManageStorageBinding
object
ManageStorageDialog
{
fun
Context
.
showManageStorageDialog
(
action
:
()
->
Unit
)
{
val
binding
=
DialogManageStorageBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
val
dialog
=
AlertDialog
.
Builder
(
this
).
setView
(
binding
.
root
).
create
()
dialog
.
setCanceledOnTouchOutside
(
false
)
dialog
.
show
()
//修改dialog的尺寸
val
lp
=
dialog
.
window
?.
attributes
// lp?.horizontalMargin = this.resources.getDimension(R.dimen.dp_16)
// lp?.width = ViewGroup.LayoutParams.MATCH_PARENT
lp
?.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
lp
?.
gravity
=
Gravity
.
BOTTOM
dialog
.
window
?.
attributes
=
lp
dialog
.
window
?.
setBackgroundDrawableResource
(
android
.
R
.
color
.
transparent
)
binding
.
tvAllow
.
setOnClickListener
{
dialog
.
dismiss
()
action
.
invoke
()
}
}
}
\ No newline at end of file
app/src/main/java/com/xm/test/myfile/view/QuitDialog.kt
View file @
38b12d9c
...
...
@@ -6,7 +6,6 @@ import android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
androidx.appcompat.app.AlertDialog
import
com.xm.test.myfile.R
import
com.xm.test.myfile.ad.MaxAdUtils
import
com.xm.test.myfile.databinding.DialogWhetherQuitBinding
import
kotlinx.coroutines.Dispatchers
...
...
app/src/main/res/drawable/bg_corners_286efd.xml
0 → 100644
View file @
38b12d9c
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"#286EFD"
/>
<corners
android:radius=
"10dp"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable/bg_corners_white_tlf.xml
0 → 100644
View file @
38b12d9c
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"@color/white"
/>
<corners
android:topLeftRadius=
"10dp"
android:topRightRadius=
"10dp"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/bottom_bar_layout.xml
View file @
38b12d9c
...
...
@@ -44,7 +44,7 @@
android:layout_gravity=
"center"
android:layout_weight=
"0.7"
android:src=
"@drawable/ic_rename"
tools:ignore=
"NestedWeights"
/>
tools:ignore=
"
ContentDescription,
NestedWeights"
/>
<TextView
android:layout_width=
"wrap_content"
...
...
@@ -68,7 +68,7 @@
android:layout_gravity=
"center"
android:layout_weight=
"0.7"
android:src=
"@drawable/ic_copy"
tools:ignore=
"NestedWeights"
/>
tools:ignore=
"
ContentDescription,
NestedWeights"
/>
<TextView
android:layout_width=
"wrap_content"
...
...
app/src/main/res/layout/dialog_manage_storage.xml
0 → 100644
View file @
38b12d9c
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10dp"
android:background=
"@drawable/bg_corners_white_tlf"
android:orientation=
"vertical"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"28dp"
android:text=
"You need to get storage permissions"
android:textSize=
"17sp"
android:textStyle=
"bold"
tools:ignore=
"HardcodedText"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"16dp"
android:layout_marginTop=
"21dp"
android:text=
"If you want to use this function, pleaseturn on the storage of KeepFiles in thesettings of your mobile phone Permissions"
tools:ignore=
"HardcodedText"
/>
<ImageView
android:layout_width=
"match_parent"
android:layout_height=
"257dp"
android:layout_marginHorizontal=
"40dp"
android:layout_marginTop=
"40dp"
android:src=
"@mipmap/permissions"
tools:ignore=
"ContentDescription"
/>
<TextView
android:id=
"@+id/tv_allow"
android:layout_width=
"224dp"
android:layout_height=
"36dp"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"8dp"
android:layout_marginBottom=
"50dp"
android:background=
"@drawable/bg_corners_286efd"
android:gravity=
"center"
android:text=
"ALLOW"
android:textColor=
"@color/white"
android:textSize=
"17sp"
android:textStyle=
"bold"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/start_app_layout.xml
View file @
38b12d9c
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#6F98ED"
>
...
...
@@ -21,7 +22,8 @@
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"16dp"
android:layout_marginBottom=
"16dp"
android:src=
"@mipmap/start_icon"
/>
android:src=
"@mipmap/start_icon"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
...
...
@@ -31,7 +33,8 @@
android:text=
"File Manager Ultra"
android:textColor=
"@color/white"
android:textSize=
"24sp"
android:textStyle=
"bold"
/>
android:textStyle=
"bold"
tools:ignore=
"HardcodedText"
/>
<TextView
android:layout_width=
"wrap_content"
...
...
app/src/main/res/layout/title_bar_layout.xml
View file @
38b12d9c
...
...
@@ -14,71 +14,76 @@
android:id=
"@+id/btn_cancel"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@drawable/ic_cancel"
android:layout_alignParentStart=
"true"
android:layout_centerVertical=
"true"
android:layout_marginStart=
"16dp"
android:src=
"@drawable/ic_cancel"
android:visibility=
"gone"
android:layout_centerVertical=
"true"
android:layout_alignParentStart=
"true"
tools:ignore=
"ContentDescription"
/>
<ImageView
android:id=
"@+id/btn_quit"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@drawable/ic_quit"
android:layout_marginStart=
"16dp"
android:layout_centerVertical=
"true"
android:layout_alignParentStart=
"true"
android:layout_centerVertical=
"true"
android:layout_marginStart=
"16dp"
android:src=
"@drawable/ic_quit"
tools:ignore=
"ContentDescription"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_alignParentEnd=
"true"
android:orientation=
"horizontal"
android:layout_centerVertical=
"true"
android:gravity=
"center"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
>
android:orientation=
"horizontal"
>
<ImageView
android:id=
"@+id/btn_new"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@drawable/ic_resource_new"
android:visibility=
"gone"
android:layout_marginEnd=
"16dp"
/>
tools:ignore=
"ContentDescription"
/>
<ImageView
android:id=
"@+id/btn_edit"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@drawable/ic_edit"
android:visibility=
"gone"
android:layout_marginEnd=
"16dp"
/>
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_alignParentEnd=
"true"
android:orientation=
"horizontal"
android:layout_centerVertical=
"true"
android:gravity=
"center"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
>
android:orientation=
"horizontal"
>
<ImageView
android:id=
"@+id/btn_delete"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@drawable/ic_delete"
android:visibility=
"gone"
android:layout_marginEnd=
"16dp"
/>
tools:ignore=
"ContentDescription"
/>
<ImageView
android:id=
"@+id/btn_share"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:
visibility=
"gone
"
android:
layout_marginEnd=
"16dp
"
android:src=
"@drawable/ic_share"
android:layout_marginEnd=
"16dp"
/>
android:visibility=
"gone"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
...
...
@@ -86,32 +91,35 @@
android:id=
"@+id/title_bar_text"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textSize=
"18dp"
android:textStyle=
"bold"
android:layout_centerInParent=
"true"
android:textColor=
"@color/black"
/>
android:textColor=
"@color/black"
android:textSize=
"18sp"
android:textStyle=
"bold"
tools:ignore=
"RelativeOverlap"
/>
</RelativeLayout>
<TextView
android:id=
"@+id/current_file_path"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/top_title_bar"
android:text=
"Internal Storage/"
android:textSize=
"16dp"
android:layout_marginStart=
"16dp"
android:textColor=
"@color/black"
/>
android:text=
"Internal Storage/"
android:textColor=
"@color/black"
android:textSize=
"16sp"
tools:ignore=
"HardcodedText"
/>
<RelativeLayout
android:id=
"@+id/switch_and_select_layout"
android:layout_below=
"@+id/current_file_path"
android:layout_width=
"match_parent"
android:layout_height=
"30dp"
android:layout_below=
"@+id/current_file_path"
android:layout_marginStart=
"16dp"
android:layout_marginEnd=
"16dp"
android:layout_marginTop=
"12dp"
android:
visibility=
"gone
"
android:
layout_height=
"30dp
"
>
android:
layout_marginEnd=
"16dp
"
android:
visibility=
"gone
"
>
<LinearLayout
android:id=
"@+id/check_item_all_btn"
...
...
@@ -123,40 +131,37 @@
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:text=
"All"
android:textColor=
"#8B8B8B"
android:textSize=
"18dp"
android:textStyle=
"bold"
android:gravity=
"center"
/>
android:textStyle=
"bold"
/>
<CheckBox
android:id=
"@+id/checkbox_item_all"
android:layout_width=
"20dp"
android:layout_height=
"wrap_content"
android:button=
"@null"
android:layout_marginStart=
"8dp"
android:drawableStart=
"@drawable/bg_item_switch_selector"
/>
android:button=
"@null"
android:drawableStart=
"@drawable/bg_item_switch_selector"
/>
</LinearLayout>
<TextView
android:id=
"@+id/select_num"
android:layout_centerVertical=
"true"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentEnd=
"true"
android:layout_centerVertical=
"true"
android:text=
"@string/select_0"
android:textColor=
"#8B8B8B"
android:textSize=
"18
d
p"
android:textSize=
"18
s
p"
android:textStyle=
"bold"
android:text=
"@string/select_0"
/>
tools:ignore=
"RelativeOverlap"
/>
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/mipmap-hdpi/permissions.png
0 → 100644
View file @
38b12d9c
36.2 KB
app/src/main/res/mipmap-mdpi/permissions.png
0 → 100644
View file @
38b12d9c
19.3 KB
app/src/main/res/mipmap-xhdpi/permissions.png
0 → 100644
View file @
38b12d9c
43.7 KB
app/src/main/res/mipmap-xxhdpi/permissions.png
0 → 100644
View file @
38b12d9c
90.9 KB
app/src/main/res/mipmap-xxxhdpi/permissions.png
0 → 100644
View file @
38b12d9c
102 KB
build.gradle
View file @
38b12d9c
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
{
dependencies
{
classpath
"com.applovin.quality:AppLovinQualityServiceGradlePlugin:5.2.4"
}
}
plugins
{
alias
(
libs
.
plugins
.
androidApplication
)
apply
false
alias
(
libs
.
plugins
.
jetbrainsKotlinAndroid
)
apply
false
}
//apply plugin: 'applovin-quality-service'
//applovin {
// apiKey "7M6t_fBDFPKdlDdekL1bw1OntM7gd4Vk5yK_p7yEdl9BCKCfGZpmZMvL2LDHcuNGWIHLXPD0w_SFDDv94WMaSw"
//}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment