Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
554a9b1b
Commit
554a9b1b
authored
Jun 19, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make service notification more compact
This also fixes styling issue on Android Q beta 1 thru 4.
parent
2f7f9310
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
14 deletions
+13
-14
core/src/main/java/com/github/shadowsocks/bg/DnsResolverCompat.kt
.../main/java/com/github/shadowsocks/bg/DnsResolverCompat.kt
+4
-6
core/src/main/java/com/github/shadowsocks/bg/ServiceNotification.kt
...ain/java/com/github/shadowsocks/bg/ServiceNotification.kt
+9
-8
No files found.
core/src/main/java/com/github/shadowsocks/bg/DnsResolverCompat.kt
View file @
554a9b1b
...
@@ -54,20 +54,18 @@ sealed class DnsResolverCompat {
...
@@ -54,20 +54,18 @@ sealed class DnsResolverCompat {
}
}
@TargetApi
(
29
)
@TargetApi
(
29
)
private
object
DnsResolverCompat29
:
DnsResolverCompat
()
{
private
object
DnsResolverCompat29
:
DnsResolverCompat
()
,
Executor
{
/**
/**
* This executor will run on its caller directly. On Q beta 3, this results in calling in main thread.
* This executor will run on its caller directly. On Q beta 3
thru 4
, this results in calling in main thread.
*/
*/
private
object
InPlaceExecutor
:
Executor
{
override
fun
execute
(
command
:
Runnable
)
=
command
.
run
()
override
fun
execute
(
command
:
Runnable
?)
=
command
!!
.
run
()
}
override
suspend
fun
resolve
(
network
:
Network
,
host
:
String
):
Array
<
InetAddress
>
{
override
suspend
fun
resolve
(
network
:
Network
,
host
:
String
):
Array
<
InetAddress
>
{
return
suspendCancellableCoroutine
{
cont
->
return
suspendCancellableCoroutine
{
cont
->
val
signal
=
CancellationSignal
()
val
signal
=
CancellationSignal
()
cont
.
invokeOnCancellation
{
signal
.
cancel
()
}
cont
.
invokeOnCancellation
{
signal
.
cancel
()
}
// retry should be handled by client instead
// retry should be handled by client instead
DnsResolver
.
getInstance
().
query
(
network
,
host
,
DnsResolver
.
FLAG_NO_RETRY
,
InPlaceExecutor
,
DnsResolver
.
getInstance
().
query
(
network
,
host
,
DnsResolver
.
FLAG_NO_RETRY
,
this
,
signal
,
object
:
DnsResolver
.
Callback
<
Collection
<
InetAddress
>>
{
signal
,
object
:
DnsResolver
.
Callback
<
Collection
<
InetAddress
>>
{
override
fun
onAnswer
(
answer
:
Collection
<
InetAddress
>,
rcode
:
Int
)
=
override
fun
onAnswer
(
answer
:
Collection
<
InetAddress
>,
rcode
:
Int
)
=
cont
.
resume
(
answer
.
toTypedArray
())
cont
.
resume
(
answer
.
toTypedArray
())
...
...
core/src/main/java/com/github/shadowsocks/bg/ServiceNotification.kt
View file @
554a9b1b
...
@@ -55,13 +55,14 @@ class ServiceNotification(private val service: BaseService.Interface, profileNam
...
@@ -55,13 +55,14 @@ class ServiceNotification(private val service: BaseService.Interface, profileNam
override
fun
stateChanged
(
state
:
Int
,
profileName
:
String
?,
msg
:
String
?)
{
}
// ignore
override
fun
stateChanged
(
state
:
Int
,
profileName
:
String
?,
msg
:
String
?)
{
}
// ignore
override
fun
trafficUpdated
(
profileId
:
Long
,
stats
:
TrafficStats
)
{
override
fun
trafficUpdated
(
profileId
:
Long
,
stats
:
TrafficStats
)
{
if
(
profileId
!=
0L
)
return
if
(
profileId
!=
0L
)
return
service
as
Context
builder
.
apply
{
val
txr
=
service
.
getString
(
R
.
string
.
speed
,
Formatter
.
formatFileSize
(
service
,
stats
.
txRate
))
setContentText
((
service
as
Context
).
getString
(
R
.
string
.
traffic
,
val
rxr
=
service
.
getString
(
R
.
string
.
speed
,
Formatter
.
formatFileSize
(
service
,
stats
.
rxRate
))
service
.
getString
(
R
.
string
.
speed
,
Formatter
.
formatFileSize
(
service
,
stats
.
txRate
)),
builder
.
setContentText
(
"$txr↑\t$rxr↓"
)
service
.
getString
(
R
.
string
.
speed
,
Formatter
.
formatFileSize
(
service
,
stats
.
rxRate
)))
)
style
.
bigText
(
service
.
getString
(
R
.
string
.
stat_summary
,
txr
,
rxr
,
setSubText
(
service
.
getString
(
R
.
string
.
traffic
,
Formatter
.
formatFileSize
(
service
,
stats
.
txTotal
),
Formatter
.
formatFileSize
(
service
,
stats
.
txTotal
),
Formatter
.
formatFileSize
(
service
,
stats
.
rxTotal
)))
Formatter
.
formatFileSize
(
service
,
stats
.
rxTotal
)))
}
show
()
show
()
}
}
override
fun
trafficPersisted
(
profileId
:
Long
)
{
}
override
fun
trafficPersisted
(
profileId
:
Long
)
{
}
...
@@ -77,7 +78,7 @@ class ServiceNotification(private val service: BaseService.Interface, profileNam
...
@@ -77,7 +78,7 @@ class ServiceNotification(private val service: BaseService.Interface, profileNam
.
setContentTitle
(
profileName
)
.
setContentTitle
(
profileName
)
.
setContentIntent
(
Core
.
configureIntent
(
service
))
.
setContentIntent
(
Core
.
configureIntent
(
service
))
.
setSmallIcon
(
R
.
drawable
.
ic_service_active
)
.
setSmallIcon
(
R
.
drawable
.
ic_service_active
)
private
val
style
=
NotificationCompat
.
BigTextStyle
(
builder
).
bigText
(
""
)
.
setCategory
(
NotificationCompat
.
CATEGORY_SERVICE
)
private
var
isVisible
=
true
private
var
isVisible
=
true
init
{
init
{
...
...
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