Ver código fonte

内容太多, 不易展示

songw 1 ano atrás
pai
commit
f53f6659aa

+ 20 - 5
app/build.gradle

@@ -29,6 +29,10 @@ android {
                 includeCompileClasspath = true
             }
         }
+        ndk {
+            //设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so)
+            abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
+        }
     }
     buildTypes {
         debug {
@@ -44,6 +48,12 @@ android {
         exclude 'META-INF/NOTICE.txt'
     }
 
+    lintOptions {
+        disable 'MissingTranslation'
+        checkReleaseBuilds false
+    }
+    useLibrary 'org.apache.http.legacy'
+
     applicationVariants.all { variant ->
         variant.outputs.all { output ->
             def outputFile = output.outputFile
@@ -103,9 +113,13 @@ dependencies {
     implementation(deps.MultiTypeFilePicker) {
         exclude group: "com.android.support"
     }
-    implementation  'com.umeng.umsdk:common:9.4.0'// 必选
-    implementation  'com.umeng.umsdk:asms:1.2.3'// 必选
-    implementation 'com.umeng.umsdk:apm:1.4.0' // 错误分析升级为独立SDK,看crash数据请一定集成,可选
+
+    // 友盟基础组件库(所有友盟业务SDK都依赖基础组件库)
+    implementation 'com.umeng.umsdk:common:9.4.4' //(必选)
+    implementation 'com.umeng.umsdk:asms:1.4.1' // asms包依赖(必选)
+    implementation 'com.umeng.umsdk:apm:1.5.2' // U-APM包依赖(必选) 错误分析升级为独立SDK,看crash数据请一定集成
+
+    //eventbus
     implementation 'org.greenrobot:eventbus:3.2.0'
     //XBanner
     implementation 'com.xhb:xbanner:1.3.1'
@@ -123,9 +137,10 @@ dependencies {
     implementation 'com.github.bumptech.glide:glide:4.12.0'
     annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
 
+    //implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
+    implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
 
-    implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
-
+//    implementation 'com.tom-roush:pdfbox-android:2.0.27.0'
 }
 
 def getVersionName() {

+ 12 - 0
app/proguard-rules.pro

@@ -19,3 +19,15 @@
 # If you keep the line number information, uncomment this to
 # hide the original source file name.
 #-renamesourcefileattribute SourceFile
+
+#友盟混淆
+-keep class com.umeng.** {*;}
+-keep class org.repackage.** {*;}
+-keep class com.uyumao.** { *; }
+-keepclassmembers class * {
+   public <init> (org.json.JSONObject);
+}
+-keepclassmembers enum * {
+    public static **[] values();
+    public static ** valueOf(java.lang.String);
+}

+ 15 - 0
app/src/main/AndroidManifest.xml

@@ -53,11 +53,26 @@
             android:icon="@mipmap/icon"
             android:label="@string/title_activity_menu"
             android:windowSoftInputMode="adjustPan|stateHidden" />
+
+        <activity
+            android:name="com.uas.kesai_esop.activity.PdfsActivity4"
+            android:icon="@mipmap/icon"
+            android:label="@string/title_activity_menu"
+            android:windowSoftInputMode="adjustPan|stateHidden" />
+
         <activity
             android:name="com.uas.kesai_esop.activity.PdfsActivity2"
             android:icon="@mipmap/icon"
             android:label="@string/title_activity_menu"
+            android:screenOrientation="portrait"
             android:windowSoftInputMode="adjustPan|stateHidden" />
+        <activity
+            android:name="com.uas.kesai_esop.activity.WebViewDPF"
+            android:icon="@mipmap/icon"
+            android:label="@string/title_activity_menu"
+            android:windowSoftInputMode="adjustPan|stateHidden" />
+
+
         <activity
             android:name="com.uas.kesai_esop.activity.BannerActivity"
             android:icon="@mipmap/icon"

+ 71 - 57
app/src/main/java/com/uas/kesai_esop/activity/IndexActivity.java

@@ -216,6 +216,15 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
     private BeanSop urlBean;
     private String keystep;
 
+    private Handler mHandler = new Handler();
+    private Runnable runnable = new Runnable() {
+        @Override
+        public void run() {
+            //mHandler.postDelayed(this, 3000);
+            getSC_CODEData();
+        }
+    };
+
     @Override
     protected void onDestroy() {
         //        SharedPreUtil.removeAll(getApplicationContext());
@@ -329,8 +338,10 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
 
                 //                getPdfOrImage("");
                 if (filenametcp.contains(".pdf") || filenametcp.contains(".PDF")) {
-//                    Intent intent = new Intent(IndexActivity.this, PdfsActivity.class);
-                    Intent intent = new Intent(IndexActivity.this, PdfsActivity2.class);
+//                                        Intent intent = new Intent(IndexActivity.this, PdfsActivity.class);
+//                    Intent intent = new Intent(IndexActivity.this, PdfsActivity2.class);
+                    //                    Intent intent = new Intent(IndexActivity.this, PdfsActivity3.class);
+                                        Intent intent = new Intent(IndexActivity.this, PdfsActivity4.class);
                     intent.putStringArrayListExtra("lists", selectedItemList);
                     intent.putExtra("filename", filenametcp);
                     startActivity(intent);
@@ -426,26 +437,25 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
                 tv_ps_stepcode.setText(ps_stepcode);
                 mPositionR.clearFocus();
                 //                tv_pr_spec.setText(pr_spec);
-                mPositionR.setText(ps_prodcode);
+                //mPositionR.setText(ps_prodcode);
+                mPositionR.setText(itemCode);
                 mPositionR.clearFocus();
 
                 //                tv_pr_detail.setText(pr_detail);
                 //                mPositionR.setSelection(mPositionR.getText().toString().trim().length());
                 myAdapter.notifyDataSetChanged();
                 getPdfOrImage(itemCode);
-
-
             }
         });
         mPositionR.setOnFocusChangeListener(new View.OnFocusChangeListener() {
             @Override
             public void onFocusChange(View v, boolean hasFocus) {
+                //                startActivity(new Intent(IndexActivity.this,WebViewDPF.class));
                 if (hasFocus) {
                     rv_data.setVisibility(View.VISIBLE);
                 } else {
                     rv_data.setVisibility(View.GONE);
                 }
-
             }
         });
         mPositionR.addTextChangedListener(new TextWatcher() {
@@ -459,10 +469,14 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
 
             @Override
             public void afterTextChanged(Editable s) {
-                getSC_CODEData();
+                if (s.toString().length() > 3) {
+                    mHandler.removeCallbacks(runnable); //取消执行
+                    mHandler.postDelayed(runnable, 3000); //延时执行
+//                    mHandler.post(runnable); //立即执行
+                }
             }
-
         });
+
         //        mPositionR.setKeyListener(new KeyListener() {
         //            @Override
         //            public int getInputType() {
@@ -953,19 +967,19 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
                                 return;
                             }
 
-//                            if(filename.contains("-") && filename.contains(at_gvtext.getText().toString().trim())){
-//                                String path = urlBean.getPath();
-//                                String str2 = new String(Base64.decode(path.getBytes(), Base64.DEFAULT));
-//                                Log.e("str2==", str2);
-//                                list.add(str2);
-//                                keystep = urlBean.getKeystep();
-//                            }else if (filename.equals(at_gvtext.getText().toString().trim())) {
-//                                String path = urlBean.getPath();
-//                                String str2 = new String(Base64.decode(path.getBytes(), Base64.DEFAULT));
-//                                Log.e("str2==", str2);
-//                                list.add(str2);
-//                                keystep = urlBean.getKeystep();
-//                            }
+                            //                            if(filename.contains("-") && filename.contains(at_gvtext.getText().toString().trim())){
+                            //                                String path = urlBean.getPath();
+                            //                                String str2 = new String(Base64.decode(path.getBytes(), Base64.DEFAULT));
+                            //                                Log.e("str2==", str2);
+                            //                                list.add(str2);
+                            //                                keystep = urlBean.getKeystep();
+                            //                            }else if (filename.equals(at_gvtext.getText().toString().trim())) {
+                            //                                String path = urlBean.getPath();
+                            //                                String str2 = new String(Base64.decode(path.getBytes(), Base64.DEFAULT));
+                            //                                Log.e("str2==", str2);
+                            //                                list.add(str2);
+                            //                                keystep = urlBean.getKeystep();
+                            //                            }
 
                             String path = urlBean.getPath();
                             String str2 = new String(Base64.decode(path.getBytes(), Base64.DEFAULT));
@@ -985,7 +999,7 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
                             }
                             //                getPdfOrImage("");
                             if (filenametcp.contains(".pdf") || filenametcp.contains(".PDF")) {
-//                                Intent intent = new Intent(IndexActivity.this, PdfsActivity.class);
+                                //                                Intent intent = new Intent(IndexActivity.this, PdfsActivity.class);
                                 Intent intent = new Intent(IndexActivity.this, PdfsActivity2.class);
                                 intent.putStringArrayListExtra("lists", list);
                                 intent.putExtra("filename", filenametcp);
@@ -1740,7 +1754,7 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
      *
      */
 
-    private void getSC_CODEData() {
+    private synchronized void getSC_CODEData() {
         Log.e("aaa", "触发调用接口: " + mPositionR.getText().toString().trim());
         VollyRequest.getInstance().stringRequest(mStringRequest,
                 new HttpParams.Builder()
@@ -1754,42 +1768,42 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
                     public void onSuccess(int flag, Object o) throws Exception {
                         progressDialog.dismiss();
                         mList.clear();
-                        Log.e("aaa", "正确的值: " + o.toString());
-                        Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
-                        if (isSuccess) {
-                            JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(), "data");
-                            if (dataArray == null || dataArray.size() == 0) {
-                                CommonUtil.toastNoRepeat(IndexActivity.this, "未搜索到匹配数据");
-                                myAdapter.setmList(mList);
-                                myAdapter.notifyDataSetChanged();
-                                return;
-                            }
-                            for (Object index : dataArray) {
-                                JSONObject data = (JSONObject) index;
-                                ComDataBean bean = new ComDataBean();
-                                bean.setPS_CODE(data.getString("PS_CODE"));
-                                bean.setPR_SPEC(data.getString("PR_SPEC"));
-                                bean.setPR_DETAIL(data.getString("PR_DETAIL"));
-                                if (data.getString("PS_PRODCODE") == null) {
-                                    bean.setPS_PRODCODE("null");
-                                } else {
-                                    bean.setPS_PRODCODE(data.getString("PS_PRODCODE"));
-                                }
-                                if (data.getString("PS_STEPCODE") == null) {
-                                    bean.setPS_STEPCODE("null");
-                                } else {
-                                    bean.setPS_STEPCODE(data.getString("PS_STEPCODE"));
+                        try {
+                            Log.e("aaa", "getSC_CODEData正确的值: " + o.toString());
+                            Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
+                            if (isSuccess) {
+                                JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(), "data");
+                                if (dataArray == null || dataArray.size() == 0) {
+                                    CommonUtil.toastNoRepeat(IndexActivity.this, "未搜索到匹配数据");
+                                    myAdapter.setmList(mList);
+                                    myAdapter.notifyDataSetChanged();
+                                    return;
                                 }
+                                for (Object index : dataArray) {
+                                    JSONObject data = (JSONObject) index;
+                                    ComDataBean bean = new ComDataBean();
+                                    bean.setPS_CODE(data.getString("PS_CODE"));
+                                    bean.setPR_SPEC(data.getString("PR_SPEC"));
+                                    bean.setPR_DETAIL(data.getString("PR_DETAIL"));
+                                    if (data.getString("PS_PRODCODE") == null) {
+                                        bean.setPS_PRODCODE("null");
+                                    } else {
+                                        bean.setPS_PRODCODE(data.getString("PS_PRODCODE"));
+                                    }
+                                    if (data.getString("PS_STEPCODE") == null) {
+                                        bean.setPS_STEPCODE("null");
+                                    } else {
+                                        bean.setPS_STEPCODE(data.getString("PS_STEPCODE"));
+                                    }
 
-                                mList.add(bean);
+                                    mList.add(bean);
+                                }
+                                myAdapter.setmList(mList);
+                                myAdapter.notifyDataSetChanged();
                             }
-                            myAdapter.setmList(mList);
-                            myAdapter.notifyDataSetChanged();
-
-                        } else {
-
+                        } catch (Exception e) {
+                            e.printStackTrace();
                         }
-
                     }
 
                     @Override
@@ -1948,7 +1962,7 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
         @Override
         protected void convert(BaseViewHolder helper, ComDataBean item) {
             helper.setText(R.id.macode_Tv, item.getPS_CODE());
-            helper.setText(R.id.remark_Tv, item.getPS_PRODCODE());
+            helper.setText(R.id.remark_Tv, item.getPR_DETAIL());
             LinearLayout line_true = helper.itemView.findViewById(R.id.line_true);
             if (item.getChecked()) {
                 line_true.setSelected(true);
@@ -2220,7 +2234,7 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
             }
             //                getPdfOrImage("");
             if (filenametcp.contains(".pdf") || filenametcp.contains(".PDF")) {
-//                Intent intent = new Intent(IndexActivity.this, PdfsActivity.class);
+                //                Intent intent = new Intent(IndexActivity.this, PdfsActivity.class);
                 Intent intent = new Intent(IndexActivity.this, PdfsActivity2.class);
                 intent.putStringArrayListExtra("lists", list);
                 intent.putExtra("filename", filenametcp);

+ 91 - 13
app/src/main/java/com/uas/kesai_esop/activity/PdfsActivity.java

@@ -2,6 +2,7 @@ package com.uas.kesai_esop.activity;
 
 import android.content.Context;
 import android.content.Intent;
+import android.graphics.Bitmap;
 import android.graphics.Color;
 import android.os.Build;
 import android.os.Bundle;
@@ -12,12 +13,15 @@ import android.util.Log;
 import android.view.View;
 import android.view.Window;
 import android.view.WindowManager;
+import android.webkit.WebChromeClient;
 import android.webkit.WebSettings;
 import android.webkit.WebView;
+import android.webkit.WebViewClient;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 
 import com.uas.kesai_esop.R;
+import com.uas.kesai_esop.util.BASE64Encoder;
 import com.uas.kesai_esop.util.CommonUtil;
 import com.uas.kesai_esop.util.DateFormatUtil;
 
@@ -25,6 +29,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.net.URL;
@@ -49,6 +54,10 @@ public class PdfsActivity extends AppCompatActivity {
     private String filename;
     private String filepath;
 
+    private String docPath = "http://gps15.com/app/sysm/1.pdf";
+    private WebView webView;
+
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -63,7 +72,7 @@ public class PdfsActivity extends AppCompatActivity {
             Log.e("smd5", filepath);
         }
 
-        WebView webView = findViewById(R.id.webView);
+        webView = findViewById(R.id.webView);
         ImageView iv_fullscreen = findViewById(R.id.iv_fullscreen);
         ImageView iv_download = findViewById(R.id.iv_download);
         LinearLayout iv_goback = findViewById(R.id.iv_goback);
@@ -71,19 +80,83 @@ public class PdfsActivity extends AppCompatActivity {
         iv_back.setColorFilter(this.getResources().getColor(R.color.zise));
         iv_fullscreen.setColorFilter(this.getResources().getColor(R.color.zise));
         iv_download.setColorFilter(this.getResources().getColor(R.color.zise));
-        WebSettings webSettings = webView.getSettings();
-        webSettings.setJavaScriptEnabled(true);
-        webSettings.setPluginState(WebSettings.PluginState.ON);
-        webSettings.setAllowContentAccess(true);
-        webSettings.setAllowFileAccess(true);
-        webSettings.setAllowFileAccessFromFileURLs(true);
-        webSettings.setAllowUniversalAccessFromFileURLs(true);
-        webView.loadUrl("file:///android_asset/web/viewer.html?file="+filepath);
+
+//        WebSettings webSettings = webView.getSettings();
+//        webSettings.setJavaScriptEnabled(true);
+//        webSettings.setPluginState(WebSettings.PluginState.ON);
+//        webSettings.setAllowContentAccess(true);
+//        webSettings.setAllowFileAccess(true);
+//        webSettings.setAllowFileAccessFromFileURLs(true);
+//        webSettings.setAllowUniversalAccessFromFileURLs(true);
+//        //设置加载进来的页面自适应手机屏幕
+//        webSettings.setUseWideViewPort(true);
+//        webSettings.setLoadWithOverviewMode(true);
+//        //支持通过JS打开新窗口
+//        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
+//        webSettings.setGeolocationEnabled(true);
+//        webSettings.setDomStorageEnabled(true);
+//        webSettings.setAppCacheEnabled(false);
+
+
+        webView.setWebViewClient(new WebViewClient() {
+            @Override
+            public boolean shouldOverrideUrlLoading(WebView view, String url) {
+                // 返回值是true的时候控制去WebView打开,为false调用系统浏览器或第三方浏览器
+                view.loadUrl(url);
+                return true;
+            }
+        });
+        WebSettings settings = webView.getSettings();
+        settings.setSavePassword(false);
+        settings.setJavaScriptEnabled(true);
+        settings.setAllowFileAccessFromFileURLs(true);
+        settings.setAllowUniversalAccessFromFileURLs(true);
+        settings.setBuiltInZoomControls(true);
+        webView.setWebChromeClient(new WebChromeClient());
+
+        webView.setWebViewClient(new WebViewClient() {
+            @Override
+            public boolean shouldOverrideUrlLoading(WebView view, String url) {
+                view.loadUrl(url);
+                return true;
+            }
+            @Override
+            public void onPageStarted(WebView view, String url, Bitmap favicon) {
+                super.onPageStarted(view, url, favicon);
+//                findViewById(R.id.pb).setVisibility(View.VISIBLE);
+            }
+            @Override
+            public void onPageFinished(WebView view, String url) {
+                super.onPageFinished(view, url);
+//                findViewById(R.id.pb).setVisibility(View.GONE);
+            }
+        });
+
+        if (!"".equals(docPath)) {
+            byte[] bytes = null;
+            try {// 获取以字符编码为utf-8的字符
+                bytes = docPath.getBytes("UTF-8");
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            if (bytes != null) {
+                docPath = new BASE64Encoder().encode(bytes);// BASE64转码
+            }
+        }
+
+//        webView.loadUrl("file:///android_asset/web/viewer.html?file="+docPath);
 //        webView.loadUrl("file:///android_asset/web/viewer.html?file="+filepath);
+//        webView.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file="+filepath);
+//        webView.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file="+docPath);
+        webView.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file=" + docPath);
+//        webView.loadUrl("file:///android_asset/pdfjs/web/viewer.html?" + docPath);
 //        webView.loadUrl("http://docs.google.com/gview?embedded=true&url=" + filepath);
-        webView.getSettings().setBuiltInZoomControls(true);
-        webView.getSettings().setSupportZoom(true);
-        webView.getSettings().setDisplayZoomControls(false);//不显示缩放按钮
+//        webView.loadUrl(filepath);
+//        webView.loadUrl(docPath);
+
+//        webView.getSettings().setBuiltInZoomControls(true);
+//        webView.getSettings().setSupportZoom(true);
+//        webView.getSettings().setDisplayZoomControls(false);//不显示缩放按钮
 
         iv_goback.setOnClickListener(new View.OnClickListener() {
             @Override
@@ -131,9 +204,14 @@ public class PdfsActivity extends AppCompatActivity {
             }
         });
 
+    }
 
-
+    @Override
+    protected void onResume() {
+        super.onResume();
+        webView.resumeTimers();
     }
+
     /**
      * 判断路径是否存在
      *

+ 142 - 68
app/src/main/java/com/uas/kesai_esop/activity/PdfsActivity2.java

@@ -1,8 +1,12 @@
 package com.uas.kesai_esop.activity;
 
+import android.content.ActivityNotFoundException;
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.res.Configuration;
 import android.graphics.Color;
+import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Environment;
@@ -15,8 +19,10 @@ import android.view.WindowManager;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
+import android.widget.Toast;
 
 import com.github.barteksc.pdfviewer.PDFView;
+import com.github.barteksc.pdfviewer.util.FitPolicy;
 import com.uas.kesai_esop.R;
 import com.uas.kesai_esop.util.CommonUtil;
 import com.uas.kesai_esop.util.DateFormatUtil;
@@ -44,7 +50,7 @@ public class PdfsActivity2 extends AppCompatActivity {
     private boolean useThemeStatusBarColor = false;//是否使用特殊的标题栏背景颜色,android5.0以上可以设置状态栏背景色,如果不使用则使用透明色值
     private boolean useStatusBarColor = true;//是否使用状态栏文字和图标为暗色,如果状态栏采用了白色系,则需要使状态栏和图标为暗色,android6.0以上可以设置
     private int option;
-    private boolean fullscreen=false;
+    private boolean fullscreen = false;
     private Context context;
     private String destDirPath;
     private String filename;
@@ -52,6 +58,7 @@ public class PdfsActivity2 extends AppCompatActivity {
     private PDFView pdfView;
     private String filenametime;
     private int rotate = -90;
+    private String pdffilePath;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -59,11 +66,11 @@ public class PdfsActivity2 extends AppCompatActivity {
         setContentView(R.layout.act_pdf);
 
         window = getWindow();
-        context=this;
+        context = this;
         Intent intent = getIntent();
         ArrayList<String> lists = intent.getStringArrayListExtra("lists");
         filename = intent.getStringExtra("filename");
-        for (int i=0;i<lists.size();i++){
+        for (int i = 0; i < lists.size(); i++) {
             filepath = lists.get(i);
             Log.e("smd5", filepath);
         }
@@ -79,20 +86,29 @@ public class PdfsActivity2 extends AppCompatActivity {
         iv_back.setColorFilter(this.getResources().getColor(R.color.zise));
         iv_fullscreen.setColorFilter(this.getResources().getColor(R.color.zise));
 
-//        WebView webView = findViewById(R.id.webView);
-//        WebSettings webSettings = webView.getSettings();
-//        webSettings.setJavaScriptEnabled(true);
-//        webSettings.setPluginState(WebSettings.PluginState.ON);
-//        webSettings.setAllowContentAccess(true);
-//        webSettings.setAllowFileAccess(true);
-//        webSettings.setAllowFileAccessFromFileURLs(true);
-//        webSettings.setAllowUniversalAccessFromFileURLs(true);
-////        webView.loadUrl("file:///android_asset/web/viewer.html?file="+filepath);
-////        webView.loadUrl("file:///android_asset/web/viewer.html?file="+filepath);
-//        webView.loadUrl("http://docs.google.com/gview?embedded=true&url=" + filepath);
-//        webView.getSettings().setBuiltInZoomControls(true);
-//        webView.getSettings().setSupportZoom(true);
-//        webView.getSettings().setDisplayZoomControls(false);//不显示缩放按钮
+        int screen = getResources().getConfiguration().orientation;
+        if (screen == Configuration.ORIENTATION_LANDSCAPE) {    //横屏
+            Log.e("aaa", "当前是横屏");
+        }else if (screen == Configuration.ORIENTATION_PORTRAIT) {   //竖屏
+            Log.e("aaa", "当前是竖屏");
+        }
+
+        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);  //切竖屏
+
+        //        WebView webView = findViewById(R.id.webView);
+        //        WebSettings webSettings = webView.getSettings();
+        //        webSettings.setJavaScriptEnabled(true);
+        //        webSettings.setPluginState(WebSettings.PluginState.ON);
+        //        webSettings.setAllowContentAccess(true);
+        //        webSettings.setAllowFileAccess(true);
+        //        webSettings.setAllowFileAccessFromFileURLs(true);
+        //        webSettings.setAllowUniversalAccessFromFileURLs(true);
+        ////        webView.loadUrl("file:///android_asset/web/viewer.html?file="+filepath);
+        ////        webView.loadUrl("file:///android_asset/web/viewer.html?file="+filepath);
+        //        webView.loadUrl("http://docs.google.com/gview?embedded=true&url=" + filepath);
+        //        webView.getSettings().setBuiltInZoomControls(true);
+        //        webView.getSettings().setSupportZoom(true);
+        //        webView.getSettings().setDisplayZoomControls(false);//不显示缩放按钮
 
         iv_goback.setOnClickListener(new View.OnClickListener() {
             @Override
@@ -104,27 +120,35 @@ public class PdfsActivity2 extends AppCompatActivity {
         iv_fullscreen.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {//全屏
-                if (fullscreen==false){
-                    fullscreen=true;
+                if (fullscreen == false) {
+                    fullscreen = true;
                     getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                     iv_fullscreen.setImageResource(R.drawable.not_fullscreen);
-                }else {
-                    fullscreen=false;
+                } else {
+                    fullscreen = false;
                     getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                     iv_fullscreen.setImageResource(R.drawable.fullscreen);
                 }
-
             }
         });
 
         tv_rotate.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                rotate -= 90;
-                if (rotate <= -360) {
-                    rotate = -90;
+//                rotate -= 90;
+//                if (rotate <= -360) {
+//                    rotate = -90;
+//                }
+//                pdfView.setRotation(rotate);
+
+                int screen = getResources().getConfiguration().orientation;
+                if (screen == Configuration.ORIENTATION_LANDSCAPE) {    //横屏
+                    Log.e("aaa", "当前是竖屏");
+                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);  //切竖屏
+                }else if (screen == Configuration.ORIENTATION_PORTRAIT) {   //竖屏
+                    Log.e("aaa", "当前是横屏");
+                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); //切横屏
                 }
-                pdfView.setRotation(rotate);
             }
         });
 
@@ -132,9 +156,9 @@ public class PdfsActivity2 extends AppCompatActivity {
             @Override
             public void run() {
                 boolean pathExist = isPathExist(destDirPath);
-                if (pathExist==true){
+                if (pathExist == true) {
                     downloadFile1(filepath, destDirPath);
-                }else {
+                } else {
                     try {
                         CreateText(filepath, destDirPath);
                     } catch (IOException e) {
@@ -145,6 +169,7 @@ public class PdfsActivity2 extends AppCompatActivity {
         }).start();
 
     }
+
     /**
      * 判断路径是否存在
      *
@@ -158,24 +183,25 @@ public class PdfsActivity2 extends AppCompatActivity {
         }
         return false;
     }
+
     //创建文件夹及文件
-    public void CreateText(String filepath,String destDirPath) throws IOException {
+    public void CreateText(String filepath, String destDirPath) throws IOException {
         File file = new File(destDirPath);
         if (!file.exists()) {
             try {
                 //按照指定的路径创建文件夹
                 file.mkdirs();
-                downloadFile1(filepath,destDirPath);
+                downloadFile1(filepath, destDirPath);
             } catch (Exception e) {
                 // TODO: handle exception
             }
         }
-
     }
-    public void downloadFile1(String urlPath,String path) {
-        try{
+
+    public void downloadFile1(String urlPath, String path) {
+        try {
             final long startTime = System.currentTimeMillis();
-            Log.i("DOWNLOAD","startTime="+startTime);
+            Log.i("DOWNLOAD", "startTime=" + startTime);
             //下载函数
             filenametime = DateFormatUtil.getProofTime();
             //获取文件名
@@ -184,34 +210,35 @@ public class PdfsActivity2 extends AppCompatActivity {
             conn.connect();
             InputStream is = conn.getInputStream();
             int fileSize = conn.getContentLength();//根据响应获取文件大小
-            if (fileSize <= 0) throw new RuntimeException("无法获知文件大小 ");
-            if (is == null) throw new RuntimeException("stream is null");
+            if (fileSize <= 0)
+                throw new RuntimeException("无法获知文件大小 ");
+            if (is == null)
+                throw new RuntimeException("stream is null");
             File file1 = new File(path);
-            if(!file1.exists()){
+            if (!file1.exists()) {
                 file1.mkdirs();
             }
             //把数据存入路径+文件名
-            FileOutputStream fos = new FileOutputStream(path+"/"+ filenametime +filename);
+            FileOutputStream fos = new FileOutputStream(path + "/" + filenametime + filename);
             byte buf[] = new byte[1024];
             int downLoadFileSize = 0;
-            do{
+            do {
                 //循环读取
                 int numread = is.read(buf);
-                if (numread == -1)
-                {
+                if (numread == -1) {
                     break;
                 }
                 fos.write(buf, 0, numread);
                 downLoadFileSize += numread;
                 //更新进度条
             } while (true);
-            Log.i("DOWNLOAD","download success");
-            Log.i("DOWNLOAD","totalTime="+ (System.currentTimeMillis() - startTime));
-            Log.i("DOWNLOAD","文件保存到:"+path);
+            Log.i("DOWNLOAD", "download success");
+            Log.i("DOWNLOAD", "totalTime=" + (System.currentTimeMillis() - startTime));
+            Log.i("DOWNLOAD", "文件保存到:" + path);
             Message message = handler.obtainMessage();
             message.what = 1;
-            message.obj = path+"/"+ filenametime +filename;
-//            handler.sendEmptyMessage(0);
+            message.obj = path + "/" + filenametime + filename;
+            //            handler.sendEmptyMessage(0);
             handler.sendMessage(message);
             is.close();
         } catch (Exception ex) {
@@ -219,7 +246,6 @@ public class PdfsActivity2 extends AppCompatActivity {
         }
     }
 
-
     private Handler handler = new Handler() {
 
         @Override
@@ -227,24 +253,19 @@ public class PdfsActivity2 extends AppCompatActivity {
             //CommonUtil.toastNoRepeat(context,"文件保存到"+destDirPath);
             switch (msg.what) {
                 case 1:
-                    String pdffilePath = (String) msg.obj;
+                    pdffilePath = (String) msg.obj;
+                    Log.e("aaa", "PDF文件路径是:" + pdffilePath);
                     getPdf(pdffilePath);
 
-//                    pdfView.fromAsset(pdffilePath)
-//                            .enableSwipe(true) // 允许滑动翻页
-//                            .swipeHorizontal(false) // 垂直翻页
-//                            .enableDoubletap(true) // 允许双击缩放
-//                            .defaultPage(0) // 默认显示第一页
-//                            .load();
                     break;
             }
         }
 
     };
 
-
     /**
      * 预览本地 pdf 文件
+     *
      * @param filePath 本地文件完整路径
      */
     private void getPdf(String filePath) {
@@ -254,11 +275,48 @@ public class PdfsActivity2 extends AppCompatActivity {
                 try {
                     InputStream in = new FileInputStream(file);
                     if (in != null) {
+                        //                        Class<?> clazz = pdfView.getClass();
+                        //                        Method method = clazz.getDeclaredMethod("setPageFitPolicy", FitPolicy.class);
+                        //                        method.setAccessible(true); // 设置为true以访问私有方法
+                        //                        method.invoke(pdfView, FitPolicy.HEIGHT); // 传递包装对象而非原始值
+                        //                        Log.e("aaa", "反射的值是:" + pdfView.getPageFitPolicy());
+
+                        pdfView.zoomTo(50);
+                        pdfView.setSwipeEnabled(false);
+
                         pdfView.fromStream(in)
-                                .enableAnnotationRendering(true) //可以显示电子章
+                                // .enableAnnotationRendering(true) //可以显示电子章
+                                .pages(0, 2, 1)     // 加载第0, 2, 1页(从0开始计数
+                                .enableDoubletap(true)  //启用双击缩放
+                                .enableAnnotationRendering(true) // 启用注释渲染
+//                                .swipeHorizontal(false)     //启用水平滑动
+                                .swipeHorizontal(true)     //启用垂直滑动
+                                .pageFitPolicy(FitPolicy.BOTH)     //修改策略模式,完全展示
+                                //                                .onPageChange(new OnPageChangeListener() {
+                                //                                    @Override
+                                //                                    public void onPageChanged(int page, int pageCount) {
+                                //                                        Log.e("aaa", "滑动页数:" + page);
+                                //                                        Log.e("aaa", "滑动页数总数:" + pageCount);
+                                //                                       // pdfView.fitToWidth(0);
+                                //                                    }
+                                //                                })
+
+//                                                        .onRender(new OnRenderListener() {      //pdf文档加载完成后才能使用
+//                                                            @Override
+//                                                            public void onInitiallyRendered(int nbPages) {
+//                                                                Log.e("aaa", "初始加载页数:" + nbPages);
+//                                                                pdfView.fitToWidth(nbPages-1);
+//                                                            }
+//                                                        })
+                                .defaultPage(0)
                                 .load();
                     }
 
+                    //旋转90度
+//                                        pdfView.setRotation(-90);
+
+                    //openPDFWithSystemViewer(PdfsActivity2.this,pdffilePath);
+
                     //                    pdfView.fromAsset(pdffilePath)
                     //                            .enableSwipe(true) // 允许滑动翻页
                     //                            .swipeHorizontal(false) // 垂直翻页
@@ -270,7 +328,19 @@ public class PdfsActivity2 extends AppCompatActivity {
                 }
             }
         } else {
-            CommonUtil.toastNoRepeat(context,"文件不存在");
+            CommonUtil.toastNoRepeat(context, "文件不存在");
+        }
+    }
+
+    // 使用系统PDF Viewer打开PDF
+    public void openPDFWithSystemViewer(Context context, String pdfPath) {
+        Intent intent = new Intent(Intent.ACTION_VIEW);
+        intent.setDataAndType(Uri.parse("file://" + pdfPath), "application/pdf");
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        try {
+            context.startActivity(intent);
+        } catch (ActivityNotFoundException e) {
+            Toast.makeText(context, "请确保安装了可以处理PDF文件的应用。", Toast.LENGTH_LONG).show();
         }
     }
 
@@ -295,31 +365,34 @@ public class PdfsActivity2 extends AppCompatActivity {
         }
         setStatusTextColor(true);
     }
+
     /**
      * 设置状态栏文字色值为深色调
+     *
      * @param useDart 是否使用深色调
      */
 
     private void setStatusTextColor(Boolean useDart) {
         if (useDart) {
-            if (isFlyme()){
+            if (isFlyme()) {
                 processFlyMe(useDart);
-            }else if (isMIUI()){
+            } else if (isMIUI()) {
                 processMIUI(useDart);
-            }else {
-                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
+            } else {
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                     getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
-                }else {
+                } else {
                     getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);//实现状态栏图标和文字颜色为暗色
                 }
             }
         }
 
     }
+
     private void processFlyMe(Boolean isLightStatusBar) {
         WindowManager.LayoutParams lp = window.getAttributes();
         try {
-//            Class instance = getClass().forName("android.view.WindowManager\$LayoutParams");
+            //            Class instance = getClass().forName("android.view.WindowManager\$LayoutParams");
             Class instance = Class.forName("android.view.WindowManager$LayoutParams");
             int value = instance.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON").getInt(lp);
             Field field = instance.getDeclaredField("meizuFlags");
@@ -334,21 +407,22 @@ public class PdfsActivity2 extends AppCompatActivity {
             e.printStackTrace();
         }
     }
+
     /**
      * 改变小米的状态栏字体颜色为黑色, 要求MIUI6以上  lightStatusBar为真时表示黑色字体
      */
     private void processMIUI(Boolean lightStatusBar) {
         Class clazz = window.getClass();
         try {
-            int  darkModeFlag;
-//            val layoutParams = Class.forName("android.view.MiuiWindowManager\$LayoutParams")
+            int darkModeFlag;
+            //            val layoutParams = Class.forName("android.view.MiuiWindowManager\$LayoutParams")
             Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
             Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
             darkModeFlag = field.getInt(layoutParams);
-//            val extraFlagField = clazz.getMethod("setExtraFlags", Int::class.javaPrimitiveType, Int::class.javaPrimitiveType)
-//            extraFlagField.invoke(window, if (lightStatusBar) darkModeFlag else 0, darkModeFlag)
+            //            val extraFlagField = clazz.getMethod("setExtraFlags", Int::class.javaPrimitiveType, Int::class.javaPrimitiveType)
+            //            extraFlagField.invoke(window, if (lightStatusBar) darkModeFlag else 0, darkModeFlag)
             Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
-            extraFlagField.invoke(window,lightStatusBar?darkModeFlag :0,darkModeFlag);
+            extraFlagField.invoke(window, lightStatusBar ? darkModeFlag : 0, darkModeFlag);
         } catch (Exception ignored) {
             ignored.printStackTrace();
         }

+ 433 - 0
app/src/main/java/com/uas/kesai_esop/activity/PdfsActivity3.java

@@ -0,0 +1,433 @@
+package com.uas.kesai_esop.activity;
+
+import android.content.ActivityNotFoundException;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.res.Configuration;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.github.barteksc.pdfviewer.PDFView;
+import com.github.barteksc.pdfviewer.listener.OnRenderListener;
+import com.github.barteksc.pdfviewer.util.FitPolicy;
+import com.uas.kesai_esop.R;
+import com.uas.kesai_esop.util.CommonUtil;
+import com.uas.kesai_esop.util.DateFormatUtil;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import static com.uas.kesai_esop.util.OSUtil.isMIUI;
+import static razerdp.util.RomUtil.isFlyme;
+
+
+public class PdfsActivity3 extends AppCompatActivity {
+
+    private Window window;
+    private boolean useThemeStatusBarColor = false;//是否使用特殊的标题栏背景颜色,android5.0以上可以设置状态栏背景色,如果不使用则使用透明色值
+    private boolean useStatusBarColor = true;//是否使用状态栏文字和图标为暗色,如果状态栏采用了白色系,则需要使状态栏和图标为暗色,android6.0以上可以设置
+    private int option;
+    private boolean fullscreen = false;
+    private Context context;
+    private String destDirPath;
+    private String filename;
+    private String filepath;
+    private PDFView pdfView;
+    private String filenametime;
+    private int rotate = -90;
+    private String pdffilePath;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.act_pdf);
+
+        window = getWindow();
+        context = this;
+        Intent intent = getIntent();
+        ArrayList<String> lists = intent.getStringArrayListExtra("lists");
+        filename = intent.getStringExtra("filename");
+        for (int i = 0; i < lists.size(); i++) {
+            filepath = lists.get(i);
+            Log.e("smd5", filepath);
+        }
+
+        destDirPath = Environment.getExternalStorageDirectory().getPath() + "//UasEsop//";
+        pdfView = findViewById(R.id.pdfView);
+
+        ImageView iv_fullscreen = findViewById(R.id.iv_fullscreen);
+        LinearLayout iv_goback = findViewById(R.id.iv_goback);
+        TextView tv_rotate = findViewById(R.id.tv_rotate);
+        ImageView iv_back = findViewById(R.id.iv_back);
+
+        iv_back.setColorFilter(this.getResources().getColor(R.color.zise));
+        iv_fullscreen.setColorFilter(this.getResources().getColor(R.color.zise));
+
+        int screen = getResources().getConfiguration().orientation;
+        if (screen == Configuration.ORIENTATION_LANDSCAPE) {    //横屏
+            Log.e("aaa", "当前是横屏");
+        }else if (screen == Configuration.ORIENTATION_PORTRAIT) {   //竖屏
+            Log.e("aaa", "当前是竖屏");
+        }
+
+                WebView webView = findViewById(R.id.webView);
+                WebSettings webSettings = webView.getSettings();
+                webSettings.setJavaScriptEnabled(true);
+                webSettings.setPluginState(WebSettings.PluginState.ON);
+                webSettings.setAllowContentAccess(true);
+                webSettings.setAllowFileAccess(true);
+                webSettings.setAllowFileAccessFromFileURLs(true);
+                webSettings.setAllowUniversalAccessFromFileURLs(true);
+        //        webView.loadUrl("file:///android_asset/web/viewer.html?file="+filepath);
+        //        webView.loadUrl("file:///android_asset/web/viewer.html?file="+filepath);
+                webView.loadUrl("http://docs.google.com/gview?embedded=true&url=" + filepath);
+                webView.getSettings().setBuiltInZoomControls(true);
+                webView.getSettings().setSupportZoom(true);
+                webView.getSettings().setDisplayZoomControls(false);//不显示缩放按钮
+
+        iv_goback.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                finish();
+            }
+        });
+
+        iv_fullscreen.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {//全屏
+//                if (fullscreen == false) {
+//                    fullscreen = true;
+//                    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+//                    iv_fullscreen.setImageResource(R.drawable.not_fullscreen);
+//                } else {
+//                    fullscreen = false;
+//                    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+//                    iv_fullscreen.setImageResource(R.drawable.fullscreen);
+//                }
+
+
+
+            }
+        });
+
+        tv_rotate.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+//                rotate -= 90;
+//                if (rotate <= -360) {
+//                    rotate = -90;
+//                }
+//                pdfView.setRotation(rotate);
+
+                int screen = getResources().getConfiguration().orientation;
+                if (screen == Configuration.ORIENTATION_LANDSCAPE) {    //横屏
+                    Log.e("aaa", "当前是竖屏");
+                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);  //切竖屏
+                }else if (screen == Configuration.ORIENTATION_PORTRAIT) {   //竖屏
+                    Log.e("aaa", "当前是横屏");
+                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); //切横屏
+                }
+            }
+        });
+
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                boolean pathExist = isPathExist(destDirPath);
+                if (pathExist == true) {
+                    downloadFile1(filepath, destDirPath);
+                } else {
+                    try {
+                        CreateText(filepath, destDirPath);
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }).start();
+
+    }
+
+    /**
+     * 判断路径是否存在
+     *
+     * @param path 需要判断的路径
+     * @return true 是存在,false 是不存在
+     */
+    public boolean isPathExist(String path) {
+        File file = new File(path);
+        if (file.exists()) {
+            return true;
+        }
+        return false;
+    }
+
+    //创建文件夹及文件
+    public void CreateText(String filepath, String destDirPath) throws IOException {
+        File file = new File(destDirPath);
+        if (!file.exists()) {
+            try {
+                //按照指定的路径创建文件夹
+                file.mkdirs();
+                downloadFile1(filepath, destDirPath);
+            } catch (Exception e) {
+                // TODO: handle exception
+            }
+        }
+    }
+
+    public void downloadFile1(String urlPath, String path) {
+        try {
+            final long startTime = System.currentTimeMillis();
+            Log.i("DOWNLOAD", "startTime=" + startTime);
+            //下载函数
+            filenametime = DateFormatUtil.getProofTime();
+            //获取文件名
+            URL myURL = new URL(urlPath);
+            URLConnection conn = myURL.openConnection();
+            conn.connect();
+            InputStream is = conn.getInputStream();
+            int fileSize = conn.getContentLength();//根据响应获取文件大小
+            if (fileSize <= 0)
+                throw new RuntimeException("无法获知文件大小 ");
+            if (is == null)
+                throw new RuntimeException("stream is null");
+            File file1 = new File(path);
+            if (!file1.exists()) {
+                file1.mkdirs();
+            }
+            //把数据存入路径+文件名
+            FileOutputStream fos = new FileOutputStream(path + "/" + filenametime + filename);
+            byte buf[] = new byte[1024];
+            int downLoadFileSize = 0;
+            do {
+                //循环读取
+                int numread = is.read(buf);
+                if (numread == -1) {
+                    break;
+                }
+                fos.write(buf, 0, numread);
+                downLoadFileSize += numread;
+                //更新进度条
+            } while (true);
+            Log.i("DOWNLOAD", "download success");
+            Log.i("DOWNLOAD", "totalTime=" + (System.currentTimeMillis() - startTime));
+            Log.i("DOWNLOAD", "文件保存到:" + path);
+            Message message = handler.obtainMessage();
+            message.what = 1;
+            message.obj = path + "/" + filenametime + filename;
+            //            handler.sendEmptyMessage(0);
+            handler.sendMessage(message);
+            is.close();
+        } catch (Exception ex) {
+            Log.e("DOWNLOAD", "error: " + ex.getMessage(), ex);
+        }
+    }
+
+    private Handler handler = new Handler() {
+
+        @Override
+        public void handleMessage(Message msg) {
+            //CommonUtil.toastNoRepeat(context,"文件保存到"+destDirPath);
+            switch (msg.what) {
+                case 1:
+                    pdffilePath = (String) msg.obj;
+                    Log.e("aaa", "PDF文件路径是:" + pdffilePath);
+                    getPdf(pdffilePath);
+
+                    break;
+            }
+        }
+
+    };
+
+    /**
+     * 预览本地 pdf 文件
+     *
+     * @param filePath 本地文件完整路径
+     */
+    private void getPdf(String filePath) {
+        File file = new File(filePath);
+        if (file.exists()) {
+            if (file.getName().endsWith(".pdf")) {//如果文件类型是 pdf
+                try {
+                    InputStream in = new FileInputStream(file);
+                    if (in != null) {
+                        //                        Class<?> clazz = pdfView.getClass();
+                        //                        Method method = clazz.getDeclaredMethod("setPageFitPolicy", FitPolicy.class);
+                        //                        method.setAccessible(true); // 设置为true以访问私有方法
+                        //                        method.invoke(pdfView, FitPolicy.HEIGHT); // 传递包装对象而非原始值
+                        //                        Log.e("aaa", "反射的值是:" + pdfView.getPageFitPolicy());
+
+                        pdfView.zoomTo(50);
+                        pdfView.setSwipeEnabled(false);
+
+                        pdfView.fromStream(in)
+                                // .enableAnnotationRendering(true) //可以显示电子章
+
+                                .enableDoubletap(true)  //启用双击缩放
+                                .enableAnnotationRendering(true) // 启用注释渲染
+                                .swipeHorizontal(false)     //启用水平滑动
+                                .pageFitPolicy(FitPolicy.BOTH)     //修改策略模式,完全展示
+                                //                                .onPageChange(new OnPageChangeListener() {
+                                //                                    @Override
+                                //                                    public void onPageChanged(int page, int pageCount) {
+                                //                                        Log.e("aaa", "滑动页数:" + page);
+                                //                                        Log.e("aaa", "滑动页数总数:" + pageCount);
+                                //                                       // pdfView.fitToWidth(0);
+                                //                                    }
+                                //                                })
+
+                                                        .onRender(new OnRenderListener() {      //pdf文档加载完成后才能使用
+                                                            @Override
+                                                            public void onInitiallyRendered(int nbPages) {
+                                                                Log.e("aaa", "初始加载页数:" + nbPages);
+                                                                pdfView.fitToWidth(nbPages-1);
+                                                            }
+                                                        })
+                                .defaultPage(0)
+                                .load();
+                    }
+
+                    //旋转90度
+//                                        pdfView.setRotation(-90);
+
+                    //openPDFWithSystemViewer(PdfsActivity2.this,pdffilePath);
+
+                    //                    pdfView.fromAsset(pdffilePath)
+                    //                            .enableSwipe(true) // 允许滑动翻页
+                    //                            .swipeHorizontal(false) // 垂直翻页
+                    //                            .enableDoubletap(true) // 允许双击缩放
+                    //                            .defaultPage(0) // 默认显示第一页
+                    //                            .load();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        } else {
+            CommonUtil.toastNoRepeat(context, "文件不存在");
+        }
+    }
+
+    // 使用系统PDF Viewer打开PDF
+    public void openPDFWithSystemViewer(Context context, String pdfPath) {
+        Intent intent = new Intent(Intent.ACTION_VIEW);
+        intent.setDataAndType(Uri.parse("file://" + pdfPath), "application/pdf");
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        try {
+            context.startActivity(intent);
+        } catch (ActivityNotFoundException e) {
+            Toast.makeText(context, "请确保安装了可以处理PDF文件的应用。", Toast.LENGTH_LONG).show();
+        }
+    }
+
+    protected void setStatusBar() {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0及以上
+            View decorView = window.getDecorView();
+            option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
+
+            decorView.setSystemUiVisibility(option);
+            //根据上面设置是否对状态栏单独设置颜色
+            if (useThemeStatusBarColor) {
+                window.setStatusBarColor(getResources().getColor(R.color.colorMain));
+            } else {
+                window.setStatusBarColor(Color.TRANSPARENT);
+            }
+        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4到5.0
+            WindowManager.LayoutParams localLayoutParams = window.getAttributes();
+            localLayoutParams.flags = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags;
+        }
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && useStatusBarColor) {//android6.0以后可以对状态栏文字颜色和图标进行修改
+            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+        }
+        setStatusTextColor(true);
+    }
+
+    /**
+     * 设置状态栏文字色值为深色调
+     *
+     * @param useDart 是否使用深色调
+     */
+
+    private void setStatusTextColor(Boolean useDart) {
+        if (useDart) {
+            if (isFlyme()) {
+                processFlyMe(useDart);
+            } else if (isMIUI()) {
+                processMIUI(useDart);
+            } else {
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+                    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+                } else {
+                    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);//实现状态栏图标和文字颜色为暗色
+                }
+            }
+        }
+
+    }
+
+    private void processFlyMe(Boolean isLightStatusBar) {
+        WindowManager.LayoutParams lp = window.getAttributes();
+        try {
+            //            Class instance = getClass().forName("android.view.WindowManager\$LayoutParams");
+            Class instance = Class.forName("android.view.WindowManager$LayoutParams");
+            int value = instance.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON").getInt(lp);
+            Field field = instance.getDeclaredField("meizuFlags");
+            field.setAccessible(true);
+            int origin = field.getInt(lp);
+            if (isLightStatusBar) {
+                field.set(lp, (origin | value));
+            } else {
+                field.set(lp, value & origin);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 改变小米的状态栏字体颜色为黑色, 要求MIUI6以上  lightStatusBar为真时表示黑色字体
+     */
+    private void processMIUI(Boolean lightStatusBar) {
+        Class clazz = window.getClass();
+        try {
+            int darkModeFlag;
+            //            val layoutParams = Class.forName("android.view.MiuiWindowManager\$LayoutParams")
+            Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
+            Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
+            darkModeFlag = field.getInt(layoutParams);
+            //            val extraFlagField = clazz.getMethod("setExtraFlags", Int::class.javaPrimitiveType, Int::class.javaPrimitiveType)
+            //            extraFlagField.invoke(window, if (lightStatusBar) darkModeFlag else 0, darkModeFlag)
+            Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
+            extraFlagField.invoke(window, lightStatusBar ? darkModeFlag : 0, darkModeFlag);
+        } catch (Exception ignored) {
+            ignored.printStackTrace();
+        }
+    }
+}

+ 402 - 0
app/src/main/java/com/uas/kesai_esop/activity/PdfsActivity4.java

@@ -0,0 +1,402 @@
+package com.uas.kesai_esop.activity;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.webkit.WebChromeClient;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+
+import com.uas.kesai_esop.R;
+import com.uas.kesai_esop.util.BASE64Encoder;
+import com.uas.kesai_esop.util.CommonUtil;
+import com.uas.kesai_esop.util.DateFormatUtil;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import static com.uas.kesai_esop.util.OSUtil.isMIUI;
+import static razerdp.util.RomUtil.isFlyme;
+
+
+public class PdfsActivity4 extends AppCompatActivity {
+
+    private Window window;
+    private boolean useThemeStatusBarColor = false;//是否使用特殊的标题栏背景颜色,android5.0以上可以设置状态栏背景色,如果不使用则使用透明色值
+    private boolean useStatusBarColor = true;//是否使用状态栏文字和图标为暗色,如果状态栏采用了白色系,则需要使状态栏和图标为暗色,android6.0以上可以设置
+    private int option;
+    private boolean fullscreen=false;
+    private Context context;
+    private String destDirPath;
+    private String filename;
+    private String filepath;
+
+    private String docPath = "http://gps15.com/app/sysm/1.pdf";
+    private String docPath2 = "https://www.gjtool.cn/pdfh5/git.pdf";
+    private String docPath3 = "http://erp.cosuntech.cn:8099/postattach/CSC0547/440aac54e500454b85d55350dee6d702.pdf";
+    private WebView webView;
+
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_pdfs);
+        window = getWindow();
+        context=this;
+        Intent intent = getIntent();
+        ArrayList<String> lists = intent.getStringArrayListExtra("lists");
+        filename = intent.getStringExtra("filename");
+        for (int i=0;i<lists.size();i++){
+            filepath = lists.get(i);
+            Log.e("smd5", filepath);
+        }
+
+        webView = findViewById(R.id.webView);
+        ImageView iv_fullscreen = findViewById(R.id.iv_fullscreen);
+        ImageView iv_download = findViewById(R.id.iv_download);
+        LinearLayout iv_goback = findViewById(R.id.iv_goback);
+        ImageView iv_back = findViewById(R.id.iv_back);
+        iv_back.setColorFilter(this.getResources().getColor(R.color.zise));
+        iv_fullscreen.setColorFilter(this.getResources().getColor(R.color.zise));
+        iv_download.setColorFilter(this.getResources().getColor(R.color.zise));
+
+        WebSettings webSettings = webView.getSettings();
+        webSettings.setJavaScriptEnabled(true);
+        webSettings.setPluginState(WebSettings.PluginState.ON);
+        webSettings.setAllowContentAccess(true);
+        webSettings.setAllowFileAccess(true);
+        webSettings.setAllowFileAccessFromFileURLs(true);
+        webSettings.setAllowUniversalAccessFromFileURLs(true);
+        //设置加载进来的页面自适应手机屏幕
+        webSettings.setUseWideViewPort(true);
+        webSettings.setLoadWithOverviewMode(true);
+        //支持通过JS打开新窗口
+        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
+        webSettings.setGeolocationEnabled(true);
+        webSettings.setDomStorageEnabled(true);
+        webSettings.setAppCacheEnabled(false);
+
+
+//        WebSettings settings = webView.getSettings();
+//        settings.setSavePassword(false);
+//        settings.setJavaScriptEnabled(true);
+//        settings.setAllowFileAccessFromFileURLs(true);
+//        settings.setAllowUniversalAccessFromFileURLs(true);
+//        settings.setBuiltInZoomControls(true);
+        webView.setWebChromeClient(new WebChromeClient());
+
+        webView.setWebViewClient(new WebViewClient() {
+            @Override
+            public boolean shouldOverrideUrlLoading(WebView view, String url) {
+                view.loadUrl(url);
+                return true;
+            }
+            @Override
+            public void onPageStarted(WebView view, String url, Bitmap favicon) {
+                super.onPageStarted(view, url, favicon);
+//                findViewById(R.id.pb).setVisibility(View.VISIBLE);
+            }
+            @Override
+            public void onPageFinished(WebView view, String url) {
+                super.onPageFinished(view, url);
+//                findViewById(R.id.pb).setVisibility(View.GONE);
+            }
+        });
+
+        if (!"".equals(docPath)) {
+            byte[] bytes = null;
+            try {// 获取以字符编码为utf-8的字符
+                bytes = docPath.getBytes("UTF-8");
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            if (bytes != null) {
+                docPath = new BASE64Encoder().encode(bytes);// BASE64转码
+            }
+        }
+
+//        webView.loadUrl("file:///android_asset/web/viewer.html?file="+docPath);
+//        webView.loadUrl("file:///android_asset/web/viewer.html?file="+docPath3);
+        webView.loadUrl("file:///android_asset/web/viewer.html?file="+filepath);
+//        webView.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file="+filepath);
+//        webView.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file="+docPath);
+//        webView.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file=" + docPath2);
+//        webView.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file=" + docPath3);
+//        webView.loadUrl("file:///android_asset/pdfjs/web/viewer.html?" + docPath);
+//        webView.loadUrl("http://docs.google.com/gview?embedded=true&url=" + filepath);
+//        webView.loadUrl(filepath);
+//        webView.loadUrl(docPath);
+
+//        webView.getSettings().setBuiltInZoomControls(true);
+//        webView.getSettings().setSupportZoom(true);
+//        webView.getSettings().setDisplayZoomControls(false);//不显示缩放按钮
+
+        iv_goback.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                finish();
+            }
+        });
+        iv_fullscreen.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {//全屏
+                if (fullscreen==false){
+                    fullscreen=true;
+                    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+                    iv_fullscreen.setImageResource(R.drawable.not_fullscreen);
+                }else {
+                    fullscreen=false;
+                    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+                    iv_fullscreen.setImageResource(R.drawable.fullscreen);
+                }
+
+            }
+        });
+        destDirPath = Environment.getExternalStorageDirectory().getPath() + "//UasEsop//";
+        iv_download.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                new Thread(new Runnable() {
+                    @Override
+                    public void run() {
+                        boolean pathExist = isPathExist(destDirPath);
+                        if (pathExist==true){
+                            downloadFile1(filepath, destDirPath);
+                        }else {
+                            try {
+                                CreateText(filepath, destDirPath);
+                            } catch (IOException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }).start();
+
+            }
+        });
+
+//        new Thread(new Runnable() {
+//            @Override
+//            public void run() {
+//                boolean pathExist = isPathExist(destDirPath);
+//                if (pathExist == true) {
+//                    downloadFile1(filepath, destDirPath);
+//                } else {
+//                    try {
+//                        CreateText(filepath, destDirPath);
+//                    } catch (IOException e) {
+//                        e.printStackTrace();
+//                    }
+//                }
+//            }
+//        }).start();
+
+
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        webView.resumeTimers();
+    }
+
+    /**
+     * 判断路径是否存在
+     *
+     * @param path 需要判断的路径
+     * @return true 是存在,false 是不存在
+     */
+    public boolean isPathExist(String path) {
+        File file = new File(path);
+        if (file.exists()) {
+            return true;
+        }
+        return false;
+    }
+    //创建文件夹及文件
+    public void CreateText(String filepath,String destDirPath) throws IOException {
+        File file = new File(destDirPath);
+        if (!file.exists()) {
+            try {
+                //按照指定的路径创建文件夹
+                file.mkdirs();
+                downloadFile1(filepath,destDirPath);
+            } catch (Exception e) {
+                // TODO: handle exception
+            }
+        }
+
+    }
+    public void downloadFile1(String urlPath,String path) {
+        try{
+            final long startTime = System.currentTimeMillis();
+            Log.i("DOWNLOAD","startTime="+startTime);
+            //下载函数
+            String filenametime= DateFormatUtil.getProofTime();
+            //获取文件名
+            URL myURL = new URL(urlPath);
+            URLConnection conn = myURL.openConnection();
+            conn.connect();
+            InputStream is = conn.getInputStream();
+            int fileSize = conn.getContentLength();//根据响应获取文件大小
+            if (fileSize <= 0) throw new RuntimeException("无法获知文件大小 ");
+            if (is == null) throw new RuntimeException("stream is null");
+            File file1 = new File(path);
+            if(!file1.exists()){
+                file1.mkdirs();
+            }
+            //把数据存入路径+文件名
+            FileOutputStream fos = new FileOutputStream(path+"/"+filenametime+filename);
+            byte buf[] = new byte[1024];
+            int downLoadFileSize = 0;
+            do{
+                //循环读取
+                int numread = is.read(buf);
+                if (numread == -1)
+                {
+                    break;
+                }
+                fos.write(buf, 0, numread);
+                downLoadFileSize += numread;
+                //更新进度条
+            } while (true);
+            Log.i("DOWNLOAD","download success");
+            Log.i("DOWNLOAD","totalTime="+ (System.currentTimeMillis() - startTime));
+            Log.i("DOWNLOAD","文件保存到:"+path);
+
+
+            Message message = handler.obtainMessage();
+            message.what = 1;
+            message.obj = path + "/" + filenametime + filename;
+            handler.sendMessage(message);
+
+            is.close();
+//            SPUtils.putString(getContext(),"stades","1");
+        } catch (Exception ex) {
+            Log.e("DOWNLOAD", "error: " + ex.getMessage(), ex);
+//            SPUtils.putString(getContext(),"stades","2");
+        }
+    }
+
+    private String pdffilePath;
+
+    private Handler handler = new Handler() {
+
+        @Override
+        public void handleMessage(Message msg) {
+            CommonUtil.toastNoRepeat(context,"文件保存到"+destDirPath);
+            switch (msg.what) {
+                case 1:
+                    pdffilePath = (String) msg.obj;
+                    Log.e("aaa", "PDF文件路径是:" + pdffilePath);
+//                    webView.loadUrl("file:///android_asset/index.html?" + pdffilePath);
+//                    webView.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file=" + pdffilePath);
+                    break;
+            }
+
+        }
+
+    };
+    protected void setStatusBar() {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0及以上
+            View decorView = window.getDecorView();
+            option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
+
+            decorView.setSystemUiVisibility(option);
+            //根据上面设置是否对状态栏单独设置颜色
+            if (useThemeStatusBarColor) {
+                window.setStatusBarColor(getResources().getColor(R.color.colorMain));
+            } else {
+                window.setStatusBarColor(Color.TRANSPARENT);
+            }
+        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4到5.0
+            WindowManager.LayoutParams localLayoutParams = window.getAttributes();
+            localLayoutParams.flags = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags;
+        }
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && useStatusBarColor) {//android6.0以后可以对状态栏文字颜色和图标进行修改
+            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+        }
+        setStatusTextColor(true);
+    }
+    /**
+     * 设置状态栏文字色值为深色调
+     * @param useDart 是否使用深色调
+     */
+
+    private void setStatusTextColor(Boolean useDart) {
+        if (useDart) {
+            if (isFlyme()){
+                processFlyMe(useDart);
+            }else if (isMIUI()){
+                processMIUI(useDart);
+            }else {
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
+                    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+                }else {
+                    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);//实现状态栏图标和文字颜色为暗色
+                }
+            }
+        }
+
+    }
+    private void processFlyMe(Boolean isLightStatusBar) {
+        WindowManager.LayoutParams lp = window.getAttributes();
+        try {
+//            Class instance = getClass().forName("android.view.WindowManager\$LayoutParams");
+            Class instance = Class.forName("android.view.WindowManager$LayoutParams");
+            int value = instance.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON").getInt(lp);
+            Field field = instance.getDeclaredField("meizuFlags");
+            field.setAccessible(true);
+            int origin = field.getInt(lp);
+            if (isLightStatusBar) {
+                field.set(lp, (origin | value));
+            } else {
+                field.set(lp, value & origin);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    /**
+     * 改变小米的状态栏字体颜色为黑色, 要求MIUI6以上  lightStatusBar为真时表示黑色字体
+     */
+    private void processMIUI(Boolean lightStatusBar) {
+        Class clazz = window.getClass();
+        try {
+            int  darkModeFlag;
+//            val layoutParams = Class.forName("android.view.MiuiWindowManager\$LayoutParams")
+            Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
+            Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
+            darkModeFlag = field.getInt(layoutParams);
+//            val extraFlagField = clazz.getMethod("setExtraFlags", Int::class.javaPrimitiveType, Int::class.javaPrimitiveType)
+//            extraFlagField.invoke(window, if (lightStatusBar) darkModeFlag else 0, darkModeFlag)
+            Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
+            extraFlagField.invoke(window,lightStatusBar?darkModeFlag :0,darkModeFlag);
+        } catch (Exception ignored) {
+            ignored.printStackTrace();
+        }
+    }
+}

+ 93 - 0
app/src/main/java/com/uas/kesai_esop/activity/WebViewDPF.java

@@ -0,0 +1,93 @@
+package com.uas.kesai_esop.activity;
+
+import android.app.Activity;
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.view.View;
+import android.webkit.WebChromeClient;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+
+import com.uas.kesai_esop.R;
+import com.uas.kesai_esop.util.BASE64Encoder;
+
+import java.io.UnsupportedEncodingException;
+
+
+public class WebViewDPF extends Activity implements View.OnClickListener {
+
+    private WebView pdfShowWebView;
+    private String docPath = "http://gps15.com/app/sysm/1.pdf";
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.act_instruction_pdf);
+//        findViewById(R.id.iv_back).setOnClickListener(this);
+
+        pdfShowWebView = (WebView) findViewById(R.id.view_web);
+        pdfShowWebView.setWebViewClient(new WebViewClient() {
+            @Override
+            public boolean shouldOverrideUrlLoading(WebView view, String url) {
+                // 返回值是true的时候控制去WebView打开,为false调用系统浏览器或第三方浏览器
+                view.loadUrl(url);
+                return true;
+            }
+        });
+        WebSettings settings = pdfShowWebView.getSettings();
+        settings.setSavePassword(false);
+        settings.setJavaScriptEnabled(true);
+        settings.setAllowFileAccessFromFileURLs(true);
+        settings.setAllowUniversalAccessFromFileURLs(true);
+        settings.setBuiltInZoomControls(true);
+        pdfShowWebView.setWebChromeClient(new WebChromeClient());
+
+        pdfShowWebView.setWebViewClient(new WebViewClient() {
+            @Override
+            public boolean shouldOverrideUrlLoading(WebView view, String url) {
+                view.loadUrl(url);
+                return true;
+            }
+            @Override
+            public void onPageStarted(WebView view, String url, Bitmap favicon) {
+                super.onPageStarted(view, url, favicon);
+//                findViewById(R.id.pb).setVisibility(View.VISIBLE);
+            }
+            @Override
+            public void onPageFinished(WebView view, String url) {
+                super.onPageFinished(view, url);
+//                findViewById(R.id.pb).setVisibility(View.GONE);
+            }
+        });
+
+        if (!"".equals(docPath)) {
+            byte[] bytes = null;
+            try {// 获取以字符编码为utf-8的字符
+                bytes = docPath.getBytes("UTF-8");
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            if (bytes != null) {
+                docPath = new BASE64Encoder().encode(bytes);// BASE64转码
+            }
+        }
+        initView();
+        pdfShowWebView.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file=" + docPath);
+    }
+
+    private void initView(){
+//        findViewById(R.id.rl_title).setBackgroundResource(App.getInstance().getmStyle().getbg_top());
+//        findViewById(R.id.top_line).setBackgroundResource(App.getInstance().getmStyle().gettop_line_color());
+    }
+
+    @Override
+    public void onClick(View v) {
+//        switch (v.getId()) {
+//            case R.id.iv_back:
+//                finish();
+//                //overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
+//                break;
+//        }
+    }
+}

+ 9 - 10
app/src/main/java/com/uas/kesai_esop/application/PdaApplication.java

@@ -13,7 +13,6 @@ import com.android.volley.toolbox.Volley;
 import com.facebook.stetho.Stetho;
 import com.uas.kesai_esop.R;
 import com.uas.kesai_esop.util.AndroidUtil;
-import com.uas.kesai_esop.util.CrashHandler;
 import com.uas.kesai_esop.util.FakeX509TrustManager;
 import com.uas.kesai_esop.util.SoundUtil;
 import com.umeng.analytics.MobclickAgent;
@@ -55,8 +54,10 @@ public class PdaApplication extends Application {
         mInstance = this;
         mContext = getApplicationContext();
 
-        CrashHandler crashHandler = CrashHandler.getInstance();
-        crashHandler.init(mContext);
+        //PDFBoxResourceLoader.init(getApplicationContext());
+
+//        CrashHandler crashHandler = CrashHandler.getInstance();
+//        crashHandler.init(mContext);
 
         FakeX509TrustManager.allowAllSSL();//去掉SSL证书验证
         if (mRequestQueue == null)
@@ -80,7 +81,6 @@ public class PdaApplication extends Application {
             mSoundPool = new SoundPool(4, AudioAttributes.CONTENT_TYPE_MUSIC, 0);
         }
 
-
         mSoundMap = new HashMap<>();
         mSoundMap.put(SoundUtil.SOUND_ARIEL, mSoundPool.load(this, R.raw.ariel, 1));
         mSoundMap.put(SoundUtil.SOUND_CARME, mSoundPool.load(this, R.raw.carme, 1));
@@ -93,19 +93,19 @@ public class PdaApplication extends Application {
         mSoundMap.put(SoundUtil.SOUND_SALACIA, mSoundPool.load(this, R.raw.salacia, 1));
         mSoundMap.put(SoundUtil.SOUND_TETHYS, mSoundPool.load(this, R.raw.tethys, 1));
         mSoundMap.put(SoundUtil.SOUND_TITAN, mSoundPool.load(this, R.raw.titan, 1));
-        //initUmeng();
-//        getMessageData();
+        initUmeng();
+
     }
 
     private void initUmeng() {
         //2.在Application.oncreate()中调用预初始化函数
-        UMConfigure.preInit(this, "6188763d09a805384d5e40d7","umeng");
+        UMConfigure.preInit(this, "67ac729a9a16fe6dcd4555f4","umeng");
         UMConfigure.setLogEnabled(true);
         //3.客户端用户同意隐私政策后,正式初始化友盟+SDK
         UMConfigure.init(
                 this,
-                "6188763d09a805384d5e40d7",
-                "umeng",
+                "67ac729a9a16fe6dcd4555f4",
+                "Umeng",
                 UMConfigure.DEVICE_TYPE_PHONE, ""
         );
         // 页面数据采集模式
@@ -130,7 +130,6 @@ public class PdaApplication extends Application {
 
     /**
      * 获取本地缓存
-     *
      * @param key
      * @return
      */

+ 68 - 0
app/src/main/java/com/uas/kesai_esop/util/BASE64Encoder.java

@@ -0,0 +1,68 @@
+package com.uas.kesai_esop.util;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class BASE64Encoder extends CharacterEncoder
+{
+	protected int bytesPerAtom()
+	{
+		return 3;
+	}
+
+	protected int bytesPerLine()
+	{
+		return 57;
+	}
+
+	private static final char[] pem_array =
+	{ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
+			'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a',
+			'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+			'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0',
+			'1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '=' };
+
+	protected void encodeAtom(OutputStream paramOutputStream,
+			byte[] paramArrayOfByte, int paramInt1, int paramInt2)
+			throws IOException
+	{
+		int i;
+		int j;
+		int k;
+		if (paramInt2 == 1)
+		{
+			i = paramArrayOfByte[paramInt1];
+			j = 0;
+			k = 0;
+			paramOutputStream.write(pem_array[(i >>> 2 & 0x3F)]);
+			paramOutputStream
+					.write(pem_array[((i << 4 & 0x30) + (j >>> 4 & 0xF))]);
+			paramOutputStream.write(61);
+			paramOutputStream.write(61);
+		}
+		else if (paramInt2 == 2)
+		{
+			i = paramArrayOfByte[paramInt1];
+			j = paramArrayOfByte[(paramInt1 + 1)];
+			k = 0;
+			paramOutputStream.write(pem_array[(i >>> 2 & 0x3F)]);
+			paramOutputStream
+					.write(pem_array[((i << 4 & 0x30) + (j >>> 4 & 0xF))]);
+			paramOutputStream
+					.write(pem_array[((j << 2 & 0x3C) + (k >>> 6 & 0x3))]);
+			paramOutputStream.write(61);
+		}
+		else
+		{
+			i = paramArrayOfByte[paramInt1];
+			j = paramArrayOfByte[(paramInt1 + 1)];
+			k = paramArrayOfByte[(paramInt1 + 2)];
+			paramOutputStream.write(pem_array[(i >>> 2 & 0x3F)]);
+			paramOutputStream
+					.write(pem_array[((i << 4 & 0x30) + (j >>> 4 & 0xF))]);
+			paramOutputStream
+					.write(pem_array[((j << 2 & 0x3C) + (k >>> 6 & 0x3))]);
+			paramOutputStream.write(pem_array[(k & 0x3F)]);
+		}
+	}
+}

+ 208 - 0
app/src/main/java/com/uas/kesai_esop/util/CharacterEncoder.java

@@ -0,0 +1,208 @@
+package com.uas.kesai_esop.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.nio.ByteBuffer;
+
+public abstract class CharacterEncoder
+{
+  protected PrintStream pStream;
+  
+  protected abstract int bytesPerAtom();
+  
+  protected abstract int bytesPerLine();
+  
+  protected void encodeBufferPrefix(OutputStream paramOutputStream)
+    throws IOException
+  {
+    this.pStream = new PrintStream(paramOutputStream);
+  }
+  
+  protected void encodeBufferSuffix(OutputStream paramOutputStream)
+    throws IOException
+  {}
+  
+  protected void encodeLinePrefix(OutputStream paramOutputStream, int paramInt)
+    throws IOException
+  {}
+  
+  protected void encodeLineSuffix(OutputStream paramOutputStream)
+    throws IOException
+  {
+    this.pStream.println();
+  }
+  
+  protected abstract void encodeAtom(OutputStream paramOutputStream, byte[] paramArrayOfByte, int paramInt1, int paramInt2)
+    throws IOException;
+  
+  protected int readFully(InputStream paramInputStream, byte[] paramArrayOfByte)
+    throws IOException
+  {
+    for (int i = 0; i < paramArrayOfByte.length; i++)
+    {
+      int j = paramInputStream.read();
+      if (j == -1) {
+        return i;
+      }
+      paramArrayOfByte[i] = ((byte)j);
+    }
+    return paramArrayOfByte.length;
+  }
+  
+  public void encode(InputStream paramInputStream, OutputStream paramOutputStream)
+    throws IOException
+  {
+    byte[] arrayOfByte = new byte[bytesPerLine()];
+    
+    encodeBufferPrefix(paramOutputStream);
+    for (;;)
+    {
+      int j = readFully(paramInputStream, arrayOfByte);
+      if (j == 0) {
+        break;
+      }
+      encodeLinePrefix(paramOutputStream, j);
+      for (int i = 0; i < j; i += bytesPerAtom()) {
+        if (i + bytesPerAtom() <= j) {
+          encodeAtom(paramOutputStream, arrayOfByte, i, bytesPerAtom());
+        } else {
+          encodeAtom(paramOutputStream, arrayOfByte, i, j - i);
+        }
+      }
+      if (j < bytesPerLine()) {
+        break;
+      }
+      encodeLineSuffix(paramOutputStream);
+    }
+    encodeBufferSuffix(paramOutputStream);
+  }
+  
+  public void encode(byte[] paramArrayOfByte, OutputStream paramOutputStream)
+    throws IOException
+  {
+    ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(paramArrayOfByte);
+    encode(localByteArrayInputStream, paramOutputStream);
+  }
+  
+  public String encode(byte[] paramArrayOfByte)
+  {
+    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
+    ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(paramArrayOfByte);
+    String str = null;
+    try
+    {
+      encode(localByteArrayInputStream, localByteArrayOutputStream);
+      
+      str = localByteArrayOutputStream.toString("8859_1");
+    }
+    catch (Exception localException)
+    {
+      throw new Error("CharacterEncoder.encode internal error");
+    }
+    return str;
+  }
+  
+  private byte[] getBytes(ByteBuffer paramByteBuffer)
+  {
+    byte[] localObject = null;
+    if (paramByteBuffer.hasArray())
+    {
+      byte[] arrayOfByte = paramByteBuffer.array();
+      if ((arrayOfByte.length == paramByteBuffer.capacity()) && (arrayOfByte.length == paramByteBuffer.remaining()))
+      {
+        localObject = arrayOfByte;
+        paramByteBuffer.position(paramByteBuffer.limit());
+      }
+    }
+    if (localObject == null)
+    {
+      localObject = new byte[paramByteBuffer.remaining()];
+      
+
+
+
+      paramByteBuffer.get((byte[])localObject);
+    }
+    return localObject;
+  }
+  
+  public void encode(ByteBuffer paramByteBuffer, OutputStream paramOutputStream)
+    throws IOException
+  {
+    byte[] arrayOfByte = getBytes(paramByteBuffer);
+    encode(arrayOfByte, paramOutputStream);
+  }
+  
+  public String encode(ByteBuffer paramByteBuffer)
+  {
+    byte[] arrayOfByte = getBytes(paramByteBuffer);
+    return encode(arrayOfByte);
+  }
+  
+  public void encodeBuffer(InputStream paramInputStream, OutputStream paramOutputStream)
+    throws IOException
+  {
+    byte[] arrayOfByte = new byte[bytesPerLine()];
+    
+    encodeBufferPrefix(paramOutputStream);
+    for (;;)
+    {
+      int j = readFully(paramInputStream, arrayOfByte);
+      if (j != 0)
+      {
+        encodeLinePrefix(paramOutputStream, j);
+        for (int i = 0; i < j; i += bytesPerAtom()) {
+          if (i + bytesPerAtom() <= j) {
+            encodeAtom(paramOutputStream, arrayOfByte, i, bytesPerAtom());
+          } else {
+            encodeAtom(paramOutputStream, arrayOfByte, i, j - i);
+          }
+        }
+        encodeLineSuffix(paramOutputStream);
+        if (j < bytesPerLine()) {
+          break;
+        }
+      }
+    }
+    encodeBufferSuffix(paramOutputStream);
+  }
+  
+  public void encodeBuffer(byte[] paramArrayOfByte, OutputStream paramOutputStream)
+    throws IOException
+  {
+    ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(paramArrayOfByte);
+    encodeBuffer(localByteArrayInputStream, paramOutputStream);
+  }
+  
+  public String encodeBuffer(byte[] paramArrayOfByte)
+  {
+    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
+    ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(paramArrayOfByte);
+    try
+    {
+      encodeBuffer(localByteArrayInputStream, localByteArrayOutputStream);
+    }
+    catch (Exception localException)
+    {
+      throw new Error("CharacterEncoder.encodeBuffer internal error");
+    }
+    return localByteArrayOutputStream.toString();
+  }
+  
+  public void encodeBuffer(ByteBuffer paramByteBuffer, OutputStream paramOutputStream)
+    throws IOException
+  {
+    byte[] arrayOfByte = getBytes(paramByteBuffer);
+    encodeBuffer(arrayOfByte, paramOutputStream);
+  }
+  
+  public String encodeBuffer(ByteBuffer paramByteBuffer)
+  {
+    byte[] arrayOfByte = getBytes(paramByteBuffer);
+    return encodeBuffer(arrayOfByte);
+  }
+}

+ 1 - 0
app/src/main/res/layout-large/act_pdf.xml

@@ -23,6 +23,7 @@
         android:src="@drawable/fullscreen"/>
 
     <TextView
+        android:visibility="gone"
         android:id="@+id/tv_rotate"
         android:layout_marginTop="15dp"
         android:layout_below="@+id/iv_fullscreen"

+ 20 - 21
app/src/main/res/layout-large/activity_pdfs.xml

@@ -1,36 +1,35 @@
 <?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:context=".activity.PdfsActivity"
     tools:ignore="MissingDefaultResource">
+
     <WebView
         android:id="@+id/webView"
         android:layout_width="match_parent"
-        android:layout_height="match_parent">
-    </WebView>
+        android:layout_height="match_parent"/>
 
     <ImageView
         android:id="@+id/iv_fullscreen"
-        android:layout_alignParentRight="true"
-        android:layout_marginRight="@dimen/dp_10"
-        android:layout_marginTop="@dimen/dp_40"
         android:layout_width="@dimen/textsize_20"
         android:layout_height="@dimen/textsize_20"
-        android:src="@drawable/fullscreen">
-    </ImageView>
+        android:layout_alignParentRight="true"
+        android:layout_marginTop="@dimen/dp_40"
+        android:layout_marginRight="@dimen/dp_10"
+        android:src="@drawable/fullscreen"/>
+
     <ImageView
         android:id="@+id/iv_download"
+        android:layout_width="@dimen/textsize_20"
+        android:layout_height="@dimen/textsize_20"
         android:layout_alignParentRight="true"
         android:layout_marginTop="100dp"
         android:layout_marginRight="@dimen/dp_10"
-        android:layout_width="@dimen/textsize_20"
-        android:layout_height="@dimen/textsize_20"
-        android:src="@mipmap/down_load">
-    </ImageView>
+        android:src="@mipmap/down_load"/>
+
     <LinearLayout
         android:id="@+id/iv_goback"
         android:layout_width="wrap_content"
@@ -38,22 +37,22 @@
         android:layout_marginLeft="@dimen/textsize_20"
         android:layout_marginTop="@dimen/dp_40"
         android:orientation="horizontal">
+
         <ImageView
             android:id="@+id/iv_back"
-            android:layout_gravity="center"
             android:layout_width="@dimen/textsize_20"
             android:layout_height="@dimen/textsize_20"
-            android:src="@mipmap/goback">
-        </ImageView>
+            android:layout_gravity="center"
+            android:src="@mipmap/goback"/>
+
         <TextView
-            android:gravity="center"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
             android:layout_gravity="center"
-            android:textSize="@dimen/dp_10"
+            android:gravity="center"
             android:text="返回"
             android:textColor="#DF77CE"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content">
-        </TextView>
+            android:textSize="@dimen/dp_10"/>
     </LinearLayout>
 
 

+ 6 - 0
app/src/main/res/layout-large/fuzzy_search_item.xml

@@ -25,6 +25,12 @@
             android:layout_height="wrap_content"
             />
 
+        <TextView
+            android:text=" "
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            />
+
         <TextView
             android:id="@+id/remark_Tv"
             android:text=""

+ 19 - 0
app/src/main/res/layout/act_instruction_pdf.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+ >
+
+
+
+    <WebView
+        android:id="@+id/view_web"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="#00000000"
+        />
+
+
+
+</RelativeLayout>

+ 1 - 0
app/src/main/res/layout/act_pdf.xml

@@ -23,6 +23,7 @@
         android:src="@drawable/fullscreen"/>
 
     <TextView
+        android:visibility="gone"
         android:id="@+id/tv_rotate"
         android:layout_marginTop="15dp"
         android:layout_below="@+id/iv_fullscreen"

+ 6 - 0
app/src/main/res/layout/fuzzy_search_item.xml

@@ -25,6 +25,12 @@
             android:layout_height="wrap_content"
             />
 
+        <TextView
+            android:text=" "
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            />
+
         <TextView
             android:id="@+id/remark_Tv"
             android:text=""

+ 2 - 2
build.gradle

@@ -58,8 +58,8 @@ ext {
             targetSdkVersion : 28,
             compileSdkVersion: 28,
             buildToolsVersion: "28.0.3",
-            versionCode      : 4,
-            versionName      : "v1.0.3"
+            versionCode      : 7,
+            versionName      : "v1.0.6"
     ]
 
     depsVersion = [