Przeglądaj źródła

Merge branch 'master' of http://192.168.3.207:10080/qmx/jyapp

apple 6 lat temu
rodzic
commit
d7395b9c04

+ 9 - 3
android/app/build.gradle

@@ -7,17 +7,23 @@ android {
         minSdkVersion 19
         targetSdkVersion 26
         versionCode 1
-        versionName "1.0.4"
+        versionName "1.0.6"
         flavorDimensions "different"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
     buildTypes {
         release {
-            minifyEnabled false
+            buildConfigField "boolean", "LOG_DEBUG", "false" //不显示log
+            zipAlignEnabled true     //Zipalign优化
+            shrinkResources true    // 移除无用的resource文件
+            minifyEnabled true     //混淆
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
         debug {
-            minifyEnabled false
+            buildConfigField "boolean", "LOG_DEBUG", "false" //不显示log
+            zipAlignEnabled true     //Zipalign优化
+            shrinkResources true    // 移除无用的resource文件
+            minifyEnabled true     //混淆
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
     }

+ 283 - 18
android/app/proguard-rules.pro

@@ -1,21 +1,286 @@
-# Add project specific ProGuard rules here.
-# You can control the set of applied configuration files using the
-# proguardFiles setting in build.gradle.
-#
-# For more details, see
-#   http://developer.android.com/guide/developing/tools/proguard.html
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-#   public *;
+# 指定代码的压缩级别 0 - 7(指定代码进行迭代优化的次数,在Android里面默认是5,这条指令也只有在可以优化时起作用。)
+-optimizationpasses 5
+# 混淆时不会产生形形色色的类名(混淆时不使用大小写混合类名)
+-dontusemixedcaseclassnames
+# 指定不去忽略非公共的库类(不跳过library中的非public的类)
+-dontskipnonpubliclibraryclasses
+# 指定不去忽略包可见的库类的成员
+-dontskipnonpubliclibraryclassmembers
+#不进行优化,建议使用此选项,
+-dontoptimize
+ # 不进行预校验,Android不需要,可加快混淆速度。
+-dontpreverify
+# 屏蔽警告
+-ignorewarnings
+# 指定混淆是采用的算法,后面的参数是一个过滤器
+# 这个过滤器是谷歌推荐的算法,一般不做更改
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+# 保护代码中的Annotation不被混淆
+-keepattributes *Annotation*
+# 避免混淆泛型, 这在JSON实体映射时非常重要
+-keepattributes Signature
+# 抛出异常时保留代码行号
+-keepattributes SourceFile,LineNumberTable
+ #优化时允许访问并修改有修饰符的类和类的成员,这可以提高优化步骤的结果。
+# 比如,当内联一个公共的getter方法时,这也可能需要外地公共访问。
+# 虽然java二进制规范不需要这个,要不然有的虚拟机处理这些代码会有问题。当有优化和使用-repackageclasses时才适用。
+#指示语:不能用这个指令处理库中的代码,因为有的类和类成员没有设计成public ,而在api中可能变成public
+-allowaccessmodification
+#当有优化和使用-repackageclasses时才适用。
+-repackageclasses ''
+ # 混淆时记录日志(打印混淆的详细信息)
+ # 这句话能够使我们的项目混淆后产生映射文件
+ # 包含有类名->混淆后类名的映射关系
+-verbose
+
+#
+# ----------------------------- 默认保留 -----------------------------
+#
+#----------------------------------------------------
+# 保持哪些类不被混淆
+#继承activity,application,service,broadcastReceiver,contentprovider....不进行混淆
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.support.multidex.MultiDexApplication
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class * extends android.view.View
+-keep class android.support.** {*;}## 保留support下的所有类及其内部类
+
+-keep public class com.google.vending.licensing.ILicensingService
+-keep public class com.android.vending.licensing.ILicensingService
+#表示不混淆上面声明的类,最后这两个类我们基本也用不上,是接入Google原生的一些服务时使用的。
+#----------------------------------------------------
+
+# 保留继承的
+-keep public class * extends android.support.v4.**
+-keep public class * extends android.support.v7.**
+-keep public class * extends android.support.annotation.**
+
+
+#表示不混淆任何包含native方法的类的类名以及native方法名,这个和我们刚才验证的结果是一致
+-keepclasseswithmembernames class * {
+    native <methods>;
+}
+
+
+#这个主要是在layout 中写的onclick方法android:onclick="onClick",不进行混淆
+#表示不混淆Activity中参数是View的方法,因为有这样一种用法,在XML中配置android:onClick=”buttonClick”属性,
+#当用户点击该按钮时就会调用Activity中的buttonClick(View view)方法,如果这个方法被混淆的话就找不到了
+-keepclassmembers class * extends android.app.Activity{
+    public void *(android.view.View);
+}
+
+#表示不混淆枚举中的values()和valueOf()方法,枚举我用的非常少,这个就不评论了
+-keepclassmembers enum * {
+    public static **[] values();
+    public static ** valueOf(java.lang.String);
+}
+
+#表示不混淆任何一个View中的setXxx()和getXxx()方法,
+#因为属性动画需要有相应的setter和getter的方法实现,混淆了就无法工作了。
+-keep public class * extends android.view.View{
+    *** get*();
+    void set*(***);
+    public <init>(android.content.Context);
+    public <init>(android.content.Context, android.util.AttributeSet);
+    public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+-keepclasseswithmembers class * {
+    public <init>(android.content.Context, android.util.AttributeSet);
+    public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+#表示不混淆Parcelable实现类中的CREATOR字段,
+#毫无疑问,CREATOR字段是绝对不能改变的,包括大小写都不能变,不然整个Parcelable工作机制都会失败。
+-keep class * implements android.os.Parcelable {
+  public static final android.os.Parcelable$Creator *;
+}
+# 这指定了继承Serizalizable的类的如下成员不被移除混淆
+-keepclassmembers class * implements java.io.Serializable {
+    static final long serialVersionUID;
+    private static final java.io.ObjectStreamField[] serialPersistentFields;
+    private void writeObject(java.io.ObjectOutputStream);
+    private void readObject(java.io.ObjectInputStream);
+    java.lang.Object writeReplace();
+    java.lang.Object readResolve();
+}
+# 保留R下面的资源
+#-keep class **.R$* {
+# *;
 #}
+#不混淆资源类下static的
+-keepclassmembers class **.R$* {
+    public static <fields>;
+}
+
+# 对于带有回调函数的onXXEvent、**On*Listener的,不能被混淆
+-keepclassmembers class * {
+    void *(**On*Event);
+    void *(**On*Listener);
+}
+
+# 保留我们自定义控件(继承自View)不被混淆
+-keep public class * extends android.view.View{
+    *** get*();
+    void set*(***);
+    public <init>(android.content.Context);
+    public <init>(android.content.Context, android.util.AttributeSet);
+    public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+#
+#----------------------------- WebView(项目中没有可以忽略) -----------------------------
+#
+#webView需要进行特殊处理
+-keepclassmembers class fqcn.of.javascript.interface.for.Webview {
+   public *;
+}
+-keepclassmembers class * extends android.webkit.WebViewClient {
+    public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
+    public boolean *(android.webkit.WebView, java.lang.String);
+}
+-keepclassmembers class * extends android.webkit.WebViewClient {
+    public void *(android.webkit.WebView, jav.lang.String);
+}
+#在app中与HTML5的JavaScript的交互进行特殊处理
+#我们需要确保这些js要调用的原生方法不能够被混淆,于是我们需要做如下处理:
+-keepclassmembers class com.ljd.example.JSInterface {
+    <methods>;
+}
+
+#
+#---------------------------------实体类---------------------------------
+#--------(实体Model不能混淆,否则找不到对应的属性获取不到值)-----
+#
+-dontwarn com.suchengkeji.android.confusiondemo.md.**
+#对含有反射类的处理
+-keep class com.suchengkeji.android.confusiondemo.md.** { *; }
+#
+# ----------------------------- 其他的 -----------------------------
+#
+# 删除代码中Log相关的代码
+-assumenosideeffects class android.util.Log {
+    public static boolean isLoggable(java.lang.String, int);
+    public static int v(...);
+    public static int i(...);
+    public static int w(...);
+    public static int d(...);
+    public static int e(...);
+}
+
+# 保持测试相关的代码
+-dontnote junit.framework.**
+-dontnote junit.runner.**
+-dontwarn android.test.**
+-dontwarn android.support.test.**
+-dontwarn org.junit.**
+
+#===========================================
+#==================三方sdk==================
+#okhttputils
+-dontwarn com.zhy.http.**
+-keep class com.zhy.http.**{*;}
+#okhttp
+-dontwarn okhttp3.**
+-keep class okhttp3.**{*;}
+#okio
+-dontwarn okio.**
+-keep class okio.**{*;}
+
+#jpush
+-dontoptimize
+-dontpreverify
 
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
+-dontwarn cn.jpush.**
+-keep class cn.jpush.** { *; }
+-keep class * extends cn.jpush.android.helpers.JPushMessageReceiver { *; }
 
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
+-dontwarn cn.jiguang.**
+-keep class cn.jiguang.** { *; }
+#友盟
+-dontshrink
+-dontoptimize
+-dontwarn com.google.android.maps.**
+-dontwarn android.webkit.WebView
+-dontwarn com.umeng.**
+-dontwarn com.tencent.weibo.sdk.**
+-dontwarn com.facebook.**
+-keep public class javax.**
+-keep public class android.webkit.**
+-dontwarn android.support.v4.**
+-keep enum com.facebook.**
+-keepattributes Exceptions,InnerClasses,Signature
+-keepattributes *Annotation*
+-keepattributes SourceFile,LineNumberTable
+-keep public interface com.facebook.**
+-keep public interface com.tencent.**
+-keep public interface com.umeng.socialize.**
+-keep public interface com.umeng.socialize.sensor.**
+-keep public interface com.umeng.scrshot.**
+-keep public class com.umeng.socialize.* {*;}
+-keep class com.facebook.**
+-keep class com.facebook.** { *; }
+-keep class com.umeng.scrshot.**
+-keep public class com.tencent.** {*;}
+-keep class com.umeng.socialize.sensor.**
+-keep class com.umeng.socialize.handler.**
+-keep class com.umeng.socialize.handler.*
+-keep class com.umeng.weixin.handler.**
+-keep class com.umeng.weixin.handler.*
+-keep class com.umeng.qq.handler.**
+-keep class com.umeng.qq.handler.*
+-keep class UMMoreHandler{*;}
+-keep class com.tencent.mm.sdk.modelmsg.WXMediaMessage {*;}
+-keep class com.tencent.mm.sdk.modelmsg.** implements com.tencent.mm.sdk.modelmsg.WXMediaMessage$IMediaObject {*;}
+-keep class im.yixin.sdk.api.YXMessage {*;}
+-keep class im.yixin.sdk.api.** implements im.yixin.sdk.api.YXMessage$YXMessageData{*;}
+-keep class com.tencent.mm.sdk.** {
+   *;
+}
+-keep class com.tencent.mm.opensdk.** {
+   *;
+}
+-keep class com.tencent.wxop.** {
+   *;
+}
+-keep class com.tencent.mm.sdk.** {
+   *;
+}
+-dontwarn twitter4j.**
+-keep class twitter4j.** { *; }
+-keep class com.tencent.** {*;}
+-dontwarn com.tencent.**
+-keep class com.kakao.** {*;}
+-dontwarn com.kakao.**
+-keep public class com.umeng.com.umeng.soexample.R$*{
+    public static final int *;
+}
+-keep public class com.linkedin.android.mobilesdk.R$*{
+    public static final int *;
+}
+-keepclassmembers enum * {
+    public static **[] values();
+    public static ** valueOf(java.lang.String);
+}
+-keep class com.tencent.open.TDialog$*
+-keep class com.tencent.open.TDialog$* {*;}
+-keep class com.tencent.open.PKDialog
+-keep class com.tencent.open.PKDialog {*;}
+-keep class com.tencent.open.PKDialog$*
+-keep class com.tencent.open.PKDialog$* {*;}
+-keep class com.umeng.socialize.impl.ImageImpl {*;}
+-keep class com.sina.** {*;}
+-dontwarn com.sina.**
+-keep class  com.alipay.share.sdk.** {
+   *;
+}
+-keepnames class * implements android.os.Parcelable {
+    public static final ** CREATOR;
+}
+-keep class com.linkedin.** { *; }
+-keep class com.android.dingtalk.share.ddsharemodule.** { *; }
+-keepattributes Signature

+ 4 - 1
android/app/src/main/AndroidManifest.xml

@@ -43,6 +43,7 @@
         </provider>
         <activity
             android:name=".WelcomePage"
+            android:screenOrientation="portrait"
             android:label="@string/app_name">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -61,8 +62,10 @@
             android:name=".MainActivity"
             android:label="@string/title_activity_main"
             android:windowSoftInputMode="adjustResize"
+            android:screenOrientation="portrait"
             android:launchMode="singleTask"></activity>
-        <activity android:name=".ExternalWebPage"></activity>
+        <activity android:name=".ExternalWebPage"
+            android:screenOrientation="portrait"></activity>
 
         <!--分享qq的Activity-->
         <activity

+ 26 - 2
android/app/src/main/java/com/topsoft/jianyu/JyObj.java

@@ -8,6 +8,7 @@ import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Build;
 import android.support.v4.app.ActivityCompat;
+import android.util.Log;
 import android.webkit.JavascriptInterface;
 import android.webkit.WebView;
 
@@ -17,7 +18,8 @@ import com.topsoft.jianyu.listener.CustomLoginListerner;
 import com.topsoft.jianyu.listener.CustomRemoveLoginListerner;
 import com.topsoft.jianyu.listener.CustomShareListener;
 import com.topsoft.jianyu.util.AppUtil;
-import com.topsoft.jianyu.util.StatisticsUtil;
+import com.topsoft.jianyu.util.HttpUtil;
+import com.topsoft.jianyu.util.StringUtil;
 import com.umeng.socialize.ShareAction;
 import com.umeng.socialize.UMShareAPI;
 import com.umeng.socialize.UMShareListener;
@@ -28,6 +30,9 @@ import com.umeng.socialize.media.UMWeb;
 import org.json.JSONArray;
 
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
 import cn.jpush.android.api.JPushInterface;
 
 import static android.content.Context.MODE_PRIVATE;
@@ -219,7 +224,7 @@ public class JyObj {
     //用户点击活动页面
     @JavascriptInterface
     public void openActivityPage(String url,String rectype,String openid){
-        StatisticsUtil.SendStatistics(url,openid,rectype);
+        HttpUtil.SendStatistics(url,openid,rectype);
     }
 
     //用户
@@ -227,4 +232,23 @@ public class JyObj {
     public void changeMessageType(String url){
         DbBase.getInstance(mContext).changeMessageTypeByUrl(url);
     }
+
+    //发送验证码请求
+    @JavascriptInterface
+    public String getCipherText(String phoneNumber){
+        String result="";
+        if("".equals(phoneNumber)||phoneNumber==null){
+            return result;
+        }
+        //获取秘钥
+        SimpleDateFormat sf=new SimpleDateFormat("yyyyMMddHHmmss");
+        String data=sf.format(new Date());
+        String sign=StringUtil.getMD5(phoneNumber+"&"+data);
+        try{
+            result=StringUtil.AESdecode(phoneNumber+"_"+data+"_"+sign);
+        }catch (Exception e){
+            Log.e("sendIdentCode: ",e.getMessage() );
+        }
+        return result;
+    }
 }

+ 4 - 7
android/app/src/main/java/com/topsoft/jianyu/MyReceiver.java

@@ -3,17 +3,14 @@ package com.topsoft.jianyu;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
-import android.content.SharedPreferences;
 import android.os.Bundle;
-import android.os.Handler;
 import android.os.Message;
-import android.provider.Settings;
 import android.text.TextUtils;
 import android.util.Log;
 
 import com.topsoft.jianyu.SQLite.DbBase;
 import com.topsoft.jianyu.SQLite.JyMessage;
-import com.topsoft.jianyu.util.StatisticsUtil;
+import com.topsoft.jianyu.util.HttpUtil;
 
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -72,7 +69,7 @@ public class MyReceiver extends BroadcastReceiver {
 					}
 					//向后台发送统计-收到信息
 					if("message".equals(type)){
-						StatisticsUtil.SendStatistics(url,openid,"D");
+						HttpUtil.SendStatistics(url,openid,"D");
 					}
 				}
 			} catch (Exception e){
@@ -130,8 +127,8 @@ public class MyReceiver extends BroadcastReceiver {
 				//向后台发送统计-点击消息
 				if("message".equals(type)){
 					if(!"".equals(url)){
-						StatisticsUtil.SendStatistics(url,openid,"C");
-						//StatisticsUtil.SendStatistics(url,openid,"C");
+						HttpUtil.SendStatistics(url,openid,"C");
+						//HttpUtil.SendStatistics(url,openid,"C");
 						//改变  message  ==》 message_r
 						DbBase.getInstance(context).changeMessageTypeByUrl(url);
 					}

+ 5 - 2
android/app/src/main/java/com/topsoft/jianyu/WelcomePage.java

@@ -10,7 +10,7 @@ import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
 import android.support.v4.app.ActivityCompat;
 import android.support.v7.app.AppCompatActivity;
-import android.widget.Toast;
+
 
 import com.topsoft.jianyu.util.AppUtil;
 import com.umeng.analytics.MobclickAgent;
@@ -27,7 +27,10 @@ import java.util.List;
 
 public class WelcomePage extends AppCompatActivity {
 
-    private String[] permissions = new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.READ_EXTERNAL_STORAGE};
+    private String[] permissions = new String[]{
+            android.Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.READ_EXTERNAL_STORAGE,
+            android.Manifest.permission.ACCESS_COARSE_LOCATION,android.Manifest.permission.ACCESS_FINE_LOCATION
+    };
     List<String> mPermissionList = new ArrayList<>();
 
     @Override

+ 4 - 2
android/app/src/main/java/com/topsoft/jianyu/listener/CustomShareListener.java

@@ -42,6 +42,7 @@ public  class CustomShareListener implements UMShareListener {
             LoadingUtils.closeDialog(dialog);
         }
         //分享成功
+        /*
         Message message = Message.obtain();
         message.what = 1201;
         Bundle b= new Bundle();
@@ -60,7 +61,7 @@ public  class CustomShareListener implements UMShareListener {
         b.putString("type", type);
         b.putString("flag","1");
         message.setData(b);
-        MainActivity.mainHandler.sendMessage(message);
+        MainActivity.mainHandler.sendMessage(message);*/
     }
 
     @Override
@@ -85,6 +86,7 @@ public  class CustomShareListener implements UMShareListener {
             LoadingUtils.closeDialog(dialog);
         }
         //取消分享
+        /*
         Message message = Message.obtain();
         message.what = 1201;
         Bundle b= new Bundle();
@@ -103,7 +105,7 @@ public  class CustomShareListener implements UMShareListener {
         b.putString("type", type);
         b.putString("flag","0");
         message.setData(b);
-        MainActivity.mainHandler.sendMessage(message);
+        MainActivity.mainHandler.sendMessage(message);*/
     }
 }
 

+ 5 - 2
android/app/src/main/java/com/topsoft/jianyu/util/AppUtil.java

@@ -30,9 +30,12 @@ public class AppUtil {
 
     //public static String AppUrl="http://webwcj.qmx.top";
     //public static String AppUrl="http://w2blmjy.qmx.top";
-    public static String AppUrl="https://www.jianyu360.com";
-    //public static String AppUrl="http://webws.qmx.top";
+    //public static String AppUrl="https://www.jianyu360.com";
+    //public static String AppUrl="http://weblxl.qmx.top";
+    public static String AppUrl="http://webws.qmx.top";
 
+    //加密偏移量字段(aes分开存放)
+    public static String ivParameter = "1389461544135476";
 
     /**
      * 判断当前应用是否是debug状态

+ 71 - 0
android/app/src/main/java/com/topsoft/jianyu/util/Base64Encoder.java

@@ -0,0 +1,71 @@
+package com.topsoft.jianyu.util;
+
+public class Base64Encoder {
+    private static final char last2byte = (char) Integer
+            .parseInt("00000011", 2);
+    private static final char last4byte = (char) Integer
+            .parseInt("00001111", 2);
+    private static final char last6byte = (char) Integer
+            .parseInt("00111111", 2);
+    private static final char lead6byte = (char) Integer
+            .parseInt("11111100", 2);
+    private static final char lead4byte = (char) Integer
+            .parseInt("11110000", 2);
+    private static final char lead2byte = (char) Integer
+            .parseInt("11000000", 2);
+    private static final char[] encodeTable = new char[] { 'A', 'B', 'C', 'D',
+            'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
+            'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
+            'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
+            'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
+            '4', '5', '6', '7', '8', '9', '+', '/' };
+
+    /**
+     * Base64 encoding.
+     *
+     * @param from
+     *            The src data.
+     * @return
+     */
+    public static String encode(byte[] from) {
+        StringBuffer to = new StringBuffer((int) (from.length * 1.34) + 3);
+        int num = 0;
+        char currentByte = 0;
+        for (int i = 0; i < from.length; i++) {
+            num = num % 8;
+            while (num < 8) {
+                switch (num) {
+                    case 0:
+                        currentByte = (char) (from[i] & lead6byte);
+                        currentByte = (char) (currentByte >>> 2);
+                        break;
+                    case 2:
+                        currentByte = (char) (from[i] & last6byte);
+                        break;
+                    case 4:
+                        currentByte = (char) (from[i] & last4byte);
+                        currentByte = (char) (currentByte << 2);
+                        if ((i + 1) < from.length) {
+                            currentByte |= (from[i + 1] & lead2byte) >>> 6;
+                        }
+                        break;
+                    case 6:
+                        currentByte = (char) (from[i] & last2byte);
+                        currentByte = (char) (currentByte << 4);
+                        if ((i + 1) < from.length) {
+                            currentByte |= (from[i + 1] & lead4byte) >>> 4;
+                        }
+                        break;
+                }
+                to.append(encodeTable[currentByte]);
+                num += 6;
+            }
+        }
+        if (to.length() % 4 != 0) {
+            for (int i = 4 - to.length() % 4; i > 0; i--) {
+                to.append("=");
+            }
+        }
+        return to.toString();
+    }
+}

+ 14 - 1
android/app/src/main/java/com/topsoft/jianyu/util/StatisticsUtil.java → android/app/src/main/java/com/topsoft/jianyu/util/HttpUtil.java

@@ -11,10 +11,11 @@ import java.io.IOException;
  * 用于统计用户点击活动
  */
 
-public class StatisticsUtil {
+public class HttpUtil {
 
     static String TAG="Statistics";
     private final static String StatisticsUrl=AppUtil.AppUrl+"/jyapp/free/message/receive";
+    private final static String SendMsgActioon=AppUtil.AppUrl+"";
 
     public static void SendStatistics(final String url,final String openid,final String rectype){
         new Thread(new Runnable(){
@@ -29,4 +30,16 @@ public class StatisticsUtil {
             }
         }).start();
     }
+    public static void SendSMsg(final String secret,final String phone){
+        new Thread(new Runnable(){
+            @Override
+            public void run() {
+                try {
+                    OkHttpUtils.post().url(SendMsgActioon).addParams("token",secret).addParams("phone",phone).build().execute();
+                } catch (IOException e) {
+                    Log.e(TAG, "run: "+e.getMessage());
+                }
+            }
+        }).start();
+    }
 }

+ 21 - 0
android/app/src/main/java/com/topsoft/jianyu/util/StringUtil.java

@@ -1,9 +1,14 @@
 package com.topsoft.jianyu.util;
 
+import android.util.Base64;
 import android.util.Log;
 
 import java.security.MessageDigest;
 
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
 /**
  * Created by wangkaiyue on 2018/1/26.
  */
@@ -44,4 +49,20 @@ public class StringUtil {
         return result;
     }
 
+    // 加密
+    private static String sKey = "mGlAgnIBB8bx2nch";
+
+
+    public static String AESdecode(String sSrc) throws Exception {
+        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+        byte[] raw = sKey.getBytes();
+        SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
+        IvParameterSpec iv = new IvParameterSpec(AppUtil.ivParameter.getBytes());//使用CBC模式,需要一个向量iv,可增加加密算法的强度
+        cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
+        byte[] encrypted = cipher.doFinal(sSrc.getBytes("utf-8"));
+        for(byte b: encrypted){
+            System.out.print(b);
+        }
+        return Base64Encoder.encode(encrypted);
+    }
 }