Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nothing to see here, move along #377

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ See [Wiki](https://github.com/tony19/logback-android/wiki) for documentation.

```groovy
dependencies {
implementation 'org.slf4j:slf4j-api:2.0.7'
implementation 'org.slf4j:slf4j-api:2.0.16'
implementation 'com.github.tony19:logback-android:3.0.0'
}
```
Expand All @@ -31,7 +31,7 @@ See [Wiki](https://github.com/tony19/logback-android/wiki) for documentation.

```groovy
dependencies {
implementation 'org.slf4j:slf4j-api:2.0.7'
implementation 'org.slf4j:slf4j-api:2.0.16'
implementation 'com.github.tony19:logback-android:3.0.0'
testImplementation 'ch.qos.logback:logback-classic:1.2.11'
}
Expand Down Expand Up @@ -93,7 +93,7 @@ _Gradle_ **release**

```groovy
dependencies {
implementation 'org.slf4j:slf4j-api:2.0.7'
implementation 'org.slf4j:slf4j-api:2.0.16'
implementation 'com.github.tony19:logback-android:3.0.0'
}
```
Expand All @@ -106,8 +106,8 @@ repositories {
}

dependencies {
implementation 'org.slf4j:slf4j-api:2.0.7'
implementation 'com.github.tony19:logback-android:3.0.1-SNAPSHOT'
implementation 'org.slf4j:slf4j-api:2.0.16'
implementation 'com.github.tony19:logback-android:3.0.2-AAPS'
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.android.tools.build:gradle:8.7.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

# `version` is needed by gradle-release-plugin and always matches
# `VERSION_NAME`. The plugin updates both automatically.
version=3.0.1-SNAPSHOT
VERSION_NAME=3.0.1-SNAPSHOT
VERSION_CODE=3020000
version=3.0.2-AAPS
VERSION_NAME=3.0.2-AAPS
VERSION_CODE=3030000

slf4jVersion=2.0.7
slf4jVersion=2.0.16

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
Expand Down Expand Up @@ -51,4 +51,4 @@ android.defaults.buildfeatures.resvalues=false
android.defaults.buildfeatures.shaders=false

# for gradle-maven-publish-plugin
android.disableAutomaticComponentCreation=true
# android.disableAutomaticComponentCreation=true
2 changes: 1 addition & 1 deletion gradle/analysis.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ staticAnalysis {
maxWarnings = 0
}
checkstyle {
toolVersion "10.12.0"
toolVersion "10.20.1"
configFile rootProject.file('config/checkstyle.xml')
}
pmd {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
27 changes: 17 additions & 10 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -83,7 +85,9 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -130,26 +134,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -198,11 +205,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
2 changes: 1 addition & 1 deletion logback-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dependencies {

testImplementation 'org.hamcrest:hamcrest-junit:2.0.0.0'
testImplementation 'org.robolectric:robolectric:4.10.3'
testImplementation 'org.mockito:mockito-core:2.28.2'
testImplementation 'org.mockito:mockito-core:5.14.2'
testImplementation 'joda-time:joda-time:2.12.5'

// This dep is required when using Robolectric and targeting pre-21 SDKs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.content.ContextWrapper;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;

Expand All @@ -38,7 +39,7 @@
*/
public class AndroidContextUtil {
private ContextWrapper context;

private static Uri logDirectoryUri;
public AndroidContextUtil() {
this(getContext());
}
Expand All @@ -55,10 +56,41 @@ public static boolean containsProperties(String value) {
|| value.contains(CoreConstants.VERSION_NAME_KEY);
}

public static void setLogDirectoryUri(Uri uri) {
// Store the URI for use in other methods
logDirectoryUri = uri;
}

/**
* Sets properties for use in configs
* @param context logger context whose property map is updated
*/
public void setupProperties(Context context) {
// Legacy properties (might need adjustments for Scoped Storage)
context.putProperty(CoreConstants.DATA_DIR_KEY, getFilesDirectoryPath());

// Scoped Storage compliant EXT_DIR_KEY
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// For Android 10 (API 29) and above, use logDirectoryUri if available
if (logDirectoryUri != null) {
context.putProperty(CoreConstants.EXT_DIR_KEY, logDirectoryUri.toString());
} else {
// Fallback to app-specific directory if URI is not set
context.putProperty(CoreConstants.EXT_DIR_KEY, getExternalFilesDirectoryPath());
}
} else {
// For older Android versions, use the legacy approach
final String extDir = getMountedExternalStorageDirectoryPath(); // This will also use logDirectoryUri if set
if (extDir != null) {
context.putProperty(CoreConstants.EXT_DIR_KEY, extDir);
}
}

context.putProperty(CoreConstants.PACKAGE_NAME_KEY, getPackageName());
context.putProperty(CoreConstants.VERSION_CODE_KEY, getVersionCode());
context.putProperty(CoreConstants.VERSION_NAME_KEY, getVersionName());
}
/*
public void setupProperties(Context context) {
// legacy properties
context.putProperty(CoreConstants.DATA_DIR_KEY, getFilesDirectoryPath());
Expand All @@ -70,6 +102,7 @@ public void setupProperties(Context context) {
context.putProperty(CoreConstants.VERSION_CODE_KEY, getVersionCode());
context.putProperty(CoreConstants.VERSION_NAME_KEY, getVersionName());
}
*/

protected static ContextWrapper getContext() {
try {
Expand All @@ -96,14 +129,35 @@ protected static ContextWrapper getContext() {
* or {@code null} if not mounted.
*/
public String getMountedExternalStorageDirectoryPath() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// For Android 10 (API 29) and above, use the stored logDirectoryUri if available
if (logDirectoryUri != null) {
return logDirectoryUri.toString();
} else {
// Fallback to app-specific directory if URI is not set
return absPath(context.getExternalFilesDir(null));
}
} else {
// For older Android versions, use the legacy approach
String path = null;
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state) ||
Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
path = getExternalStorageDirectoryPath(); // This will also use logDirectoryUri if set
}
return path;
}
}

/*public String getMountedExternalStorageDirectoryPath() {
String path = null;
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state) ||
Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
path = getExternalStorageDirectoryPath();
}
return path;
}
}*/

/**
* Gets the path to the external storage directory
Expand All @@ -120,11 +174,27 @@ public String getMountedExternalStorageDirectoryPath() {
@SuppressWarnings("deprecation")
public String getExternalStorageDirectoryPath() {
if (Build.VERSION.SDK_INT >= 29) {
return getExternalFilesDirectoryPath();
// Use the stored logDirectoryUri if available
if (logDirectoryUri != null) {
return logDirectoryUri.toString();
} else {
// Fallback to app-specific directory if URI is not set
return absPath(context.getExternalFilesDir(null));
}
} else {
// Use Environment.getExternalStorageDirectory() for older versions
return absPath(Environment.getExternalStorageDirectory());
}
}
/*@TargetApi(8)
@SuppressWarnings("deprecation")
public String getExternalStorageDirectoryPath() {
if (Build.VERSION.SDK_INT >= 29) {
return getExternalFilesDirectoryPath();
} else {
return absPath(Environment.getExternalStorageDirectory());
}
}*/

/**
* Gets the path to the external storage directory
Expand Down
Loading
Loading