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
d71c8dce
Commit
d71c8dce
authored
Nov 09, 2015
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
This commit seems to be able to speed up AppManager on second launch noticeably.
P.S. Android 6.0, 200+ apps installed.
parent
d70480a8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
70 deletions
+9
-70
build.sbt
build.sbt
+0
-1
src/main/scala/com/github/shadowsocks/AppManager.scala
src/main/scala/com/github/shadowsocks/AppManager.scala
+7
-45
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+2
-24
No files found.
build.sbt
View file @
d71c8dce
...
...
@@ -35,7 +35,6 @@ libraryDependencies ++= Seq(
"com.google.android.gms"
%
"play-services-analytics"
%
"8.1.0"
,
"com.android.support"
%
"design"
%
"23.1.0"
,
"com.github.jorgecastilloprz"
%
"fabprogresscircle"
%
"1.01"
,
"com.nostra13.universalimageloader"
%
"universal-image-loader"
%
"1.9.4"
,
"com.j256.ormlite"
%
"ormlite-core"
%
"4.48"
,
"com.j256.ormlite"
%
"ormlite-android"
%
"4.48"
)
...
...
src/main/scala/com/github/shadowsocks/AppManager.scala
View file @
d71c8dce
...
...
@@ -39,11 +39,10 @@
package
com.github.shadowsocks
import
java.io.
{
ByteArrayInputStream
,
ByteArrayOutputStream
,
InputStream
}
import
android.content.pm.PackageManager
import
android.content.
{
ClipData
,
ClipboardManager
,
Context
,
SharedPreferences
}
import
android.graphics.
{
Bitmap
,
PixelFormat
}
import
android.graphics.PixelFormat
import
android.graphics.drawable.Drawable
import
android.os.
{
Bundle
,
Handler
}
import
android.preference.PreferenceManager
import
android.support.v7.app.AppCompatActivity
...
...
@@ -55,16 +54,13 @@ import android.view.{MenuItem, View, ViewGroup, WindowManager}
import
android.widget.AbsListView.OnScrollListener
import
android.widget.CompoundButton.OnCheckedChangeListener
import
android.widget._
import
com.github.shadowsocks.utils.
{
Key
,
Scheme
,
Utils
}
import
com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer
import
com.nostra13.universalimageloader.core.download.BaseImageDownloader
import
com.nostra13.universalimageloader.core.
{
DisplayImageOptions
,
ImageLoader
,
ImageLoaderConfiguration
}
import
com.github.shadowsocks.utils.
{
Key
,
Utils
}
import
scala.concurrent.ExecutionContext.Implicits.global
import
scala.concurrent.Future
import
scala.language.implicitConversions
case
class
ProxiedApp
(
uid
:
Int
,
name
:
String
,
packageName
:
String
,
var
proxied
:
Boolean
)
case
class
ProxiedApp
(
uid
:
Int
,
name
:
String
,
packageName
:
String
,
icon
:
Drawable
,
var
proxied
:
Boolean
)
class
ObjectArrayTools
[
T
<:
AnyRef
](
a
:
Array
[
T
])
{
def
binarySearch
(
key
:
T
)
=
{
...
...
@@ -94,7 +90,7 @@ object AppManager {
val
name
=
packageManager
.
getApplicationLabel
(
a
).
toString
val
packageName
=
a
.
packageName
val
proxied
=
proxiedApps
.
binarySearch
(
userName
)
>=
0
new
ProxiedApp
(
uid
,
name
,
packageName
,
proxied
)
new
ProxiedApp
(
uid
,
name
,
packageName
,
null
,
proxied
)
}.
toArray
}
}
...
...
@@ -132,7 +128,7 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
val
name
=
packageManager
.
getApplicationLabel
(
a
).
toString
val
packageName
=
a
.
packageName
val
proxied
=
(
proxiedApps
binarySearch
userName
)
>=
0
new
ProxiedApp
(
uid
,
name
,
packageName
,
proxied
)
new
ProxiedApp
(
uid
,
name
,
packageName
,
a
.
loadIcon
(
packageManager
),
proxied
)
}.
toArray
}
...
...
@@ -167,19 +163,9 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
}
val
app
:
ProxiedApp
=
apps
(
position
)
val
options
=
new
DisplayImageOptions
.
Builder
()
.
showStubImage
(
STUB
)
.
showImageForEmptyUri
(
STUB
)
.
showImageOnFail
(
STUB
)
.
resetViewBeforeLoading
()
.
cacheInMemory
()
.
cacheOnDisc
()
.
displayer
(
new
FadeInBitmapDisplayer
(
300
))
.
build
()
ImageLoader
.
getInstance
().
displayImage
(
Scheme
.
APP
+
app
.
packageName
,
entry
.
icon
,
options
)
entry
.
text
.
setText
(
app
.
name
)
entry
.
icon
.
setImageDrawable
(
app
.
icon
)
val
switch
=
entry
.
switch
switch
.
setTag
(
app
)
switch
.
setChecked
(
app
.
proxied
)
...
...
@@ -281,12 +267,6 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
WindowManager
.
LayoutParams
.
FLAG_NOT_FOCUSABLE
|
WindowManager
.
LayoutParams
.
FLAG_NOT_TOUCHABLE
,
PixelFormat
.
TRANSLUCENT
))
val
config
=
new
ImageLoaderConfiguration
.
Builder
(
this
)
.
imageDownloader
(
new
AppIconDownloader
(
this
))
.
build
()
ImageLoader
.
getInstance
().
init
(
config
)
val
bypassSwitch
=
findViewById
(
R
.
id
.
bypassSwitch
).
asInstanceOf
[
Switch
]
bypassSwitch
.
setOnCheckedChangeListener
((
button
:
CompoundButton
,
checked
:
Boolean
)
=>
ShadowsocksApplication
.
settings
.
edit
().
putBoolean
(
Key
.
isBypassApps
,
checked
).
apply
())
...
...
@@ -342,22 +322,4 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
var
handler
:
Handler
=
null
class
AppIconDownloader
(
context
:
Context
,
connectTimeout
:
Int
,
readTimeout
:
Int
)
extends
BaseImageDownloader
(
context
,
connectTimeout
,
readTimeout
)
{
def
this
(
context
:
Context
)
{
this
(
context
,
0
,
0
)
}
override
def
getStreamFromOtherSource
(
imageUri
:
String
,
extra
:
AnyRef
)
:
InputStream
=
{
val
packageName
=
imageUri
.
substring
(
Scheme
.
APP
.
length
)
val
drawable
=
Utils
.
getAppIcon
(
getBaseContext
,
packageName
)
val
bitmap
=
Utils
.
drawableToBitmap
(
drawable
)
val
os
=
new
ByteArrayOutputStream
()
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
100
,
os
)
new
ByteArrayInputStream
(
os
.
toByteArray
)
}
}
}
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
d71c8dce
...
...
@@ -38,7 +38,7 @@
*/
package
com.github.shadowsocks
import
java.io.
{
ByteArrayInputStream
,
ByteArrayOutputStream
,
FileOutputStream
,
IOException
,
InputStream
,
OutputStream
}
import
java.io.
{
FileOutputStream
,
IOException
,
InputStream
,
OutputStream
}
import
java.util
import
java.util.Locale
...
...
@@ -46,7 +46,7 @@ import android.app.backup.BackupManager
import
android.app.
{
Activity
,
AlertDialog
,
ProgressDialog
}
import
android.content._
import
android.content.res.AssetManager
import
android.graphics.
{
Bitmap
,
Color
,
Typeface
}
import
android.graphics.
Typeface
import
android.net.
{
Uri
,
VpnService
}
import
android.os._
import
android.preference.
{
Preference
,
SwitchPreference
}
...
...
@@ -64,33 +64,11 @@ import com.github.shadowsocks.database._
import
com.github.shadowsocks.preferences.
{
DropDownPreference
,
PasswordEditTextPreference
,
SummaryEditTextPreference
}
import
com.github.shadowsocks.utils._
import
com.google.android.gms.ads.
{
AdRequest
,
AdSize
,
AdView
}
import
com.nostra13.universalimageloader.core.download.BaseImageDownloader
import
scala.collection.mutable.ArrayBuffer
import
scala.concurrent.ExecutionContext.Implicits.global
import
scala.concurrent.Future
class
ProfileIconDownloader
(
context
:
Context
,
connectTimeout
:
Int
,
readTimeout
:
Int
)
extends
BaseImageDownloader
(
context
,
connectTimeout
,
readTimeout
)
{
def
this
(
context
:
Context
)
{
this
(
context
,
0
,
0
)
}
override
def
getStreamFromOtherSource
(
imageUri
:
String
,
extra
:
AnyRef
)
:
InputStream
=
{
val
text
=
imageUri
.
substring
(
Scheme
.
PROFILE
.
length
)
val
size
=
Utils
.
dpToPx
(
context
,
16
)
val
idx
=
text
.
getBytes
.
last
%
6
val
color
=
Seq
(
Color
.
MAGENTA
,
Color
.
GREEN
,
Color
.
YELLOW
,
Color
.
BLUE
,
Color
.
DKGRAY
,
Color
.
CYAN
)(
idx
)
val
bitmap
=
Utils
.
getBitmap
(
text
,
size
,
size
,
color
)
val
os
=
new
ByteArrayOutputStream
()
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
100
,
os
)
new
ByteArrayInputStream
(
os
.
toByteArray
)
}
}
object
Typefaces
{
def
get
(
c
:
Context
,
assetPath
:
String
)
:
Typeface
=
{
cache
synchronized
{
...
...
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