Przeglądaj źródła

2.2部分修改提交

liujiangyao 8 lat temu
rodzic
commit
f6ef676f90

+ 11 - 0
app/src/main/java/com/kfzs/duanduan/utils/dlg/HelperUtils.java

@@ -113,6 +113,17 @@ public class HelperUtils {
         }
         }
         return sizes / ((1024 * 1024));
         return sizes / ((1024 * 1024));
     }
     }
+    public static long getFreeSpaceB() {
+        File file = Environment.getDataDirectory();
+        StatFs dataFs = new StatFs(file.getPath());
+        long sizes;
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+            sizes = dataFs.getFreeBlocksLong() * dataFs.getBlockSizeLong();
+        } else {
+            sizes = (long) dataFs.getFreeBlocks() * (long) dataFs.getBlockSize();
+        }
+        return sizes ;
+    }
 
 
 
 
     public static int getPercent(long allcount, long calcount) {
     public static int getPercent(long allcount, long calcount) {

+ 67 - 4
app/src/main/java/com/kfzs/duanduan/view/DialogStorageLow.java

@@ -1,14 +1,23 @@
 package com.kfzs.duanduan.view;
 package com.kfzs.duanduan.view;
 
 
 import android.app.Activity;
 import android.app.Activity;
+import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.Intent;
+import android.graphics.PixelFormat;
 import android.provider.Settings;
 import android.provider.Settings;
 import android.support.v7.app.AlertDialog;
 import android.support.v7.app.AlertDialog;
+import android.view.Gravity;
+import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.TextView;
 
 
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.R;
 import com.kfzs.duanduan.utils.dlg.HelperUtils;
 import com.kfzs.duanduan.utils.dlg.HelperUtils;
 import com.kfzs.duanduan.utils.dlg.ViewFindUtils;
 import com.kfzs.duanduan.utils.dlg.ViewFindUtils;
+import com.sheep.jiuyan.samllsheep.SheepApp;
 
 
 /**
 /**
  * @ Created by Dlg
  * @ Created by Dlg
@@ -22,7 +31,9 @@ public class DialogStorageLow {
 
 
     private static AlertDialog mAlertDialog;
     private static AlertDialog mAlertDialog;
 
 
-    public static AlertDialog showDialog(final Activity activity) {
+    private static AlertDialog mAlertDialogs;
+
+    public static AlertDialog showDialog(final Context activity) {
         if (mAlertDialog == null) {
         if (mAlertDialog == null) {
             View view = View.inflate(activity, R.layout.diag_show_install, null);
             View view = View.inflate(activity, R.layout.diag_show_install, null);
             ViewFindUtils.find(view, R.id.btn_diag_show_install_cancle)
             ViewFindUtils.find(view, R.id.btn_diag_show_install_cancle)
@@ -47,11 +58,63 @@ public class DialogStorageLow {
                     .create();
                     .create();
 
 
         }
         }
-        if (!HelperUtils.isActivityOnTop(activity)) {
-            return mAlertDialog;//如果不是顶层窗口,那就不显示了。
-        }
+        //设置弹出全局对话框
+        mAlertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST);
+//        if (!HelperUtils.isActivityOnTop((Activity) activity)) {
+//            return mAlertDialog;//如果不是顶层窗口,那就不显示了。
+//        }
 
 
         mAlertDialog.show();
         mAlertDialog.show();
         return mAlertDialog;
         return mAlertDialog;
     }
     }
+
+    /**
+     * 显示弹出框
+     *
+     * @param context
+     */
+    public static void showPopupWindow(final Context context) {
+        // 获取WindowManager
+        final WindowManager mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+
+
+        final WindowManager.LayoutParams params = new WindowManager.LayoutParams();
+        // 类型
+        params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
+        // 设置flag
+        params.flags = WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
+        // 如果设置了WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,弹出的View收不到Back键的事件
+        // 不设置这个弹出框的透明遮罩显示为黑色
+        params.format = PixelFormat.TRANSLUCENT;
+        // FLAG_NOT_TOUCH_MODAL不阻塞事件传递到后面的窗口
+        // 设置 FLAG_NOT_FOCUSABLE 悬浮窗口较小时,后面的应用图标由不可长按变为可长按
+        // 不设置这个flag的话,home页的划屏会有问题
+        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
+        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
+        params.gravity = Gravity.CENTER;
+
+        final View mView = LayoutInflater.from(context).inflate(R.layout.diag_show_install, null);
+        Button tv_itemdialog_ok = (Button) mView.findViewById(R.id.btn_diag_show_install_manage);
+        Button tv_itemdialog_close = (Button) mView.findViewById(R.id.btn_diag_show_install_cancle);
+
+        tv_itemdialog_ok.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                // 隐藏弹窗
+                mWindowManager.removeView(mView);
+                Intent intent = new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
+                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                context.startActivity(intent);
+            }
+        });
+
+        tv_itemdialog_close.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                mWindowManager.removeView(mView);
+            }
+        });
+
+        mWindowManager.addView(mView, params);
+    }
 }
 }

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

@@ -310,8 +310,9 @@ public class TaskDetailAct extends BaseActivity implements TaskDetailContract.Vi
      * update file
      * update file
      */
      */
     private void uploadImag() {
     private void uploadImag() {
-        Intent intent = new Intent(Intent.ACTION_PICK,
-                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
+//        Intent intent = new Intent(Intent.ACTION_PICK,
+//                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
+        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
         startActivityForResult(intent, 1);
         startActivityForResult(intent, 1);
     }
     }
 
 

+ 16 - 19
app/src/main/java/com/sheep/gamegroup/view/adapter/TryMakeMoneyAdp.java

@@ -174,10 +174,9 @@ public class TryMakeMoneyAdp extends AdpCommonRecy<RecyleObj> {
 //                        }
 //                        }
                         TaskEty taskEty = etyList.get(i).getTask();
                         TaskEty taskEty = etyList.get(i).getTask();
                         taskEty.setRunTask(0);
                         taskEty.setRunTask(0);
-                        taskEty.setBonus(etyList.get(i).getBonus());
                         taskEty.setRelease_task_id(etyList.get(i).getId());
                         taskEty.setRelease_task_id(etyList.get(i).getId());
                         taskEty.setName(etyList.get(i).getName());
                         taskEty.setName(etyList.get(i).getName());
-                        Jump2View.getInstance().goTaskDetailView(context, taskEty, taskAcceptedEty);
+                        Jump2View.getInstance().goDialogActivityView(context, taskEty, taskAcceptedEty);
                     }
                     }
                 });
                 });
                 Glide.with(context)
                 Glide.with(context)
@@ -187,11 +186,13 @@ public class TryMakeMoneyAdp extends AdpCommonRecy<RecyleObj> {
                 viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                 viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                     @Override
                     @Override
                     public void onClick(View v) {
                     public void onClick(View v) {
+
                         TaskEty taskEty = etyList.get(i).getTask();
                         TaskEty taskEty = etyList.get(i).getTask();
                         taskEty.setRunTask(0);
                         taskEty.setRunTask(0);
+                        taskEty.setBonus(etyList.get(i).getBonus());
                         taskEty.setRelease_task_id(etyList.get(i).getId());
                         taskEty.setRelease_task_id(etyList.get(i).getId());
                         taskEty.setName(etyList.get(i).getName());
                         taskEty.setName(etyList.get(i).getName());
-                        Jump2View.getInstance().goDialogActivityView(context, taskEty, taskAcceptedEty);
+                        Jump2View.getInstance().goTaskDetailView(context, taskEty, taskAcceptedEty);
                     }
                     }
                 });
                 });
                 setDebugDownLoad(context, viewHolder.itemView, etyList.get(i).getTask());
                 setDebugDownLoad(context, viewHolder.itemView, etyList.get(i).getTask());
@@ -248,23 +249,17 @@ public class TryMakeMoneyAdp extends AdpCommonRecy<RecyleObj> {
                 ((TextView)viewHolder.itemView.findViewById(R.id.detail_task_tv)).setOnClickListener(new View.OnClickListener() {
                 ((TextView)viewHolder.itemView.findViewById(R.id.detail_task_tv)).setOnClickListener(new View.OnClickListener() {
                     @Override
                     @Override
                     public void onClick(View v) {
                     public void onClick(View v) {
-                        TaskEty taskEty = etyList.get(i).getRelease_task().getTask();
-                        taskEty.setRunTask(1);
-                        taskEty.setBonus(etyList.get(i).getRelease_task().getBonus());
-                        taskEty.setRelease_task_id(etyList.get(i).getRelease_task().getId());
-                        taskEty.setAcceptedTaskId(etyList.get(i).getId());
-                        taskEty.setName(etyList.get(i).getRelease_task().getName());
-                        Jump2View.getInstance().goTaskDetailView(context, taskEty, taskAcceptedEty);
-                        UMConfigUtils.onEvent(UMConfigUtils.Event.TASK_DETAIL);
-                    }
-                });
-                ((TextView)viewHolder.itemView.findViewById(R.id.cancel_task_tv)).setOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
+
                         presenter.giveUpTask(etyList.get(i).getId());
                         presenter.giveUpTask(etyList.get(i).getId());
                         //暂停下载
                         //暂停下载
                         CommonUtil.getInstance().stopDownloadTask(mContext, etyList.get(i).getRelease_task().getTask().getDownload_link());
                         CommonUtil.getInstance().stopDownloadTask(mContext, etyList.get(i).getRelease_task().getTask().getDownload_link());
-//                        UMConfigUtils.onEvent(UMConfigUtils.Event.TASK_DETAIL);
+
+//                        TaskEty taskEty = etyList.get(i).getRelease_task().getTask();
+//                        taskEty.setRunTask(1);
+//                        taskEty.setRelease_task_id(etyList.get(i).getRelease_task().getId());
+//                        taskEty.setName(etyList.get(i).getRelease_task().getName());
+//                        taskEty.setAcceptedTaskId(etyList.get(i).getId());
+//                        Jump2View.getInstance().goDialogActivityView(context, taskEty, taskAcceptedEty);
                     }
                     }
                 });
                 });
                 Glide.with(context)
                 Glide.with(context)
@@ -277,10 +272,12 @@ public class TryMakeMoneyAdp extends AdpCommonRecy<RecyleObj> {
 
 
                         TaskEty taskEty = etyList.get(i).getRelease_task().getTask();
                         TaskEty taskEty = etyList.get(i).getRelease_task().getTask();
                         taskEty.setRunTask(1);
                         taskEty.setRunTask(1);
+                        taskEty.setBonus(etyList.get(i).getRelease_task().getBonus());
                         taskEty.setRelease_task_id(etyList.get(i).getRelease_task().getId());
                         taskEty.setRelease_task_id(etyList.get(i).getRelease_task().getId());
-                        taskEty.setName(etyList.get(i).getRelease_task().getName());
                         taskEty.setAcceptedTaskId(etyList.get(i).getId());
                         taskEty.setAcceptedTaskId(etyList.get(i).getId());
-                        Jump2View.getInstance().goDialogActivityView(context, taskEty, taskAcceptedEty);
+                        taskEty.setName(etyList.get(i).getRelease_task().getName());
+                        Jump2View.getInstance().goTaskDetailView(context, taskEty, taskAcceptedEty);
+                        UMConfigUtils.onEvent(UMConfigUtils.Event.TASK_DETAIL);
                     }
                     }
                 });
                 });
                 setDebugDownLoad(context, viewHolder.itemView, etyList.get(i).getRelease_task().getTask());
                 setDebugDownLoad(context, viewHolder.itemView, etyList.get(i).getRelease_task().getTask());

+ 10 - 0
app/src/main/java/com/sheep/jiuyan/samllsheep/service/DownloadService.java

@@ -10,6 +10,8 @@ import com.arialyy.aria.core.Aria;
 import com.arialyy.aria.core.download.DownloadTask;
 import com.arialyy.aria.core.download.DownloadTask;
 import com.kfzs.duanduan.services.DownloadTaskService;
 import com.kfzs.duanduan.services.DownloadTaskService;
 import com.kfzs.duanduan.utils.ApkUtils;
 import com.kfzs.duanduan.utils.ApkUtils;
+import com.kfzs.duanduan.utils.dlg.HelperUtils;
+import com.kfzs.duanduan.view.DialogStorageLow;
 
 
 /**
 /**
  *  @auther realicing
  *  @auther realicing
@@ -50,6 +52,14 @@ public class DownloadService extends Service{
 
 
     @Download.onTaskFail void taskFail(DownloadTask task) {
     @Download.onTaskFail void taskFail(DownloadTask task) {
         mDownloadTaskService.setDownloadTaskStatus(task.getKey(), DownloadTaskService.STATUS_FAIL);
         mDownloadTaskService.setDownloadTaskStatus(task.getKey(), DownloadTaskService.STATUS_FAIL);
+        //空间不足,弹框提示
+        try{
+            if (0 <= task.getFileSize() && task.getFileSize() > HelperUtils.getFreeSpaceB()) {
+                DialogStorageLow.showPopupWindow(DownloadService.this);
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
     }
     }
 
 
     @Download.onTaskComplete void taskComplete(DownloadTask task) {
     @Download.onTaskComplete void taskComplete(DownloadTask task) {

+ 2 - 2
app/src/main/res/layout/diag_show_install.xml

@@ -2,7 +2,7 @@
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_height="match_parent"
-    android:background="@color/transparent">
+    android:background="@color/bg_gray">
 
 
     <RelativeLayout
     <RelativeLayout
         android:layout_width="match_parent"
         android:layout_width="match_parent"
@@ -27,7 +27,7 @@
             android:layout_below="@id/img_diag_show_install"
             android:layout_below="@id/img_diag_show_install"
             android:layout_centerHorizontal="true"
             android:layout_centerHorizontal="true"
             android:text="@string/space_low"
             android:text="@string/space_low"
-            android:textColor="?attr/main_color"
+            android:textColor="@color/theme_app_main"
             android:textSize="@dimen/app_size_tv_large" />
             android:textSize="@dimen/app_size_tv_large" />
 
 
         <TextView
         <TextView

+ 24 - 5
app/src/main/res/layout/try_makemoney_item_recommend.xml

@@ -14,6 +14,13 @@
         android:layout_height="wrap_content"
         android:layout_height="wrap_content"
         android:orientation="horizontal">
         android:orientation="horizontal">
 
 
+        <ImageView
+            android:id="@+id/item_title_iv"
+            android:layout_width="@dimen/content_padding_20"
+            android:layout_height="@dimen/content_padding_20"
+            android:src="@mipmap/icon"
+            android:layout_marginRight="@dimen/content_padding_small"/>
+
         <TextView
         <TextView
             android:id="@+id/item_title_tv"
             android:id="@+id/item_title_tv"
             android:layout_width="0dp"
             android:layout_width="0dp"
@@ -34,7 +41,8 @@
             android:gravity="center"
             android:gravity="center"
             android:layout_marginBottom="13dp"
             android:layout_marginBottom="13dp"
             android:padding="@dimen/content_padding_3"
             android:padding="@dimen/content_padding_3"
-            android:background="@drawable/sp_bg_gradient_rectangle_blue"/>
+            android:background="@drawable/sp_bg_gradient_rectangle_blue"
+            android:visibility="gone"/>
     </LinearLayout>
     </LinearLayout>
 
 
     <android.support.constraint.ConstraintLayout
     <android.support.constraint.ConstraintLayout
@@ -77,10 +85,10 @@
             android:text=""
             android:text=""
             app:layout_constraintTop_toBottomOf="@+id/item_anem_tv"
             app:layout_constraintTop_toBottomOf="@+id/item_anem_tv"
             app:layout_constraintStart_toStartOf="@+id/item_anem_tv"
             app:layout_constraintStart_toStartOf="@+id/item_anem_tv"
-            android:textColor="@color/txt_black_8e8e8e"
             android:layout_marginTop="@dimen/content_padding_small"
             android:layout_marginTop="@dimen/content_padding_small"
             android:layout_marginBottom="@dimen/content_padding_10"
             android:layout_marginBottom="@dimen/content_padding_10"
-            android:textSize="@dimen/text_size_12"/>
+            android:textSize="@dimen/text_size_12"
+            android:textColor="@color/txt_black_8e8e8e"/>
         <TextView
         <TextView
             android:id="@+id/item_date_tv"
             android:id="@+id/item_date_tv"
             android:layout_width="wrap_content"
             android:layout_width="wrap_content"
@@ -96,7 +104,7 @@
             android:id="@+id/detail_task_tv"
             android:id="@+id/detail_task_tv"
             android:layout_width="wrap_content"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
-            android:text="任务详情"
+            android:text="取消任务"
             android:minWidth="@dimen/view_size_80"
             android:minWidth="@dimen/view_size_80"
             android:textColor="@color/white"
             android:textColor="@color/white"
             android:textSize="@dimen/text_size_12"
             android:textSize="@dimen/text_size_12"
@@ -106,8 +114,19 @@
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintBottom_toBottomOf="parent"
             android:layout_marginTop="@dimen/content_padding_small"
             android:layout_marginTop="@dimen/content_padding_small"
             android:layout_marginBottom="@dimen/content_padding_10"
             android:layout_marginBottom="@dimen/content_padding_10"
-            android:background="@drawable/sp_bg_gradient_rectangle_yellow"/>
+            android:background="@drawable/sp_bg_gradient_rectangle_blue"/>
     </android.support.constraint.ConstraintLayout>
     </android.support.constraint.ConstraintLayout>
+
+    <TextView
+        android:id="@+id/countdown_tv"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@drawable/sp_rectangle_bg_gray_radius"
+        android:textSize="@dimen/text_size_12"
+        android:textColor="@color/txt_black_8e8e8e"
+        android:text="若1小时35分22秒后任务未完成,该任务自动取消,您可以重新接受该任务"
+        android:padding="@dimen/content_padding_small"
+        android:visibility="gone"/>
     <TextView
     <TextView
         android:id="@+id/line_tv"
         android:id="@+id/line_tv"
         android:layout_width="match_parent"
         android:layout_width="match_parent"