提交 4eee99fa 编写于 作者: B Blankj

see 04/02 log

上级 5f588ea0
......@@ -14,4 +14,4 @@ jobs:
with:
java-version: 1.8
- name: Build with Gradle
run: ./gradlew aR
run: ./gradlew aR -x :lib:lib_utilcode:verifyReleaseResources
* `20/04/02` [fix] PathUtils sdcard enable state is wrong; ActivityUtils finish activity wrong; Publish v1.27.1.
* `20/03/31` [add] Publish v1.27.0.
* `20/03/30` [add] BatteryUtils in subutil.
* `20/03/27` [add] publish.gradle.
......
......@@ -15,7 +15,7 @@ class Config {
static minSdkVersion = 14
static targetSdkVersion = 29
static versionCode = 1_026_001
static versionName = '1.27.0'// E.g. 1.9.72 => 1,009,072
static versionName = '1.27.1'// E.g. 1.9.72 => 1,009,072
// lib version
static gradlePluginVersion = '3.5.0'
......
......@@ -2,10 +2,10 @@
Gradle:
```groovy
implementation 'com.blankj:utilcode:1.27.0'
implementation 'com.blankj:utilcode:1.27.1'
// if u use AndroidX, use the following
implementation 'com.blankj:utilcodex:1.27.0'
implementation 'com.blankj:utilcodex:1.27.1'
```
......
......@@ -2,10 +2,10 @@
Gradle:
```groovy
implementation 'com.blankj:utilcode:1.27.0'
implementation 'com.blankj:utilcode:1.27.1'
// if u use AndroidX, use the following
implementation 'com.blankj:utilcodex:1.27.0'
implementation 'com.blankj:utilcodex:1.27.1'
```
......
......@@ -1645,15 +1645,14 @@ public final class ActivityUtils {
final boolean isIncludeSelf,
final boolean isLoadAnim) {
List<Activity> activities = UtilsBridge.getActivityList();
for (int i = activities.size() - 1; i >= 0; --i) {
Activity aActivity = activities.get(i);
if (aActivity.equals(activity)) {
for (Activity act : activities) {
if (act.equals(activity)) {
if (isIncludeSelf) {
finishActivity(aActivity, isLoadAnim);
finishActivity(act, isLoadAnim);
}
return true;
}
finishActivity(aActivity, isLoadAnim);
finishActivity(act, isLoadAnim);
}
return false;
}
......@@ -1673,15 +1672,14 @@ public final class ActivityUtils {
@AnimRes final int enterAnim,
@AnimRes final int exitAnim) {
List<Activity> activities = UtilsBridge.getActivityList();
for (int i = activities.size() - 1; i >= 0; --i) {
Activity aActivity = activities.get(i);
if (aActivity.equals(activity)) {
for (Activity act : activities) {
if (act.equals(activity)) {
if (isIncludeSelf) {
finishActivity(aActivity, enterAnim, exitAnim);
finishActivity(act, enterAnim, exitAnim);
}
return true;
}
finishActivity(aActivity, enterAnim, exitAnim);
finishActivity(act, enterAnim, exitAnim);
}
return false;
}
......@@ -1708,15 +1706,14 @@ public final class ActivityUtils {
final boolean isIncludeSelf,
final boolean isLoadAnim) {
List<Activity> activities = UtilsBridge.getActivityList();
for (int i = activities.size() - 1; i >= 0; --i) {
Activity aActivity = activities.get(i);
if (aActivity.getClass().equals(clz)) {
for (Activity act : activities) {
if (act.getClass().equals(clz)) {
if (isIncludeSelf) {
finishActivity(aActivity, isLoadAnim);
finishActivity(act, isLoadAnim);
}
return true;
}
finishActivity(aActivity, isLoadAnim);
finishActivity(act, isLoadAnim);
}
return false;
}
......@@ -1736,15 +1733,14 @@ public final class ActivityUtils {
@AnimRes final int enterAnim,
@AnimRes final int exitAnim) {
List<Activity> activities = UtilsBridge.getActivityList();
for (int i = activities.size() - 1; i >= 0; --i) {
Activity aActivity = activities.get(i);
if (aActivity.getClass().equals(clz)) {
for (Activity act : activities) {
if (act.getClass().equals(clz)) {
if (isIncludeSelf) {
finishActivity(aActivity, enterAnim, exitAnim);
finishActivity(act, enterAnim, exitAnim);
}
return true;
}
finishActivity(aActivity, enterAnim, exitAnim);
finishActivity(act, enterAnim, exitAnim);
}
return false;
}
......@@ -1768,10 +1764,9 @@ public final class ActivityUtils {
public static void finishOtherActivities(@NonNull final Class<? extends Activity> clz,
final boolean isLoadAnim) {
List<Activity> activities = UtilsBridge.getActivityList();
for (int i = activities.size() - 1; i >= 0; i--) {
Activity activity = activities.get(i);
if (!activity.getClass().equals(clz)) {
finishActivity(activity, isLoadAnim);
for (Activity act : activities) {
if (!act.getClass().equals(clz)) {
finishActivity(act, isLoadAnim);
}
}
}
......@@ -1789,10 +1784,9 @@ public final class ActivityUtils {
@AnimRes final int enterAnim,
@AnimRes final int exitAnim) {
List<Activity> activities = UtilsBridge.getActivityList();
for (int i = activities.size() - 1; i >= 0; i--) {
Activity activity = activities.get(i);
if (!activity.getClass().equals(clz)) {
finishActivity(activity, enterAnim, exitAnim);
for (Activity act : activities) {
if (!act.getClass().equals(clz)) {
finishActivity(act, enterAnim, exitAnim);
}
}
}
......@@ -1811,12 +1805,11 @@ public final class ActivityUtils {
*/
public static void finishAllActivities(final boolean isLoadAnim) {
List<Activity> activityList = UtilsBridge.getActivityList();
for (int i = activityList.size() - 1; i >= 0; --i) {// remove from top
Activity activity = activityList.get(i);
for (Activity act : activityList) {
// sActivityList remove the index activity at onActivityDestroyed
activity.finish();
act.finish();
if (!isLoadAnim) {
activity.overridePendingTransition(0, 0);
act.overridePendingTransition(0, 0);
}
}
}
......@@ -1832,11 +1825,10 @@ public final class ActivityUtils {
public static void finishAllActivities(@AnimRes final int enterAnim,
@AnimRes final int exitAnim) {
List<Activity> activityList = UtilsBridge.getActivityList();
for (int i = activityList.size() - 1; i >= 0; --i) {// remove from top
Activity activity = activityList.get(i);
for (Activity act : activityList) {
// sActivityList remove the index activity at onActivityDestroyed
activity.finish();
activity.overridePendingTransition(enterAnim, exitAnim);
act.finish();
act.overridePendingTransition(enterAnim, exitAnim);
}
}
......@@ -1854,7 +1846,7 @@ public final class ActivityUtils {
*/
public static void finishAllActivitiesExceptNewest(final boolean isLoadAnim) {
List<Activity> activities = UtilsBridge.getActivityList();
for (int i = activities.size() - 2; i >= 0; i--) {
for (int i = 1; i < activities.size() - 1; i++) {
finishActivity(activities.get(i), isLoadAnim);
}
}
......@@ -1870,7 +1862,7 @@ public final class ActivityUtils {
public static void finishAllActivitiesExceptNewest(@AnimRes final int enterAnim,
@AnimRes final int exitAnim) {
List<Activity> activities = UtilsBridge.getActivityList();
for (int i = activities.size() - 2; i >= 0; i--) {
for (int i = 1; i < activities.size() - 1; i++) {
finishActivity(activities.get(i), enterAnim, exitAnim);
}
}
......
package com.blankj.utilcode.util;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
......@@ -294,12 +293,7 @@ public final class AppUtils {
* Exit the application.
*/
public static void exitApp() {
List<Activity> activityList = UtilsBridge.getActivityList();
for (int i = activityList.size() - 1; i >= 0; --i) {// remove from top
Activity activity = activityList.get(i);
// sActivityList remove the index activity at onActivityDestroyed
activity.finish();
}
UtilsBridge.finishAllActivities();
System.exit(0);
}
......
......@@ -134,7 +134,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0
*/
public static String getExternalStoragePath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Environment.getExternalStorageDirectory());
}
......@@ -144,7 +144,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Music
*/
public static String getExternalMusicPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC));
}
......@@ -154,7 +154,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Podcasts
*/
public static String getExternalPodcastsPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PODCASTS));
}
......@@ -164,7 +164,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Ringtones
*/
public static String getExternalRingtonesPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES));
}
......@@ -174,7 +174,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Alarms
*/
public static String getExternalAlarmsPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS));
}
......@@ -184,7 +184,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Notifications
*/
public static String getExternalNotificationsPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS));
}
......@@ -194,7 +194,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Pictures
*/
public static String getExternalPicturesPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES));
}
......@@ -204,7 +204,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Movies
*/
public static String getExternalMoviesPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES));
}
......@@ -214,7 +214,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Download
*/
public static String getExternalDownloadsPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS));
}
......@@ -224,7 +224,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/DCIM
*/
public static String getExternalDcimPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM));
}
......@@ -234,7 +234,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Documents
*/
public static String getExternalDocumentsPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return getAbsolutePath(Environment.getExternalStorageDirectory()) + "/Documents";
}
......@@ -247,7 +247,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Android/data/package
*/
public static String getExternalAppDataPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
File externalCacheDir = Utils.getApp().getExternalCacheDir();
if (externalCacheDir == null) return "";
return getAbsolutePath(externalCacheDir.getParentFile());
......@@ -259,7 +259,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Android/data/package/cache
*/
public static String getExternalAppCachePath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Utils.getApp().getExternalCacheDir());
}
......@@ -269,7 +269,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Android/data/package/files
*/
public static String getExternalAppFilesPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Utils.getApp().getExternalFilesDir(null));
}
......@@ -279,7 +279,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Android/data/package/files/Music
*/
public static String getExternalAppMusicPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_MUSIC));
}
......@@ -289,7 +289,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Android/data/package/files/Podcasts
*/
public static String getExternalAppPodcastsPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_PODCASTS));
}
......@@ -299,7 +299,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Android/data/package/files/Ringtones
*/
public static String getExternalAppRingtonesPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_RINGTONES));
}
......@@ -309,7 +309,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Android/data/package/files/Alarms
*/
public static String getExternalAppAlarmsPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_ALARMS));
}
......@@ -319,7 +319,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Android/data/package/files/Notifications
*/
public static String getExternalAppNotificationsPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_NOTIFICATIONS));
}
......@@ -329,7 +329,7 @@ public class PathUtils {
* @return path of /storage/emulated/0/Android/data/package/files/Pictures
*/
public static String getExternalAppPicturesPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_PICTURES));
}
......@@ -339,7 +339,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Android/data/package/files/Movies
*/
public static String getExternalAppMoviesPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_MOVIES));
}
......@@ -349,7 +349,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Android/data/package/files/Download
*/
public static String getExternalAppDownloadPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS));
}
......@@ -359,7 +359,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Android/data/package/files/DCIM
*/
public static String getExternalAppDcimPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Utils.getApp().getExternalFilesDir(Environment.DIRECTORY_DCIM));
}
......@@ -369,7 +369,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Android/data/package/files/Documents
*/
public static String getExternalAppDocumentsPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return getAbsolutePath(Utils.getApp().getExternalFilesDir(null)) + "/Documents";
}
......@@ -382,7 +382,7 @@ public class PathUtils {
* @return the path of /storage/emulated/0/Android/obb/package
*/
public static String getExternalAppObbPath() {
if (UtilsBridge.isSDCardEnableByEnvironment()) return "";
if (!UtilsBridge.isSDCardEnableByEnvironment()) return "";
return getAbsolutePath(Utils.getApp().getObbDir());
}
......
......@@ -6,8 +6,6 @@ import android.app.Application;
import android.arch.lifecycle.Lifecycle;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
......@@ -133,15 +131,10 @@ final class UtilsActivityLifecycleImpl implements Application.ActivityLifecycleC
// lifecycle start
///////////////////////////////////////////////////////////////////////////
@Override
public void onActivityPreCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
public void onActivityCreated(@NotNull Activity activity, Bundle savedInstanceState) {
UtilsBridge.applyLanguage(activity);
setAnimatorsEnabled();
setTopActivity(activity);
}
@Override
public void onActivityCreated(@NotNull Activity activity, Bundle savedInstanceState) {
setTopActivity(activity);
consumeActivityLifecycleCallbacks(activity, Lifecycle.Event.ON_CREATE);
}
......
......@@ -95,6 +95,10 @@ class UtilsBridge {
ActivityUtils.startHomeActivity();
}
static void finishAllActivities() {
ActivityUtils.finishAllActivities();
}
///////////////////////////////////////////////////////////////////////////
// AppUtils
///////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册