From 74e1c919d441a4500fc9da868e8e4fe13059c932 Mon Sep 17 00:00:00 2001 From: lionel <.> Date: Wed, 9 Jul 2025 13:40:50 +0200 Subject: [PATCH] Update Gradle to 8.9.3, Sdk to 35, Java to 17 and Fix --- .idea/.name | 1 + .idea/AndroidProjectSystem.xml | 6 ++++ .idea/compiler.xml | 2 +- .idea/deploymentTargetSelector.xml | 10 +++++++ .idea/gradle.xml | 5 ++-- .idea/migrations.xml | 10 +++++++ .idea/misc.xml | 10 +++++-- .idea/runConfigurations.xml | 17 +++++++++++ app/build.gradle | 29 +++++++++---------- .../ExampleInstrumentedTest.java | 26 ----------------- app/src/main/AndroidManifest.xml | 9 +++--- .../java/com/localtransfer/MainActivity.java | 3 +- .../com/localtransfer/SettingsActivity.java | 5 ++-- .../main/java/com/localtransfer/Transfer.java | 13 +++++++++ app/src/main/res/values/strings.xml | 4 +-- .../com/localtransfer/ExampleUnitTest.java | 17 ----------- build.gradle | 14 +++++---- gradle.properties | 5 +++- gradle/wrapper/gradle-wrapper.properties | 2 +- 19 files changed, 104 insertions(+), 84 deletions(-) create mode 100644 .idea/.name create mode 100644 .idea/AndroidProjectSystem.xml create mode 100644 .idea/deploymentTargetSelector.xml create mode 100644 .idea/migrations.xml create mode 100644 .idea/runConfigurations.xml delete mode 100644 app/src/androidTest/java/com/localtransfer/ExampleInstrumentedTest.java delete mode 100644 app/src/test/java/com/localtransfer/ExampleUnitTest.java diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..b3d1c80 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +LocalTransfer \ No newline at end of file diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml new file mode 100644 index 0000000..4a53bee --- /dev/null +++ b/.idea/AndroidProjectSystem.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index fb7f4a8..b589d56 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..b268ef3 --- /dev/null +++ b/.idea/deploymentTargetSelector.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 526b4c2..639c779 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,16 +4,15 @@ diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index f4f18d3..9e3a8ea 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -16,7 +16,7 @@ - + diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..16660f1 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 27c226f..7114955 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,12 +1,11 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 30 - + compileSdk 35 defaultConfig { applicationId "com.localtransfer" - minSdkVersion 24 - targetSdkVersion 30 + minSdkVersion 27 + targetSdkVersion 35 versionCode 1 versionName "2.0" @@ -20,22 +19,20 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } + namespace 'com.localtransfer' } dependencies { - implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.google.android.material:material:1.2.1' - implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'androidx.appcompat:appcompat:1.7.1' + implementation 'com.google.android.material:material:1.12.0' + implementation 'androidx.constraintlayout:constraintlayout:2.2.1' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' - implementation 'androidx.preference:preference:1.1.1' + implementation 'androidx.preference:preference:1.2.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - testImplementation 'junit:junit:4.13.1' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' - implementation 'lib.kashif:folderpicker:2.4' - + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' } \ No newline at end of file diff --git a/app/src/androidTest/java/com/localtransfer/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/localtransfer/ExampleInstrumentedTest.java deleted file mode 100644 index 7241b24..0000000 --- a/app/src/androidTest/java/com/localtransfer/ExampleInstrumentedTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.localtransfer; - -import android.content.Context; - -import androidx.test.platform.app.InstrumentationRegistry; -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumented test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("com.localtransfer", appContext.getPackageName()); - } -} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0414bfa..7f80242 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ - + + + android:exported="true" /> + android:label="@string/title_activity_settings" /> diff --git a/app/src/main/java/com/localtransfer/MainActivity.java b/app/src/main/java/com/localtransfer/MainActivity.java index 09b2bcf..b1e4f09 100644 --- a/app/src/main/java/com/localtransfer/MainActivity.java +++ b/app/src/main/java/com/localtransfer/MainActivity.java @@ -72,7 +72,7 @@ public class MainActivity extends AppCompatActivity { Transfer.resolver = this.getContentResolver(); Intent notificationIntent = new Intent(this, MainActivity.class); - Transfer.pendingIntent = PendingIntent.getActivity(this,0, notificationIntent, 0); + Transfer.pendingIntent = PendingIntent.getActivity(this,0, notificationIntent, PendingIntent.FLAG_IMMUTABLE); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); @@ -244,6 +244,7 @@ public class MainActivity extends AppCompatActivity { public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); switch (requestCode) { case REQUEST_ID_READ_EXTERNAL_STORAGE: if (grantResults.length > 0 && diff --git a/app/src/main/java/com/localtransfer/SettingsActivity.java b/app/src/main/java/com/localtransfer/SettingsActivity.java index b1352e9..90d86bb 100644 --- a/app/src/main/java/com/localtransfer/SettingsActivity.java +++ b/app/src/main/java/com/localtransfer/SettingsActivity.java @@ -19,8 +19,6 @@ import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceManager; import androidx.preference.SwitchPreference; -import lib.folderpicker.FolderPicker; - public class SettingsActivity extends AppCompatActivity { @Override @@ -76,7 +74,8 @@ public class SettingsActivity extends AppCompatActivity { directory.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { - Intent intent = new Intent(getContext(), FolderPicker.class); + Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); + intent.addCategory(Intent.CATEGORY_DEFAULT); startActivityForResult(intent, REQUEST_DIRECTORY_PICKER); return false; } diff --git a/app/src/main/java/com/localtransfer/Transfer.java b/app/src/main/java/com/localtransfer/Transfer.java index 060c363..3125a40 100644 --- a/app/src/main/java/com/localtransfer/Transfer.java +++ b/app/src/main/java/com/localtransfer/Transfer.java @@ -2,12 +2,14 @@ package com.localtransfer; import static java.lang.Integer.valueOf; +import android.Manifest; import android.app.Activity; import android.app.Notification; import android.app.PendingIntent; import android.content.ContentResolver; import android.content.Context; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.graphics.Color; import android.util.Log; import android.view.LayoutInflater; @@ -18,6 +20,7 @@ import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; +import androidx.core.app.ActivityCompat; import androidx.core.app.NotificationManagerCompat; import androidx.preference.PreferenceManager; @@ -202,6 +205,16 @@ public class Transfer { .setContentText(String.format("%d%% %s/%s", percent, loadedSI, sizeSI)) .setProgress(100, (int) percent, false) .setContentIntent(pendingIntent); + if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { + // TODO: Consider calling + // ActivityCompat#requestPermissions + // here to request the missing permissions, and then overriding + // public void onRequestPermissionsResult(int requestCode, String[] permissions, + // int[] grantResults) + // to handle the case where the user grants the permission. See the documentation + // for ActivityCompat#requestPermissions for more details. + return; + } notifiManager.notify(Transfer.NOTIF_SERVICE, notifBuilder.build()); if (app_started && fragment_on) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 474e6fa..1e37f25 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,11 +23,11 @@ Host Use secure https - www.netdldata.net + transfer.netdldata.net Port Root - /transfer + /php Use shared storage diff --git a/app/src/test/java/com/localtransfer/ExampleUnitTest.java b/app/src/test/java/com/localtransfer/ExampleUnitTest.java deleted file mode 100644 index 373beb1..0000000 --- a/app/src/test/java/com/localtransfer/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.localtransfer; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 781e205..c9fcfd2 100644 --- a/build.gradle +++ b/build.gradle @@ -2,10 +2,10 @@ buildscript { repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.1' + classpath 'com.android.tools.build:gradle:8.9.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,15 +15,17 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } gradle.projectsEvaluated { - tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" + tasks.withType(JavaCompile).tap { + configureEach { + options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" + } } } } -task clean(type: Delete) { +tasks.register('clean', Delete) { delete rootProject.buildDir } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index c52ac9b..091e018 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,7 @@ org.gradle.jvmargs=-Xmx2048m # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true \ No newline at end of file +android.enableJetifier=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3cf3705..2e03e70 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip