Browse Source

修改老师端webActivity

Pq 2 years ago
parent
commit
b206cfee8a

+ 4 - 0
BaseLibrary/build.gradle

@@ -25,12 +25,16 @@ android {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
             buildConfigField "String", "BASE_SERVER_URL", RELEASE_BASE_URL
+            buildConfigField "String", "BASE_URL_H5", RELEASE_BASE_URL_H5
+            buildConfigField "String", "BASE_URL_H5_STUDENT", RELEASE_BASE_URL_H5_STUDENT
         }
 
         debug {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
             buildConfigField "String", "BASE_SERVER_URL", TEST_BASE_URL
+            buildConfigField "String", "BASE_URL_H5", TEST_BASE_URL_H5
+            buildConfigField "String", "BASE_URL_H5_STUDENT", TEST_BASE_URL_H5_STUDENT
         }
     }
     compileOptions {

+ 5 - 4
BaseLibrary/src/main/java/com/cooleshow/base/common/BaseApplication.kt

@@ -8,14 +8,13 @@ import com.alibaba.android.arouter.launcher.ARouter
 /*
     Application 基类
  */
-open class BaseApplication : Application() {
+abstract class BaseApplication : Application() {
 
 
     override fun onCreate() {
         super.onCreate()
-
         context = this
-
+        isTeacherClient = isTeacherClient()
         //ARouter初始化
         ARouter.openLog()    // 打印日志
         ARouter.openDebug()
@@ -25,11 +24,13 @@ open class BaseApplication : Application() {
     }
 
 
-
     /*
         全局伴生对象
      */
     companion object {
+        var isTeacherClient = false
         lateinit var context: Context
     }
+
+    abstract fun isTeacherClient(): Boolean
 }

+ 28 - 0
BaseLibrary/src/main/java/com/cooleshow/base/common/WebConstants.java

@@ -0,0 +1,28 @@
+package com.cooleshow.base.common;
+
+import com.cooleshow.base.BuildConfig;
+
+/**
+ * Author by pq, Date on 2022/4/26.
+ */
+public abstract class WebConstants {
+    public static final String WEB_URL = "web_url";//
+
+    private static String getTeacherBaseUrlH5() {
+        return BuildConfig.BASE_URL_H5;
+    }
+
+    private static String getStudentBaseUrlH5() {
+        return BuildConfig.BASE_URL_H5_STUDENT;
+    }
+
+    private static String getBaseUrlH5() {
+        return BaseApplication.Companion.isTeacherClient() ? getTeacherBaseUrlH5() : getStudentBaseUrlH5();
+    }
+
+    //注册协议
+    public static final String REGISTRATION_AGREEMENT = getBaseUrlH5() + "/#/registerProtocol";
+    //隐私协议
+    public static final String PRIVACY_AGREEMENT = getBaseUrlH5() + "/#/privacyProtocol";
+
+}

+ 3 - 1
BaseLibrary/src/main/java/com/cooleshow/base/constanst/Constanst.java

@@ -1,11 +1,13 @@
 package com.cooleshow.base.constanst;
 
 import com.cooleshow.base.BuildConfig;
+import com.cooleshow.base.common.BaseApplication;
 import com.cooleshow.base.utils.AppUtils;
 
 /**
  * Author by pq, Date on 2022/4/22.
  */
 public class Constanst {
-    public static final String CLIENT = AppUtils.getAppPackageName().equals("com.daya.cooleshow") ? "student" : "teacher";
+    public static final String CLIENT = BaseApplication.Companion.isTeacherClient() ? "teacher" : "student";
+    public static final String COLEXIUAPPA = "COLEXIUAPPA";//H5 js接口注册interfaceName
 }

+ 0 - 35
BaseLibrary/src/main/java/com/cooleshow/base/utils/helper/JsInterfaceHelper.java

@@ -1,35 +0,0 @@
-package com.cooleshow.base.utils.helper;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.net.Uri;
-import android.text.TextUtils;
-import android.view.Window;
-import android.view.WindowManager;
-import android.webkit.JavascriptInterface;
-
-import com.alibaba.android.arouter.launcher.ARouter;
-
-import org.json.JSONObject;
-
-
-/**
- * Description:
- * Copyright  : Copyright (c) 2016
- * Company    : 大雅
- * Author     : 刘瑞
- * Date       : 2018/11/12 15:23
- */
-public class JsInterfaceHelper extends Object {
-    public static final String ENTERLIVEROOM = "enterLiveRoom";
-
-    private Activity activity;
-    JSONObject resultJson;
-
-
-    public JsInterfaceHelper(Activity activity) {
-        this.activity = activity;
-
-    }
-
-}

+ 80 - 0
BaseLibrary/src/main/java/com/cooleshow/base/widgets/WebClient.java

@@ -0,0 +1,80 @@
+package com.cooleshow.base.widgets;
+
+import android.content.ActivityNotFoundException;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.os.Build;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.View;
+import android.webkit.WebResourceError;
+import android.webkit.WebResourceRequest;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+
+import com.cooleshow.base.utils.LogUtils;
+
+/**
+ * Author by pq, Date on 2022/4/26.
+ */
+public class WebClient extends WebViewClient {
+    public String webViewUrl = "";
+    public String authorization = "";
+
+    public void setAuthorization(String authorization) {
+        this.authorization = authorization;
+    }
+
+    //页面开始载入时调用
+    @Override
+    public void onPageStarted(WebView view, String url, Bitmap favicon) {
+        super.onPageStarted(view, url, favicon);
+        webViewUrl = url;
+        LogUtils.i("onPageStarted:" + url);
+    }
+
+    //页面载入结束时调用
+    @Override
+    public void onPageFinished(WebView view, String url) {
+        super.onPageFinished(view, url);
+        webViewUrl = url;
+        if (!TextUtils.isEmpty(authorization)) {
+            String js = "window.localStorage.setItem('Authorization','" + authorization + "');";
+            String jsUrl = "javascript:(function({var localStorage = window.localStorage; localStorage.setItem('Authorization','" + authorization + "') })()";
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+                view.evaluateJavascript(js, null);
+            } else {
+                view.loadUrl(jsUrl);
+                view.reload();
+            }
+        }
+        LogUtils.e("onPageFinished:" + url);
+        LogUtils.e("Authorization:" + authorization);
+    }
+
+    //截取url请求,在当前视图加载,避免在跳转到自带浏览器
+    @Override
+    public boolean shouldOverrideUrlLoading(WebView view, String request) {
+        if (!(request.startsWith("http://") || request.startsWith("https://"))) {
+            try {
+                Intent intent = new Intent();
+                intent.setAction(Intent.ACTION_VIEW);
+                intent.setData(Uri.parse(request));
+                view.getContext().startActivity(intent);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            return true;
+        } else {
+            view.loadUrl(request);
+            return true;
+        }
+    }
+
+    //处理报错信息
+    @Override
+    public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
+        super.onReceivedError(view, request, error);
+    }
+}

+ 24 - 25
BaseLibrary/src/main/res/layout/activity_html.xml

@@ -4,28 +4,15 @@
     android:id="@+id/rl_activity_html"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@color/white"
     android:orientation="vertical">
 
-    <FrameLayout
-        android:id="@+id/fl_video"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_below="@+id/ll_activity_html"
-        android:visibility="gone" />
-
-    <FrameLayout
-        android:id="@+id/view_parent"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_below="@+id/ll_activity_html"
-        android:scrollbars="none" />
-
     <LinearLayout
         android:id="@+id/ll_activity_html"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:orientation="vertical">
+        android:orientation="vertical"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toTopOf="parent">
 
         <View
             android:id="@+id/view_statusbar"
@@ -48,9 +35,9 @@
             android:orientation="vertical">
 
             <View
-                android:id="@+id/view"
+                android:id="@+id/status_bar_view"
                 android:layout_width="match_parent"
-                android:layout_height="0dp"
+                android:layout_height="1px"
                 app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintTop_toTopOf="parent" />
@@ -64,7 +51,7 @@
                 android:scaleType="center"
                 android:src="@drawable/ic_back"
                 app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintTop_toBottomOf="@id/view" />
+                app:layout_constraintTop_toBottomOf="@+id/status_bar_view" />
 
             <ImageView
                 android:id="@+id/btn_close"
@@ -75,7 +62,7 @@
                 android:scaleType="center"
                 android:src="@drawable/ic_html_close_stu"
                 app:layout_constraintStart_toEndOf="@id/btn_back"
-                app:layout_constraintTop_toBottomOf="@id/view" />
+                app:layout_constraintTop_toBottomOf="@+id/status_bar_view" />
 
             <TextView
                 android:id="@+id/tv_title"
@@ -90,11 +77,11 @@
                 android:paddingStart="@dimen/dp_15"
                 android:paddingEnd="@dimen/dp_15"
                 android:singleLine="true"
-                android:textColor="@color/black"
+                android:textColor="@color/common_black"
                 android:textSize="@dimen/dp_18"
                 app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintTop_toBottomOf="@id/view" />
+                app:layout_constraintTop_toBottomOf="@+id/status_bar_view" />
 
             <TextView
                 android:id="@+id/tv_action"
@@ -103,11 +90,11 @@
                 android:gravity="center"
                 android:paddingEnd="@dimen/dp_15"
                 android:text=""
-                android:textColor="@color/black"
+                android:textColor="@color/common_black"
                 android:textSize="@dimen/dp_16"
                 android:visibility="invisible"
                 app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintTop_toBottomOf="@id/view" />
+                app:layout_constraintTop_toBottomOf="@+id/status_bar_view" />
 
             <ImageView
                 android:id="@+id/iv_action"
@@ -120,10 +107,22 @@
                 android:visibility="gone"
                 app:layout_constraintBottom_toBottomOf="parent"
                 app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintTop_toBottomOf="@id/view" />
+                app:layout_constraintTop_toBottomOf="@+id/status_bar_view" />
         </androidx.constraintlayout.widget.ConstraintLayout>
 
     </LinearLayout>
 
+    <FrameLayout
+        android:id="@+id/fl_video"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_below="@+id/ll_activity_html"
+        android:visibility="gone" />
 
+    <FrameLayout
+        android:id="@+id/view_parent"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_below="@+id/ll_activity_html"
+        android:scrollbars="none" />
 </RelativeLayout>

+ 6 - 0
gradle.properties

@@ -29,3 +29,9 @@ isUserModule = true
 
 TEST_BASE_URL ="http://dev.colexiu.com/"
 RELEASE_BASE_URL =""
+
+TEST_BASE_URL_H5 ="http://dev.colexiu.com/teacher"
+RELEASE_BASE_URL_H5 =""
+
+TEST_BASE_URL_H5_STUDENT ="http://dev.colexiu.com/student"
+RELEASE_BASE_URL_H5_STUDENT =""

+ 0 - 2
teacher/gradle.properties

@@ -1,2 +0,0 @@
-TEST_BASE_URL_H5 ="http://dev.colexiu.com/teacher"
-RELEASE_BASE_URL_H5 ="http://dev.colexiu.com/teacher"

+ 10 - 5
teacher/src/main/AndroidManifest.xml

@@ -7,9 +7,9 @@
         android:allowBackup="true"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name"
+        android:networkSecurityConfig="@xml/network_security_config"
         android:roundIcon="@mipmap/ic_launcher_round"
         android:supportsRtl="true"
-        android:networkSecurityConfig="@xml/network_security_config"
         android:theme="@style/Theme.CooleShow">
 
         <activity
@@ -23,11 +23,16 @@
         </activity>
         <activity
             android:name="com.cooleshow.teacher.ui.main.MainActivity"
-            android:exported="false">
-        </activity>
-        <activity android:name=".ui.course.MineCourseActivity"
+            android:exported="false"></activity>
+        <activity
+            android:name=".ui.course.MineCourseActivity"
+            android:configChanges="orientation|screenSize|keyboardHidden"
+            android:screenOrientation="portrait" />
+
+        <activity
+            android:name=".ui.web.WebActivity"
             android:configChanges="orientation|screenSize|keyboardHidden"
-            android:screenOrientation="portrait"/>
+            android:screenOrientation="portrait" />
     </application>
 
 </manifest>

+ 8 - 2
teacher/src/main/java/com/cooleshow/teacher/App.kt

@@ -18,11 +18,17 @@ class App : BaseApplication() {
         initCommonParams();
     }
 
+
     private fun initCommonParams() {
         var userToken = UserHelper.getUserToken()
-        if(!TextUtils.isEmpty(userToken)){
+        if (!TextUtils.isEmpty(userToken)) {
             //添加公共参数
-            CommonParamsHelper.getInstance().addCommonHeaderParams(CommonParamsHelper.USER_TOKEN, userToken);
+            CommonParamsHelper.getInstance()
+                .addCommonHeaderParams(CommonParamsHelper.USER_TOKEN, userToken);
         }
     }
+
+    override fun isTeacherClient(): Boolean {
+        return true
+    }
 }

+ 174 - 8
teacher/src/main/java/com/cooleshow/teacher/ui/web/WebActivity.java

@@ -1,26 +1,56 @@
 package com.cooleshow.teacher.ui.web;
 
+import android.content.pm.ActivityInfo;
+import android.content.res.Configuration;
+import android.graphics.Color;
+import android.net.Uri;
 import android.os.Build;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.webkit.GeolocationPermissions;
+import android.webkit.ValueCallback;
+import android.webkit.WebChromeClient;
 import android.webkit.WebSettings;
 import android.webkit.WebView;
 import android.widget.FrameLayout;
 
+import com.alibaba.android.arouter.facade.annotation.Route;
 import com.cooleshow.base.BuildConfig;
 import com.cooleshow.base.databinding.ActivityHtmlBinding;
+import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.ui.activity.BaseActivity;
-import com.cooleshow.base.utils.helper.JsInterfaceHelper;
+import com.cooleshow.base.utils.LogUtils;
+import com.cooleshow.base.utils.Utils;
+import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
+import com.cooleshow.base.widgets.WebClient;
+import com.cooleshow.teacher.widgets.helper.JsInterfaceHelper;
 import com.cooleshow.base.widgets.LollipopFixedWebView;
 import com.cooleshow.usercenter.helper.UserHelper;
 
+import org.json.JSONObject;
+
 import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import static com.cooleshow.base.common.WebConstants.WEB_URL;
 
 /**
  * Author by pq, Date on 2022/4/24.
  */
-public class WebActivity extends BaseActivity<ActivityHtmlBinding> {
+@Route(path = RouterPath.WebCenter.ACTIVITY_HTML)
+public class WebActivity extends BaseActivity<ActivityHtmlBinding> implements JsInterfaceHelper.OnJsMethodCallListener {
 
     private WebView webView;
     private String url;
+    private JsInterfaceHelper mInterfaceUtils;
+    private WebClient mWebClient;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        QMUIStatusBarHelper.setStatusBarLightMode(this);
+    }
 
     @NonNull
     @Override
@@ -30,6 +60,7 @@ public class WebActivity extends BaseActivity<ActivityHtmlBinding> {
 
     @Override
     protected void initView() {
+        Utils.setHeadView(viewBinding.statusBarView, this, 0);
         try {
             if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT < 23) {
                 webView = new LollipopFixedWebView(this);
@@ -40,23 +71,30 @@ public class WebActivity extends BaseActivity<ActivityHtmlBinding> {
             e.printStackTrace();
         }
         if (null == webView) {
+            finish();
+            return;
+        }
+        url = getIntent().getStringExtra(WEB_URL);
+        if (TextUtils.isEmpty(url)) {
+            finish();
             return;
         }
         viewBinding.viewParent.addView(webView, new FrameLayout.LayoutParams(
                 FrameLayout.LayoutParams.MATCH_PARENT,
                 FrameLayout.LayoutParams.MATCH_PARENT));
         initWebView();
-        JsInterfaceHelper jsInterfaceUtils = new JsInterfaceHelper(WebActivity.this);
-//        jsInterfaceUtils.setOnItemClickListener(this);
-
-        webView.addJavascriptInterface(jsInterfaceUtils, "DAYA");
-//        webView.setWebViewClient(new WebClient());
-//        webView.setWebChromeClient(new MyWebChromeClient());
+        mInterfaceUtils = new JsInterfaceHelper(WebActivity.this);
+        mInterfaceUtils.setOnJsCallListener(this);
+        webView.addJavascriptInterface(mInterfaceUtils, "COLEXIUAPPA");
+        mWebClient = new WebClient();
+        webView.setWebViewClient(mWebClient);
+        webView.setWebChromeClient(new MyWebChromeClient());
         loadUrl();
     }
 
     private void loadUrl() {
         String userToken = UserHelper.getUserToken();
+        mWebClient.setAuthorization(userToken);
         boolean status = url.contains("?");
         if (status) {
             url = (url + "&Authorization=" + userToken);
@@ -123,4 +161,132 @@ public class WebActivity extends BaseActivity<ActivityHtmlBinding> {
 //            downloadFile(url);
         });
     }
+
+    /**
+     * 状态栏控制
+     *
+     * @param message
+     */
+    @Override
+    public void setBarStatus(JSONObject message) {
+
+    }
+
+    /**
+     * 返回按钮
+     *
+     * @param message
+     */
+    @Override
+    public void backIconChange(JSONObject message) {
+
+    }
+
+    /**
+     * 获取状态栏高度
+     *
+     * @param message
+     */
+    @Override
+    public void getNavHeight(JSONObject message) {
+
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        if (mInterfaceUtils != null) {
+            mInterfaceUtils.release();
+        }
+    }
+
+
+    private class MyWebChromeClient extends WebChromeClient {
+        public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
+            callback.invoke(origin, true, false);
+        }
+
+        @Override
+        public void onProgressChanged(WebView view, int newProgress) {
+            LogUtils.e(newProgress + "");
+            if (newProgress == 100 && null != viewBinding.progressBar) {
+                viewBinding.progressBar.setVisibility(View.GONE);//加载完网页进度条消失
+            } else {
+                if (null != viewBinding.progressBar) {
+                    viewBinding.progressBar.setVisibility(View.VISIBLE);//开始加载网页时显示进度条
+                    viewBinding.progressBar.setProgress(newProgress);//设置进度值
+                }
+
+            }
+        }
+
+        @Override
+        public void onReceivedTitle(WebView view, String title) {
+            super.onReceivedTitle(view, title);
+            if (!TextUtils.isEmpty(title)) {
+                viewBinding.tvTitle.setText(title);
+            }
+
+        }
+
+        // Android > 5.0.1
+        public boolean onShowFileChooser(
+                WebView webView, ValueCallback<Uri[]> filePathCallback,
+                FileChooserParams fileChooserParams) {
+//            setUploadMsg(filePathCallback);
+//            addPermissions(PORTRAIT_REQUEST_CODE);
+            return true;
+        }
+
+        private CustomViewCallback mCustomViewCallback;
+        //  横屏时,显示视频的view
+        private View mCustomView;
+
+        // 点击全屏按钮时,调用的方法
+        @Override
+        public void onShowCustomView(View view, CustomViewCallback callback) {
+            super.onShowCustomView(view, callback);
+
+            //如果view 已经存在,则隐藏
+            if (mCustomView != null) {
+                callback.onCustomViewHidden();
+                return;
+            }
+
+            mCustomView = view;
+            mCustomView.setVisibility(View.VISIBLE);
+            mCustomViewCallback = callback;
+            viewBinding.flVideo.addView(mCustomView);
+            viewBinding.flVideo.setVisibility(View.VISIBLE);
+//            mLayout.bringToFront();
+            viewBinding.headerBarView.setVisibility(View.GONE);
+            //设置横屏
+            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+        }
+
+        // 取消全屏调用的方法
+        @Override
+        public void onHideCustomView() {
+            super.onHideCustomView();
+            if (mCustomView == null) {
+                return;
+            }
+            mCustomView.setVisibility(View.GONE);
+            viewBinding.flVideo.removeView(mCustomView);
+            mCustomView = null;
+            viewBinding.flVideo.setVisibility(View.GONE);
+            try {
+                mCustomViewCallback.onCustomViewHidden();
+            } catch (Exception e) {
+
+            }
+            viewBinding.headerBarView.setVisibility(View.VISIBLE);
+            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//竖屏
+        }
+    }
+
+    @Override
+    public void onConfigurationChanged(@NonNull Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+    }
 }

+ 129 - 0
teacher/src/main/java/com/cooleshow/teacher/widgets/helper/JsInterfaceHelper.java

@@ -0,0 +1,129 @@
+package com.cooleshow.teacher.widgets.helper;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.text.TextUtils;
+import android.view.Window;
+import android.view.WindowManager;
+import android.webkit.JavascriptInterface;
+
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.cooleshow.base.utils.LogUtils;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+
+/**
+ * Description:
+ * Copyright  : Copyright (c) 2016
+ * Company    : 大雅
+ * Author     : 刘瑞
+ * Date       : 2018/11/12 15:23
+ */
+public class JsInterfaceHelper extends Object {
+    public static final String ENTERLIVEROOM = "enterLiveRoom";
+    public static final String GET_NAV_HEIGHT = "getNavHeight";//获取状态栏高度
+    public static final String BACKICONCHANGE = "backIconChange";//顶部栏返回按钮颜色
+    public static final String SETBARSTATUS = "setBarStatus";//顶部栏控制
+
+    private Activity activity;
+    JSONObject resultJson;
+
+    public OnJsMethodCallListener onListener;
+
+
+    public JsInterfaceHelper(Activity activity) {
+        this.activity = activity;
+    }
+
+    /*
+     *统一方法
+     */
+    @JavascriptInterface
+    public void postMessage(String message) {
+        LogUtils.i("pq", "收到Msg:" + message);
+        if (activity == null) {
+            return;
+        }
+        activity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                JSONObject jsonObject = null;
+                try {
+                    jsonObject = new JSONObject(message);
+                    String api = jsonObject.getString("api");
+                    handleAction(api, jsonObject);
+                } catch (JSONException e) {
+                    e.printStackTrace();
+                }
+            }
+
+        });
+    }
+
+    private void handleAction(String api, JSONObject jsonObject) {
+        if (TextUtils.equals(GET_NAV_HEIGHT, api)) {
+            //获取状态栏高度
+            if (onListener != null) {
+                onListener.getNavHeight(jsonObject);
+            }
+            return;
+        }
+
+        if (TextUtils.equals(BACKICONCHANGE, api)) {
+            //返回按钮颜色
+            if (onListener != null) {
+                onListener.backIconChange(jsonObject);
+            }
+            return;
+        }
+
+        if (TextUtils.equals(SETBARSTATUS, api)) {
+            //状态栏控制
+            if (onListener != null) {
+                onListener.setBarStatus(jsonObject);
+            }
+            return;
+        }
+    }
+
+
+    public void setOnJsCallListener(OnJsMethodCallListener onListener) {
+        this.onListener = onListener;
+    }
+
+
+    public interface OnJsMethodCallListener {
+
+        /**
+         * 顶部栏控制
+         *
+         * @param message
+         */
+        void setBarStatus(JSONObject message);
+
+        /**
+         * 顶部栏返回按钮颜色
+         * {iconStyle:  black , white}
+         *
+         * @param message
+         */
+        void backIconChange(JSONObject message);
+
+        /**
+         * 返回顶部高度
+         * 顶部栏高度
+         * 以及dpi
+         *
+         * @param message
+         */
+        void getNavHeight(JSONObject message);
+    }
+
+
+    public void release() {
+        this.activity = null;
+    }
+}

+ 18 - 2
usercenter/src/main/java/com/cooleshow/usercenter/ui/activity/LoginActivity.kt

@@ -9,6 +9,8 @@ import android.text.method.LinkMovementMethod
 import android.text.style.ClickableSpan
 import android.view.View
 import com.alibaba.android.arouter.facade.annotation.Route
+import com.alibaba.android.arouter.launcher.ARouter
+import com.cooleshow.base.common.WebConstants
 import com.cooleshow.base.ext.onClick
 import com.cooleshow.base.router.RouterPath
 import com.cooleshow.base.ui.activity.BaseMVPActivity
@@ -88,7 +90,10 @@ class LoginActivity : BaseMVPActivity<ActivityLoginBinding, LoginPresenter>(),
         viewBinding.tvPrivacy.highlightColor = Color.TRANSPARENT
         builder.append(getString(R.string.login_privacy_tip))
             .setClickSpan(object : ClickableSpan() {
-                override fun onClick(view: View) {}
+                override fun onClick(view: View) {
+                    startWebActivity(WebConstants.REGISTRATION_AGREEMENT);
+                }
+
                 override fun updateDrawState(ds: TextPaint) {
                     super.updateDrawState(ds)
                     ds.color = resources.getColor(com.cooleshow.base.R.color.color_2dc7aa)
@@ -98,7 +103,10 @@ class LoginActivity : BaseMVPActivity<ActivityLoginBinding, LoginPresenter>(),
             .setForegroundColor(resources.getColor(com.cooleshow.base.R.color.color_999999))
             .append(getString(R.string.login_privacy_tip2))
             .setClickSpan(object : ClickableSpan() {
-                override fun onClick(view: View) {}
+                override fun onClick(view: View) {
+                    startWebActivity(WebConstants.PRIVACY_AGREEMENT);
+                }
+
                 override fun updateDrawState(ds: TextPaint) {
                     super.updateDrawState(ds)
                     ds.color = resources.getColor(com.cooleshow.base.R.color.color_2dc7aa)
@@ -107,4 +115,12 @@ class LoginActivity : BaseMVPActivity<ActivityLoginBinding, LoginPresenter>(),
             })
         viewBinding.tvPrivacy.text = builder.create()
     }
+
+    private fun startWebActivity(agreement: String?) {
+        //跳转隐私协议
+        ARouter.getInstance()
+            .build(RouterPath.WebCenter.ACTIVITY_HTML)
+            .withString(WebConstants.WEB_URL, agreement)
+            .navigation()
+    }
 }

+ 11 - 2
usercenter/src/main/java/com/cooleshow/usercenter/ui/activity/VerifyCodeLoginActivity.java

@@ -11,6 +11,7 @@ import android.view.View;
 
 import com.alibaba.android.arouter.facade.annotation.Route;
 import com.alibaba.android.arouter.launcher.ARouter;
+import com.cooleshow.base.common.WebConstants;
 import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.ui.activity.BaseMVPActivity;
 import com.cooleshow.base.utils.SpannableStringUtils;
@@ -99,7 +100,7 @@ public class VerifyCodeLoginActivity extends BaseMVPActivity<ActivityVerifyCodeL
                 .setClickSpan(new ClickableSpan() {
                     @Override
                     public void onClick(View view) {
-
+                        startWebActivity(WebConstants.REGISTRATION_AGREEMENT);
                     }
 
                     public void updateDrawState(@NonNull TextPaint ds) {
@@ -112,8 +113,8 @@ public class VerifyCodeLoginActivity extends BaseMVPActivity<ActivityVerifyCodeL
                 .setClickSpan(new ClickableSpan() {
                     @Override
                     public void onClick(View view) {
+                        startWebActivity(WebConstants.PRIVACY_AGREEMENT);
                     }
-
                     public void updateDrawState(@NonNull TextPaint ds) {
                         super.updateDrawState(ds);
                         ds.setColor(getResources().getColor(com.cooleshow.base.R.color.color_2dc7aa));
@@ -122,4 +123,12 @@ public class VerifyCodeLoginActivity extends BaseMVPActivity<ActivityVerifyCodeL
                 });
         viewBinding.tvPrivacy.setText(builder.create());
     }
+
+    private void startWebActivity(String agreement) {
+        //跳转隐私协议
+        ARouter.getInstance()
+                .build(RouterPath.WebCenter.ACTIVITY_HTML)
+                .withString(WebConstants.WEB_URL, agreement)
+                .navigation();
+    }
 }