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
9966368a
Commit
9966368a
authored
Nov 08, 2015
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add long press toast for FAB
parent
2fa97be1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
3 deletions
+28
-3
src/main/res/values-zh/strings.xml
src/main/res/values-zh/strings.xml
+1
-1
src/main/res/values/strings.xml
src/main/res/values/strings.xml
+1
-1
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+5
-0
src/main/scala/com/github/shadowsocks/utils/Utils.scala
src/main/scala/com/github/shadowsocks/utils/Utils.scala
+21
-1
No files found.
src/main/res/values-zh/strings.xml
View file @
9966368a
...
...
@@ -53,7 +53,7 @@
<string
name=
"port_empty"
>
端口号不能为空
</string>
<string
name=
"proxy_empty"
>
代理服务器地址不能为空
</string>
<string
name=
"crash_alert"
>
检测到意外退出,状态已被重置。
</string>
<string
name=
"connect
ing"
>
正在连接...
</string>
<string
name=
"connect
"
>
连接
</string>
<string
name=
"initializing"
>
正在初始化...
</string>
<string
name=
"recovering"
>
重置中...
</string>
<string
name=
"loading"
>
正在加载...
</string>
...
...
src/main/res/values/strings.xml
View file @
9966368a
...
...
@@ -74,7 +74,7 @@
<string
name=
"proxy_empty"
>
Proxy should not be empty
</string>
<string
name=
"crash_alert"
>
An unexpected exit detected, the context has been reset.
</string>
<string
name=
"connect
ing"
>
Connecting…
</string>
<string
name=
"connect
"
>
Connect
</string>
<string
name=
"initializing"
>
Initializing…
</string>
<string
name=
"recovering"
>
Resetting…
</string>
<string
name=
"loading"
>
Loading…
</string>
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
9966368a
...
...
@@ -505,6 +505,11 @@ class Shadowsocks
}
}
})
fab
.
setOnLongClickListener
((
v
:
View
)
=>
{
Utils
.
positionToast
(
Toast
.
makeText
(
this
,
if
(
serviceStarted
)
R
.
string
.
stop
else
R
.
string
.
connect
,
Toast
.
LENGTH_SHORT
),
fab
,
getWindow
,
0
,
Utils
.
dpToPx
(
this
,
8
).
toInt
).
show
true
})
toolbar
.
setNavigationIcon
(
R
.
drawable
.
ic_drawer
)
toolbar
.
setNavigationOnClickListener
((
v
:
View
)
=>
drawer
.
toggleMenu
())
title
.
setOnLongClickListener
((
v
:
View
)
=>
{
...
...
src/main/scala/com/github/shadowsocks/utils/Utils.scala
View file @
9966368a
...
...
@@ -50,7 +50,10 @@ import android.graphics.drawable.{BitmapDrawable, Drawable}
import
android.os.Build
import
android.provider.Settings
import
android.support.v4.content.ContextCompat
import
android.util.
{
Base64
,
Log
}
import
android.util.
{
DisplayMetrics
,
Base64
,
Log
}
import
android.view.View.MeasureSpec
import
android.view.
{
Gravity
,
View
,
Window
}
import
android.widget.Toast
import
com.github.shadowsocks.BuildConfig
import
org.xbill.DNS._
...
...
@@ -126,6 +129,23 @@ object Utils {
bitmap
}
// Based on: http://stackoverflow.com/a/21026866/2245107
def
positionToast
(
toast
:
Toast
,
view
:
View
,
window
:
Window
,
offsetX
:
Int
=
0
,
offsetY
:
Int
=
0
)
=
{
val
rect
=
new
Rect
window
.
getDecorView
.
getWindowVisibleDisplayFrame
(
rect
)
val
viewLocation
=
new
Array
[
Int
](
2
)
view
.
getLocationInWindow
(
viewLocation
)
val
metrics
=
new
DisplayMetrics
window
.
getWindowManager
.
getDefaultDisplay
.
getMetrics
(
metrics
)
val
toastView
=
toast
.
getView
toastView
.
measure
(
MeasureSpec
.
makeMeasureSpec
(
metrics
.
widthPixels
,
MeasureSpec
.
UNSPECIFIED
),
MeasureSpec
.
makeMeasureSpec
(
metrics
.
heightPixels
,
MeasureSpec
.
UNSPECIFIED
))
toast
.
setGravity
(
Gravity
.
LEFT
|
Gravity
.
TOP
,
viewLocation
(
0
)
-
rect
.
left
+
(
view
.
getWidth
-
toast
.
getView
.
getMeasuredWidth
)
/
2
+
offsetX
,
viewLocation
(
1
)
-
rect
.
top
+
view
.
getHeight
+
offsetY
)
toast
}
// Blocked > 3 seconds
def
toggleAirplaneMode
(
context
:
Context
)
{
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