| | |
| | | package com.weikou.beibeivideo.ui.mine; |
| | | |
| | | import android.Manifest; |
| | | import android.annotation.TargetApi; |
| | | import android.app.Activity; |
| | | import android.app.AlertDialog; |
| | | import android.app.Notification; |
| | | import android.app.NotificationChannel; |
| | | import android.app.NotificationManager; |
| | | import android.content.ActivityNotFoundException; |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.graphics.BitmapFactory; |
| | |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.os.Message; |
| | | import android.provider.MediaStore; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.v4.app.NotificationCompat; |
| | | import android.util.Log; |
| | |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.view.ViewGroup; |
| | | import android.widget.LinearLayout.LayoutParams; |
| | | import android.widget.ProgressBar; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.media.VideoDetailActivity; |
| | | import com.weikou.beibeivideo.ui.media.VideoDetailActivity2; |
| | | import com.weikou.beibeivideo.util.ConfigUtil; |
| | | import com.weikou.beibeivideo.util.browser.BWJavaInterface; |
| | | import com.weikou.beibeivideo.util.browser.PPJavaInterface; |
| | | import com.weikou.beibeivideo.util.downutil.DownFiles; |
| | | import com.weikou.beibeivideo.util.downutil.DownFiles.IProgress; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | | import com.weikou.beibeivideo.util.x5.X5WebView; |
| | | |
| | | import java.util.Map; |
| | | import java.io.IOException; |
| | | import java.util.Set; |
| | | |
| | | public class BrowserActivity extends BaseActivity implements OnClickListener, PermissionInterface { |
| | | private final static String TAG = "BrowserActivity"; |
| | |
| | | ProgressBar progressBar; |
| | | private PermissionHelper mPermissionsChecker; // 权限检测器 检测是否有储存卡写入读取权限 |
| | | |
| | | private Set<String> webSpeedUpHost; |
| | | |
| | | private WebResourceResponse replaceLocalResource(String url) throws IOException { |
| | | if (url == null) |
| | | return null; |
| | | WebResourceResponse response = null; |
| | | if (webSpeedUpHost == null) { |
| | | webSpeedUpHost = ConfigUtil.getWebSpeedUpHost(this); |
| | | } |
| | | |
| | | |
| | | String host = null; |
| | | try { |
| | | Uri uri = Uri.parse(url); |
| | | host = uri.getHost(); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | if (webSpeedUpHost != null && webSpeedUpHost.contains(host)) { |
| | | if (url.endsWith("2.1.4/jquery.min.js")) { |
| | | response = new WebResourceResponse("*", "UTF-8", getAssets().open("js/jquery-2.1.4.min.js")); |
| | | } else if (url.endsWith("vue-2.6.12.min.js")) { |
| | | response = new WebResourceResponse("*", "UTF-8", getAssets().open("js/vue-2.6.12.min.js")); |
| | | } |
| | | } |
| | | return response; |
| | | } |
| | | |
| | | |
| | | private void initX5WebView() { |
| | | webview = findViewById(R.id.webview); |
| | |
| | | webview.setWebViewClient(new WebViewClient() { |
| | | @Override |
| | | public boolean shouldOverrideUrlLoading(WebView view, String url) { |
| | | Log.i(TAG, url); |
| | | if (url != null && url.startsWith("weixin://")) { |
| | | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
| | | startActivity(intent); |
| | |
| | | startActivity(intent); |
| | | } |
| | | return true; |
| | | } else if (url.startsWith("tenvideo2://") || url.startsWith("iqiyi://")) { |
| | | try { |
| | | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
| | | startActivity(intent); |
| | | }catch(Exception e){ |
| | | |
| | | } |
| | | return true; |
| | | } else if (url != null && (!url.startsWith("http"))) { |
| | | return true; |
| | | } |
| | |
| | | @Override |
| | | public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) { |
| | | } |
| | | |
| | | @Override |
| | | public WebResourceResponse shouldInterceptRequest(WebView webView, String url) { |
| | | WebResourceResponse response = null; |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { |
| | | response = super.shouldInterceptRequest(webView, url); |
| | | try { |
| | | WebResourceResponse newResponse = replaceLocalResource(url); |
| | | if (newResponse != null) |
| | | response = newResponse; |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return response; |
| | | } |
| | | |
| | | @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| | | @Override |
| | | public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { |
| | | WebResourceResponse response = super.shouldInterceptRequest(view, request); |
| | | String url = String.valueOf(request.getUrl()); |
| | | try { |
| | | WebResourceResponse newResponse = replaceLocalResource(url); |
| | | if (newResponse != null) |
| | | response = newResponse; |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return response; |
| | | } |
| | | |
| | | }); |
| | | |
| | | webview.setWebChromeClient(new WebChromeClient() { |
| | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | MobclickAgent.onPageStart("网页"); |
| | | // webview.reload(); |
| | | if (webview != null) { |
| | | webview.loadUrl("javascript:onResume()"); |
| | | } |
| | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | MobclickAgent.onPageEnd("网页"); |
| | | } |
| | | |
| | | @Override |