Bläddra i källkod

1.修改Android Apex CRM,完成图片预览。

Pen Li 7 år sedan
förälder
incheckning
efad0e4f0d

+ 3 - 0
ApexDrivers/RAUtilsLibrary/src/main/AndroidManifest.xml

@@ -83,6 +83,9 @@
 
         <activity android:name=".preview.RAPDFPreviewActivity"/>
 
+        <activity android:name=".InfinitePhoto.InfinitePhotoActivity"
+            android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"/>
+
     </application>
 
 </manifest>

+ 159 - 0
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/InfinitePhoto/InfinitePhotoActivity.java

@@ -0,0 +1,159 @@
+package com.usai.redant.rautils.InfinitePhoto;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.widget.TextView;
+
+import com.usai.redant.rautils.R;
+import com.usai.redant.rautils.carousel.CarouselView;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+
+public class InfinitePhotoActivity extends AppCompatActivity {
+
+    private final static String ImagesKey = "ImagesKey";
+    private final static String OffsetKey = "OffsetKey";
+
+    private final static String PhotoItemKeyPath_URL = "url";
+    private final static String PhotoItemKeyPath_Local = "local";
+    private final static String PhotoItemKeyPath_PlaceHolder = "placeHolder";
+
+    public static JSONObject buildPhotoItem(String url, boolean local, int placeHolderResId) {
+        JSONObject json = new JSONObject();
+        try {
+
+            if (url != null) {
+                json.put(PhotoItemKeyPath_URL, url);
+            }
+            json.put(PhotoItemKeyPath_Local,local);
+            json.put(PhotoItemKeyPath_PlaceHolder, placeHolderResId);
+
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        return json;
+    }
+
+    public static void startInfinitePhotoActivity(Activity context, JSONArray images, int offset) {
+        if (context == null || images == null || images.length() == 0) {
+            return;
+        }
+
+        Intent intent = new Intent(context, InfinitePhotoActivity.class);
+        intent.putExtra(ImagesKey, images.toString());
+        intent.putExtra(OffsetKey, offset);
+
+        context.startActivity(intent);
+    }
+
+    private CarouselView mCarouselView;
+    private TextView mIndicatorTv;
+    private ArrayList<InfinitePhotoItem> mPhotoItems;
+    private int mOffset;
+    private Context mCtx = this;
+    private InfinitePhotoActivity self = this;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.ra_infinite_photo_activity);
+
+        mCarouselView = findViewById(R.id.ra_infinite_photo_carousel);
+        mIndicatorTv = findViewById(R.id.ra_infinite_photo_indicator_tv);
+
+        Intent intent = getIntent();
+        if (intent != null) {
+
+            String imagesStr = intent.getStringExtra(ImagesKey);
+            int offset = intent.getIntExtra(OffsetKey, 0);
+
+            try {
+                JSONArray images = new JSONArray(imagesStr);
+                if (images.length() > 0) {
+
+                    ArrayList<InfinitePhotoItem> tmpArr = new ArrayList<>();
+                    for (int i = 0; i < images.length(); i++) {
+
+                        JSONObject itemJson = images.getJSONObject(i);
+                        InfinitePhotoItem photoItem = new InfinitePhotoItem(self);
+                        photoItem.setValuesForKeysWithJSON(itemJson);
+                        tmpArr.add(photoItem);
+                    }
+
+                    mPhotoItems = tmpArr;
+                }
+
+            } catch (JSONException e) {
+                e.printStackTrace();
+            }
+
+            mOffset = offset;
+        }
+
+        updateIndicator();
+
+        // Carousel
+        mCarouselView.setAutoScroll(false);
+        mCarouselView.registResourceId(R.layout.ra_infinite_photo_cell);
+        mCarouselView.setDelegate(new CarouselView.CarouselDelegate() {
+            @Override
+            public void carouselWillShowItem(CarouselView carousel, View cell, int index) {
+
+                if (cell instanceof InfinitePhotoItemCell) {
+
+                    InfinitePhotoItemCell photoItemCell = (InfinitePhotoItemCell) cell;
+                    photoItemCell.setActivity(self);
+
+                    if (index >= mPhotoItems.size()) {
+                        photoItemCell.setPhotoItem(null);
+                    } else {
+                        InfinitePhotoItem photoItem = mPhotoItems.get(index);
+                        photoItemCell.setPhotoItem(photoItem);
+                    }
+
+                    TextView tv = photoItemCell.findViewById(R.id.test);
+                    tv.setText("" + (index + 1));
+                }
+
+            }
+
+            @Override
+            public void carouselDidShowItem(CarouselView carousel, int index) {
+                mOffset = index;
+                updateIndicator();
+            }
+
+            @Override
+            public int carouselNumberOfItems(CarouselView carousel) {
+                if (mPhotoItems == null) {
+                    return 0;
+                }
+                return mPhotoItems.size();
+            }
+        });
+        mCarouselView.reloadDataWithOffset(mOffset);
+    }
+
+    /**
+     * Private
+     * */
+
+    private void updateIndicator() {
+
+        int index = mOffset + 1;
+        if (index > mPhotoItems.size()) {
+            index = mPhotoItems.size();
+        }
+        String offsetStr = String.format("%d/%d",index, mPhotoItems.size());
+        mIndicatorTv.setText(offsetStr);
+    }
+
+}

+ 128 - 0
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/InfinitePhoto/InfinitePhotoItem.java

@@ -0,0 +1,128 @@
+package com.usai.redant.rautils.InfinitePhoto;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.os.Handler;
+import android.os.Looper;
+import android.util.Log;
+
+import com.usai.redant.rautils.base.BaseObject;
+import com.usai.redant.rautils.operationQueue.OperationQueue;
+import com.usai.redant.rautils.utils.ImageUtil;
+
+import org.json.JSONObject;
+
+import java.io.File;
+import java.lang.ref.WeakReference;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public   class InfinitePhotoItem extends BaseObject {
+
+    public final static int PlaceHolderResIdNone = -1;
+
+    public String url;
+    public boolean local;
+    public Bitmap image;
+    private WeakReference<InfinitePhotoItemUIDelegate> mWeakdelegate;
+    private InfinitePhotoItem self = this;
+
+    private WeakReference<Activity> mWeakCtx;
+    public InfinitePhotoItem(Activity context) {
+        if (context != null) {
+            mWeakCtx = new WeakReference<>(context);
+        } else {
+            mWeakCtx = null;
+        }
+    }
+
+    @Override
+    public void setValuesForKeysWithJSON(JSONObject json) {
+        super.setValuesForKeysWithJSON(json);
+
+        fetchPhoto();
+    }
+
+    private InfinitePhotoItemUIDelegate getDelegate() {
+        if (mWeakdelegate == null) {
+            return null;
+        } else {
+            return mWeakdelegate.get();
+        }
+    }
+
+    private void setWeakDelegate(InfinitePhotoItemUIDelegate delegate) {
+        if (delegate == null) {
+            mWeakdelegate = null;
+        } else {
+            mWeakdelegate = new WeakReference<>(delegate);
+        }
+    }
+
+    public void setImage(Bitmap image) {
+        this.image = image;
+
+        InfinitePhotoItemUIDelegate oldDelegate = getDelegate();
+        if (oldDelegate != null) {
+            oldDelegate.refreshUI();
+        }
+    }
+
+    public Bitmap getImage() {
+        return image;
+    }
+
+    public void setDelegate(InfinitePhotoItemUIDelegate delegate) {
+        InfinitePhotoItemUIDelegate oldDelegate = getDelegate();
+        if (oldDelegate != null) {
+            oldDelegate.unbind();
+        }
+
+        setWeakDelegate(delegate);
+    }
+
+    private void fetchPhoto() {
+        OperationQueue.sharedQueue().addOperationTask(new OperationQueue.OperationBackgroundCallBack() {
+            @Override
+            public Object operationDoInBackground() {
+
+                Bitmap photo = null;
+                if (url != null) {
+
+                    if (local) {
+
+                        photo = ImageUtil.loadImageFromFile(null, new File(url));
+
+                    } else {
+
+                        if (mWeakCtx != null) {
+                            try {
+                                photo = ImageUtil.loadImageFromURL(mWeakCtx.get(),new URI(url),0,0);
+                            } catch (URISyntaxException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+
+                }
+
+                Log.d("Load Photo", "operationDoInBackground: " + photo);
+                return photo;
+            }
+        }, new OperationQueue.OperationCompletionCallBack() {
+            @Override
+            public void operationCompletion(Object object) {
+
+                if (object != null && object instanceof Bitmap) {
+
+                    setImage((Bitmap) object);
+
+                } else {
+                    setImage(null);
+                }
+
+            }
+        }, null);
+    }
+}

+ 89 - 0
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/InfinitePhoto/InfinitePhotoItemCell.java

@@ -0,0 +1,89 @@
+package com.usai.redant.rautils.InfinitePhoto;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.os.Looper;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.usai.redant.rautils.R;
+
+import java.lang.ref.WeakReference;
+
+public class InfinitePhotoItemCell extends RelativeLayout implements InfinitePhotoItemUIDelegate {
+
+    private WeakReference<Activity> mWeakActivity;
+
+    public InfinitePhotoItemCell(Context context) {
+        super(context);
+    }
+
+    public InfinitePhotoItemCell(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public InfinitePhotoItemCell(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+    }
+
+    private InfinitePhotoItem mPhotoItem;
+    private ImageView mPhotoIv;
+
+    public void setActivity(Activity activity) {
+
+        if (activity == null) {
+            mWeakActivity = null;
+        } else {
+            mWeakActivity = new WeakReference<>(activity);
+        }
+    }
+
+    public void setPhotoItem(InfinitePhotoItem photoItem) {
+        if (mPhotoItem != null) {
+            mPhotoItem.setDelegate(null);
+        }
+
+        mPhotoItem = photoItem;
+        mPhotoItem.setDelegate(this);
+
+        refreshUI();
+    }
+
+    @Override
+    public void refreshUI() {
+        if (mWeakActivity != null) {
+            Activity activity = mWeakActivity.get();
+            if (activity != null) {
+                activity.runOnUiThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (mPhotoIv == null) {
+                            mPhotoIv = findViewById(R.id.ra_infinite_photo_iv);
+                        }
+
+                        Bitmap bitmap = null;
+                        if (mPhotoItem != null) {
+                             bitmap = mPhotoItem.getImage();
+                        }
+
+                        if (bitmap == null) {
+                            TextView tv = findViewById(R.id.test);
+                            tv.setText("null");
+                        }
+                        mPhotoIv.setImageBitmap(bitmap);
+                    }
+                });
+            }
+        }
+    }
+
+    @Override
+    public void unbind() {
+        if (mPhotoItem != null) {
+            mPhotoItem = null;
+        }
+    }
+}

+ 8 - 0
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/InfinitePhoto/InfinitePhotoItemUIDelegate.java

@@ -0,0 +1,8 @@
+package com.usai.redant.rautils.InfinitePhoto;
+
+public interface InfinitePhotoItemUIDelegate {
+
+    void refreshUI();
+    void unbind();
+
+}

+ 5 - 4
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/carousel/CarouselView.java

@@ -108,17 +108,18 @@ public class CarouselView extends RelativeLayout {
     }
 
     public void reloadData() {
+        reloadDataWithOffset(0);
+    }
+
+    public void reloadDataWithOffset(int offset) {
         mAdapter.notifyDataSetChanged();
-        mCurrentItem = 1;
+        mCurrentItem = 1 + offset;
         mPager.setCurrentItem(mCurrentItem,false);
         if (mAutoScroll) {
-
             startAutoScroll();
         }
     }
 
-
-
     public interface CarouselDelegate {
 
         void carouselWillShowItem(CarouselView carousel, View cell, int index);

+ 18 - 18
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/utils/FileManager.java

@@ -59,14 +59,14 @@ public class FileManager {
 
     public static String internalStorageFileDir(Context context) {
 
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
-        {
-            Context ctx = context.createDeviceProtectedStorageContext();
-            File dir = ctx.getFilesDir();
-            return dir.getAbsolutePath();
-        }
-        else
-        {
+//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+//        {
+//            Context ctx = context.createDeviceProtectedStorageContext();
+//            File dir = ctx.getFilesDir();
+//            return dir.getAbsolutePath();
+//        }
+//        else
+//        {
             String appName = RAUtil.getApplicationName(context);
             String dir = SDCardRoot() + appName;
             File file = new File(dir);
@@ -75,19 +75,19 @@ public class FileManager {
             }
 
             return dir;
-        }
+//        }
     }
 
     public static String internalStorageTempDir(Context context) {
 
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
-        {
-            Context ctx = context.createDeviceProtectedStorageContext();
-            File dir = ctx.getCacheDir();
-            return dir.getAbsolutePath();
-        }
-        else
-        {
+//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+//        {
+//            Context ctx = context.createDeviceProtectedStorageContext();
+//            File dir = ctx.getCacheDir();
+//            return dir.getAbsolutePath();
+//        }
+//        else
+//        {
             String appName = RAUtil.getApplicationName(context);
             String dir = SDCardRoot() + appName + File.separator + "temp";
             File file = new File(dir);
@@ -96,7 +96,7 @@ public class FileManager {
             }
 
             return dir;
-        }
+//        }
 
     }
 

+ 12 - 0
ApexDrivers/RAUtilsLibrary/src/main/res/drawable/ra_infinite_photo_index_round_corner.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <corners android:radius="15dp">
+
+    </corners>
+
+    <solid android:color="#ffffff">
+
+    </solid>
+
+</shape>

+ 28 - 0
ApexDrivers/RAUtilsLibrary/src/main/res/layout/ra_infinite_photo_activity.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
+
+    <com.usai.redant.rautils.carousel.CarouselView
+        android:id="@+id/ra_infinite_photo_carousel"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="#000000"
+        >
+
+    </com.usai.redant.rautils.carousel.CarouselView>
+
+    <TextView
+        android:id="@+id/ra_infinite_photo_indicator_tv"
+        android:layout_width="100dp"
+        android:layout_height="30dp"
+        android:layout_marginTop="20dp"
+        android:layout_centerHorizontal="true"
+        android:textColor="#888888"
+        android:background="@drawable/ra_infinite_photo_index_round_corner"
+        android:textSize="17sp"
+        android:gravity="center"
+        android:text="100/100"
+        />
+
+</RelativeLayout>

+ 19 - 0
ApexDrivers/RAUtilsLibrary/src/main/res/layout/ra_infinite_photo_cell.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.usai.redant.rautils.InfinitePhoto.InfinitePhotoItemCell xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
+
+    <ImageView
+        android:id="@+id/ra_infinite_photo_iv"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:scaleType="fitCenter"
+        android:background="#aaffaa"
+        />
+
+    <TextView
+        android:id="@+id/test"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
+
+</com.usai.redant.rautils.InfinitePhoto.InfinitePhotoItemCell>

+ 7 - 0
ApexDrivers/RAUtilsLibrary/src/main/res/values/styles.xml

@@ -8,4 +8,11 @@
         <item name="colorAccent">@color/colorAccent</item>
     </style>
 
+    <style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light">
+        <item name="windowNoTitle">true</item>
+        <item name="windowActionBar">false</item>
+        <item name="android:windowFullscreen">true</item>
+        <item name="android:windowContentOverlay">@null</item>
+    </style>
+
 </resources>

+ 186 - 8
ApexDrivers/apexcrm/src/main/java/com/usai/apex/apexcrm/MainActivity.java

@@ -1,22 +1,29 @@
 package com.usai.apex.apexcrm;
 
 import android.Manifest;
+import android.app.Activity;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.net.Uri;
 import android.os.Bundle;
 import android.support.v4.content.PermissionChecker;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AlertDialog;
 import android.support.v7.app.AppCompatActivity;
 
 import android.util.Log;
+import android.view.MenuItem;
 import android.view.View;
 import android.webkit.ValueCallback;
 import android.widget.Toast;
 
 import com.usai.apex.apexcrm.dataProvider.DataProvider;
+import com.usai.redant.rautils.InfinitePhoto.InfinitePhotoActivity;
 import com.usai.redant.rautils.actionSheet.ActionSheet;
 import com.usai.redant.rautils.camera.CameraHelper;
 import com.usai.redant.rautils.email.EmailHelper;
+import com.usai.redant.rautils.fileViewer.FileViewerActivity;
 import com.usai.redant.rautils.map.MapHelper;
 import com.usai.redant.rautils.preview.RAPDFPreviewActivity;
 import com.usai.redant.rautils.utils.FileManager;
@@ -35,6 +42,7 @@ import java.util.Date;
 
 
 import static com.usai.apex.apexcrm.RAWebView.RALocalFileScheme;
+import static com.usai.redant.rautils.InfinitePhoto.InfinitePhotoItem.PlaceHolderResIdNone;
 import static com.usai.redant.rautils.utils.Network.RESULT_TRUE;
 
 
@@ -57,7 +65,6 @@ public class MainActivity extends AppCompatActivity {
     private JSONArray mExcuteJSArray;
     private RAJSInterface mJSInterface;
 
-
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -77,11 +84,31 @@ public class MainActivity extends AppCompatActivity {
 
         } else {
             mExcuteJSArray = new JSONArray();
-            mWebView.loadUrl("http://192.168.0.138:8080/backend_test/index.html");
+
+            String url = "http://192.168.0.138:8080/backend_test/index.html";
+            Intent intent = getIntent();
+            if (intent != null) {
+                String tmpUrl = intent.getStringExtra("url");
+                if (tmpUrl != null) {
+                    url = tmpUrl;
+
+                    enableActionBarBackItem();
+                }
+            }
+            mWebView.loadUrl(url);
         }
 
     }
 
+    private void enableActionBarBackItem() {
+
+        ActionBar actionBar = getSupportActionBar();
+        if (actionBar != null) {
+            actionBar.setDisplayHomeAsUpEnabled(true);
+            actionBar.setHomeButtonEnabled(true);
+        }
+    }
+
     @Override
     protected void onRestoreInstanceState(Bundle savedInstanceState) {
         super.onRestoreInstanceState(savedInstanceState);
@@ -103,6 +130,17 @@ public class MainActivity extends AppCompatActivity {
         }
     }
 
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+
+        if (item.getItemId() == android.R.id.home) {
+            finish();
+            return true;
+        }
+
+        return super.onOptionsItemSelected(item);
+    }
+
     @Override
     protected void onRestart() {
         super.onRestart();
@@ -213,12 +251,7 @@ public class MainActivity extends AppCompatActivity {
 
                                 saveExcuteJS(js);
 
-                                mWebView.evaluateJavascript(js, new ValueCallback<String>() {
-                                    @Override
-                                    public void onReceiveValue(String value) {
-                                        Log.d(TAG, "onReceiveValue: " + value);
-                                    }
-                                });
+                                evaluateJavaScript(js);
                             }
 
                         } catch (JSONException e) {
@@ -233,6 +266,28 @@ public class MainActivity extends AppCompatActivity {
 
     }
 
+    private void evaluateJavaScript(final String js) {
+
+        if (js != null) {
+
+            runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+
+                    mWebView.evaluateJavascript(js, new ValueCallback<String>() {
+                        @Override
+                        public void onReceiveValue(String value) {
+                            Log.d(TAG, "onReceiveValue: " + value);
+                        }
+                    });
+
+                }
+            });
+
+        }
+
+    }
+
     private void setWebImageWithBase64(String imageWithBase64) {
 
         if (imageWithBase64 != null) {
@@ -263,6 +318,35 @@ public class MainActivity extends AppCompatActivity {
         }
     }
 
+    private void startActivityWithURL(String className, String url) {
+
+        if (className == null) {
+            return;
+        }
+
+        try {
+
+            className = String.format("%s.%s",getPackageName(),className);
+            Class cls = Class.forName(className);
+
+            // a.isAssignableFrom(b); a 是 b的父类,或a == b
+            if (Activity.class.isAssignableFrom(cls)) {
+                Intent intent = new Intent(self, cls);
+                if (url != null) {
+                    intent.putExtra("url",url);
+                }
+                startActivity(intent);
+                return;
+
+            }
+
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+        }
+
+        RAUtil.alertMessage(self,getString(R.string.ra_title_warning),getString(R.string.method_not_found));
+    }
+
     /**
      * Result
      * */
@@ -382,17 +466,92 @@ public class MainActivity extends AppCompatActivity {
 
         @Override
         public void JumpTo(String msg) {
+            Log.d(TAG, "JumpTo: " + msg);
+            if (msg != null) {
 
+                try {
+
+                    JSONObject json = new JSONObject(msg);
+                    String className = json.getString("android_module");
+                    String url = json.getString("url");
+
+                    startActivityWithURL(className, url);
+
+                } catch (JSONException e) {
+                    e.printStackTrace();
+                }
+
+
+            }
         }
 
         @Override
         public void ViewImage(String msg) {
 
+            if (msg != null) {
+
+                try {
+                    JSONObject json = new JSONObject(msg);
+                    JSONArray images = json.getJSONArray("images");
+
+                    int index = json.getInt("index");
+
+                    JSONArray imageArr = new JSONArray();
+                    for (int i = 0; i < images.length(); i++) {
+
+                        String url = images.getString(1 - i);
+//                        String url = String.format("http://192.168.0.130:8080/MyWeb/images/%d.png",i + 1);
+
+                        JSONObject imageJson = InfinitePhotoActivity.buildPhotoItem(url,false,PlaceHolderResIdNone);
+                        imageArr.put(imageJson);
+                    }
+
+                    InfinitePhotoActivity.startInfinitePhotoActivity(self, imageArr, index);
+
+                } catch (JSONException e) {
+                    e.printStackTrace();
+                }
+
+            }
         }
 
         @Override
         public void PostDialog(String msg) {
 
+            if (msg != null) {
+
+                try {
+
+                    final JSONObject json = new JSONObject(msg);
+                    String title = json.getString("title");
+                    String message = json.getString("message");
+                    JSONArray buttons = json.getJSONArray("buttons");
+
+                    AlertDialog.Builder builder = new AlertDialog.Builder(self);
+                    builder.setTitle(title);
+                    builder.setMessage(message);
+                    for (int i = 0; i < buttons.length(); i++) {
+                        JSONObject buttonJson = buttons.getJSONObject(i);
+
+                        String text = buttonJson.getString("text");
+                        final String value = buttonJson.getString("value");
+
+                        builder.setPositiveButton(text, new DialogInterface.OnClickListener() {
+                            @Override
+                            public void onClick(DialogInterface dialog, int which) {
+                                String js = mJSInterface.returnToWebPage(json, value);
+                                evaluateJavaScript(js);
+                            }
+                        });
+                    }
+
+                    builder.show();
+
+                } catch (JSONException e) {
+                    e.printStackTrace();
+                }
+
+            }
         }
 
         @Override
@@ -518,6 +677,25 @@ public class MainActivity extends AppCompatActivity {
         @Override
         public void Signature(String msg) {
 
+            new AlertDialog.Builder(self)
+                    .setTitle("Select Directory")
+                    .setSingleChoiceItems(new String[]{"Files", "Cache"}, -1, new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+
+                            String path;
+                            if (which == 0) {
+                                path = FileManager.internalStorageFileDir(mCtx);
+                            } else {
+                                path = FileManager.internalStorageTempDir(mCtx);
+                            }
+
+                            File file = new File(path);
+                            FileViewerActivity.start(mCtx,file);
+                        }
+                    })
+                    .show();
+
         }
     };
 }

+ 3 - 0
ApexDrivers/apexcrm/src/main/java/com/usai/apex/apexcrm/RAWebView.java

@@ -119,6 +119,9 @@ public class RAWebView extends RelativeLayout {
             webSettings.setAllowFileAccessFromFileURLs(true);
             webSettings.setAllowUniversalAccessFromFileURLs(true);
 
+            // 禁用缓存
+            webSettings.setAppCacheEnabled(false);
+
             hackWebJSMethod();
             hackWebURL();
         }

+ 1 - 0
ApexDrivers/apexcrm/src/main/res/values-zh/strings.xml

@@ -2,6 +2,7 @@
     <string name="app_name">Apex CRM</string>
 
     <string name="btn_cancel">取消</string>
+    <string name="method_not_found">没有方法可用</string>
 
     <string name="allow_camera">请检查相机权限是否打开</string>
     <string name="wb_photo_library_action">相册</string>

+ 2 - 0
ApexDrivers/apexcrm/src/main/res/values/strings.xml

@@ -3,6 +3,8 @@
 
     <string name="btn_cancel">Cancel</string>
 
+    <string name="method_not_found">method not found</string>
+
     <string name="allow_camera">please allow app use camera</string>
     <string name="wb_photo_library_action">Photo Library</string>
     <string name="wb_camera_action">Camera</string>