From 0350790c5d3343b198f7cce75ca2ce331427bcaf Mon Sep 17 00:00:00 2001 From: TranceLove Date: Mon, 8 Jul 2024 11:27:31 +0800 Subject: [PATCH] SDK 34 adaptations - build.gradle upgrades - Code adaptations to remove switch cases to resource IDs - Fix import of resource IDs from library level resources - Minimum version requirement set to LOLLIPOP --- .github/workflows/android-build.yml | 8 +- .../android-debug-artifact-ondemand.yml | 4 +- .../android-debug-artifact-release.yml | 4 +- .github/workflows/android-feature.yml | 8 +- .github/workflows/android-main.yml | 13 +- app/build.gradle | 21 +- app/proguard.cfg | 7 + .../crashreport/ErrorActivity.java | 22 +- .../amaze/filemanager/ui/ItemPopupMenu.java | 289 +++++++++--------- .../ui/activities/AboutActivity.java | 170 +++++------ .../ui/activities/MainActivity.java | 215 ++++++------- .../texteditor/TextEditorActivity.java | 128 ++++---- .../ui/fragments/AppsListFragment.java | 27 +- .../ui/fragments/CloudSheetFragment.java | 66 ++-- .../filemanager/ui/views/FastScroller.java | 2 +- .../ui/views/ScrimInsetsRelativeLayout.java | 16 +- .../ui/views/appbar/SearchView.java | 4 +- .../com/amaze/filemanager/utils/AnimUtils.kt | 3 +- .../com/amaze/filemanager/utils/Utils.java | 3 +- .../application/AppConfigTest.java | 4 +- .../asynctasks/AbstractDeleteTaskTestBase.kt | 4 +- .../asynctasks/DbViewerTaskTest.java | 4 +- .../AbstractCompressedHelperCallableTest.kt | 4 +- .../CompressedHelperForBadArchiveTest.kt | 4 +- .../SearchResultListSorterTest.kt | 2 +- .../ssh/PemToKeyPairObservableEd25519Test.kt | 4 +- .../ssh/PemToKeyPairObservableRsaTest.kt | 4 +- .../ssh/SshAuthenticationTaskTest.kt | 4 +- .../read/ReadTextFileCallableTest.kt | 4 +- .../write/WriteTextFileCallableTest.java | 4 +- .../services/DecryptServiceTest.kt | 4 +- .../services/EncryptServiceTest.kt | 4 +- ...ServiceAndroidFileSystemIntegrationTest.kt | 4 +- .../asynchronous/services/ZipServiceTest.kt | 4 +- .../services/ftp/FtpReceiverTest.kt | 6 +- .../database/ExplorerDatabaseMigrationTest.kt | 4 +- .../UtilitiesDatabaseMigrationTest.kt | 4 +- .../filemanager/database/UtilsHandlerTest.kt | 4 +- .../EncryptedStringTypeConverterTest.kt | 4 +- ...bstractFilenameHelperIncrementNameTests.kt | 4 +- .../filesystem/AbstractOperationsTestBase.kt | 4 +- .../EditableFileAbstractionTest.java | 4 +- .../filemanager/filesystem/HybridFileTest.kt | 4 +- .../filesystem/OperationsTest.java | 4 +- .../filesystem/RootHelperTest.java | 4 +- .../filesystem/compressed/B0rkenZipTest.java | 4 +- .../compressed/CompressedHelperTest.java | 4 +- .../extractcontents/AbstractExtractorTest.kt | 4 +- .../filesystem/files/FileListSorterTest.kt | 2 +- .../filesystem/files/FileUtilsTest.kt | 4 +- .../filesystem/files/sort/DirSortByTest.kt | 2 +- .../filesystem/files/sort/SortByTest.kt | 2 +- .../filesystem/files/sort/SortTypeTest.kt | 2 +- .../filesystem/ftp/FtpsHybridFileTest.kt | 9 +- .../ftp/NetCopyClientConnectionPoolFtpTest.kt | 4 +- .../commands/AbstractFtpserverCommandTest.kt | 4 +- .../filesystem/root/ListFilesCommandTest.kt | 4 +- .../filesystem/root/ListFilesCommandTest2.kt | 61 ++-- .../filesystem/smb/CifsContextsTest.java | 4 +- .../filesystem/smb/SmbHybridFileTest.kt | 4 +- .../filesystem/ssh/AbstractSftpServerTest.kt | 4 +- .../ssh/NetCopyClientConnectionPoolSshTest.kt | 4 +- .../filesystem/ssh/SshHybridFileTest.kt | 4 +- .../filesystem/usb/ReflectionHelpers.java | 20 +- .../AbstractMainActivityTestBase.kt | 4 +- .../ui/activities/PermissionsActivityTest.kt | 4 +- .../ui/activities/TextEditorActivityTest.java | 4 +- .../ui/dialogs/AbstractEncryptDialogTests.kt | 4 +- .../ui/dialogs/ColorPickerDialogTest.kt | 4 +- .../ui/fragments/CloudSheetFragmentTest.java | 4 +- .../UiPrefsFragmentTest.kt | 2 +- .../amaze/filemanager/ui/icons/IconsTest.java | 4 +- .../NotificationConstantsTest.java | 12 +- .../filemanager/ui/theme/AppThemeTest.kt | 4 +- .../views/WarnableTextInputValidatorTest.java | 4 +- .../amaze/filemanager/utils/AESCryptTest.kt | 4 +- .../filemanager/utils/AnimUtilsTest.java | 4 +- .../amaze/filemanager/utils/CryptUtilTest.kt | 4 +- .../utils/MinMaxInputFilterTest.kt | 4 +- .../amaze/filemanager/utils/SmbUtilTest.kt | 4 +- .../amaze/filemanager/utils/TinyDBTest.java | 4 +- .../amaze/filemanager/utils/UtilsTest.java | 4 +- .../utils/X509CertificateUtilTest.kt | 22 +- ...tractSubnetDiscoverDevicesStrategyTests.kt | 4 +- .../MultipartRarExtractorTest.kt | 2 +- .../utils/PackageInstallValidationTest.kt | 3 +- build.gradle | 42 +-- commons_compress_7z/build.gradle | 7 +- commons_compress_7z/consumer-rules.pro | 0 commons_compress_7z/proguard-rules.pro | 23 ++ file_operations/build.gradle | 9 +- file_operations/proguard-rules.pro | 5 +- .../smbstreamer/StreamSourceTest.java | 3 +- gradle/libs.versions.toml | 6 +- gradle/wrapper/gradle-wrapper.properties | 2 +- portscanner/build.gradle | 6 +- .../test/ShadowPasswordUtilTest.java | 4 +- 97 files changed, 694 insertions(+), 782 deletions(-) create mode 100644 commons_compress_7z/consumer-rules.pro create mode 100644 commons_compress_7z/proguard-rules.pro diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index c304c37817..24cbf5c350 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -16,11 +16,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: "temurin" - java-version: 11 + java-version: 17 - name: Check formatting using spotless uses: gradle/actions/setup-gradle@v3 with: @@ -31,11 +31,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: "temurin" - java-version: 11 + java-version: 17 - name: Build with Gradle uses: gradle/actions/setup-gradle@v3 with: diff --git a/.github/workflows/android-debug-artifact-ondemand.yml b/.github/workflows/android-debug-artifact-ondemand.yml index d3f4360288..4f19d69688 100644 --- a/.github/workflows/android-debug-artifact-ondemand.yml +++ b/.github/workflows/android-debug-artifact-ondemand.yml @@ -35,11 +35,11 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} repository: ${{fromJson(steps.request.outputs.data).head.repo.full_name}} ref: ${{fromJson(steps.request.outputs.data).head.ref}} - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: "temurin" - java-version: 11 + java-version: 17 - name: Build with Gradle uses: gradle/actions/setup-gradle@v3 with: diff --git a/.github/workflows/android-debug-artifact-release.yml b/.github/workflows/android-debug-artifact-release.yml index 56cfdbf0d1..53d915a20c 100644 --- a/.github/workflows/android-debug-artifact-release.yml +++ b/.github/workflows/android-debug-artifact-release.yml @@ -9,11 +9,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: "temurin" - java-version: 11 + java-version: 17 - name: Build with Gradle uses: gradle/actions/setup-gradle@v3 with: diff --git a/.github/workflows/android-feature.yml b/.github/workflows/android-feature.yml index a551a2ebec..91d46524ba 100644 --- a/.github/workflows/android-feature.yml +++ b/.github/workflows/android-feature.yml @@ -17,11 +17,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: "temurin" - java-version: 11 + java-version: 17 - name: Check formatting using spotless uses: gradle/actions/setup-gradle@v3 with: @@ -32,11 +32,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: "temurin" - java-version: 11 + java-version: 17 - name: Build with Gradle uses: gradle/actions/setup-gradle@v3 with: diff --git a/.github/workflows/android-main.yml b/.github/workflows/android-main.yml index 331d75846e..ef4f48c00c 100644 --- a/.github/workflows/android-main.yml +++ b/.github/workflows/android-main.yml @@ -17,11 +17,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: "temurin" - java-version: 11 + java-version: 17 - name: Check formatting using spotless uses: gradle/actions/setup-gradle@v3 with: @@ -34,11 +34,11 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: "temurin" - java-version: 11 + java-version: 17 - name: Build with Gradle uses: gradle/actions/setup-gradle@v3 with: @@ -71,10 +71,11 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - - name: Java 15 + - name: Java 17 uses: actions/setup-java@v4 with: - java-version: 15 + distribution: "temurin" + java-version: 17 - name: Gradle cache uses: gradle/actions/setup-gradle@v3 - name: AVD cache diff --git a/app/build.gradle b/app/build.gradle index b7d0ce2d23..091b9d1337 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-parcelize' -apply plugin: 'com.hiya.jacoco-android' +apply plugin: "com.mxalbert.gradle.jacoco-android" apply plugin: "com.starter.easylauncher" apply plugin: 'com.google.devtools.ksp' @@ -15,7 +15,6 @@ android { } } - defaultConfig { applicationId "com.amaze.filemanager" minSdkVersion libs.versions.minSdk.get().toInteger() @@ -95,12 +94,12 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '11' + jvmTarget = '17' } testOptions { @@ -262,7 +261,7 @@ dependencies { } kotlin { - jvmToolchain(11) + jvmToolchain(17) } configurations.configureEach { @@ -291,6 +290,8 @@ tasks.register('supportOldLangCodes') include('strings.xml') } supportOldLangCodes.dependsOn copyTask + rootProject.tasks.named('spotlessJava').configure { dependsOn copyTask } + rootProject.tasks.named('spotlessKotlin').configure { dependsOn copyTask } } project.afterEvaluate { @@ -304,14 +305,6 @@ jacoco { toolVersion = libs.versions.jacoco.get() } -tasks.withType(JacocoReport).configureEach { - reports { - csv.required.set(false) - html.required.set(true) - xml.required.set(true) - } -} - tasks.withType(Test).configureEach { jacoco.includeNoLocationClasses = true jacoco.excludes = ['jdk.internal.*'] diff --git a/app/proguard.cfg b/app/proguard.cfg index 19bb9c2bb5..738663b299 100644 --- a/app/proguard.cfg +++ b/app/proguard.cfg @@ -98,6 +98,13 @@ -keep class org.bouncycastle.jcajce.spec.* {*;} -keep class org.bouncycastle.jce.** {*;} +-dontwarn org.bouncycastle.jsse.** +-dontwarn org.bouncycastle.asn1.ASN1ApplicationSpecific +-dontwarn org.bouncycastle.asn1.DERApplicationSpecific +-dontwarn org.conscrypt.** +-dontwarn org.openjsse.** +-dontwarn sun.security.x509.X509Key + -dontwarn javax.naming.** #From here sshj. We are not using GSSAPI to connect to SSH diff --git a/app/src/main/java/com/amaze/filemanager/crashreport/ErrorActivity.java b/app/src/main/java/com/amaze/filemanager/crashreport/ErrorActivity.java index 331a00d6d7..67e0c25ca5 100644 --- a/app/src/main/java/com/amaze/filemanager/crashreport/ErrorActivity.java +++ b/app/src/main/java/com/amaze/filemanager/crashreport/ErrorActivity.java @@ -263,20 +263,14 @@ public boolean onCreateOptionsMenu(final Menu menu) { @Override public boolean onOptionsItemSelected(final MenuItem item) { - final int id = item.getItemId(); - switch (id) { - case android.R.id.home: - goToReturnActivity(); - break; - case R.id.menu_item_share_error: - final Intent intent = new Intent(); - intent.setAction(Intent.ACTION_SEND); - intent.putExtra(Intent.EXTRA_TEXT, buildMarkdown()); - intent.setType("text/plain"); - startActivity(Intent.createChooser(intent, getString(R.string.share))); - break; - default: - break; + if (item.getItemId() == android.R.id.home) { + goToReturnActivity(); + } else if (item.getItemId() == R.id.menu_item_share_error) { + final Intent intent = new Intent(); + intent.setAction(Intent.ACTION_SEND); + intent.putExtra(Intent.EXTRA_TEXT, buildMarkdown()); + intent.setType("text/plain"); + startActivity(Intent.createChooser(intent, getString(R.string.share))); } return false; } diff --git a/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java b/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java index 2320ddb3c4..d3b0ea387f 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java +++ b/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java @@ -94,168 +94,163 @@ public ItemPopupMenu( @Override public boolean onMenuItemClick(MenuItem item) { - switch (item.getItemId()) { - case R.id.about: - GeneralDialogCreation.showPropertiesDialogWithPermissions( - (rowItem).generateBaseFile(), - rowItem.permissions, - mainActivity, - mainFragment, - mainActivity.isRootExplorer(), - utilitiesProvider.getAppTheme()); - return true; - case R.id.share: - switch (rowItem.getMode()) { - case DROPBOX: - case BOX: - case GDRIVE: - case ONEDRIVE: - FileUtils.shareCloudFile(rowItem.desc, rowItem.getMode(), context); - break; - default: - ArrayList arrayList = new ArrayList<>(); - arrayList.add(new File(rowItem.desc)); - FileUtils.shareFiles( - arrayList, mainActivity, utilitiesProvider.getAppTheme(), accentColor); - break; - } - return true; - case R.id.rename: - mainFragment.rename(rowItem.generateBaseFile()); - return true; - case R.id.cpy: - case R.id.cut: - { - int op = - item.getItemId() == R.id.cpy ? PasteHelper.OPERATION_COPY : PasteHelper.OPERATION_CUT; - PasteHelper pasteHelper = - new PasteHelper( - mainActivity, op, new HybridFileParcelable[] {rowItem.generateBaseFile()}); - mainActivity.setPaste(pasteHelper); - return true; - } - case R.id.ex: - mainActivity.mainActivityHelper.extractFile(new File(rowItem.desc)); - return true; - case R.id.book: - DataUtils dataUtils = DataUtils.getInstance(); - if (dataUtils.addBook(new String[] {rowItem.title, rowItem.desc}, true)) { - mainActivity.getDrawer().refreshDrawer(); - Toast.makeText( - mainFragment.getActivity(), - mainFragment.getString(R.string.bookmarks_added), - Toast.LENGTH_LONG) - .show(); - } else { - Toast.makeText( - mainFragment.getActivity(), - mainFragment.getString(R.string.bookmark_exists), - Toast.LENGTH_LONG) - .show(); - } - return true; - case R.id.delete: - ArrayList positions = new ArrayList<>(); - positions.add(rowItem); - GeneralDialogCreation.deleteFilesDialog( - context, mainActivity, positions, utilitiesProvider.getAppTheme()); - return true; - case R.id.restore: - ArrayList p2 = new ArrayList<>(); - p2.add(rowItem); - GeneralDialogCreation.restoreFilesDialog( - context, mainActivity, p2, utilitiesProvider.getAppTheme()); - return true; - case R.id.open_with: - boolean useNewStack = - sharedPrefs.getBoolean(PreferencesConstants.PREFERENCE_TEXTEDITOR_NEWSTACK, false); + if (item.getItemId() == R.id.about) { + GeneralDialogCreation.showPropertiesDialogWithPermissions( + (rowItem).generateBaseFile(), + rowItem.permissions, + mainActivity, + mainFragment, + mainActivity.isRootExplorer(), + utilitiesProvider.getAppTheme()); + return true; + } else if (item.getItemId() == R.id.share) { + switch (rowItem.getMode()) { + case DROPBOX: + case BOX: + case GDRIVE: + case ONEDRIVE: + FileUtils.shareCloudFile(rowItem.desc, rowItem.getMode(), context); + break; + default: + ArrayList arrayList = new ArrayList<>(); + arrayList.add(new File(rowItem.desc)); + FileUtils.shareFiles( + arrayList, mainActivity, utilitiesProvider.getAppTheme(), accentColor); + break; + } + return true; + } else if (item.getItemId() == R.id.rename) { + mainFragment.rename(rowItem.generateBaseFile()); + return true; + } else if (item.getItemId() == R.id.cpy || item.getItemId() == R.id.cut) { + int op = + item.getItemId() == R.id.cpy ? PasteHelper.OPERATION_COPY : PasteHelper.OPERATION_CUT; + PasteHelper pasteHelper = + new PasteHelper( + mainActivity, op, new HybridFileParcelable[] {rowItem.generateBaseFile()}); + mainActivity.setPaste(pasteHelper); + return true; + } else if (item.getItemId() == R.id.ex) { + mainActivity.mainActivityHelper.extractFile(new File(rowItem.desc)); + return true; + } else if (item.getItemId() == R.id.book) { + DataUtils dataUtils = DataUtils.getInstance(); + if (dataUtils.addBook(new String[] {rowItem.title, rowItem.desc}, true)) { + mainActivity.getDrawer().refreshDrawer(); + Toast.makeText( + mainFragment.getActivity(), + mainFragment.getString(R.string.bookmarks_added), + Toast.LENGTH_LONG) + .show(); + } else { + Toast.makeText( + mainFragment.getActivity(), + mainFragment.getString(R.string.bookmark_exists), + Toast.LENGTH_LONG) + .show(); + } + return true; + } else if (item.getItemId() == R.id.delete) { + ArrayList positions = new ArrayList<>(); + positions.add(rowItem); + GeneralDialogCreation.deleteFilesDialog( + context, mainActivity, positions, utilitiesProvider.getAppTheme()); + return true; + } else if (item.getItemId() == R.id.restore) { + ArrayList p2 = new ArrayList<>(); + p2.add(rowItem); + GeneralDialogCreation.restoreFilesDialog( + context, mainActivity, p2, utilitiesProvider.getAppTheme()); + return true; + } else if (item.getItemId() == R.id.open_with) { + boolean useNewStack = + sharedPrefs.getBoolean(PreferencesConstants.PREFERENCE_TEXTEDITOR_NEWSTACK, false); - if (OpenMode.DOCUMENT_FILE.equals(rowItem.getMode())) { + if (OpenMode.DOCUMENT_FILE.equals(rowItem.getMode())) { - @Nullable Uri fullUri = rowItem.generateBaseFile().getFullUri(); + @Nullable Uri fullUri = rowItem.generateBaseFile().getFullUri(); - if (fullUri != null) { + if (fullUri != null) { - DocumentFile documentFile = DocumentFile.fromSingleUri(context, fullUri); + DocumentFile documentFile = DocumentFile.fromSingleUri(context, fullUri); - if (documentFile != null) { - FileUtils.openWith(documentFile, mainActivity, useNewStack); - return true; - } + if (documentFile != null) { + FileUtils.openWith(documentFile, mainActivity, useNewStack); + return true; } } + } - FileUtils.openWith(new File(rowItem.desc), mainActivity, useNewStack); + FileUtils.openWith(new File(rowItem.desc), mainActivity, useNewStack); - return true; - case R.id.encrypt: - final Intent encryptIntent = new Intent(context, EncryptService.class); - encryptIntent.putExtra(EncryptService.TAG_OPEN_MODE, rowItem.getMode().ordinal()); - encryptIntent.putExtra(EncryptService.TAG_SOURCE, rowItem.generateBaseFile()); + return true; + } else if (item.getItemId() == R.id.encrypt) { + final Intent encryptIntent = new Intent(context, EncryptService.class); + encryptIntent.putExtra(EncryptService.TAG_OPEN_MODE, rowItem.getMode().ordinal()); + encryptIntent.putExtra(EncryptService.TAG_SOURCE, rowItem.generateBaseFile()); - final EncryptDecryptUtils.EncryptButtonCallbackInterface - encryptButtonCallbackInterfaceAuthenticate = - new EncryptDecryptUtils.EncryptButtonCallbackInterface() { - @Override - public void onButtonPressed(Intent intent, String password) - throws GeneralSecurityException, IOException { - EncryptDecryptUtils.startEncryption( - context, rowItem.generateBaseFile().getPath(), password, intent); - } - }; + final EncryptDecryptUtils.EncryptButtonCallbackInterface + encryptButtonCallbackInterfaceAuthenticate = + new EncryptDecryptUtils.EncryptButtonCallbackInterface() { + @Override + public void onButtonPressed(Intent intent, String password) + throws GeneralSecurityException, IOException { + EncryptDecryptUtils.startEncryption( + context, rowItem.generateBaseFile().getPath(), password, intent); + } + }; - final SharedPreferences preferences = - PreferenceManager.getDefaultSharedPreferences(context); + final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); - if (!preferences - .getString( - PreferencesConstants.PREFERENCE_CRYPT_MASTER_PASSWORD, - PreferencesConstants.PREFERENCE_CRYPT_MASTER_PASSWORD_DEFAULT) - .equals("")) { - EncryptWithPresetPasswordSaveAsDialog.show( - context, - encryptIntent, - mainActivity, - PreferencesConstants.ENCRYPT_PASSWORD_MASTER, - encryptButtonCallbackInterfaceAuthenticate); - } else if (preferences.getBoolean( - PreferencesConstants.PREFERENCE_CRYPT_FINGERPRINT, - PreferencesConstants.PREFERENCE_CRYPT_FINGERPRINT_DEFAULT)) { - EncryptWithPresetPasswordSaveAsDialog.show( - context, - encryptIntent, - mainActivity, - PreferencesConstants.ENCRYPT_PASSWORD_FINGERPRINT, - encryptButtonCallbackInterfaceAuthenticate); - } else { - EncryptAuthenticateDialog.show( - context, - encryptIntent, - mainActivity, - utilitiesProvider.getAppTheme(), - encryptButtonCallbackInterfaceAuthenticate); - } - return true; - case R.id.decrypt: - EncryptDecryptUtils.decryptFile( + if (!preferences + .getString( + PreferencesConstants.PREFERENCE_CRYPT_MASTER_PASSWORD, + PreferencesConstants.PREFERENCE_CRYPT_MASTER_PASSWORD_DEFAULT) + .equals("")) { + EncryptWithPresetPasswordSaveAsDialog.show( + context, + encryptIntent, + mainActivity, + PreferencesConstants.ENCRYPT_PASSWORD_MASTER, + encryptButtonCallbackInterfaceAuthenticate); + } else if (preferences.getBoolean( + PreferencesConstants.PREFERENCE_CRYPT_FINGERPRINT, + PreferencesConstants.PREFERENCE_CRYPT_FINGERPRINT_DEFAULT)) { + EncryptWithPresetPasswordSaveAsDialog.show( context, + encryptIntent, mainActivity, - mainFragment, - mainFragment.getMainFragmentViewModel().getOpenMode(), - rowItem.generateBaseFile(), - rowItem.generateBaseFile().getParent(context), - utilitiesProvider, - false); - return true; - case R.id.compress: - GeneralDialogCreation.showCompressDialog( + PreferencesConstants.ENCRYPT_PASSWORD_FINGERPRINT, + encryptButtonCallbackInterfaceAuthenticate); + } else { + EncryptAuthenticateDialog.show( + context, + encryptIntent, mainActivity, - rowItem.generateBaseFile(), - mainActivity.getCurrentMainFragment().getMainFragmentViewModel().getCurrentPath()); - return true; - case R.id.return_select: - mainFragment.returnIntentResults(new HybridFileParcelable[] {rowItem.generateBaseFile()}); - return true; + utilitiesProvider.getAppTheme(), + encryptButtonCallbackInterfaceAuthenticate); + } + return true; + } else if (item.getItemId() == R.id.decrypt) { + EncryptDecryptUtils.decryptFile( + context, + mainActivity, + mainFragment, + mainFragment.getMainFragmentViewModel().getOpenMode(), + rowItem.generateBaseFile(), + rowItem.generateBaseFile().getParent(context), + utilitiesProvider, + false); + return true; + } else if (item.getItemId() == R.id.compress) { + GeneralDialogCreation.showCompressDialog( + mainActivity, + rowItem.generateBaseFile(), + mainActivity.getCurrentMainFragment().getMainFragmentViewModel().getCurrentPath()); + return true; + } else if (item.getItemId() == R.id.return_select) { + mainFragment.returnIntentResults(new HybridFileParcelable[] {rowItem.generateBaseFile()}); + return true; } return false; } diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java index e74c7f46e9..7fb9bed221 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java @@ -55,6 +55,7 @@ import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.content.FileProvider; +import androidx.core.content.res.ResourcesCompat; import androidx.palette.graphics.Palette; /** Created by vishal on 27/7/16. */ @@ -116,7 +117,10 @@ public void onCreate(@Nullable Bundle savedInstanceState) { Toolbar mToolbar = findViewById(R.id.toolBar); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setHomeAsUpIndicator(getResources().getDrawable(R.drawable.md_nav_back)); + getSupportActionBar() + .setHomeAsUpIndicator( + ResourcesCompat.getDrawable( + getResources(), com.afollestad.materialdialogs.R.drawable.md_nav_back, getTheme())); getSupportActionBar().setDisplayShowTitleEnabled(false); switchIcons(); @@ -188,10 +192,8 @@ private CoordinatorLayout.LayoutParams calculateHeaderViewParams() { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - break; + if (item.getItemId() == android.R.id.home) { + onBackPressed(); } return super.onOptionsItemSelected(item); } @@ -208,100 +210,72 @@ private void switchIcons() { @Override public void onClick(View v) { - switch (v.getId()) { - case R.id.relative_layout_source: - openURL(URL_REPO, this); - break; - - case R.id.relative_layout_issues: - openURL(URL_REPO_ISSUES, this); - break; - - case R.id.relative_layout_share_logs: - try { - File logFile = - new File( - "/data/data/" + getApplicationContext().getPackageName() + "/cache/logs.txt"); - Uri logUri = - FileProvider.getUriForFile( - getApplicationContext(), getApplicationContext().getPackageName(), logFile); - ArrayList logUriList = new ArrayList<>(); - logUriList.add(logUri); - new ShareTask(this, logUriList, this.getAppTheme(), getAccent()).execute("*/*"); - } catch (Exception e) { - LOG.warn("failed to share logs", e); - } - break; - - case R.id.relative_layout_changelog: - openURL(URL_REPO_CHANGELOG, this); - break; - - case R.id.relative_layout_licenses: - LibsBuilder libsBuilder = - new LibsBuilder() - .withLibraries("apachemina") // Not auto-detected for some reason - .withActivityTitle(getString(R.string.libraries)) - .withAboutIconShown(true) - .withAboutVersionShownName(true) - .withAboutVersionShownCode(false) - .withAboutDescription(getString(R.string.about_amaze)) - .withAboutSpecial1(getString(R.string.license)) - .withAboutSpecial1Description(getString(R.string.amaze_license)) - .withLicenseShown(true); - - switch (getAppTheme()) { - case LIGHT: - libsBuilder.withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR); - break; - case DARK: - libsBuilder.withActivityStyle(Libs.ActivityStyle.DARK); - break; - case BLACK: - libsBuilder.withActivityTheme(R.style.AboutLibrariesTheme_Black); - break; - default: - LogHelper.logOnProductionOrCrash("Incorrect value for switch"); - } - - libsBuilder.start(this); - - break; - - case R.id.text_view_author_1_github: - openURL(URL_AUTHOR1_GITHUB, this); - break; - - case R.id.text_view_author_2_github: - openURL(URL_AUTHOR2_GITHUB, this); - break; - - case R.id.text_view_developer_1_github: - openURL(URL_DEVELOPER1_GITHUB, this); - break; - - case R.id.text_view_developer_2_github: - openURL(URL_DEVELOPER2_GITHUB, this); - break; - - case R.id.text_view_developer_3_github: - openURL(URL_DEVELOPER3_GITHUB, this); - break; - - case R.id.relative_layout_translate: - openURL(URL_REPO_TRANSLATE, this); - break; - - case R.id.relative_layout_xda: - openURL(URL_REPO_XDA, this); - break; + if (v.getId() == R.id.relative_layout_source) { + openURL(URL_REPO, this); + } else if (v.getId() == R.id.relative_layout_issues) { + openURL(URL_REPO_ISSUES, this); + } else if (v.getId() == R.id.relative_layout_share_logs) { + try { + File logFile = + new File("/data/data/" + getApplicationContext().getPackageName() + "/cache/logs.txt"); + Uri logUri = + FileProvider.getUriForFile( + getApplicationContext(), getApplicationContext().getPackageName(), logFile); + ArrayList logUriList = new ArrayList<>(); + logUriList.add(logUri); + new ShareTask(this, logUriList, this.getAppTheme(), getAccent()).execute("*/*"); + } catch (Exception e) { + LOG.warn("failed to share logs", e); + } + } else if (v.getId() == R.id.relative_layout_changelog) { + openURL(URL_REPO_CHANGELOG, this); + } else if (v.getId() == R.id.relative_layout_licenses) { + LibsBuilder libsBuilder = + new LibsBuilder() + .withLibraries("apachemina") // Not auto-detected for some reason + .withActivityTitle(getString(R.string.libraries)) + .withAboutIconShown(true) + .withAboutVersionShownName(true) + .withAboutVersionShownCode(false) + .withAboutDescription(getString(R.string.about_amaze)) + .withAboutSpecial1(getString(R.string.license)) + .withAboutSpecial1Description(getString(R.string.amaze_license)) + .withLicenseShown(true); + + switch (getAppTheme()) { + case LIGHT: + libsBuilder.withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR); + break; + case DARK: + libsBuilder.withActivityStyle(Libs.ActivityStyle.DARK); + break; + case BLACK: + libsBuilder.withActivityTheme(R.style.AboutLibrariesTheme_Black); + break; + default: + LogHelper.logOnProductionOrCrash("Incorrect value for switch"); + } - case R.id.relative_layout_rate: - openURL(URL_REPO_RATE, this); - break; - case R.id.relative_layout_donate: - billing = new Billing(this); - break; + libsBuilder.start(this); + + } else if (v.getId() == R.id.text_view_author_1_github) { + openURL(URL_AUTHOR1_GITHUB, this); + } else if (v.getId() == R.id.text_view_author_2_github) { + openURL(URL_AUTHOR2_GITHUB, this); + } else if (v.getId() == R.id.text_view_developer_1_github) { + openURL(URL_DEVELOPER1_GITHUB, this); + } else if (v.getId() == R.id.text_view_developer_2_github) { + openURL(URL_DEVELOPER2_GITHUB, this); + } else if (v.getId() == R.id.text_view_developer_3_github) { + openURL(URL_DEVELOPER3_GITHUB, this); + } else if (v.getId() == R.id.relative_layout_translate) { + openURL(URL_REPO_TRANSLATE, this); + } else if (v.getId() == R.id.relative_layout_xda) { + openURL(URL_REPO_XDA, this); + } else if (v.getId() == R.id.relative_layout_rate) { + openURL(URL_REPO_RATE, this); + } else if (v.getId() == R.id.relative_layout_donate) { + billing = new Billing(this); } } diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java index fe7dec1436..fac4f49dbd 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java @@ -1174,124 +1174,111 @@ public boolean onOptionsItemSelected(MenuItem item) { // Handle action buttons executeWithMainFragment( mainFragment -> { - switch (item.getItemId()) { - case R.id.home: - mainFragment.home(); - break; - case R.id.history: - HistoryDialog.showHistoryDialog(this, mainFragment); - break; - case R.id.sethome: - if (mainFragment.getMainFragmentViewModel().getOpenMode() != OpenMode.FILE - && mainFragment.getMainFragmentViewModel().getOpenMode() != OpenMode.ROOT) { - Toast.makeText(mainActivity, R.string.not_allowed, Toast.LENGTH_SHORT).show(); - break; - } - final MaterialDialog dialog = - GeneralDialogCreation.showBasicDialog( - mainActivity, - R.string.question_set_path_as_home, - R.string.set_as_home, - R.string.yes, - R.string.no); - dialog - .getActionButton(DialogAction.POSITIVE) - .setOnClickListener( - (v) -> { - mainFragment - .getMainFragmentViewModel() - .setHome(mainFragment.getCurrentPath()); - updatePaths(mainFragment.getMainFragmentViewModel().getNo()); - dialog.dismiss(); - }); - dialog.show(); - break; - case R.id.exit: - finish(); - break; - case R.id.sortby: - GeneralDialogCreation.showSortDialog(mainFragment, getAppTheme(), getPrefs()); - break; - case R.id.dsort: - String[] sort = getResources().getStringArray(R.array.directorysortmode); - MaterialDialog.Builder builder = new MaterialDialog.Builder(mainActivity); - builder.theme(getAppTheme().getMaterialDialogTheme()); - builder.title(R.string.directorysort); - int current = - Integer.parseInt( + if (item.getItemId() == R.id.home) { + mainFragment.home(); + } else if (item.getItemId() == R.id.history) { + HistoryDialog.showHistoryDialog(mainActivity, mainFragment); + } else if (item.getItemId() == R.id.sethome) { + if (mainFragment.getMainFragmentViewModel().getOpenMode() != OpenMode.FILE + && mainFragment.getMainFragmentViewModel().getOpenMode() != OpenMode.ROOT) { + Toast.makeText(mainActivity, R.string.not_allowed, Toast.LENGTH_SHORT).show(); + } + final MaterialDialog dialog = + GeneralDialogCreation.showBasicDialog( + mainActivity, + R.string.question_set_path_as_home, + R.string.set_as_home, + R.string.yes, + R.string.no); + dialog + .getActionButton(DialogAction.POSITIVE) + .setOnClickListener( + (v) -> { + mainFragment + .getMainFragmentViewModel() + .setHome(mainFragment.getCurrentPath()); + updatePaths(mainFragment.getMainFragmentViewModel().getNo()); + dialog.dismiss(); + }); + dialog.show(); + } else if (item.getItemId() == R.id.exit) { + finish(); + } else if (item.getItemId() == R.id.sortby) { + GeneralDialogCreation.showSortDialog(mainFragment, getAppTheme(), getPrefs()); + } else if (item.getItemId() == R.id.dsort) { + String[] sort = getResources().getStringArray(R.array.directorysortmode); + MaterialDialog.Builder builder = new MaterialDialog.Builder(mainActivity); + builder.theme(getAppTheme().getMaterialDialogTheme()); + builder.title(R.string.directorysort); + int current = + Integer.parseInt( + getPrefs().getString(PreferencesConstants.PREFERENCE_DIRECTORY_SORT_MODE, "0")); + + builder + .items(sort) + .itemsCallbackSingleChoice( + current, + (dialog1, view, which, text) -> { getPrefs() - .getString(PreferencesConstants.PREFERENCE_DIRECTORY_SORT_MODE, "0")); - - builder - .items(sort) - .itemsCallbackSingleChoice( - current, - (dialog1, view, which, text) -> { - getPrefs() - .edit() - .putString( - PreferencesConstants.PREFERENCE_DIRECTORY_SORT_MODE, "" + which) - .commit(); - mainFragment - .getMainFragmentViewModel() - .initSortModes( - SortHandler.getSortType( - this, mainFragment.getMainFragmentViewModel().getCurrentPath()), - getPrefs()); - mainFragment.updateList(false); - dialog1.dismiss(); - return true; - }); - builder.build().show(); - break; - case R.id.hiddenitems: - HiddenFilesDialog.showHiddenDialog(this, mainFragment); - break; - case R.id.view: - int pathLayout = - dataUtils.getListOrGridForPath(mainFragment.getCurrentPath(), DataUtils.LIST); - if (mainFragment.getMainFragmentViewModel().isList()) { - if (pathLayout == DataUtils.LIST) { - AppConfig.getInstance() - .runInBackground( - () -> { - utilsHandler.removeFromDatabase( - new OperationData( - UtilsHandler.Operation.LIST, mainFragment.getCurrentPath())); - }); - } - utilsHandler.saveToDatabase( - new OperationData(UtilsHandler.Operation.GRID, mainFragment.getCurrentPath())); + .edit() + .putString( + PreferencesConstants.PREFERENCE_DIRECTORY_SORT_MODE, "" + which) + .commit(); + mainFragment + .getMainFragmentViewModel() + .initSortModes( + SortHandler.getSortType( + this, mainFragment.getMainFragmentViewModel().getCurrentPath()), + getPrefs()); + mainFragment.updateList(false); + dialog1.dismiss(); + return true; + }); + builder.build().show(); + } else if (item.getItemId() == R.id.hiddenitems) { + HiddenFilesDialog.showHiddenDialog(mainActivity, mainFragment); + } else if (item.getItemId() == R.id.view) { + int pathLayout = + dataUtils.getListOrGridForPath(mainFragment.getCurrentPath(), DataUtils.LIST); + if (mainFragment.getMainFragmentViewModel().isList()) { + if (pathLayout == DataUtils.LIST) { + AppConfig.getInstance() + .runInBackground( + () -> { + utilsHandler.removeFromDatabase( + new OperationData( + UtilsHandler.Operation.LIST, mainFragment.getCurrentPath())); + }); + } + utilsHandler.saveToDatabase( + new OperationData(UtilsHandler.Operation.GRID, mainFragment.getCurrentPath())); - dataUtils.setPathAsGridOrList(mainFragment.getCurrentPath(), DataUtils.GRID); - } else { - if (pathLayout == DataUtils.GRID) { - AppConfig.getInstance() - .runInBackground( - () -> { - utilsHandler.removeFromDatabase( - new OperationData( - UtilsHandler.Operation.GRID, mainFragment.getCurrentPath())); - }); - } + dataUtils.setPathAsGridOrList(mainFragment.getCurrentPath(), DataUtils.GRID); + } else { + if (pathLayout == DataUtils.GRID) { + AppConfig.getInstance() + .runInBackground( + () -> { + utilsHandler.removeFromDatabase( + new OperationData( + UtilsHandler.Operation.GRID, mainFragment.getCurrentPath())); + }); + } - utilsHandler.saveToDatabase( - new OperationData(UtilsHandler.Operation.LIST, mainFragment.getCurrentPath())); + utilsHandler.saveToDatabase( + new OperationData(UtilsHandler.Operation.LIST, mainFragment.getCurrentPath())); - dataUtils.setPathAsGridOrList(mainFragment.getCurrentPath(), DataUtils.LIST); - } - mainFragment.switchView(); - break; - case R.id.extract: - Fragment fragment1 = getFragmentAtFrame(); - if (fragment1 instanceof CompressedExplorerFragment) { - mainActivityHelper.extractFile( - ((CompressedExplorerFragment) fragment1).compressedFile); - } - break; - case R.id.search: - getAppbar().getSearchView().revealSearchView(); - break; + dataUtils.setPathAsGridOrList(mainFragment.getCurrentPath(), DataUtils.LIST); + } + mainFragment.switchView(); + } else if (item.getItemId() == R.id.extract) { + Fragment fragment1 = getFragmentAtFrame(); + if (fragment1 instanceof CompressedExplorerFragment) { + mainActivityHelper.extractFile( + ((CompressedExplorerFragment) fragment1).compressedFile); + } + } else if (item.getItemId() == R.id.search) { + getAppbar().getSearchView().revealSearchView(); } return null; }, diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/texteditor/TextEditorActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/texteditor/TextEditorActivity.java index 97b518614e..35856612df 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/texteditor/TextEditorActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/texteditor/TextEditorActivity.java @@ -293,58 +293,51 @@ public boolean onOptionsItemSelected(MenuItem item) { new ViewModelProvider(this).get(TextEditorActivityViewModel.class); final EditableFileAbstraction editableFileAbstraction = viewModel.getFile(); - switch (item.getItemId()) { - case android.R.id.home: - checkUnsavedChanges(); - break; - case R.id.save: - // Make sure EditText is visible before saving! - if (mainTextView.getText() != null) { - saveFile(this, mainTextView.getText().toString()); - } - break; - case R.id.details: - if (editableFileAbstraction.scheme.equals(FILE) - && editableFileAbstraction.hybridFileParcelable.getFile() != null - && editableFileAbstraction.hybridFileParcelable.getFile().exists()) { - GeneralDialogCreation.showPropertiesDialogWithoutPermissions( - editableFileAbstraction.hybridFileParcelable, this, getAppTheme()); - } else if (editableFileAbstraction.scheme.equals(CONTENT)) { - if (getApplicationContext() - .getPackageName() - .equals(editableFileAbstraction.uri.getAuthority())) { - File file = FileUtils.fromContentUri(editableFileAbstraction.uri); - HybridFileParcelable p = new HybridFileParcelable(file.getAbsolutePath()); - if (isRootExplorer()) p.setMode(OpenMode.ROOT); - GeneralDialogCreation.showPropertiesDialogWithoutPermissions(p, this, getAppTheme()); - } - } else { - Toast.makeText(this, R.string.no_obtainable_info, Toast.LENGTH_SHORT).show(); + if (item.getItemId() == android.R.id.home) { + checkUnsavedChanges(); + } else if (item.getItemId() == R.id.save) { + // Make sure EditText is visible before saving! + if (mainTextView.getText() != null) { + saveFile(this, mainTextView.getText().toString()); + } + } else if (item.getItemId() == R.id.details) { + if (editableFileAbstraction.scheme.equals(FILE) + && editableFileAbstraction.hybridFileParcelable.getFile() != null + && editableFileAbstraction.hybridFileParcelable.getFile().exists()) { + GeneralDialogCreation.showPropertiesDialogWithoutPermissions( + editableFileAbstraction.hybridFileParcelable, this, getAppTheme()); + } else if (editableFileAbstraction.scheme.equals(CONTENT)) { + if (getApplicationContext() + .getPackageName() + .equals(editableFileAbstraction.uri.getAuthority())) { + File file = FileUtils.fromContentUri(editableFileAbstraction.uri); + HybridFileParcelable p = new HybridFileParcelable(file.getAbsolutePath()); + if (isRootExplorer()) p.setMode(OpenMode.ROOT); + GeneralDialogCreation.showPropertiesDialogWithoutPermissions(p, this, getAppTheme()); } - break; - case R.id.openwith: - if (editableFileAbstraction.scheme.equals(FILE)) { - File currentFile = editableFileAbstraction.hybridFileParcelable.getFile(); - if (currentFile != null && currentFile.exists()) { - boolean useNewStack = getBoolean(PREFERENCE_TEXTEDITOR_NEWSTACK); - FileUtils.openWith(currentFile, this, useNewStack); - } else { - Toast.makeText(this, R.string.not_allowed, Toast.LENGTH_SHORT).show(); - } + } else { + Toast.makeText(this, R.string.no_obtainable_info, Toast.LENGTH_SHORT).show(); + } + } else if (item.getItemId() == R.id.openwith) { + if (editableFileAbstraction != null && editableFileAbstraction.scheme.equals(FILE)) { + File currentFile = editableFileAbstraction.hybridFileParcelable.getFile(); + if (currentFile != null && currentFile.exists()) { + boolean useNewStack = getBoolean(PREFERENCE_TEXTEDITOR_NEWSTACK); + FileUtils.openWith(currentFile, this, useNewStack); } else { - Toast.makeText(this, R.string.reopen_from_source, Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.not_allowed, Toast.LENGTH_SHORT).show(); } - break; - case R.id.find: - if (searchViewLayout.isShown()) hideSearchView(); - else revealSearchView(); - break; - case R.id.monofont: - item.setChecked(!item.isChecked()); - mainTextView.setTypeface(item.isChecked() ? inputTypefaceMono : inputTypefaceDefault); - break; - default: - return false; + } else { + Toast.makeText(this, R.string.reopen_from_source, Toast.LENGTH_SHORT).show(); + } + } else if (item.getItemId() == R.id.find) { + if (searchViewLayout.isShown()) hideSearchView(); + else revealSearchView(); + } else if (item.getItemId() == R.id.monofont) { + item.setChecked(!item.isChecked()); + mainTextView.setTypeface(item.isChecked() ? inputTypefaceMono : inputTypefaceDefault); + } else { + return false; } return super.onOptionsItemSelected(item); } @@ -546,30 +539,27 @@ public void onClick(View v) { final TextEditorActivityViewModel viewModel = new ViewModelProvider(this).get(TextEditorActivityViewModel.class); - switch (v.getId()) { - case R.id.textEditorSearchPrevButton: - // upButton - if (viewModel.getCurrent() > 0) { - unhighlightCurrentSearchResult(viewModel); + if (v.getId() == R.id.textEditorSearchPrevButton) { + // upButton + if (viewModel.getCurrent() > 0) { + unhighlightCurrentSearchResult(viewModel); - // highlighting previous element in list - viewModel.setCurrent(viewModel.getCurrent() - 1); + // highlighting previous element in list + viewModel.setCurrent(viewModel.getCurrent() - 1); - highlightCurrentSearchResult(viewModel); - } - break; - case R.id.textEditorSearchNextButton: - // downButton - if (viewModel.getCurrent() < viewModel.getSearchResultIndices().size() - 1) { - unhighlightCurrentSearchResult(viewModel); + highlightCurrentSearchResult(viewModel); + } + } else if (v.getId() == R.id.textEditorSearchNextButton) { + // downButton + if (viewModel.getCurrent() < viewModel.getSearchResultIndices().size() - 1) { + unhighlightCurrentSearchResult(viewModel); - viewModel.setCurrent(viewModel.getCurrent() + 1); + viewModel.setCurrent(viewModel.getCurrent() + 1); - highlightCurrentSearchResult(viewModel); - } - break; - default: - throw new IllegalStateException(); + highlightCurrentSearchResult(viewModel); + } + } else { + throw new IllegalStateException(); } } diff --git a/app/src/main/java/com/amaze/filemanager/ui/fragments/AppsListFragment.java b/app/src/main/java/com/amaze/filemanager/ui/fragments/AppsListFragment.java index fd8355f064..f3e885d5fd 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/fragments/AppsListFragment.java +++ b/app/src/main/java/com/amaze/filemanager/ui/fragments/AppsListFragment.java @@ -142,20 +142,19 @@ public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflat @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { - switch (item.getItemId()) { - case R.id.sort: - showSortDialog(((MainActivity) requireActivity()).getAppTheme()); - return true; - case R.id.exit: - requireActivity().finish(); - return true; - case R.id.checkbox_system_apps: - item.setChecked(!item.isChecked()); - adapter.setData(appDataParcelableList, item.isChecked()); - showSystemApps = item.isChecked(); - return true; - default: - return super.onOptionsItemSelected(item); + if (item.getItemId() == R.id.sort) { + showSortDialog(((MainActivity) requireActivity()).getAppTheme()); + return true; + } else if (item.getItemId() == R.id.exit) { + requireActivity().finish(); + return true; + } else if (item.getItemId() == R.id.checkbox_system_apps) { + item.setChecked(!item.isChecked()); + adapter.setData(appDataParcelableList, item.isChecked()); + showSystemApps = item.isChecked(); + return true; + } else { + return super.onOptionsItemSelected(item); } } diff --git a/app/src/main/java/com/amaze/filemanager/ui/fragments/CloudSheetFragment.java b/app/src/main/java/com/amaze/filemanager/ui/fragments/CloudSheetFragment.java index 3a976e0f32..45d4e544b1 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/fragments/CloudSheetFragment.java +++ b/app/src/main/java/com/amaze/filemanager/ui/fragments/CloudSheetFragment.java @@ -155,45 +155,35 @@ public static final boolean isCloudProviderAvailable(Context context) { @Override public void onClick(View v) { - switch (v.getId()) { - case R.id.linear_layout_smb: - dismiss(); - SmbSearchDialog smbDialog = new SmbSearchDialog(); - smbDialog.show(getActivity().getSupportFragmentManager(), "tab"); - return; - case R.id.linear_layout_scp: - dismiss(); - SftpConnectDialog sftpConnectDialog = new SftpConnectDialog(); - Bundle args = new Bundle(); - args.putBoolean("edit", false); - sftpConnectDialog.setArguments(args); - sftpConnectDialog.show(getFragmentManager(), "tab"); - return; - case R.id.linear_layout_box: - ((MainActivity) getActivity()).addConnection(OpenMode.BOX); - break; - case R.id.linear_layout_dropbox: - ((MainActivity) getActivity()).addConnection(OpenMode.DROPBOX); - break; - case R.id.linear_layout_google_drive: - GeneralDialogCreation.showSignInWithGoogleDialog((MainActivity) getActivity()); - break; - case R.id.linear_layout_onedrive: - ((MainActivity) getActivity()).addConnection(OpenMode.ONEDRIVE); - break; - case R.id.linear_layout_get_cloud: - Intent cloudPluginIntent = new Intent(Intent.ACTION_VIEW); - cloudPluginIntent.setData(Uri.parse(getString(R.string.cloud_plugin_google_play_uri))); - try { - startActivity(cloudPluginIntent); - } catch (ActivityNotFoundException ifGooglePlayIsNotInstalled) { - cloudPluginIntent.setData( - Uri.parse(getString(R.string.cloud_plugin_google_play_web_uri))); - startActivity(cloudPluginIntent); - } - break; + if (v.getId() == R.id.linear_layout_smb) { + dismiss(); + SmbSearchDialog smbDialog = new SmbSearchDialog(); + smbDialog.show(requireActivity().getSupportFragmentManager(), "tab"); + } else if (v.getId() == R.id.linear_layout_scp) { + dismiss(); + SftpConnectDialog sftpConnectDialog = new SftpConnectDialog(); + Bundle args = new Bundle(); + args.putBoolean("edit", false); + sftpConnectDialog.setArguments(args); + sftpConnectDialog.show(getFragmentManager(), "tab"); + } else if (v.getId() == R.id.linear_layout_box) { + ((MainActivity) requireActivity()).addConnection(OpenMode.BOX); + } else if (v.getId() == R.id.linear_layout_dropbox) { + ((MainActivity) requireActivity()).addConnection(OpenMode.DROPBOX); + } else if (v.getId() == R.id.linear_layout_google_drive) { + GeneralDialogCreation.showSignInWithGoogleDialog((MainActivity) requireActivity()); + } else if (v.getId() == R.id.linear_layout_onedrive) { + ((MainActivity) getActivity()).addConnection(OpenMode.ONEDRIVE); + } else if (v.getId() == R.id.linear_layout_get_cloud) { + Intent cloudPluginIntent = new Intent(Intent.ACTION_VIEW); + cloudPluginIntent.setData(Uri.parse(getString(R.string.cloud_plugin_google_play_uri))); + try { + startActivity(cloudPluginIntent); + } catch (ActivityNotFoundException ifGooglePlayIsNotInstalled) { + cloudPluginIntent.setData(Uri.parse(getString(R.string.cloud_plugin_google_play_web_uri))); + startActivity(cloudPluginIntent); + } } - // dismiss this sheet dialog dismiss(); } diff --git a/app/src/main/java/com/amaze/filemanager/ui/views/FastScroller.java b/app/src/main/java/com/amaze/filemanager/ui/views/FastScroller.java index c3bd60b368..ea21ba0798 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/views/FastScroller.java +++ b/app/src/main/java/com/amaze/filemanager/ui/views/FastScroller.java @@ -111,7 +111,7 @@ private void setHandlePosition1(float relativePos) { private void setUpBarBackground() { InsetDrawable insetDrawable; - int resolveColor = resolveColor(getContext(), R.attr.colorControlNormal); + int resolveColor = resolveColor(getContext(), android.R.attr.colorControlNormal); insetDrawable = new InsetDrawable( new ColorDrawable(resolveColor), diff --git a/app/src/main/java/com/amaze/filemanager/ui/views/ScrimInsetsRelativeLayout.java b/app/src/main/java/com/amaze/filemanager/ui/views/ScrimInsetsRelativeLayout.java index 9ff35469aa..3dfaf415e3 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/views/ScrimInsetsRelativeLayout.java +++ b/app/src/main/java/com/amaze/filemanager/ui/views/ScrimInsetsRelativeLayout.java @@ -20,8 +20,6 @@ package com.amaze.filemanager.ui.views; -import com.amaze.filemanager.R; - import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; @@ -30,6 +28,7 @@ import android.util.AttributeSet; import android.widget.RelativeLayout; +import androidx.annotation.NonNull; import androidx.core.view.ViewCompat; /* @@ -60,13 +59,12 @@ public ScrimInsetsRelativeLayout(Context context, AttributeSet attrs, int defSty private void init(Context context, AttributeSet attrs, int defStyle) { final TypedArray a = - context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyle, 0); - if (a == null) { - return; - } - mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground); + context.obtainStyledAttributes( + attrs, com.google.android.material.R.styleable.ScrimInsetsFrameLayout, defStyle, 0); + mInsetForeground = + a.getDrawable( + com.google.android.material.R.styleable.ScrimInsetsFrameLayout_insetForeground); a.recycle(); - setWillNotDraw(true); } @@ -82,7 +80,7 @@ protected boolean fitSystemWindows(Rect insets) { } @Override - public void draw(Canvas canvas) { + public void draw(@NonNull Canvas canvas) { super.draw(canvas); int width = getWidth(); diff --git a/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java b/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java index 1397fcaee0..d82be932b3 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java +++ b/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java @@ -510,7 +510,9 @@ private void setSearchResultSortOrderIcon() { orderDrawable.setColorFilter( new PorterDuffColorFilter( - mainActivity.getResources().getColor(R.color.accent_material_light), + mainActivity + .getResources() + .getColor(com.google.android.material.R.color.accent_material_light), PorterDuff.Mode.SRC_ATOP)); searchResultsSortButton.setCompoundDrawablesWithIntrinsicBounds( null, null, orderDrawable, null); diff --git a/app/src/main/java/com/amaze/filemanager/utils/AnimUtils.kt b/app/src/main/java/com/amaze/filemanager/utils/AnimUtils.kt index 89f4356642..7ddc34d216 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/AnimUtils.kt +++ b/app/src/main/java/com/amaze/filemanager/utils/AnimUtils.kt @@ -24,7 +24,6 @@ import android.content.Context import android.os.Handler import android.view.animation.AnimationUtils import android.view.animation.Interpolator -import com.amaze.filemanager.R import com.amaze.filemanager.ui.views.ThemedTextView /** Utility methods for working with animations. */ @@ -35,7 +34,7 @@ object AnimUtils { fun getFastOutSlowInInterpolator(context: Context?): Interpolator? { if (fastOutSlowIn == null) { fastOutSlowIn = - AnimationUtils.loadInterpolator(context, R.interpolator.fast_out_slow_in) + AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_slow_in) } return fastOutSlowIn } diff --git a/app/src/main/java/com/amaze/filemanager/utils/Utils.java b/app/src/main/java/com/amaze/filemanager/utils/Utils.java index c7484391db..9d2f2419a0 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/Utils.java +++ b/app/src/main/java/com/amaze/filemanager/utils/Utils.java @@ -128,7 +128,8 @@ public static void setTint(Context context, AppCompatCheckBox box, int color) { } else { Drawable drawable = DrawableCompat.wrap( - ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material)); + ContextCompat.getDrawable( + box.getContext(), com.google.android.material.R.drawable.abc_btn_check_material)); DrawableCompat.setTintList(drawable, sl); box.setButtonDrawable(drawable); } diff --git a/app/src/test/java/com/amaze/filemanager/application/AppConfigTest.java b/app/src/test/java/com/amaze/filemanager/application/AppConfigTest.java index c700e29975..de57e3ea1b 100644 --- a/app/src/test/java/com/amaze/filemanager/application/AppConfigTest.java +++ b/app/src/test/java/com/amaze/filemanager/application/AppConfigTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.application; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static android.os.Looper.getMainLooper; import static org.awaitility.Awaitility.await; @@ -51,7 +51,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; @RunWith(AndroidJUnit4.class) -@Config(sdk = {KITKAT, P, Build.VERSION_CODES.R}) +@Config(sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class AppConfigTest { @After diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/AbstractDeleteTaskTestBase.kt b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/AbstractDeleteTaskTestBase.kt index be9335ad21..4b75a0d812 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/AbstractDeleteTaskTestBase.kt +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/AbstractDeleteTaskTestBase.kt @@ -23,7 +23,7 @@ package com.amaze.filemanager.asynchronous.asynctasks import android.Manifest import android.content.Context import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.os.Looper import android.os.storage.StorageManager @@ -68,7 +68,7 @@ import org.robolectric.shadows.ShadowToast ShadowTabHandler::class, ShadowPasswordUtil::class, ], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) abstract class AbstractDeleteTaskTestBase { private var ctx: Context? = null diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/DbViewerTaskTest.java b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/DbViewerTaskTest.java index 5546f904b0..343e16b743 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/DbViewerTaskTest.java +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/DbViewerTaskTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.asynchronous.asynctasks; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static android.os.Looper.getMainLooper; import static android.view.View.VISIBLE; @@ -58,7 +58,7 @@ @RunWith(AndroidJUnit4.class) @Config( shadows = {ShadowMultiDex.class}, - sdk = {KITKAT, P, Build.VERSION_CODES.R}) + sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class DbViewerTaskTest { private WebView webView; diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/compress/AbstractCompressedHelperCallableTest.kt b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/compress/AbstractCompressedHelperCallableTest.kt index 15d4575565..ca6c8959f5 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/compress/AbstractCompressedHelperCallableTest.kt +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/compress/AbstractCompressedHelperCallableTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.asynchronous.asynctasks.compress import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.os.Environment import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -37,7 +37,7 @@ import java.io.FileOutputStream import java.util.TimeZone @RunWith(AndroidJUnit4::class) -@Config(shadows = [ShadowMultiDex::class], sdk = [KITKAT, P, Build.VERSION_CODES.R]) +@Config(shadows = [ShadowMultiDex::class], sdk = [LOLLIPOP, P, Build.VERSION_CODES.R]) abstract class AbstractCompressedHelperCallableTest { private lateinit var systemTz: TimeZone diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/compress/CompressedHelperForBadArchiveTest.kt b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/compress/CompressedHelperForBadArchiveTest.kt index 3d69134c85..335f975c18 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/compress/CompressedHelperForBadArchiveTest.kt +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/compress/CompressedHelperForBadArchiveTest.kt @@ -20,7 +20,7 @@ package com.amaze.filemanager.asynchronous.asynctasks.compress -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.os.Environment import androidx.test.core.app.ApplicationProvider @@ -42,7 +42,7 @@ import java.io.FileOutputStream * Test behaviour of CompressedHelpers in handling corrupt archives. */ @RunWith(AndroidJUnit4::class) -@Config(shadows = [ShadowMultiDex::class], sdk = [KITKAT, P]) +@Config(shadows = [ShadowMultiDex::class], sdk = [LOLLIPOP, P]) class CompressedHelperForBadArchiveTest { /** * Test handling of corrupt archive with random junk. diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/searchfilesystem/SearchResultListSorterTest.kt b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/searchfilesystem/SearchResultListSorterTest.kt index 9b630d2465..097eeb34fd 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/searchfilesystem/SearchResultListSorterTest.kt +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/searchfilesystem/SearchResultListSorterTest.kt @@ -41,7 +41,7 @@ import java.util.regex.Pattern @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class], - sdk = [Build.VERSION_CODES.KITKAT, Build.VERSION_CODES.P, Build.VERSION_CODES.R], + sdk = [Build.VERSION_CODES.LOLLIPOP, Build.VERSION_CODES.P, Build.VERSION_CODES.R], ) @Suppress("StringLiteralDuplication", "ComplexMethod", "LongMethod", "LargeClass") class SearchResultListSorterTest { diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/ssh/PemToKeyPairObservableEd25519Test.kt b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/ssh/PemToKeyPairObservableEd25519Test.kt index 845ae38282..9547873544 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/ssh/PemToKeyPairObservableEd25519Test.kt +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/ssh/PemToKeyPairObservableEd25519Test.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.asynchronous.asynctasks.ssh import android.os.Build.VERSION_CODES -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.ext.junit.runners.AndroidJUnit4 import com.amaze.filemanager.shadows.ShadowMultiDex @@ -44,7 +44,7 @@ import org.robolectric.annotation.Config @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowTabHandler::class], - sdk = [KITKAT, P, VERSION_CODES.R], + sdk = [LOLLIPOP, P, VERSION_CODES.R], ) class PemToKeyPairObservableEd25519Test { companion object { diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/ssh/PemToKeyPairObservableRsaTest.kt b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/ssh/PemToKeyPairObservableRsaTest.kt index 84a21ab6b4..952cf3d2df 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/ssh/PemToKeyPairObservableRsaTest.kt +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/ssh/PemToKeyPairObservableRsaTest.kt @@ -22,7 +22,7 @@ package com.amaze.filemanager.asynchronous.asynctasks.ssh import android.os.Build.VERSION.SDK_INT import android.os.Build.VERSION_CODES -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.N import android.os.Build.VERSION_CODES.P import androidx.appcompat.widget.AppCompatEditText @@ -64,7 +64,7 @@ import java.util.concurrent.TimeUnit @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowTabHandler::class], - sdk = [KITKAT, P, VERSION_CODES.R], + sdk = [LOLLIPOP, P, VERSION_CODES.R], ) class PemToKeyPairObservableRsaTest { companion object { diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/ssh/SshAuthenticationTaskTest.kt b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/ssh/SshAuthenticationTaskTest.kt index eb2b972aa8..a176c0fdd6 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/ssh/SshAuthenticationTaskTest.kt +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/ssh/SshAuthenticationTaskTest.kt @@ -22,7 +22,7 @@ package com.amaze.filemanager.asynchronous.asynctasks.ssh import android.content.Context import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -66,7 +66,7 @@ import java.util.concurrent.CountDownLatch @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowPasswordUtil::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) @Suppress("StringLiteralDuplication") class SshAuthenticationTaskTest { diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/texteditor/read/ReadTextFileCallableTest.kt b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/texteditor/read/ReadTextFileCallableTest.kt index ba2f6e8aa5..f120e7f542 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/texteditor/read/ReadTextFileCallableTest.kt +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/texteditor/read/ReadTextFileCallableTest.kt @@ -23,7 +23,7 @@ package com.amaze.filemanager.asynchronous.asynctasks.texteditor.read import android.content.Context import android.net.Uri import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -46,7 +46,7 @@ import kotlin.random.Random @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) class ReadTextFileCallableTest { /** diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/texteditor/write/WriteTextFileCallableTest.java b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/texteditor/write/WriteTextFileCallableTest.java index 75fc954662..8fcc850e5d 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/texteditor/write/WriteTextFileCallableTest.java +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/asynctasks/texteditor/write/WriteTextFileCallableTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.asynchronous.asynctasks.texteditor.write; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -65,7 +65,7 @@ @RunWith(AndroidJUnit4.class) @Config( shadows = {ShadowMultiDex.class, ShadowContentResolver.class}, - sdk = {KITKAT, P, Build.VERSION_CODES.R}) + sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class WriteTextFileCallableTest { private static final String contents = "This is modified data"; diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/services/DecryptServiceTest.kt b/app/src/test/java/com/amaze/filemanager/asynchronous/services/DecryptServiceTest.kt index d4cfdc8c2b..eca0bf4fd4 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/services/DecryptServiceTest.kt +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/services/DecryptServiceTest.kt @@ -25,7 +25,7 @@ import android.content.Context import android.content.Intent import android.os.Build import android.os.Build.VERSION.SDK_INT -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.M import android.os.Build.VERSION_CODES.P import android.os.Environment @@ -64,7 +64,7 @@ import java.util.concurrent.TimeUnit import kotlin.random.Random @RunWith(AndroidJUnit4::class) -@Config(shadows = [ShadowMultiDex::class], sdk = [KITKAT, P, Build.VERSION_CODES.R]) +@Config(shadows = [ShadowMultiDex::class], sdk = [LOLLIPOP, P, Build.VERSION_CODES.R]) @Suppress("StringLiteralDuplication") class DecryptServiceTest { private lateinit var source: ByteArray diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/services/EncryptServiceTest.kt b/app/src/test/java/com/amaze/filemanager/asynchronous/services/EncryptServiceTest.kt index 2bac482d89..7443d72e6d 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/services/EncryptServiceTest.kt +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/services/EncryptServiceTest.kt @@ -25,7 +25,7 @@ import android.content.Context import android.content.Intent import android.os.Build import android.os.Build.VERSION.SDK_INT -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.M import android.os.Build.VERSION_CODES.P import android.os.Environment @@ -68,7 +68,7 @@ import java.util.concurrent.TimeUnit import kotlin.random.Random @RunWith(AndroidJUnit4::class) -@Config(shadows = [ShadowMultiDex::class], sdk = [KITKAT, P, Build.VERSION_CODES.R]) +@Config(shadows = [ShadowMultiDex::class], sdk = [LOLLIPOP, P, Build.VERSION_CODES.R]) class EncryptServiceTest { private lateinit var service: EncryptService private lateinit var notificationManager: ShadowNotificationManager diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/services/FtpServiceAndroidFileSystemIntegrationTest.kt b/app/src/test/java/com/amaze/filemanager/asynchronous/services/FtpServiceAndroidFileSystemIntegrationTest.kt index 4c212a026e..8a2fa1df4f 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/services/FtpServiceAndroidFileSystemIntegrationTest.kt +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/services/FtpServiceAndroidFileSystemIntegrationTest.kt @@ -26,7 +26,7 @@ import android.net.NetworkInfo import android.net.Uri import android.net.wifi.WifiInfo import android.net.wifi.WifiManager -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Environment import androidx.preference.PreferenceManager import androidx.test.core.app.ApplicationProvider @@ -62,7 +62,7 @@ import java.net.InetAddress import kotlin.random.Random @RunWith(AndroidJUnit4::class) -@Config(sdk = [KITKAT], shadows = [ShadowMultiDex::class]) +@Config(sdk = [LOLLIPOP], shadows = [ShadowMultiDex::class]) @LooperMode(LooperMode.Mode.PAUSED) @Suppress("StringLiteralDuplication") class FtpServiceAndroidFileSystemIntegrationTest { diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/services/ZipServiceTest.kt b/app/src/test/java/com/amaze/filemanager/asynchronous/services/ZipServiceTest.kt index 8650664d2b..9faa8029cf 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/services/ZipServiceTest.kt +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/services/ZipServiceTest.kt @@ -23,7 +23,7 @@ package com.amaze.filemanager.asynchronous.services import android.content.Context import android.content.Intent import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.os.Looper.getMainLooper import androidx.test.core.app.ApplicationProvider @@ -59,7 +59,7 @@ import kotlin.random.Random @RunWith(RobolectricTestRunner::class) @LooperMode(LooperMode.Mode.PAUSED) -@Config(shadows = [ShadowMultiDex::class], sdk = [KITKAT, P, Build.VERSION_CODES.R]) +@Config(shadows = [ShadowMultiDex::class], sdk = [LOLLIPOP, P, Build.VERSION_CODES.R]) class ZipServiceTest { val dt = DateTimeFormatter.ofPattern("yyyyMMddkkmm") val dates = diff --git a/app/src/test/java/com/amaze/filemanager/asynchronous/services/ftp/FtpReceiverTest.kt b/app/src/test/java/com/amaze/filemanager/asynchronous/services/ftp/FtpReceiverTest.kt index 7fe0fc513e..b08a421056 100644 --- a/app/src/test/java/com/amaze/filemanager/asynchronous/services/ftp/FtpReceiverTest.kt +++ b/app/src/test/java/com/amaze/filemanager/asynchronous/services/ftp/FtpReceiverTest.kt @@ -22,7 +22,7 @@ package com.amaze.filemanager.asynchronous.services.ftp import android.content.Intent import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.N import android.os.Build.VERSION_CODES.O import android.os.Build.VERSION_CODES.P @@ -44,7 +44,7 @@ import org.junit.runner.RunWith import org.robolectric.annotation.Config @RunWith(AndroidJUnit4::class) -@Config(shadows = [ShadowMultiDex::class], sdk = [KITKAT, P, Build.VERSION_CODES.R]) +@Config(shadows = [ShadowMultiDex::class], sdk = [LOLLIPOP, P, Build.VERSION_CODES.R]) @Suppress("StringLiteralDuplication") class FtpReceiverTest { private lateinit var receiver: FtpReceiver @@ -81,7 +81,7 @@ class FtpReceiverTest { * Test [Context.startService()] called for pre-Oreo Androids. */ @Test - @Config(minSdk = KITKAT, maxSdk = N) + @Config(sdk = [N]) fun testStartServiceCalled() { val ctx = AppConfig.getInstance() val spy = spyk(ctx) diff --git a/app/src/test/java/com/amaze/filemanager/database/ExplorerDatabaseMigrationTest.kt b/app/src/test/java/com/amaze/filemanager/database/ExplorerDatabaseMigrationTest.kt index f14726982f..69c1e48289 100644 --- a/app/src/test/java/com/amaze/filemanager/database/ExplorerDatabaseMigrationTest.kt +++ b/app/src/test/java/com/amaze/filemanager/database/ExplorerDatabaseMigrationTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.database import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.room.Room import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory @@ -44,7 +44,7 @@ import java.io.IOException @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowPasswordUtil::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) @Suppress("StringLiteralDuplication", "ComplexMethod", "LongMethod") class ExplorerDatabaseMigrationTest { diff --git a/app/src/test/java/com/amaze/filemanager/database/UtilitiesDatabaseMigrationTest.kt b/app/src/test/java/com/amaze/filemanager/database/UtilitiesDatabaseMigrationTest.kt index d8dce58635..f3167fcaf0 100644 --- a/app/src/test/java/com/amaze/filemanager/database/UtilitiesDatabaseMigrationTest.kt +++ b/app/src/test/java/com/amaze/filemanager/database/UtilitiesDatabaseMigrationTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.database import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.util.Base64 import androidx.room.Room @@ -52,7 +52,7 @@ import org.robolectric.annotation.Config @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowPasswordUtil::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) class UtilitiesDatabaseMigrationTest { companion object { diff --git a/app/src/test/java/com/amaze/filemanager/database/UtilsHandlerTest.kt b/app/src/test/java/com/amaze/filemanager/database/UtilsHandlerTest.kt index b3569d9177..7b8a5e433c 100644 --- a/app/src/test/java/com/amaze/filemanager/database/UtilsHandlerTest.kt +++ b/app/src/test/java/com/amaze/filemanager/database/UtilsHandlerTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.database import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.os.Environment import android.os.Environment.DIRECTORY_DCIM @@ -53,7 +53,7 @@ import java.io.File @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowPasswordUtil::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) class UtilsHandlerTest { companion object { diff --git a/app/src/test/java/com/amaze/filemanager/database/typeconverters/EncryptedStringTypeConverterTest.kt b/app/src/test/java/com/amaze/filemanager/database/typeconverters/EncryptedStringTypeConverterTest.kt index ac93635ea2..f5adf4c7bd 100644 --- a/app/src/test/java/com/amaze/filemanager/database/typeconverters/EncryptedStringTypeConverterTest.kt +++ b/app/src/test/java/com/amaze/filemanager/database/typeconverters/EncryptedStringTypeConverterTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.database.typeconverters import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.ext.junit.runners.AndroidJUnit4 import com.amaze.filemanager.database.models.StringWrapper @@ -38,7 +38,7 @@ import org.robolectric.annotation.Config @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowPasswordUtil::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) class EncryptedStringTypeConverterTest { /** diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/AbstractFilenameHelperIncrementNameTests.kt b/app/src/test/java/com/amaze/filemanager/filesystem/AbstractFilenameHelperIncrementNameTests.kt index 26dfb75e16..f306e23d7a 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/AbstractFilenameHelperIncrementNameTests.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/AbstractFilenameHelperIncrementNameTests.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.filesystem import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.ext.junit.runners.AndroidJUnit4 import com.amaze.filemanager.application.AppConfig @@ -42,7 +42,7 @@ import org.robolectric.annotation.Config @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) @Suppress("StringLiteralDuplication") abstract class AbstractFilenameHelperIncrementNameTests { diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/AbstractOperationsTestBase.kt b/app/src/test/java/com/amaze/filemanager/filesystem/AbstractOperationsTestBase.kt index 26ac58851b..b76c0d6434 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/AbstractOperationsTestBase.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/AbstractOperationsTestBase.kt @@ -23,7 +23,7 @@ package com.amaze.filemanager.filesystem import android.Manifest import android.content.Context import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.os.Looper import android.os.storage.StorageManager @@ -66,7 +66,7 @@ import org.robolectric.shadows.ShadowSQLiteConnection ShadowTabHandler::class, ShadowPasswordUtil::class, ], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) abstract class AbstractOperationsTestBase { private var ctx: Context? = null diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/EditableFileAbstractionTest.java b/app/src/test/java/com/amaze/filemanager/filesystem/EditableFileAbstractionTest.java index a7de457697..32897ee00e 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/EditableFileAbstractionTest.java +++ b/app/src/test/java/com/amaze/filemanager/filesystem/EditableFileAbstractionTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.filesystem; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static com.amaze.filemanager.filesystem.EditableFileAbstraction.Scheme.CONTENT; import static com.amaze.filemanager.filesystem.EditableFileAbstraction.Scheme.FILE; @@ -49,7 +49,7 @@ @RunWith(AndroidJUnit4.class) @Config( shadows = {ShadowMultiDex.class}, - sdk = {KITKAT, P, Build.VERSION_CODES.R}) + sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class EditableFileAbstractionTest { @Test(expected = IllegalArgumentException.class) diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/HybridFileTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/HybridFileTest.kt index 2c29b3fb08..7d1f6267b0 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/HybridFileTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/HybridFileTest.kt @@ -23,7 +23,7 @@ package com.amaze.filemanager.filesystem import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.os.Environment import androidx.test.core.app.ApplicationProvider @@ -40,7 +40,7 @@ import java.net.URLDecoder import kotlin.random.Random @RunWith(AndroidJUnit4::class) -@Config(shadows = [ShadowMultiDex::class], sdk = [KITKAT, P, Build.VERSION_CODES.R]) +@Config(shadows = [ShadowMultiDex::class], sdk = [LOLLIPOP, P, Build.VERSION_CODES.R]) @Suppress("StringLiteralDuplication") class HybridFileTest { /** diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/OperationsTest.java b/app/src/test/java/com/amaze/filemanager/filesystem/OperationsTest.java index c0868b7061..329e3107e3 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/OperationsTest.java +++ b/app/src/test/java/com/amaze/filemanager/filesystem/OperationsTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.filesystem; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -45,7 +45,7 @@ @RunWith(AndroidJUnit4.class) @Config( shadows = {ShadowMultiDex.class}, - sdk = {KITKAT, P, Build.VERSION_CODES.R}) + sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class OperationsTest { private File storageRoot = Environment.getExternalStorageDirectory(); diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/RootHelperTest.java b/app/src/test/java/com/amaze/filemanager/filesystem/RootHelperTest.java index a5ca73548f..f3004396db 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/RootHelperTest.java +++ b/app/src/test/java/com/amaze/filemanager/filesystem/RootHelperTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.filesystem; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static org.junit.Assert.fail; @@ -51,7 +51,7 @@ @RunWith(AndroidJUnit4.class) @Config( shadows = {ShadowMultiDex.class}, - sdk = {KITKAT, P, Build.VERSION_CODES.R}) + sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) @Ignore("FIXME: should not ignore - please implement a shadow") public class RootHelperTest { diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/compressed/B0rkenZipTest.java b/app/src/test/java/com/amaze/filemanager/filesystem/compressed/B0rkenZipTest.java index ee5e9c6b05..1047900c01 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/compressed/B0rkenZipTest.java +++ b/app/src/test/java/com/amaze/filemanager/filesystem/compressed/B0rkenZipTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.filesystem.compressed; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static kotlin.io.ConstantsKt.DEFAULT_BUFFER_SIZE; import static org.junit.Assert.assertEquals; @@ -56,7 +56,7 @@ @RunWith(AndroidJUnit4.class) @Config( shadows = {ShadowMultiDex.class}, - sdk = {KITKAT, P, Build.VERSION_CODES.R}) + sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class B0rkenZipTest { private File zipfile1 = new File(Environment.getExternalStorageDirectory(), "zip-slip.zip"); diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/compressed/CompressedHelperTest.java b/app/src/test/java/com/amaze/filemanager/filesystem/compressed/CompressedHelperTest.java index e011837730..8208508b35 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/compressed/CompressedHelperTest.java +++ b/app/src/test/java/com/amaze/filemanager/filesystem/compressed/CompressedHelperTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.filesystem.compressed; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -66,7 +66,7 @@ @RunWith(AndroidJUnit4.class) @Config( shadows = {ShadowMultiDex.class}, - sdk = {KITKAT, P, Build.VERSION_CODES.R}) + sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class CompressedHelperTest { private Context context; diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/compressed/extractcontents/AbstractExtractorTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/compressed/extractcontents/AbstractExtractorTest.kt index 59aa3bdd24..8e2e8e1c45 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/compressed/extractcontents/AbstractExtractorTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/compressed/extractcontents/AbstractExtractorTest.kt @@ -22,7 +22,7 @@ package com.amaze.filemanager.filesystem.compressed.extractcontents import android.content.Context import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.os.Environment import androidx.test.core.app.ApplicationProvider @@ -50,7 +50,7 @@ import java.nio.file.Paths import java.util.TimeZone @RunWith(AndroidJUnit4::class) -@Config(shadows = [ShadowMultiDex::class], sdk = [KITKAT, P, Build.VERSION_CODES.R]) +@Config(shadows = [ShadowMultiDex::class], sdk = [LOLLIPOP, P, Build.VERSION_CODES.R]) abstract class AbstractExtractorTest { protected abstract fun extractorClass(): Class diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/files/FileListSorterTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/files/FileListSorterTest.kt index cf77873108..e2890ed677 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/files/FileListSorterTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/files/FileListSorterTest.kt @@ -43,7 +43,7 @@ import org.robolectric.annotation.Config @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class], - sdk = [Build.VERSION_CODES.KITKAT, Build.VERSION_CODES.P, Build.VERSION_CODES.R], + sdk = [Build.VERSION_CODES.LOLLIPOP, Build.VERSION_CODES.P, Build.VERSION_CODES.R], ) @Suppress("StringLiteralDuplication", "ComplexMethod", "LongMethod", "LargeClass") class FileListSorterTest { diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/files/FileUtilsTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/files/FileUtilsTest.kt index cd8a1dde92..a75c54e152 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/files/FileUtilsTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/files/FileUtilsTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.filesystem.files import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.ext.junit.runners.AndroidJUnit4 import com.amaze.filemanager.filesystem.files.FileUtils.getPathsInPath @@ -38,7 +38,7 @@ import java.util.TimeZone @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) -@Config(sdk = [KITKAT, P, Build.VERSION_CODES.R]) +@Config(sdk = [LOLLIPOP, P, Build.VERSION_CODES.R]) @Suppress("TooManyFunctions", "StringLiteralDuplication") class FileUtilsTest { /** diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/files/sort/DirSortByTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/files/sort/DirSortByTest.kt index 188618514d..fb00c32fdb 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/files/sort/DirSortByTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/files/sort/DirSortByTest.kt @@ -32,7 +32,7 @@ import kotlin.random.Random @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class], - sdk = [Build.VERSION_CODES.KITKAT, Build.VERSION_CODES.P, Build.VERSION_CODES.R], + sdk = [Build.VERSION_CODES.LOLLIPOP, Build.VERSION_CODES.P, Build.VERSION_CODES.R], ) class DirSortByTest { /** Tests if [DirSortBy.getDirSortBy] returns the correct [DirSortBy] corresponding to the given index */ diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/files/sort/SortByTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/files/sort/SortByTest.kt index 673dfe2d39..a851d96afb 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/files/sort/SortByTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/files/sort/SortByTest.kt @@ -32,7 +32,7 @@ import kotlin.random.Random @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class], - sdk = [Build.VERSION_CODES.KITKAT, Build.VERSION_CODES.P, Build.VERSION_CODES.R], + sdk = [Build.VERSION_CODES.LOLLIPOP, Build.VERSION_CODES.P, Build.VERSION_CODES.R], ) class SortByTest { /** Tests if [SortBy.getSortBy] returns the correct [SortBy] corresponding to the given index */ diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/files/sort/SortTypeTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/files/sort/SortTypeTest.kt index 204dab7dd5..ee9bae2172 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/files/sort/SortTypeTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/files/sort/SortTypeTest.kt @@ -31,7 +31,7 @@ import org.robolectric.annotation.Config @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class], - sdk = [Build.VERSION_CODES.KITKAT, Build.VERSION_CODES.P, Build.VERSION_CODES.R], + sdk = [Build.VERSION_CODES.LOLLIPOP, Build.VERSION_CODES.P, Build.VERSION_CODES.R], ) class SortTypeTest { /** Tests if the Int returned from [SortType.toDirectorySortInt] is as expected */ diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/ftp/FtpsHybridFileTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/ftp/FtpsHybridFileTest.kt index a67f46b6b1..046a81cacf 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/ftp/FtpsHybridFileTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/ftp/FtpsHybridFileTest.kt @@ -33,9 +33,10 @@ import org.apache.ftpserver.ssl.impl.DefaultSslConfiguration import org.json.JSONObject import org.junit.Ignore import java.security.KeyStore +import java.security.cert.CertificateFactory +import java.security.cert.X509Certificate import javax.net.ssl.KeyManagerFactory import javax.net.ssl.TrustManagerFactory -import javax.security.cert.X509Certificate @Ignore open class FtpsHybridFileTest : FtpHybridFileTest() { @@ -62,7 +63,11 @@ open class FtpsHybridFileTest : FtpHybridFileTest() { certInfo = JSONObject( X509CertificateUtil.parse( - X509Certificate.getInstance(keyStore.getCertificate("ftpserver").encoded), + CertificateFactory.getInstance( + "X.509", + ).generateCertificate( + keyStore.getCertificate("ftpserver").encoded.inputStream(), + ) as X509Certificate, ), ) super.setUp() diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/ftp/NetCopyClientConnectionPoolFtpTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/ftp/NetCopyClientConnectionPoolFtpTest.kt index 356c6f2154..35d51316ac 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/ftp/NetCopyClientConnectionPoolFtpTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/ftp/NetCopyClientConnectionPoolFtpTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.filesystem.ftp import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.ext.junit.runners.AndroidJUnit4 import com.amaze.filemanager.application.AppConfig @@ -64,7 +64,7 @@ import kotlin.text.Charsets.UTF_8 @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowPasswordUtil::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) class NetCopyClientConnectionPoolFtpTest { /** diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/ftpserver/commands/AbstractFtpserverCommandTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/ftpserver/commands/AbstractFtpserverCommandTest.kt index 89d884bf66..6aed30ecb4 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/ftpserver/commands/AbstractFtpserverCommandTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/ftpserver/commands/AbstractFtpserverCommandTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.filesystem.ftpserver.commands import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.ext.junit.runners.AndroidJUnit4 import com.amaze.filemanager.shadows.ShadowMultiDex @@ -38,7 +38,7 @@ import org.robolectric.annotation.Config @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) abstract class AbstractFtpserverCommandTest { protected lateinit var logger: LogMessageFilter diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/root/ListFilesCommandTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/root/ListFilesCommandTest.kt index 2df3522804..b00c868784 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/root/ListFilesCommandTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/root/ListFilesCommandTest.kt @@ -22,7 +22,7 @@ package com.amaze.filemanager.filesystem.root import android.content.SharedPreferences import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.preference.PreferenceManager import androidx.test.core.app.ApplicationProvider @@ -54,7 +54,7 @@ import java.io.InputStreamReader @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowNativeOperations::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) class ListFilesCommandTest { private val sharedPreferences: SharedPreferences = diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/root/ListFilesCommandTest2.kt b/app/src/test/java/com/amaze/filemanager/filesystem/root/ListFilesCommandTest2.kt index a7d32e2485..6b828df226 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/root/ListFilesCommandTest2.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/root/ListFilesCommandTest2.kt @@ -22,29 +22,24 @@ package com.amaze.filemanager.filesystem.root import android.content.SharedPreferences import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.preference.PreferenceManager import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import com.amaze.filemanager.exceptions.ShellCommandInvalidException -import com.amaze.filemanager.fileoperations.filesystem.OpenMode -import com.amaze.filemanager.filesystem.HybridFileParcelable import com.amaze.filemanager.shadows.ShadowMultiDex import com.amaze.filemanager.test.ShadowNativeOperations -import com.amaze.filemanager.test.TestUtils import com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants import com.topjohnwu.superuser.Shell +import io.mockk.every +import io.mockk.mockkObject +import io.mockk.unmockkObject import org.junit.After import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.mockito.ArgumentMatchers.anyBoolean -import org.mockito.ArgumentMatchers.anyString -import org.mockito.Mockito.mock -import org.mockito.Mockito.`when` -import org.mockito.kotlin.argumentCaptor import org.robolectric.annotation.Config import java.io.InputStreamReader @@ -59,12 +54,12 @@ import java.io.InputStreamReader @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowNativeOperations::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) class ListFilesCommandTest2 { - val sharedPreferences: SharedPreferences = + private val sharedPreferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext()) - val lsLines = + private val lsLines = InputStreamReader(javaClass.getResourceAsStream("/rootCommands/ls-bin.txt")) .readLines() @@ -73,39 +68,27 @@ class ListFilesCommandTest2 { */ @Before fun setUp() { - val mockCommand = mock(ListFilesCommand.javaClass) - `when`( - mockCommand.listFiles( - anyString(), - anyBoolean(), - anyBoolean(), - argumentCaptor<(OpenMode) -> Unit>().capture(), - argumentCaptor<(HybridFileParcelable) -> Unit>().capture(), - ), - ).thenCallRealMethod() - `when`( - mockCommand.executeRootCommand( - anyString(), - anyBoolean(), - anyBoolean(), - ), - ).thenCallRealMethod() - `when`(mockCommand.runShellCommand("pwd")).thenReturn( + mockkObject(ListFilesCommand) + every { + ListFilesCommand.listFiles(any(), any(), any(), any(), any()) + } answers { callOriginal() } + every { + ListFilesCommand.executeRootCommand(any(), any(), any()) + } answers { callOriginal() } + every { ListFilesCommand.runShellCommand("pwd") } returns object : Shell.Result() { override fun getOut(): MutableList = listOf("/").toMutableList() override fun getErr(): MutableList = emptyList().toMutableList() override fun getCode(): Int = 0 - }, - ) - `when`(mockCommand.runShellCommandToList("ls -l \"/bin\"")).thenReturn(lsLines) - `when`( - mockCommand.runShellCommandToList( + } + every { ListFilesCommand.runShellCommandToList("ls -l \"/bin\"") } returns lsLines + every { + ListFilesCommand.runShellCommandToList( "stat -c '%A %h %G %U %B %Y %N' /bin/*", - ), - ).thenThrow(ShellCommandInvalidException("Intentional exception")) - TestUtils.replaceObjectInstance(ListFilesCommand.javaClass, mockCommand) + ) + } throws ShellCommandInvalidException("Intentional exception") } /** @@ -113,7 +96,7 @@ class ListFilesCommandTest2 { */ @After fun tearDown() { - TestUtils.replaceObjectInstance(ListFilesCommand.javaClass, null) + unmockkObject(ListFilesCommand) } /** diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/smb/CifsContextsTest.java b/app/src/test/java/com/amaze/filemanager/filesystem/smb/CifsContextsTest.java index 7c118cf953..bb83e42eb4 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/smb/CifsContextsTest.java +++ b/app/src/test/java/com/amaze/filemanager/filesystem/smb/CifsContextsTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.filesystem.smb; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -44,7 +44,7 @@ import jcifs.ResolverType; import jcifs.context.BaseContext; -@Config(sdk = {KITKAT, P, Build.VERSION_CODES.R}) +@Config(sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) @RunWith(AndroidJUnit4.class) public class CifsContextsTest { diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/smb/SmbHybridFileTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/smb/SmbHybridFileTest.kt index c67581ff68..e6995e4ef4 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/smb/SmbHybridFileTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/smb/SmbHybridFileTest.kt @@ -22,7 +22,7 @@ package com.amaze.filemanager.filesystem.smb import android.content.Context import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -45,7 +45,7 @@ import org.robolectric.shadows.ShadowSQLiteConnection @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowSmbUtil::class, ShadowMultiDex::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) @LooperMode(LooperMode.Mode.PAUSED) class SmbHybridFileTest { diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/ssh/AbstractSftpServerTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/ssh/AbstractSftpServerTest.kt index a7cab8f40d..a7cce7c3f1 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/ssh/AbstractSftpServerTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/ssh/AbstractSftpServerTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.filesystem.ssh import android.os.Build.VERSION_CODES -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.os.Environment import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -65,7 +65,7 @@ import kotlin.text.Charsets.UTF_8 @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowPasswordUtil::class], - sdk = [KITKAT, P, VERSION_CODES.R], + sdk = [LOLLIPOP, P, VERSION_CODES.R], ) abstract class AbstractSftpServerTest { protected var encryptedPassword: String? = diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/ssh/NetCopyClientConnectionPoolSshTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/ssh/NetCopyClientConnectionPoolSshTest.kt index b3d6e9d07b..27b8e5c406 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/ssh/NetCopyClientConnectionPoolSshTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/ssh/NetCopyClientConnectionPoolSshTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.filesystem.ssh import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.ext.junit.runners.AndroidJUnit4 import com.amaze.filemanager.application.AppConfig @@ -75,7 +75,7 @@ import kotlin.text.Charsets.UTF_8 @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowPasswordUtil::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) class NetCopyClientConnectionPoolSshTest { /** diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/ssh/SshHybridFileTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/ssh/SshHybridFileTest.kt index 9957eae5dd..5c10d396a8 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/ssh/SshHybridFileTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/ssh/SshHybridFileTest.kt @@ -22,7 +22,7 @@ package com.amaze.filemanager.filesystem.ssh import android.content.Context import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -46,7 +46,7 @@ import org.robolectric.annotation.LooperMode @LooperMode(LooperMode.Mode.PAUSED) @Config( shadows = [ShadowMultiDex::class, ShadowPasswordUtil::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) class SshHybridFileTest { private var ctx: Context? = null diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/usb/ReflectionHelpers.java b/app/src/test/java/com/amaze/filemanager/filesystem/usb/ReflectionHelpers.java index 49253194dc..f6d8a958b5 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/usb/ReflectionHelpers.java +++ b/app/src/test/java/com/amaze/filemanager/filesystem/usb/ReflectionHelpers.java @@ -43,7 +43,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.annotation.RequiresApi; +import androidx.test.filters.SdkSuppress; class ReflectionHelpers { @@ -77,7 +77,7 @@ static void addUsbOtgDevice(Activity activity) { ShadowEnvironment.setExternalStorageState(storageDir1, Environment.MEDIA_MOUNTED); } - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + @SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP) static void configureUsbDevice(UsbDevice device) throws NoSuchMethodException, ClassNotFoundException, @@ -92,7 +92,7 @@ static void configureUsbDevice(UsbDevice device) configureMethod.invoke(device, (Object) new Parcelable[] {usbConfiguration}); } - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + @SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP) static void configureUsbConfiguration(UsbConfiguration usbConfiguration) throws NoSuchMethodException, ClassNotFoundException, @@ -107,7 +107,7 @@ static void configureUsbConfiguration(UsbConfiguration usbConfiguration) configureMethod.invoke(usbConfiguration, (Object) new Parcelable[] {usbInterface}); } - @RequiresApi(Build.VERSION_CODES.KITKAT) + @SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP) static Parcelable[] configureUsbDevice() throws ClassNotFoundException, NoSuchMethodException, @@ -120,7 +120,7 @@ static Parcelable[] configureUsbDevice() return new Parcelable[] {usbInterface}; } - @RequiresApi(Build.VERSION_CODES.M) + @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) static UsbDevice callUsbDeviceConstructor( @NonNull String name, int vendorId, @@ -165,7 +165,7 @@ static UsbDevice callUsbDeviceConstructor( serialNumber); } - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + @SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP) static UsbDevice callUsbDeviceConstructor( @NonNull String name, int vendorId, @@ -207,7 +207,7 @@ static UsbDevice callUsbDeviceConstructor( serialNumber); } - @RequiresApi(Build.VERSION_CODES.KITKAT) + @SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP) static UsbDevice callUsbDeviceConstructor( @NonNull String name, int vendorId, @@ -237,7 +237,7 @@ static UsbDevice callUsbDeviceConstructor( name, vendorId, productId, usbClass, subClass, protocol, interfaces); } - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + @SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP) static UsbConfiguration callUsbConfigurationConstructor( int id, @Nullable String name, int attributes, int maxPower) throws ClassNotFoundException, @@ -254,7 +254,7 @@ static UsbConfiguration callUsbConfigurationConstructor( return constructor.newInstance(id, name, attributes, maxPower); } - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + @SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP) static UsbInterface callUsbInterfaceConstructor( int id, int alternateSetting, @Nullable String name, int usbClass, int subClass, int protocol) throws ClassNotFoundException, @@ -271,7 +271,7 @@ static UsbInterface callUsbInterfaceConstructor( return constructor.newInstance(id, alternateSetting, name, usbClass, subClass, protocol); } - @RequiresApi(Build.VERSION_CODES.KITKAT) + @SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP) static UsbInterface callUsbInterfaceConstructor( int id, int usbClass, int subClass, int protocol, @Nullable Parcelable[] endpoints) throws ClassNotFoundException, diff --git a/app/src/test/java/com/amaze/filemanager/ui/activities/AbstractMainActivityTestBase.kt b/app/src/test/java/com/amaze/filemanager/ui/activities/AbstractMainActivityTestBase.kt index bba0121b90..307828c771 100644 --- a/app/src/test/java/com/amaze/filemanager/ui/activities/AbstractMainActivityTestBase.kt +++ b/app/src/test/java/com/amaze/filemanager/ui/activities/AbstractMainActivityTestBase.kt @@ -24,7 +24,7 @@ import android.Manifest import android.content.Context import android.os.Build import android.os.Build.VERSION_CODES -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.os.storage.StorageManager import androidx.annotation.NonNull @@ -54,7 +54,7 @@ import org.robolectric.shadows.ShadowStorageManager */ @RunWith(AndroidJUnit4::class) @Config( - sdk = [KITKAT, P, VERSION_CODES.R], + sdk = [LOLLIPOP, P, VERSION_CODES.R], shadows = [ ShadowMultiDex::class, ShadowStorageManager::class, diff --git a/app/src/test/java/com/amaze/filemanager/ui/activities/PermissionsActivityTest.kt b/app/src/test/java/com/amaze/filemanager/ui/activities/PermissionsActivityTest.kt index 7fe654ea58..548d0b2bf4 100644 --- a/app/src/test/java/com/amaze/filemanager/ui/activities/PermissionsActivityTest.kt +++ b/app/src/test/java/com/amaze/filemanager/ui/activities/PermissionsActivityTest.kt @@ -24,7 +24,7 @@ import android.app.AppOpsManager import android.content.Context import android.net.Uri import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.os.Build.VERSION_CODES.R import android.os.storage.StorageManager @@ -62,7 +62,7 @@ import org.robolectric.shadows.ShadowStorageManager */ @RunWith(AndroidJUnit4::class) @Config( - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], shadows = [ShadowMultiDex::class, ShadowStorageManager::class], ) class PermissionsActivityTest { diff --git a/app/src/test/java/com/amaze/filemanager/ui/activities/TextEditorActivityTest.java b/app/src/test/java/com/amaze/filemanager/ui/activities/TextEditorActivityTest.java index af5b150df3..c65a67166c 100644 --- a/app/src/test/java/com/amaze/filemanager/ui/activities/TextEditorActivityTest.java +++ b/app/src/test/java/com/amaze/filemanager/ui/activities/TextEditorActivityTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.ui.activities; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -58,7 +58,7 @@ @RunWith(AndroidJUnit4.class) @Config( shadows = {ShadowMultiDex.class}, - sdk = {KITKAT, P, Build.VERSION_CODES.R}) + sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class TextEditorActivityTest { private final String fileContents = "fsdfsdfs"; diff --git a/app/src/test/java/com/amaze/filemanager/ui/dialogs/AbstractEncryptDialogTests.kt b/app/src/test/java/com/amaze/filemanager/ui/dialogs/AbstractEncryptDialogTests.kt index 5fd8606f4b..f78ff3a5d5 100644 --- a/app/src/test/java/com/amaze/filemanager/ui/dialogs/AbstractEncryptDialogTests.kt +++ b/app/src/test/java/com/amaze/filemanager/ui/dialogs/AbstractEncryptDialogTests.kt @@ -23,7 +23,7 @@ package com.amaze.filemanager.ui.dialogs import android.Manifest import android.os.Build import android.os.Build.VERSION.SDK_INT -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.N import android.os.Build.VERSION_CODES.P import androidx.annotation.RequiresApi @@ -47,7 +47,7 @@ import org.robolectric.annotation.Config @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowTabHandler::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) abstract class AbstractEncryptDialogTests { protected lateinit var scenario: ActivityScenario diff --git a/app/src/test/java/com/amaze/filemanager/ui/dialogs/ColorPickerDialogTest.kt b/app/src/test/java/com/amaze/filemanager/ui/dialogs/ColorPickerDialogTest.kt index 08f0cb2798..e7fa4329f3 100644 --- a/app/src/test/java/com/amaze/filemanager/ui/dialogs/ColorPickerDialogTest.kt +++ b/app/src/test/java/com/amaze/filemanager/ui/dialogs/ColorPickerDialogTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.ui.dialogs import android.os.Build.VERSION_CODES -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.ext.junit.runners.AndroidJUnit4 import com.amaze.filemanager.application.AppConfig @@ -41,7 +41,7 @@ import org.robolectric.annotation.Config @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class, ShadowTabHandler::class], - sdk = [KITKAT, P, VERSION_CODES.R], + sdk = [LOLLIPOP, P, VERSION_CODES.R], ) class ColorPickerDialogTest { /** diff --git a/app/src/test/java/com/amaze/filemanager/ui/fragments/CloudSheetFragmentTest.java b/app/src/test/java/com/amaze/filemanager/ui/fragments/CloudSheetFragmentTest.java index e719ba8c60..28ca6edcb3 100644 --- a/app/src/test/java/com/amaze/filemanager/ui/fragments/CloudSheetFragmentTest.java +++ b/app/src/test/java/com/amaze/filemanager/ui/fragments/CloudSheetFragmentTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.ui.fragments; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -39,7 +39,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; @RunWith(AndroidJUnit4.class) -@Config(sdk = {KITKAT, P, Build.VERSION_CODES.R}) +@Config(sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class CloudSheetFragmentTest { @Test diff --git a/app/src/test/java/com/amaze/filemanager/ui/fragments/preferencefragments/UiPrefsFragmentTest.kt b/app/src/test/java/com/amaze/filemanager/ui/fragments/preferencefragments/UiPrefsFragmentTest.kt index 03ad5817b1..277aaccb33 100644 --- a/app/src/test/java/com/amaze/filemanager/ui/fragments/preferencefragments/UiPrefsFragmentTest.kt +++ b/app/src/test/java/com/amaze/filemanager/ui/fragments/preferencefragments/UiPrefsFragmentTest.kt @@ -52,7 +52,7 @@ import kotlin.random.Random */ @Config( sdk = [ - Build.VERSION_CODES.KITKAT, + Build.VERSION_CODES.LOLLIPOP, Build.VERSION_CODES.N, Build.VERSION_CODES.P, Build.VERSION_CODES.R, diff --git a/app/src/test/java/com/amaze/filemanager/ui/icons/IconsTest.java b/app/src/test/java/com/amaze/filemanager/ui/icons/IconsTest.java index add1f19ac7..117e3da274 100644 --- a/app/src/test/java/com/amaze/filemanager/ui/icons/IconsTest.java +++ b/app/src/test/java/com/amaze/filemanager/ui/icons/IconsTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.ui.icons; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static org.junit.Assert.assertEquals; @@ -41,7 +41,7 @@ @RunWith(AndroidJUnit4.class) @Config( shadows = {ShadowMultiDex.class}, - sdk = {KITKAT, P, Build.VERSION_CODES.R}) + sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class IconsTest { @Before diff --git a/app/src/test/java/com/amaze/filemanager/ui/notifications/NotificationConstantsTest.java b/app/src/test/java/com/amaze/filemanager/ui/notifications/NotificationConstantsTest.java index aafa3fe106..78468e5358 100644 --- a/app/src/test/java/com/amaze/filemanager/ui/notifications/NotificationConstantsTest.java +++ b/app/src/test/java/com/amaze/filemanager/ui/notifications/NotificationConstantsTest.java @@ -22,7 +22,7 @@ import static android.app.NotificationManager.IMPORTANCE_HIGH; import static android.app.NotificationManager.IMPORTANCE_MIN; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static com.amaze.filemanager.ui.notifications.NotificationConstants.CHANNEL_FTP_ID; import static com.amaze.filemanager.ui.notifications.NotificationConstants.CHANNEL_NORMAL_ID; @@ -54,7 +54,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; @RunWith(AndroidJUnit4.class) -@Config(sdk = {KITKAT, P, Build.VERSION_CODES.R}) +@Config(sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class NotificationConstantsTest { private Context context; @@ -89,7 +89,7 @@ public void testSetMetadataIllegalType() { } @Test - @Config(sdk = {KITKAT}) // max sdk is N + @Config(sdk = {LOLLIPOP}) // max sdk is N public void testNormalNotification() { NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_NORMAL_ID) @@ -101,7 +101,7 @@ public void testNormalNotification() { NotificationConstants.setMetadata(context, builder, TYPE_NORMAL); Notification result = builder.build(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (Build.VERSION.SDK_INT >= LOLLIPOP) { assertEquals(Notification.CATEGORY_SERVICE, result.category); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { @@ -112,7 +112,7 @@ public void testNormalNotification() { } @Test - @Config(sdk = {KITKAT}) // max sdk is N + @Config(sdk = {LOLLIPOP}) // max sdk is N public void testFtpNotification() { NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_FTP_ID) @@ -124,7 +124,7 @@ public void testFtpNotification() { .setOnlyAlertOnce(true); NotificationConstants.setMetadata(context, builder, TYPE_FTP); Notification result = builder.build(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (Build.VERSION.SDK_INT >= LOLLIPOP) { assertEquals(Notification.CATEGORY_SERVICE, result.category); assertEquals(Notification.VISIBILITY_PUBLIC, result.visibility); } diff --git a/app/src/test/java/com/amaze/filemanager/ui/theme/AppThemeTest.kt b/app/src/test/java/com/amaze/filemanager/ui/theme/AppThemeTest.kt index 16c8efa38a..7d614b8431 100644 --- a/app/src/test/java/com/amaze/filemanager/ui/theme/AppThemeTest.kt +++ b/app/src/test/java/com/amaze/filemanager/ui/theme/AppThemeTest.kt @@ -22,7 +22,7 @@ package com.amaze.filemanager.ui.theme import android.content.Context import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.os.PowerManager import androidx.preference.PreferenceManager @@ -41,7 +41,7 @@ import java.util.Calendar @RunWith(AndroidJUnit4::class) @Config( - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], shadows = [ShadowMultiDex::class], ) class AppThemeTest { diff --git a/app/src/test/java/com/amaze/filemanager/ui/views/WarnableTextInputValidatorTest.java b/app/src/test/java/com/amaze/filemanager/ui/views/WarnableTextInputValidatorTest.java index 99970bb305..37070cd432 100644 --- a/app/src/test/java/com/amaze/filemanager/ui/views/WarnableTextInputValidatorTest.java +++ b/app/src/test/java/com/amaze/filemanager/ui/views/WarnableTextInputValidatorTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.ui.views; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -44,7 +44,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; @RunWith(AndroidJUnit4.class) -@Config(sdk = {KITKAT, P, Build.VERSION_CODES.R}) +@Config(sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class WarnableTextInputValidatorTest { private Context context; diff --git a/app/src/test/java/com/amaze/filemanager/utils/AESCryptTest.kt b/app/src/test/java/com/amaze/filemanager/utils/AESCryptTest.kt index 0ae810cc81..7559fa97d4 100644 --- a/app/src/test/java/com/amaze/filemanager/utils/AESCryptTest.kt +++ b/app/src/test/java/com/amaze/filemanager/utils/AESCryptTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.utils import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.ext.junit.runners.AndroidJUnit4 import org.junit.Assert.assertArrayEquals @@ -36,7 +36,7 @@ import kotlin.random.Random * Unit test for [AESCrypt] */ @RunWith(AndroidJUnit4::class) -@Config(sdk = [KITKAT, P, Build.VERSION_CODES.R]) +@Config(sdk = [LOLLIPOP, P, Build.VERSION_CODES.R]) class AESCryptTest { /** * Simple sanity test on [AESCrypt]. diff --git a/app/src/test/java/com/amaze/filemanager/utils/AnimUtilsTest.java b/app/src/test/java/com/amaze/filemanager/utils/AnimUtilsTest.java index 3cb7fe314b..92b65fdc29 100644 --- a/app/src/test/java/com/amaze/filemanager/utils/AnimUtilsTest.java +++ b/app/src/test/java/com/amaze/filemanager/utils/AnimUtilsTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.utils; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -45,7 +45,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; @RunWith(AndroidJUnit4.class) -@Config(sdk = {KITKAT, P, Build.VERSION_CODES.R}) +@Config(sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class AnimUtilsTest { @Test diff --git a/app/src/test/java/com/amaze/filemanager/utils/CryptUtilTest.kt b/app/src/test/java/com/amaze/filemanager/utils/CryptUtilTest.kt index ac364acfb6..d7e116593f 100644 --- a/app/src/test/java/com/amaze/filemanager/utils/CryptUtilTest.kt +++ b/app/src/test/java/com/amaze/filemanager/utils/CryptUtilTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.utils import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.os.Environment import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -48,7 +48,7 @@ import kotlin.random.Random @RunWith(AndroidJUnit4::class) @Config( - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) class CryptUtilTest { /** diff --git a/app/src/test/java/com/amaze/filemanager/utils/MinMaxInputFilterTest.kt b/app/src/test/java/com/amaze/filemanager/utils/MinMaxInputFilterTest.kt index d16eb031f6..0e882b12c8 100644 --- a/app/src/test/java/com/amaze/filemanager/utils/MinMaxInputFilterTest.kt +++ b/app/src/test/java/com/amaze/filemanager/utils/MinMaxInputFilterTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.utils import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import android.text.SpannedString import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -32,7 +32,7 @@ import org.junit.runner.RunWith import org.robolectric.annotation.Config @RunWith(AndroidJUnit4::class) -@Config(sdk = [KITKAT, P, Build.VERSION_CODES.R]) +@Config(sdk = [LOLLIPOP, P, Build.VERSION_CODES.R]) class MinMaxInputFilterTest { /** * Test MinMaxInputFilter functioning diff --git a/app/src/test/java/com/amaze/filemanager/utils/SmbUtilTest.kt b/app/src/test/java/com/amaze/filemanager/utils/SmbUtilTest.kt index 4cc95e2f00..ccc65a0110 100644 --- a/app/src/test/java/com/amaze/filemanager/utils/SmbUtilTest.kt +++ b/app/src/test/java/com/amaze/filemanager/utils/SmbUtilTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.utils import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -46,7 +46,7 @@ import org.robolectric.annotation.Config @Suppress("StringLiteralDuplication") @RunWith(AndroidJUnit4::class) @Config( - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], shadows = [ShadowPasswordUtil::class, ShadowSmbUtil::class], ) class SmbUtilTest { diff --git a/app/src/test/java/com/amaze/filemanager/utils/TinyDBTest.java b/app/src/test/java/com/amaze/filemanager/utils/TinyDBTest.java index 530e2694c4..12e9f3cd13 100644 --- a/app/src/test/java/com/amaze/filemanager/utils/TinyDBTest.java +++ b/app/src/test/java/com/amaze/filemanager/utils/TinyDBTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.utils; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertNull; @@ -38,7 +38,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; @RunWith(AndroidJUnit4.class) -@Config(sdk = {KITKAT, P, Build.VERSION_CODES.R}) +@Config(sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class TinyDBTest { private SharedPreferences prefs; diff --git a/app/src/test/java/com/amaze/filemanager/utils/UtilsTest.java b/app/src/test/java/com/amaze/filemanager/utils/UtilsTest.java index 52a5fbc687..fa90467fca 100644 --- a/app/src/test/java/com/amaze/filemanager/utils/UtilsTest.java +++ b/app/src/test/java/com/amaze/filemanager/utils/UtilsTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.utils; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.P; import static com.amaze.filemanager.utils.Utils.formatTimer; @@ -56,7 +56,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; @RunWith(AndroidJUnit4.class) -@Config(sdk = {KITKAT, P, Build.VERSION_CODES.R}) +@Config(sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class UtilsTest { @Test diff --git a/app/src/test/java/com/amaze/filemanager/utils/X509CertificateUtilTest.kt b/app/src/test/java/com/amaze/filemanager/utils/X509CertificateUtilTest.kt index 35cf830f44..fd74085121 100644 --- a/app/src/test/java/com/amaze/filemanager/utils/X509CertificateUtilTest.kt +++ b/app/src/test/java/com/amaze/filemanager/utils/X509CertificateUtilTest.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.utils import android.os.Build -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.ext.junit.runners.AndroidJUnit4 import com.amaze.filemanager.shadows.ShadowMultiDex @@ -29,21 +29,19 @@ import com.amaze.filemanager.utils.X509CertificateUtil.FINGERPRINT import com.amaze.filemanager.utils.X509CertificateUtil.ISSUER import com.amaze.filemanager.utils.X509CertificateUtil.SERIAL import com.amaze.filemanager.utils.X509CertificateUtil.SUBJECT -import org.bouncycastle.cert.X509CertificateHolder -import org.bouncycastle.openssl.PEMParser import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.robolectric.annotation.Config -import java.io.StringReader -import javax.security.cert.X509Certificate +import java.security.cert.CertificateFactory +import java.security.cert.X509Certificate @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class], - sdk = [KITKAT, P, Build.VERSION_CODES.R], + sdk = [LOLLIPOP, P, Build.VERSION_CODES.R], ) class X509CertificateUtilTest { private lateinit var cert: X509Certificate @@ -53,16 +51,8 @@ class X509CertificateUtilTest { */ @Before fun setUp() { - val parser = - PEMParser( - StringReader( - String( - javaClass.getResourceAsStream("/test.pem").readBytes(), - ), - ), - ) - val a = parser.readObject() - cert = X509Certificate.getInstance((a as X509CertificateHolder).encoded) + val certFactory = CertificateFactory.getInstance("X.509") + cert = certFactory.generateCertificate(javaClass.getResourceAsStream("/test.pem")) as X509Certificate } /** diff --git a/app/src/test/java/com/amaze/filemanager/utils/smb/AbstractSubnetDiscoverDevicesStrategyTests.kt b/app/src/test/java/com/amaze/filemanager/utils/smb/AbstractSubnetDiscoverDevicesStrategyTests.kt index b218c06ed9..d937bc0c06 100644 --- a/app/src/test/java/com/amaze/filemanager/utils/smb/AbstractSubnetDiscoverDevicesStrategyTests.kt +++ b/app/src/test/java/com/amaze/filemanager/utils/smb/AbstractSubnetDiscoverDevicesStrategyTests.kt @@ -21,7 +21,7 @@ package com.amaze.filemanager.utils.smb import android.os.Build.VERSION_CODES -import android.os.Build.VERSION_CODES.KITKAT +import android.os.Build.VERSION_CODES.LOLLIPOP import android.os.Build.VERSION_CODES.P import androidx.test.ext.junit.runners.AndroidJUnit4 import com.amaze.filemanager.utils.NetworkUtil @@ -38,7 +38,7 @@ import java.net.InetAddress * Base class for [SmbDeviceScannerObservable.DiscoverDeviceStrategy] tests. */ @RunWith(AndroidJUnit4::class) -@Config(sdk = [KITKAT, P, VERSION_CODES.R]) +@Config(sdk = [LOLLIPOP, P, VERSION_CODES.R]) abstract class AbstractSubnetDiscoverDevicesStrategyTests { /** * Post test cleanup. diff --git a/app/src/testPlay/java/com/amaze/filemanager/filesystem/compressed/extractcontents/MultipartRarExtractorTest.kt b/app/src/testPlay/java/com/amaze/filemanager/filesystem/compressed/extractcontents/MultipartRarExtractorTest.kt index 41e028ac14..e2538e9cf8 100644 --- a/app/src/testPlay/java/com/amaze/filemanager/filesystem/compressed/extractcontents/MultipartRarExtractorTest.kt +++ b/app/src/testPlay/java/com/amaze/filemanager/filesystem/compressed/extractcontents/MultipartRarExtractorTest.kt @@ -44,7 +44,7 @@ import java.util.concurrent.CountDownLatch @RunWith(AndroidJUnit4::class) @Config( shadows = [ShadowMultiDex::class], - sdk = [Build.VERSION_CODES.KITKAT, Build.VERSION_CODES.P], + sdk = [Build.VERSION_CODES.LOLLIPOP, Build.VERSION_CODES.P], ) class MultipartRarExtractorTest { private val callback = diff --git a/app/src/testPlayRelease/java/com/amaze/filemanager/utils/PackageInstallValidationTest.kt b/app/src/testPlayRelease/java/com/amaze/filemanager/utils/PackageInstallValidationTest.kt index b7c42503db..cf91812023 100644 --- a/app/src/testPlayRelease/java/com/amaze/filemanager/utils/PackageInstallValidationTest.kt +++ b/app/src/testPlayRelease/java/com/amaze/filemanager/utils/PackageInstallValidationTest.kt @@ -24,7 +24,6 @@ import android.annotation.SuppressLint import android.content.Context import android.content.pm.PackageInfo import android.os.Build.VERSION.SDK_INT -import android.os.Build.VERSION_CODES.KITKAT import android.os.Build.VERSION_CODES.N import android.os.Build.VERSION_CODES.P import android.os.storage.StorageManager @@ -65,7 +64,7 @@ import java.util.concurrent.TimeUnit @SuppressLint("SdCardPath") @RunWith(AndroidJUnit4::class) @Config( - sdk = [KITKAT, P], + sdk = [P], shadows = [ShadowPackageManager::class, ShadowMultiDex::class, ShadowTabHandler::class], ) class PackageInstallValidationTest { diff --git a/build.gradle b/build.gradle index f3c2f82d1c..7bcfab7019 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,4 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { ext { kotlin_version = "1.9.10" @@ -11,10 +10,10 @@ buildscript { } } dependencies { - classpath 'com.android.tools.build:gradle:7.3.1' - classpath 'com.hiya:jacoco-android:0.2' + classpath 'com.android.tools.build:gradle:8.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.project.starter:easylauncher:6.1.0" + classpath "com.mxalbert.gradle:jacoco-android:0.2.1" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -34,9 +33,9 @@ allprojects { } tasks.withType(Test).tap { configureEach { - maxParallelForks = 8 - maxHeapSize = "2g" - forkEvery = 4 + maxParallelForks = 16 + maxHeapSize = "4g" + forkEvery = 8 failFast = true } } @@ -55,17 +54,11 @@ spotless { kotlin { licenseHeaderFile 'amaze.license.spotless.txt' target '*/src/**/*.kt' - ktlint("1.1.1") - .setEditorConfigPath("$projectDir/.editorconfig") - + ktlint("1.1.1").setEditorConfigPath("$projectDir/.editorconfig") } } configurations { - robo16 - robo17 - robo18 - robo19 robo21 robo22 robo23 @@ -79,13 +72,10 @@ configurations { robo31 robo32 robo33 + robo34 } dependencies { - robo16 "org.robolectric:android-all-instrumented:4.1.2_r1-robolectric-r1-i4" - robo17 "org.robolectric:android-all-instrumented:4.2.2_r1.2-robolectric-r1-i4" - robo18 "org.robolectric:android-all-instrumented:4.3_r2-robolectric-r1-i4" - robo19 "org.robolectric:android-all-instrumented:4.4_r1-robolectric-r2-i4" robo21 "org.robolectric:android-all-instrumented:5.0.2_r3-robolectric-r0-i4" robo22 "org.robolectric:android-all-instrumented:5.1.1_r9-robolectric-r2-i4" robo23 "org.robolectric:android-all-instrumented:6.0.1_r3-robolectric-r1-i4" @@ -99,15 +89,12 @@ dependencies { robo31 "org.robolectric:android-all-instrumented:12-robolectric-7732740-i4" robo32 "org.robolectric:android-all-instrumented:12.1-robolectric-8229987-i4" robo33 "org.robolectric:android-all-instrumented:13-robolectric-9030017-i4" + robo34 "org.robolectric:android-all-instrumented:14-robolectric-10818077-i4" } -def robolectricDependencies = "${rootProject.buildDir.path}/robolectric" +def robolectricDependencies = "${rootProject.layout.buildDirectory}/robolectric" tasks.register('fetchRobolectricDependencies', Copy) { - from configurations.robo16 - from configurations.robo17 - from configurations.robo18 - from configurations.robo19 from configurations.robo21 from configurations.robo22 from configurations.robo23 @@ -121,6 +108,7 @@ tasks.register('fetchRobolectricDependencies', Copy) { from configurations.robo31 from configurations.robo32 from configurations.robo33 + from configurations.robo34 into robolectricDependencies } @@ -133,20 +121,10 @@ subprojects { systemProperty 'robolectric.dependency.dir', robolectricDependencies } } - tasks.withType(Test).configureEach { it.dependsOn fetchRobolectricDependencies } } - if (project.plugins.hasPlugin("jacoco-android")) { - android { - testOptions.unitTests.all { - jacoco { - excludes = ['jdk.internal.*'] - } - } - } - } dependencies { compileOnly 'com.github.pengrad:jdk9-deps:1.0' diff --git a/commons_compress_7z/build.gradle b/commons_compress_7z/build.gradle index 9a3f653f5e..886f3172d9 100644 --- a/commons_compress_7z/build.gradle +++ b/commons_compress_7z/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { + namespace "com.amaze.filemanager.filesystem.compressed.sevenz" compileSdk libs.versions.compileSdk.get().toInteger() defaultConfig { @@ -14,12 +15,12 @@ android { buildTypes { release { minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard.cfg' + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } } diff --git a/commons_compress_7z/consumer-rules.pro b/commons_compress_7z/consumer-rules.pro new file mode 100644 index 0000000000..e69de29bb2 diff --git a/commons_compress_7z/proguard-rules.pro b/commons_compress_7z/proguard-rules.pro new file mode 100644 index 0000000000..a9171abf8d --- /dev/null +++ b/commons_compress_7z/proguard-rules.pro @@ -0,0 +1,23 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile +-keep class com.amaze.filemanager.filesystem.compressed.sevenz.** +-keep enum com.amaze.filemanager.filesystem.compressed.sevenz.** \ No newline at end of file diff --git a/file_operations/build.gradle b/file_operations/build.gradle index 39bb52f1aa..a6f83f4c58 100644 --- a/file_operations/build.gradle +++ b/file_operations/build.gradle @@ -3,6 +3,7 @@ apply plugin: 'kotlin-android' apply plugin: 'com.google.devtools.ksp' android { + namespace "com.amaze.filemanager.fileoperations" compileSdk libs.versions.compileSdk.get().toInteger() defaultConfig { @@ -33,8 +34,8 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } testOptions { @@ -52,12 +53,12 @@ android { } kotlinOptions { - jvmTarget = '11' + jvmTarget = '17' } } kotlin { - jvmToolchain(11) + jvmToolchain(17) } dependencies { diff --git a/file_operations/proguard-rules.pro b/file_operations/proguard-rules.pro index 481bb43481..0a911bb0cb 100644 --- a/file_operations/proguard-rules.pro +++ b/file_operations/proguard-rules.pro @@ -18,4 +18,7 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile +-keep class com.amaze.filemanager.fileoperations.** +-keep interface com.amaze.filemanager.fileoperations.** +-keep enum com.amaze.filemanager.fileoperations.** \ No newline at end of file diff --git a/file_operations/src/test/java/com/amaze/filemanager/fileoperations/filesystem/smbstreamer/StreamSourceTest.java b/file_operations/src/test/java/com/amaze/filemanager/fileoperations/filesystem/smbstreamer/StreamSourceTest.java index a9f972f5cd..9415dcf1f6 100644 --- a/file_operations/src/test/java/com/amaze/filemanager/fileoperations/filesystem/smbstreamer/StreamSourceTest.java +++ b/file_operations/src/test/java/com/amaze/filemanager/fileoperations/filesystem/smbstreamer/StreamSourceTest.java @@ -20,7 +20,6 @@ package com.amaze.filemanager.fileoperations.filesystem.smbstreamer; -import static android.os.Build.VERSION_CODES.KITKAT; import static android.os.Build.VERSION_CODES.P; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -51,7 +50,7 @@ @RunWith(AndroidJUnit4.class) @Config( shadows = {ShadowMultiDex.class, ShadowSmbFile.class}, - sdk = {KITKAT, P}) + sdk = {P}) public class StreamSourceTest { private SmbFile file; private StreamSource ss; diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bc8b19e858..c22956ec5f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] -compileSdk = "33" -minSdk = "19" -targetSdk = "33" +compileSdk = "34" +minSdk = "21" +targetSdk = "34" kotlin = "1.9.10" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3994438e22..48c0a02ca4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/portscanner/build.gradle b/portscanner/build.gradle index 361d0fb70a..ee039f9b63 100644 --- a/portscanner/build.gradle +++ b/portscanner/build.gradle @@ -22,13 +22,13 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } } kotlin { - jvmToolchain(11) + jvmToolchain(17) } dependencies { diff --git a/testShared/src/test/java/com/amaze/filemanager/test/ShadowPasswordUtilTest.java b/testShared/src/test/java/com/amaze/filemanager/test/ShadowPasswordUtilTest.java index 1af6c0e167..c1f8919b50 100644 --- a/testShared/src/test/java/com/amaze/filemanager/test/ShadowPasswordUtilTest.java +++ b/testShared/src/test/java/com/amaze/filemanager/test/ShadowPasswordUtilTest.java @@ -20,7 +20,7 @@ package com.amaze.filemanager.test; -import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.P; import static org.awaitility.Awaitility.await; import static org.junit.Assert.assertEquals; @@ -56,7 +56,7 @@ @RunWith(AndroidJUnit4.class) @Config( shadows = {ShadowMultiDex.class, ShadowPasswordUtil.class}, - sdk = {KITKAT, P, Build.VERSION_CODES.R}) + sdk = {LOLLIPOP, P, Build.VERSION_CODES.R}) public class ShadowPasswordUtilTest { @Before