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
d70480a8
Commit
d70480a8
authored
Nov 09, 2015
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove ProgressDialog in AppManager
parent
e6cf38e6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
46 deletions
+49
-46
src/main/res/layout/layout_apps.xml
src/main/res/layout/layout_apps.xml
+13
-4
src/main/scala/com/github/shadowsocks/AppManager.scala
src/main/scala/com/github/shadowsocks/AppManager.scala
+25
-42
src/main/scala/com/github/shadowsocks/utils/Utils.scala
src/main/scala/com/github/shadowsocks/utils/Utils.scala
+11
-0
No files found.
src/main/res/layout/layout_apps.xml
View file @
d70480a8
...
@@ -32,8 +32,17 @@
...
@@ -32,8 +32,17 @@
android:layout_marginEnd=
"6dp"
android:layout_marginEnd=
"6dp"
android:layout_marginRight=
"6dp"
/>
android:layout_marginRight=
"6dp"
/>
</LinearLayout>
</LinearLayout>
<ListView
<FrameLayout
android:layout_width=
"fill_parent"
android:layout_width=
"fill_parent"
android:layout_height=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
>
android:id=
"@+id/applistview"
/>
<ProgressBar
android:id=
"@+id/loading"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
/>
<ListView
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
android:id=
"@+id/applistview"
android:visibility=
"gone"
/>
</FrameLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
src/main/scala/com/github/shadowsocks/AppManager.scala
View file @
d70480a8
...
@@ -41,7 +41,6 @@ package com.github.shadowsocks
...
@@ -41,7 +41,6 @@ package com.github.shadowsocks
import
java.io.
{
ByteArrayInputStream
,
ByteArrayOutputStream
,
InputStream
}
import
java.io.
{
ByteArrayInputStream
,
ByteArrayOutputStream
,
InputStream
}
import
android.app.ProgressDialog
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager
import
android.content.
{
ClipData
,
ClipboardManager
,
Context
,
SharedPreferences
}
import
android.content.
{
ClipData
,
ClipboardManager
,
Context
,
SharedPreferences
}
import
android.graphics.
{
Bitmap
,
PixelFormat
}
import
android.graphics.
{
Bitmap
,
PixelFormat
}
...
@@ -112,7 +111,6 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
...
@@ -112,7 +111,6 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
var
apps
:
Array
[
ProxiedApp
]
=
null
var
apps
:
Array
[
ProxiedApp
]
=
null
var
appListView
:
ListView
=
null
var
appListView
:
ListView
=
null
var
overlay
:
TextView
=
null
var
overlay
:
TextView
=
null
var
progressDialog
:
ProgressDialog
=
null
var
adapter
:
ListAdapter
=
null
var
adapter
:
ListAdapter
=
null
var
appsLoaded
:
Boolean
=
false
var
appsLoaded
:
Boolean
=
false
...
@@ -295,14 +293,37 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
...
@@ -295,14 +293,37 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
bypassSwitch
.
setChecked
(
ShadowsocksApplication
.
settings
.
getBoolean
(
Key
.
isBypassApps
,
false
))
bypassSwitch
.
setChecked
(
ShadowsocksApplication
.
settings
.
getBoolean
(
Key
.
isBypassApps
,
false
))
appListView
=
findViewById
(
R
.
id
.
applistview
).
asInstanceOf
[
ListView
]
appListView
=
findViewById
(
R
.
id
.
applistview
).
asInstanceOf
[
ListView
]
appListView
.
setOnScrollListener
(
new
AbsListView
.
OnScrollListener
{
var
visible
=
false
def
onScroll
(
view
:
AbsListView
,
firstVisibleItem
:
Int
,
visibleItemCount
:
Int
,
totalItemCount
:
Int
)
{
if
(
visible
)
{
val
name
:
String
=
apps
(
firstVisibleItem
).
name
if
(
name
!=
null
&&
name
.
length
>
1
)
{
overlay
.
setText
(
apps
(
firstVisibleItem
).
name
.
substring
(
0
,
1
))
}
else
{
overlay
.
setText
(
"*"
)
}
overlay
.
setVisibility
(
View
.
VISIBLE
)
}
}
def
onScrollStateChanged
(
view
:
AbsListView
,
scrollState
:
Int
)
{
visible
=
true
if
(
scrollState
==
OnScrollListener
.
SCROLL_STATE_IDLE
)
{
overlay
.
setVisibility
(
View
.
INVISIBLE
)
}
}
})
}
}
protected
override
def
onResume
()
{
protected
override
def
onResume
()
{
super
.
onResume
()
super
.
onResume
()
Future
{
Future
{
handler
.
post
(
loadStartRunnable
)
if
(!
appsLoaded
)
loadApps
()
if
(!
appsLoaded
)
loadApps
()
handler
.
post
(
loadFinishRunnable
)
handler
.
post
(()
=>
{
appListView
.
setAdapter
(
adapter
)
Utils
.
crossFade
(
AppManager
.
this
,
findViewById
(
R
.
id
.
loading
),
appListView
)
})
}
}
}
}
...
@@ -319,44 +340,6 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
...
@@ -319,44 +340,6 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
edit
.
apply
edit
.
apply
}
}
val
loadStartRunnable
=
new
Runnable
{
override
def
run
()
{
progressDialog
=
ProgressDialog
.
show
(
AppManager
.
this
,
""
,
getString
(
R
.
string
.
loading
),
true
,
true
)
}
}
val
loadFinishRunnable
=
new
Runnable
{
override
def
run
()
=
{
appListView
.
setAdapter
(
adapter
)
appListView
.
setOnScrollListener
(
new
AbsListView
.
OnScrollListener
{
def
onScroll
(
view
:
AbsListView
,
firstVisibleItem
:
Int
,
visibleItemCount
:
Int
,
totalItemCount
:
Int
)
{
if
(
visible
)
{
val
name
:
String
=
apps
(
firstVisibleItem
).
name
if
(
name
!=
null
&&
name
.
length
>
1
)
{
overlay
.
setText
(
apps
(
firstVisibleItem
).
name
.
substring
(
0
,
1
))
}
else
{
overlay
.
setText
(
"*"
)
}
overlay
.
setVisibility
(
View
.
VISIBLE
)
}
}
def
onScrollStateChanged
(
view
:
AbsListView
,
scrollState
:
Int
)
{
visible
=
true
if
(
scrollState
==
OnScrollListener
.
SCROLL_STATE_IDLE
)
{
overlay
.
setVisibility
(
View
.
INVISIBLE
)
}
}
var
visible
=
false
})
if
(
progressDialog
!=
null
)
{
progressDialog
.
dismiss
()
progressDialog
=
null
}
}
}
var
handler
:
Handler
=
null
var
handler
:
Handler
=
null
class
AppIconDownloader
(
context
:
Context
,
connectTimeout
:
Int
,
readTimeout
:
Int
)
class
AppIconDownloader
(
context
:
Context
,
connectTimeout
:
Int
,
readTimeout
:
Int
)
...
...
src/main/scala/com/github/shadowsocks/utils/Utils.scala
View file @
d70480a8
...
@@ -42,6 +42,7 @@ import java.io._
...
@@ -42,6 +42,7 @@ import java.io._
import
java.net._
import
java.net._
import
java.security.MessageDigest
import
java.security.MessageDigest
import
android.animation.
{
AnimatorListenerAdapter
,
Animator
}
import
android.app.ActivityManager
import
android.app.ActivityManager
import
android.content.pm.
{
ApplicationInfo
,
PackageManager
}
import
android.content.pm.
{
ApplicationInfo
,
PackageManager
}
import
android.content.
{
Context
,
Intent
}
import
android.content.
{
Context
,
Intent
}
...
@@ -142,6 +143,16 @@ object Utils {
...
@@ -142,6 +143,16 @@ object Utils {
toast
toast
}
}
def
crossFade
(
context
:
Context
,
from
:
View
,
to
:
View
)
{
def
shortAnimTime
=
context
.
getResources
.
getInteger
(
android
.
R
.
integer
.
config_shortAnimTime
)
to
.
setAlpha
(
0
)
to
.
setVisibility
(
View
.
VISIBLE
)
to
.
animate
().
alpha
(
1
).
setDuration
(
shortAnimTime
)
from
.
animate
().
alpha
(
0
).
setDuration
(
shortAnimTime
).
setListener
(
new
AnimatorListenerAdapter
{
override
def
onAnimationEnd
(
animation
:
Animator
)
=
from
.
setVisibility
(
View
.
GONE
)
})
}
// Blocked > 3 seconds
// Blocked > 3 seconds
def
toggleAirplaneMode
(
context
:
Context
)
{
def
toggleAirplaneMode
(
context
:
Context
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
17
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
17
)
{
...
...
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