From dad486568838d1648a3a3d2d4f18bd888b23e3b8 Mon Sep 17 00:00:00 2001 From: Nicola Dorigatti Date: Thu, 29 Oct 2020 11:30:04 +0100 Subject: [PATCH 1/4] Update Libraries and dependencies to make it work with androidX (no jetifier) and Android Studio 4.1 Libraries: Kotlin to 1.4.10 Compile&TargetSDK to 29 buildTools to 30.0.2 Google Truth to 1.1 Robolectric to 3.8 Mocktio to 2.28.2 Json to 20200518 Annotations to androidX Annotations 1.1.0 --- build.gradle | 22 +++++++++---------- gradle.properties | 4 +++- .../orhanobut/logger/AndroidLogAdapter.java | 4 ++-- .../orhanobut/logger/CsvFormatStrategy.java | 6 ++--- .../com/orhanobut/logger/DiskLogAdapter.java | 4 ++-- .../com/orhanobut/logger/DiskLogStrategy.java | 6 +++-- .../com/orhanobut/logger/FormatStrategy.java | 4 ++-- .../java/com/orhanobut/logger/LogAdapter.java | 6 ++--- .../com/orhanobut/logger/LogStrategy.java | 4 ++-- .../orhanobut/logger/LogcatLogStrategy.java | 5 +++-- .../java/com/orhanobut/logger/Logger.java | 4 ++-- .../com/orhanobut/logger/LoggerPrinter.java | 5 ++--- .../logger/PrettyFormatStrategy.java | 4 ++-- .../java/com/orhanobut/logger/Printer.java | 4 ++-- .../main/java/com/orhanobut/logger/Utils.java | 5 +++-- 15 files changed, 46 insertions(+), 41 deletions(-) diff --git a/build.gradle b/build.gradle index e1a1ed21..d469347c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ buildscript { - ext.kotlinVersion = '1.2.31' + ext.kotlinVersion = '1.4.10' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.0' + classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" } } @@ -46,17 +46,17 @@ task clean(type: Delete) { ext { minSdkVersion = 8 - targetSdkVersion = 27 - compileSdkVersion = 27 - buildToolsVersion = '27.0.3' + targetSdkVersion = 29 + compileSdkVersion = 29 + buildToolsVersion = '30.0.2' } ext.deps = [ junit : 'junit:junit:4.12', - truth : 'com.google.truth:truth:0.28', - robolectric : 'org.robolectric:robolectric:3.3', - mockito : "org.mockito:mockito-core:2.8.9", - json : "org.json:json:20160810", - supportAnnotations: "com.android.support:support-annotations:27.1.0", + truth : 'com.google.truth:truth:1.1', + robolectric : 'org.robolectric:robolectric:3.8', + mockito : "org.mockito:mockito-core:2.28.2", + json : "org.json:json:20200518", + supportAnnotations: "androidx.annotation:annotation:1.1.0", kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" -] \ No newline at end of file +] diff --git a/gradle.properties b/gradle.properties index 86a28fb1..5e66227c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,4 +10,6 @@ POM_LICENCE_NAME=The Apache Software License, Version 2.0 POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt POM_LICENCE_DIST=repo POM_DEVELOPER_ID=nr4bt -POM_DEVELOPER_NAME=Orhan Obut \ No newline at end of file +POM_DEVELOPER_NAME=Orhan Obut + +android.useAndroidX=true diff --git a/logger/src/main/java/com/orhanobut/logger/AndroidLogAdapter.java b/logger/src/main/java/com/orhanobut/logger/AndroidLogAdapter.java index 3eaedab3..03ff3a80 100644 --- a/logger/src/main/java/com/orhanobut/logger/AndroidLogAdapter.java +++ b/logger/src/main/java/com/orhanobut/logger/AndroidLogAdapter.java @@ -1,7 +1,7 @@ package com.orhanobut.logger; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import static com.orhanobut.logger.Utils.checkNotNull; diff --git a/logger/src/main/java/com/orhanobut/logger/CsvFormatStrategy.java b/logger/src/main/java/com/orhanobut/logger/CsvFormatStrategy.java index 57a0cedd..e57d67af 100644 --- a/logger/src/main/java/com/orhanobut/logger/CsvFormatStrategy.java +++ b/logger/src/main/java/com/orhanobut/logger/CsvFormatStrategy.java @@ -3,8 +3,8 @@ import android.os.Environment; import android.os.Handler; import android.os.HandlerThread; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import java.io.File; import java.text.SimpleDateFormat; @@ -52,7 +52,7 @@ private CsvFormatStrategy(@NonNull Builder builder) { StringBuilder builder = new StringBuilder(); // machine-readable date/time - builder.append(Long.toString(date.getTime())); + builder.append(date.getTime()); // human-readable date/time builder.append(SEPARATOR); diff --git a/logger/src/main/java/com/orhanobut/logger/DiskLogAdapter.java b/logger/src/main/java/com/orhanobut/logger/DiskLogAdapter.java index 2d4fb5ce..1273a926 100644 --- a/logger/src/main/java/com/orhanobut/logger/DiskLogAdapter.java +++ b/logger/src/main/java/com/orhanobut/logger/DiskLogAdapter.java @@ -1,7 +1,7 @@ package com.orhanobut.logger; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import static com.orhanobut.logger.Utils.checkNotNull; diff --git a/logger/src/main/java/com/orhanobut/logger/DiskLogStrategy.java b/logger/src/main/java/com/orhanobut/logger/DiskLogStrategy.java index 7d742d06..47e83efb 100644 --- a/logger/src/main/java/com/orhanobut/logger/DiskLogStrategy.java +++ b/logger/src/main/java/com/orhanobut/logger/DiskLogStrategy.java @@ -3,8 +3,9 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import java.io.File; import java.io.FileWriter; @@ -12,6 +13,7 @@ import static com.orhanobut.logger.Utils.checkNotNull; + /** * Abstract class that takes care of background threading the file log operation on Android. * implementing classes are free to directly perform I/O operations there. diff --git a/logger/src/main/java/com/orhanobut/logger/FormatStrategy.java b/logger/src/main/java/com/orhanobut/logger/FormatStrategy.java index 2256dc86..0ce89c9f 100644 --- a/logger/src/main/java/com/orhanobut/logger/FormatStrategy.java +++ b/logger/src/main/java/com/orhanobut/logger/FormatStrategy.java @@ -1,7 +1,7 @@ package com.orhanobut.logger; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; /** * Used to determine how messages should be printed or saved. diff --git a/logger/src/main/java/com/orhanobut/logger/LogAdapter.java b/logger/src/main/java/com/orhanobut/logger/LogAdapter.java index f58e54d2..c5e3dc22 100644 --- a/logger/src/main/java/com/orhanobut/logger/LogAdapter.java +++ b/logger/src/main/java/com/orhanobut/logger/LogAdapter.java @@ -1,7 +1,7 @@ package com.orhanobut.logger; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; /** * Provides a common interface to emits logs through. This is a required contract for Logger. @@ -30,4 +30,4 @@ public interface LogAdapter { * @param message is the given message for the log message. */ void log(int priority, @Nullable String tag, @NonNull String message); -} \ No newline at end of file +} diff --git a/logger/src/main/java/com/orhanobut/logger/LogStrategy.java b/logger/src/main/java/com/orhanobut/logger/LogStrategy.java index ad7040f3..0298ef2e 100644 --- a/logger/src/main/java/com/orhanobut/logger/LogStrategy.java +++ b/logger/src/main/java/com/orhanobut/logger/LogStrategy.java @@ -1,7 +1,7 @@ package com.orhanobut.logger; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; /** * Determines destination target for the logs such as Disk, Logcat etc. diff --git a/logger/src/main/java/com/orhanobut/logger/LogcatLogStrategy.java b/logger/src/main/java/com/orhanobut/logger/LogcatLogStrategy.java index 1ead6221..fa501916 100644 --- a/logger/src/main/java/com/orhanobut/logger/LogcatLogStrategy.java +++ b/logger/src/main/java/com/orhanobut/logger/LogcatLogStrategy.java @@ -1,9 +1,10 @@ package com.orhanobut.logger; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import static com.orhanobut.logger.Utils.checkNotNull; /** diff --git a/logger/src/main/java/com/orhanobut/logger/Logger.java b/logger/src/main/java/com/orhanobut/logger/Logger.java index 6a538f21..44aa8d71 100644 --- a/logger/src/main/java/com/orhanobut/logger/Logger.java +++ b/logger/src/main/java/com/orhanobut/logger/Logger.java @@ -1,7 +1,7 @@ package com.orhanobut.logger; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import static com.orhanobut.logger.Utils.checkNotNull; diff --git a/logger/src/main/java/com/orhanobut/logger/LoggerPrinter.java b/logger/src/main/java/com/orhanobut/logger/LoggerPrinter.java index bdd25530..94d54b29 100644 --- a/logger/src/main/java/com/orhanobut/logger/LoggerPrinter.java +++ b/logger/src/main/java/com/orhanobut/logger/LoggerPrinter.java @@ -1,8 +1,7 @@ package com.orhanobut.logger; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; diff --git a/logger/src/main/java/com/orhanobut/logger/PrettyFormatStrategy.java b/logger/src/main/java/com/orhanobut/logger/PrettyFormatStrategy.java index 74e33ad5..d6870d04 100644 --- a/logger/src/main/java/com/orhanobut/logger/PrettyFormatStrategy.java +++ b/logger/src/main/java/com/orhanobut/logger/PrettyFormatStrategy.java @@ -1,7 +1,7 @@ package com.orhanobut.logger; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import static com.orhanobut.logger.Utils.checkNotNull; diff --git a/logger/src/main/java/com/orhanobut/logger/Printer.java b/logger/src/main/java/com/orhanobut/logger/Printer.java index 9fad8de3..542b6142 100644 --- a/logger/src/main/java/com/orhanobut/logger/Printer.java +++ b/logger/src/main/java/com/orhanobut/logger/Printer.java @@ -1,7 +1,7 @@ package com.orhanobut.logger; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; /** * A proxy interface to enable additional operations. diff --git a/logger/src/main/java/com/orhanobut/logger/Utils.java b/logger/src/main/java/com/orhanobut/logger/Utils.java index 1789de23..adf783ce 100644 --- a/logger/src/main/java/com/orhanobut/logger/Utils.java +++ b/logger/src/main/java/com/orhanobut/logger/Utils.java @@ -1,7 +1,8 @@ package com.orhanobut.logger; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import java.io.PrintWriter; import java.io.StringWriter; From bd01c06b04f654000ccd2c098af958f233de1e43 Mon Sep 17 00:00:00 2001 From: Nicola Dorigatti Date: Thu, 29 Oct 2020 11:30:54 +0100 Subject: [PATCH 2/4] Fix checkstyle issue, moving LineLength out of TreeWalker --- checkstyle.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/checkstyle.xml b/checkstyle.xml index 93390382..3a31c202 100755 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -6,6 +6,9 @@ + + + @@ -63,9 +66,6 @@ - - - From cff3b2e9f0995be0d883e1841a28af90b48a4ca9 Mon Sep 17 00:00:00 2001 From: Nicola Dorigatti Date: Thu, 29 Oct 2020 11:31:33 +0100 Subject: [PATCH 3/4] Update version to 2.2.1 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 5e66227c..eff36628 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.2.0 +VERSION_NAME=2.2.1 GROUP=com.orhanobut POM_DESCRIPTION=Simple, Pretty and Advanced Logger From 926985c0667eb71d836cf9d4574b134318f32a09 Mon Sep 17 00:00:00 2001 From: Nicola Dorigatti Date: Thu, 29 Oct 2020 11:31:49 +0100 Subject: [PATCH 4/4] Make sample app use same targetSdkVersion as library --- sample/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample/build.gradle b/sample/build.gradle index 0b33264b..6df2a920 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -7,7 +7,7 @@ android { defaultConfig { applicationId "com.orhanobut.sample" minSdkVersion 23 - targetSdkVersion 27 + targetSdkVersion rootProject.ext.compileSdkVersion versionCode 1 versionName "1.0"