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
69d2bc1e
Commit
69d2bc1e
authored
Jan 05, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set card background using StateListDrawable
parent
af9e8c78
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
19 deletions
+29
-19
src/main/res/drawable/background_profile.xml
src/main/res/drawable/background_profile.xml
+25
-0
src/main/res/drawable/background_selected.xml
src/main/res/drawable/background_selected.xml
+0
-15
src/main/res/layout/layout_profile.xml
src/main/res/layout/layout_profile.xml
+0
-1
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
+4
-3
No files found.
src/main/res/drawable/background_
selectab
le.xml
→
src/main/res/drawable/background_
profi
le.xml
View file @
69d2bc1e
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<layer-list
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item>
<item>
<shape
android:shape=
"rectangle"
>
<selector>
<solid
android:color=
"@color/material_primary_300"
/>
<item
android:state_selected=
"true"
>
<corners
android:radius=
"4dp"
/>
<shape
android:shape=
"rectangle"
>
</shape>
<solid
android:color=
"@color/material_green_700"
/>
<corners
android:radius=
"4dp"
/>
</shape>
</item>
<item>
<shape
android:shape=
"rectangle"
>
<solid
android:color=
"@color/material_primary_300"
/>
<corners
android:radius=
"4dp"
/>
</shape>
</item>
</selector>
</item>
</item>
<item
android:left=
"8dp"
>
<item
android:left=
"8dp"
>
<shape
android:shape=
"rectangle"
>
<shape
android:shape=
"rectangle"
>
...
...
src/main/res/drawable/background_selected.xml
deleted
100644 → 0
View file @
af9e8c78
<?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"
/>
<corners
android:radius=
"4dp"
/>
</shape>
</item>
<item
android:left=
"8dp"
>
<shape
android:shape=
"rectangle"
>
<solid
android:color=
"@android:color/white"
/>
<corners
android:bottomRightRadius=
"4dp"
android:topRightRadius=
"4dp"
/>
</shape>
</item>
</layer-list>
src/main/res/layout/layout_profile.xml
View file @
69d2bc1e
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
>
<com.github.shadowsocks.widget.BoundedCardView
android:layout_width=
"match_parent"
<com.github.shadowsocks.widget.BoundedCardView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/background_selectable"
android:layout_marginTop=
"8dp"
android:layout_marginTop=
"8dp"
android:layout_marginStart=
"8dp"
android:layout_marginStart=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginEnd=
"8dp"
...
...
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
View file @
69d2bc1e
...
@@ -79,11 +79,12 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
...
@@ -79,11 +79,12 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
private
val
title
=
itemView
.
findViewById
(
R
.
id
.
title
).
asInstanceOf
[
TextView
]
private
val
title
=
itemView
.
findViewById
(
R
.
id
.
title
).
asInstanceOf
[
TextView
]
private
val
address
=
itemView
.
findViewById
(
R
.
id
.
address
).
asInstanceOf
[
TextView
]
private
val
address
=
itemView
.
findViewById
(
R
.
id
.
address
).
asInstanceOf
[
TextView
]
private
val
traffic
=
itemView
.
findViewById
(
R
.
id
.
traffic
).
asInstanceOf
[
TextView
]
private
val
traffic
=
itemView
.
findViewById
(
R
.
id
.
traffic
).
asInstanceOf
[
TextView
]
private
val
indicator
=
itemView
.
findViewById
(
R
.
id
.
indicator
).
asInstanceOf
[
ViewGroup
]
private
val
edit
=
itemView
.
findViewById
(
R
.
id
.
edit
)
private
val
edit
=
itemView
.
findViewById
(
R
.
id
.
edit
)
edit
.
setOnClickListener
(
_
=>
startConfig
(
item
.
id
))
edit
.
setOnClickListener
(
_
=>
startConfig
(
item
.
id
))
edit
.
setOnLongClickListener
(
cardButtonLongClickListener
)
edit
.
setOnLongClickListener
(
cardButtonLongClickListener
)
itemView
.
setOnClickListener
(
this
)
itemView
.
setOnClickListener
(
this
)
// it will not take effect unless set in code
itemView
.
findViewById
(
R
.
id
.
indicator
).
setBackgroundResource
(
R
.
drawable
.
background_profile
)
private
var
adView
:
NativeExpressAdView
=
_
private
var
adView
:
NativeExpressAdView
=
_
...
@@ -115,10 +116,10 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
...
@@ -115,10 +116,10 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
TrafficMonitor
.
formatTraffic
(
tx
),
TrafficMonitor
.
formatTraffic
(
rx
)))
TrafficMonitor
.
formatTraffic
(
tx
),
TrafficMonitor
.
formatTraffic
(
rx
)))
if
(
item
.
id
==
app
.
profileId
)
{
if
(
item
.
id
==
app
.
profileId
)
{
i
ndicator
.
setBackgroundResource
(
R
.
drawable
.
background_selected
)
i
temView
.
setSelected
(
true
)
selectedItem
=
this
selectedItem
=
this
}
else
{
}
else
{
i
ndicator
.
setBackgroundResource
(
R
.
drawable
.
background_selectabl
e
)
i
temView
.
setSelected
(
fals
e
)
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