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
c87930b2
Commit
c87930b2
authored
Dec 20, 2016
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine the profile item layout
parent
436119e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
23 deletions
+45
-23
src/main/res/layout/layout_profiles_item.xml
src/main/res/layout/layout_profiles_item.xml
+31
-11
src/main/res/values/strings.xml
src/main/res/values/strings.xml
+1
-1
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
+13
-11
No files found.
src/main/res/layout/layout_profiles_item.xml
View file @
c87930b2
...
@@ -4,23 +4,23 @@
...
@@ -4,23 +4,23 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:focusable=
"true"
android:background=
"@drawable/background_selectable"
android:nextFocusRight=
"@+id/edit"
android:background=
"?android:attr/selectableItemBackground"
android:layout_marginTop=
"8dp"
android:layout_marginTop=
"8dp"
android:layout_marginStart=
"8dp"
android:layout_marginStart=
"8dp"
android:layout_marginEnd=
"8dp"
>
android:layout_marginEnd=
"8dp"
android:id=
"@+id/indicator"
>
<LinearLayout
android:layout_width=
"match_parent"
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:orientation=
"vertical"
android:padding=
"8dp"
android:padding=
"8dp"
android:id=
"@+id/indicator"
android:focusable=
"true"
android:background=
"@drawable/background_selectable"
>
android:nextFocusRight=
"@+id/edit"
android:background=
"?android:attr/selectableItemBackground"
>
<LinearLayout
android:layout_width=
"match_parent"
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:layout_marginStart=
"8dp"
android:id=
"@+id/container"
>
android:id=
"@+id/container"
>
<TextView
android:id=
"@
android:id/text1
"
<TextView
android:id=
"@
+id/title
"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_gravity=
"center_vertical"
...
@@ -41,11 +41,31 @@
...
@@ -41,11 +41,31 @@
android:focusable=
"true"
android:focusable=
"true"
android:nextFocusLeft=
"@+id/container"
/>
android:nextFocusLeft=
"@+id/container"
/>
</LinearLayout>
</LinearLayout>
<TextView
android:id=
"@android:id/text2"
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:layout_marginStart=
"8dp"
android:textAppearance=
"?android:attr/textAppearanceMedium"
android:layout_marginTop=
"8dp"
android:textColor=
"?android:attr/textColorSecondary"
/>
android:id=
"@+id/details"
>
<TextView
android:id=
"@+id/address"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical|left"
android:gravity=
"center_vertical|left"
android:layout_weight=
"1"
android:maxLines=
"1"
android:ellipsize=
"end"
android:textAppearance=
"?android:attr/textAppearanceMedium"
android:textColor=
"?android:attr/textColorSecondary"
/>
<TextView
android:id=
"@+id/traffic"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical|right"
android:gravity=
"center_vertical|right"
android:layout_weight=
"1"
android:maxLines=
"1"
android:ellipsize=
"end"
android:textAppearance=
"?android:attr/textAppearanceMedium"
android:textColor=
"?android:attr/textColorSecondary"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.v7.widget.CardView>
src/main/res/values/strings.xml
View file @
c87930b2
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
<string
name=
"remote_dns_summary"
>
DNS server for remote hostname resolution. (Default 8.8.8.8)
</string>
<string
name=
"remote_dns_summary"
>
DNS server for remote hostname resolution. (Default 8.8.8.8)
</string>
<string
name=
"stat"
>
Network Traffic
</string>
<string
name=
"stat"
>
Network Traffic
</string>
<string
name=
"stat_summary"
>
Sent: \t\t\t\t\t%3$s\t↑\t%1$s/s\nReceived: \t%4$s\t↓\t%2$s/s
</string>
<string
name=
"stat_summary"
>
Sent: \t\t\t\t\t%3$s\t↑\t%1$s/s\nReceived: \t%4$s\t↓\t%2$s/s
</string>
<string
name=
"stat_profiles"
>
\n
%1$s↑\t%2$s↓
</string>
<string
name=
"stat_profiles"
>
%1$s↑\t%2$s↓
</string>
<string
name=
"traffic_summary"
>
%1$s/s↑\t%2$s/s↓
</string>
<string
name=
"traffic_summary"
>
%1$s/s↑\t%2$s/s↓
</string>
<plurals
name=
"bytes"
translatable=
"false"
>
<plurals
name=
"bytes"
translatable=
"false"
>
<item
quantity=
"one"
>
Byte
</item>
<item
quantity=
"one"
>
Byte
</item>
...
...
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
View file @
c87930b2
...
@@ -43,8 +43,9 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
...
@@ -43,8 +43,9 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
with
View
.
OnClickListener
{
with
View
.
OnClickListener
{
var
item
:
Profile
=
_
var
item
:
Profile
=
_
private
val
text1
=
itemView
.
findViewById
(
android
.
R
.
id
.
text1
).
asInstanceOf
[
TextView
]
private
val
text1
=
itemView
.
findViewById
(
R
.
id
.
title
).
asInstanceOf
[
TextView
]
private
val
text2
=
itemView
.
findViewById
(
android
.
R
.
id
.
text2
).
asInstanceOf
[
TextView
]
private
val
text2
=
itemView
.
findViewById
(
R
.
id
.
address
).
asInstanceOf
[
TextView
]
private
val
text3
=
itemView
.
findViewById
(
R
.
id
.
traffic
).
asInstanceOf
[
TextView
]
private
val
indicator
=
itemView
.
findViewById
(
R
.
id
.
indicator
).
asInstanceOf
[
ViewGroup
]
private
val
indicator
=
itemView
.
findViewById
(
R
.
id
.
indicator
).
asInstanceOf
[
ViewGroup
]
itemView
.
setOnClickListener
(
this
)
itemView
.
setOnClickListener
(
this
)
...
@@ -63,17 +64,15 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
...
@@ -63,17 +64,15 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
val
tx
=
item
.
tx
+
txTotal
val
tx
=
item
.
tx
+
txTotal
val
rx
=
item
.
rx
+
rxTotal
val
rx
=
item
.
rx
+
rxTotal
var
title
=
if
(
isDemoMode
)
"Profile #"
+
item
.
id
else
item
.
name
var
title
=
if
(
isDemoMode
)
"Profile #"
+
item
.
id
else
item
.
name
val
builder
=
new
StringBuilder
()
val
address
=
(
if
(
item
.
host
.
contains
(
":"
))
"[%s]:%d"
else
"%s:%d"
).
format
(
item
.
host
,
item
.
remotePort
)
val
address
=
(
if
(
item
.
host
.
contains
(
":"
))
"[%s]:%d"
else
"%s:%d"
).
format
(
item
.
host
,
item
.
remotePort
)
if
(
title
==
null
||
title
.
isEmpty
)
title
=
address
else
builder
.
append
(
address
)
if
(
title
==
null
||
title
.
isEmpty
)
title
=
address
// if (tx != 0 || rx != 0) {
val
traffic
=
getString
(
R
.
string
.
stat_profiles
,
if
(
builder
.
nonEmpty
)
builder
.
append
(
'\n'
)
TrafficMonitor
.
formatTraffic
(
tx
),
TrafficMonitor
.
formatTraffic
(
rx
))
builder
.
append
(
getString
(
R
.
string
.
stat_profiles
,
TrafficMonitor
.
formatTraffic
(
tx
),
TrafficMonitor
.
formatTraffic
(
rx
)))
// }
handler
.
post
(()
=>
{
handler
.
post
(()
=>
{
text1
.
setText
(
title
)
text1
.
setText
(
title
)
text2
.
setText
(
builder
)
text2
.
setText
(
address
)
text3
.
setText
(
traffic
)
})
})
}
}
...
@@ -92,11 +91,14 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
...
@@ -92,11 +91,14 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
}
}
def
onClick
(
v
:
View
)
{
def
onClick
(
v
:
View
)
{
if
(
getActivity
.
asInstanceOf
[
MainActivity
].
state
==
State
.
STOPPED
)
{
val
activity
=
getActivity
.
asInstanceOf
[
MainActivity
]
val
state
=
activity
.
state
if
(
state
==
State
.
STOPPED
||
state
==
State
.
CONNECTED
)
{
val
old
=
app
.
profileId
val
old
=
app
.
profileId
app
.
switchProfile
(
item
.
id
)
app
.
switchProfile
(
item
.
id
)
profilesAdapter
.
refreshId
(
old
)
profilesAdapter
.
refreshId
(
old
)
bind
(
item
)
bind
(
item
)
if
(
state
==
State
.
CONNECTED
)
activity
.
serviceLoad
()
}
}
}
}
}
}
...
...
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