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
02513418
Commit
02513418
authored
Dec 16, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the no longer needed quick switch
parent
59c5d01c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
3 additions
and
127 deletions
+3
-127
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+0
-12
src/main/res/xml/shortcuts.xml
src/main/res/xml/shortcuts.xml
+0
-8
src/main/scala/com/github/shadowsocks/ShadowsocksNotification.scala
...cala/com/github/shadowsocks/ShadowsocksNotification.scala
+3
-10
src/main/scala/com/github/shadowsocks/ShadowsocksQuickSwitchActivity.scala
...m/github/shadowsocks/ShadowsocksQuickSwitchActivity.scala
+0
-96
src/main/scala/com/github/shadowsocks/utils/Constants.scala
src/main/scala/com/github/shadowsocks/utils/Constants.scala
+0
-1
No files found.
src/main/AndroidManifest.xml
View file @
02513418
...
...
@@ -98,18 +98,6 @@
</intent-filter>
</activity>
<activity
android:name=
".ShadowsocksQuickSwitchActivity"
android:label=
"@string/quick_switch"
android:launchMode=
"singleInstance"
android:excludeFromRecents=
"true"
android:taskAffinity=
""
android:theme=
"@style/Theme.Material.Dialog"
>
<intent-filter>
<action
android:name=
"com.github.shadowsocks.QUICK_SWITCH"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</activity>
<activity
android:name=
".QuickToggleShortcut"
android:label=
"@string/quick_toggle"
...
...
src/main/res/xml/shortcuts.xml
View file @
02513418
...
...
@@ -8,14 +8,6 @@
android:targetPackage=
"com.github.shadowsocks"
android:targetClass=
"com.github.shadowsocks.QuickToggleShortcut"
/>
</shortcut>
<shortcut
android:shortcutId=
"switch"
android:icon=
"@drawable/ic_qu_shadowsocks_launcher"
android:shortcutShortLabel=
"@string/quick_switch"
android:shortcutLongLabel=
"@string/quick_switch"
>
<intent
android:action=
"android.intent.action.MAIN"
android:targetPackage=
"com.github.shadowsocks"
android:targetClass=
"com.github.shadowsocks.ShadowsocksQuickSwitchActivity"
/>
</shortcut>
<shortcut
android:shortcutId=
"scan"
android:icon=
"@drawable/ic_qu_camera_launcher"
android:shortcutShortLabel=
"@string/add_profile_methods_scan_qr_code"
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksNotification.scala
View file @
02513418
...
...
@@ -24,13 +24,12 @@ import java.util.Locale
import
android.app.
{
KeyguardManager
,
NotificationManager
,
PendingIntent
}
import
android.content.
{
BroadcastReceiver
,
Context
,
Intent
,
IntentFilter
}
import
android.os.
PowerManager
import
android.os.
{
Build
,
PowerManager
}
import
android.support.v4.app.NotificationCompat
import
android.support.v4.app.NotificationCompat.BigTextStyle
import
android.support.v4.content.ContextCompat
import
com.github.shadowsocks.aidl.IShadowsocksServiceCallback.Stub
import
com.github.shadowsocks.utils.
{
TrafficMonitor
,
Action
,
State
,
Utils
}
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.utils.
{
Action
,
State
,
TrafficMonitor
,
Utils
}
/**
* @author Mygod
...
...
@@ -60,14 +59,8 @@ class ShadowsocksNotification(private val service: BaseService, profileName: Str
.
setContentIntent
(
PendingIntent
.
getActivity
(
service
,
0
,
new
Intent
(
service
,
classOf
[
MainActivity
])
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
),
0
))
.
setSmallIcon
(
R
.
drawable
.
ic_stat_shadowsocks
)
builder
.
addAction
(
R
.
drawable
.
ic_navigation_close
,
if
(
Build
.
VERSION
.
SDK_INT
<
24
)
builder
.
addAction
(
R
.
drawable
.
ic_navigation_close
,
service
.
getString
(
R
.
string
.
stop
),
PendingIntent
.
getBroadcast
(
service
,
0
,
new
Intent
(
Action
.
CLOSE
),
0
))
app
.
profileManager
.
getAllProfiles
match
{
case
Some
(
profiles
)
=>
if
(
profiles
.
length
>
1
)
builder
.
addAction
(
R
.
drawable
.
ic_action_settings
,
service
.
getString
(
R
.
string
.
quick_switch
),
PendingIntent
.
getActivity
(
service
,
0
,
new
Intent
(
Action
.
QUICK_SWITCH
),
0
))
case
_
=>
}
private
lazy
val
style
=
new
BigTextStyle
(
builder
)
private
var
isVisible
=
true
update
(
if
(
service
.
getSystemService
(
Context
.
POWER_SERVICE
).
asInstanceOf
[
PowerManager
].
isScreenOn
)
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksQuickSwitchActivity.scala
deleted
100644 → 0
View file @
59c5d01c
/*******************************************************************************/
/* */
/* Copyright (C) 2016 by Max Lv <max.c.lv@gmail.com> */
/* Copyright (C) 2016 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
import
android.content.pm.ShortcutManager
import
android.content.res.Resources
import
android.os.
{
Build
,
Bundle
}
import
android.support.v7.app.AppCompatActivity
import
android.support.v7.widget.
{
DefaultItemAnimator
,
LinearLayoutManager
,
RecyclerView
,
Toolbar
}
import
android.view.
{
LayoutInflater
,
View
,
ViewGroup
}
import
android.widget.CheckedTextView
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.utils.Utils
import
com.github.shadowsocks.ShadowsocksApplication.app
/**
* Created by Lucas on 3/10/16.
*/
class
ShadowsocksQuickSwitchActivity
extends
AppCompatActivity
{
private
class
ProfileViewHolder
(
val
view
:
View
)
extends
RecyclerView
.
ViewHolder
(
view
)
with
View
.
OnClickListener
{
{
val
typedArray
=
obtainStyledAttributes
(
Array
(
android
.
R
.
attr
.
selectableItemBackground
))
view
.
setBackgroundResource
(
typedArray
.
getResourceId
(
0
,
0
))
typedArray
.
recycle
()
}
private
var
item
:
Profile
=
_
private
val
text
=
itemView
.
findViewById
(
android
.
R
.
id
.
text1
).
asInstanceOf
[
CheckedTextView
]
itemView
.
setOnClickListener
(
this
)
def
bind
(
item
:
Profile
)
{
this
.
item
=
item
text
.
setText
(
item
.
name
)
text
.
setChecked
(
item
.
id
==
app
.
profileId
)
}
def
onClick
(
v
:
View
)
{
app
.
switchProfile
(
item
.
id
)
Utils
.
startSsService
(
ShadowsocksQuickSwitchActivity
.
this
)
finish
()
}
}
private
class
ProfilesAdapter
extends
RecyclerView
.
Adapter
[
ProfileViewHolder
]
{
val
profiles
:
List
[
Profile
]
=
app
.
profileManager
.
getAllProfiles
.
getOrElse
(
List
.
empty
[
Profile
])
def
getItemCount
:
Int
=
profiles
.
length
def
onBindViewHolder
(
vh
:
ProfileViewHolder
,
i
:
Int
)
:
Unit
=
i
match
{
case
_
=>
vh
.
bind
(
profiles
(
i
))
}
private
val
name
=
"select_dialog_singlechoice_"
+
(
if
(
Build
.
VERSION
.
SDK_INT
>=
21
)
"material"
else
"holo"
)
def
onCreateViewHolder
(
vg
:
ViewGroup
,
i
:
Int
)
=
new
ProfileViewHolder
(
LayoutInflater
.
from
(
vg
.
getContext
)
.
inflate
(
Resources
.
getSystem
.
getIdentifier
(
name
,
"layout"
,
"android"
),
vg
,
false
))
}
private
val
profilesAdapter
=
new
ProfilesAdapter
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
layout_quick_switch
)
val
toolbar
=
findViewById
(
R
.
id
.
toolbar
).
asInstanceOf
[
Toolbar
]
toolbar
.
setTitle
(
R
.
string
.
quick_switch
)
val
profilesList
=
findViewById
(
R
.
id
.
profilesList
).
asInstanceOf
[
RecyclerView
]
val
lm
=
new
LinearLayoutManager
(
this
)
profilesList
.
setLayoutManager
(
lm
)
profilesList
.
setItemAnimator
(
new
DefaultItemAnimator
)
profilesList
.
setAdapter
(
profilesAdapter
)
if
(
app
.
profileId
>=
0
)
lm
.
scrollToPosition
(
profilesAdapter
.
profiles
.
zipWithIndex
.
collectFirst
{
case
(
profile
,
i
)
if
profile
.
id
==
app
.
profileId
=>
i
}.
getOrElse
(
0
))
if
(
Build
.
VERSION
.
SDK_INT
>=
25
)
getSystemService
(
classOf
[
ShortcutManager
]).
reportShortcutUsed
(
"switch"
)
}
}
src/main/scala/com/github/shadowsocks/utils/Constants.scala
View file @
02513418
...
...
@@ -173,7 +173,6 @@ object Action {
final
val
CONNECTED
=
"com.github.shadowsocks.CONNECTED"
// TODO
final
val
PROFILE_CHANGED
=
"com.github.shadowsocks.PROFILE_CHANGED"
final
val
PROFILE_REMOVED
=
"com.github.shadowsocks.PROFILE_REMOVED"
final
val
QUICK_SWITCH
=
"com.github.shadowsocks.QUICK_SWITCH"
final
val
EXTRA_PROFILE_ID
=
"com.github.shadowsocks.EXTRA_PROFILE_ID"
}
...
...
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