diff --git a/lib_base/src/main/java/com/android/base/utils/android/views/TextViewEx.kt b/lib_base/src/main/java/com/android/base/utils/android/views/TextViewEx.kt
index dc7fbcc..67cbee1 100644
--- a/lib_base/src/main/java/com/android/base/utils/android/views/TextViewEx.kt
+++ b/lib_base/src/main/java/com/android/base/utils/android/views/TextViewEx.kt
@@ -1,10 +1,7 @@
package com.android.base.utils.android.views
import android.graphics.drawable.Drawable
-import android.text.Editable
-import android.text.InputFilter
-import android.text.Spanned
-import android.text.TextWatcher
+import android.text.*
import android.text.method.LinkMovementMethod
import android.widget.Button
import android.widget.EditText
@@ -142,6 +139,12 @@ fun TextView.enableSpanClickable() {
highlightColor = ContextCompat.getColor(context, android.R.color.transparent)
}
+fun EditText.disableEdit() {
+ isFocusable = false
+ isFocusableInTouchMode = false
+ inputType = InputType.TYPE_NULL
+}
+
fun EditText.disableEmojiEntering() {
val filter = EmojiExcludeFilter()
val oldFilters = filters
diff --git a/lib_base/src/main/java/com/android/base/widget/pulltozoom/PullToZoomScrollView.java b/lib_base/src/main/java/com/android/base/widget/pulltozoom/PullToZoomScrollView.java
index 7f50a42..995a473 100644
--- a/lib_base/src/main/java/com/android/base/widget/pulltozoom/PullToZoomScrollView.java
+++ b/lib_base/src/main/java/com/android/base/widget/pulltozoom/PullToZoomScrollView.java
@@ -13,6 +13,8 @@ import android.view.animation.DecelerateInterpolator;
import com.android.base.R;
+import timber.log.Timber;
+
/**
*
@@ -229,9 +231,13 @@ public class PullToZoomScrollView extends NestedScrollView {
mZoomView.setPivotY(mOriginContainerViewHeight / 3F);
float addOffset = (height - mOriginContainerViewHeight) * mZoomFactory / mOriginContainerViewHeight;
float scale = height * 1.0F / mOriginContainerViewHeight + addOffset;
+ Timber.d("scale = %f", scale);
if (!Float.isInfinite(scale)) {
mZoomView.setScaleX(scale);
mZoomView.setScaleY(scale);
+ } else {
+ mZoomView.setScaleX(1);
+ mZoomView.setScaleY(1);
}
}
diff --git a/lib_push/.gitignore b/lib_push/.gitignore
deleted file mode 100644
index c06fb85..0000000
--- a/lib_push/.gitignore
+++ /dev/null
@@ -1,22 +0,0 @@
-*.iml
-.gradle
-/local.properties
-/.idea
-.DS_Store
-/build
-/captures
-.externalNativeBuild
-*.iml
-.idea/
-.gradle
-/local.properties
-.DS_Store
-/build
-/captures
-*.apk
-*.ap_
-*.dex
-*.class
-bin/
-gen/
-local.properties
\ No newline at end of file
diff --git a/lib_push/README.md b/lib_push/README.md
deleted file mode 100644
index be8de78..0000000
--- a/lib_push/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# 推送库
-
-目前集成的是极光推送,不允许暴露具体的推送 SDK 的 API 到其他模块中,必须采用统一的封装。
\ No newline at end of file
diff --git a/lib_push/build.gradle b/lib_push/build.gradle
deleted file mode 100644
index 304c337..0000000
--- a/lib_push/build.gradle
+++ /dev/null
@@ -1,26 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion rootProject.compileSdkVersion
- buildToolsVersion rootProject.buildToolsVersion
-
- defaultConfig {
- minSdkVersion rootProject.minSdkVersion
- targetSdkVersion rootProject.targetSdkVersion
- versionCode 1
- versionName "1.0"
- }
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- compileOnly androidLibraries.androidAnnotations
- implementation 'cn.jiguang.sdk:jpush:3.1.6'
- implementation 'cn.jiguang.sdk:jcore:1.2.5'
- implementation thirdLibraries.timber
-}
diff --git a/lib_push/src/main/AndroidManifest.xml b/lib_push/src/main/AndroidManifest.xml
deleted file mode 100644
index 43f0d7b..0000000
--- a/lib_push/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lib_push/src/main/java/com/android/sdk/push/MessageHandler.java b/lib_push/src/main/java/com/android/sdk/push/MessageHandler.java
deleted file mode 100644
index bde64cc..0000000
--- a/lib_push/src/main/java/com/android/sdk/push/MessageHandler.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.android.sdk.push;
-
-/**
- * @author Ztiany
- * Email: 1169654504@qq.com
- * Date : 2017-03-09 11:31
- */
-public interface MessageHandler {
-
- /**
- * 处理透传消息
- *
- * @param pushMessage 消息
- */
- void onDirectMessageArrived(PushMessage pushMessage);
-
- /**
- * 通知栏消息被点击
- */
- void handleOnNotificationMessageClicked(PushMessage pushMessage);
-
- /**
- * 通知栏消息到达
- */
- void onNotificationMessageArrived(PushMessage pushMessage);
-
-}
diff --git a/lib_push/src/main/java/com/android/sdk/push/Push.java b/lib_push/src/main/java/com/android/sdk/push/Push.java
deleted file mode 100644
index 3ae56cb..0000000
--- a/lib_push/src/main/java/com/android/sdk/push/Push.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.android.sdk.push;
-
-import android.app.Activity;
-import android.support.annotation.NonNull;
-
-/**
- * @author Ztiany
- * Email: 1169654504@qq.com
- * Date : 2017-03-09 11:31
- */
-public interface Push {
-
- void registerPush(@NonNull final PushCallBack pushCallBack);
-
- void setAlias(String alias);
-
- void clearAlias();
-
- void setTag(String tag);
-
- void addTag(String tag);
-
- void deleteTag(String tag);
-
- void clearTag();
-
- void enablePush();
-
- void disablePush();
-
- void setMessageHandler(MessageHandler messageHandler);
-
- MessageHandler getMessageHandler();
-
- void onActivityCreate(Activity activity);
-
- void setChannel(String channel);
-
-}
diff --git a/lib_push/src/main/java/com/android/sdk/push/PushCallBack.java b/lib_push/src/main/java/com/android/sdk/push/PushCallBack.java
deleted file mode 100644
index be9836f..0000000
--- a/lib_push/src/main/java/com/android/sdk/push/PushCallBack.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.android.sdk.push;
-
-
-public interface PushCallBack {
- void onRegisterPushSuccess(String registrationID);
- void onRegisterPushFail();
-}
diff --git a/lib_push/src/main/java/com/android/sdk/push/PushContext.java b/lib_push/src/main/java/com/android/sdk/push/PushContext.java
deleted file mode 100644
index af9aa72..0000000
--- a/lib_push/src/main/java/com/android/sdk/push/PushContext.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.android.sdk.push;
-
-import android.app.Application;
-import android.text.TextUtils;
-
-import com.android.sdk.push.jpush.JPush;
-
-/**
- * @author Ztiany
- * Email: 1169654504@qq.com
- * Date : 2017-03-03 16:22
- */
-public class PushContext {
-
- private static Application mApplication;
- private static boolean isDebug;
- private static Push sPush;
-
- private static String APP_ID;
- private static String APP_KEY;
-
- public static void configPush(String appKey, String appId) {
- APP_KEY = appKey;
- APP_ID = appId;
- }
-
- public static boolean isPushConfigured() {
- return !TextUtils.isEmpty(APP_ID) && !TextUtils.isEmpty(APP_KEY);
- }
-
- public static void init(Application application, boolean debug) {
- isDebug = debug;
- mApplication = application;
- initPush();
- }
-
- private static void initPush() {
- sPush = new JPush(mApplication);
- }
-
- public static Push getPush() {
- return sPush;
- }
-
- public static boolean isDebug() {
- return isDebug;
- }
-
- public static Application getApplication() {
- return mApplication;
- }
-
-}
diff --git a/lib_push/src/main/java/com/android/sdk/push/PushMessage.java b/lib_push/src/main/java/com/android/sdk/push/PushMessage.java
deleted file mode 100644
index 3214be4..0000000
--- a/lib_push/src/main/java/com/android/sdk/push/PushMessage.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.android.sdk.push;
-
-
-import android.support.annotation.NonNull;
-
-public class PushMessage {
-
- private int messageId;
- private int notificationId;
- private String alertType;
- private String content;
- private String extra;
- private String title;
-
- public int getNotificationId() {
- return notificationId;
- }
-
- public void setNotificationId(int notificationId) {
- this.notificationId = notificationId;
- }
-
- public String getAlertType() {
- return alertType;
- }
-
- public void setAlertType(String alertType) {
- this.alertType = alertType;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getContent() {
- return content;
- }
-
- public void setContent(String content) {
- this.content = content;
- }
-
- public String getExtra() {
- return extra;
- }
-
- public void setExtra(String extra) {
- this.extra = extra;
- }
-
- public int getMessageId() {
- return messageId;
- }
-
- public void setMessageId(int messageId) {
- this.messageId = messageId;
- }
-
- @NonNull
- @Override
- public String toString() {
- return "PushMessage{" +
- "messageiId=" + messageId +
- ", notificationId=" + notificationId +
- ", alertType=" + alertType +
- ", content='" + content + '\'' +
- ", extra='" + extra + '\'' +
- ", title='" + title + '\'' +
- '}';
- }
-
-}
diff --git a/lib_push/src/main/java/com/android/sdk/push/Utils.java b/lib_push/src/main/java/com/android/sdk/push/Utils.java
deleted file mode 100644
index f5aa5ec..0000000
--- a/lib_push/src/main/java/com/android/sdk/push/Utils.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.android.sdk.push;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-
-/**
- * @author Ztiany
- * Email: ztiany3@gmail.com
- * Date : 2019-02-26 11:36
- */
-public class Utils {
-
- private static final String PUSH_SP_NAME = "push_sp_name";
-
- public static void savePushId(String key, String id) {
- SharedPreferences sharedPreferences = PushContext.getApplication().getSharedPreferences(PUSH_SP_NAME, Context.MODE_PRIVATE);
- sharedPreferences.edit().putString(key, id).apply();
- }
-
- public static String getPushId(String key) {
- SharedPreferences sharedPreferences = PushContext.getApplication().getSharedPreferences(PUSH_SP_NAME, Context.MODE_PRIVATE);
- return sharedPreferences.getString(key, "");
- }
-
-}
diff --git a/lib_push/src/main/java/com/android/sdk/push/exception/PushUnConfigException.java b/lib_push/src/main/java/com/android/sdk/push/exception/PushUnConfigException.java
deleted file mode 100644
index 8707836..0000000
--- a/lib_push/src/main/java/com/android/sdk/push/exception/PushUnConfigException.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.android.sdk.push.exception;
-
-/**
- * @author Ztiany
- * Email: 1169654504@qq.com
- * Date : 2017-05-18 12:00
- */
-public class PushUnConfigException extends RuntimeException {
-
- private static final String MESSAGE = "you have not deployed the %s id";
-
- public PushUnConfigException(String message) {
- super(String.format(MESSAGE, message));
- }
-
-}
diff --git a/lib_push/src/main/java/com/android/sdk/push/jpush/JPush.java b/lib_push/src/main/java/com/android/sdk/push/jpush/JPush.java
deleted file mode 100644
index 1cae4a4..0000000
--- a/lib_push/src/main/java/com/android/sdk/push/jpush/JPush.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package com.android.sdk.push.jpush;
-
-import android.app.Activity;
-import android.app.Application;
-import android.content.Context;
-import android.support.annotation.NonNull;
-import android.text.TextUtils;
-
-import com.android.sdk.push.MessageHandler;
-import com.android.sdk.push.Push;
-import com.android.sdk.push.PushCallBack;
-import com.android.sdk.push.PushContext;
-import com.android.sdk.push.Utils;
-
-import cn.jpush.android.api.JPushInterface;
-import timber.log.Timber;
-
-/**
- * @author Ztiany
- * Email: ztiany3@gmail.com
- * Date : 2019-01-26 17:44
- */
-public class JPush implements Push {
-
- private Context mContext;
- private MessageHandler mMessageHandler;
- private PushCallBack mPushCallBack;
-
- static final String JPUSH_ID_KET = "jpush_id_key";
-
- public JPush(Application mApplication) {
- mContext = mApplication.getApplicationContext();
- }
-
- @Override
- public void registerPush(@NonNull PushCallBack pushCallBack) {
- this.mPushCallBack = pushCallBack;
- //给 JPushReceiver 设置 JPush
- JPushReceiver.sJPush = this;
- // 设置开启日志,发布时请关闭日志
- JPushInterface.setDebugMode(PushContext.isDebug());
- // 初始化极光推送服务
- JPushInterface.init(mContext);
- String registrationID = getRegistrationID();
- Timber.d("jpush registrationID = " + registrationID);
- boolean isRegistrationSuccess = !TextUtils.isEmpty(registrationID);
- if (isRegistrationSuccess) {
- this.mPushCallBack.onRegisterPushSuccess(registrationID);
- }
- }
-
- private String getRegistrationID() {
- String registrationID = JPushInterface.getRegistrationID(mContext);
- if (TextUtils.isEmpty(registrationID)) {
- registrationID = Utils.getPushId(JPUSH_ID_KET);
- }
- return registrationID;
- }
-
- @Override
- public void setAlias(String alias) {
- JPushUtils.setAlias(mContext, alias);
- }
-
- @Override
- public void clearAlias() {
- JPushUtils.clearAlias(mContext);
- }
-
- @Override
- public void setTag(String tag) {
- JPushUtils.setTag(mContext, tag);
- }
-
- @Override
- public void addTag(String tag) {
- JPushUtils.deleteTag(mContext, tag);
- }
-
- @Override
- public void deleteTag(String tag) {
- JPushUtils.setTag(mContext, tag);
- }
-
- @Override
- public void clearTag() {
- JPushUtils.clearTags(mContext);
- }
-
- @Override
- public void enablePush() {
- JPushInterface.resumePush(mContext);
- }
-
- @Override
- public void disablePush() {
- JPushInterface.stopPush(mContext);
- }
-
- @Override
- public void setMessageHandler(MessageHandler messageHandler) {
- this.mMessageHandler = messageHandler;
- }
-
- @Override
- public MessageHandler getMessageHandler() {
- return mMessageHandler;
- }
-
- PushCallBack getPushCallBack() {
- return mPushCallBack;
- }
-
- @Override
- public void setChannel(String channel) {
- JPushInterface.setChannel(mContext, channel);
- }
-
- @Override
- public void onActivityCreate(Activity activity) {
- // no op
- }
-
-}
diff --git a/lib_push/src/main/java/com/android/sdk/push/jpush/JPushReceiver.java b/lib_push/src/main/java/com/android/sdk/push/jpush/JPushReceiver.java
deleted file mode 100644
index 65bc4cd..0000000
--- a/lib_push/src/main/java/com/android/sdk/push/jpush/JPushReceiver.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package com.android.sdk.push.jpush;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-
-import com.android.sdk.push.PushContext;
-import com.android.sdk.push.PushMessage;
-import com.android.sdk.push.Utils;
-
-import cn.jpush.android.api.JPushInterface;
-import timber.log.Timber;
-
-import static com.android.sdk.push.jpush.JPush.JPUSH_ID_KET;
-
-/**
- * 极光推送-消息接收广播
- *
- * @author Wangwb
- * Email: 253123123@qq.com
- * Date : 2019-01-28 11:21
- */
-public class JPushReceiver extends BroadcastReceiver {
-
- static JPush sJPush;
-
- @Override
- public void onReceive(Context context, Intent intent) {
- try {
- processMessage(intent);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void processMessage(Intent intent) {
- Bundle bundle = intent.getExtras();
-
- if (PushContext.isDebug()) {
- Timber.d("[JPushReceiver] onReceive - " + intent.getAction() + ", extras: " + JPushUtils.printBundle(bundle));
- }
-
- if (bundle == null) {
- return;
- }
-
- if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
-
- processRegisterSuccess(bundle);
-
- } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
-
- processMessageReceived(bundle);
-
- } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
-
- processNotificationMessageReceived(bundle);
-
- } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
-
- //目前没有配置这个 action,不会接收此类消息
- processNotificationMessageClicked(bundle);
-
- } else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
-
- Timber.w("[JPushReceiver]" + intent.getAction() + " connected state change to " + intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false));
-
- } else {
- Timber.d("[JPushReceiver] Unhandled intent - " + intent.getAction());
- }
-
- }
-
- private void processNotificationMessageClicked(Bundle bundle) {
- Timber.d("[JPushReceiver] 接收到推送下来的通知被点击了");
- PushMessage pushMessage = extractMessage(bundle);
- sJPush.getMessageHandler().handleOnNotificationMessageClicked(pushMessage);
- }
-
- // 在这里可以做些统计,或者做些其他工作
- private void processNotificationMessageReceived(Bundle bundle) {
- Timber.d("[JPushReceiver] 接收到推送下来的通知");
- PushMessage pushMessage = extractMessage(bundle);
- sJPush.getMessageHandler().onNotificationMessageArrived(pushMessage);
- }
-
- @NonNull
- private PushMessage extractMessage(Bundle bundle) {
- int notificationId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
- String alertType = bundle.getString(JPushInterface.EXTRA_ALERT_TYPE);
- String alert = bundle.getString(JPushInterface.EXTRA_ALERT);
- String title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);
- String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
-
- PushMessage pushMessage = new PushMessage();
- pushMessage.setTitle(title);
- pushMessage.setContent(alert);
- pushMessage.setExtra(extras);
- pushMessage.setNotificationId(notificationId);
- pushMessage.setAlertType(alertType);
- return pushMessage;
- }
-
- private void processRegisterSuccess(Bundle bundle) {
- String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
- Timber.d("[JPushReceiver] JPush 用户注册成功,接收Registration Id : " + regId);
- //you can send the Registration Id to your server...
- Utils.savePushId(JPUSH_ID_KET, regId);
- sJPush.getPushCallBack().onRegisterPushSuccess(regId);
- }
-
- // 自定义消息不会展示在通知栏,完全要开发者写代码去处理
- private void processMessageReceived(Bundle bundle) {
- Timber.d("[JPushReceiver] 接收到推送下来的透传消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
-
- String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
- String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
-
- PushMessage pushMessage = new PushMessage();
- pushMessage.setContent(message);
- pushMessage.setExtra(extras);
-
- sJPush.getMessageHandler().onDirectMessageArrived(pushMessage);
- }
-
-}
diff --git a/lib_push/src/main/java/com/android/sdk/push/jpush/JPushUtils.java b/lib_push/src/main/java/com/android/sdk/push/jpush/JPushUtils.java
deleted file mode 100644
index ba5974a..0000000
--- a/lib_push/src/main/java/com/android/sdk/push/jpush/JPushUtils.java
+++ /dev/null
@@ -1,195 +0,0 @@
-package com.android.sdk.push.jpush;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.text.TextUtils;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import cn.jpush.android.api.JPushInterface;
-import timber.log.Timber;
-
-import static com.android.sdk.push.jpush.TagAliasOperatorHelper.ACTION_ADD;
-import static com.android.sdk.push.jpush.TagAliasOperatorHelper.ACTION_CLEAN;
-import static com.android.sdk.push.jpush.TagAliasOperatorHelper.ACTION_DELETE;
-import static com.android.sdk.push.jpush.TagAliasOperatorHelper.ACTION_SET;
-
-/**
- * @author Wangwb
- * Email: 253123123@qq.com
- * Date : 2019-01-28 11:29
- */
-class JPushUtils {
-
- private static final String TAG = "JPushReceiver";
-
- /**
- * 打印 Bundle Extras
- */
- static String printBundle(Bundle bundle) {
- if (bundle == null) {
- return "null";
- }
-
- StringBuilder sb = new StringBuilder();
-
- for (String key : bundle.keySet()) {
- switch (key) {
- case JPushInterface.EXTRA_NOTIFICATION_ID:
- sb.append("\nkey:").append(key).append(", value:").append(bundle.getInt(key));
- break;
- case JPushInterface.EXTRA_CONNECTION_CHANGE:
- sb.append("\nkey:").append(key).append(", value:").append(bundle.getBoolean(key));
- break;
- case JPushInterface.EXTRA_EXTRA:
- if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
- Timber.i(TAG, "This message has no Extra data");
- continue;
- }
-
- try {
- JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
- Iterator it = json.keys();
-
- while (it.hasNext()) {
- String myKey = it.next();
- sb.append("\nkey:").append(key).append(", value: [").append(myKey).append(" - ").append(json.optString(myKey)).append("]");
- }
- } catch (JSONException e) {
- Timber.e(TAG, "Get message extra JSON error!");
- }
- break;
- default:
- sb.append("\nkey:").append(key).append(", value:").append(bundle.get(key));
- break;
- }
- }
- return sb.toString();
- }
-
- /**
- * 获取极光推送AppKey
- */
- @SuppressWarnings("unused")
- static String appKey(Context context) {
- Bundle metaData = null;
- String appKey = null;
- try {
- ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
- if (null != ai)
- metaData = ai.metaData;
- if (null != metaData) {
- appKey = metaData.getString("JPUSH_APPKEY");
- Timber.d("JPush AppKey: " + appKey + ", pkg: " + context.getPackageName());
- if ((null == appKey) || appKey.length() != 24) {
- appKey = null;
- }
- }
- } catch (PackageManager.NameNotFoundException e) {
- e.printStackTrace();
- }
- return appKey;
- }
-
- /**
- * 校验Tag Alias 只能是数字,英文字母和中文
- */
- @SuppressWarnings("all")
- private static boolean isValidTagAndAlias(String s) {
- Pattern p = Pattern.compile("^[\u4E00-\u9FA50-9a-zA-Z_!@#$&*+=.|]+$");
- Matcher m = p.matcher(s);
- return m.matches();
- }
-
- static boolean isConnected(Context context) {
- ConnectivityManager conn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- @SuppressLint("MissingPermission")
- NetworkInfo info = conn.getActiveNetworkInfo();
- return (info == null || !info.isConnected());
- }
-
- /**
- * 获取设备ID
- */
- @SuppressWarnings("unused")
- static String getDeviceId(Context context) {
- return JPushInterface.getUdid(context);
- }
-
- static void setTag(Context context, String tag) {
- if (!JPushUtils.isValidTagAndAlias(tag)) {
- Timber.e("Tag Alias 命名不符合规范");
- return;
- }
-
- TagAliasOperatorHelper.TagAliasBean tagAliasBean = createTagAliasBean(tag);
- tagAliasBean.action = ACTION_SET;
-
- TagAliasOperatorHelper.getInstance().handleAction(context, ++TagAliasOperatorHelper.sequence, tagAliasBean);
- }
-
- static void deleteTag(Context context, String tag) {
- if (!JPushUtils.isValidTagAndAlias(tag)) {
- Timber.e("Tag Alias 命名不符合规范");
- return;
- }
-
- TagAliasOperatorHelper.TagAliasBean tagAliasBean = createTagAliasBean(tag);
- tagAliasBean.action = ACTION_DELETE;
-
- TagAliasOperatorHelper.getInstance().handleAction(context, ++TagAliasOperatorHelper.sequence, tagAliasBean);
- }
-
- static void clearTags(Context context) {
- TagAliasOperatorHelper.TagAliasBean tagAliasBean = createTagAliasBean(null);
- tagAliasBean.action = ACTION_CLEAN;
-
- TagAliasOperatorHelper.getInstance().handleAction(context, ++TagAliasOperatorHelper.sequence, tagAliasBean);
- }
-
- @NonNull
- private static TagAliasOperatorHelper.TagAliasBean createTagAliasBean(String tag) {
- TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
- tagAliasBean.isAliasAction = false;
-
- if (!TextUtils.isEmpty(tag)) {
- LinkedHashSet tags = new LinkedHashSet<>();
- tags.add(tag);
- tagAliasBean.tags = tags;
- }
-
- return tagAliasBean;
- }
-
- static void setAlias(Context context, String alias) {
- TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
-
- tagAliasBean.action = ACTION_ADD;
- tagAliasBean.isAliasAction = true;
- tagAliasBean.alias = alias;
-
- TagAliasOperatorHelper.getInstance().handleAction(context, ++TagAliasOperatorHelper.sequence, tagAliasBean);
- }
-
- static void clearAlias(Context context) {
- TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
-
- tagAliasBean.action = ACTION_DELETE;
- tagAliasBean.isAliasAction = true;
-
- TagAliasOperatorHelper.getInstance().handleAction(context, ++TagAliasOperatorHelper.sequence, tagAliasBean);
- }
-
-}
\ No newline at end of file
diff --git a/lib_push/src/main/java/com/android/sdk/push/jpush/TagAliasJPushMessageReceiver.java b/lib_push/src/main/java/com/android/sdk/push/jpush/TagAliasJPushMessageReceiver.java
deleted file mode 100644
index 92b8ea1..0000000
--- a/lib_push/src/main/java/com/android/sdk/push/jpush/TagAliasJPushMessageReceiver.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.android.sdk.push.jpush;
-
-import android.content.Context;
-
-import cn.jpush.android.api.JPushMessage;
-import cn.jpush.android.service.JPushMessageReceiver;
-
-/**
- * 自定义 JPush message 接收器,包括操作 tag/alias 的结果返回(仅仅包含 tag/alias 新接口部分)
- */
-public class TagAliasJPushMessageReceiver extends JPushMessageReceiver {
-
- @Override
- public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
- TagAliasOperatorHelper.getInstance().onTagOperatorResult(context, jPushMessage);
- super.onTagOperatorResult(context, jPushMessage);
- }
-
- @Override
- public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage) {
- TagAliasOperatorHelper.getInstance().onCheckTagOperatorResult(context, jPushMessage);
- super.onCheckTagOperatorResult(context, jPushMessage);
- }
-
- @Override
- public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
- TagAliasOperatorHelper.getInstance().onAliasOperatorResult(context, jPushMessage);
- super.onAliasOperatorResult(context, jPushMessage);
- }
-
- @Override
- public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
- TagAliasOperatorHelper.getInstance().onMobileNumberOperatorResult(context, jPushMessage);
- super.onMobileNumberOperatorResult(context, jPushMessage);
- }
-
-}
diff --git a/lib_push/src/main/java/com/android/sdk/push/jpush/TagAliasOperatorHelper.java b/lib_push/src/main/java/com/android/sdk/push/jpush/TagAliasOperatorHelper.java
deleted file mode 100644
index 9927ca3..0000000
--- a/lib_push/src/main/java/com/android/sdk/push/jpush/TagAliasOperatorHelper.java
+++ /dev/null
@@ -1,412 +0,0 @@
-package com.android.sdk.push.jpush;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.os.Handler;
-import android.os.Message;
-import android.support.annotation.NonNull;
-import android.util.SparseArray;
-
-import java.util.Locale;
-import java.util.Objects;
-import java.util.Set;
-
-import cn.jpush.android.api.JPushInterface;
-import cn.jpush.android.api.JPushMessage;
-import timber.log.Timber;
-
-/**
- * 处理 tag alias 相关的逻辑
- */
-class TagAliasOperatorHelper {
-
- private static final String TAG = "JIGUANG-TagAliasHelper";
-
- static int sequence = 1;
-
- /**
- * 增加
- */
- static final int ACTION_ADD = 1;
- /**
- * 覆盖
- */
- static final int ACTION_SET = 2;
- /**
- * 删除部分
- */
- static final int ACTION_DELETE = 3;
- /**
- * 删除所有
- */
- static final int ACTION_CLEAN = 4;
- /**
- * 查询
- */
- static final int ACTION_GET = 5;
- /**
- * 检查
- */
- static final int ACTION_CHECK = 6;
-
- private static final int DELAY_SEND_ACTION = 1;
-
- private static final int DELAY_SET_MOBILE_NUMBER_ACTION = 2;
-
- private Context context;
-
- @SuppressLint("StaticFieldLeak")
- private static TagAliasOperatorHelper mInstance;
-
- private TagAliasOperatorHelper() {
- }
-
- public static TagAliasOperatorHelper getInstance() {
- if (mInstance == null) {
- synchronized (TagAliasOperatorHelper.class) {
- if (mInstance == null) {
- mInstance = new TagAliasOperatorHelper();
- }
- }
- }
- return mInstance;
- }
-
- public void init(Context context) {
- if (context != null) {
- this.context = context.getApplicationContext();
- }
- }
-
- private SparseArray