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
3b6cd416
Commit
3b6cd416
authored
Jul 19, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent status text from overflowing
parent
9b876446
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
4 deletions
+20
-4
mobile/src/main/java/com/github/shadowsocks/widget/StatsBar.kt
...e/src/main/java/com/github/shadowsocks/widget/StatsBar.kt
+9
-3
mobile/src/main/res/layout/layout_main.xml
mobile/src/main/res/layout/layout_main.xml
+2
-1
mobile/src/main/res/values-v26/styles.xml
mobile/src/main/res/values-v26/styles.xml
+6
-0
mobile/src/main/res/values/styles.xml
mobile/src/main/res/values/styles.xml
+3
-0
No files found.
mobile/src/main/java/com/github/shadowsocks/widget/StatsBar.kt
View file @
3b6cd416
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
package
com.github.shadowsocks.widget
package
com.github.shadowsocks.widget
import
android.content.Context
import
android.content.Context
import
android.os.Build
import
android.text.format.Formatter
import
android.text.format.Formatter
import
android.util.AttributeSet
import
android.util.AttributeSet
import
android.view.View
import
android.view.View
...
@@ -70,21 +71,26 @@ class StatsBar @JvmOverloads constructor(context: Context, attrs: AttributeSet?
...
@@ -70,21 +71,26 @@ class StatsBar @JvmOverloads constructor(context: Context, attrs: AttributeSet?
super
.
setOnClickListener
(
l
)
super
.
setOnClickListener
(
l
)
}
}
private
fun
setStatus
(
text
:
CharSequence
)
{
statusText
.
text
=
text
if
(
Build
.
VERSION
.
SDK_INT
>=
26
)
statusText
.
tooltipText
=
text
}
fun
changeState
(
state
:
BaseService
.
State
)
{
fun
changeState
(
state
:
BaseService
.
State
)
{
val
activity
=
context
as
MainActivity
val
activity
=
context
as
MainActivity
if
(
state
!=
BaseService
.
State
.
Connected
)
{
if
(
state
!=
BaseService
.
State
.
Connected
)
{
updateTraffic
(
0
,
0
,
0
,
0
)
updateTraffic
(
0
,
0
,
0
,
0
)
tester
.
status
.
removeObservers
(
activity
)
tester
.
status
.
removeObservers
(
activity
)
if
(
state
!=
BaseService
.
State
.
Idle
)
tester
.
invalidate
()
if
(
state
!=
BaseService
.
State
.
Idle
)
tester
.
invalidate
()
s
tatusText
.
s
etText
(
when
(
state
)
{
s
etStatus
(
context
.
g
etText
(
when
(
state
)
{
BaseService
.
State
.
Connecting
->
R
.
string
.
connecting
BaseService
.
State
.
Connecting
->
R
.
string
.
connecting
BaseService
.
State
.
Stopping
->
R
.
string
.
stopping
BaseService
.
State
.
Stopping
->
R
.
string
.
stopping
else
->
R
.
string
.
not_connected
else
->
R
.
string
.
not_connected
})
})
)
}
else
{
}
else
{
behavior
.
slideUp
(
this
)
behavior
.
slideUp
(
this
)
tester
.
status
.
observe
(
activity
,
Observer
{
tester
.
status
.
observe
(
activity
,
Observer
{
it
.
retrieve
(
statusText
::
setText
)
{
activity
.
snackbar
(
it
).
show
()
}
it
.
retrieve
(
this
::
setStatus
)
{
activity
.
snackbar
(
it
).
show
()
}
})
})
}
}
}
}
...
...
mobile/src/main/res/layout/layout_main.xml
View file @
3b6cd416
...
@@ -106,13 +106,14 @@
...
@@ -106,13 +106,14 @@
android:id=
"@+id/status"
android:id=
"@+id/status"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:
ellipsize=
"marquee
"
android:
maxLines=
"1
"
android:textColor=
"?android:attr/textColorPrimary"
android:textColor=
"?android:attr/textColorPrimary"
android:textSize=
"16sp"
android:textSize=
"16sp"
android:layout_gravity=
"fill_horizontal"
android:layout_gravity=
"fill_horizontal"
android:layout_row=
"2"
android:layout_row=
"2"
android:layout_column=
"0"
android:layout_column=
"0"
android:layout_columnSpan=
"3"
android:layout_columnSpan=
"3"
style=
"@style/stats_status"
tools:text=
"@string/connection_test_available"
/>
tools:text=
"@string/connection_test_available"
/>
</GridLayout>
</GridLayout>
...
...
mobile/src/main/res/values-v26/styles.xml
0 → 100644
View file @
3b6cd416
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style
name=
"stats_status"
>
<item
name=
"android:ellipsize"
>
end
</item>
</style>
</resources>
mobile/src/main/res/values/styles.xml
View file @
3b6cd416
...
@@ -4,4 +4,7 @@
...
@@ -4,4 +4,7 @@
<item
name=
"android:windowDrawsSystemBarBackgrounds"
>
true
</item>
<item
name=
"android:windowDrawsSystemBarBackgrounds"
>
true
</item>
<item
name=
"android:statusBarColor"
>
@android:color/transparent
</item>
<item
name=
"android:statusBarColor"
>
@android:color/transparent
</item>
</style>
</style>
<style
name=
"stats_status"
>
<item
name=
"android:ellipsize"
>
marquee
</item>
</style>
</resources>
</resources>
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