diff --git a/README.md b/README.md index d89d210..07669f1 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,10 @@ MNCrashMonitor 监听程序崩溃日志,直接页面展示崩溃日志列表,调 ``` gradle dependencies { (support 包版本随意) + compile 'com.android.support:support-v4:26.1.0' compile 'com.android.support:appcompat-v7:26.1.0' compile 'com.android.support:recyclerview-v7:26.1.0' - compile 'com.android.support:design:26.1.0' - compile 'com.android.support:support-v4:26.1.0' -       compile 'com.github.maning0303:MNCrashMonitor:V1.0.9' +       compile 'com.github.maning0303:MNCrashMonitor:V1.1.0' } ``` @@ -72,7 +71,6 @@ MNCrashMonitor 监听程序崩溃日志,直接页面展示崩溃日志列表,调 ``` java /** - * Created by maning on 2017/4/20. * 主类 */ public class MCrashMonitor { @@ -182,7 +180,9 @@ MNCrashMonitor 监听程序崩溃日志,直接页面展示崩溃日志列表,调 ### 生成截图的位置: ``` java - Environment.getExternalStorageDirectory() + "/crash_pic_" + System.currentTimeMillis() + ".jpg" + /Android/data/包名/cache/crashPics/ + 或者 + /data/data/包名/cache/crashPics/ ``` @@ -194,6 +194,11 @@ MNCrashMonitor 监听程序崩溃日志,直接页面展示崩溃日志列表,调 ``` ### 版本记录: + V1.1.0: + 1.修复通知栏不显示问题 + 2.生成截图添加动画显示,截图保存位置更换data/包名/cache/crashPics/ + 3.优化v4,v7包添加方式,去掉design包 + V1.0.9: 1.修复7.0 FileUriExposedException 分享功能报错问题 2.文件权限适配6.0之下版本 diff --git a/library-crashmonitor/src/main/java/com/maning/librarycrashmonitor/ui/activity/CrashDetailsActivity.java b/library-crashmonitor/src/main/java/com/maning/librarycrashmonitor/ui/activity/CrashDetailsActivity.java index c56e4f6..720f74a 100644 --- a/library-crashmonitor/src/main/java/com/maning/librarycrashmonitor/ui/activity/CrashDetailsActivity.java +++ b/library-crashmonitor/src/main/java/com/maning/librarycrashmonitor/ui/activity/CrashDetailsActivity.java @@ -1,6 +1,5 @@ package com.maning.librarycrashmonitor.ui.activity; -import android.Manifest; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.content.ClipData; @@ -9,12 +8,9 @@ import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.Color; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; import android.text.Spannable; import android.text.TextUtils; import android.view.View; @@ -30,7 +26,6 @@ import com.maning.librarycrashmonitor.utils.MActivityListUtil; import com.maning.librarycrashmonitor.utils.MBitmapUtil; import com.maning.librarycrashmonitor.utils.MFileUtils; -import com.maning.librarycrashmonitor.utils.MPermission5Utils; import com.maning.librarycrashmonitor.utils.MScreenShotUtil; import com.maning.librarycrashmonitor.utils.MShareUtil; import com.maning.librarycrashmonitor.utils.MSizeUtils; @@ -104,9 +99,11 @@ protected void onCreate(Bundle savedInstanceState) { } private void initDatas() { + showProgressLoading("加载中..."); new Thread(new Runnable() { @Override public void run() { + dismissProgressLoading(); //获取文件夹名字匹配异常信息高亮显示 File file = new File(filePath); String[] splitNames = file.getName().replace(".txt", "").split("_"); @@ -204,7 +201,7 @@ private void saveScreenShot() { @Override public void run() { if (bitmap != null) { - String crashPicPath = MFileUtils.getCrashPicPath() + "/crash_pic_" + System.currentTimeMillis() + ".jpg"; + String crashPicPath = MFileUtils.getCrashPicPath(context) + "/crash_pic_" + System.currentTimeMillis() + ".jpg"; boolean saveBitmap = MBitmapUtil.saveBitmap(context, bitmap, crashPicPath); if (saveBitmap) { showToast("保存截图成功,请到相册查看\n路径:" + crashPicPath); @@ -293,22 +290,24 @@ public void onClick(View v) { putTextIntoClip(); Toast.makeText(context, "复制内容成功", Toast.LENGTH_SHORT).show(); } else if (i == R.id.btn_screenshot) { - //请求权限 - //检查版本是否大于M - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { - ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 10086); - } else { - saveScreenShot(); - } - } else { - //6.0之下判断有没有权限 - if (MPermission5Utils.hasWritePermission()) { - saveScreenShot(); - } else { - Toast.makeText(context, "缺少存储权限", Toast.LENGTH_SHORT).show(); - } - } + //直接保存 + saveScreenShot(); +// //请求权限 +// //检查版本是否大于M +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { +// if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { +// ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 10086); +// } else { +// saveScreenShot(); +// } +// } else { +// //6.0之下判断有没有权限 +// if (MPermission5Utils.hasWritePermission()) { +// saveScreenShot(); +// } else { +// Toast.makeText(context, "缺少存储权限", Toast.LENGTH_SHORT).show(); +// } +// } } } } diff --git a/library-crashmonitor/src/main/java/com/maning/librarycrashmonitor/utils/MFileUtils.java b/library-crashmonitor/src/main/java/com/maning/librarycrashmonitor/utils/MFileUtils.java index edb0ad6..ac6d743 100644 --- a/library-crashmonitor/src/main/java/com/maning/librarycrashmonitor/utils/MFileUtils.java +++ b/library-crashmonitor/src/main/java/com/maning/librarycrashmonitor/utils/MFileUtils.java @@ -29,8 +29,8 @@ public static String getCrashLogPath(Context context) { return path; } - public static String getCrashPicPath() { - String path = Environment.getExternalStorageDirectory() + ""; + public static String getCrashPicPath(Context context) { + String path = getCachePath(context) + File.separator + "crashPics"; File file = new File(path); if (!file.exists()) { file.mkdirs();