Просмотр исходного кода

Apex Mobile
1 完成pdf 预览功能。
2 pdf预览集成 缓存和保存逻辑。
3 pdf预览集成 发送功能。
4 整合PDF打开,统一通过pdf preview 内部打开。
5 修改主框架,禁止在tab间滚动。

Ray Zhang 8 лет назад
Родитель
Сommit
af9a8ea306

+ 2 - 0
Apex Mobile/app/app.iml

@@ -112,6 +112,7 @@
     <orderEntry type="library" name="__local_aars__:/Users/ray/Documents/code_ERPSuiteAndroid/Apex Mobile/app/libs/core-2.3.0.jar:unspecified@jar" level="project" />
     <orderEntry type="library" name="com.android.support:recyclerview-v7-26.1.0" level="project" />
     <orderEntry type="library" name="__local_aars__:/Users/ray/Documents/code_ERPSuiteAndroid/Apex Mobile/app/libs/BaiduLBS_Android.jar:unspecified@jar" level="project" />
+    <orderEntry type="library" name="com.github.barteksc:android-pdf-viewer-3.0.0-beta.5" level="project" />
     <orderEntry type="library" name="android.arch.lifecycle:common:1.0.0@jar" level="project" />
     <orderEntry type="library" name="com.google.android.gms:play-services-base-license-11.4.2" level="project" />
     <orderEntry type="library" name="com.android.support:support-fragment-26.1.0" level="project" />
@@ -131,6 +132,7 @@
     <orderEntry type="library" name="android.arch.core:common:1.0.0@jar" level="project" />
     <orderEntry type="library" name="com.google.android.gms:play-services-tasks-11.4.2" level="project" />
     <orderEntry type="library" name="com.google.android.gms:play-services-maps-11.4.2" level="project" />
+    <orderEntry type="library" name="com.github.barteksc:pdfium-android-1.8.2" level="project" />
     <orderEntry type="library" name="__local_aars__:/Users/ray/Documents/code_ERPSuiteAndroid/Apex Mobile/app/libs/bcprov-jdk15on-157.jar:unspecified@jar" level="project" />
     <orderEntry type="library" name="com.android.support:support-v4-26.1.0" level="project" />
     <orderEntry type="library" name="com.google.android.gms:play-services-location-11.4.2" level="project" />

+ 1 - 0
Apex Mobile/app/build.gradle

@@ -48,6 +48,7 @@ dependencies {
     //    compile files('libs/baidumapapi_map_v3_7_1.jar')
     compile files('libs/httpmime-4.1.1.jar')
     compile files('libs/core-2.3.0.jar')
+    compile 'com.github.barteksc:android-pdf-viewer:3.0.0-beta.5'
     implementation files('libs/BaiduLBS_Android.jar')
 }
 android {

+ 5 - 0
Apex Mobile/app/src/main/AndroidManifest.xml

@@ -316,6 +316,11 @@
             android:name=".Result.SearchResultActivity"
             android:screenOrientation="portrait"></activity>
         <activity android:name=".ContainerSearchActivity"></activity>
+
+        <activity
+            android:name=".pdf.PDFPreviewActivity"
+            android:screenOrientation="portrait"
+            android:theme="@style/ResultActionbarTheme"></activity>
     </application>
 
 </manifest>

+ 51 - 0
Apex Mobile/app/src/main/java/com/usai/apex/Result/AMResultActivity.java

@@ -23,13 +23,16 @@ import com.usai.apex.ApexTrackingApplication;
 import com.usai.apex.CustomizeFieldsActivity;
 import com.usai.apex.DetailActivity;
 import com.usai.apex.R;
+import com.usai.apex.pdf.PDFPreviewActivity;
 import com.usai.util.Network;
+import com.usai.util.RAUtil;
 import com.usai.util.dbUtil;
 
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.Set;
@@ -317,7 +320,45 @@ public class AMResultActivity extends SearchResultActivity {
         }
 
     }
+    @Override
+    public void showQuickLook(final JSONObject param, final String url) {
+
+        showProgressDialog("Please wait","Downloading...");
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+
+                String cacheDir = ApexTrackingApplication.getInstance().getExternalCacheDir().getAbsolutePath();//ApexTrackingApplication.getInstance().getDocumentDir();
+
+                // 下载文件
+                final File downloadFile = Network.downloadFile(RAUtil.Json2Bundle(param),url,cacheDir);
+
+                runOnUiThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        progressDialog.dismiss();
+                        if (downloadFile != null && downloadFile.exists()) {
+//                            try {
+//                                //此处需要新增保存文档的本地表
+//                                param;
+////                                String email=param.getString("email");
+////                                String email_subject=param.getString("email_subject");
+////                                String email_content=param.getString("email_content");
+//                            } catch (JSONException e) {
+//                                e.printStackTrace();
+//                            }
+                            previewPDF(downloadFile.getAbsolutePath());
+                        } else {
+                            showAlert("Sorry,there is a wrong.");
+                        }
+                    }
+                });
+
+            }
+        }).start();
+
 
+    }
     public void showQuickLookForPosition(final int position,JSONObject action) {
 
         try {
@@ -343,6 +384,16 @@ public class AMResultActivity extends SearchResultActivity {
 
     }
 
+
+    protected void previewPDF(String file) {
+        Intent myIntent = new Intent();
+        myIntent = new Intent(AMResultActivity.this, PDFPreviewActivity.class);
+
+        myIntent.putExtra("file",file);
+        myIntent.putExtra("iscache",true);
+        startActivity(myIntent);
+    }
+
     private void downloaddoc(String url)
     {
 

+ 9 - 0
Apex Mobile/app/src/main/java/com/usai/apex/Result/SearchResultActivity.java

@@ -1224,6 +1224,15 @@ public class SearchResultActivity extends AppCompatActivity {
                     public void run() {
                         progressDialog.dismiss();
                         if (downloadFile != null && downloadFile.exists()) {
+//                            try {
+//                                //此处需要新增保存文档的本地表
+//                                param;
+////                                String email=param.getString("email");
+////                                String email_subject=param.getString("email_subject");
+////                                String email_content=param.getString("email_content");
+//                            } catch (JSONException e) {
+//                                e.printStackTrace();
+//                            }
                             openFile(downloadFile);
                         } else {
                             showAlert("Sorry,there is a wrong.");

+ 30 - 0
Apex Mobile/app/src/main/java/com/usai/apex/mainframe/NoScrollViewPager.java

@@ -0,0 +1,30 @@
+package com.usai.apex.mainframe;
+
+import android.content.Context;
+import android.support.v4.view.ViewPager;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+
+/**
+ * Created by ray on 05/03/2018.
+ */
+
+public class NoScrollViewPager extends ViewPager {
+    public NoScrollViewPager(Context context) {
+        super(context);
+    }
+
+    public NoScrollViewPager(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent arg0) {
+        return false;
+    }
+
+    @Override
+    public boolean onInterceptTouchEvent(MotionEvent arg0) {
+        return false;
+    }
+}

+ 2 - 2
Apex Mobile/app/src/main/java/com/usai/apex/mainframe/RootActivity.java

@@ -28,7 +28,7 @@ import com.usai.util.commonUtil;
 
 public class RootActivity extends AppCompatActivity {
 
-    private ViewPager viewPager;
+    private NoScrollViewPager viewPager;
     private MenuItem menuItem;
     private BottomNavigationView bottomNavigationView;
     int selectedMenuItem;
@@ -87,7 +87,7 @@ public class RootActivity extends AppCompatActivity {
         actionBar.setDisplayShowTitleEnabled(false);
 
 
-        viewPager = (ViewPager) findViewById(R.id.viewpager);
+        viewPager = (NoScrollViewPager) findViewById(R.id.viewpager);
         bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation);
 
         bottomNavigationView.setItemIconTintList(null);

+ 366 - 0
Apex Mobile/app/src/main/java/com/usai/apex/pdf/PDFPreviewActivity.java

@@ -0,0 +1,366 @@
+package com.usai.apex.pdf;
+
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.v4.content.FileProvider;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.TextView;
+
+import com.github.barteksc.pdfviewer.PDFView;
+import com.github.barteksc.pdfviewer.listener.OnLoadCompleteListener;
+import com.github.barteksc.pdfviewer.listener.OnPageChangeListener;
+import com.github.barteksc.pdfviewer.listener.OnPageErrorListener;
+import com.github.barteksc.pdfviewer.util.FitPolicy;
+import com.shockwave.pdfium.PdfDocument;
+import com.usai.apex.ApexTrackingApplication;
+import com.usai.apex.R;
+import com.usai.util.RAUtil;
+
+import java.io.File;
+import java.util.List;
+
+public class PDFPreviewActivity extends AppCompatActivity implements OnPageChangeListener, OnLoadCompleteListener,
+        OnPageErrorListener {
+
+    boolean iscachefile;
+    private static final String TAG = PDFPreviewActivity.class.getSimpleName();
+//    String pdfFileName;
+    PDFView pdfView;
+//    @NonConfigurationInstance
+    Integer pageNumber = 0;
+//    public static final String SAMPLE_FILE = "sample.pdf";
+
+
+
+    protected void openFile() {
+
+        String path=getIntent().getStringExtra("file");
+        File file = new File(path);
+        if (file == null || !file.exists()) {
+            return;
+        }
+
+        Uri uri = null;
+        String type = RAUtil.getMimeType(file.getPath());
+
+        // type "application/pdf"
+        Intent intent = new Intent(Intent.ACTION_VIEW);
+
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+
+            // "com.usai.apex.fileprovider"即是在Manifest文件中配置的authorities
+            uri = FileProvider.getUriForFile(this, "com.usai.apex.fileprovider", file);
+            // 给目标应用一个临时授权
+            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+        } else {
+            uri = Uri.fromFile(file);
+        }
+
+        intent.setDataAndType(uri, type);
+
+        if (getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
+            // someone knows how to handle this mime type with this scheme, don't download.
+            try {
+                startActivity(intent);
+                return;
+            } catch (Exception ex) {
+                Log.d("Open File", "activity not found for " + type + " over " + uri, ex);
+            }
+
+        } else {
+            Log.d("Open File", "openFileAtPath: " + "No App " + uri);
+
+
+            AlertDialog.Builder builder = new AlertDialog.Builder(
+                    PDFPreviewActivity.this);
+            builder.setMessage("Can not open PDF file, no external App found." );
+
+            builder.setTitle("Open PDF");
+
+            builder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener()
+            {
+
+                @Override
+                public void onClick(DialogInterface dialog, int which)
+                {
+                    dialog.dismiss();
+
+
+                }
+            });
+
+            builder.create().show();
+
+//            try {
+//                shareFile(uri,type);
+//            } catch (Exception e) {
+//                Log.e("Show Dialog Error", "openFileAtPath: ", e);
+//            }
+        }
+
+    }
+
+    protected void shareFile(/*Uri uri, String type*/) {
+
+        String path=getIntent().getStringExtra("file");
+        File file = new File(path);
+        if (file == null || !file.exists()) {
+            return;
+        }
+        Uri uri = null;
+        String type = RAUtil.getMimeType(file.getPath());
+
+
+
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+
+            // "com.usai.apex.fileprovider"即是在Manifest文件中配置的authorities
+            uri = FileProvider.getUriForFile(this, "com.usai.apex.fileprovider", file);
+            // 给目标应用一个临时授权
+        } else {
+            uri = Uri.fromFile(file);
+        }
+
+        Intent share = new Intent();
+        share.setAction(Intent.ACTION_SEND);
+        share.putExtra(Intent.EXTRA_STREAM, uri);
+        share.setType(type);
+
+
+        share.putExtra(Intent.EXTRA_TEXT, "test content text");   //附带的说明信息
+        share.putExtra(Intent.EXTRA_SUBJECT, "test subject");
+        share.putExtra(Intent.EXTRA_EMAIL, new String[]{"isbcd@hotmail.com","isbcd.zhangrui@gmail.com"});
+        share.putExtra(Intent.EXTRA_CC, new String[]{"ray.zhang@united-cn.net"});
+//        startActivity(Intent.createChooser(share,getString(R.string.str_sendto)));
+        startActivity(Intent.createChooser(share, "Share"));
+
+
+
+
+//        Intent share = new Intent(Intent.ACTION_SEND);
+//        String filename = (String) v.getTag();
+//        share.putExtra(Intent.EXTRA_STREAM,
+//                Uri.fromFile(new File(Environment.getExternalStorageDirectory().getPath()+"/Apex Mobile/"+filename)));
+//        String[] token = filename.split("\\.");
+//        String ext = token[token.length-1];
+//        share.setType("application/"+ext);//此处可发送多种文件
+
+    }
+
+    private void setCustomActionBar() {
+        ActionBar.LayoutParams lp =new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);
+        View mActionBarView = LayoutInflater.from(this).inflate(R.layout.actionbar_customtitle, null);
+
+        String path=getIntent().getStringExtra("file");
+        String title=new File(path).getName();
+        TextView mtitleview= mActionBarView.findViewById(R.id.title);
+//        String title = mParams.getString("title");
+        mtitleview.setText(title);
+//
+//        mActionBarView.setBackgroundColor(Color.YELLOW);
+//        titleview.setBackgroundColor(Color.BLUE);
+        ActionBar actionBar = getSupportActionBar();
+        actionBar.setCustomView(mActionBarView, lp);
+        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
+        actionBar.setDisplayShowCustomEnabled(true);
+        actionBar.setDisplayHomeAsUpEnabled(true);
+
+
+//        actionBar.setIcon(getNumberDrawable());
+//        actionBar.setDisplayShowHomeEnabled(true);
+        actionBar.setDisplayShowTitleEnabled(false);
+    }
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        switch (item.getItemId()) {
+
+            case android.R.id.home:
+                finish();
+                break;
+            case R.id.action_save:
+                SavePDF();
+                break;
+            case R.id.action_open:
+                openFile();
+                break;
+            case R.id.action_send:
+                shareFile();
+                break;
+
+            default: break;
+        }
+        return super.onOptionsItemSelected(item);
+    }
+
+    private void SavePDF()
+    {
+
+
+        String todir=ApexTrackingApplication.getInstance().getDocumentDir();
+
+//        String sourcefile=getIntent().getStringExtra("file");
+        File source =new File(getIntent().getStringExtra("file"));
+        String filename = source.getName();
+//        boolean successful= source.renameTo(new File(todir+filename));
+
+        boolean successful=RAUtil.copyFile(getIntent().getStringExtra("file"),todir+"/"+filename);
+
+
+//        Files.copy(source, Path target, CopyOption... options)
+
+        String title= "Save document";
+        String msg = "Can not save document";
+
+        if(successful)
+        {
+            msg= "Document Saved";
+
+        }
+
+        AlertDialog.Builder builder = new AlertDialog.Builder(
+                PDFPreviewActivity.this);
+        builder.setMessage(msg);
+
+        builder.setTitle(title);
+
+        builder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener()
+        {
+
+            @Override
+            public void onClick(DialogInterface dialog, int which)
+            {
+                dialog.dismiss();
+
+
+            }
+        });
+
+        builder.create().show();
+
+    }
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu)
+    {
+        // Inflate the menu; this adds items to the action bar if it is present.
+
+        if(iscachefile)
+            getMenuInflater().inflate(R.menu.pdf_cached_preview, menu);
+        else
+            getMenuInflater().inflate(R.menu.pdf_saved_preview, menu);
+        return true;
+    }
+    @Override
+    protected void onDestroy()
+    {
+
+        if(iscachefile) {
+            String file = getIntent().getStringExtra("file");
+            new File(file).delete();
+        }
+        super.onDestroy();
+    }
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_pdf_preview);
+
+        setCustomActionBar();
+        pdfView = findViewById(R.id.pdfView);
+        pdfView.setBackgroundColor(Color.LTGRAY);
+        pdfView.setPadding(10,10,10,10);
+
+        String file=getIntent().getStringExtra("file");
+        iscachefile = getIntent().getBooleanExtra("iscache",false);
+//        pdfFileName = assetFileName;
+        pdfView.fromFile(new File(file))
+//        pdfView.fromAsset(SAMPLE_FILE)
+                .defaultPage(pageNumber)
+                .onPageChange(this)
+                .enableAnnotationRendering(true)
+                .onLoad(this)
+//                .scrollHandle(new DefaultScrollHandle(this))
+
+                .spacing(10) // in dp
+                .onPageError(this)
+                .pageFitPolicy(FitPolicy.BOTH)
+                .load();
+
+        /*
+        pdfView.fromAsset(SAMPLE_FILE)
+//                .pages(0, 2, 1, 3, 3, 3) // all pages are displayed by default
+                .enableSwipe(true) // allows to block changing pages using swipe
+                .swipeHorizontal(false)
+                .enableDoubletap(true)
+                .defaultPage(0)
+                // allows to draw something on the current page, usually visible in the middle of the screen
+//                .onDraw(this)
+                // allows to draw something on all pages, separately for every page. Called only for visible pages
+//                .onDrawAll(onDrawListener)
+                .onLoad(this) // called after document is loaded and starts to be rendered
+                .onPageChange(this)
+//                .onPageScroll(onPageScrollListener)
+//                .onError(onErrorListener)
+                .onPageError(this)
+//                .onRender(onRenderListener) // called after document is rendered for the first time
+                // called on single tap, return true if handled, false to toggle scroll handle visibility
+//                .onTap(onTapListener)
+                .enableAnnotationRendering(false) // render annotations (such as comments, colors or forms)
+                .password(null)
+                .scrollHandle(null)
+                .enableAntialiasing(true) // improve rendering a little bit on low-res screens
+                // spacing between pages in dp. To define spacing color, set view background
+                .spacing(0)
+//                .linkHandler(DefaultLinkHandler)
+                .pageFitPolicy(FitPolicy.WIDTH)
+                .load();*/
+    }
+
+    @Override
+    public void loadComplete(int nbPages) {
+        PdfDocument.Meta meta = pdfView.getDocumentMeta();
+        Log.e(TAG, "title = " + meta.getTitle());
+        Log.e(TAG, "author = " + meta.getAuthor());
+        Log.e(TAG, "subject = " + meta.getSubject());
+        Log.e(TAG, "keywords = " + meta.getKeywords());
+        Log.e(TAG, "creator = " + meta.getCreator());
+        Log.e(TAG, "producer = " + meta.getProducer());
+        Log.e(TAG, "creationDate = " + meta.getCreationDate());
+        Log.e(TAG, "modDate = " + meta.getModDate());
+
+        printBookmarksTree(pdfView.getTableOfContents(), "-");
+    }
+
+    @Override
+    public void onPageChanged(int page, int pageCount) {
+
+    }
+
+    @Override
+    public void onPageError(int page, Throwable t) {
+
+    }
+
+    public void printBookmarksTree(List<PdfDocument.Bookmark> tree, String sep) {
+        for (PdfDocument.Bookmark b : tree) {
+
+            Log.e(TAG, String.format("%s %s, p %d", sep, b.getTitle(), b.getPageIdx()));
+
+            if (b.hasChildren()) {
+                printBookmarksTree(b.getChildren(), sep + "-");
+            }
+        }
+    }
+}

+ 42 - 8
Apex Mobile/app/src/main/java/com/usai/apex/saved/SavedDocumentsFragment.java

@@ -18,6 +18,7 @@ import android.widget.ListView;
 import android.widget.TextView;
 
 import com.usai.apex.R;
+import com.usai.apex.pdf.PDFPreviewActivity;
 import com.usai.apex.swipemenulistview.BaseSwipListAdapter;
 import com.usai.apex.swipemenulistview.SwipeMenu;
 import com.usai.apex.swipemenulistview.SwipeMenuCreator;
@@ -119,14 +120,31 @@ public class SavedDocumentsFragment extends AMListFragment/* implements View.OnT
                 @Override
                 public void onClick(View v)
                 {
-                    Intent share = new Intent(Intent.ACTION_SEND);
-                    String filename = (String) v.getTag();
-                    share.putExtra(Intent.EXTRA_STREAM,
-                            Uri.fromFile(new File(Environment.getExternalStorageDirectory().getPath()+"/Apex Mobile/"+filename)));
-                    String[] token = filename.split("\\.");
-                    String ext = token[token.length-1];
-                    share.setType("application/"+ext);//此处可发送多种文件
-                    startActivity(Intent.createChooser(share,getString(R.string.str_sendto)));
+
+                    if(false)
+                    {
+                        Intent intent = new Intent(Intent.ACTION_SEND); // 启动分享发送的属性
+                        intent.setType("text/plain"); // 分享发送的数据类型
+                        intent.putExtra(Intent.EXTRA_TEXT, "email test"); // 分享的内容
+                        startActivity(Intent.createChooser(intent,"abcdefg!!!!!!!"));// 目标应用选择对话框的标题
+                    }
+                    else
+
+                    {
+                        Intent share = new Intent(Intent.ACTION_SEND);
+                        String filename = (String) v.getTag();
+                        share.putExtra(Intent.EXTRA_STREAM,
+                                Uri.fromFile(new File(Environment.getExternalStorageDirectory().getPath()+"/Apex Mobile/"+filename)));
+                        String[] token = filename.split("\\.");
+                        String ext = token[token.length-1];
+                        share.setType("application/"+ext);//此处可发送多种文件
+                        share.putExtra(Intent.EXTRA_TEXT, "test content text");   //附带的说明信息
+                        share.putExtra(Intent.EXTRA_SUBJECT, "test subject");
+                        share.putExtra(Intent.EXTRA_EMAIL, new String[]{"isbcd@hotmail.com","isbcd.zhangrui@gmail.com"});
+                        share.putExtra(Intent.EXTRA_CC, new String[]{"ray.zhang@united-cn.net"});
+                        startActivity(Intent.createChooser(share,getString(R.string.str_sendto)));
+                    }
+
 
                 }
             });
@@ -260,6 +278,21 @@ public class SavedDocumentsFragment extends AMListFragment/* implements View.OnT
     @Override
     public void onListItemClick(ListView l, View v, int position, long id)
     {
+
+        String filename = (String) getData().get(position).get("title");
+        String file=new File(Environment
+                .getExternalStorageDirectory().getPath()
+                + "/Apex Mobile/"
+                + filename).getAbsolutePath();
+
+        Intent myIntent = new Intent();
+        myIntent = new Intent(getActivity(), PDFPreviewActivity.class);
+
+        myIntent.putExtra("file",file);
+        myIntent.putExtra("iscache",false);
+        startActivity(myIntent);
+
+        /*
         Log.d("FragmentList", "Item clicked: " + id);
         String filename = (String) getData().get(position).get("title");
         Intent intent = new Intent("android.intent.action.VIEW");
@@ -277,6 +310,7 @@ public class SavedDocumentsFragment extends AMListFragment/* implements View.OnT
 //	    startActivity(intent);
         startActivity(Intent.createChooser(intent,getString(R.string.str_openfile)));
 //
+*/
 //		Intent intent = new Intent();
 //		if(title.equals("Search documents online"))
 //		{

+ 34 - 0
Apex Mobile/app/src/main/java/com/usai/util/RAUtil.java

@@ -27,6 +27,7 @@ import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -699,6 +700,39 @@ public class RAUtil {
         return mime;
     }
 
+    /**
+     * 复制单个文件
+     * @param oldPath String 原文件路径 如:c:/fqf.txt
+     * @param newPath String 复制后路径 如:f:/fqf.txt
+     * @return boolean
+     */
+    public static boolean copyFile(String oldPath, String newPath) {
+        try {
+            int bytesum = 0;
+            int byteread = 0;
+            File oldfile = new File(oldPath);
+            if (oldfile.exists()) { //文件存在时
+                InputStream inStream = new FileInputStream(oldPath); //读入原文件
+                FileOutputStream fs = new FileOutputStream(newPath);
+                byte[] buffer = new byte[4*1024];
+                int length;
+                while ( (byteread = inStream.read(buffer)) != -1) {
+                    bytesum += byteread; //字节数 文件大小
+                    System.out.println(bytesum);
+                    fs.write(buffer, 0, byteread);
+                }
+                inStream.close();
+            }
+        }
+        catch (Exception e) {
+            System.out.println("复制单个文件操作出错");
+            e.printStackTrace();
+            return false;
+
+        }
+        return true;
+
+    }
     public static void openFile(Context context,File file) {
 
         if (context == null || file == null || !file.exists()) {

+ 2 - 0
Apex Mobile/app/src/main/res/layout/actionbar_customtitle.xml

@@ -11,7 +11,9 @@
         android:layout_height="0dp"
         android:layout_centerInParent="true"
 
+        android:ellipsize="end"
         android:gravity="center"
+        android:singleLine="true"
         android:textColor="@color/icon_gray"
         android:textSize="17sp"
         app:layout_constraintBottom_toBottomOf="parent"

+ 14 - 0
Apex Mobile/app/src/main/res/layout/activity_pdf_preview.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout 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="com.usai.redant.mytestpdf.MyQLActivity">
+
+    <com.github.barteksc.pdfviewer.PDFView
+        android:id="@+id/pdfView"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"/>
+
+</android.support.constraint.ConstraintLayout>

+ 1 - 1
Apex Mobile/app/src/main/res/layout/activity_root.xml

@@ -6,7 +6,7 @@
     android:layout_height="match_parent"
     android:orientation="vertical">
 
-    <android.support.v4.view.ViewPager
+    <com.usai.apex.mainframe.NoScrollViewPager
         android:id="@+id/viewpager"
         android:layout_width="match_parent"
         android:layout_height="match_parent"

+ 1 - 0
Apex Mobile/app/src/main/res/layout/saved_doc.xml

@@ -58,6 +58,7 @@
             android:layout_marginEnd="16dp"
             android:layout_marginTop="8dp"
             android:src="@drawable/ic_share_new"
+            android:visibility="invisible"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintTop_toTopOf="parent" />

+ 24 - 0
Apex Mobile/app/src/main/res/menu/pdf_cached_preview.xml

@@ -0,0 +1,24 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+ >
+
+
+    <item
+        android:id="@+id/action_save"
+        android:orderInCategory="100"
+        android:title="@string/action_pdf_save"
+        android:icon="@drawable/ic_save"
+        app:showAsAction="ifRoom" />
+    <item
+        android:id="@+id/action_open"
+        android:orderInCategory="100"
+        android:title="@string/action_pdf_open"
+        app:showAsAction="never" />
+    <item
+        android:id="@+id/action_send"
+        android:orderInCategory="200"
+
+        android:title="@string/action_pdf_send"
+        app:showAsAction="never" />
+
+</menu>

+ 24 - 0
Apex Mobile/app/src/main/res/menu/pdf_saved_preview.xml

@@ -0,0 +1,24 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+ >
+
+
+    <!--<item-->
+        <!--android:id="@+id/action_save"-->
+        <!--android:orderInCategory="100"-->
+        <!--android:title="@string/action_pdf_save"-->
+        <!--android:icon="@drawable/ic_save"-->
+        <!--app:showAsAction="ifRoom" />-->
+    <item
+        android:id="@+id/action_open"
+        android:orderInCategory="100"
+        android:title="@string/action_pdf_open"
+        app:showAsAction="never" />
+    <item
+        android:id="@+id/action_send"
+        android:orderInCategory="200"
+
+        android:title="@string/action_pdf_send"
+        app:showAsAction="never" />
+
+</menu>

+ 3 - 0
Apex Mobile/app/src/main/res/values/strings.xml

@@ -9,6 +9,9 @@
     <string name="action_deleteall">Delete all</string>
     <string name="action_markallread">Mark all as read</string>
     <string name="action_forget_password">Forget password</string>
+    <string name="action_pdf_save">Save</string>
+    <string name="action_pdf_send">Share</string>
+    <string name="action_pdf_open">Open</string>
     <string name="action_custom_fields">Customize Fields</string>
     <string name="action_sign_in_register"><b>Login</b></string>
     <string name="action_sign_in_short">Sign in</string>