Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@ apply plugin: 'com.google.devtools.ksp'

android {
namespace "com.amaze.filemanager"
compileSdk libs.versions.compileSdk.get().toInteger()
compileSdkVersion libs.versions.compileSdk.get().toInteger()
packagingOptions {
resources {
excludes += ['proguard-project.txt', 'project.properties', 'META-INF/LICENSE.txt', 'META-INF/LICENSE', 'META-INF/NOTICE.txt', 'META-INF/NOTICE', 'META-INF/DEPENDENCIES.txt', 'META-INF/DEPENDENCIES', 'META-INF/versions/9/OSGI-INF/MANIFEST.MF']
excludes += [
'proguard-project.txt',
'project.properties',
'META-INF/LICENSE.txt',
'META-INF/LICENSE.md',
'META-INF/LICENSE',
'META-INF/NOTICE.txt',
'META-INF/NOTICE',
'META-INF/DEPENDENCIES.txt',
'META-INF/DEPENDENCIES',
'META-INF/versions/9/OSGI-INF/MANIFEST.MF'
]
}
}

Expand Down Expand Up @@ -44,7 +55,7 @@ android {
debug {
applicationIdSuffix ".debug"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard.cfg'
testProguardFile 'tests-proguard.cfg'
buildConfigField "String", "CRYPTO_IV", "\"LxbHiJhhUXcj\""
debuggable true //For "debug" banner on icon
Expand All @@ -55,7 +66,7 @@ android {
signingConfig signingConfigs.release

minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard.cfg'
buildConfigField "String", "CRYPTO_IV", "\"LxbHiJhhUXcj\""
}
}
Expand Down Expand Up @@ -87,17 +98,9 @@ android {
includeInBundle = false
}

sourceSets {
test.java.srcDirs += '../testShared/src/test/java'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '17'
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}

testOptions {
Expand Down Expand Up @@ -131,6 +134,7 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation libs.systembarTint

implementation libs.androidX.activity
implementation libs.androidX.vectordrawable.animated
implementation libs.androidX.legacySupportV13
implementation libs.androidX.material
Expand All @@ -150,6 +154,7 @@ dependencies {
ksp libs.androidX.annotation

//For tests
testImplementation project(':testShared')
testImplementation libs.junit//tests the app logic
testImplementation libs.robolectric//tests android interaction
testImplementation libs.robolectric.shadows.httpclient//tests android interaction
Expand All @@ -162,14 +167,16 @@ dependencies {
testImplementation libs.mockito.inline
testImplementation libs.mockito.kotlin
testImplementation libs.apache.sshd
testImplementation libs.apache.sshd.scp
testImplementation libs.apache.sshd.sftp
testImplementation libs.awaitility
testImplementation libs.jsoup
testImplementation libs.room.migration
testImplementation libs.mockk
testImplementation libs.kotlin.coroutine.test
testImplementation libs.androidX.core.testing
testImplementation libs.logback.classic
kspTest libs.auto.service
testImplementation 'ch.qos.logback:logback-classic:1.4.14'

androidTestImplementation libs.junit //tests the app logic
androidTestImplementation libs.androidX.test.expresso
Expand Down Expand Up @@ -260,14 +267,15 @@ dependencies {
}

kotlin {
jvmToolchain(17)
jvmToolchain(21)
}

configurations.configureEach {
resolutionStrategy {
dependencySubstitution {
substitute module("commons-logging:commons-logging-api:1.1") using module("commons-logging:commons-logging:1.1.1")
substitute module("com.android.support:support-annotations:27.1.1") using module("com.android.support:support-annotations:27.0.2")
substitute module("org.bouncycastle:bcprov-jdk18on:1.80.2") using module("org.bouncycastle:bcprov-jdk18on:1.85")
// These two lines are added to prevent possible class clashes between awaitility (which uses hamcrest 2.1) and junit (which uses hamcrest 1.3).
substitute module('org.hamcrest:hamcrest-core:1.3') using module("org.hamcrest:hamcrest:2.1")
substitute module('org.hamcrest:hamcrest-library:1.3') using module("org.hamcrest:hamcrest:2.1")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2025 Arpit Khurana <arpitkh96@gmail.com>, Vishal Nehra <vishalmeham2@gmail.com>,
* Copyright (C) 2014-2026 Arpit Khurana <arpitkh96@gmail.com>, Vishal Nehra <vishalmeham2@gmail.com>,
* Emmanuel Messulam<emmanuelbendavid@gmail.com>, Raymond Lai <airwave209gt at gmail.com> and Contributors.
*
* This file is part of Amaze File Manager.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2014-2026 Arpit Khurana <arpitkh96@gmail.com>, Vishal Nehra <vishalmeham2@gmail.com>,
* Emmanuel Messulam<emmanuelbendavid@gmail.com>, Raymond Lai <airwave209gt at gmail.com> and Contributors.
*
* This file is part of Amaze File Manager.
*
* Amaze File Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.github.junrar.exception;

/*
* This file is extracted from junrar library (https://github.com/junrar/junrar).
* The file exist to comply with F-Droid's requirement that no proprietary archive formats can be
* supported.
*
* - TranceLove
*/

/**
* Thrown when the archive signature names a RAR format this library cannot read: a future format
* version byte ({@code 0x02}..{@code 0x04}) that the library predates (unrar {@code RARFMT_FUTURE},
* {@code d861246:archive.cpp:122,178-181}: "so we can return a sensible warning in case we'll want
* to change the archive format sometimes in the future"). The ancient RAR 1.4 format (marker {@code
* 52 45 7e 5e}, unrar {@code RARFMT14}) no longer throws this -- {@code Archive} reads its headers
* through a dedicated loop (P1, issue #293). Distinct from {@link BadRarArchiveException} (no valid
Comment thread
TranceLove marked this conversation as resolved.
* signature at all).
*/
public class UnsupportedRarVersionException extends Exception {
public UnsupportedRarVersionException(Throwable cause) {
super(cause);
}

public UnsupportedRarVersionException() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.amaze.filemanager.adapters

import android.view.LayoutInflater
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.amaze.filemanager.adapters

import android.view.LayoutInflater
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package com.amaze.filemanager.asynchronous.asynctasks.compress

import android.content.Context
import android.net.Uri
import androidx.core.net.toUri
import com.amaze.filemanager.R
import com.amaze.filemanager.adapters.data.CompressedObjectParcelable
import com.amaze.filemanager.application.AppConfig
Expand All @@ -41,95 +42,100 @@ class ZipHelperCallable(
) :
CompressedHelperCallable(goback) {
private val context: WeakReference<Context> = WeakReference(c)
private val fileLocation: Uri = Uri.parse(realFileDirectory)
private val fileLocation: Uri = realFileDirectory.toUri()
private val relativeDirectory: String? = dir

@Throws(ArchiveException::class)
@Suppress("ComplexMethod", "LongMethod")
public override fun addElements(elements: ArrayList<CompressedObjectParcelable>) =
public override fun addElements(elements: ArrayList<CompressedObjectParcelable>) {
val path =
fileLocation.path
?: throw ArchiveException("Invalid zip file location: $fileLocation")
try {
fileLocation.path?.run {
val zipfile = ZipFile(fileLocation.path)
val wholelist = filterValidEntryList(zipfile)
val strings = ArrayList<String>()
for (entry in wholelist) {
val file = File(entry.path)
val y =
entry.path.let {
if (it.startsWith("/")) {
it.substring(1, it.length)
} else {
it
}
val zipfile = ZipFile(path)
if (!zipfile.isValidZipFile || zipfile.file.length() == 0L) {
throw ZipException("Zero byte or corrupt zip file")
}
val wholelist = filterValidEntryList(zipfile)
val strings = ArrayList<String>()
for (entry in wholelist) {
val file = File(entry.path)
val y =
entry.path.let {
if (it.startsWith("/")) {
it.substring(1, it.length)
} else {
it
}
if (relativeDirectory == null || relativeDirectory.trim { it <= ' ' }.isEmpty()) {
var path: String
var zipObj: CompressedObjectParcelable
if (file.parent == null || file.parent!!.isEmpty() || file.parent == "/") {
path = y
zipObj =
}
if (relativeDirectory == null || relativeDirectory.trim { it <= ' ' }.isEmpty()) {
var path: String
var zipObj: CompressedObjectParcelable
if (file.parent == null || file.parent!!.isEmpty() || file.parent == "/") {
path = y
zipObj =
CompressedObjectParcelable(
y,
entry.date,
entry.size,
entry.directory,
)
} else {
path = y.substring(0, y.indexOf("/") + 1)
zipObj =
CompressedObjectParcelable(
path,
entry.date,
entry.size,
true,
)
}
if (!strings.contains(path)) {
elements.add(zipObj)
strings.add(path)
}
} else {
if (file.parent != null &&
(
file.parent == relativeDirectory ||
file.parent == "/$relativeDirectory"
)
) {
if (!strings.contains(y)) {
elements.add(
CompressedObjectParcelable(
y,
entry.date,
entry.size,
entry.directory,
)
} else {
path = y.substring(0, y.indexOf("/") + 1)
zipObj =
),
)
strings.add(y)
}
} else if (y.startsWith("$relativeDirectory/") &&
(y.length > (relativeDirectory.length + 1))
) {
val path1 = y.substring(relativeDirectory.length + 1, y.length)
val index = relativeDirectory.length + 1 + path1.indexOf("/")
val path = y.substring(0, index + 1)
if (!strings.contains(path)) {
elements.add(
CompressedObjectParcelable(
path,
y.substring(0, index + 1),
entry.date,
entry.size,
true,
)
}
if (!strings.contains(path)) {
elements.add(zipObj)
strings.add(path)
}
} else {
if (file.parent != null &&
(
file.parent == relativeDirectory ||
file.parent == "/$relativeDirectory"
),
)
) {
if (!strings.contains(y)) {
elements.add(
CompressedObjectParcelable(
y,
entry.date,
entry.size,
entry.directory,
),
)
strings.add(y)
}
} else if (y.startsWith("$relativeDirectory/") &&
y.length > relativeDirectory.length + 1
) {
val path1 = y.substring(relativeDirectory.length + 1, y.length)
val index = relativeDirectory.length + 1 + path1.indexOf("/")
val path = y.substring(0, index + 1)
if (!strings.contains(path)) {
elements.add(
CompressedObjectParcelable(
y.substring(0, index + 1),
entry.date,
entry.size,
true,
),
)
strings.add(path)
}
strings.add(path)
}
}
}
} ?: throw ArchiveException(null)
}
} catch (e: ZipException) {
throw ArchiveException("Zip file is corrupt", e)
}
}

private fun filterValidEntryList(zipFile: ZipFile): List<CompressedObjectParcelable> {
val retval = ArrayList<CompressedObjectParcelable>()
Expand Down
Loading
Loading