Target APIs greater than 25 must hold
+ * {@code
Target APIs greater than 25 must hold
+ * {@code
Target APIs greater than 25 must hold
@@ -42,6 +65,7 @@ public final class AppUtils {
* @param authority Target APIs greater than 23 must hold the authority of a FileProvider
* defined in a {@code Target APIs greater than 25 must hold
+ * {@code Target APIs greater than 25 must hold
+ * {@code Target APIs greater than 25 must hold
@@ -72,6 +130,7 @@ public final class AppUtils {
* @param requestCode If >= 0, this code will be returned in
* onActivityResult() when the activity exits.
*/
+ @Deprecated
public static void installApp(final Activity activity,
final String filePath,
final String authority,
@@ -91,6 +150,7 @@ public final class AppUtils {
* @param requestCode If >= 0, this code will be returned in
* onActivityResult() when the activity exits.
*/
+ @Deprecated
public static void installApp(final Activity activity,
final File file,
final String authority,
diff --git a/utilcode/src/main/java/com/blankj/utilcode/util/CrashUtils.java b/utilcode/src/main/java/com/blankj/utilcode/util/CrashUtils.java
index d643380977af981099137224e1817c736faa923b..c86c52707d6ef2bc6f4f7e29c247a06b9aeea33f 100644
--- a/utilcode/src/main/java/com/blankj/utilcode/util/CrashUtils.java
+++ b/utilcode/src/main/java/com/blankj/utilcode/util/CrashUtils.java
@@ -80,7 +80,7 @@ public final class CrashUtils {
final String time = FORMAT.format(new Date(System.currentTimeMillis()));
final StringBuilder sb = new StringBuilder();
final String head = "************* Log Head ****************" +
- "\nThe time of Crash : " + time +
+ "\nTime Of Crash : " + time +
"\nDevice Manufacturer: " + Build.MANUFACTURER +
"\nDevice Model : " + Build.MODEL +
"\nAndroid Version : " + Build.VERSION.RELEASE +
diff --git a/utilcode/src/main/java/com/blankj/utilcode/util/IntentUtils.java b/utilcode/src/main/java/com/blankj/utilcode/util/IntentUtils.java
index d414fd074eaa591bfa4b4e7cac6f5fd17621f8cf..cd887b73e89e5131c1876f44170936e7c8395b7f 100644
--- a/utilcode/src/main/java/com/blankj/utilcode/util/IntentUtils.java
+++ b/utilcode/src/main/java/com/blankj/utilcode/util/IntentUtils.java
@@ -27,6 +27,68 @@ public final class IntentUtils {
throw new UnsupportedOperationException("u can't instantiate me...");
}
+ /**
+ * Return the intent of install app.
+ * Target APIs greater than 25 must hold
+ * {@code Target APIs greater than 25 must hold
+ * {@code Target APIs greater than 25 must hold
+ * {@code Target APIs greater than 25 must hold
+ * {@code Target APIs greater than 25 must hold
@@ -37,8 +99,9 @@ public final class IntentUtils {
* defined in a {@code Target APIs greater than 25 must hold
+ * {@code Target APIs greater than 25 must hold
@@ -66,6 +148,7 @@ public final class IntentUtils {
* @param isNewTask True to add flag of new task, false otherwise.
* @return the intent of install app
*/
+ @Deprecated
public static Intent getInstallAppIntent(final File file,
final String authority,
final boolean isNewTask) {
@@ -451,6 +534,20 @@ public final class IntentUtils {
return isNewTask ? intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) : intent;
}
+ private static File getFileByPath(final String filePath) {
+ return isSpace(filePath) ? null : new File(filePath);
+ }
+
+ private static boolean isSpace(final String s) {
+ if (s == null) return true;
+ for (int i = 0, len = s.length(); i < len; ++i) {
+ if (!Character.isWhitespace(s.charAt(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
// /**
// * 获取选择照片的 Intent
// *
diff --git a/utilcode/src/main/java/com/blankj/utilcode/util/LogUtils.java b/utilcode/src/main/java/com/blankj/utilcode/util/LogUtils.java
index 35f7b7e1b767d73965d9607a3b6fa134d4fbd8f4..132ed69cb78b242ea4e78d6fb2d65e6c92ba1975 100644
--- a/utilcode/src/main/java/com/blankj/utilcode/util/LogUtils.java
+++ b/utilcode/src/main/java/com/blankj/utilcode/util/LogUtils.java
@@ -191,7 +191,7 @@ public final class LogUtils {
log(XML | type, tag, content);
}
- private static void log(final int type, final String tag, final Object... contents) {
+ public static void log(final int type, final String tag, final Object... contents) {
if (!CONFIG.mLogSwitch || (!CONFIG.mLog2ConsoleSwitch && !CONFIG.mLog2FileSwitch)) return;
int type_low = type & 0x0f, type_high = type & 0xf0;
if (type_low < CONFIG.mConsoleFilter && type_low < CONFIG.mFileFilter) return;
@@ -210,7 +210,17 @@ public final class LogUtils {
tag = CONFIG.mGlobalTag;
} else {
final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
- StackTraceElement targetElement = stackTrace[3];
+ final int stackIndex = 3 + CONFIG.mStackOffset;
+ if (stackIndex >= stackTrace.length) {
+ StackTraceElement targetElement = stackTrace[3];
+ final String fileName = getFileName(targetElement);
+ if (CONFIG.mTagIsSpace && isSpace(tag)) {
+ int index = fileName.indexOf('.');// Use proguard may not find '.'.
+ tag = index == -1 ? fileName : fileName.substring(0, index);
+ }
+ return new TagHead(tag, null, ": ");
+ }
+ StackTraceElement targetElement = stackTrace[stackIndex];
final String fileName = getFileName(targetElement);
if (CONFIG.mTagIsSpace && isSpace(tag)) {
int index = fileName.indexOf('.');// Use proguard may not find '.'.
@@ -231,12 +241,15 @@ public final class LogUtils {
return new TagHead(tag, new String[]{head}, fileHead);
} else {
final String[] consoleHead =
- new String[Math.min(CONFIG.mStackDeep, stackTrace.length - 3)];
+ new String[Math.min(
+ CONFIG.mStackDeep,
+ stackTrace.length - stackIndex
+ )];
consoleHead[0] = head;
int spaceLen = tName.length() + 2;
String space = new Formatter().format("%" + spaceLen + "s", "").toString();
for (int i = 1, len = consoleHead.length; i < len; ++i) {
- targetElement = stackTrace[i + 3];
+ targetElement = stackTrace[i + stackIndex];
consoleHead[i] = new Formatter()
.format("%s%s.%s(%s:%d)",
space,
@@ -502,7 +515,9 @@ public final class LogUtils {
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
+ String time = filePath.substring(filePath.length() - 9, filePath.length() - 4);
final String head = "************* Log Head ****************" +
+ "\nDate of Log : " + time +
"\nDevice Manufacturer: " + Build.MANUFACTURER +
"\nDevice Model : " + Build.MODEL +
"\nAndroid Version : " + Build.VERSION.RELEASE +
@@ -578,6 +593,7 @@ public final class LogUtils {
private int mConsoleFilter = V; // The console's filter of log.
private int mFileFilter = V; // The file's filter of log.
private int mStackDeep = 1; // The stack's deep of log.
+ private int mStackOffset = 0; // The stack's offset of log.
private Config() {
if (mDefaultDir != null) return;
@@ -668,6 +684,11 @@ public final class LogUtils {
return this;
}
+ public Config setStackOffset(@IntRange(from = 0) final int stackOffset) {
+ mStackOffset = stackOffset;
+ return this;
+ }
+
@Override
public String toString() {
return "switch: " + mLogSwitch
@@ -681,7 +702,8 @@ public final class LogUtils {
+ LINE_SEP + "singleTag: " + mSingleTagSwitch
+ LINE_SEP + "consoleFilter: " + T[mConsoleFilter - V]
+ LINE_SEP + "fileFilter: " + T[mFileFilter - V]
- + LINE_SEP + "stackDeep: " + mStackDeep;
+ + LINE_SEP + "stackDeep: " + mStackDeep
+ + LINE_SEP + "mStackOffset: " + mStackOffset;
}
}
diff --git a/utilcode/src/main/res/xml/provider_paths.xml b/utilcode/src/main/res/xml/provider_paths.xml
new file mode 100644
index 0000000000000000000000000000000000000000..0c40bb34afd10f72078fe01c1c455c95d9c311b1
--- /dev/null
+++ b/utilcode/src/main/res/xml/provider_paths.xml
@@ -0,0 +1,26 @@
+
+