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
6f355ed1
Commit
6f355ed1
authored
Jan 31, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LongSparseArray
parent
5b1b2794
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
6 deletions
+9
-6
core/src/main/java/com/github/shadowsocks/database/Profile.kt
.../src/main/java/com/github/shadowsocks/database/Profile.kt
+3
-2
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
.../src/main/java/com/github/shadowsocks/ProfilesFragment.kt
+4
-3
tv/src/main/java/com/github/shadowsocks/tv/MainPreferenceFragment.kt
.../java/com/github/shadowsocks/tv/MainPreferenceFragment.kt
+2
-1
No files found.
core/src/main/java/com/github/shadowsocks/database/Profile.kt
View file @
6f355ed1
...
...
@@ -23,6 +23,7 @@ package com.github.shadowsocks.database
import
android.net.Uri
import
android.util.Base64
import
android.util.Log
import
android.util.LongSparseArray
import
androidx.core.net.toUri
import
androidx.room.*
import
com.github.shadowsocks.plugin.PluginConfiguration
...
...
@@ -249,7 +250,7 @@ class Profile : Serializable {
}
override
fun
toString
()
=
toUri
().
toString
()
fun
toJson
(
profiles
:
Map
<
Long
,
Profile
>?
=
null
):
JSONObject
=
JSONObject
().
apply
{
fun
toJson
(
profiles
:
LongSparseArray
<
Profile
>?
=
null
):
JSONObject
=
JSONObject
().
apply
{
put
(
"server"
,
host
)
put
(
"server_port"
,
remotePort
)
put
(
"password"
,
password
)
...
...
@@ -274,7 +275,7 @@ class Profile : Serializable {
}
})
put
(
"udpdns"
,
udpdns
)
val
fallback
=
profiles
[
udpFallback
]
val
fallback
=
profiles
.
get
(
udpFallback
?:
return
@apply
)
if
(
fallback
!=
null
&&
fallback
.
plugin
.
isNullOrEmpty
())
fallback
.
toJson
().
also
{
put
(
"udp_fallback"
,
it
)
}
}
...
...
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
View file @
6f355ed1
...
...
@@ -28,6 +28,7 @@ import android.nfc.NdefRecord
import
android.nfc.NfcAdapter
import
android.os.Bundle
import
android.text.format.Formatter
import
android.util.LongSparseArray
import
android.view.*
import
android.widget.ImageView
import
android.widget.LinearLayout
...
...
@@ -301,7 +302,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
val
profilesAdapter
by
lazy
{
ProfilesAdapter
()
}
private
lateinit
var
undoManager
:
UndoSnackbarManager
<
Profile
>
private
val
statsCache
=
mutableMapOf
<
Long
,
TrafficStats
>()
private
val
statsCache
=
LongSparseArray
<
TrafficStats
>()
private
val
clipboard
by
lazy
{
requireContext
().
getSystemService
<
ClipboardManager
>()
!!
}
...
...
@@ -443,7 +444,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
REQUEST_EXPORT_PROFILES
->
{
val
profiles
=
ProfileManager
.
getAllProfiles
()
if
(
profiles
!=
null
)
try
{
val
lookup
=
profiles
.
associateBy
{
it
.
id
}
val
lookup
=
LongSparseArray
<
Profile
>(
profiles
.
size
).
apply
{
profiles
.
forEach
{
put
(
it
.
id
,
it
)
}
}
requireContext
().
contentResolver
.
openOutputStream
(
data
?.
data
!!
)
!!
.
bufferedWriter
().
use
{
it
.
write
(
JSONArray
(
profiles
.
map
{
it
.
toJson
(
lookup
)
}.
toTypedArray
()).
toString
(
2
))
}
...
...
@@ -458,7 +459,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
override
fun
onTrafficUpdated
(
profileId
:
Long
,
stats
:
TrafficStats
)
{
if
(
profileId
!=
0L
)
{
// ignore aggregate stats
statsCache
[
profileId
]
=
stats
statsCache
.
put
(
profileId
,
stats
)
profilesAdapter
.
refreshId
(
profileId
)
}
}
...
...
tv/src/main/java/com/github/shadowsocks/tv/MainPreferenceFragment.kt
View file @
6f355ed1
...
...
@@ -30,6 +30,7 @@ import android.os.DeadObjectException
import
android.os.Handler
import
android.text.format.Formatter
import
android.util.Log
import
android.util.LongSparseArray
import
android.widget.Toast
import
androidx.fragment.app.FragmentActivity
import
androidx.leanback.preference.LeanbackPreferenceFragment
...
...
@@ -318,7 +319,7 @@ class MainPreferenceFragment : LeanbackPreferenceFragment(), ShadowsocksConnecti
if
(
resultCode
!=
Activity
.
RESULT_OK
)
return
val
profiles
=
ProfileManager
.
getAllProfiles
()
if
(
profiles
!=
null
)
try
{
val
lookup
=
profiles
.
associateBy
{
it
.
id
}
val
lookup
=
LongSparseArray
<
Profile
>(
profiles
.
size
).
apply
{
profiles
.
forEach
{
put
(
it
.
id
,
it
)
}
}
activity
.
contentResolver
.
openOutputStream
(
data
?.
data
!!
)
!!
.
bufferedWriter
().
use
{
it
.
write
(
JSONArray
(
profiles
.
map
{
it
.
toJson
(
lookup
)
}.
toTypedArray
()).
toString
(
2
))
}
...
...
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