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
a537a7fc
Commit
a537a7fc
authored
Jun 27, 2016
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate a Barcode Scanner
parent
bd58de6a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
12 deletions
+23
-12
build.sbt
build.sbt
+2
-2
project/plugins.sbt
project/plugins.sbt
+1
-1
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+10
-0
src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala
...scala/com/github/shadowsocks/ProfileManagerActivity.scala
+10
-9
No files found.
build.sbt
View file @
a537a7fc
...
@@ -30,7 +30,6 @@ libraryDependencies ++= Seq(
...
@@ -30,7 +30,6 @@ libraryDependencies ++= Seq(
"dnsjava"
%
"dnsjava"
%
"2.1.7"
,
"dnsjava"
%
"dnsjava"
%
"2.1.7"
,
"com.github.kevinsawicki"
%
"http-request"
%
"6.0"
,
"com.github.kevinsawicki"
%
"http-request"
%
"6.0"
,
"eu.chainfire"
%
"libsuperuser"
%
"1.0.0.201602271131"
,
"eu.chainfire"
%
"libsuperuser"
%
"1.0.0.201602271131"
,
"com.google.zxing"
%
"android-integration"
%
"3.2.1"
,
"net.glxn.qrgen"
%
"android"
%
"2.0"
,
"net.glxn.qrgen"
%
"android"
%
"2.0"
,
"com.google.android.gms"
%
"play-services-base"
%
"9.0.2"
,
"com.google.android.gms"
%
"play-services-base"
%
"9.0.2"
,
"com.google.android.gms"
%
"play-services-ads"
%
"9.0.2"
,
"com.google.android.gms"
%
"play-services-ads"
%
"9.0.2"
,
...
@@ -42,7 +41,8 @@ libraryDependencies ++= Seq(
...
@@ -42,7 +41,8 @@ libraryDependencies ++= Seq(
"com.j256.ormlite"
%
"ormlite-core"
%
"4.48"
,
"com.j256.ormlite"
%
"ormlite-core"
%
"4.48"
,
"com.j256.ormlite"
%
"ormlite-android"
%
"4.48"
,
"com.j256.ormlite"
%
"ormlite-android"
%
"4.48"
,
"com.twofortyfouram"
%
"android-plugin-api-for-locale"
%
"1.0.2"
,
"com.twofortyfouram"
%
"android-plugin-api-for-locale"
%
"1.0.2"
,
"com.github.clans"
%
"fab"
%
"1.6.4"
"com.github.clans"
%
"fab"
%
"1.6.4"
,
"me.dm7.barcodescanner"
%
"zxing"
%
"1.8.4"
)
)
proguardVersion
in
Android
:=
"5.2.1"
proguardVersion
in
Android
:=
"5.2.1"
...
...
project/plugins.sbt
View file @
a537a7fc
addSbtPlugin
(
"org.scala-android"
%
"sbt-android"
%
"1.6.
4
"
)
addSbtPlugin
(
"org.scala-android"
%
"sbt-android"
%
"1.6.
5
"
)
addSbtPlugin
(
"com.timushev.sbt"
%
"sbt-updates"
%
"0.1.10"
)
addSbtPlugin
(
"com.timushev.sbt"
%
"sbt-updates"
%
"0.1.10"
)
src/main/AndroidManifest.xml
View file @
a537a7fc
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
<uses-permission
android:name=
"android.permission.NFC"
/>
<uses-permission
android:name=
"android.permission.NFC"
/>
<uses-permission
android:name=
"android.permission.CAMERA"
/>
<uses-feature
<uses-feature
android:name=
"android.hardware.touchscreen"
android:name=
"android.hardware.touchscreen"
...
@@ -57,6 +58,7 @@
...
@@ -57,6 +58,7 @@
android:name=
".ShadowsocksRunnerActivity"
android:name=
".ShadowsocksRunnerActivity"
android:process=
":bg"
android:process=
":bg"
android:theme=
"@android:style/Theme.NoDisplay"
android:theme=
"@android:style/Theme.NoDisplay"
android:excludeFromRecents=
"true"
android:launchMode=
"singleTask"
>
android:launchMode=
"singleTask"
>
</activity>
</activity>
...
@@ -83,10 +85,18 @@
...
@@ -83,10 +85,18 @@
</intent-filter>
</intent-filter>
</activity>
</activity>
<activity
android:name=
".ScannerActivity"
android:label=
"@string/add_profile_methods_scan_qr_code"
android:parentActivityName=
".ProfileManagerActivity"
android:excludeFromRecents=
"true"
android:launchMode=
"singleTask"
/>
<activity
<activity
android:name=
".AppManager"
android:name=
".AppManager"
android:label=
"@string/proxied_apps"
android:label=
"@string/proxied_apps"
android:parentActivityName=
".Shadowsocks"
android:parentActivityName=
".Shadowsocks"
android:excludeFromRecents=
"true"
android:launchMode=
"singleTask"
/>
android:launchMode=
"singleTask"
/>
<activity
android:name=
".TaskerActivity"
<activity
android:name=
".TaskerActivity"
...
...
src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala
View file @
a537a7fc
...
@@ -2,6 +2,7 @@ package com.github.shadowsocks
...
@@ -2,6 +2,7 @@ package com.github.shadowsocks
import
java.nio.charset.Charset
import
java.nio.charset.Charset
import
android.app.Activity
import
android.content._
import
android.content._
import
android.nfc.NfcAdapter.CreateNdefMessageCallback
import
android.nfc.NfcAdapter.CreateNdefMessageCallback
import
android.nfc.
{
NdefMessage
,
NdefRecord
,
NfcAdapter
,
NfcEvent
}
import
android.nfc.
{
NdefMessage
,
NdefRecord
,
NfcAdapter
,
NfcEvent
}
...
@@ -15,6 +16,7 @@ import android.support.v7.widget.helper.ItemTouchHelper.SimpleCallback
...
@@ -15,6 +16,7 @@ import android.support.v7.widget.helper.ItemTouchHelper.SimpleCallback
import
android.support.v7.widget.
{
DefaultItemAnimator
,
LinearLayoutManager
,
RecyclerView
,
Toolbar
}
import
android.support.v7.widget.
{
DefaultItemAnimator
,
LinearLayoutManager
,
RecyclerView
,
Toolbar
}
import
android.text.style.TextAppearanceSpan
import
android.text.style.TextAppearanceSpan
import
android.text.
{
SpannableStringBuilder
,
Spanned
,
TextUtils
}
import
android.text.
{
SpannableStringBuilder
,
Spanned
,
TextUtils
}
import
android.util.Log
import
android.view._
import
android.view._
import
android.widget.
{
CheckedTextView
,
ImageView
,
LinearLayout
,
Toast
}
import
android.widget.
{
CheckedTextView
,
ImageView
,
LinearLayout
,
Toast
}
import
com.github.clans.fab.
{
FloatingActionButton
,
FloatingActionMenu
}
import
com.github.clans.fab.
{
FloatingActionButton
,
FloatingActionMenu
}
...
@@ -23,15 +25,16 @@ import com.github.shadowsocks.database.Profile
...
@@ -23,15 +25,16 @@ import com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.utils.
{
Key
,
Parser
,
TrafficMonitor
,
Utils
}
import
com.github.shadowsocks.utils.
{
Key
,
Parser
,
TrafficMonitor
,
Utils
}
import
com.github.shadowsocks.widget.UndoSnackbarManager
import
com.github.shadowsocks.widget.UndoSnackbarManager
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.google.zxing.integration.android.IntentIntegrator
import
net.glxn.qrgen.android.QRCode
import
net.glxn.qrgen.android.QRCode
import
scala.collection.mutable.ArrayBuffer
import
scala.collection.mutable.ArrayBuffer
final
class
ProfileManagerActivity
extends
AppCompatActivity
with
OnMenuItemClickListener
with
ServiceBoundContext
final
class
ProfileManagerActivity
extends
AppCompatActivity
with
OnMenuItemClickListener
with
ServiceBoundContext
with
View
.
OnClickListener
with
CreateNdefMessageCallback
{
with
View
.
OnClickListener
with
CreateNdefMessageCallback
{
private
final
class
ProfileViewHolder
(
val
view
:
View
)
extends
RecyclerView
.
ViewHolder
(
view
)
private
final
class
ProfileViewHolder
(
val
view
:
View
)
extends
RecyclerView
.
ViewHolder
(
view
)
with
View
.
OnClickListener
with
View
.
OnKeyListener
{
with
View
.
OnClickListener
with
View
.
OnKeyListener
{
var
item
:
Profile
=
_
var
item
:
Profile
=
_
private
val
text
=
itemView
.
findViewById
(
android
.
R
.
id
.
text1
).
asInstanceOf
[
CheckedTextView
]
private
val
text
=
itemView
.
findViewById
(
android
.
R
.
id
.
text1
).
asInstanceOf
[
CheckedTextView
]
itemView
.
setOnClickListener
(
this
)
itemView
.
setOnClickListener
(
this
)
...
@@ -188,6 +191,8 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
...
@@ -188,6 +191,8 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
private
var
isNfcEnabled
:
Boolean
=
_
private
var
isNfcEnabled
:
Boolean
=
_
private
var
isNfcBeamEnabled
:
Boolean
=
_
private
var
isNfcBeamEnabled
:
Boolean
=
_
private
val
REQUEST_QRCODE
=
1
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
layout_profiles
)
setContentView
(
R
.
layout
.
layout_profiles
)
...
@@ -276,11 +281,8 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
...
@@ -276,11 +281,8 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
finish
finish
case
R
.
id
.
fab_qrcode_add
=>
case
R
.
id
.
fab_qrcode_add
=>
menu
.
toggle
(
false
)
menu
.
toggle
(
false
)
val
integrator
=
new
IntentIntegrator
(
ProfileManagerActivity
.
this
)
val
intent
=
new
Intent
(
this
,
classOf
[
ScannerActivity
])
val
list
=
new
java
.
util
.
ArrayList
(
IntentIntegrator
.
TARGET_ALL_KNOWN
)
startActivityForResult
(
intent
,
REQUEST_QRCODE
)
list
.
add
(
"tw.com.quickmark"
)
integrator
.
setTargetApplications
(
list
)
integrator
.
initiateScan
()
case
R
.
id
.
fab_nfc_add
=>
case
R
.
id
.
fab_nfc_add
=>
menu
.
toggle
(
true
)
menu
.
toggle
(
true
)
val
dialog
=
new
AlertDialog
.
Builder
(
ProfileManagerActivity
.
this
)
val
dialog
=
new
AlertDialog
.
Builder
(
ProfileManagerActivity
.
this
)
...
@@ -371,9 +373,8 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
...
@@ -371,9 +373,8 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
}
}
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
{
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
{
val
scanResult
=
IntentIntegrator
.
parseActivityResult
(
requestCode
,
resultCode
,
data
)
if
(
requestCode
==
REQUEST_QRCODE
&&
resultCode
==
Activity
.
RESULT_OK
)
{
if
(
scanResult
!=
null
)
{
val
contents
=
data
.
getStringExtra
(
"uri"
)
val
contents
=
scanResult
.
getContents
if
(!
TextUtils
.
isEmpty
(
contents
))
if
(!
TextUtils
.
isEmpty
(
contents
))
Parser
.
findAll
(
contents
).
foreach
(
app
.
profileManager
.
createProfile
)
Parser
.
findAll
(
contents
).
foreach
(
app
.
profileManager
.
createProfile
)
}
}
...
...
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