From 2a5c5e4f4fcd1d847155e4bb42cea71acf06594b Mon Sep 17 00:00:00 2001 From: Blankj <625783482@qq.com> Date: Mon, 23 Apr 2018 20:24:04 +0800 Subject: [PATCH] see 04/23 log --- README-CN.md | 2 +- README.md | 2 +- app/build.gradle | 2 +- .../feature/core/CoreUtilActivity.java | 5 ----- .../feature/core/sdcard/SDCardActivity.java | 2 ++ build.gradle | 4 ++-- update_log.md | 1 + utilcode/README-CN.md | 14 +++++------- utilcode/README.md | 10 ++++----- utilcode/build.gradle | 1 + utilcode/proguard-rules.pro | 6 ++++- utilcode/src/main/AndroidManifest.xml | 4 ++-- .../support/v4/content/FileProvider4Util.java | 12 ++++++++++ .../blankj/utilcode/util/FragmentUtils.java | 9 ++++++-- .../com/blankj/utilcode/util/SDCardUtils.java | 22 +++++++++++++++++++ .../com/blankj/utilcode/util/ToastUtils.java | 15 +++++++++---- ...paths.xml => util_code_provider_paths.xml} | 0 17 files changed, 78 insertions(+), 33 deletions(-) create mode 100644 utilcode/src/main/java/android/support/v4/content/FileProvider4Util.java rename utilcode/src/main/res/xml/{provider_paths.xml => util_code_provider_paths.xml} (100%) diff --git a/README-CN.md b/README-CN.md index 3d67a412..925172aa 100644 --- a/README-CN.md +++ b/README-CN.md @@ -41,7 +41,7 @@ [logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png -[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.16-brightgreen.svg +[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.14.0-brightgreen.svg [auc]: https://github.com/Blankj/AndroidUtilCode [apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg diff --git a/README.md b/README.md index e1c5ecc4..fa5a140f 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen [logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png -[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.16-brightgreen.svg +[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.14.0-brightgreen.svg [auc]: https://github.com/Blankj/AndroidUtilCode [apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg diff --git a/app/build.gradle b/app/build.gradle index 4a066232..4e8949fa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,7 +57,7 @@ dependencies { // LeakCanary debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version" releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version" -// implementation 'com.blankj:utilcode:1.13.15' +// implementation 'com.blankj:utilcode:1.14.0' } diff --git a/app/src/main/java/com/blankj/androidutilcode/feature/core/CoreUtilActivity.java b/app/src/main/java/com/blankj/androidutilcode/feature/core/CoreUtilActivity.java index 1e552110..201bc4f0 100644 --- a/app/src/main/java/com/blankj/androidutilcode/feature/core/CoreUtilActivity.java +++ b/app/src/main/java/com/blankj/androidutilcode/feature/core/CoreUtilActivity.java @@ -11,7 +11,6 @@ import com.blankj.androidutilcode.base.BaseBackActivity; import com.blankj.androidutilcode.feature.core.activity.ActivityActivity; import com.blankj.androidutilcode.feature.core.app.AppActivity; import com.blankj.androidutilcode.feature.core.bar.BarActivity; -import com.blankj.androidutilcode.feature.core.clean.CleanActivity; import com.blankj.androidutilcode.feature.core.device.DeviceActivity; import com.blankj.androidutilcode.feature.core.fragment.FragmentActivity; import com.blankj.androidutilcode.feature.core.image.ImageActivity; @@ -85,10 +84,6 @@ public class CoreUtilActivity extends BaseBackActivity { BarActivity.start(this); } - public void cleanClick(View view) { - CleanActivity.start(this); - } - public void crashClick(View view) { throw new NullPointerException("crash test"); } diff --git a/app/src/main/java/com/blankj/androidutilcode/feature/core/sdcard/SDCardActivity.java b/app/src/main/java/com/blankj/androidutilcode/feature/core/sdcard/SDCardActivity.java index 0fa8d933..097339ac 100644 --- a/app/src/main/java/com/blankj/androidutilcode/feature/core/sdcard/SDCardActivity.java +++ b/app/src/main/java/com/blankj/androidutilcode/feature/core/sdcard/SDCardActivity.java @@ -43,6 +43,8 @@ public class SDCardActivity extends BaseBackActivity { TextView tvAboutSdcard = findViewById(R.id.tv_about_sdcard); tvAboutSdcard.setText(new SpanUtils() + .appendLine("isSDCardEnableByEnvironment: " + SDCardUtils.isSDCardEnableByEnvironment()) + .appendLine("getSDCardPathByEnvironment: " + SDCardUtils.getSDCardPathByEnvironment()) .appendLine("isSDCardEnable: " + SDCardUtils.isSDCardEnable()) .appendLine("getSDCardPaths: " + SDCardUtils.getSDCardPaths()) .appendLine("getInnerSDCardPaths: " + SDCardUtils.getSDCardPaths(true)) diff --git a/build.gradle b/build.gradle index 04e9a19e..c5dbddbf 100644 --- a/build.gradle +++ b/build.gradle @@ -33,8 +33,8 @@ ext { min_sdk_version = 14 target_sdk_version = 27 - version_code = 1_013_016 - version_name = '1.13.16'// E.g 1.9.72 => 1,009,072 + version_code = 1_014_000 + version_name = '1.14.0'// E.g 1.9.72 => 1,009,072 // App dependencies support_version = '27.1.0' diff --git a/update_log.md b/update_log.md index 3df53e20..8c17c0d7 100644 --- a/update_log.md +++ b/update_log.md @@ -1,3 +1,4 @@ +* 18/04/24 修复多 FileProvider 带来的问题,发布 1.14.0 版本 * 18/04/23 新增 RSA 加解密,发布 1.13.16 版本 * 18/04/22 新增 LogUtils 设置栈偏移 * 18/04/21 新增 AppUtils#relaunchApp、DeviceUtils#getABIs,发布 1.13.15 版本 diff --git a/utilcode/README-CN.md b/utilcode/README-CN.md index f9eaf706..f62fed9f 100644 --- a/utilcode/README-CN.md +++ b/utilcode/README-CN.md @@ -2,7 +2,7 @@ Gradle: ```groovy -implementation 'com.blankj:utilcode:1.13.16' +implementation 'com.blankj:utilcode:1.14.0' ``` @@ -16,11 +16,7 @@ Utils.init(application); ## Proguard -``` --keep class com.blankj.utilcode.** { *; } --keepclassmembers class com.blankj.utilcode.** { *; } --dontwarn com.blankj.utilcode.** -``` +U needn't do anything, because I add `consumerProguardFiles 'proguard-rules.pro'` in build.gradle. ## APIs @@ -493,8 +489,10 @@ isTablet : 判断是否是平板 * ### SD 卡相关 -> [SDCardUtils.java][sdcard.java] -> [Demo][sdcard.demo] ``` -isSDCardEnable: 判断 SD 卡是否可用 -getSDCardPaths: 获取 SD 卡路径 +isSDCardEnableByEnvironment: 根据 Environment 判断 SD 卡是否可用 +getSDCardPathByEnvironment : 根据 Environment 获取 SD 卡路径 +isSDCardEnable : 判断 SD 卡是否可用 +getSDCardPaths : 获取 SD 卡路径 ``` * ### 服务相关 -> [ServiceUtils.java][service.java] diff --git a/utilcode/README.md b/utilcode/README.md index ef8ef9d8..dfdcdf5d 100644 --- a/utilcode/README.md +++ b/utilcode/README.md @@ -2,7 +2,7 @@ Gradle: ```groovy -implementation 'com.blankj:utilcode:1.13.16' +implementation 'com.blankj:utilcode:1.14.0' ``` @@ -16,11 +16,7 @@ Utils.init(application); ## Proguard -``` --keep class com.blankj.utilcode.** { *; } --keepclassmembers class com.blankj.utilcode.** { *; } --dontwarn com.blankj.utilcode.** -``` +U needn't do anything, because I add `consumerProguardFiles 'proguard-rules.pro'` in build.gradle. ## APIs @@ -493,6 +489,8 @@ isTablet * ### About SDCard -> [SDCardUtils.java][sdcard.java] -> [Demo][sdcard.demo] ``` +isSDCardEnableByEnvironment +getSDCardPathByEnvironment isSDCardEnable getSDCardPaths ``` diff --git a/utilcode/build.gradle b/utilcode/build.gradle index c75d54f0..fa7686b8 100644 --- a/utilcode/build.gradle +++ b/utilcode/build.gradle @@ -12,6 +12,7 @@ android { buildTypes { release { minifyEnabled false + consumerProguardFiles 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } diff --git a/utilcode/proguard-rules.pro b/utilcode/proguard-rules.pro index 18960abd..c27c3632 100644 --- a/utilcode/proguard-rules.pro +++ b/utilcode/proguard-rules.pro @@ -14,4 +14,8 @@ # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; -#} \ No newline at end of file +#} + +-keep class com.blankj.utilcode.** { *; } +-keepclassmembers class com.blankj.utilcode.** { *; } +-dontwarn com.blankj.utilcode.** \ No newline at end of file diff --git a/utilcode/src/main/AndroidManifest.xml b/utilcode/src/main/AndroidManifest.xml index afd728eb..45840c32 100644 --- a/utilcode/src/main/AndroidManifest.xml +++ b/utilcode/src/main/AndroidManifest.xml @@ -10,13 +10,13 @@ android:windowSoftInputMode="stateHidden|stateAlwaysHidden" /> + android:resource="@xml/util_code_provider_paths" /> \ No newline at end of file diff --git a/utilcode/src/main/java/android/support/v4/content/FileProvider4Util.java b/utilcode/src/main/java/android/support/v4/content/FileProvider4Util.java new file mode 100644 index 00000000..728a5fcb --- /dev/null +++ b/utilcode/src/main/java/android/support/v4/content/FileProvider4Util.java @@ -0,0 +1,12 @@ +package android.support.v4.content; + +/** + *
+ *     author: Blankj
+ *     blog  : http://blankj.com
+ *     time  : 2018/04/23
+ *     desc  :
+ * 
+ */ +public final class FileProvider4Util extends FileProvider { +} diff --git a/utilcode/src/main/java/com/blankj/utilcode/util/FragmentUtils.java b/utilcode/src/main/java/com/blankj/utilcode/util/FragmentUtils.java index f2aceb08..940f0f19 100644 --- a/utilcode/src/main/java/com/blankj/utilcode/util/FragmentUtils.java +++ b/utilcode/src/main/java/com/blankj/utilcode/util/FragmentUtils.java @@ -11,7 +11,6 @@ import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; -import android.support.v4.view.ViewCompat; import android.util.Log; import android.view.View; @@ -1170,7 +1169,13 @@ public final class FragmentUtils { * @param background The background. */ public static void setBackground(@NonNull final Fragment fragment, final Drawable background) { - ViewCompat.setBackground(fragment.getView(), background); + View view = fragment.getView(); + if (view == null) return; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + view.setBackground(background); + } else { + view.setBackgroundDrawable(background); + } } /** diff --git a/utilcode/src/main/java/com/blankj/utilcode/util/SDCardUtils.java b/utilcode/src/main/java/com/blankj/utilcode/util/SDCardUtils.java index a88ebf64..1e4d51a9 100644 --- a/utilcode/src/main/java/com/blankj/utilcode/util/SDCardUtils.java +++ b/utilcode/src/main/java/com/blankj/utilcode/util/SDCardUtils.java @@ -1,6 +1,7 @@ package com.blankj.utilcode.util; import android.content.Context; +import android.os.Environment; import android.os.storage.StorageManager; import java.lang.reflect.Array; @@ -24,6 +25,27 @@ public final class SDCardUtils { throw new UnsupportedOperationException("u can't instantiate me..."); } + /** + * Return whether sdcard is enabled by environment. + * + * @return true : enabled
false : disabled + */ + public static boolean isSDCardEnableByEnvironment() { + return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()); + } + + /** + * Return the path of sdcard by environment. + * + * @return the path of sdcard by environment + */ + public static String getSDCardPathByEnvironment() { + if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { + return Environment.getExternalStorageDirectory().getAbsolutePath(); + } + return null; + } + /** * Return whether sdcard is enabled. * diff --git a/utilcode/src/main/java/com/blankj/utilcode/util/ToastUtils.java b/utilcode/src/main/java/com/blankj/utilcode/util/ToastUtils.java index b1c8fe95..016c4376 100644 --- a/utilcode/src/main/java/com/blankj/utilcode/util/ToastUtils.java +++ b/utilcode/src/main/java/com/blankj/utilcode/util/ToastUtils.java @@ -6,6 +6,7 @@ import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.os.Build; import android.os.Handler; import android.os.Looper; import android.support.annotation.ColorInt; @@ -13,8 +14,6 @@ import android.support.annotation.DrawableRes; import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; import android.support.annotation.StringRes; -import android.support.v4.view.ViewCompat; -import android.support.v4.widget.TextViewCompat; import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; @@ -244,7 +243,11 @@ public final class ToastUtils { final TextView tvMessage = toast.getView().findViewById(android.R.id.message); int msgColor = tvMessage.getCurrentTextColor(); //it solve the font of toast - TextViewCompat.setTextAppearance(tvMessage, android.R.style.TextAppearance); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + tvMessage.setTextAppearance(android.R.style.TextAppearance); + } else { + tvMessage.setTextAppearance(tvMessage.getContext(), android.R.style.TextAppearance); + } if (sMsgColor != COLOR_DEFAULT) { tvMessage.setTextColor(sMsgColor); } else { @@ -292,7 +295,11 @@ public final class ToastUtils { new PorterDuffColorFilter(sBgColor, PorterDuff.Mode.SRC_IN) ); } else { - ViewCompat.setBackground(toastView, new ColorDrawable(sBgColor)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + toastView.setBackground(new ColorDrawable(sBgColor)); + } else { + toastView.setBackgroundDrawable(new ColorDrawable(sBgColor)); + } } } } diff --git a/utilcode/src/main/res/xml/provider_paths.xml b/utilcode/src/main/res/xml/util_code_provider_paths.xml similarity index 100% rename from utilcode/src/main/res/xml/provider_paths.xml rename to utilcode/src/main/res/xml/util_code_provider_paths.xml -- GitLab