| | |
| | | import android.Manifest; |
| | | import android.annotation.SuppressLint; |
| | | import android.app.Activity; |
| | | import android.app.AlertDialog; |
| | | import android.content.ClipData; |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.PixelFormat; |
| | | import android.net.Uri; |
| | | import android.os.Build; |
| | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.annotation.RequiresApi; |
| | | import wendu.dsbridge.DWebView; |
| | | |
| | | import android.util.Base64; |
| | | import android.util.Log; |
| | | import android.view.KeyEvent; |
| | | import android.view.View; |
| | |
| | | import android.widget.PopupWindow; |
| | | import android.widget.ProgressBar; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.ali.auth.third.ui.context.CallbackContext; |
| | | import com.alibaba.baichuan.android.trade.model.AlibcShowParams; |
| | | import com.alibaba.baichuan.trade.biz.AlibcConstants; |
| | | import com.alibaba.baichuan.trade.biz.applink.adapter.AlibcFailModeType; |
| | | import com.tejia.lijin.app.ui.recommend.GoodsDetailActivity; |
| | | import com.tejia.lijin.app.util.web.RebateJavaInterfaceBS; |
| | | import com.tejia.lijin.app.util.web.WebViewUtil; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.wpc.library.okhttp.OkHttpUtils; |
| | | import com.wpc.library.util.JDLinkCutUtil; |
| | |
| | | import com.tejia.lijin.app.ui.recommend.NoExtendPDDGoodsActivity; |
| | | import com.tejia.lijin.app.ui.recommend.NoExtendTaoBaoGoodsActivity; |
| | | import com.tejia.lijin.app.util.AndroidBug5497Workaround; |
| | | import com.tejia.lijin.app.util.ApkUtil; |
| | | import com.tejia.lijin.app.util.Constant; |
| | | import com.tejia.lijin.app.util.KeFuUtil; |
| | | import com.tejia.lijin.app.util.PermissionHelper; |
| | | import com.tejia.lijin.app.util.RebateJavaInterface; |
| | | import com.tejia.lijin.app.util.Tools; |
| | | import com.tejia.lijin.app.util.web.RebateJavaInterface; |
| | | import com.tejia.lijin.app.util.TopStatusSettings; |
| | | import com.tejia.lijin.app.util.baichuan.AlibcTradeUtil; |
| | | import com.tejia.lijin.app.util.clipboard.ClipboardUtil; |
| | | import com.tejia.lijin.app.util.goods.GoodsDetailJumpUtil; |
| | | import com.tejia.lijin.app.util.web.CustomNavigationJsObject; |
| | | |
| | | import org.apache.http.Header; |
| | |
| | | private TextView tv_top_bar_left2; |
| | | private ImageView iv_right; |
| | | private Button tv_top_bar_middle; |
| | | private WebView webview; |
| | | private DWebView webview; |
| | | private FrameLayout fl_webview; |
| | | View v_cover_web; |
| | | ProgressBar progressBar; |
| | |
| | | String mTitle; |
| | | |
| | | RebateJavaInterface javaInterface; |
| | | RebateJavaInterfaceBS javaInterface1; |
| | | private FrameLayout fl_full_video; |
| | | |
| | | String tag1 = "config/getWebConfig"; |
| | |
| | | private boolean interceptGoodsDetail; |
| | | |
| | | private String originalUrl = ""; |
| | | //沉浸式网页 |
| | | private boolean immersion = false; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | |
| | | String immersionStr = getIntent().getStringExtra("immersion"); |
| | | if (!StringUtils.isNullOrEmpty(immersionStr) && Boolean.parseBoolean(immersionStr)) { |
| | | immersion = true; |
| | | } |
| | | setContentView(R.layout.browser_activity); |
| | | AndroidBug5497Workaround.assistActivity(this); |
| | | TopStatusSettings.setStatusViewAndDeepColor(this); |
| | |
| | | iv_right = findViewById(R.id.iv_top_bar_right); |
| | | fl_webview = findViewById(R.id.fl_webview); |
| | | fl_full_video = findViewById(R.id.fl_full_video); |
| | | tv_top_bar_left2.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_web_close, 0, 0, 0); |
| | | |
| | | tv_top_bar_left.setOnClickListener(this); |
| | | tv_top_bar_left2.setOnClickListener(this); |
| | | iv_right.setOnClickListener(this); |
| | |
| | | // tv_top_bar_middle.setText("奥术大师大所大所多奥术大师"); |
| | | pd = new ShapeLoadingDialog.Builder(this).build(); |
| | | |
| | | webview = new WebView(ShareBrowserActivity.this); |
| | | webview = new DWebView(ShareBrowserActivity.this); |
| | | |
| | | fl_webview.addView(webview, new FrameLayout.LayoutParams( |
| | | FrameLayout.LayoutParams.MATCH_PARENT, |
| | |
| | | |
| | | mPermissionsChecker = new PermissionHelper(this, this); |
| | | // webview.loadUrl("http://mp.weixin.qq.com/s/mu3lJ1DYEc0MxgnMHArHYA"); |
| | | // String url = "http://192.168.1.122:8848/test/WKWebView.html"; |
| | | //url = "https://amcn.bytedance.com/ug/armor/623040fd8df75a02420060e1?show_loading=1&pull_down_close=0&enter_from=UG_CF_CSJ_2022&ug_feed_type=1&ug_app=0&plan_id=7106425777876369677&ug_app=0&page_id=F618&ecom_pid=dy_107062945313497465096_11642_3276765365"; |
| | | if (!StringUtils.isEmpty(url)) { |
| | | getWebConfig(url); |
| | | } |
| | |
| | | webview.addJavascriptInterface(javaInterface, "yestv"); |
| | | CustomNavigationJsObject customNavigation = new CustomNavigationJsObject(this); |
| | | webview.addJavascriptInterface(customNavigation, "czb");//第二个参数czb不可更改, |
| | | |
| | | javaInterface1 = new RebateJavaInterfaceBS(ShareBrowserActivity.this, |
| | | tv_top_bar_middle, tv_top_bar_left2, new TextView(this), iv_right, webview, pd); |
| | | javaInterface1.setGeneralBackCallback(this);//分享图片权限回调 |
| | | webview.addJavascriptObject(javaInterface1, "yestv"); |
| | | |
| | | /*** |
| | | * Android5.0开始,WebView默认不支持同时加载Https和Http混合模式 |
| | | * WebView在微信网页中首先打开一个https网址,然后它会被重定向到一个http网址 |
| | |
| | | return true; |
| | | } |
| | | } |
| | | if (url != null && url.startsWith("yestv://copy")) { |
| | | String murl = url.split("yestv://")[1]; |
| | | String[] params = murl.split("#"); |
| | | byte raw[] = Base64.decode(params[1], Base64.DEFAULT); |
| | | |
| | | ClipboardUtil.copy(getApplicationContext(), new String(raw)); |
| | | Toast.makeText(ShareBrowserActivity.this, "复制成功", |
| | | Toast.LENGTH_SHORT).show(); |
| | | return true; |
| | | } else if (url != null && url.startsWith("yestv://toast")) { |
| | | String murl = url.split("yestv://")[1]; |
| | | String[] params = murl.split("#"); |
| | | byte raw[] = Base64.decode(params[1], Base64.DEFAULT); |
| | | String content = new String(raw); |
| | | Toast.makeText(ShareBrowserActivity.this, content, Toast.LENGTH_LONG).show(); |
| | | return true; |
| | | } |
| | | if (url != null && !url.startsWith("http")) { |
| | | if (url.startsWith("weixin://wap/pay?")) { |
| | | if (Tools.isWeixinAvilible(ShareBrowserActivity.this) == 2) { |
| | | Toast.makeText(ShareBrowserActivity.this, |
| | | "尚未安装微信", Toast.LENGTH_LONG).show(); |
| | | return true; |
| | | } |
| | | Intent intent = new Intent(); |
| | | intent.setAction(Intent.ACTION_VIEW); |
| | | intent.setData(Uri.parse(url)); |
| | | startActivity(intent); |
| | | } else if (url.startsWith("alipays:") || url.startsWith("alipay")) { |
| | | try { |
| | | startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); |
| | | } catch (Exception e) { |
| | | new AlertDialog.Builder(ShareBrowserActivity.this) |
| | | .setMessage("未检测到支付宝客户端,请安装后重试。") |
| | | .setPositiveButton("立即安装", new DialogInterface.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | Uri alipayUrl = Uri.parse("https://d.alipay.com"); |
| | | startActivity(new Intent("android.intent.action.VIEW", alipayUrl)); |
| | | } |
| | | }).setNegativeButton("取消", null).show(); |
| | | } |
| | | } else if (url.startsWith("pinduoduo://")) {//拦截拼多多页面 |
| | | if (ApkUtil.checkAPP(getApplicationContext(), "com.xunmeng.pinduoduo")) { |
| | | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
| | | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | startActivity(intent); |
| | | return true; |
| | | } else { |
| | | return true; |
| | | } |
| | | } else if (url.startsWith("suning://")) {//苏宁 |
| | | if (ApkUtil.checkAPP(getApplicationContext(), "com.suning.mobile.ebuy")) { |
| | | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
| | | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | startActivity(intent); |
| | | return true; |
| | | } else |
| | | return true; |
| | | } else if (url.startsWith("vipshop://")) {//唯品会 |
| | | if (ApkUtil.checkAPP(getApplicationContext(), "com.achievo.vipshop")) { |
| | | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
| | | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | startActivity(intent); |
| | | return true; |
| | | } else |
| | | return true; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | if (url.endsWith(".apk")) { |
| | | Intent intent = new Intent(Intent.ACTION_VIEW); |
| | | intent.addCategory(Intent.CATEGORY_BROWSABLE); |
| | | intent.setData(Uri.parse(url)); |
| | | startActivity(intent); |
| | | } |
| | | Boolean intercept = WebViewUtil.interceptUrl(getApplicationContext(), url); |
| | | if (intercept != null) |
| | | return intercept; |
| | | |
| | | return super.shouldOverrideUrlLoading(view, url); |
| | | } |
| | |
| | | } |
| | | } |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public void onPageStarted(WebView view, String url, Bitmap favicon) { |
| | | super.onPageStarted(view, url, favicon); |
| | | if (view.canGoBack()) { |
| | | tv_top_bar_left2.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_web_close, 0, 0, 0); |
| | | } else { |
| | | tv_top_bar_left2.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); |
| | | } |
| | | } |
| | | }; |
| | | |
| | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | MobclickAgent.onPageStart("网页"); |
| | | if (webview != null) { |
| | | webview.onResume(); |
| | | webview.loadUrl("javascript:yestvcallback.resume()"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | MobclickAgent.onPageEnd("网页"); |
| | | if (webview != null) { |
| | | webview.onPause(); |
| | | } |
| | |
| | | if (mulList.size() == 2 && javaInterface.mList.size() > 0) { |
| | | mulList.addAll(0, javaInterface.mList); |
| | | } |
| | | |
| | | if (mulList.size() == 2 && javaInterface1.mList.size() > 0) { |
| | | mulList.addAll(0, javaInterface1.mList); |
| | | } |
| | | |
| | | |
| | | if (mTopRightPopupWindow != null) { |
| | | v_cover_web.setVisibility(View.VISIBLE); |
| | | mTopRightPopupWindow.showAsDropDown(iv_right); |
| | |
| | | if (javaInterface.mList.size() > 0) |
| | | mulList.addAll(0, javaInterface.mList); |
| | | |
| | | if (javaInterface1.mList.size() > 0) |
| | | mulList.addAll(0, javaInterface1.mList); |
| | | |
| | | shareFromAdapter = new WebTopRightAdapter(this, mulList); |
| | | lv.setAdapter(shareFromAdapter); |
| | | |