mDatas = new ArrayList<>();
36 | PushInterface pushInterface = new PushInterface() {
37 | @Override
38 | public void onRegister(Context context, String registerID) {
39 | addData("onRegister id:" + registerID+"; target: "+ RomUtil.rom().toString());
40 | }
41 |
42 | @Override
43 | public void onUnRegister(Context context) {
44 | addData("onUnRegister");
45 | }
46 |
47 | @Override
48 | public void onPaused(Context context) {
49 | addData("onPaused");
50 | }
51 |
52 | @Override
53 | public void onResume(Context context) {
54 | addData("onResume");
55 | }
56 |
57 | @Override
58 | public void onMessage(Context context, Message message) {
59 |
60 | addData(message.toString());
61 | }
62 |
63 | @Override
64 | public void onMessageClicked(Context context, Message message) {
65 |
66 | addData("MessageClicked: " + message.toString());
67 | }
68 |
69 | @Override
70 | public void onCustomMessage(Context context, Message message) {
71 |
72 | addData(message.toString());
73 | }
74 |
75 | @Override
76 | public void onAlias(Context context, String alias) {
77 | addData("alias: " + alias);
78 | }
79 | };
80 | private AppCompatButton alias;
81 |
82 | @Override
83 | protected void onCreate(Bundle savedInstanceState) {
84 | super.onCreate(savedInstanceState);
85 | setContentView(R.layout.activity_main);
86 | if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
87 | ActivityCompat.requestPermissions(this,
88 | new String[]{android.Manifest.permission.READ_PHONE_STATE},
89 | 100);
90 | }
91 |
92 | //android.permission.WRITE_SETTINGS
93 | if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_SETTINGS) != PackageManager.PERMISSION_GRANTED) {
94 | ActivityCompat.requestPermissions(this,
95 | new String[]{android.Manifest.permission.WRITE_SETTINGS},
96 | 1300);
97 | }
98 | register = (AppCompatButton) findViewById(R.id.register);
99 | register.setOnClickListener(this);
100 | unregister = (AppCompatButton) findViewById(R.id.unregister);
101 | unregister.setOnClickListener(this);
102 | open = (AppCompatButton) findViewById(R.id.open);
103 | open.setOnClickListener(this);
104 | close = (AppCompatButton) findViewById(R.id.close);
105 | alias = (AppCompatButton) findViewById(R.id.alias);
106 | close.setOnClickListener(this);
107 | alias.setOnClickListener(this);
108 | recyclerView = (RecyclerView) findViewById(R.id.rv);
109 |
110 | Push.setPushInterface(pushInterface);
111 |
112 | mDatas.add("--------- log ----------");
113 | recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
114 | BaseAdapter adapter = new BaseAdapter() {
115 | @Override
116 | protected void onBindView(BaseViewHolder baseViewHolder, int i) {
117 |
118 | TextView title = baseViewHolder.getView(R.id.tv);
119 | title.setText(mDatas.get(i));
120 | }
121 |
122 | @Override
123 | protected int getLayoutID(int i) {
124 | return R.layout.item;
125 | }
126 |
127 | @Override
128 | public int getItemCount() {
129 | return mDatas.size();
130 | }
131 | };
132 |
133 | adapter.setOnItemClickListener(new OnItemClickListener() {
134 | @Override
135 | public void onItemClick(int i) {
136 | ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
137 | cm.setText(mDatas.get(i));
138 | Toast.makeText(MainActivity.this, "复制成功", Toast.LENGTH_SHORT).show();
139 | }
140 | });
141 | recyclerView.setAdapter(adapter);
142 |
143 | }
144 |
145 | @Override
146 | public void onClick(View view) {
147 | switch (view.getId()) {
148 | case R.id.register:
149 | register();
150 | toast("开始注册");
151 | break;
152 | case R.id.unregister:
153 | Push.unregister(this);
154 | toast("取消注册");
155 | break;
156 | case R.id.open:
157 | Push.resume(this);
158 | toast("开启推送");
159 | break;
160 | case R.id.close:
161 | Push.pause(this);
162 | toast("开始暂停");
163 | break;
164 | case R.id.alias:
165 | Push.setAlias(this, "haha");
166 | toast("alias");
167 | break;
168 | }
169 |
170 | }
171 |
172 | private void toast(String s) {
173 | Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
174 | }
175 |
176 | private void register() {
177 | Push.register(this, BuildConfig.DEBUG);
178 |
179 | }
180 |
181 | private void addData(String value) {
182 | mDatas.add(value);
183 | recyclerView.getAdapter().notifyDataSetChanged();
184 |
185 | }
186 | }
187 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jiang/android/pushdemo/PushService.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.pushdemo;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 |
6 | import com.jiang.android.push.Message;
7 | import com.jiang.android.push.PushInterface;
8 |
9 | /**
10 | * Created by jiang on 2016/10/9.
11 | */
12 |
13 | public class PushService implements PushInterface {
14 |
15 | private static final String TAG = "PushServiceforMyOwn";
16 |
17 | @Override
18 | public void onRegister(Context context, String registerID) {
19 | Log.i(TAG, "onRegister: " + " id: " + registerID);
20 |
21 | }
22 |
23 | @Override
24 | public void onUnRegister(Context context) {
25 | Log.i(TAG, "onUnRegister: ");
26 |
27 | }
28 |
29 | @Override
30 | public void onPaused(Context context) {
31 | Log.i(TAG, "onPaused: ");
32 |
33 | }
34 |
35 | @Override
36 | public void onResume(Context context) {
37 | Log.i(TAG, "onResume: ");
38 |
39 | }
40 |
41 | @Override
42 | public void onMessage(Context context, Message message) {
43 | Log.i(TAG, "onMessage: " + message.toString());
44 |
45 | }
46 |
47 | @Override
48 | public void onMessageClicked(Context context, Message message) {
49 | Log.i(TAG, "onMessageClicked: " + message.toString());
50 |
51 | }
52 |
53 | @Override
54 | public void onCustomMessage(Context context, Message message) {
55 | Log.i(TAG, "onCustomMessage: " + message.toString());
56 |
57 | }
58 |
59 | @Override
60 | public void onAlias(Context context, String alias) {
61 | Log.i(TAG, "onAlias: " + alias);
62 |
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
22 |
23 |
30 |
31 |
38 |
45 |
52 |
53 |
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AndroidPush
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | google()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.1.0'
10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | maven { url "https://jitpack.io" }
21 | google()
22 |
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
29 |
--------------------------------------------------------------------------------
/code.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/code.zip
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 | android.useDeprecatedNdk=true。
19 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jun 26 18:23:11 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
7 |
--------------------------------------------------------------------------------
/push/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/push/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | group = 'com.github.jiang111'
4 | android {
5 | compileSdkVersion 28
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 28
10 | versionCode 5
11 | versionName "1.1.2"
12 | ndk {
13 | abiFilters 'armeabi', 'armeabi-v7a', 'armeabi-v8a'
14 |
15 | }
16 | manifestPlaceholders = [
17 | JPUSH_PKGNAME: "library",
18 | JPUSH_APPKEY : "library",
19 | JPUSH_CHANNEL: "developer",
20 | PNAME : "library"
21 | ]
22 |
23 | }
24 |
25 | }
26 |
27 | dependencies {
28 | /**
29 | * flyme
30 | */
31 | implementation 'com.android.support:support-v4:28.0.0'
32 | implementation 'com.android.volley:volley:1.1.0'
33 | implementation 'com.squareup.okhttp:okhttp:2.1.0'
34 | implementation 'com.meizu.flyme.internet:push-internal-publish:3.3.+@aar'
35 | /**
36 | * jpush
37 | */
38 | implementation fileTree(include: ['*.jar'], dir: 'libs')
39 | implementation 'cn.jiguang:jpush:2.1.8'
40 | implementation files('libs/pushsdk_v2.3.4.jar')
41 | implementation files('libs/com.coloros.mcssdk.jar')
42 | }
43 |
--------------------------------------------------------------------------------
/push/libs/HwPush_SDK_V2705.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/libs/HwPush_SDK_V2705.jar
--------------------------------------------------------------------------------
/push/libs/MiPush_SDK_Client_3_1_2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/libs/MiPush_SDK_Client_3_1_2.jar
--------------------------------------------------------------------------------
/push/libs/com.coloros.mcssdk.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/libs/com.coloros.mcssdk.jar
--------------------------------------------------------------------------------
/push/libs/pushsdk_v2.3.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/libs/pushsdk_v2.3.4.jar
--------------------------------------------------------------------------------
/push/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/jiang/androidsdk/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | -keep public class * extends android.content.BroadcastReceiver
20 | -keep class com.xiaomi.mipush.sdk.DemoMessageReceiver {*;}
21 | #可以防止一个误报的 warning 导致无法成功编译,如果编译使用的 Android 版本是 23。
22 | -dontwarn com.xiaomi.push.**
23 | # library
24 | -keep class com.jiang.android.push.**{*;}
25 |
26 |
27 | # huawei
28 | -keep class com.huawei.**{*;}
29 | -keep class com.hianalytics.android.**{*;}
30 | -keep class com.baidu.mapapi.**{*;}
31 | -dontwarn com.huawei.**
32 |
33 | # jpush
34 | -dontoptimize
35 | -dontpreverify
36 |
37 | -dontwarn cn.jpush.**
38 | -keep class cn.jpush.** { *; }
39 | #==================gson && protobuf==========================
40 | -dontwarn com.google.**
41 | -keep class com.google.gson.** {*;}
42 | -keep class com.google.protobuf.** {*;}
43 |
--------------------------------------------------------------------------------
/push/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
37 |
38 |
39 |
40 |
41 |
42 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
118 |
119 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
134 |
137 |
138 |
139 | />
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
154 |
155 |
156 |
157 |
158 |
161 |
162 |
163 |
164 |
167 |
168 |
169 |
170 |
171 |
172 |
176 |
182 |
183 |
187 |
190 |
191 |
194 |
195 |
196 |
197 |
198 |
199 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
214 |
219 |
220 |
223 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/Const.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push;
2 |
3 | import android.text.TextUtils;
4 |
5 | /**
6 | * Created by jiang on 2016/10/8.
7 | */
8 |
9 | public class Const {
10 |
11 | private static String miui_app_id = null;
12 | private static String miui_app_key = null;
13 | private static String flyme_app_id = null;
14 | private static String flyme_app_key = null;
15 | private static String color_app_key = null;
16 | private static String color_app_secret = null;
17 |
18 | public static String getMiui_app_id() {
19 | if (TextUtils.isEmpty(miui_app_id)) {
20 | throw new NullPointerException("please config miui_app_id before use it");
21 | }
22 | return miui_app_id;
23 | }
24 |
25 | public static String getMiui_app_key() {
26 | if (TextUtils.isEmpty(miui_app_key)) {
27 | throw new NullPointerException("please config miui_app_key before use it");
28 | }
29 | return miui_app_key;
30 | }
31 |
32 | public static String getFlyme_app_id() {
33 | if (TextUtils.isEmpty(flyme_app_id)) {
34 | throw new NullPointerException("please config flyme_app_id before use it");
35 | }
36 | return flyme_app_id;
37 | }
38 |
39 | public static String getFlyme_app_key() {
40 | if (TextUtils.isEmpty(flyme_app_key)) {
41 | throw new NullPointerException("please config flyme_app_key before use it");
42 | }
43 | return flyme_app_key;
44 | }
45 |
46 |
47 | public static void setMiUI_APP(String miui_app_id, String miui_app_key) {
48 | setMiui_app_id(miui_app_id);
49 | setMiui_app_key(miui_app_key);
50 | }
51 |
52 | public static void setFlyme_APP(String flyme_app_id, String flyme_app_key) {
53 | setFlyme_app_id(flyme_app_id);
54 | setFlyme_app_key(flyme_app_key);
55 | }
56 |
57 | public static void setColor_APP(String app_key, String app_secret) {
58 | Const.color_app_key = app_key;
59 | Const.color_app_secret = app_secret;
60 | }
61 |
62 | public static String getColor_app_key() {
63 | if (TextUtils.isEmpty(color_app_key)) {
64 | throw new NullPointerException("please config color_app_key before use it");
65 | }
66 | return color_app_key;
67 | }
68 |
69 | public static String getColor_app_secret() {
70 | if (TextUtils.isEmpty(color_app_secret)) {
71 | throw new NullPointerException("please config color_app_secret before use it");
72 | }
73 | return color_app_secret;
74 | }
75 |
76 | private static void setMiui_app_id(String miui_app_id) {
77 | Const.miui_app_id = miui_app_id;
78 | }
79 |
80 | private static void setMiui_app_key(String miui_app_key) {
81 | Const.miui_app_key = miui_app_key;
82 | }
83 |
84 | private static void setFlyme_app_id(String flyme_app_id) {
85 | Const.flyme_app_id = flyme_app_id;
86 | }
87 |
88 | private static void setFlyme_app_key(String flyme_app_key) {
89 | Const.flyme_app_key = flyme_app_key;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/IPushManager.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push;
2 |
3 | import android.content.Context;
4 |
5 | import com.jiang.android.push.model.TokenModel;
6 |
7 | public interface IPushManager {
8 | void register(Context context, boolean debug, final PushInterface pushInterface);
9 |
10 | void unregister(Context context);
11 |
12 | void setPushInterface(PushInterface pushInterface);
13 |
14 | void setAlias(final Context context, String alias);
15 |
16 | TokenModel getToken(Context context);
17 |
18 | void pause(Context context);
19 |
20 | void resume(Context context);
21 | }
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/Message.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push;
2 |
3 | import com.jiang.android.push.utils.Target;
4 |
5 | /**
6 | * 将消息整合成Message model
7 | * Created by jiang on 2016/10/8.
8 | */
9 |
10 | public final class Message {
11 | private int notifyID; //这个字段用于通知的消息类型,在透传中都是默认0
12 | private String messageID;
13 | private String title;
14 | private String message;
15 | private String extra;
16 | private Target target;
17 |
18 | public int getNotifyID() {
19 | return notifyID;
20 | }
21 |
22 | public void setNotifyID(int notifyID) {
23 | this.notifyID = notifyID;
24 | }
25 |
26 | public String getMessageID() {
27 | return messageID;
28 | }
29 |
30 | public void setMessageID(String messageID) {
31 | this.messageID = messageID;
32 | }
33 |
34 | public Target getTarget() {
35 | return target;
36 | }
37 |
38 | public void setTarget(Target target) {
39 | this.target = target;
40 | }
41 |
42 | public String getTitle() {
43 | return title;
44 | }
45 |
46 | public void setTitle(String title) {
47 | this.title = title;
48 | }
49 |
50 | public String getMessage() {
51 | return message;
52 | }
53 |
54 | public void setMessage(String message) {
55 | this.message = message;
56 | }
57 |
58 | public String getExtra() {
59 | return extra;
60 | }
61 |
62 | public void setExtra(String extra) {
63 | this.extra = extra;
64 | }
65 |
66 | @Override
67 | public String toString() {
68 | return "Message{" +
69 | "notifyID=" + notifyID +
70 | ", messageID='" + messageID + '\'' +
71 | ", title='" + title + '\'' +
72 | ", message='" + message + '\'' +
73 | ", extra='" + extra + '\'' +
74 | ", target=" + target +
75 | '}';
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/Push.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push;
2 |
3 | import android.content.Context;
4 | import android.text.TextUtils;
5 |
6 | import com.jiang.android.push.emui.EMPushManager;
7 | import com.jiang.android.push.jpush.JPushManager;
8 | import com.jiang.android.push.miui.MiuiPushManager;
9 | import com.jiang.android.push.model.TokenModel;
10 | import com.jiang.android.push.oppo.OppoPushManager;
11 | import com.jiang.android.push.utils.RomUtil;
12 | import com.jiang.android.push.utils.Target;
13 | import com.jiang.android.push.vivo.ViVOPushManager;
14 |
15 | /**
16 | * Created by jiang on 2016/10/8.
17 | */
18 |
19 | public class Push {
20 |
21 |
22 | private static IPushManager pushManager;
23 |
24 |
25 | public static void initPushManager(IPushManager pushManager) {
26 | Push.pushManager = pushManager;
27 | }
28 |
29 | /**
30 | * 初始化配置
31 | *
32 | * @param context
33 | * @param debug
34 | */
35 | public static void register(Context context, boolean debug) {
36 | register(context, debug, null);
37 | }
38 |
39 | /**
40 | * 注册
41 | *
42 | * @param context
43 | * @param debug
44 | * @param pushInterface
45 | */
46 | public static void register(Context context, boolean debug, final PushInterface pushInterface) {
47 | if (context == null) return;
48 | init();
49 | pushManager.register(context, debug, pushInterface);
50 |
51 |
52 | }
53 |
54 | private static void init() {
55 |
56 | if (pushManager != null) return;
57 |
58 | if (RomUtil.rom() == Target.EMUI) {
59 | pushManager = new EMPushManager();
60 | }
61 | if (RomUtil.rom() == Target.MIUI) {
62 | pushManager = new MiuiPushManager();
63 | }
64 |
65 | if (RomUtil.rom() == Target.JPUSH) {
66 | pushManager = new JPushManager();
67 | }
68 |
69 | if (RomUtil.rom() == Target.VIVO) {
70 | pushManager = new ViVOPushManager();
71 |
72 | }
73 | if (RomUtil.rom() == Target.OPPO) {
74 | pushManager = new OppoPushManager();
75 | }
76 |
77 |
78 | }
79 |
80 |
81 | public static void unregister(Context context) {
82 | if (context == null) return;
83 | pushManager.unregister(context);
84 | }
85 |
86 |
87 | /**
88 | * @param pushInterface
89 | */
90 | public static void setPushInterface(PushInterface pushInterface) {
91 | if (pushInterface == null) return;
92 | pushManager.setPushInterface(pushInterface);
93 | }
94 |
95 |
96 | /**
97 | * 设置别名,
98 | * 华为不支持alias的写法,所以只能用tag,tag只能放map,所以alias作为value,key为name
99 | *
100 | * @param context
101 | * @param alias
102 | */
103 | public static void setAlias(final Context context, String alias) {
104 | if (context == null) return;
105 | if (TextUtils.isEmpty(alias)) return;
106 | pushManager.setAlias(context, alias);
107 | }
108 |
109 | /**
110 | * 获取唯一的token
111 | *
112 | * @param context
113 | * @return
114 | */
115 | public static TokenModel getToken(Context context) {
116 | if (context == null) return null;
117 | return pushManager.getToken(context);
118 | }
119 |
120 |
121 | /**
122 | * 停止推送
123 | */
124 | public static void pause(Context context) {
125 | if (context == null) return;
126 | pushManager.pause(context);
127 | }
128 |
129 |
130 | /**
131 | * 开始推送
132 | */
133 | public static void resume(Context context) {
134 | if (context == null) return;
135 | pushManager.resume(context);
136 |
137 | }
138 |
139 | }
140 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/PushInterface.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * warning:
7 | * 在flyme的推送中,不会回调onMessage()和onMessageClicked()方法
8 | * 在华为推送中,不会回调onMessage(),onMessageClicked()和onAlias()方法
9 | * 如上两个方法不会回调是因为设计的时候,通知栏的点击事件由后台负责控制,手机端值负责处理透传消息
10 | *
11 | * oppo中不需要自己处理,所以用不到PushInterface
12 | *
13 | * Created by jiang on 2016/10/8.
14 | */
15 |
16 | public interface PushInterface {
17 |
18 | /**
19 | * 注册成功之后回调
20 | *
21 | * @param context
22 | * @param registerID
23 | */
24 | void onRegister(Context context, String registerID);
25 |
26 | /**
27 | * 取消注册成功
28 | *
29 | * @param context
30 | */
31 | void onUnRegister(Context context);
32 |
33 | /**
34 | * 暂停推送
35 | *
36 | * @param context
37 | */
38 | void onPaused(Context context);
39 |
40 | /**
41 | * 开启推送
42 | *
43 | * @param context
44 | */
45 | void onResume(Context context);
46 |
47 | /**
48 | * 通知下来之后
49 | *
50 | * @param context
51 | * @param message
52 | */
53 | void onMessage(Context context, Message message);
54 |
55 | /**
56 | * 通知栏被点击之后
57 | *
58 | * @param context
59 | * @param message
60 | */
61 | void onMessageClicked(Context context, Message message);
62 |
63 | /**
64 | * 透传消息
65 | *
66 | * @param context
67 | * @param message
68 | */
69 | void onCustomMessage(Context context, Message message);
70 |
71 |
72 | /**
73 | * 别名设置成功的回调
74 | *
75 | * @param context
76 | * @param alias
77 | */
78 | void onAlias(Context context, String alias);
79 | }
80 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/emui/EMHuaweiPushReceiver.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.emui;
2 |
3 | import android.app.NotificationManager;
4 | import android.content.Context;
5 | import android.os.Bundle;
6 |
7 | import com.huawei.android.pushagent.PushReceiver;
8 | import com.jiang.android.push.Message;
9 | import com.jiang.android.push.PushInterface;
10 | import com.jiang.android.push.utils.JHandler;
11 | import com.jiang.android.push.utils.L;
12 | import com.jiang.android.push.utils.Target;
13 |
14 | /**
15 | * Created by jiang on 2016/10/8.
16 | */
17 |
18 | public class EMHuaweiPushReceiver extends PushReceiver {
19 |
20 | private static String mToken = null;
21 |
22 |
23 | private static PushInterface mPushInterface;
24 |
25 | public static void registerInterface(PushInterface pushInterface) {
26 | mPushInterface = pushInterface;
27 | }
28 |
29 | public static PushInterface getPushInterface() {
30 | return mPushInterface;
31 | }
32 |
33 | public static String getmToken() {
34 | return mToken;
35 | }
36 |
37 |
38 | @Override
39 | public void onToken(final Context context, final String token, Bundle extras) {
40 | String belongId = extras.getString("belongId");
41 | String content = "获取token和belongId成功,token = " + token + ",belongId = " + belongId;
42 | L.i(content);
43 | mToken = token;
44 | if (mPushInterface != null) {
45 | JHandler.handler().post(new Runnable() {
46 | @Override
47 | public void run() {
48 | mPushInterface.onRegister(context, token);
49 | }
50 | });
51 | }
52 | }
53 |
54 | @Override
55 | public void onPushMsg(Context context, byte[] bytes, String s) {
56 | super.onPushMsg(context, bytes, s);
57 | L.i("onPushMsg...");
58 | }
59 |
60 |
61 | @Override
62 | public boolean onPushMsg(final Context context, byte[] msg, Bundle bundle) {
63 | //这里是透传消息, msg是透传消息的字节数组 bundle字段没用
64 | L.i("onPushMsg: " + new String(msg));
65 | try {
66 | String content = new String(msg, "UTF-8");
67 | if (mPushInterface != null) {
68 | final Message message = new Message();
69 | message.setMessage(content);
70 | //华为的sdk在透传的时候无法实现extra字段,这里要注意
71 | message.setExtra("{}");
72 | message.setTarget(Target.EMUI);
73 | JHandler.handler().post(new Runnable() {
74 | @Override
75 | public void run() {
76 | mPushInterface.onCustomMessage(context, message);
77 | }
78 | });
79 | }
80 | L.i(content);
81 | } catch (Exception e) {
82 | e.printStackTrace();
83 | }
84 | return false;
85 | }
86 |
87 |
88 | /**
89 | * 在华为的sdk中,通知栏的事件只有三种:
90 | *
91 | * NOTIFICATION_OPENED, //通知栏中的通知被点击打开
92 | * NOTIFICATION_CLICK_BTN, //通知栏中通知上的按钮被点击
93 | * PLUGINRSP, //标签上报回应
94 | *
95 | * @param context
96 | * @param event
97 | * @param extras
98 | */
99 | public void onEvent(final Context context, Event event, Bundle extras) {
100 | L.i("onEvent: ");
101 | if (Event.NOTIFICATION_OPENED.equals(event) || Event.NOTIFICATION_CLICK_BTN.equals(event)) {
102 | int notifyId = extras.getInt(BOUND_KEY.pushNotifyId, 0);
103 | if (0 != notifyId) {
104 | NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
105 | manager.cancel(notifyId);
106 | }
107 | String content = "收到通知附加消息: " + extras.getString(BOUND_KEY.pushMsgKey);
108 | L.i(content);
109 | // try {
110 | // if (mPushInterface != null) {
111 | // final Message message = new Message();
112 | // message.setTitle("暂无");
113 | // message.setNotifyID(notifyId);
114 | // message.setMessage(content);
115 | // message.setExtra(JsonUtils.getJson(extras));
116 | // message.setTarget(Target.EMUI);
117 | // JHandler.handler().post(new Runnable() {
118 | // @Override
119 | // public void run() {
120 | // mPushInterface.onMessageClicked(context, message);
121 | // }
122 | // });
123 | // }
124 | // } catch (Exception e) {
125 | // e.printStackTrace();
126 | // }
127 | } else if (Event.PLUGINRSP.equals(event)) {
128 | final int TYPE_LBS = 1;
129 | final int TYPE_TAG = 2;
130 | int reportType = extras.getInt(BOUND_KEY.PLUGINREPORTTYPE, -1);
131 | boolean isSuccess = extras.getBoolean(BOUND_KEY.PLUGINREPORTRESULT, false);
132 | String message = "";
133 | if (TYPE_LBS == reportType) {
134 | message = "LBS report result :";
135 | } else if (TYPE_TAG == reportType) {
136 | message = "TAG report result :";
137 | }
138 | L.i(message + isSuccess);
139 | // showPushMessage(PustDemoActivity.RECEIVE_TAG_LBS_MSG, message + isSuccess);
140 | super.onEvent(context, event, extras);
141 | }
142 | }
143 |
144 |
145 | public static void clearPushInterface() {
146 | mPushInterface = null;
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/emui/EMPushManager.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.emui;
2 |
3 | import android.content.Context;
4 |
5 | import com.huawei.android.pushagent.api.PushManager;
6 | import com.jiang.android.push.IPushManager;
7 | import com.jiang.android.push.PushInterface;
8 | import com.jiang.android.push.model.TokenModel;
9 | import com.jiang.android.push.utils.RomUtil;
10 | import com.jiang.android.push.utils.Target;
11 |
12 | import java.util.HashMap;
13 | import java.util.Map;
14 |
15 | public class EMPushManager implements IPushManager {
16 | @Override
17 | public void register(Context context, boolean debug, PushInterface pushInterface) {
18 | if (pushInterface != null) {
19 | EMHuaweiPushReceiver.registerInterface(pushInterface);
20 | }
21 | PushManager.requestToken(context);
22 |
23 | }
24 |
25 | @Override
26 | public void unregister(Context context) {
27 | EMHuaweiPushReceiver.clearPushInterface();
28 | PushManager.deregisterToken(context, getToken(context).getToken());
29 |
30 | }
31 |
32 | @Override
33 | public void setPushInterface(PushInterface pushInterface) {
34 | if (pushInterface != null) {
35 | EMHuaweiPushReceiver.registerInterface(pushInterface);
36 | }
37 | }
38 |
39 | @Override
40 | public void setAlias(Context context, String alias) {
41 | Map tag = new HashMap<>();
42 | tag.put("name", alias);
43 | PushManager.setTags(context, tag);
44 | }
45 |
46 | @Override
47 | public TokenModel getToken(Context context) {
48 | if (context == null)
49 | return null;
50 | TokenModel result = new TokenModel();
51 | result.setTarget(RomUtil.rom());
52 | result.setToken(EMHuaweiPushReceiver.getmToken());
53 | return result;
54 | }
55 |
56 | @Override
57 | public void pause(Context context) {
58 | PushManager.enableReceiveNormalMsg(context, false);
59 | PushManager.enableReceiveNotifyMsg(context, false);
60 | if (EMHuaweiPushReceiver.getPushInterface() != null) {
61 | EMHuaweiPushReceiver.getPushInterface().onPaused(context);
62 | }
63 |
64 | }
65 |
66 | @Override
67 | public void resume(Context context) {
68 | PushManager.enableReceiveNormalMsg(context, true);
69 | PushManager.enableReceiveNotifyMsg(context, true);
70 | if (EMHuaweiPushReceiver.getPushInterface() != null) {
71 | EMHuaweiPushReceiver.getPushInterface().onResume(context);
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/flyme/FlymePushManager.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.flyme;
2 |
3 | import android.content.Context;
4 |
5 | import com.jiang.android.push.Const;
6 | import com.jiang.android.push.IPushManager;
7 | import com.jiang.android.push.PushInterface;
8 | import com.jiang.android.push.model.TokenModel;
9 | import com.jiang.android.push.utils.RomUtil;
10 | import com.meizu.cloud.pushsdk.PushManager;
11 |
12 | public class FlymePushManager implements IPushManager {
13 | @Override
14 | public void register(Context context, boolean debug, PushInterface pushInterface) {
15 | if (pushInterface != null) {
16 | FlymeReceiver.registerInterface(pushInterface);
17 | }
18 | PushManager.register(context, Const.getFlyme_app_id(), Const.getFlyme_app_key());
19 | }
20 |
21 | @Override
22 | public void unregister(Context context) {
23 | FlymeReceiver.clearPushInterface();
24 | PushManager.unRegister(context, Const.getFlyme_app_id(), Const.getFlyme_app_key());
25 | }
26 |
27 | @Override
28 | public void setPushInterface(PushInterface pushInterface) {
29 | if (pushInterface != null) {
30 | FlymeReceiver.registerInterface(pushInterface);
31 | }
32 | }
33 |
34 | @Override
35 | public void setAlias(Context context, String alias) {
36 | PushManager.subScribeAlias(context, Const.getFlyme_app_id(), Const.getFlyme_app_key(), getToken(context).getToken(), alias);
37 |
38 | }
39 |
40 | @Override
41 | public TokenModel getToken(Context context) {
42 | if (context == null)
43 | return null;
44 | TokenModel result = new TokenModel();
45 | result.setTarget(RomUtil.rom());
46 | result.setToken(PushManager.getPushId(context));
47 | return result;
48 | }
49 |
50 | @Override
51 | public void pause(Context context) {
52 | PushManager.unRegister(context, Const.getFlyme_app_id(), Const.getFlyme_app_key());
53 | if (FlymeReceiver.getPushInterface() != null) {
54 | FlymeReceiver.getPushInterface().onPaused(context);
55 | }
56 | }
57 |
58 | @Override
59 | public void resume(Context context) {
60 | PushManager.register(context, Const.getMiui_app_id(), Const.getFlyme_app_key());
61 | if (FlymeReceiver.getPushInterface() != null) {
62 | FlymeReceiver.getPushInterface().onResume(context);
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/flyme/FlymeReceiver.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.flyme;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 |
6 | import com.jiang.android.push.Message;
7 | import com.jiang.android.push.PushInterface;
8 | import com.jiang.android.push.utils.JHandler;
9 | import com.jiang.android.push.utils.L;
10 | import com.jiang.android.push.utils.Target;
11 | import com.meizu.cloud.pushsdk.MzPushMessageReceiver;
12 | import com.meizu.cloud.pushsdk.notification.PushNotificationBuilder;
13 | import com.meizu.cloud.pushsdk.platform.message.PushSwitchStatus;
14 | import com.meizu.cloud.pushsdk.platform.message.RegisterStatus;
15 | import com.meizu.cloud.pushsdk.platform.message.SubAliasStatus;
16 | import com.meizu.cloud.pushsdk.platform.message.SubTagsStatus;
17 | import com.meizu.cloud.pushsdk.platform.message.UnRegisterStatus;
18 |
19 | /**
20 | * flyme push
21 | * 如果发现onregister回调了两次,那就得删除相关的代码,主要是因为flyme的sdk分老版本和新版本
22 | * Created by jiang on 2016/10/8.
23 | */
24 |
25 | public class FlymeReceiver extends MzPushMessageReceiver {
26 |
27 | private static PushInterface mPushInterface = null;
28 |
29 | public static void registerInterface(PushInterface pushInterface) {
30 |
31 | mPushInterface = pushInterface;
32 | }
33 |
34 |
35 | public static PushInterface getPushInterface() {
36 | return mPushInterface;
37 | }
38 |
39 | @Override
40 | public void onRegister(final Context context, final String pushid) {
41 | //应用在接受返回的pushid
42 | L.i("onRegister called pushId: " + pushid);
43 | if (mPushInterface != null) {
44 | JHandler.handler().post(new Runnable() {
45 | @Override
46 | public void run() {
47 | mPushInterface.onRegister(context, pushid);
48 |
49 | }
50 | });
51 | }
52 | }
53 |
54 | /**
55 | * 若该回调有数据,就证明是透传消息,否则全部都是通知消息
56 | *
57 | * @param context
58 | * @param s
59 | */
60 | @Override
61 | public void onMessage(final Context context, final String s) {
62 | L.i("onMessage called: s:" + s);
63 | if (mPushInterface != null) {
64 | final Message message = new Message();
65 | message.setMessageID("");
66 | message.setTarget(Target.FLYME);
67 | message.setExtra(s);
68 | JHandler.handler().post(new Runnable() {
69 | @Override
70 | public void run() {
71 |
72 |
73 | mPushInterface.onCustomMessage(context, message);
74 |
75 |
76 | }
77 | });
78 | }
79 | }
80 |
81 | @Override
82 | public void onMessage(Context context, Intent intent) {
83 | super.onMessage(context, intent);
84 | }
85 |
86 | @Override
87 | public void onUnRegister(final Context context, boolean b) {
88 | //调用PushManager.unRegister(context)方法后,会在此回调反注册状态
89 | L.i("onUnRegister called");
90 | if (b == true) {
91 | if (mPushInterface != null) {
92 | JHandler.handler().post(new Runnable() {
93 | @Override
94 | public void run() {
95 | mPushInterface.onUnRegister(context);
96 |
97 | }
98 | });
99 | }
100 | }
101 | }
102 |
103 | //设置通知栏小图标
104 | @Override
105 | public void onUpdateNotificationBuilder(PushNotificationBuilder pushNotificationBuilder) {
106 | // pushNotificationBuilder.setmStatusbarIcon(R.drawable.mz_stat_share_weibo);
107 | }
108 |
109 | @Override
110 | public void onPushStatus(Context context, PushSwitchStatus pushSwitchStatus) {
111 | //检查通知栏和透传消息开关状态回调
112 | }
113 |
114 | @Override
115 | public void onRegisterStatus(final Context context, final RegisterStatus registerStatus) {
116 | //新版订阅回调
117 | if (mPushInterface != null) {
118 | JHandler.handler().post(new Runnable() {
119 | @Override
120 | public void run() {
121 | mPushInterface.onRegister(context, registerStatus.getPushId());
122 | }
123 | });
124 | }
125 | }
126 |
127 | @Override
128 | public void onUnRegisterStatus(final Context context, UnRegisterStatus unRegisterStatus) {
129 | //新版反订阅回调
130 | L.i("onUnRegisterStatus");
131 | if (mPushInterface != null) {
132 | JHandler.handler().post(new Runnable() {
133 | @Override
134 | public void run() {
135 | mPushInterface.onUnRegister(context);
136 | }
137 | });
138 | }
139 | }
140 |
141 | @Override
142 | public void onSubTagsStatus(Context context, SubTagsStatus subTagsStatus) {
143 | //标签回调
144 | L.i("onSubTagsStatus");
145 | }
146 |
147 | @Override
148 | public void onSubAliasStatus(final Context context, final SubAliasStatus subAliasStatus) {
149 | L.i("onSubAliasStatus");
150 | if (mPushInterface != null) {
151 | JHandler.handler().post(new Runnable() {
152 | @Override
153 | public void run() {
154 | mPushInterface.onAlias(context, subAliasStatus.getAlias());
155 | }
156 | });
157 | }
158 |
159 | //别名回调
160 | }
161 |
162 | public static void clearPushInterface() {
163 | mPushInterface = null;
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/jpush/JPushManager.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.jpush;
2 |
3 | import android.content.Context;
4 |
5 | import com.jiang.android.push.IPushManager;
6 | import com.jiang.android.push.PushInterface;
7 | import com.jiang.android.push.model.TokenModel;
8 | import com.jiang.android.push.utils.L;
9 | import com.jiang.android.push.utils.RomUtil;
10 |
11 | import java.util.Set;
12 |
13 | import cn.jpush.android.api.JPushInterface;
14 | import cn.jpush.android.api.TagAliasCallback;
15 |
16 | public class JPushManager implements IPushManager {
17 | @Override
18 | public void register(Context context, boolean debug, PushInterface pushInterface) {
19 | if (pushInterface != null) {
20 | JPushReceiver.registerInterface(pushInterface);
21 | }
22 | JPushInterface.init(context);
23 | JPushInterface.setDebugMode(debug);
24 | }
25 |
26 | @Override
27 | public void unregister(Context context) {
28 | JPushReceiver.clearPushInterface();
29 | JPushInterface.stopPush(context);
30 | }
31 |
32 | @Override
33 | public void setPushInterface(PushInterface pushInterface) {
34 | if (pushInterface != null) {
35 | JPushReceiver.registerInterface(pushInterface);
36 | }
37 | }
38 |
39 | @Override
40 | public void setAlias(final Context context, String alias) {
41 | JPushInterface.setAlias(context, alias, new TagAliasCallback() {
42 | @Override
43 | public void gotResult(int i, String s, Set set) {
44 | if (i == 0) { // 这里极光规定0代表成功
45 | if (JPushReceiver.getPushInterface() != null) {
46 | L.i("JPushInterface.setAlias");
47 | JPushReceiver.getPushInterface().onAlias(context, s);
48 |
49 | }
50 | }
51 | }
52 | });
53 | }
54 |
55 | @Override
56 | public TokenModel getToken(Context context) {
57 | if (context == null)
58 | return null;
59 | TokenModel result = new TokenModel();
60 | result.setTarget(RomUtil.rom());
61 | result.setToken(JPushInterface.getRegistrationID(context));
62 | return result;
63 | }
64 |
65 | @Override
66 | public void pause(Context context) {
67 | if (!JPushInterface.isPushStopped(context)) {
68 | JPushInterface.stopPush(context);
69 | if (JPushReceiver.getPushInterface() != null) {
70 | JPushReceiver.getPushInterface().onPaused(context);
71 | }
72 | }
73 | }
74 |
75 | @Override
76 | public void resume(Context context) {
77 | if (JPushInterface.isPushStopped(context)) {
78 | JPushInterface.resumePush(context);
79 | if (JPushReceiver.getPushInterface() != null) {
80 | JPushReceiver.getPushInterface().onResume(context);
81 | }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/jpush/JPushReceiver.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.jpush;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 |
8 | import com.jiang.android.push.Message;
9 | import com.jiang.android.push.PushInterface;
10 | import com.jiang.android.push.utils.L;
11 | import com.jiang.android.push.utils.Target;
12 |
13 | import org.json.JSONException;
14 | import org.json.JSONObject;
15 |
16 | import java.util.Iterator;
17 |
18 | import cn.jpush.android.api.JPushInterface;
19 |
20 | /**
21 | * Created by jiang on 2016/10/8.
22 | */
23 |
24 | public class JPushReceiver extends BroadcastReceiver {
25 |
26 |
27 | private static PushInterface mPushInterface;
28 |
29 | public static void registerInterface(PushInterface pushInterface) {
30 | mPushInterface = pushInterface;
31 | }
32 |
33 | public static PushInterface getPushInterface() {
34 | return mPushInterface;
35 | }
36 |
37 | @Override
38 | public void onReceive(Context context, Intent intent) {
39 | Bundle bundle = intent.getExtras();
40 | L.i("[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
41 | int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
42 | String messageId = bundle.getString(JPushInterface.EXTRA_MSG_ID);
43 | String extraMessage = bundle.getString(JPushInterface.EXTRA_EXTRA);
44 |
45 | if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
46 | String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
47 | L.i("[MyReceiver] 接收Registration Id : " + regId);
48 | if (mPushInterface != null)
49 | mPushInterface.onRegister(context, regId);
50 |
51 | } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
52 | L.i("[MyReceiver] 接收到推送下来的自定义消息: " + extraMessage);
53 | if (mPushInterface != null) {
54 | Message message = new Message();
55 | message.setTitle(bundle.getString(JPushInterface.EXTRA_TITLE));
56 | message.setMessageID(messageId);
57 | message.setMessage(bundle.getString(JPushInterface.EXTRA_MESSAGE));
58 | message.setExtra(extraMessage);
59 | message.setTarget(Target.JPUSH);
60 | mPushInterface.onCustomMessage(context, message);
61 | }
62 |
63 | } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
64 |
65 | L.i("[MyReceiver] 接收到推送下来的通知");
66 |
67 | L.i("[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
68 | if (mPushInterface != null) {
69 | Message message = new Message();
70 | message.setNotifyID(notifactionId);
71 | message.setMessageID(messageId);
72 | message.setTitle(bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE));
73 | message.setMessage(bundle.getString(JPushInterface.EXTRA_ALERT));
74 | message.setExtra(extraMessage);
75 | message.setTarget(Target.JPUSH);
76 | mPushInterface.onMessage(context, message);
77 | }
78 |
79 | } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
80 | L.i("[MyReceiver] 用户点击打开了通知");
81 | if (mPushInterface != null) {
82 | Message message = new Message();
83 | message.setNotifyID(notifactionId);
84 | message.setMessageID(messageId);
85 | message.setTitle(bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE));
86 | message.setMessage(bundle.getString(JPushInterface.EXTRA_ALERT));
87 | message.setExtra(extraMessage);
88 | message.setTarget(Target.JPUSH);
89 | mPushInterface.onMessageClicked(context, message);
90 | }
91 |
92 |
93 | } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
94 | L.i("[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
95 | //在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..
96 |
97 | } else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
98 | boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
99 | L.i("[MyReceiver]" + intent.getAction() + " connected state change to " + connected);
100 | } else {
101 | L.i("[MyReceiver] Unhandled intent - " + intent.getAction());
102 | }
103 | }
104 |
105 | // 打印所有的 intent extra 数据
106 | private static String printBundle(Bundle bundle) {
107 | StringBuilder sb = new StringBuilder();
108 | for (String key : bundle.keySet()) {
109 | if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
110 | sb.append("\nkey:").append(key).append(", value:").append(bundle.getInt(key));
111 | } else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) {
112 | sb.append("\nkey:").append(key).append(", value:").append(bundle.getBoolean(key));
113 | } else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
114 | if (bundle.getString(JPushInterface.EXTRA_EXTRA).isEmpty()) {
115 | L.i("This message has no Extra data");
116 | continue;
117 | }
118 |
119 | try {
120 | JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
121 | Iterator it = json.keys();
122 |
123 | while (it.hasNext()) {
124 | String myKey = it.next().toString();
125 | sb.append("\nkey:").append(key + ", value: [" +
126 | myKey).append(" - ").append(json.optString(myKey) + "]");
127 | }
128 | } catch (JSONException e) {
129 | L.i("Get message extra JSON error!");
130 | }
131 |
132 | } else {
133 | sb.append("\nkey:").append(key).append(", value:" + bundle.getString(key));
134 | }
135 | }
136 | return sb.toString();
137 | }
138 |
139 | public static void clearPushInterface() {
140 | mPushInterface = null;
141 | }
142 |
143 |
144 | }
145 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/miui/MiuiPushManager.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.miui;
2 |
3 | import android.app.ActivityManager;
4 | import android.content.Context;
5 | import android.os.Process;
6 |
7 | import com.jiang.android.push.Const;
8 | import com.jiang.android.push.IPushManager;
9 | import com.jiang.android.push.PushInterface;
10 | import com.jiang.android.push.model.TokenModel;
11 | import com.jiang.android.push.utils.L;
12 | import com.jiang.android.push.utils.RomUtil;
13 | import com.xiaomi.channel.commonutils.logger.LoggerInterface;
14 | import com.xiaomi.mipush.sdk.Logger;
15 | import com.xiaomi.mipush.sdk.MiPushClient;
16 |
17 | import java.util.List;
18 |
19 | public class MiuiPushManager implements IPushManager {
20 | @Override
21 | public void register(Context context, boolean debug, PushInterface pushInterface) {
22 | if (pushInterface != null) {
23 | MiuiReceiver.registerInterface(pushInterface);
24 | }
25 | if (shouldInit(context)) {
26 | MiPushClient.registerPush(context, Const.getMiui_app_id(), Const.getMiui_app_key());
27 | }
28 | if (debug) {
29 | LoggerInterface newLogger = new LoggerInterface() {
30 | @Override
31 | public void setTag(String tag) {
32 | // ignore
33 | }
34 |
35 | @Override
36 | public void log(String content, Throwable t) {
37 | L.i("content" + content + " exception: " + t.toString());
38 | }
39 |
40 | @Override
41 | public void log(String content) {
42 | L.i("miui: " + content);
43 | }
44 | };
45 | Logger.setLogger(context, newLogger);
46 | }
47 | }
48 |
49 |
50 | private static boolean shouldInit(Context context) {
51 | ActivityManager am = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE));
52 | List processInfos = am.getRunningAppProcesses();
53 | String mainProcessName = context.getPackageName();
54 | int myPid = Process.myPid();
55 | for (ActivityManager.RunningAppProcessInfo info : processInfos) {
56 | if (info.pid == myPid && mainProcessName.equals(info.processName)) {
57 | return true;
58 | }
59 | }
60 | return false;
61 | }
62 |
63 | @Override
64 | public void unregister(Context context) {
65 | MiuiReceiver.clearPushInterface();
66 | MiPushClient.unregisterPush(context);
67 | }
68 |
69 | @Override
70 | public void setPushInterface(PushInterface pushInterface) {
71 | if (pushInterface != null) {
72 | MiuiReceiver.registerInterface(pushInterface);
73 | }
74 | }
75 |
76 | @Override
77 | public void setAlias(Context context, String alias) {
78 | MiPushClient.setAlias(context, alias, null);
79 |
80 | }
81 |
82 | @Override
83 | public TokenModel getToken(Context context) {
84 | if (context == null)
85 | return null;
86 | TokenModel result = new TokenModel();
87 | result.setTarget(RomUtil.rom());
88 | result.setToken(MiPushClient.getRegId(context));
89 | return result;
90 | }
91 |
92 | @Override
93 | public void pause(Context context) {
94 | MiPushClient.pausePush(context, null);
95 | if (MiuiReceiver.getPushInterface() != null) {
96 | MiuiReceiver.getPushInterface().onPaused(context);
97 | }
98 | }
99 |
100 | @Override
101 | public void resume(Context context) {
102 | MiPushClient.resumePush(context, null);
103 | if (MiuiReceiver.getPushInterface() != null) {
104 | MiuiReceiver.getPushInterface().onResume(context);
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/miui/MiuiReceiver.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.miui;
2 |
3 | import android.content.Context;
4 | import android.text.TextUtils;
5 | import android.util.Log;
6 |
7 | import com.jiang.android.push.Message;
8 | import com.jiang.android.push.PushInterface;
9 | import com.jiang.android.push.utils.JHandler;
10 | import com.jiang.android.push.utils.JsonUtils;
11 | import com.jiang.android.push.utils.L;
12 | import com.jiang.android.push.utils.Target;
13 | import com.xiaomi.mipush.sdk.ErrorCode;
14 | import com.xiaomi.mipush.sdk.MiPushClient;
15 | import com.xiaomi.mipush.sdk.MiPushCommandMessage;
16 | import com.xiaomi.mipush.sdk.MiPushMessage;
17 | import com.xiaomi.mipush.sdk.PushMessageReceiver;
18 |
19 | import java.util.List;
20 |
21 | /**
22 | * 小米推送下来的消息运行在子线程
23 | * Created by jiang on 2016/10/8.
24 | */
25 |
26 | public class MiuiReceiver extends PushMessageReceiver {
27 |
28 | private static final String TAG = "MiuiReceiver";
29 | private String mRegId;
30 | private long mResultCode = -1;
31 | private String mReason;
32 | private String mCommand;
33 | private String mMessage;
34 | private String mTopic;
35 | private String mAlias;
36 | private String mUserAccount;
37 | private String mStartTime;
38 | private String mEndTime;
39 |
40 |
41 | private static PushInterface mPushInterface;
42 |
43 | /**
44 | * @param pushInterface
45 | */
46 | public static void registerInterface(PushInterface pushInterface) {
47 |
48 | mPushInterface = pushInterface;
49 | }
50 |
51 | public static PushInterface getPushInterface() {
52 | return mPushInterface;
53 | }
54 |
55 |
56 | @Override
57 | public void onReceivePassThroughMessage(final Context context, MiPushMessage message) {
58 | mMessage = message.getContent();
59 | if (!TextUtils.isEmpty(message.getTopic())) {
60 | mTopic = message.getTopic();
61 | } else if (!TextUtils.isEmpty(message.getAlias())) {
62 | mAlias = message.getAlias();
63 | } else if (!TextUtils.isEmpty(message.getUserAccount())) {
64 | mUserAccount = message.getUserAccount();
65 | }
66 | if (mPushInterface != null) {
67 | final Message result = new Message();
68 | result.setMessageID(message.getMessageId());
69 | result.setTitle(message.getTitle());
70 | result.setMessage(message.getContent());
71 | result.setExtra(mMessage);
72 | result.setTarget(Target.MIUI);
73 | try {
74 | // result.setExtra(JsonUtils.setJson(message.getExtra()).toString());
75 | result.setExtra(message.getContent());
76 | } catch (Exception e) {
77 | L.i("onReceivePassThroughMessage: " + e.toString());
78 | result.setExtra("{}");
79 | }
80 | JHandler.handler().post(new Runnable() {
81 | @Override
82 | public void run() {
83 | mPushInterface.onCustomMessage(context, result);
84 | }
85 | });
86 | }
87 |
88 |
89 | }
90 |
91 | @Override
92 | public void onNotificationMessageClicked(final Context context, MiPushMessage message) {
93 | mMessage = message.getContent();
94 | if (!TextUtils.isEmpty(message.getTopic())) {
95 | mTopic = message.getTopic();
96 | } else if (!TextUtils.isEmpty(message.getAlias())) {
97 | mAlias = message.getAlias();
98 | } else if (!TextUtils.isEmpty(message.getUserAccount())) {
99 | mUserAccount = message.getUserAccount();
100 | }
101 | if (mPushInterface != null) {
102 | final Message result = new Message();
103 | result.setNotifyID(message.getNotifyId());
104 | result.setMessageID(message.getMessageId());
105 | result.setTitle(mTopic);
106 | result.setMessage(mMessage);
107 | result.setTarget(Target.MIUI);
108 | try {
109 | result.setExtra(JsonUtils.setJson(message.getExtra()).toString());
110 | // result.setExtra(message.getContent());
111 | } catch (Exception e) {
112 | Log.e(TAG, "onNotificationMessageClicked: " + e.toString());
113 | result.setExtra("{}");
114 | }
115 | JHandler.handler().post(new Runnable() {
116 | @Override
117 | public void run() {
118 | mPushInterface.onMessageClicked(context, result);
119 | }
120 | });
121 | }
122 | }
123 |
124 | @Override
125 | public void onNotificationMessageArrived(final Context context, MiPushMessage message) {
126 | mMessage = message.getContent();
127 | if (!TextUtils.isEmpty(message.getTopic())) {
128 | mTopic = message.getTopic();
129 | } else if (!TextUtils.isEmpty(message.getAlias())) {
130 | mAlias = message.getAlias();
131 | } else if (!TextUtils.isEmpty(message.getUserAccount())) {
132 | mUserAccount = message.getUserAccount();
133 | }
134 | if (mPushInterface != null) {
135 | final Message result = new Message();
136 | result.setTitle(message.getTitle());
137 | result.setMessageID(message.getMessageId());
138 | result.setNotifyID(message.getNotifyId());
139 | result.setMessage(message.getDescription());
140 | result.setTarget(Target.MIUI);
141 | try {
142 | result.setExtra(JsonUtils.setJson(message.getExtra()).toString());
143 | // result.setExtra(message.getContent());
144 | } catch (Exception e) {
145 | L.i("onReceivePassThroughMessage: " + e.toString());
146 | result.setExtra("{}");
147 | }
148 | JHandler.handler().post(new Runnable() {
149 | @Override
150 | public void run() {
151 | mPushInterface.onMessage(context, result);
152 | }
153 | });
154 | }
155 | }
156 |
157 | @Override
158 | public void onCommandResult(final Context context, MiPushCommandMessage message) {
159 | String command = message.getCommand();
160 | List arguments = message.getCommandArguments();
161 | String cmdArg1 = ((arguments != null && arguments.size() > 0) ? arguments.get(0) : null);
162 | String cmdArg2 = ((arguments != null && arguments.size() > 1) ? arguments.get(1) : null);
163 | if (MiPushClient.COMMAND_REGISTER.equals(command)) {
164 | if (message.getResultCode() == ErrorCode.SUCCESS) {
165 | mRegId = cmdArg1;
166 | if (mPushInterface != null) {
167 | JHandler.handler().post(new Runnable() {
168 | @Override
169 | public void run() {
170 | mPushInterface.onRegister(context, mRegId);
171 | }
172 | });
173 | }
174 | } else if (MiPushClient.COMMAND_SET_ALIAS.equals(command)) {
175 | if (message.getResultCode() == ErrorCode.SUCCESS) {
176 | mAlias = cmdArg1;
177 | if (mPushInterface != null) {
178 | JHandler.handler().post(new Runnable() {
179 | @Override
180 | public void run() {
181 | mPushInterface.onAlias(context, mAlias);
182 | }
183 | });
184 | }
185 | }
186 | } else if (MiPushClient.COMMAND_UNSET_ALIAS.equals(command)) {
187 | if (message.getResultCode() == ErrorCode.SUCCESS) {
188 | mAlias = cmdArg1;
189 | }
190 | } else if (MiPushClient.COMMAND_SUBSCRIBE_TOPIC.equals(command)) {
191 | if (message.getResultCode() == ErrorCode.SUCCESS) {
192 | mTopic = cmdArg1;
193 | }
194 | } else if (MiPushClient.COMMAND_UNSUBSCRIBE_TOPIC.equals(command)) {
195 | if (message.getResultCode() == ErrorCode.SUCCESS) {
196 | mTopic = cmdArg1;
197 | }
198 | } else if (MiPushClient.COMMAND_SET_ACCEPT_TIME.equals(command)) {
199 | if (message.getResultCode() == ErrorCode.SUCCESS) {
200 | mStartTime = cmdArg1;
201 | mEndTime = cmdArg2;
202 | }
203 | }
204 | }
205 |
206 |
207 | }
208 |
209 | @Override
210 | public void onReceiveRegisterResult(Context context, MiPushCommandMessage miPushCommandMessage) {
211 | super.onReceiveRegisterResult(context, miPushCommandMessage);
212 | }
213 |
214 | public static void clearPushInterface() {
215 | mPushInterface = null;
216 | }
217 |
218 | }
219 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/model/TokenModel.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.model;
2 |
3 | import com.jiang.android.push.utils.Target;
4 |
5 | /**
6 | * Created by jiang on 2016/10/8.
7 | */
8 |
9 | public class TokenModel {
10 | private String mToken;
11 | private Target mTarget;
12 |
13 | public String getToken() {
14 | return mToken;
15 | }
16 |
17 | public void setToken(String mToken) {
18 | this.mToken = mToken;
19 | }
20 |
21 | public Target getTarget() {
22 | return mTarget;
23 | }
24 |
25 | public void setTarget(Target mTarget) {
26 | this.mTarget = mTarget;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/oppo/OppoPushManager.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.oppo;
2 |
3 | import android.content.Context;
4 |
5 | import com.coloros.mcssdk.PushManager;
6 | import com.coloros.mcssdk.callback.PushCallback;
7 | import com.coloros.mcssdk.mode.SubscribeResult;
8 | import com.jiang.android.push.Const;
9 | import com.jiang.android.push.IPushManager;
10 | import com.jiang.android.push.PushInterface;
11 | import com.jiang.android.push.model.TokenModel;
12 | import com.jiang.android.push.utils.RomUtil;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | public class OppoPushManager implements IPushManager {
18 | @Override
19 | public void register(Context context, boolean debug, PushInterface pushInterface) {
20 | PushManager.getInstance().register(context, Const.getColor_app_key(), Const.getColor_app_secret(), new PushCallback() {
21 | @Override
22 | public void onRegister(int i, String s) {
23 |
24 |
25 | }
26 |
27 | @Override
28 | public void onUnRegister(int i) {
29 |
30 | }
31 |
32 | @Override
33 | public void onGetAliases(int i, List list) {
34 |
35 | }
36 |
37 | @Override
38 | public void onSetAliases(int i, List list) {
39 |
40 | }
41 |
42 | @Override
43 | public void onUnsetAliases(int i, List list) {
44 |
45 | }
46 |
47 | @Override
48 | public void onSetUserAccounts(int i, List list) {
49 |
50 | }
51 |
52 | @Override
53 | public void onUnsetUserAccounts(int i, List list) {
54 |
55 | }
56 |
57 | @Override
58 | public void onGetUserAccounts(int i, List list) {
59 |
60 | }
61 |
62 | @Override
63 | public void onSetTags(int i, List list) {
64 |
65 | }
66 |
67 | @Override
68 | public void onUnsetTags(int i, List list) {
69 |
70 | }
71 |
72 | @Override
73 | public void onGetTags(int i, List list) {
74 |
75 | }
76 |
77 | @Override
78 | public void onGetPushStatus(int i, int i1) {
79 |
80 | }
81 |
82 | @Override
83 | public void onSetPushTime(int i, String s) {
84 |
85 | }
86 |
87 | @Override
88 | public void onGetNotificationStatus(int i, int i1) {
89 |
90 | }
91 | });
92 | }
93 |
94 | @Override
95 | public void unregister(Context context) {
96 | PushManager.getInstance().unRegister();
97 |
98 | }
99 |
100 | @Override
101 | public void setPushInterface(PushInterface pushInterface) {
102 |
103 | }
104 |
105 | @Override
106 | public void setAlias(Context context, String alias) {
107 |
108 | List list = new ArrayList<>();
109 | list.add(alias);
110 | PushManager.getInstance().setAliases(list);
111 | }
112 |
113 | @Override
114 | public TokenModel getToken(Context context) {
115 | if (context == null)
116 | return null;
117 | TokenModel result = new TokenModel();
118 | result.setTarget(RomUtil.rom());
119 | result.setToken(PushManager.getInstance().getRegisterID());
120 | return result;
121 | }
122 |
123 | @Override
124 | public void pause(Context context) {
125 | PushManager.getInstance().pausePush();
126 |
127 | }
128 |
129 | @Override
130 | public void resume(Context context) {
131 | PushManager.getInstance().resumePush();
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/utils/BuildProperties.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.utils;
2 |
3 | import android.os.Environment;
4 |
5 | import java.io.File;
6 | import java.io.FileInputStream;
7 | import java.io.IOException;
8 | import java.util.Collection;
9 | import java.util.Enumeration;
10 | import java.util.Map.Entry;
11 | import java.util.Properties;
12 | import java.util.Set;
13 |
14 | /**
15 | * Created by jiang on 2016/10/8.
16 | */
17 |
18 | public class BuildProperties {
19 |
20 | private final Properties properties;
21 |
22 | private BuildProperties() throws IOException {
23 | properties = new Properties();
24 | properties.load(new FileInputStream(new File(Environment.getRootDirectory(), "build.prop")));
25 | }
26 |
27 | public boolean containsKey(final Object key) {
28 | return properties.containsKey(key);
29 | }
30 |
31 | public boolean containsValue(final Object value) {
32 | return properties.containsValue(value);
33 | }
34 |
35 | public Set> entrySet() {
36 | return properties.entrySet();
37 | }
38 |
39 | public String getProperty(final String name) {
40 | return properties.getProperty(name);
41 | }
42 |
43 | public String getProperty(final String name, final String defaultValue) {
44 | return properties.getProperty(name, defaultValue);
45 | }
46 |
47 | public boolean isEmpty() {
48 | return properties.isEmpty();
49 | }
50 |
51 | public Enumeration keys() {
52 | return properties.keys();
53 | }
54 |
55 | public Set keySet() {
56 | return properties.keySet();
57 | }
58 |
59 | public int size() {
60 | return properties.size();
61 | }
62 |
63 | public Collection values() {
64 | return properties.values();
65 | }
66 |
67 | public static BuildProperties newInstance() throws IOException {
68 | return new BuildProperties();
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/utils/JHandler.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.utils;
2 |
3 | import android.os.Looper;
4 |
5 | /**
6 | * Created by jiang on 2016/10/10.
7 | */
8 |
9 | public class JHandler {
10 | private static android.os.Handler mHandler = null;
11 |
12 | public static android.os.Handler handler() {
13 | if (mHandler == null) {
14 | synchronized (JHandler.class) {
15 | mHandler = new android.os.Handler(Looper.getMainLooper());
16 | }
17 | }
18 | return mHandler;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/utils/JsonUtils.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.utils;
2 |
3 | import android.os.Bundle;
4 |
5 | import org.json.JSONArray;
6 | import org.json.JSONException;
7 | import org.json.JSONObject;
8 |
9 | import java.lang.reflect.Array;
10 | import java.util.Collection;
11 | import java.util.Iterator;
12 | import java.util.List;
13 | import java.util.Map;
14 | import java.util.Set;
15 |
16 | /**
17 | * Created by jiang on 2016/10/9.
18 | */
19 |
20 | public class JsonUtils {
21 |
22 | public static String getJson(final Bundle bundle) {
23 | if (bundle == null) return null;
24 | JSONObject jsonObject = new JSONObject();
25 |
26 | for (String key : bundle.keySet()) {
27 | Object obj = bundle.get(key);
28 | try {
29 | jsonObject.put(key, wrap(bundle.get(key)));
30 | } catch (JSONException e) {
31 | e.printStackTrace();
32 | }
33 | }
34 | return jsonObject.toString();
35 | }
36 |
37 | private static Object wrap(Object o) {
38 | if (o == null) {
39 | return JSONObject.NULL;
40 | }
41 | if (o instanceof JSONArray || o instanceof JSONObject) {
42 | return o;
43 | }
44 | if (o.equals(JSONObject.NULL)) {
45 | return o;
46 | }
47 | try {
48 | if (o instanceof Collection) {
49 | return new JSONArray((Collection) o);
50 | } else if (o.getClass().isArray()) {
51 | return toJSONArray(o);
52 | }
53 | if (o instanceof Map) {
54 | return new JSONObject((Map) o);
55 | }
56 | if (o instanceof Boolean ||
57 | o instanceof Byte ||
58 | o instanceof Character ||
59 | o instanceof Double ||
60 | o instanceof Float ||
61 | o instanceof Integer ||
62 | o instanceof Long ||
63 | o instanceof Short ||
64 | o instanceof String) {
65 | return o;
66 | }
67 | if (o.getClass().getPackage().getName().startsWith("java.")) {
68 | return o.toString();
69 | }
70 | } catch (Exception ignored) {
71 | }
72 | return null;
73 | }
74 |
75 | private static JSONArray toJSONArray(Object array) throws JSONException {
76 | JSONArray result = new JSONArray();
77 | if (!array.getClass().isArray()) {
78 | throw new JSONException("Not a primitive array: " + array.getClass());
79 | }
80 | final int length = Array.getLength(array);
81 | for (int i = 0; i < length; ++i) {
82 | result.put(wrap(Array.get(array, i)));
83 | }
84 | return result;
85 | }
86 |
87 | /**
88 | * 将map数据解析出来,并拼接成json字符串
89 | *
90 | * @param map
91 | * @return
92 | */
93 | public static JSONObject setJson(Map map) throws Exception {
94 | JSONObject json = null;
95 | StringBuffer temp = new StringBuffer();
96 | if (!map.isEmpty()) {
97 | temp.append("{");
98 | // 遍历map
99 | Set set = map.entrySet();
100 | Iterator i = set.iterator();
101 | while (i.hasNext()) {
102 | Map.Entry entry = (Map.Entry) i.next();
103 | String key = (String) entry.getKey();
104 | Object value = entry.getValue();
105 | temp.append("\"" ).append( key ).append( "\":");
106 | if (value instanceof Map, ?>) {
107 | temp.append(setJson((Map) value) ).append( ",");
108 | } else if (value instanceof List>) {
109 | temp.append(setList((List>) value)
110 | ).append( ",");
111 | } else {
112 | temp.append(value ).append( ",");
113 | }
114 | }
115 | if (temp.length() > 1) {
116 | temp = new StringBuffer(temp.substring(0, temp.length() - 1));
117 | }
118 | temp.append("}");
119 | json = new JSONObject(temp.toString());
120 | }
121 | return json;
122 | }
123 |
124 | /**
125 | * 将单个list转成json字符串
126 | *
127 | * @param list
128 | * @return
129 | * @throws Exception
130 | */
131 | private static String setList(List> list)
132 | throws Exception {
133 | String jsonL;
134 | StringBuffer temp = new StringBuffer();
135 | temp.append("[");
136 | for (int i = 0; i < list.size(); i++) {
137 | Map m = list.get(i);
138 | if (i == list.size() - 1) {
139 | temp.append(setJson(m));
140 | } else {
141 | temp.append(setJson(m) ).append( ",");
142 | }
143 | }
144 | if (temp.length() > 1) {
145 | temp = new StringBuffer(temp.substring(0, temp.length()));
146 | }
147 | temp.append("]");
148 | jsonL = temp.toString();
149 | return jsonL;
150 | }
151 |
152 | }
153 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/utils/L.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.utils;
2 |
3 | import android.util.Log;
4 |
5 | import com.jiang.android.push.BuildConfig;
6 |
7 | /**
8 | * Created by jiang on 2016/10/11.
9 | */
10 |
11 | public class L {
12 | private static final String TAG = "AndroidPush";
13 |
14 | public static final boolean debug = BuildConfig.DEBUG;
15 |
16 | public static void i(String msg) {
17 | //if (debug) {
18 | Log.i(TAG, msg);
19 | //}
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/utils/RomUtil.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.utils;
2 |
3 | import android.os.Build;
4 | import android.text.TextUtils;
5 | import android.util.Log;
6 |
7 | import java.io.BufferedReader;
8 | import java.io.IOException;
9 | import java.io.InputStreamReader;
10 |
11 | /**
12 | * Created by jiang on 2016/10/8.
13 | */
14 |
15 | public class RomUtil {
16 | private static Target mTarget = null;
17 |
18 | private static final String TAG = "RomUtil";
19 |
20 | public static final String ROM_MIUI = "MIUI";
21 | public static final String ROM_EMUI = "EMUI";
22 | public static final String ROM_FLYME = "FLYME";
23 | public static final String ROM_OPPO = "OPPO";
24 | public static final String ROM_SMARTISAN = "SMARTISAN";
25 |
26 | public static final String ROM_VIVO = "VIVO";
27 | public static final String ROM_QIKU = "QIKU";
28 |
29 | public static final String ROM_LENOVO = "LENOVO";
30 | public static final String ROM_SAMSUNG = "SAMSUNG";
31 |
32 | private static final String KEY_VERSION_MIUI = "ro.miui.ui.version.name";
33 | private static final String KEY_VERSION_EMUI = "ro.build.version.emui";
34 | private static final String KEY_VERSION_OPPO = "ro.build.version.opporom";
35 | private static final String KEY_VERSION_SMARTISAN = "ro.smartisan.version";
36 | private static final String KEY_VERSION_VIVO = "ro.vivo.os.version";
37 | private static final String KEY_VERSION_GIONEE = "ro.gn.sv.version";
38 | private static final String KEY_VERSION_LENOVO = "ro.lenovo.lvp.version";
39 | private static final String KEY_VERSION_FLYME = "ro.build.display.id";
40 |
41 |
42 | private static final String KEY_EMUI_VERSION_CODE = "ro.build.hw_emui_api_level";
43 |
44 | private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";
45 | private static final String KEY_MIUI_HANDY_MODE_SF = "ro.miui.has_handy_mode_sf";
46 | private static final String KEY_MIUI_REAL_BLUR = "ro.miui.has_real_blur";
47 |
48 | private static final String KEY_FLYME_PUBLISHED = "ro.flyme.published";
49 | private static final String KEY_FLYME_FLYME = "ro.meizu.setupwizard.flyme";
50 |
51 | private static final String KEY_FLYME_ICON_FALG = "persist.sys.use.flyme.icon";
52 | private static final String KEY_FLYME_SETUP_FALG = "ro.meizu.setupwizard.flyme";
53 | private static final String KEY_FLYME_PUBLISH_FALG = "ro.flyme.published";
54 |
55 | private static final String KEY_VIVO_OS_NAME = "ro.vivo.os.name";
56 | private static final String KEY_VIVO_OS_VERSION = "ro.vivo.os.version";
57 | private static final String KEY_VIVO_ROM_VERSION = "ro.vivo.rom.version";
58 |
59 | public static boolean isEMUI() {
60 | return check(ROM_EMUI);
61 | }
62 |
63 | public static boolean isMIUI() {
64 | return check(ROM_MIUI);
65 | }
66 |
67 | public static boolean isVivo() {
68 | return check(ROM_VIVO);
69 | }
70 |
71 | public static boolean isOppo() {
72 | return check(ROM_OPPO);
73 | }
74 |
75 | public static boolean isFlyme() {
76 | return check(ROM_FLYME);
77 | }
78 |
79 | public static boolean isQiku() {
80 | return check(ROM_QIKU) || check("360");
81 | }
82 |
83 | public static boolean isSmartisan() {
84 | return check(ROM_SMARTISAN);
85 | }
86 |
87 | private static String sName;
88 |
89 | public static String getName() {
90 | if (sName == null) {
91 | check("");
92 | }
93 | return sName;
94 | }
95 |
96 | private static String sVersion;
97 |
98 | public static String getVersion() {
99 | if (sVersion == null) {
100 | check("");
101 | }
102 | return sVersion;
103 | }
104 |
105 | public static boolean check(String rom) {
106 | if (sName != null) {
107 | return sName.equals(rom);
108 | }
109 |
110 | if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_MIUI))) {
111 | sName = ROM_MIUI;
112 | } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_EMUI))) {
113 | sName = ROM_EMUI;
114 | } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_OPPO))) {
115 | sName = ROM_OPPO;
116 | } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_VIVO))) {
117 | sName = ROM_VIVO;
118 | } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_SMARTISAN))) {
119 | sName = ROM_SMARTISAN;
120 | } else {
121 | sVersion = Build.DISPLAY;
122 | if (sVersion.toUpperCase().contains(ROM_FLYME)) {
123 | sName = ROM_FLYME;
124 | } else {
125 | sVersion = Build.UNKNOWN;
126 | sName = Build.MANUFACTURER.toUpperCase();
127 | }
128 | }
129 | return sName.equals(rom);
130 | }
131 |
132 | public static String getProp(String name) {
133 | String line = null;
134 | BufferedReader input = null;
135 | try {
136 | Process p = Runtime.getRuntime().exec("getprop " + name);
137 | input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
138 | line = input.readLine();
139 | input.close();
140 | } catch (IOException ex) {
141 | Log.e(TAG, "Unable to read prop " + name, ex);
142 | return null;
143 | } finally {
144 | if (input != null) {
145 | try {
146 | input.close();
147 | } catch (IOException e) {
148 | e.printStackTrace();
149 | }
150 | }
151 | }
152 | return line;
153 | }
154 |
155 |
156 | public static Target rom() {
157 | if (mTarget != null)
158 | return mTarget;
159 |
160 | if (isEMUI()) {
161 | mTarget = Target.EMUI;
162 | return mTarget;
163 | }
164 | if (isMIUI()) {
165 | mTarget = Target.MIUI;
166 | return mTarget;
167 | }
168 | if (isVivo()) {
169 | mTarget = Target.VIVO;
170 | return mTarget;
171 | }
172 | if (isOppo()) {
173 | mTarget = Target.OPPO;
174 | return mTarget;
175 | }
176 | mTarget = Target.JPUSH;
177 | return mTarget;
178 | }
179 |
180 | }
181 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/utils/Target.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.utils;
2 |
3 | /**
4 | * Created by jiang on 2016/10/8.
5 | */
6 |
7 | public enum Target {
8 | MIUI, EMUI, FLYME, VIVO, OPPO, JPUSH
9 | }
10 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/vivo/PushMessageReceiverImpl.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.vivo;
2 |
3 | import android.content.Context;
4 | import android.text.TextUtils;
5 | import android.util.Log;
6 |
7 | import com.jiang.android.push.Message;
8 | import com.jiang.android.push.PushInterface;
9 | import com.jiang.android.push.utils.JHandler;
10 | import com.jiang.android.push.utils.JsonUtils;
11 | import com.jiang.android.push.utils.Target;
12 | import com.vivo.push.model.UPSNotificationMessage;
13 | import com.vivo.push.sdk.OpenClientPushMessageReceiver;
14 |
15 | public class PushMessageReceiverImpl extends OpenClientPushMessageReceiver {
16 |
17 |
18 | private static PushInterface mPushInterface;
19 | private String mMessage;
20 |
21 | /**
22 | * @param pushInterface
23 | */
24 | public static void registerInterface(PushInterface pushInterface) {
25 |
26 | mPushInterface = pushInterface;
27 | }
28 |
29 | public static PushInterface getPushInterface() {
30 | return mPushInterface;
31 | }
32 |
33 |
34 | @Override
35 | public void onNotificationMessageClicked(final Context context, UPSNotificationMessage message) {
36 | mMessage = message.getContent();
37 |
38 | if (mPushInterface != null) {
39 | final Message result = new Message();
40 | result.setNotifyID(1);
41 | result.setMessageID(String.valueOf(message.getMsgId()));
42 | result.setTitle(message.getTitle());
43 | result.setMessage(mMessage);
44 | result.setTarget(Target.MIUI);
45 | try {
46 | result.setExtra(JsonUtils.setJson(message.getParams()).toString());
47 | } catch (Exception e) {
48 | Log.e(TAG, "onNotificationMessageClicked: " + e.toString());
49 | result.setExtra("{}");
50 | }
51 | JHandler.handler().post(new Runnable() {
52 | @Override
53 | public void run() {
54 | mPushInterface.onMessageClicked(context, result);
55 | }
56 | });
57 | }
58 | }
59 |
60 | @Override
61 | public void onReceiveRegId(Context context, String s) {
62 | if (mPushInterface != null) {
63 | Message message = new Message();
64 | message.setMessage(s);
65 | mPushInterface.onMessage(context, message);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/push/src/main/java/com/jiang/android/push/vivo/ViVOPushManager.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.push.vivo;
2 |
3 | import android.content.Context;
4 |
5 | import com.jiang.android.push.IPushManager;
6 | import com.jiang.android.push.PushInterface;
7 | import com.jiang.android.push.model.TokenModel;
8 | import com.jiang.android.push.utils.RomUtil;
9 | import com.vivo.push.IPushActionListener;
10 | import com.vivo.push.PushClient;
11 |
12 | public class ViVOPushManager implements IPushManager {
13 | @Override
14 | public void register(Context context, boolean debug, final PushInterface pushInterface) {
15 | // 在当前工程入口函数,建议在 Application 的 onCreate 函数中,添加以下代码:
16 | PushClient.getInstance(context).initialize();
17 | // 当需要打开推送服务时,调用以下代码:
18 | PushClient.getInstance(context).turnOnPush(new IPushActionListener() {
19 | @Override
20 | public void onStateChanged(int i) {
21 | if (i == 0 && pushInterface != null) {
22 | PushMessageReceiverImpl.registerInterface(pushInterface);
23 | }
24 |
25 | }
26 | });
27 | }
28 |
29 | @Override
30 | public void unregister(Context context) {
31 | PushClient.getInstance(context).turnOffPush(new IPushActionListener() {
32 | @Override
33 | public void onStateChanged(int i) {
34 | if (i == 0) {
35 | PushMessageReceiverImpl.registerInterface(null);
36 | }
37 |
38 | }
39 | });
40 |
41 | }
42 |
43 | @Override
44 | public void setPushInterface(PushInterface pushInterface) {
45 | PushMessageReceiverImpl.registerInterface(pushInterface);
46 |
47 | }
48 |
49 | @Override
50 | public void setAlias(Context context, String alias) {
51 | PushClient.getInstance(context).bindAlias(alias, new IPushActionListener() {
52 | @Override
53 | public void onStateChanged(int i) {
54 |
55 | }
56 | });
57 | }
58 |
59 | @Override
60 | public TokenModel getToken(Context context) {
61 | TokenModel result = new TokenModel();
62 | result.setTarget(RomUtil.rom());
63 | result.setToken(PushClient.getInstance(context).getRegId());
64 |
65 | return result;
66 | }
67 |
68 | @Override
69 | public void pause(Context context) {
70 |
71 | PushClient.getInstance(context).turnOffPush(new IPushActionListener() {
72 | @Override
73 | public void onStateChanged(int i) {
74 |
75 | }
76 | });
77 | if (PushMessageReceiverImpl.getPushInterface() != null) {
78 | PushMessageReceiverImpl.getPushInterface().onPaused(context);
79 | }
80 | }
81 |
82 | @Override
83 | public void resume(Context context) {
84 | register(context, false, null);
85 | if (PushMessageReceiverImpl.getPushInterface() != null) {
86 | PushMessageReceiverImpl.getPushInterface().onResume(context);
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/push/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-hdpi/pushnotify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-hdpi/pushnotify.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-hdpi/send.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-hdpi/send.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-hdpi/start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-hdpi/start.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-hdpi/upload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-hdpi/upload.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_ab_bottom_emui.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_ab_bottom_emui.9.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_background_emui.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_background_emui.9.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_btn_check_off_emui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_btn_check_off_emui.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_btn_check_off_pressed_emui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_btn_check_off_pressed_emui.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_btn_check_on_emui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_btn_check_on_emui.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_btn_check_on_pressed_emui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_btn_check_on_pressed_emui.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_ic_cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_ic_cancel.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_ic_cancel_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_ic_cancel_light.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_advance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_advance.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_back.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_collect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_collect.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_delete.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_multiple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_multiple.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_multiple1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_multiple1.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_ic_toolbar_refresh.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_list_activated_emui.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_list_activated_emui.9.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_list_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_list_icon.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_main_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_main_icon.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_no_collection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_no_collection.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_pic_ab_number.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_pic_ab_number.9.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_pic_ab_number_light.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_pic_ab_number_light.9.png
--------------------------------------------------------------------------------
/push/src/main/res/drawable-xhdpi/hwpush_progress.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiang111/AndroidPush/33b0e1728f1eb63a976e0a43d0aeb20061465ab7/push/src/main/res/drawable-xhdpi/hwpush_progress.9.png
--------------------------------------------------------------------------------
/push/src/main/res/layout/hwpush_buttons_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/push/src/main/res/layout/hwpush_collect_tip_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
26 |
27 |
37 |
38 |
39 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/push/src/main/res/layout/hwpush_collection_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
23 |
24 |
37 |
38 |
52 |
53 |
64 |
65 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/push/src/main/res/layout/hwpush_collection_listview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
22 |
23 |
24 |
30 |
31 |
40 |
41 |
51 |
52 |
53 |
61 |
62 |
71 |
72 |
82 |
83 |
84 |
85 |
94 |
95 |
106 |
107 |
116 |
117 |
125 |
126 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
151 |
152 |
161 |
162 |
171 |
177 |
192 |
193 |
194 |
--------------------------------------------------------------------------------
/push/src/main/res/layout/hwpush_icons_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/push/src/main/res/layout/hwpush_layout2.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
28 |
29 |
38 |
39 |
49 |
50 |
62 |
63 |
64 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/push/src/main/res/layout/hwpush_layout4.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
27 |
28 |
37 |
38 |
48 |
49 |
55 |
56 |
61 |
62 |
63 |
64 |
65 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/push/src/main/res/layout/hwpush_layout7.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
15 |
26 |
37 |
38 |
48 |
49 |
60 |
61 |
71 |
72 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/push/src/main/res/layout/hwpush_layout8.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
17 |
18 |
--------------------------------------------------------------------------------
/push/src/main/res/layout/hwpush_msg_show.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
22 |
23 |
24 |
30 |
31 |
39 |
40 |
50 |
51 |
52 |
53 |
61 |
69 |
70 |
80 |
81 |
82 |
83 |
91 |
99 |
100 |
110 |
111 |
112 |
113 |
121 |
122 |
130 |
131 |
141 |
142 |
143 |
144 |
153 |
154 |
164 |
165 |
166 |
174 |
175 |
184 |
194 |
195 |
196 |
--------------------------------------------------------------------------------
/push/src/main/res/values-zh-rCN/hwpush_strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | "推送服务"
4 | "后退"
5 | "前进"
6 | "刷新"
7 | "收藏"
8 | "删除通知"
9 | "通知收藏"
10 | 通知收藏
11 |
12 | "删除"
13 | "全选"
14 |
15 | "点击收藏后,将在桌面自动生成一个“通知收藏”的图标,以后可从桌面直接点击查看。"
16 | "知道了"
17 |
18 | "取消"
19 |
20 |
21 | - "是否删除所选通知?"
22 |
23 | "取消全选"
24 | "没有通知收藏"
25 | "富媒体"
26 | "正在加载,请稍候..."
27 | "收藏已达上限"
28 | "已收藏 1000 条通知信息,需要删除部分通知才能继续收藏,是否继续?"
29 | "继续"
30 | 存储消息
31 |
--------------------------------------------------------------------------------
/push/src/main/res/values/hwpush_colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ffffffff
4 | #ff000000
5 | #FF000000
6 | #80000000
7 | #65000000
8 | #2c9195
9 | #00bcd5
10 | #000000
11 |
12 |
--------------------------------------------------------------------------------
/push/src/main/res/values/hwpush_strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Back
5 | Forward
6 | Refresh
7 | Favorite
8 | Delete notifications
9 | Favorites
10 | Favorite notifications
11 |
12 | Delete
13 | Select all
14 |
15 | A Favorites icon will be created on the home screen. You can touch the icon to view all your favorite notifications.
16 | OK
17 |
18 | Cancel
19 |
20 |
21 | - Delete selected notification?
22 |
23 | - Delete selected notifications?
24 |
25 | Deselect all
26 | No favorite notifications
27 | Push Service
28 | Rich media
29 | Loading... Please wait.
30 | Note
31 | A maximum of 1000 favorite notifications can be saved. Delete some notifications before you can add new ones. Go to your favorite notifications list?
32 | Go
33 | Store messages
34 |
35 | successRateAnalytics
36 |
--------------------------------------------------------------------------------
/push/src/main/res/values/hwpush_styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
--------------------------------------------------------------------------------
/push/src/main/res/values/jpush_style.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
--------------------------------------------------------------------------------
/push/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PushDemo
5 | Settings
6 | Hello world!
7 |
8 |
9 | 姓名:
10 | 年龄:
11 | 位置信息上报周期(min):
12 | 设置标签
13 | 删除标签
14 | 位置上报
15 | 设置周期(秒)
16 | 开启位置定时上报
17 | 关闭位置定时上报
18 |
19 |
20 | 标签1:
21 | 标签2:
22 | 请输入标签名(空则不设置)
23 | 请输入标签值
24 | 请输入待删标签名
25 |
26 | 获取标签
27 |
28 |
--------------------------------------------------------------------------------
/push/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':push'
2 |
--------------------------------------------------------------------------------