Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
e83f40d5
Commit
e83f40d5
authored
Jul 13, 2019
by
Viktor De Pasquale
Committed by
John Wu
Jul 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added actions for opening files in the file browser
No icons are added at this time, so crashes might occur
parent
e5118418
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
+30
-3
DownloadService.kt
...va/com/topjohnwu/magisk/model/download/DownloadService.kt
+28
-3
strings.xml
app/src/main/res/values/strings.xml
+2
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/model/download/DownloadService.kt
View file @
e83f40d5
...
@@ -21,6 +21,7 @@ import com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Magisk
...
@@ -21,6 +21,7 @@ import com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Magisk
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Module
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Module
import
com.topjohnwu.magisk.ui.flash.FlashActivity
import
com.topjohnwu.magisk.ui.flash.FlashActivity
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.chooser
import
com.topjohnwu.magisk.utils.provide
import
com.topjohnwu.magisk.utils.provide
import
java.io.File
import
java.io.File
import
kotlin.random.Random.Default.nextInt
import
kotlin.random.Random.Default.nextInt
...
@@ -34,7 +35,7 @@ open class DownloadService : RemoteFileService() {
...
@@ -34,7 +35,7 @@ open class DownloadService : RemoteFileService() {
private
val
File
.
type
private
val
File
.
type
get
()
=
MimeTypeMap
.
getSingleton
()
get
()
=
MimeTypeMap
.
getSingleton
()
.
getMimeTypeFromExtension
(
extension
)
.
getMimeTypeFromExtension
(
extension
)
.
orEmpty
()
?:
"resource/folder"
override
fun
onFinished
(
file
:
File
,
subject
:
DownloadSubject
)
=
when
(
subject
)
{
override
fun
onFinished
(
file
:
File
,
subject
:
DownloadSubject
)
=
when
(
subject
)
{
is
Magisk
->
onFinishedInternal
(
file
,
subject
)
is
Magisk
->
onFinishedInternal
(
file
,
subject
)
...
@@ -77,7 +78,8 @@ open class DownloadService : RemoteFileService() {
...
@@ -77,7 +78,8 @@ open class DownloadService : RemoteFileService() {
file
:
File
,
file
:
File
,
subject
:
Magisk
subject
:
Magisk
)
=
when
(
val
conf
=
subject
.
configuration
)
{
)
=
when
(
val
conf
=
subject
.
configuration
)
{
Download
->
setContentIntent
(
fileIntent
(
subject
.
fileName
))
Download
->
addAction
(
0
,
R
.
string
.
download_open_parent
,
fileParentIntent
(
subject
.
fileName
))
.
addAction
(
0
,
R
.
string
.
download_open_self
,
fileIntent
(
subject
.
fileName
))
Uninstall
->
setContentIntent
(
FlashActivity
.
uninstallIntent
(
context
,
file
))
Uninstall
->
setContentIntent
(
FlashActivity
.
uninstallIntent
(
context
,
file
))
is
Flash
->
setContentIntent
(
FlashActivity
.
flashIntent
(
context
,
file
,
conf
is
Secondary
))
is
Flash
->
setContentIntent
(
FlashActivity
.
flashIntent
(
context
,
file
,
conf
is
Secondary
))
is
Patch
->
setContentIntent
(
FlashActivity
.
patchIntent
(
context
,
file
,
conf
.
fileUri
))
is
Patch
->
setContentIntent
(
FlashActivity
.
patchIntent
(
context
,
file
,
conf
.
fileUri
))
...
@@ -88,7 +90,8 @@ open class DownloadService : RemoteFileService() {
...
@@ -88,7 +90,8 @@ open class DownloadService : RemoteFileService() {
file
:
File
,
file
:
File
,
subject
:
Module
subject
:
Module
)
=
when
(
subject
.
configuration
)
{
)
=
when
(
subject
.
configuration
)
{
Download
->
setContentIntent
(
fileIntent
(
subject
.
fileName
))
Download
->
addAction
(
0
,
R
.
string
.
download_open_parent
,
fileParentIntent
(
subject
.
fileName
))
.
addAction
(
0
,
R
.
string
.
download_open_self
,
fileIntent
(
subject
.
fileName
))
is
Flash
->
setContentIntent
(
FlashActivity
.
installIntent
(
context
,
file
))
is
Flash
->
setContentIntent
(
FlashActivity
.
installIntent
(
context
,
file
))
else
->
this
else
->
this
}
}
...
@@ -98,6 +101,11 @@ open class DownloadService : RemoteFileService() {
...
@@ -98,6 +101,11 @@ open class DownloadService : RemoteFileService() {
PendingIntent
.
getActivity
(
context
,
nextInt
(),
intent
,
PendingIntent
.
FLAG_ONE_SHOT
)
PendingIntent
.
getActivity
(
context
,
nextInt
(),
intent
,
PendingIntent
.
FLAG_ONE_SHOT
)
.
let
{
setContentIntent
(
it
)
}
.
let
{
setContentIntent
(
it
)
}
@Suppress
(
"ReplaceSingleLineLet"
)
private
fun
NotificationCompat
.
Builder
.
addAction
(
icon
:
Int
,
title
:
Int
,
intent
:
Intent
)
=
PendingIntent
.
getActivity
(
context
,
nextInt
(),
intent
,
PendingIntent
.
FLAG_ONE_SHOT
)
.
let
{
addAction
(
icon
,
getString
(
title
),
it
)
}
// ---
// ---
private
fun
moveToDownloads
(
file
:
File
)
{
private
fun
moveToDownloads
(
file
:
File
)
{
...
@@ -131,9 +139,26 @@ open class DownloadService : RemoteFileService() {
...
@@ -131,9 +139,26 @@ open class DownloadService : RemoteFileService() {
)
)
return
Intent
()
return
Intent
()
}
}
return
fileIntent
(
file
)
}
private
fun
fileParentIntent
(
fileName
:
String
):
Intent
{
val
file
=
fileName
.
downloadsFile
?.
parentFile
?:
let
{
Utils
.
toast
(
getString
(
R
.
string
.
download_file_folder_error
),
Toast
.
LENGTH_LONG
)
return
Intent
()
}
return
fileIntent
(
file
)
}
private
fun
fileIntent
(
file
:
File
):
Intent
{
return
Intent
(
Intent
.
ACTION_VIEW
)
return
Intent
(
Intent
.
ACTION_VIEW
)
.
setDataAndType
(
file
.
provide
(
this
),
file
.
type
)
.
setDataAndType
(
file
.
provide
(
this
),
file
.
type
)
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
)
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
)
.
chooser
()
}
}
class
Builder
{
class
Builder
{
...
...
app/src/main/res/values/strings.xml
View file @
e83f40d5
...
@@ -76,6 +76,8 @@
...
@@ -76,6 +76,8 @@
<string
name=
"download_module"
>
Injecting installer…
</string>
<string
name=
"download_module"
>
Injecting installer…
</string>
<string
name=
"download_file_error"
>
Error downloading file
</string>
<string
name=
"download_file_error"
>
Error downloading file
</string>
<string
name=
"download_file_folder_error"
>
Unable to fetch parent folder in order to save the downloaded file, check permissions.
</string>
<string
name=
"download_file_folder_error"
>
Unable to fetch parent folder in order to save the downloaded file, check permissions.
</string>
<string
name=
"download_open_parent"
>
Show in parent folder
</string>
<string
name=
"download_open_self"
>
Show file
</string>
<string
name=
"magisk_update_title"
>
Magisk Update Available!
</string>
<string
name=
"magisk_update_title"
>
Magisk Update Available!
</string>
<string
name=
"manager_update_title"
>
Magisk Manager Update Available!
</string>
<string
name=
"manager_update_title"
>
Magisk Manager Update Available!
</string>
...
...
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