| | |
| | | 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.PixelFormat; |
| | |
| | | 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; |
| | |
| | | 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); |
| | | String url = getIntent().getStringExtra("url"); |
| | | String url = "http://192.168.3.122:8848/tejia-web/dsbridge-test.html";//getIntent().getStringExtra("url"); |
| | | originalUrl = url; |
| | | //是否允许粘贴板推荐 |
| | | String clipboradStr = getIntent().getStringExtra("clipboard"); |
| | |
| | | // 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, |
| | |
| | | webview.addJavascriptInterface(javaInterface, "yestv"); |
| | | CustomNavigationJsObject customNavigation = new CustomNavigationJsObject(this); |
| | | webview.addJavascriptInterface(customNavigation, "czb");//第二个参数czb不可更改, |
| | | |
| | | RebateJavaInterfaceBS javaInterface1 = new RebateJavaInterfaceBS(ShareBrowserActivity.this, |
| | | tv_top_bar_middle, tv_top_bar_left2, new TextView(this), iv_right, webview, pd); |
| | | 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); |
| | | } |