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

添加 小绵羊截图方案的上传截图功能

zengjiebin лет назад: 7
Родитель
Сommit
5e5131221e

+ 27 - 0
app/src/main/java/com/sheep/gamegroup/absBase/AbsChooseImageActivity.java

@@ -9,7 +9,9 @@ import com.kfzs.appstore.utils.string.HexUtils;
 import com.kfzs.duanduan.react.upfile.UpFileListener;
 import com.kfzs.duanduan.react.upfile.UpFileUtils;
 import com.sheep.gamegroup.model.entity.UploadResult;
+import com.sheep.gamegroup.util.ListUtil;
 import com.sheep.gamegroup.view.dialog.DialogShowLoading;
+import com.sheep.jiuyan.samllsheep.utils.G;
 import com.yalantis.ucrop.UCrop;
 
 import java.io.File;
@@ -55,6 +57,31 @@ public abstract class AbsChooseImageActivity extends BaseActivity implements UpF
                 .setPreviewEnabled(true)
                 .start(this, PhotoPicker.REQUEST_CODE);
     }
+    public void showChooseDialog(boolean isCrop, boolean isUpload, int photoCount, File dir) {
+        if(dir.exists() && dir.listFiles().length > 0) {
+            photoCount = Math.max(1, photoCount);
+            this.isUpload = isUpload;
+            this.isCrop = isCrop && photoCount == 1;
+            this.photoCount = photoCount;
+            this.photos = null;
+            this.path = null;
+            this.urls.clear();
+            PhotoPicker.builder()
+                    .setPhotoCount(photoCount)
+                    .setShowCamera(showCamera)
+                    .setShowGif(false)
+                    .setPreviewEnabled(true)
+                    .setPicker(ListUtil.asList(new ListUtil.CallBack<File, String>() {
+                        @Override
+                        public String call(File file) {
+                            return file.getAbsolutePath();
+                        }
+                    }, dir.listFiles()))
+                    .start(this, PhotoPicker.REQUEST_CODE);
+        } else {
+            G.showToast("暂无截图");
+        }
+    }
     private boolean showCamera = false;
 
     public void setShowCamera(boolean showCamera) {

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/util/DataUtil.java

@@ -291,7 +291,7 @@ public class DataUtil {
         return null;
     }
     //是否使用小绵羊截图方案
-    public static final boolean IS_USE_SCREEN_SHOT = true;
+    public static final boolean IS_USE_SCREEN_SHOT = TestUtil.isTest();
     /**
      * 截图路径
      *

+ 11 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/TaskDetailAct.java

@@ -74,6 +74,7 @@ import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 import org.afinal.simplecache.ApiKey;
 import org.greenrobot.eventbus.EventBus;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
@@ -620,8 +621,13 @@ public class TaskDetailAct extends AbsChooseImageActivity implements TaskDetailC
                         } catch (Exception e) {
                             e.printStackTrace();
                         }
-                    } else {
-                        showChooseDialog(false, true, DEFAULT_MAX_COUNT);
+                    } else {//截图任务
+                        if(DataUtil.IS_USE_SCREEN_SHOT) {//小绵羊截图方案
+                            File dir = DataUtil.getInstance().getScreenShotsDir(taskEty.getPackage_names());
+                            showChooseDialog(false, true, DEFAULT_MAX_COUNT, dir);
+                        } else {//用户手动截图方案
+                            showChooseDialog(false, true, DEFAULT_MAX_COUNT);
+                        }
                         UMConfigUtils.onEvent(UMConfigUtils.Event.TASK_UPLOAD_PICTURE);
                     }
                     break;
@@ -746,6 +752,9 @@ public class TaskDetailAct extends AbsChooseImageActivity implements TaskDetailC
 //                            onGetNetImageUrl(data);
         dismissLoaddingDialog();
         G.showToast("提交成功,等待审核!");
+        if(DataUtil.IS_USE_SCREEN_SHOT) {//小绵羊截图方案:上传截图成功后删除之前的截图
+            DataUtil.getInstance().clearScreenShots();
+        }
 
         if(isFromTaskList)//之前界面为任务记录界面,需要回调刷新任务记录列表
             setResult(RESULT_OK);

+ 13 - 0
app/src/main/res/layout-um/act_preview_screen_shot.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent">
+
+  <ImageView
+      android:id="@+id/preview_image"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent"
+      android:scaleType="centerCrop"/>
+
+</LinearLayout>

+ 36 - 0
app/src/main/res/layout-um/global_screenshot.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+    <ImageView android:id="@+id/global_screenshot_background"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:src="@android:color/black"
+        android:visibility="gone" />
+    <ImageView android:id="@+id/global_screenshot"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:background="@drawable/screenshot_panel"
+        android:visibility="gone"
+        android:adjustViewBounds="true" />
+    <ImageView android:id="@+id/global_screenshot_flash"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:src="@android:color/white"
+        android:visibility="gone" />
+</FrameLayout>