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
1a67a3c1
Commit
1a67a3c1
authored
May 02, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refine the notification
parent
721e31d8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
93 additions
and
88 deletions
+93
-88
AndroidManifest.xml
AndroidManifest.xml
+57
-56
pom.xml
pom.xml
+1
-1
res/drawable-hdpi/ic_stat_large.png
res/drawable-hdpi/ic_stat_large.png
+0
-0
res/drawable-mdpi/ic_stat_large.png
res/drawable-mdpi/ic_stat_large.png
+0
-0
res/drawable-xhdpi/ic_stat_large.png
res/drawable-xhdpi/ic_stat_large.png
+0
-0
res/values/strings.xml
res/values/strings.xml
+6
-5
src/com/github/shadowsocks/ShadowsocksReceiver.java
src/com/github/shadowsocks/ShadowsocksReceiver.java
+4
-1
src/com/github/shadowsocks/ShadowsocksService.java
src/com/github/shadowsocks/ShadowsocksService.java
+25
-25
No files found.
AndroidManifest.xml
View file @
1a67a3c1
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.github.shadowsocks"
android:installLocation=
"auto"
android:versionCode=
"21"
android:versionName=
"1.3.9"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
<uses-permission
android:name=
"android.permission.ACCESS_SUPERUSER"
/>
<uses-feature
android:name=
"android.hardware.touchscreen"
android:required=
"false"
/>
<uses-sdk
android:minSdkVersion=
"9"
android:targetSdkVersion=
"16"
/>
<application
android:name=
".ShadowsocksApplication"
android:hardwareAccelerated=
"true"
android:icon=
"@drawable/ic_launcher"
android:label=
"@string/app_name"
>
<activity
android:name=
".Shadowsocks"
android:label=
"@string/app_name"
android:theme=
"@style/Theme.GAEProxy"
android:launchMode=
"singleTask"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name=
".AppManager"
android:theme=
"@style/Theme.GAEProxy"
android:label=
"@string/app_name"
>
<intent-filter>
<action
android:name=
"com.github.shadowsocks.AppManager"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</activity>
<service
android:name=
".ShadowsocksService"
android:enabled=
"true"
/>
<receiver
android:name=
".ShadowsocksReceiver"
>
<intent-filter>
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
<action
android:name=
"android.intent.action.ACTION_SHUTDOWN"
/>
</intent-filter>
</receiver>
</application>
package=
"com.github.shadowsocks"
android:installLocation=
"auto"
android:versionCode=
"21"
android:versionName=
"1.3.9"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
<uses-permission
android:name=
"android.permission.ACCESS_SUPERUSER"
/>
<uses-feature
android:name=
"android.hardware.touchscreen"
android:required=
"false"
/>
<uses-sdk
android:minSdkVersion=
"9"
android:targetSdkVersion=
"16"
/>
<application
android:name=
".ShadowsocksApplication"
android:hardwareAccelerated=
"true"
android:icon=
"@drawable/ic_launcher"
android:label=
"@string/app_name"
>
<activity
android:name=
".Shadowsocks"
android:label=
"@string/app_name"
android:theme=
"@style/Theme.GAEProxy"
android:launchMode=
"singleTask"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name=
".AppManager"
android:theme=
"@style/Theme.GAEProxy"
android:label=
"@string/app_name"
>
<intent-filter>
<action
android:name=
"com.github.shadowsocks.AppManager"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</activity>
<service
android:name=
".ShadowsocksService"
android:enabled=
"true"
/>
<receiver
android:name=
".ShadowsocksReceiver"
>
<intent-filter>
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
<action
android:name=
"android.intent.action.ACTION_SHUTDOWN"
/>
<action
android:name=
"com.github.shadowsocks.ACTION_SHUTDOWN"
/>
</intent-filter>
</receiver>
</application>
</manifest>
pom.xml
View file @
1a67a3c1
...
...
@@ -35,7 +35,7 @@
<dependency>
<groupId>
com.google.android
</groupId>
<artifactId>
support-v4
</artifactId>
<version>
r
7
</version>
<version>
r
12
</version>
</dependency>
<dependency>
<artifactId>
crouton
</artifactId>
...
...
res/drawable-hdpi/ic_stat_large.png
0 → 100644
View file @
1a67a3c1
1.55 KB
res/drawable-mdpi/ic_stat_large.png
0 → 100644
View file @
1a67a3c1
1.02 KB
res/drawable-xhdpi/ic_stat_large.png
0 → 100644
View file @
1a67a3c1
2.17 KB
res/values/strings.xml
View file @
1a67a3c1
...
...
@@ -50,12 +50,13 @@
<string
name=
"auto_connect_summary"
>
Start Shadowsocks at the startup
</string>
<!-- notification category -->
<string
name=
"forward_success"
>
Shadowsocks started
</string>
<string
name=
"service_running"
>
Running in the background
</string>
<string
name=
"forward_fail"
>
Shadowsocks failed to start
</string>
<string
name=
"service_stopped"
>
Shadowsocks stopped
</string>
<string
name=
"forward_stop"
>
Shadowsocks stopped
</string>
<string
name=
"forward_success"
>
Shadowsocks started
.
</string>
<string
name=
"service_running"
>
Running in the background
.
</string>
<string
name=
"forward_fail"
>
Shadowsocks failed to start
.
</string>
<string
name=
"service_stopped"
>
Shadowsocks stopped
.
</string>
<string
name=
"forward_stop"
>
Shadowsocks stopped
.
</string>
<string
name=
"service_failed"
>
Please check your network status and try again.
</string>
<string
name=
"stop"
>
Stop the service
</string>
<!-- alert category -->
<string
name=
"ok_iknow"
>
OK
</string>
...
...
src/com/github/shadowsocks/ShadowsocksReceiver.java
View file @
1a67a3c1
...
...
@@ -47,6 +47,8 @@ import android.preference.PreferenceManager;
public
class
ShadowsocksReceiver
extends
BroadcastReceiver
{
public
static
final
String
CLOSE_ACTION
=
"com.github.shadowsocks.ACTION_SHUTDOWN"
;
private
static
final
String
TAG
=
"Shadowsocks"
;
@Override
...
...
@@ -54,7 +56,8 @@ public class ShadowsocksReceiver extends BroadcastReceiver {
if
(
intent
!=
null
)
{
final
String
action
=
intent
.
getAction
();
if
(
action
.
equals
(
Intent
.
ACTION_SHUTDOWN
))
{
if
(
action
.
equals
(
Intent
.
ACTION_SHUTDOWN
)
||
action
.
equals
(
CLOSE_ACTION
))
{
context
.
stopService
(
new
Intent
(
context
,
ShadowsocksService
.
class
));
return
;
}
...
...
src/com/github/shadowsocks/ShadowsocksService.java
View file @
1a67a3c1
...
...
@@ -48,11 +48,14 @@ import android.content.SharedPreferences;
import
android.content.SharedPreferences.Editor
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.os.Handler
;
import
android.os.IBinder
;
import
android.os.Message
;
import
android.os.PowerManager
;
import
android.preference.PreferenceManager
;
import
android.support.v4.app.NotificationCompat
;
import
android.util.Log
;
import
com.google.analytics.tracking.android.EasyTracker
;
import
java.io.BufferedReader
;
...
...
@@ -153,9 +156,7 @@ public class ShadowsocksService extends Service {
super
.
handleMessage
(
msg
);
}
};
private
Notification
notification
;
private
NotificationManager
notificationManager
;
private
PendingIntent
pendIntent
;
private
PowerManager
.
WakeLock
mWakeLock
;
private
String
appHost
;
private
int
remotePort
;
...
...
@@ -403,22 +404,29 @@ public class ShadowsocksService extends Service {
}
private
void
notifyAlert
(
String
title
,
String
info
)
{
notification
.
icon
=
R
.
drawable
.
ic_stat_shadowsocks
;
notification
.
tickerText
=
title
;
notification
.
flags
=
Notification
.
FLAG_ONGOING_EVENT
;
initSoundVibrateLights
(
notification
);
// notification.defaults = Notification.DEFAULT_SOUND;
notification
.
setLatestEventInfo
(
this
,
getString
(
R
.
string
.
app_name
),
info
,
pendIntent
);
startForegroundCompat
(
1
,
notification
);
}
private
void
notifyAlert
(
String
title
,
String
info
,
int
flags
)
{
notification
.
icon
=
R
.
drawable
.
ic_stat_shadowsocks
;
notification
.
tickerText
=
title
;
notification
.
flags
=
flags
;
initSoundVibrateLights
(
notification
);
notification
.
setLatestEventInfo
(
this
,
getString
(
R
.
string
.
app_name
),
info
,
pendIntent
);
notificationManager
.
notify
(
0
,
notification
);
// ContentIntent
Intent
openIntent
=
new
Intent
(
this
,
Shadowsocks
.
class
);
openIntent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
PendingIntent
contentIntent
=
PendingIntent
.
getActivity
(
this
,
0
,
openIntent
,
0
);
// ActionIntent
Intent
closeIntent
=
new
Intent
(
ShadowsocksReceiver
.
CLOSE_ACTION
);
PendingIntent
actionIntent
=
PendingIntent
.
getBroadcast
(
this
,
0
,
closeIntent
,
0
);
//large icon for notification,normally use App icon
final
Bitmap
largeIcon
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
ic_stat_large
);
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
this
);
builder
.
setSmallIcon
(
R
.
drawable
.
ic_stat_shadowsocks
)
.
setWhen
(
0
)
.
setTicker
(
title
)
.
setContentTitle
(
getString
(
R
.
string
.
app_name
))
.
setContentText
(
info
)
.
setContentIntent
(
contentIntent
)
.
addAction
(
android
.
R
.
drawable
.
ic_menu_close_clear_cancel
,
getString
(
R
.
string
.
stop
),
actionIntent
);
startForegroundCompat
(
1
,
builder
.
build
());
}
@Override
...
...
@@ -435,11 +443,6 @@ public class ShadowsocksService extends Service {
settings
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
notificationManager
=
(
NotificationManager
)
this
.
getSystemService
(
NOTIFICATION_SERVICE
);
Intent
intent
=
new
Intent
(
this
,
Shadowsocks
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
pendIntent
=
PendingIntent
.
getActivity
(
this
,
0
,
intent
,
0
);
notification
=
new
Notification
();
try
{
mStartForeground
=
getClass
().
getMethod
(
"startForeground"
,
mStartForegroundSignature
);
mStopForeground
=
getClass
().
getMethod
(
"stopForeground"
,
mStopForegroundSignature
);
...
...
@@ -464,9 +467,6 @@ public class ShadowsocksService extends Service {
stopForegroundCompat
(
1
);
notifyAlert
(
getString
(
R
.
string
.
forward_stop
),
getString
(
R
.
string
.
service_stopped
),
Notification
.
FLAG_AUTO_CANCEL
);
new
Thread
()
{
@Override
public
void
run
()
{
...
...
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