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
5505c78f
Commit
5505c78f
authored
Nov 18, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine 'Replace CardView with normal list view'
parent
f59f7137
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
111 deletions
+78
-111
mobile/src/main/res/layout/layout_profile.xml
mobile/src/main/res/layout/layout_profile.xml
+76
-72
mobile/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
.../main/scala/com/github/shadowsocks/ProfilesFragment.scala
+2
-7
mobile/src/main/scala/com/github/shadowsocks/widget/BoundedCardView.scala
...scala/com/github/shadowsocks/widget/BoundedCardView.scala
+0
-32
No files found.
mobile/src/main/res/layout/layout_profile.xml
View file @
5505c78f
<?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 -->
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<LinearLayout
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:id=
"@+id/
ads
"
android:id=
"@+id/
indicator
"
android:orientation=
"vertical"
android:orientation=
"vertical"
android:
focusable=
"fals
e"
android:
background=
"@drawable/background_profil
e"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
>
<FrameLayout
android:layout_width=
"match_parent"
<LinearLayout
android:layout_height=
"wrap_content"
android:layout_width=
"match_parent"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/indicator"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:orientation=
"vertical"
android:paddingLeft=
"16dp"
android:paddingLeft=
"16dp"
...
@@ -22,11 +20,13 @@
...
@@ -22,11 +20,13 @@
android:nextFocusRight=
"@+id/edit"
android:nextFocusRight=
"@+id/edit"
android:id=
"@+id/content"
android:id=
"@+id/content"
android:background=
"?android:attr/selectableItemBackground"
>
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=
"@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"
...
@@ -37,7 +37,8 @@
...
@@ -37,7 +37,8 @@
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/share"
<android.support.v7.widget.AppCompatImageView
android:id=
"@+id/share"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"8dp"
android:padding=
"8dp"
...
@@ -47,7 +48,8 @@
...
@@ -47,7 +48,8 @@
android:contentDescription=
"@string/share"
android:contentDescription=
"@string/share"
android:focusable=
"true"
android:focusable=
"true"
android:nextFocusLeft=
"@+id/container"
/>
android:nextFocusLeft=
"@+id/container"
/>
<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=
"8dp"
android:padding=
"8dp"
...
@@ -57,10 +59,12 @@
...
@@ -57,10 +59,12 @@
android:contentDescription=
"@string/edit"
android:contentDescription=
"@string/edit"
android:focusable=
"true"
/>
android:focusable=
"true"
/>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width=
"match_parent"
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
>
android:layout_marginStart=
"8dp"
>
<TextView
android:id=
"@android:id/text2"
<TextView
android:id=
"@android:id/text2"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentStart=
"true"
android:layout_alignParentStart=
"true"
...
@@ -70,7 +74,8 @@
...
@@ -70,7 +74,8 @@
android:ellipsize=
"end"
android:ellipsize=
"end"
android:textAppearance=
"?android:attr/textAppearanceSmall"
android:textAppearance=
"?android:attr/textAppearanceSmall"
android:textColor=
"?android:attr/textColorSecondary"
/>
android:textColor=
"?android:attr/textColorSecondary"
/>
<TextView
android:id=
"@+id/traffic"
<TextView
android:id=
"@+id/traffic"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
android:layout_gravity=
"bottom"
...
@@ -80,5 +85,4 @@
...
@@ -80,5 +85,4 @@
android:textColor=
"?android:attr/textColorSecondary"
/>
android:textColor=
"?android:attr/textColorSecondary"
/>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</LinearLayout>
mobile/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
View file @
5505c78f
...
@@ -78,8 +78,6 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
...
@@ -78,8 +78,6 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
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
[
View
](
R
.
id
.
indicator
).
setBackgroundResource
(
R
.
drawable
.
background_profile
)
private
var
adView
:
AdView
=
_
private
var
adView
:
AdView
=
_
...
@@ -135,12 +133,11 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
...
@@ -135,12 +133,11 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
val
params
=
val
params
=
new
LinearLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
new
LinearLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
params
.
gravity
=
Gravity
.
CENTER_HORIZONTAL
params
.
gravity
=
Gravity
.
CENTER_HORIZONTAL
params
.
setMargins
(
0
,
0
,
0
,
0
)
adView
=
new
AdView
(
getActivity
)
adView
=
new
AdView
(
getActivity
)
adView
.
setLayoutParams
(
params
)
adView
.
setLayoutParams
(
params
)
adView
.
setAdUnitId
(
"ca-app-pub-9097031975646651/7760346322"
)
adView
.
setAdUnitId
(
"ca-app-pub-9097031975646651/7760346322"
)
adView
.
setAdSize
(
AdSize
.
SMART_BANNER
)
adView
.
setAdSize
(
AdSize
.
SMART_BANNER
)
itemView
.
findViewById
[
LinearLayout
](
R
.
id
.
ads
).
addView
(
adView
)
itemView
.
findViewById
[
LinearLayout
](
R
.
id
.
indicator
).
addView
(
adView
)
// Load Ad
// Load Ad
val
adBuilder
=
new
AdRequest
.
Builder
()
val
adBuilder
=
new
AdRequest
.
Builder
()
...
@@ -267,10 +264,8 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
...
@@ -267,10 +264,8 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
if
(
app
.
profileManager
.
getFirstProfile
.
isEmpty
)
app
.
dataStore
.
profileId
=
app
.
profileManager
.
createProfile
().
id
if
(
app
.
profileManager
.
getFirstProfile
.
isEmpty
)
app
.
dataStore
.
profileId
=
app
.
profileManager
.
createProfile
().
id
val
profilesList
=
view
.
findViewById
[
RecyclerView
](
R
.
id
.
list
)
val
profilesList
=
view
.
findViewById
[
RecyclerView
](
R
.
id
.
list
)
val
layoutManager
=
new
LinearLayoutManager
(
getActivity
,
LinearLayoutManager
.
VERTICAL
,
false
)
val
layoutManager
=
new
LinearLayoutManager
(
getActivity
,
LinearLayoutManager
.
VERTICAL
,
false
)
val
dividerItemDecoration
=
new
DividerItemDecoration
(
profilesList
.
getContext
(),
layoutManager
.
getOrientation
())
profilesList
.
setLayoutManager
(
layoutManager
)
profilesList
.
setLayoutManager
(
layoutManager
)
profilesList
.
addItemDecoration
(
dividerItemDecoration
)
profilesList
.
addItemDecoration
(
new
DividerItemDecoration
(
getActivity
,
layoutManager
.
getOrientation
)
)
layoutManager
.
scrollToPosition
(
profilesAdapter
.
profiles
.
zipWithIndex
.
collectFirst
{
layoutManager
.
scrollToPosition
(
profilesAdapter
.
profiles
.
zipWithIndex
.
collectFirst
{
case
(
profile
,
i
)
if
profile
.
id
==
app
.
dataStore
.
profileId
=>
i
case
(
profile
,
i
)
if
profile
.
id
==
app
.
dataStore
.
profileId
=>
i
}.
getOrElse
(-
1
))
}.
getOrElse
(-
1
))
...
...
mobile/src/main/scala/com/github/shadowsocks/widget/BoundedCardView.scala
deleted
100644 → 0
View file @
f59f7137
/*******************************************************************************/
/* */
/* Copyright (C) 2017 by Max Lv <max.c.lv@gmail.com> */
/* Copyright (C) 2017 by Mygod Studio <contact-shadowsocks-android@mygod.be> */
/* */
/* This program is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*******************************************************************************/
package
com.github.shadowsocks.widget
import
android.content.Context
import
android.support.v7.widget.CardView
import
android.util.AttributeSet
/**
* @author Mygod
*/
class
BoundedCardView
(
context
:
Context
,
attrs
:
AttributeSet
)
extends
CardView
(
context
,
attrs
)
with
BoundedView
{
initAttrs
(
context
,
attrs
)
}
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