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
3a66bbba
Commit
3a66bbba
authored
Dec 24, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move share functionality to ProfilesFragment
parent
5898d291
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
37 deletions
+63
-37
src/main/res/drawable/ic_social_share.xml
src/main/res/drawable/ic_social_share.xml
+9
-0
src/main/res/layout/layout_profiles_item.xml
src/main/res/layout/layout_profiles_item.xml
+11
-2
src/main/res/menu/profile_config_menu.xml
src/main/res/menu/profile_config_menu.xml
+0
-16
src/main/res/menu/profile_share_popup.xml
src/main/res/menu/profile_share_popup.xml
+11
-0
src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala
.../scala/com/github/shadowsocks/ProfileConfigFragment.scala
+3
-10
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
+29
-9
No files found.
src/main/res/drawable/ic_social_share.xml
0 → 100644
View file @
3a66bbba
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"24dp"
android:height=
"24dp"
android:viewportWidth=
"24.0"
android:viewportHeight=
"24.0"
>
<path
android:fillColor=
"#FF000000"
android:pathData=
"M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"
/>
</vector>
src/main/res/layout/layout_profiles_item.xml
View file @
3a66bbba
...
...
@@ -31,6 +31,16 @@
android:gravity=
"center_vertical"
android:maxLines=
"2"
android:ellipsize=
"end"
/>
<android.support.v7.widget.AppCompatImageView
android:id=
"@+id/share"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"4dp"
android:layout_gravity=
"top"
app:srcCompat=
"@drawable/ic_social_share"
android:background=
"?attr/selectableItemBackgroundBorderless"
android:contentDescription=
"Share"
android:focusable=
"true"
android:nextFocusLeft=
"@+id/container"
/>
<android.support.v7.widget.AppCompatImageView
android:id=
"@+id/edit"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
@@ -39,8 +49,7 @@
app:srcCompat=
"@drawable/ic_image_edit"
android:background=
"?attr/selectableItemBackgroundBorderless"
android:contentDescription=
"Edit"
android:focusable=
"true"
android:nextFocusLeft=
"@+id/container"
/>
android:focusable=
"true"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
...
...
src/main/res/menu/profile_config_menu.xml
View file @
3a66bbba
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<item
android:title=
"@string/share"
android:icon=
"@drawable/abc_ic_menu_share_mtrl_alpha"
android:alphabeticShortcut=
"s"
android:numericShortcut=
"1"
app:showAsAction=
"always"
>
<menu>
<item
android:id=
"@+id/action_qr_code_nfc"
android:title=
"QR code/NFC"
android:alphabeticShortcut=
"q"
android:numericShortcut=
"1"
/>
<item
android:id=
"@+id/action_export"
android:title=
"@string/action_export"
android:alphabeticShortcut=
"e"
android:numericShortcut=
"2"
/>
</menu>
</item>
<item
android:id=
"@+id/action_delete"
android:title=
"Delete"
android:icon=
"@drawable/ic_action_delete"
...
...
src/main/res/menu/profile_share_popup.xml
0 → 100644
View file @
3a66bbba
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:id=
"@+id/action_qr_code_nfc"
android:title=
"QR code/NFC"
android:alphabeticShortcut=
"q"
android:numericShortcut=
"1"
/>
<item
android:id=
"@+id/action_export"
android:title=
"@string/action_export"
android:alphabeticShortcut=
"e"
android:numericShortcut=
"2"
/>
</menu>
src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala
View file @
3a66bbba
...
...
@@ -20,16 +20,16 @@
package
com.github.shadowsocks
import
android.content.
{
DialogInterface
,
Intent
,
SharedPreferences
}
import
android.content.SharedPreferences.OnSharedPreferenceChangeListener
import
android.content._
import
android.os._
import
android.os.
{
Build
,
Bundle
,
UserManager
}
import
android.support.v14.preference.SwitchPreference
import
android.support.v4.content.LocalBroadcastManager
import
android.support.v7.app.AlertDialog
import
android.support.v7.preference.Preference
import
android.support.v7.widget.Toolbar.OnMenuItemClickListener
import
android.view.MenuItem
import
be.mygod.preference.
_
import
be.mygod.preference.
PreferenceFragment
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.preferences.KcpCliPreferenceDialogFragment
...
...
@@ -37,7 +37,6 @@ import com.github.shadowsocks.utils.{Action, Key, Utils}
class
ProfileConfigFragment
extends
PreferenceFragment
with
OnMenuItemClickListener
with
OnSharedPreferenceChangeListener
{
private
lazy
val
clipboard
=
getActivity
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
).
asInstanceOf
[
ClipboardManager
]
private
var
profile
:
Profile
=
_
private
var
isProxyApps
:
SwitchPreference
=
_
...
...
@@ -83,12 +82,6 @@ class ProfileConfigFragment extends PreferenceFragment with OnMenuItemClickListe
}
override
def
onMenuItemClick
(
item
:
MenuItem
)
:
Boolean
=
item
.
getItemId
match
{
case
R
.
id
.
action_qr_code_nfc
=>
getFragmentManager
.
beginTransaction
().
add
(
new
QRCodeDialog
(
profile
.
toString
),
""
).
commitAllowingStateLoss
()
true
case
R
.
id
.
action_export
=>
clipboard
.
setPrimaryClip
(
ClipData
.
newPlainText
(
null
,
profile
.
toString
))
true
case
R
.
id
.
action_delete
=>
new
AlertDialog
.
Builder
(
getActivity
)
.
setTitle
(
"Confirm?"
)
// TODO
...
...
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
View file @
3a66bbba
...
...
@@ -25,13 +25,13 @@ import java.util.GregorianCalendar
import
android.content._
import
android.os.
{
Bundle
,
Handler
}
import
android.support.v4.content.LocalBroadcastManager
import
android.support.v7.widget.
{
DefaultItemAnimator
,
LinearLayoutManager
,
RecyclerView
,
Toolbar
}
import
android.support.v7.widget.RecyclerView.ViewHolder
import
android.support.v7.widget.Toolbar.OnMenuItemClickListener
import
android.support.v7.widget._
import
android.support.v7.widget.helper.ItemTouchHelper
import
android.support.v7.widget.helper.ItemTouchHelper.SimpleCallback
import
android.view._
import
android.widget.
{
LinearLayout
,
TextView
,
Toast
}
import
android.view.View.OnLongClickListener
import
android.widget.
{
LinearLayout
,
PopupMenu
,
TextView
,
Toast
}
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.utils._
...
...
@@ -41,9 +41,15 @@ import com.google.android.gms.ads.{AdRequest, AdSize, NativeExpressAdView}
import
scala.collection.mutable.ArrayBuffer
import
scala.util.Random
final
class
ProfilesFragment
extends
ToolbarFragment
with
OnMenuItemClickListener
{
final
class
ProfilesFragment
extends
ToolbarFragment
with
Toolbar
.
OnMenuItemClickListener
{
private
val
cardButtonLongClickListener
:
OnLongClickListener
=
view
=>
{
Utils
.
positionToast
(
Toast
.
makeText
(
getActivity
,
view
.
getContentDescription
,
Toast
.
LENGTH_SHORT
),
view
,
getActivity
.
getWindow
,
0
,
Utils
.
dpToPx
(
getActivity
,
8
)).
show
()
true
}
private
final
class
ProfileViewHolder
(
val
view
:
View
)
extends
RecyclerView
.
ViewHolder
(
view
)
with
View
.
OnClickListener
{
with
View
.
OnClickListener
with
PopupMenu
.
OnMenuItemClickListener
{
var
item
:
Profile
=
_
...
...
@@ -59,11 +65,15 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
{
val
edit
=
itemView
.
findViewById
(
R
.
id
.
edit
)
edit
.
setOnClickListener
(
_
=>
startConfig
(
item
.
id
))
edit
.
setOnLongClickListener
(
_
=>
{
Utils
.
positionToast
(
Toast
.
makeText
(
getActivity
,
edit
.
getContentDescription
,
Toast
.
LENGTH_SHORT
),
edit
,
getActivity
.
getWindow
,
0
,
Utils
.
dpToPx
(
getActivity
,
8
)).
show
()
true
edit
.
setOnLongClickListener
(
cardButtonLongClickListener
)
val
share
=
itemView
.
findViewById
(
R
.
id
.
share
)
share
.
setOnClickListener
(
_
=>
{
val
popup
=
new
PopupMenu
(
getActivity
,
share
)
popup
.
getMenuInflater
.
inflate
(
R
.
menu
.
profile_share_popup
,
popup
.
getMenu
)
popup
.
setOnMenuItemClickListener
(
this
)
popup
.
show
()
})
share
.
setOnLongClickListener
(
cardButtonLongClickListener
)
}
def
updateText
(
txTotal
:
Long
=
0
,
rxTotal
:
Long
=
0
)
{
...
...
@@ -131,6 +141,16 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
if
(
state
==
State
.
CONNECTED
)
activity
.
serviceLoad
()
}
}
override
def
onMenuItemClick
(
item
:
MenuItem
)
:
Boolean
=
item
.
getItemId
match
{
case
R
.
id
.
action_qr_code_nfc
=>
getFragmentManager
.
beginTransaction
().
add
(
new
QRCodeDialog
(
item
.
toString
),
""
).
commitAllowingStateLoss
()
true
case
R
.
id
.
action_export
=>
clipboard
.
setPrimaryClip
(
ClipData
.
newPlainText
(
null
,
item
.
toString
))
true
case
_
=>
false
}
}
private
class
ProfilesAdapter
extends
RecyclerView
.
Adapter
[
ProfileViewHolder
]
{
...
...
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