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
e8ff469e
Commit
e8ff469e
authored
Dec 18, 2016
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add indicator for profile items
parent
e7d2dec9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
57 deletions
+90
-57
src/main/res/drawable/background_selectable.xml
src/main/res/drawable/background_selectable.xml
+13
-0
src/main/res/drawable/background_selected.xml
src/main/res/drawable/background_selected.xml
+13
-0
src/main/res/layout/layout_main.xml
src/main/res/layout/layout_main.xml
+17
-16
src/main/res/layout/layout_profiles_item.xml
src/main/res/layout/layout_profiles_item.xml
+40
-36
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
+7
-5
No files found.
src/main/res/drawable/background_selectable.xml
0 → 100644
View file @
e8ff469e
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item>
<shape
android:shape=
"rectangle"
>
<solid
android:color=
"@color/material_blue_grey_300"
/>
</shape>
</item>
<item
android:left=
"8dp"
>
<shape
android:shape=
"rectangle"
>
<solid
android:color=
"@android:color/white"
/>
</shape>
</item>
</layer-list>
src/main/res/drawable/background_selected.xml
0 → 100644
View file @
e8ff469e
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item>
<shape
android:shape=
"rectangle"
>
<solid
android:color=
"@color/material_green_700"
/>
</shape>
</item>
<item
android:left=
"8dp"
>
<shape
android:shape=
"rectangle"
>
<solid
android:color=
"@android:color/white"
/>
</shape>
</item>
</layer-list>
src/main/res/layout/layout_main.xml
View file @
e8ff469e
...
@@ -20,22 +20,6 @@
...
@@ -20,22 +20,6 @@
android:orientation=
"vertical"
android:orientation=
"vertical"
android:nextFocusRight=
"@+id/fab"
android:nextFocusRight=
"@+id/fab"
android:layout_alignParentBottom=
"true"
>
android:layout_alignParentBottom=
"true"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<TextView
android:text=
"@string/stat"
android:textSize=
"16sp"
android:textColor=
"?android:attr/textColorPrimary"
android:ellipsize=
"marquee"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/connection_test"
android:gravity=
"end"
android:textSize=
"14sp"
android:textColor=
"?android:attr/textColorSecondary"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
/>
</LinearLayout>
<android.support.v7.widget.GridLayout
android:layout_width=
"match_parent"
<android.support.v7.widget.GridLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:paddingEnd=
"72dip"
android:paddingEnd=
"72dip"
...
@@ -74,6 +58,23 @@
...
@@ -74,6 +58,23 @@
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
app:layout_columnWeight=
"1"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
app:layout_columnWeight=
"1"
app:layout_gravity=
"fill_horizontal"
android:gravity=
"end"
/>
app:layout_gravity=
"fill_horizontal"
android:gravity=
"end"
/>
</android.support.v7.widget.GridLayout>
</android.support.v7.widget.GridLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
>
<TextView
android:text=
"@string/stat"
android:textSize=
"16sp"
android:textColor=
"?android:attr/textColorPrimary"
android:ellipsize=
"marquee"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/connection_test"
android:gravity=
"end"
android:textSize=
"14sp"
android:textColor=
"?android:attr/textColorSecondary"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<com.github.jorgecastilloprz.FABProgressCircle
android:id=
"@+id/fabProgressCircle"
<com.github.jorgecastilloprz.FABProgressCircle
android:id=
"@+id/fabProgressCircle"
app:reusable=
"true"
app:reusable=
"true"
...
...
src/main/res/layout/layout_profiles_item.xml
View file @
e8ff469e
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- Based on: https://github.com/android/platform_frameworks_base/blob/505e3ab/core/res/res/layout/simple_list_item_2.xml -->
<!-- Based on: https://github.com/android/platform_frameworks_base/blob/505e3ab/core/res/res/layout/simple_list_item_2.xml -->
<android.support.v7.widget.CardView
xmlns:android=
"http://schemas.android.com/apk/res/android"
<android.support.v7.widget.CardView
xmlns:android=
"http://schemas.android.com/apk/res/android"
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:background=
"?android:attr/selectableItemBackground
"
android:focusable=
"true
"
android:focusable=
"true
"
android:nextFocusRight=
"@+id/edit
"
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"
>
<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:layout_margin=
"8dp"
>
android:padding=
"8dp"
android:id=
"@+id/indicator"
android:background=
"@drawable/background_selectable"
>
<LinearLayout
android:layout_width=
"match_parent"
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/container"
>
android:layout_marginStart=
"8dp"
android:id=
"@+id/container"
>
<TextView
android:id=
"@android:id/text1"
<TextView
android:id=
"@android:id/text1"
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"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:textAppearance=
"?android:attr/textAppearanceLarge"
android:textAppearance=
"?android:attr/textAppearanceLarge"
android:textColor=
"?android:attr/textColorPrimary"
android:textColor=
"?android:attr/textColorPrimary"
android:gravity=
"center_vertical"
android:gravity=
"center_vertical"
android:maxLines=
"2"
android:maxLines=
"2"
android:ellipsize=
"end"
/>
android:ellipsize=
"end"
/>
<android.support.v7.widget.AppCompatImageView
android:id=
"@+id/edit"
<android.support.v7.widget.AppCompatImageView
android:id=
"@+id/edit"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"4dp"
android:padding=
"4dp"
android:layout_gravity=
"top"
android:layout_gravity=
"top"
app:srcCompat=
"@drawable/ic_image_edit"
app:srcCompat=
"@drawable/ic_image_edit"
android:background=
"?attr/selectableItemBackgroundBorderless"
android:background=
"?attr/selectableItemBackgroundBorderless"
android:contentDescription=
"Edit"
android:contentDescription=
"Edit"
android:focusable=
"true"
android:focusable=
"true"
android:nextFocusLeft=
"@+id/container"
/>
android:nextFocusLeft=
"@+id/container"
/>
</LinearLayout>
</LinearLayout>
<TextView
android:id=
"@android:id/text2"
<TextView
android:id=
"@android:id/text2"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:textAppearance=
"?android:attr/textAppearanceMedium"
android:layout_marginStart=
"8dp"
android:textColor=
"?android:attr/textColorSecondary"
/>
android:textAppearance=
"?android:attr/textAppearanceMedium"
android:textColor=
"?android:attr/textColorSecondary"
/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.v7.widget.CardView>
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
View file @
e8ff469e
...
@@ -45,6 +45,7 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
...
@@ -45,6 +45,7 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
var
item
:
Profile
=
_
var
item
:
Profile
=
_
private
val
text1
=
itemView
.
findViewById
(
android
.
R
.
id
.
text1
).
asInstanceOf
[
TextView
]
private
val
text1
=
itemView
.
findViewById
(
android
.
R
.
id
.
text1
).
asInstanceOf
[
TextView
]
private
val
text2
=
itemView
.
findViewById
(
android
.
R
.
id
.
text2
).
asInstanceOf
[
TextView
]
private
val
text2
=
itemView
.
findViewById
(
android
.
R
.
id
.
text2
).
asInstanceOf
[
TextView
]
private
val
indicator
=
itemView
.
findViewById
(
R
.
id
.
indicator
).
asInstanceOf
[
ViewGroup
]
itemView
.
setOnClickListener
(
this
)
itemView
.
setOnClickListener
(
this
)
{
{
...
@@ -65,15 +66,14 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
...
@@ -65,15 +66,14 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
val
builder
=
new
StringBuilder
()
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
else
builder
.
append
(
address
)
if
(
tx
!=
0
||
rx
!=
0
)
{
//
if (tx != 0 || rx != 0) {
if
(
builder
.
nonEmpty
)
builder
.
append
(
'\n'
)
if
(
builder
.
nonEmpty
)
builder
.
append
(
'\n'
)
builder
.
append
(
getString
(
R
.
string
.
stat_profiles
,
builder
.
append
(
getString
(
R
.
string
.
stat_profiles
,
TrafficMonitor
.
formatTraffic
(
tx
),
TrafficMonitor
.
formatTraffic
(
rx
)))
TrafficMonitor
.
formatTraffic
(
tx
),
TrafficMonitor
.
formatTraffic
(
rx
)))
}
//
}
handler
.
post
(()
=>
{
handler
.
post
(()
=>
{
text1
.
setText
(
title
)
text1
.
setText
(
title
)
text2
.
setText
(
builder
)
text2
.
setText
(
builder
)
text2
.
setVisibility
(
if
(
builder
.
isEmpty
)
View
.
GONE
else
View
.
VISIBLE
)
})
})
}
}
...
@@ -81,10 +81,12 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
...
@@ -81,10 +81,12 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
this
.
item
=
item
this
.
item
=
item
updateText
()
updateText
()
if
(
item
.
id
==
app
.
profileId
)
{
if
(
item
.
id
==
app
.
profileId
)
{
text1
.
setTypeface
(
null
,
Typeface
.
BOLD
)
// text1.setTypeface(null, Typeface.BOLD)
indicator
.
setBackgroundResource
(
R
.
drawable
.
background_selected
)
selectedItem
=
this
selectedItem
=
this
}
else
{
}
else
{
text1
.
setTypeface
(
null
,
Typeface
.
NORMAL
)
// text1.setTypeface(null, Typeface.NORMAL)
indicator
.
setBackgroundResource
(
R
.
drawable
.
background_selectable
)
if
(
selectedItem
eq
this
)
selectedItem
=
null
if
(
selectedItem
eq
this
)
selectedItem
=
null
}
}
}
}
...
...
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