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
8a86176d
Commit
8a86176d
authored
Mar 18, 2016
by
Lucas Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle share intent in ProfileManagerActivity
parent
5fa8e966
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
124 deletions
+57
-124
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+12
-20
src/main/scala/com/github/shadowsocks/ParserActivity.scala
src/main/scala/com/github/shadowsocks/ParserActivity.scala
+0
-104
src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala
...scala/com/github/shadowsocks/ProfileManagerActivity.scala
+45
-0
No files found.
src/main/AndroidManifest.xml
View file @
8a86176d
...
...
@@ -46,25 +46,6 @@
</intent-filter>
</activity>
<activity
android:name=
".ParserActivity"
android:theme=
"@style/PopupTheme"
android:excludeFromRecents=
"true"
android:taskAffinity=
""
android:launchMode=
"singleTask"
>
<intent-filter>
<action
android:name=
"android.intent.action.VIEW"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<category
android:name=
"android.intent.category.BROWSABLE"
/>
<data
android:scheme=
"ss"
/>
</intent-filter>
<intent-filter>
<action
android:name=
"android.nfc.action.NDEF_DISCOVERED"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<data
android:scheme=
"ss"
/>
</intent-filter>
</activity>
<activity
android:name=
".ShadowsocksRunnerActivity"
android:theme=
"@android:style/Theme.NoDisplay"
...
...
@@ -75,12 +56,23 @@
android:name=
".ProfileManagerActivity"
android:label=
"@string/profiles"
android:parentActivityName=
".Shadowsocks"
android:ex
ported=
"fals
e"
android:ex
cludeFromRecents=
"tru
e"
android:launchMode=
"singleTask"
>
<intent-filter>
<action
android:name=
"com.github.shadowsocks.ProfileManagerActivity"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.VIEW"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<category
android:name=
"android.intent.category.BROWSABLE"
/>
<data
android:scheme=
"ss"
/>
</intent-filter>
<intent-filter>
<action
android:name=
"android.nfc.action.NDEF_DISCOVERED"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<data
android:scheme=
"ss"
/>
</intent-filter>
</activity>
<activity
...
...
src/main/scala/com/github/shadowsocks/ParserActivity.scala
deleted
100644 → 0
View file @
5fa8e966
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2014 <max.c.lv@gmail.com>
*
* 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/>.
*
*
* ___====-_ _-====___
* _--^^^#####// \\#####^^^--_
* _-^##########// ( ) \\##########^-_
* -############// |\^^/| \\############-
* _/############// (@::@) \\############\_
* /#############(( \\// ))#############\
* -###############\\ (oo) //###############-
* -#################\\ / VV \ //#################-
* -###################\\/ \//###################-
* _#/|##########/\######( /\ )######/\##########|\#_
* |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
* ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
* ` ` ` ` / | | | | \ ' ' ' '
* ( | | | | )
* __\ | | | | /__
* (vvv(VVV)(VVV)vvv)
*
* HERE BE DRAGONS
*
*/
package
com.github.shadowsocks
import
android.content.
{
DialogInterface
,
Intent
}
import
android.graphics.Color
import
android.graphics.drawable.ColorDrawable
import
android.nfc.
{
NdefMessage
,
NfcAdapter
}
import
android.os.Bundle
import
android.support.v7.app.
{
AlertDialog
,
AppCompatActivity
}
import
android.text.TextUtils
import
android.view.WindowManager
import
com.github.shadowsocks.utils.Parser
class
ParserActivity
extends
AppCompatActivity
{
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
super
.
onCreate
(
savedInstanceState
)
handledSharedIntent
()
}
override
def
onNewIntent
(
intent
:
Intent
)
{
super
.
onNewIntent
(
intent
)
setIntent
(
intent
)
handledSharedIntent
()
}
def
handledSharedIntent
()
{
val
intent
=
getIntent
()
val
sharedStr
=
intent
.
getAction
match
{
case
Intent
.
ACTION_VIEW
=>
intent
.
getData
.
toString
case
NfcAdapter
.
ACTION_NDEF_DISCOVERED
=>
val
rawMsgs
=
intent
.
getParcelableArrayExtra
(
NfcAdapter
.
EXTRA_NDEF_MESSAGES
)
if
(
rawMsgs
!=
null
&&
rawMsgs
.
nonEmpty
)
new
String
(
rawMsgs
(
0
).
asInstanceOf
[
NdefMessage
].
getRecords
()(
0
).
getPayload
)
else
null
case
_
=>
null
}
if
(
TextUtils
.
isEmpty
(
sharedStr
))
return
val
profiles
=
Parser
.
findAll
(
sharedStr
).
toList
if
(
profiles
.
isEmpty
)
{
finish
()
return
}
showAsPopup
()
val
dialog
=
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
add_profile_dialog
)
.
setCancelable
(
false
)
.
setPositiveButton
(
android
.
R
.
string
.
yes
,
((
_
,
_
)
=>
profiles
.
foreach
(
ShadowsocksApplication
.
profileManager
.
createProfile
))
:
DialogInterface.OnClickListener
)
.
setNegativeButton
(
android
.
R
.
string
.
no
,
null
)
.
setMessage
(
profiles
.
mkString
(
"\n"
))
.
create
()
dialog
.
setOnDismissListener
((
_:
DialogInterface
)
=>
finish
())
// builder method was added in API 17
dialog
.
show
()
}
def
showAsPopup
()
{
val
window
=
getWindow
window
.
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_DIM_BEHIND
,
WindowManager
.
LayoutParams
.
FLAG_DIM_BEHIND
)
val
params
=
window
.
getAttributes
params
.
alpha
=
1.0f
params
.
dimAmount
=
0.5f
window
.
setAttributes
(
params
.
asInstanceOf
[
android.view.WindowManager.LayoutParams
])
window
.
setBackgroundDrawable
(
new
ColorDrawable
(
Color
.
TRANSPARENT
))
}
}
src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala
View file @
8a86176d
...
...
@@ -7,6 +7,7 @@ import android.nfc.NfcAdapter.CreateNdefMessageCallback
import
android.nfc.
{
NdefMessage
,
NdefRecord
,
NfcAdapter
,
NfcEvent
}
import
android.os.
{
Build
,
Bundle
,
Handler
}
import
android.provider.Settings
import
android.support.v4.app.
{
NavUtils
,
TaskStackBuilder
}
import
android.support.v7.app.
{
AlertDialog
,
AppCompatActivity
}
import
android.support.v7.widget.RecyclerView.ViewHolder
import
android.support.v7.widget.Toolbar.OnMenuItemClickListener
...
...
@@ -113,6 +114,9 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
def
onClick
(
v
:
View
)
=
{
ShadowsocksApplication
.
switchProfile
(
item
.
id
)
finish
if
(
isLauncherFromShareIntent
){
TaskStackBuilder
.
create
(
ProfileManagerActivity
.
this
).
addNextIntentWithParentStack
(
NavUtils
.
getParentActivityIntent
(
ProfileManagerActivity
.
this
)).
startActivities
()
}
}
}
...
...
@@ -181,6 +185,8 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
private
var
nfcEnable
=
false
private
var
nfcBeamEnable
=
false
private
var
isLauncherFromShareIntent
=
false
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
layout_profiles
)
...
...
@@ -234,6 +240,17 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
override
def
onResume
()
{
super
.
onResume
()
isLauncherFromShareIntent
=
false
handledShareIntent
()
updateNFCState
()
}
override
def
onNewIntent
(
intent
:
Intent
)
:
Unit
={
super
.
onNewIntent
(
intent
)
setIntent
(
intent
)
}
def
updateNFCState
()
:
Unit
=
{
nfcAdapter
=
NfcAdapter
.
getDefaultAdapter
(
this
)
if
(
nfcAdapter
!=
null
){
nfcAvailable
=
true
...
...
@@ -256,6 +273,34 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
}
}
def
handledShareIntent
()
{
val
intent
=
getIntent
()
val
sharedStr
=
intent
.
getAction
match
{
case
Intent
.
ACTION_VIEW
=>
intent
.
getData
.
toString
case
NfcAdapter
.
ACTION_NDEF_DISCOVERED
=>
val
rawMsgs
=
intent
.
getParcelableArrayExtra
(
NfcAdapter
.
EXTRA_NDEF_MESSAGES
)
if
(
rawMsgs
!=
null
&&
rawMsgs
.
nonEmpty
)
new
String
(
rawMsgs
(
0
).
asInstanceOf
[
NdefMessage
].
getRecords
()(
0
).
getPayload
)
else
null
case
_
=>
null
}
if
(
TextUtils
.
isEmpty
(
sharedStr
))
return
val
profiles
=
Parser
.
findAll
(
sharedStr
).
toList
if
(
profiles
.
isEmpty
)
{
finish
()
return
}
val
dialog
=
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
add_profile_dialog
)
.
setPositiveButton
(
android
.
R
.
string
.
yes
,
((
_
,
_
)
=>
profiles
.
foreach
(
ShadowsocksApplication
.
profileManager
.
createProfile
))
:
DialogInterface.OnClickListener
)
.
setNegativeButton
(
android
.
R
.
string
.
no
,
((
_
,
_
)
=>
finish
())
:
DialogInterface.OnClickListener
)
.
setMessage
(
profiles
.
mkString
(
"\n"
))
.
create
()
dialog
.
show
()
isLauncherFromShareIntent
=
true
}
override
def
onStart
()
{
super
.
onStart
()
registerCallback
...
...
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