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
971cd73f
Commit
971cd73f
authored
Jul 25, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dismiss notification on error
parent
1947860d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
12 deletions
+12
-12
NotificationService.kt
...om/topjohnwu/magisk/model/download/NotificationService.kt
+7
-7
RemoteFileService.kt
.../com/topjohnwu/magisk/model/download/RemoteFileService.kt
+1
-0
Notifications.java
...rc/main/java/com/topjohnwu/magisk/view/Notifications.java
+4
-5
No files found.
app/src/main/java/com/topjohnwu/magisk/model/download/NotificationService.kt
View file @
971cd73f
...
@@ -46,9 +46,6 @@ abstract class NotificationService : Service() {
...
@@ -46,9 +46,6 @@ abstract class NotificationService : Service() {
)
:
Int
{
)
:
Int
{
val
currentNotification
=
remove
(
id
)
?.
run
(
editBody
)
val
currentNotification
=
remove
(
id
)
?.
run
(
editBody
)
updateForeground
()
cancel
(
id
)
var
newId
=
-
1
var
newId
=
-
1
currentNotification
?.
let
{
currentNotification
?.
let
{
newId
=
nextInt
(
Int
.
MAX_VALUE
)
newId
=
nextInt
(
Int
.
MAX_VALUE
)
...
@@ -56,7 +53,6 @@ abstract class NotificationService : Service() {
...
@@ -56,7 +53,6 @@ abstract class NotificationService : Service() {
}
}
if
(!
hasNotifications
)
{
if
(!
hasNotifications
)
{
stopForeground
(
true
)
stopSelf
()
stopSelf
()
}
}
return
newId
return
newId
...
@@ -72,12 +68,16 @@ abstract class NotificationService : Service() {
...
@@ -72,12 +68,16 @@ abstract class NotificationService : Service() {
manager
.
cancel
(
id
)
manager
.
cancel
(
id
)
}
}
private
fun
remove
(
id
:
Int
)
=
notifications
.
remove
(
id
)
protected
fun
remove
(
id
:
Int
)
=
notifications
.
remove
(
id
).
also
{
.
also
{
updateForeground
()
}
cancel
(
id
)
updateForeground
()
}
private
fun
updateForeground
()
{
private
fun
updateForeground
()
{
if
(
notifications
.
isNotEmpty
()
)
if
(
hasNotifications
)
startForeground
(
notifications
.
keys
.
first
(),
notifications
.
values
.
first
().
build
())
startForeground
(
notifications
.
keys
.
first
(),
notifications
.
values
.
first
().
build
())
else
stopForeground
(
true
)
}
}
// --
// --
...
...
app/src/main/java/com/topjohnwu/magisk/model/download/RemoteFileService.kt
View file @
971cd73f
...
@@ -49,6 +49,7 @@ abstract class RemoteFileService : NotificationService() {
...
@@ -49,6 +49,7 @@ abstract class RemoteFileService : NotificationService() {
.
onErrorResumeNext
(
download
(
subject
))
.
onErrorResumeNext
(
download
(
subject
))
.
doOnSubscribe
{
update
(
subject
.
hashCode
())
{
it
.
setContentTitle
(
subject
.
title
)
}
}
.
doOnSubscribe
{
update
(
subject
.
hashCode
())
{
it
.
setContentTitle
(
subject
.
title
)
}
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
doOnError
{
remove
(
subject
.
hashCode
())
}
.
doOnSuccess
{
.
doOnSuccess
{
val
id
=
finish
(
it
,
subject
)
val
id
=
finish
(
it
,
subject
)
runCatching
{
onFinished
(
it
,
subject
,
id
)
}.
onFailure
{
Timber
.
e
(
it
)
}
runCatching
{
onFinished
(
it
,
subject
,
id
)
}.
onFailure
{
Timber
.
e
(
it
)
}
...
...
app/src/main/java/com/topjohnwu/magisk/view/Notifications.java
View file @
971cd73f
...
@@ -7,6 +7,10 @@ import android.content.Context;
...
@@ -7,6 +7,10 @@ import android.content.Context;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.os.Build
;
import
androidx.core.app.NotificationCompat
;
import
androidx.core.app.NotificationManagerCompat
;
import
androidx.core.app.TaskStackBuilder
;
import
com.topjohnwu.magisk.App
;
import
com.topjohnwu.magisk.App
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Const
;
...
@@ -16,17 +20,12 @@ import com.topjohnwu.magisk.model.receiver.GeneralReceiver;
...
@@ -16,17 +20,12 @@ import com.topjohnwu.magisk.model.receiver.GeneralReceiver;
import
com.topjohnwu.magisk.ui.SplashActivity
;
import
com.topjohnwu.magisk.ui.SplashActivity
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
androidx.core.app.NotificationCompat
;
import
androidx.core.app.NotificationManagerCompat
;
import
androidx.core.app.TaskStackBuilder
;
public
class
Notifications
{
public
class
Notifications
{
public
static
NotificationManagerCompat
mgr
=
NotificationManagerCompat
.
from
(
App
.
self
);
public
static
NotificationManagerCompat
mgr
=
NotificationManagerCompat
.
from
(
App
.
self
);
public
static
void
setup
(
Context
c
)
{
public
static
void
setup
(
Context
c
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
NotificationManager
mgr
=
c
.
getSystemService
(
NotificationManager
.
class
);
mgr
.
deleteNotificationChannel
(
"magisk_notification"
);
mgr
.
deleteNotificationChannel
(
"magisk_notification"
);
NotificationChannel
channel
=
NotificationChannel
channel
=
new
NotificationChannel
(
Const
.
ID
.
UPDATE_NOTIFICATION_CHANNEL
,
new
NotificationChannel
(
Const
.
ID
.
UPDATE_NOTIFICATION_CHANNEL
,
...
...
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