From c6005ee9a115bb77da2c916efccf898a0ff00628 Mon Sep 17 00:00:00 2001 From: lijia Date: Fri, 22 Nov 2024 15:55:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E7=A7=81=E6=94=BF=E7=AD=96=E6=8B=A6?= =?UTF-8?q?=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 55 +++-- .../hndahesudintocctmsdriver/H5Activity.java | 3 +- .../ui/alert/AgreementAlert.java | 5 +- .../ui/auth/CertificatesActivity.java | 133 ++++++---- .../ui/login/LoginActivity.java | 7 +- .../ui/login/WelcomeActivity.java | 4 +- .../ui/web/WebOnlyOneActivity.java | 227 ++++++++++++++++++ 7 files changed, 361 insertions(+), 73 deletions(-) create mode 100644 app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/web/WebOnlyOneActivity.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4ed4aa6..90f907f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,7 @@ + @@ -71,14 +72,14 @@ android:configChanges="orientation|keyboardHidden|screenSize" android:exported="true" android:launchMode="singleTop" - android:screenOrientation="portrait" > + android:screenOrientation="portrait"> + android:screenOrientation="portrait" /> + android:screenOrientation="portrait" /> @@ -93,11 +94,11 @@ android:screenOrientation="portrait" /> + android:screenOrientation="portrait" + android:windowSoftInputMode="adjustPan|stateHidden" /> + android:screenOrientation="portrait" /> @@ -142,13 +143,13 @@ + android:screenOrientation="portrait" /> + android:screenOrientation="portrait" /> + android:screenOrientation="portrait" /> @@ -161,14 +162,14 @@ + android:screenOrientation="portrait" + android:windowSoftInputMode="adjustPan|stateHidden" /> + android:screenOrientation="portrait" /> + android:screenOrientation="portrait" /> + android:screenOrientation="portrait" /> + android:screenOrientation="portrait" /> @@ -203,17 +204,21 @@ + android:screenOrientation="portrait" /> + android:screenOrientation="portrait" /> + android:screenOrientation="portrait" /> + + android:windowSoftInputMode="stateAlwaysHidden" /> - + @@ -362,10 +367,11 @@ + android:launchMode="singleTask" + android:screenOrientation="portrait"> + @@ -383,10 +389,11 @@ + android:launchMode="singleTask" + android:screenOrientation="portrait"> + diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/H5Activity.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/H5Activity.java index 4664c87..cc72aea 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/H5Activity.java +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/H5Activity.java @@ -41,6 +41,7 @@ import androidx.appcompat.app.AppCompatActivity; import com.arpa.hndahesudintocctmsdriver.cuspop.SimCenterPop; import com.arpa.hndahesudintocctmsdriver.event.FaceEvent; import com.arpa.hndahesudintocctmsdriver.event.HomeEvent; +import com.arpa.hndahesudintocctmsdriver.request.UserRequset; import com.arpa.hndahesudintocctmsdriver.ui.MainActivity; import com.arpa.hndahesudintocctmsdriver.ui.UiAuxiliary; import com.arpa.hndahesudintocctmsdriver.ui.auth.CertificatesActivity; @@ -249,7 +250,7 @@ public class H5Activity extends AppCompatActivity { Uri uri = Uri.parse(url); Log.e("test", "要加载的地址:" + uri.getScheme() + " " + url + " "); if (uri.getScheme().equals("http") || uri.getScheme().equals("https")) { - if (isGoCar&&url.startsWith("http://agreement.dahehuoyun.com/#/1ba5c216/912f4c9587/5eb5184653/6ef9")){ + if (isGoCar&&url.startsWith("https://agreement.dahehuoyun.com/#/1ba5c216/912f4c9587/5eb5184653/6ef9")){ isOk = true; view.loadUrl(url); new MessageUtils().showSimCenPop(ctx, "个人信息上传成功,请添加车辆信息!", "去添加",() -> { diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/alert/AgreementAlert.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/alert/AgreementAlert.java index 98cb60f..9843d94 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/alert/AgreementAlert.java +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/alert/AgreementAlert.java @@ -14,6 +14,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; +import com.arpa.hndahesudintocctmsdriver.ui.web.WebOnlyOneActivity; import com.lxj.xpopup.core.CenterPopupView; import com.arpa.hndahesudintocctmsdriver.R; import com.arpa.hndahesudintocctmsdriver.ui.web.WebActivity; @@ -68,7 +69,7 @@ public class AgreementAlert extends CenterPopupView { @Override public void onClick(View widget) { //用户服务协议点击事件 - Intent in=new Intent(getContext(), WebActivity.class); + Intent in=new Intent(getContext(), WebOnlyOneActivity.class); in.putExtra("url",url2); in.putExtra("title","用户服务协议"); getContext().startActivity(in); @@ -87,7 +88,7 @@ public class AgreementAlert extends CenterPopupView { @Override public void onClick(View widget) { //用户服务协议点击事件 - Intent in=new Intent(getContext(), WebActivity.class); + Intent in=new Intent(getContext(), WebOnlyOneActivity.class); in.putExtra("url",url); in.putExtra("title","隐私政策"); getContext().startActivity(in); diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/auth/CertificatesActivity.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/auth/CertificatesActivity.java index c0132ab..a80865c 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/auth/CertificatesActivity.java +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/auth/CertificatesActivity.java @@ -1,11 +1,13 @@ package com.arpa.hndahesudintocctmsdriver.ui.auth; +import android.Manifest; import android.content.Context; import android.content.Intent; import android.net.Uri; 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 android.view.View; @@ -35,6 +37,7 @@ import com.arpa.hndahesudintocctmsdriver.event.VehicleEvent; import com.arpa.hndahesudintocctmsdriver.ui.wallet.UpBankActivity; import com.arpa.hndahesudintocctmsdriver.util.MessageUtils; import com.arpa.hndahesudintocctmsdriver.util.PickerUtils; +import com.arpa.hndahesudintocctmsdriver.util.PicturlUtil; import com.arpa.hndahesudintocctmsdriver.util.alert.ToastUtil; import com.arpa.hndahesudintocctmsdriver.util.map.MapUtil; import com.bumptech.glide.Glide; @@ -85,6 +88,8 @@ import com.arpa.hndahesudintocctmsdriver.util.view.BaseAppCompatActivity; import com.arpa.hndahesudintocctmsdriver.util.view.BaseRecyclerView; import com.lxj.xpopup.photoview.PhotoView; import com.lxj.xpopup.util.SmartGlideImageLoader; +import com.lxj.xpopup.util.XPermission; +import com.permissionx.guolindev.PermissionX; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -209,8 +214,6 @@ public class CertificatesActivity extends BaseAppCompatActivity { key = true; }, 3000); } - - } else { Toast.makeText(con, bb.getMsg(), Toast.LENGTH_SHORT).show(); } @@ -221,12 +224,25 @@ public class CertificatesActivity extends BaseAppCompatActivity { Log.e("url", CacheGroup.cacheList.get("authUrl")); BaseBean bb = gson.fromJson(CacheGroup.cacheList.get("authUrl"), BaseBean.class); if (bb.getCode() == 200) { - Intent intent = new Intent(this, H5Activity.class); - intent.putExtra("url", (String) bb.getData()); - intent.putExtra("view_file", false); - intent.putExtra("title", "人脸识别"); - intent.putExtra("isGoCar", true); - startActivity(intent); + PermissionX.init(this) + .permissions(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA) + .request((allGranted, grantedList, deniedList) -> { + if (allGranted) { + Intent intent = new Intent(this, H5Activity.class); + intent.putExtra("url", (String) bb.getData()); + intent.putExtra("view_file", false); + intent.putExtra("title", "人脸识别"); + intent.putExtra("isGoCar", true); + startActivity(intent); + } else { + new MessageUtils().showSimCenPop(act, "缺少相机,媒体权限,将无法为您提供服务,去开启!", "取消", "确认", () -> { + Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + Uri uri = Uri.fromParts("package", getPackageName(), null); + intent.setData(uri); + act.startActivity(intent); + }); + } + }); // EsignSdk.getInstance().startH5Activity(act, StringUtil.isNull(String.valueOf(bb.getData()), "")); } else { Toast.makeText(con, bb.getMsg(), Toast.LENGTH_LONG).show(); @@ -280,22 +296,6 @@ public class CertificatesActivity extends BaseAppCompatActivity { con.startActivity(in); } finish(); -// if ("1".equals(needUpQCPhoto)) { -// //现逻辑:上传行驶证信息后 判断是否跳转从业资格证 -// Intent in = new Intent(con, AuthQualificationActivity.class); -// in.putExtra("type", "0"); -// in.putExtra("isOverCar", false); -// in.putExtra("carId", String.valueOf(czb.getData().getCarId())); -// startActivity(in); -// } else { -// //原逻辑:上传行驶证信息后 跳转车辆照片页面 -// Intent in = new Intent(con, PhotoCarActivity.class); -// in.putExtra("type", 0); -// in.putExtra("carId", String.valueOf(czb.getData().getCarId())); -// con.startActivity(in); -// } - - } else { Toast.makeText(con, czb.getMsg(), Toast.LENGTH_SHORT).show(); } @@ -459,12 +459,25 @@ public class CertificatesActivity extends BaseAppCompatActivity { Log.e("url", CacheGroup.cacheList.get("authUrl")); BaseBean bb = gson.fromJson(CacheGroup.cacheList.get("authUrl"), BaseBean.class); if (bb.getCode() == 200) { - Intent intent = new Intent(this, H5Activity.class); - intent.putExtra("url", (String) bb.getData()); - intent.putExtra("view_file", false); - intent.putExtra("title", "人脸识别"); - intent.putExtra("isGoCar", true); - startActivity(intent); + PermissionX.init(this) + .permissions(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA) + .request((allGranted, grantedList, deniedList) -> { + if (allGranted) { + Intent intent = new Intent(this, H5Activity.class); + intent.putExtra("url", (String) bb.getData()); + intent.putExtra("view_file", false); + intent.putExtra("title", "人脸识别"); + intent.putExtra("isGoCar", true); + startActivity(intent); + } else { + new MessageUtils().showSimCenPop(act, "缺少相机,媒体权限,将无法为您提供服务,去开启!", "取消", "确认", () -> { + Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + Uri uri = Uri.fromParts("package", getPackageName(), null); + intent.setData(uri); + act.startActivity(intent); + }); + } + }); // EsignSdk.getInstance().startH5Activity(act, StringUtil.isNull(String.valueOf(bb.getData()), "")); } else { Toast.makeText(con, bb.getMsg(), Toast.LENGTH_LONG).show(); @@ -922,7 +935,7 @@ public class CertificatesActivity extends BaseAppCompatActivity { value3.setText(ocb.getData().getAddress()); Glide.with(con).load(path).into(img1); } else { - Toast.makeText(con, "识别失败", Toast.LENGTH_SHORT).show(); + Toast.makeText(con, "识别失败请重新上传", Toast.LENGTH_SHORT).show(); } CacheGroup.cacheList.remove(TYPE_NAME[0]); } @@ -935,7 +948,7 @@ public class CertificatesActivity extends BaseAppCompatActivity { //自动调取提交功能,实现页面自动跳转 subimt(); } else { - Toast.makeText(con, "识别失败", Toast.LENGTH_SHORT).show(); + Toast.makeText(con, "识别失败请重新上传", Toast.LENGTH_SHORT).show(); } CacheGroup.cacheList.remove(TYPE_NAME_BANK[0]); } @@ -954,7 +967,7 @@ public class CertificatesActivity extends BaseAppCompatActivity { value4.setText(StringUtil.isNull(od.getEndDate(), "识别异常")); Glide.with(con).load(path).into(img1); } else { - Toast.makeText(con, "识别失败", Toast.LENGTH_SHORT).show(); + Toast.makeText(con, "识别失败请重新上传", Toast.LENGTH_SHORT).show(); } CacheGroup.cacheList.remove(TYPE_NAME[1]); } @@ -965,7 +978,7 @@ public class CertificatesActivity extends BaseAppCompatActivity { //自动调取提交功能,实现页面自动跳转 subimt(); } else { - Toast.makeText(con, "识别失败", Toast.LENGTH_SHORT).show(); + Toast.makeText(con, "识别失败请重新上传", Toast.LENGTH_SHORT).show(); } CacheGroup.cacheList.remove(TYPE_NAME_BANK[1]); } @@ -1006,7 +1019,7 @@ public class CertificatesActivity extends BaseAppCompatActivity { new AuthRequest().getCarInfo(con, hd, olb.getData().getVclN()); Log.e("-cardId-", oCrcarId); } else { - Toast.makeText(con, "识别失败", Toast.LENGTH_SHORT).show(); + Toast.makeText(con, "识别失败请重新上传", Toast.LENGTH_SHORT).show(); } CacheGroup.cacheList.remove(TYPE_NAME[2]); } @@ -1020,7 +1033,7 @@ public class CertificatesActivity extends BaseAppCompatActivity { //自动调取提交功能,实现页面自动跳转实现页面自动跳转 subimt(); } else { - Toast.makeText(con, "识别失败", Toast.LENGTH_SHORT).show(); + Toast.makeText(con, "识别失败请重新上传", Toast.LENGTH_SHORT).show(); } CacheGroup.cacheList.remove(TYPE_NAME_BANK[2]); } @@ -1119,8 +1132,18 @@ public class CertificatesActivity extends BaseAppCompatActivity { switch (index) { case 0: if (ocb != null && ocbb != null) { + if (ocb.getData() == null) { + ToastUtils.showToast(con, "主页照片识别失败,请重新上传"); + return; + } + + if (ocbb == null || ocbb.getData() == null) { + ToastUtils.showToast(con, "副页照片识别失败,请重新上传"); + return; + } customDialog = new CustomDialog(con, "网络请求中..."); customDialog.show(); + IDInputBean ib = new IDInputBean(); ib.setIdcarName(str1); ib.setIdcard(str2); @@ -1143,8 +1166,20 @@ public class CertificatesActivity extends BaseAppCompatActivity { //olb //{"档案编号","初次领证日期","准驾车型","有效期限(止)"}, if (odl != null && odlb != null) { + + if (odl.getData() == null) { + ToastUtils.showToast(con, "主页照片识别失败,请重新上传"); + return; + } + + if (odlb == null || odlb.getData() == null) { + ToastUtils.showToast(con, "副页照片识别失败,请重新上传"); + return; + } + customDialog = new CustomDialog(con, "网络请求中..."); customDialog.show(); + Log.e("ocr", new Gson().toJson(odl)); LicenseInputBean iib = new LicenseInputBean(); iib.setArchivesName(odlb.getData().getFileNumber()); @@ -1182,6 +1217,17 @@ public class CertificatesActivity extends BaseAppCompatActivity { // Toast.makeText(con, "请完善内容", Toast.LENGTH_SHORT).show(); // return; // } + if (olb.getData() == null) { + ToastUtils.showToast(con, "主页照片识别失败,请重新上传"); + return; + } + + if (oblb == null || oblb.getData() == null) { + ToastUtils.showToast(con, "副页照片识别失败,请重新上传"); + return; + } + + customDialog = new CustomDialog(con, "网络请求中..."); customDialog.show(); HashMap map = new HashMap<>(); @@ -1194,6 +1240,7 @@ public class CertificatesActivity extends BaseAppCompatActivity { // map.put("ownerName", str3); // map.put("vin", str4);//车辆识别代号 + String carLong = ""; String carWidth = ""; String carHeight = ""; @@ -1288,10 +1335,15 @@ public class CertificatesActivity extends BaseAppCompatActivity { break; case 3: if (olb != null || (cdb != null && cdb.getRes() == 1)) { -// if (curEnergy==null){ -// Toast.makeText(con,"请完善内容",Toast.LENGTH_SHORT).show(); -// return; -// } + if (olb.getData() == null) { + ToastUtils.showToast(con, "主页照片识别失败,请重新上传"); + return; + } + + if (oblb == null || oblb.getData() == null) { + ToastUtils.showToast(con, "副页照片识别失败,请重新上传"); + return; + } customDialog = new CustomDialog(con, "网络请求中..."); customDialog.show(); // Map map = new HashMap<>(); @@ -1328,7 +1380,6 @@ public class CertificatesActivity extends BaseAppCompatActivity { // map.put("fileNumber", oblb.getData().getRecordId());//档案编号 // map.put("towAuality", oblb.getData().getVclDrwTn());//准牵引总质量 - String carLong = ""; String carWidth = ""; String carHeight = ""; diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/login/LoginActivity.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/login/LoginActivity.java index 177dbd6..989f3c9 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/login/LoginActivity.java +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/login/LoginActivity.java @@ -31,6 +31,7 @@ import com.arpa.hndahesudintocctmsdriver.parts.ConfigParts; import com.arpa.hndahesudintocctmsdriver.request.net.BaseObserver; import com.arpa.hndahesudintocctmsdriver.request.net.DataManager; import com.arpa.hndahesudintocctmsdriver.request.net.RxHttpCallBack; +import com.arpa.hndahesudintocctmsdriver.ui.web.WebOnlyOneActivity; import com.dahe.mylibrary.net.CommonResponseBean; import com.google.gson.Gson; import com.arpa.hndahesudintocctmsdriver.R; @@ -157,7 +158,7 @@ public class LoginActivity extends BaseActivity { ConfigBean cb = ConfigParts.getConfigParts(con); if (cb != null) { - url1 = cb.getData().getUserUrl(); + url1 = "https://agreement.dahehuoyun.com/#/user"; url2 = "https://agreement.dahehuoyun.com/currency/#/"; } TextView tv_content = findViewById(R.id.tv_content); @@ -171,7 +172,7 @@ public class LoginActivity extends BaseActivity { public void onClick(View widget) { Log.e("-用户服务协议-", url1); //用户服务协议点击事件 - Intent in = new Intent(con, WebActivity.class); + Intent in = new Intent(con, WebOnlyOneActivity.class); in.putExtra("title", "用户服务协议"); in.putExtra("url", url1); startActivity(in); @@ -191,7 +192,7 @@ public class LoginActivity extends BaseActivity { @Override public void onClick(View widget) { //隐私协议点击事件 - Intent in = new Intent(con, WebActivity.class); + Intent in = new Intent(con, WebOnlyOneActivity.class); in.putExtra("title", "隐私政策"); in.putExtra("url", url2); startActivity(in); diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/login/WelcomeActivity.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/login/WelcomeActivity.java index c261300..8a2f012 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/login/WelcomeActivity.java +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/login/WelcomeActivity.java @@ -140,8 +140,8 @@ public class WelcomeActivity extends BaseAppCompatActivity { new XPopup.Builder(con) .dismissOnBackPressed(false) .dismissOnTouchOutside(false) - .asCustom(new AgreementAlert(con, "http://agreement.dahehuoyun.com/currency/#/", - "http://agreement.dahehuoyun.com/rule/serviceAgreement/dist/index.html#/", hd)) + .asCustom(new AgreementAlert(con, "https://agreement.dahehuoyun.com/currency/#/", + "https://agreement.dahehuoyun.com/#/user", hd)) .show(); } Glide.with(con) diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/web/WebOnlyOneActivity.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/web/WebOnlyOneActivity.java new file mode 100644 index 0000000..d36b89e --- /dev/null +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/web/WebOnlyOneActivity.java @@ -0,0 +1,227 @@ +package com.arpa.hndahesudintocctmsdriver.ui.web; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.net.http.SslError; +import android.os.Build; +import android.os.Bundle; +import android.util.Log; +import android.webkit.JavascriptInterface; +import android.webkit.SslErrorHandler; +import android.webkit.WebResourceRequest; +import android.webkit.WebSettings; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.Nullable; + +import com.arpa.hndahesudintocctmsdriver.R; +import com.arpa.hndahesudintocctmsdriver.bean.UserBean; +import com.arpa.hndahesudintocctmsdriver.parts.UserParts; +import com.arpa.hndahesudintocctmsdriver.util.PaxWebChromeClient; +import com.arpa.hndahesudintocctmsdriver.util.statusbar.StateStyleUtil; +import com.arpa.hndahesudintocctmsdriver.util.string.StringUtil; +import com.arpa.hndahesudintocctmsdriver.util.view.BaseActivity; + +/** + * @author hlh + * @version 1.0.0 + * @date 2021/8/6 16:48 + * @description:访问webview的activity + */ +public class WebOnlyOneActivity extends BaseActivity { + + private String url = ""; + private String title = ""; + private WebView wv; + private TextView title_tv; + private PaxWebChromeClient chromeClient; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + StateStyleUtil.stateTextColor(this); + setContentView(R.layout.activity_web); + con = this; + initHardwareAccelerate(); + wv = findViewById(R.id.wv); + title_tv = findViewById(R.id.title); + Intent in = getIntent(); + url = in.getExtras().getString("url"); + title = in.getExtras().getString("title"); + chromeClient = new PaxWebChromeClient(this, null, null); + if ("咨询建议".equals(title)) { + initOpinion(); + } else { + initView(null); + } + } + + private void initHardwareAccelerate() { + try { + if (Integer.parseInt(Build.VERSION.SDK) >= 11) { + getWindow() + .setFlags( + android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, + android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); + } + } catch (Exception e) { + } + } + + @SuppressLint({"JavascriptInterface", "SetJavaScriptEnabled"}) + @Override + public void initView(Object obj) { + super.initView(obj); + WebSettings webSettings = wv.getSettings(); + //设置网页有缓存的时候也继续读取新的地址 + webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); + webSettings.setJavaScriptEnabled(true); + webSettings.setDomStorageEnabled(true); + webSettings.setDefaultTextEncodingName("utf-8"); + // 特别注意:5.1以上默认禁止了https和http混用,以下方式是开启 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); + } + + wv.addJavascriptInterface(new JavaScriptObject(con), "webObj"); + //PaxWebChromeClient chromeClient=new PaxWebChromeClient(); + //WebView加载web资源 + //覆盖WebView默认使用第三方或系统默认浏览器打开网页的行为,使网页用WebView打开 + wv.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { + return super.shouldOverrideUrlLoading(view, request); + } + + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url1) { + //返回值是true的时候控制去WebView打开,为false调用系统浏览器或第三方浏览器 + Log.d("test", "webactivity..url:" + url); +// if(!url.startsWith("http")) +// { +// Log.d("test","非http开头..url:"+url); +// Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(url)); +// boolean isInstall = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size()>0; +// Log.d("test","是否安装要跳转的app:"+isInstall); +// if(isInstall) +// { +// startActivity(intent); +// finish(); +// } +// return true; +// } + if (!url1.equals(url)) + return true; + wv.loadUrl(url1); + return true; + } + + @Override + public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { + super.onReceivedSslError(view, handler, error); + handler.proceed(); + } + }); + wv.setWebChromeClient(chromeClient); + wv.loadUrl(url); + title_tv.setText(title); + } + + public void initOpinion() { + if (findViewById(R.id.return_btn) != null) { + findViewById(R.id.return_btn).setOnClickListener(v -> { + finish(); + }); + } + title_tv.setText(title); + UserBean ub = UserParts.getUser(con); + wv.getSettings().setJavaScriptEnabled(true); + wv.getSettings().setDomStorageEnabled(true); // 这个要加上 + String openid = ub.getData().getUname(); // 用户的openid + String nickname = StringUtil.isNull(ub.getData().getRname(), "游客"); // 用户的nickname + String headimgurl = StringUtil.isNull(ub.getData().getHeadportraitUrl(), ""); // 用户的头像url + + /* 获得 webview url,请注意url单词是product而不是products,products是旧版本的参数,用错地址将不能成功提交 */ + String url = "https://support.qq.com/products/335639"; // 把1221数字换成你的产品ID,否则会不成功 + /* 准备post参数 */ + String postData = "nickname=" + nickname + "&avatar=" + headimgurl + "&openid=" + openid; + wv.postUrl(url, postData.getBytes()); + wv.setWebChromeClient(chromeClient); + wv.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { + return super.shouldOverrideUrlLoading(view, request); + } + + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + //返回值是true的时候控制去WebView打开,为false调用系统浏览器或第三方浏览器 + view.loadUrl(url); + return true; + } + + @Override + public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { + super.onReceivedSslError(view, handler, error); + handler.proceed(); + } + }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + + chromeClient.onActivityResult(requestCode, resultCode, data); + + super.onActivityResult(requestCode, resultCode, data); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + } + + + public class JavaScriptObject { + + Context mContxt; + + public JavaScriptObject(Context mContxt) { + this.mContxt = mContxt; + + } + + @JavascriptInterface + public void getName() { + Log.e("eeee-", "name"); + Toast.makeText(con, "hello", Toast.LENGTH_SHORT).show(); + } + + @JavascriptInterface + public String getUserToken() { +// Log.e("-token-",UserParts.getUser(con).getData().getToken()); +// return "woshitoken-androidfasdf"; + return UserParts.getUser(con).getData().getToken(); + } + + @JavascriptInterface + public void isSuccess() { + finish(); + } + + @JavascriptInterface + public void isPdfSuccess() { + Toast.makeText(con, "签署成功", Toast.LENGTH_SHORT).show(); + finish(); + } + } + + +} +