From 399ac289f80b7a40aa4210341db6b447cacdcf14 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 09 八月 2022 17:42:33 +0800 Subject: [PATCH] 广告升级,隐私政策整改 --- app/src/main/java/com/tejia/lijin/app/ui/invite/ShareBrowserActivity.java | 159 +++++++++++++++++++--------------------------------- 1 files changed, 58 insertions(+), 101 deletions(-) diff --git a/app/src/main/java/com/tejia/lijin/app/ui/invite/ShareBrowserActivity.java b/app/src/main/java/com/tejia/lijin/app/ui/invite/ShareBrowserActivity.java index 985050a..14e1d73 100644 --- a/app/src/main/java/com/tejia/lijin/app/ui/invite/ShareBrowserActivity.java +++ b/app/src/main/java/com/tejia/lijin/app/ui/invite/ShareBrowserActivity.java @@ -3,19 +3,20 @@ 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 android.os.Bundle; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; -import android.util.Base64; +import wendu.dsbridge.DWebView; + import android.util.Log; import android.view.KeyEvent; import android.view.View; @@ -40,12 +41,14 @@ 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; @@ -68,16 +71,12 @@ 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; @@ -98,7 +97,7 @@ 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; @@ -107,6 +106,7 @@ String mTitle; RebateJavaInterface javaInterface; + RebateJavaInterfaceBS javaInterface1; private FrameLayout fl_full_video; String tag1 = "config/getWebConfig"; @@ -114,16 +114,23 @@ private boolean interceptGoodsDetail; - private String originalUrl=""; + 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"); - originalUrl=url; + originalUrl = url; //鏄惁鍏佽绮樿创鏉挎帹鑽� String clipboradStr = getIntent().getStringExtra("clipboard"); interceptGoodsDetail = getIntent().getBooleanExtra("interceptGoodsDetail", true); @@ -147,7 +154,7 @@ 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); @@ -162,7 +169,7 @@ // 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, @@ -177,7 +184,7 @@ 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); } @@ -199,7 +206,7 @@ webSettings.setPluginState(WebSettings.PluginState.ON); webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);//璁剧疆缂撳瓨妯″紡锛堟牴鎹甤ache-control鍐冲畾鏄惁浠庣綉缁滀笂鍙栨暟鎹�傦級 //鍥㈡补鐗规畩璁剧疆 - if(originalUrl!=null&&originalUrl.contains(".czb365.com")) { + if (originalUrl != null && originalUrl.contains(".czb365.com")) { webSettings.setUserAgentString("BLKS+Android"); } webview.setDrawingCacheEnabled(true); @@ -211,6 +218,12 @@ webview.addJavascriptInterface(javaInterface, "yestv"); CustomNavigationJsObject customNavigation = new CustomNavigationJsObject(this); webview.addJavascriptInterface(customNavigation, "czb");//绗簩涓弬鏁癱zb涓嶅彲鏇存敼锛� + + 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榛樿涓嶆敮鎸佸悓鏃跺姞杞紿ttps鍜孒ttp娣峰悎妯″紡 * WebView鍦ㄥ井淇$綉椤典腑棣栧厛鎵撳紑涓�涓猦ttps缃戝潃锛岀劧鍚庡畠浼氳閲嶅畾鍚戝埌涓�涓猦ttp缃戝潃 @@ -243,7 +256,7 @@ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // Log.e("mResult", "shouldOverrideUrlLoading----" + url); - if (goodsDetail&&interceptGoodsDetail) { + if (goodsDetail && interceptGoodsDetail) { String taoBaoId = TaobaoLinkCutUtil.linkCutId(url); String JDId = null; String PDDId = null; @@ -294,85 +307,9 @@ 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); } @@ -442,13 +379,23 @@ } 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); + } + } }; WebChromeClient webChromeClient = new WebChromeClient() { @Override public boolean onConsoleMessage(ConsoleMessage consoleMessage) { - Log.i("ShareBrowserActivity",consoleMessage.message() +" "+consoleMessage.lineNumber()); + Log.i("ShareBrowserActivity", consoleMessage.message() + " " + consoleMessage.lineNumber()); return super.onConsoleMessage(consoleMessage); } @@ -617,7 +564,11 @@ boolean extend = jsonObject.optJSONObject("data").optBoolean("extend"); // Log.e("mResult", "extend:" + extend); if (extend) {//鏈夋帹骞� - Intent intent = GoodsDetailJumpUtil.getGoodsDetailIntent(getApplicationContext(), goodsType); + + Intent intent = new Intent(getApplicationContext(), GoodsDetailActivity.class); + intent.putExtra("goodsId", goodsId); + intent.putExtra("goodsType", goodsType); + intent.putExtra("id", goodsId); intent.putExtra("from", "baichuanweb"); startActivity(intent); @@ -694,18 +645,15 @@ @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(); } @@ -742,6 +690,12 @@ 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); @@ -805,6 +759,9 @@ 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); -- Gitblit v1.8.0