Skip to content

Commit

Permalink
see 08/09 log
Browse files Browse the repository at this point in the history
  • Loading branch information
Blankj committed Aug 9, 2018
1 parent 205943d commit 07925ad
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png

[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.18.5-brightgreen.svg
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.18.6-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode

[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.18.5-brightgreen.svg
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.18.6-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode

[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
Expand Down
2 changes: 1 addition & 1 deletion apk/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1018005,"versionName":"1.18.5","enabled":true,"outputFile":"util_1_18_5.apk","fullName":"release","baseName":"release"},"path":"util_1_18_5.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1018006,"versionName":"1.18.6","enabled":true,"outputFile":"util_1_18_6.apk","fullName":"release","baseName":"release"},"path":"util_1_18_6.apk","properties":{}}]
Binary file renamed apk/util_1_18_5.apk → apk/util_1_18_6.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/src/main/java/com/blankj/androidutilcode/UtilsApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void initLog() {
.setLogHeadSwitch(true)// 设置 log 头信息开关,默认为开
.setLog2FileSwitch(false)// 打印 log 时是否存到文件的开关,默认关
.setDir("")// 当自定义路径为空时,写入应用的/cache/log/目录中
.setFilePrefix("")// 当文件前缀为空时,默认为"util",即写入文件为"util-MM-dd.txt"
.setFilePrefix("")// 当文件前缀为空时,默认为"util",即写入文件为"util-yyyy-MM-dd.txt"
.setBorderSwitch(true)// 输出日志是否带边框开关,默认开
.setSingleTagSwitch(true)// 一条日志仅输出一条,默认开,为美化 AS 3.1 的 Logcat
.setConsoleFilter(LogUtils.V)// log 的控制台过滤器,和 logcat 过滤器同理,默认 Verbose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.support.v4.content.ContextCompat;
import android.view.Gravity;
import android.view.View;
import android.widget.Toast;

import com.blankj.androidutilcode.R;
import com.blankj.androidutilcode.base.BaseBackActivity;
Expand Down
6 changes: 3 additions & 3 deletions config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ ext {
compileSdkVersion: 27,
minSdkVersion : 14,
targetSdkVersion : 27,
versionCode : 1_018_005,
versionName : '1.18.5'// E.g 1.9.72 => 1,009,072
versionCode : 1_018_006,
versionName : '1.18.6'// E.g 1.9.72 => 1,009,072
]

versionConfig = [
Expand Down Expand Up @@ -167,7 +167,7 @@ def configAppDependencies(Project pro) {
// LeakCanary
debugImplementation depConfig.leakcanary.android
releaseImplementation depConfig.leakcanary.android_no_op
// implementation 'com.blankj:utilcode:1.18.5'
// implementation 'com.blankj:utilcode:1.18.6'
}
}

Expand Down
1 change: 1 addition & 0 deletions update_log.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* 18/08/09 新增 IntentUtils#isIntentAvailable,ToastUtils 传入空显示 null,发布 1.18.6
* 18/08/08 修复 ScreenUtils#adaptxx 在第三方 SDK 会出现的问题,发布 1.18.5
* 18/08/07 修复 ScreenUtils#adaptxx 在 API 26 以下无效的 bug,发布 1.18.4
* 18/08/06 修复 ScreenUtils#screenShot 中 decorView.getDrawingCache() 为空的问题,发布 1.18.3
Expand Down
3 changes: 2 additions & 1 deletion utilcode/README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gradle:
```groovy
implementation 'com.blankj:utilcode:1.18.5'
implementation 'com.blankj:utilcode:1.18.6'
```


Expand Down Expand Up @@ -347,6 +347,7 @@ compressBySampleSize : 按采样大小压缩

* ### 意图相关 -> [IntentUtils.java][intent.java]
```
isIntentAvailable : 判断意图是否可用
getInstallAppIntent : 获取安装 App(支持 6.0)的意图
getUninstallAppIntent : 获取卸载 App 的意图
getLaunchAppIntent : 获取打开 App 的意图
Expand Down
3 changes: 2 additions & 1 deletion utilcode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gradle:
```groovy
implementation 'com.blankj:utilcode:1.18.5'
implementation 'com.blankj:utilcode:1.18.6'
```


Expand Down Expand Up @@ -347,6 +347,7 @@ compressBySampleSize

* ### About Intent -> [IntentUtils.java][intent.java]
```
isIntentAvailable
getInstallAppIntent
getUninstallAppIntent
getLaunchAppIntent
Expand Down
10 changes: 10 additions & 0 deletions utilcode/src/main/java/com/blankj/utilcode/util/IntentUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ private IntentUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}

/**
* Return whether the intent is available.
*
* @param intent The intent.
* @return {@code true}: yes<br>{@code false}: no
*/
public static boolean isIntentAvailable(final Intent intent) {
return Utils.getApp().getPackageManager().queryIntentActivities(intent, 0).size() > 0;
}

/**
* Return the intent of install app.
* <p>Target APIs greater than 25 must hold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ public static boolean isTablet() {
/**
* Adapt the screen for vertical slide.
*
* @param activity The activity.
* @param designWidthInPx The size of design diagram's width, in pixel.
*/
public static void adaptScreen4VerticalSlide(final Activity activity,
Expand All @@ -312,6 +313,7 @@ public static void adaptScreen4VerticalSlide(final Activity activity,
/**
* Adapt the screen for horizontal slide.
*
* @param activity The activity.
* @param designHeightInPx The size of design diagram's height, in pixel.
*/
public static void adaptScreen4HorizontalSlide(final Activity activity,
Expand Down
45 changes: 20 additions & 25 deletions utilcode/src/main/java/com/blankj/utilcode/util/ToastUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public final class ToastUtils {

private static final int COLOR_DEFAULT = 0xFEFFFFFF;
private static final Handler HANDLER = new Handler(Looper.getMainLooper());
private static final String NULL = "null";

private static Toast sToast;
private static int sGravity = -1;
Expand Down Expand Up @@ -107,8 +108,8 @@ public static void setMsgTextSize(final int textSize) {
*
* @param text The text.
*/
public static void showShort(@NonNull final CharSequence text) {
show(text, Toast.LENGTH_SHORT);
public static void showShort(final CharSequence text) {
show(text == null ? NULL : text, Toast.LENGTH_SHORT);
}

/**
Expand All @@ -127,11 +128,7 @@ public static void showShort(@StringRes final int resId) {
* @param args The args.
*/
public static void showShort(@StringRes final int resId, final Object... args) {
if (args != null && args.length == 0) {
show(resId, Toast.LENGTH_SHORT);
} else {
show(resId, Toast.LENGTH_SHORT, args);
}
show(resId, Toast.LENGTH_SHORT, args);
}

/**
Expand All @@ -141,20 +138,16 @@ public static void showShort(@StringRes final int resId, final Object... args) {
* @param args The args.
*/
public static void showShort(final String format, final Object... args) {
if (args != null && args.length == 0) {
show(format, Toast.LENGTH_SHORT);
} else {
show(format, Toast.LENGTH_SHORT, args);
}
show(format, Toast.LENGTH_SHORT, args);
}

/**
* Show the sToast for a long period of time.
*
* @param text The text.
*/
public static void showLong(@NonNull final CharSequence text) {
show(text, Toast.LENGTH_LONG);
public static void showLong(final CharSequence text) {
show(text == null ? NULL : text, Toast.LENGTH_LONG);
}

/**
Expand All @@ -173,11 +166,7 @@ public static void showLong(@StringRes final int resId) {
* @param args The args.
*/
public static void showLong(@StringRes final int resId, final Object... args) {
if (args != null && args.length == 0) {
show(resId, Toast.LENGTH_SHORT);
} else {
show(resId, Toast.LENGTH_LONG, args);
}
show(resId, Toast.LENGTH_LONG, args);
}

/**
Expand All @@ -187,11 +176,7 @@ public static void showLong(@StringRes final int resId, final Object... args) {
* @param args The args.
*/
public static void showLong(final String format, final Object... args) {
if (args != null && args.length == 0) {
show(format, Toast.LENGTH_SHORT);
} else {
show(format, Toast.LENGTH_LONG, args);
}
show(format, Toast.LENGTH_LONG, args);
}

/**
Expand Down Expand Up @@ -234,7 +219,16 @@ private static void show(@StringRes final int resId, final int duration, final O
}

private static void show(final String format, final int duration, final Object... args) {
show(String.format(format, args), duration);
String text;
if (format == null) {
text = NULL;
} else {
text = String.format(format, args);
if (text == null) {
text = NULL;
}
}
show(text, duration);
}

private static void show(final CharSequence text, final int duration) {
Expand Down Expand Up @@ -280,6 +274,7 @@ public void run() {
private static void showToast() {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N_MR1) {
try {
//noinspection JavaReflectionMemberAccess
Field field = View.class.getDeclaredField("mContext");
field.setAccessible(true);
field.set(sToast.getView(), new ApplicationContextWrapperForApi25());
Expand Down

0 comments on commit 07925ad

Please sign in to comment.