Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: Add pre API 26 support #270

Merged
merged 7 commits into from
Jul 14, 2024
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
Binary file modified source/app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions source/app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="432.0dip"
android:height="432.0dip"
android:width="108dp"
android:height="108dp"
android:viewportWidth="432"
android:viewportHeight="432">
<group
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class CloudRepository @Inject constructor(

var isSuccess = true
val out = mutableListOf<String>()
PathUtil.setFilesDirSELinux(context)

runCatching {
client.upload(src = src, dst = dstDir, onUploading = onUploading)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ class DirectoryRepository @Inject constructor(
val customDirList = mutableListOf<DirectoryUpsertEntity>()
pathList.forEach { pathString ->
if (pathString.isNotEmpty()) {
val path = Paths.get(pathString)
val parent = path.parent.pathString
val child = path.name
val parent = PathUtil.getParentPath(pathString)
val child = PathUtil.getFileName(pathString)

// Custom storage
val dir = DirectoryUpsertEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class PackageRepository @Inject constructor(
this.storageStats.appBytes = stats.appBytes
this.storageStats.cacheBytes = stats.cacheBytes
this.storageStats.dataBytes = stats.dataBytes
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) this.storageStats.externalCacheBytes = stats.externalCacheBytes
this.storageStats.externalCacheBytes = stats.externalCacheBytes
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ public class UserHandleHidden {
public static UserHandle of(int userId) {
throw new RuntimeException("Stub!");
}

public int getIdentifier() {
throw new RuntimeException("Stub!");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.xayah.core.model.util

import android.os.Build
import com.xayah.core.model.CompressionType
import com.xayah.core.model.KillAppOption
import com.xayah.core.model.LZ4_SUFFIX
Expand Down Expand Up @@ -53,7 +54,7 @@ fun SelectionType.Companion.of(name: String?): SelectionType =
runCatching { SelectionType.valueOf(name!!.uppercase()) }.getOrDefault(SelectionType.DEFAULT)

fun ThemeType.Companion.of(name: String?): ThemeType =
runCatching { ThemeType.valueOf(name!!.uppercase()) }.getOrDefault(ThemeType.AUTO)
runCatching { ThemeType.valueOf(name!!.uppercase()) }.getOrDefault(if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) ThemeType.AUTO else ThemeType.LIGHT_THEME)

fun SmbAuthMode.Companion.indexOf(index: Int): SmbAuthMode = when (index) {
1 -> SmbAuthMode.GUEST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.xayah.core.network.util.getExtraEntity
import com.xayah.core.rootservice.parcelables.PathParcelable
import com.xayah.core.util.GsonUtil
import com.xayah.core.util.LogUtil
import com.xayah.core.util.PathUtil
import com.xayah.core.util.toPathList
import com.xayah.core.util.withMainContext
import com.xayah.libpickyou.parcelables.DirChildrenParcelable
Expand All @@ -25,10 +26,7 @@ import java.io.FileInputStream
import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
import java.nio.file.Paths
import javax.security.auth.login.LoginException
import kotlin.io.path.Path
import kotlin.io.path.pathString

class FTPClientImpl(private val entity: CloudEntity, private val extra: FTPExtra) : CloudClient {
private var client: FTPClient? = null
Expand Down Expand Up @@ -88,7 +86,7 @@ class FTPClientImpl(private val entity: CloudEntity, private val extra: FTPExtra
}

override fun upload(src: String, dst: String, onUploading: (read: Long, total: Long) -> Unit) = withClient { client ->
val name = Paths.get(src).fileName
val name = PathUtil.getFileName(src)
val dstPath = "$dst/$name"
log { "upload: $src to $dstPath" }
val srcFile = File(src)
Expand All @@ -102,7 +100,7 @@ class FTPClientImpl(private val entity: CloudEntity, private val extra: FTPExtra
}

override fun download(src: String, dst: String, onDownloading: (written: Long, total: Long) -> Unit) = withClient { client ->
val name = Paths.get(src).fileName
val name = PathUtil.getFileName(src)
val dstPath = "$dst/$name"
log { "download: $src to $dstPath" }
val dstFile = File(dstPath)
Expand Down Expand Up @@ -130,11 +128,10 @@ class FTPClientImpl(private val entity: CloudEntity, private val extra: FTPExtra
private fun listFile(src: String): FTPFile {
var srcFile: FTPFile? = null
withClient { client ->
val srcPath = Path(src)
srcFile = client.mlistFile(src)
if (srcFile == null) {
srcFile = client.listFiles(runCatching { srcPath.parent.pathString }.getOrElse { "." })
.firstOrNull { it.name == srcPath.fileName.pathString }
srcFile = client.listFiles(runCatching { PathUtil.getParentPath(src) }.getOrElse { "." })
.firstOrNull { it.name == PathUtil.getFileName(src) }
}
}
if (srcFile != null) {
Expand Down Expand Up @@ -253,7 +250,7 @@ class FTPClientImpl(private val entity: CloudEntity, private val extra: FTPExtra
connect()
PickYouLauncher.apply {
val prefix = "${context.getString(R.string.cloud)}:"
sTraverseBackend = { listFiles(it.pathString.replaceFirst(prefix, "")) }
sTraverseBackend = { listFiles(it.replaceFirst(prefix, "")) }
sMkdirsBackend = { parent, child ->
runCatching { mkdirRecursively(handleOriginalPath("$parent/$child")) }.isSuccess
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.xayah.core.network.util.getExtraEntity
import com.xayah.core.rootservice.parcelables.PathParcelable
import com.xayah.core.util.GsonUtil
import com.xayah.core.util.LogUtil
import com.xayah.core.util.PathUtil
import com.xayah.core.util.toPathList
import com.xayah.core.util.withMainContext
import com.xayah.libpickyou.parcelables.DirChildrenParcelable
Expand All @@ -27,8 +28,6 @@ import net.schmizz.sshj.userauth.password.PasswordFinder
import net.schmizz.sshj.userauth.password.Resource
import java.io.File
import java.io.FileOutputStream
import java.nio.file.Paths
import kotlin.io.path.pathString


class SFTPClientImpl(private val entity: CloudEntity, private val extra: SFTPExtra) : CloudClient {
Expand Down Expand Up @@ -109,7 +108,7 @@ class SFTPClientImpl(private val entity: CloudEntity, private val extra: SFTPExt
}

override fun upload(src: String, dst: String, onUploading: (read: Long, total: Long) -> Unit) {
val name = Paths.get(src).fileName
val name = PathUtil.getFileName(src)
val dstPath = "$dst/$name"
log { "upload: $src to $dstPath" }
val dstFile = openFile(dstPath)
Expand All @@ -126,7 +125,7 @@ class SFTPClientImpl(private val entity: CloudEntity, private val extra: SFTPExt
}

override fun download(src: String, dst: String, onDownloading: (written: Long, total: Long) -> Unit) {
val name = Paths.get(src).fileName
val name = PathUtil.getFileName(src)
val dstPath = "${dst}/$name"
log { "download: $src to $dstPath" }
val dstFile = File(dstPath)
Expand Down Expand Up @@ -221,7 +220,7 @@ class SFTPClientImpl(private val entity: CloudEntity, private val extra: SFTPExt
connect()
PickYouLauncher.apply {
val prefix = "${context.getString(R.string.cloud)}:"
sTraverseBackend = { listFiles(it.pathString.replaceFirst(prefix, ".")) }
sTraverseBackend = { listFiles(it.replaceFirst(prefix, ".")) }
sMkdirsBackend = { parent, child ->
runCatching { mkdirRecursively(handleOriginalPath("$parent/$child")) }.isSuccess
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.xayah.core.network.util.getExtraEntity
import com.xayah.core.rootservice.parcelables.PathParcelable
import com.xayah.core.util.GsonUtil
import com.xayah.core.util.LogUtil
import com.xayah.core.util.PathUtil
import com.xayah.core.util.SymbolUtil
import com.xayah.core.util.toPathList
import com.xayah.core.util.withLog
Expand All @@ -41,8 +42,6 @@ import com.xayah.libpickyou.ui.model.PickerType
import java.io.File
import java.io.FileInputStream
import java.io.IOException
import java.nio.file.Paths
import kotlin.io.path.pathString


class SMBClientImpl(private val entity: CloudEntity, private val extra: SMBExtra) : CloudClient {
Expand Down Expand Up @@ -200,7 +199,7 @@ class SMBClientImpl(private val entity: CloudEntity, private val extra: SMBExtra
}

override fun upload(src: String, dst: String, onUploading: (read: Long, total: Long) -> Unit) = run {
val name = Paths.get(src).fileName
val name = PathUtil.getFileName(src)
val dstPath = "$dst/$name"
log { "upload: $src to $dstPath" }
val dstFile = openFile(dstPath)
Expand All @@ -216,7 +215,7 @@ class SMBClientImpl(private val entity: CloudEntity, private val extra: SMBExtra
}

override fun download(src: String, dst: String, onDownloading: (written: Long, total: Long) -> Unit) = run {
val name = Paths.get(src).fileName
val name = PathUtil.getFileName(src)
val dstPath = "$dst/$name"
log { "download: $src to $dstPath" }
val dstOutputStream = File(dstPath).outputStream()
Expand Down Expand Up @@ -343,7 +342,7 @@ class SMBClientImpl(private val entity: CloudEntity, private val extra: SMBExtra
connect()
PickYouLauncher.apply {
val prefix = "${context.getString(R.string.cloud)}:"
sTraverseBackend = { listFiles(it.pathString.replaceFirst(prefix, "")) }
sTraverseBackend = { listFiles(it.replaceFirst(prefix, "")) }
sMkdirsBackend = { parent, child ->
val (_, target) = handleOriginalPath("$parent/$child")
runCatching { mkdirRecursively(target) }.isSuccess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.xayah.core.model.database.CloudEntity
import com.xayah.core.network.R
import com.xayah.core.rootservice.parcelables.PathParcelable
import com.xayah.core.util.LogUtil
import com.xayah.core.util.PathUtil
import com.xayah.core.util.toPathList
import com.xayah.core.util.withMainContext
import com.xayah.libpickyou.parcelables.DirChildrenParcelable
Expand All @@ -15,9 +16,7 @@ import com.xayah.libpickyou.ui.model.PickerType
import com.xayah.libsardine.impl.OkHttpSardine
import okhttp3.OkHttpClient
import java.io.File
import java.nio.file.Paths
import java.util.concurrent.TimeUnit
import kotlin.io.path.pathString

class WebDAVClientImpl(private val entity: CloudEntity) : CloudClient {
private var client: OkHttpSardine? = null
Expand Down Expand Up @@ -72,15 +71,15 @@ class WebDAVClientImpl(private val entity: CloudEntity) : CloudClient {
}

override fun upload(src: String, dst: String, onUploading: (read: Long, total: Long) -> Unit) = withClient { client ->
val name = Paths.get(src).fileName
val name = PathUtil.getFileName(src)
val dstPath = "${getPath(dst)}/$name"
log { "upload: $src to $dstPath" }
val srcFile = File(src)
client.put(dstPath, srcFile, null)
}

override fun download(src: String, dst: String, onDownloading: (written: Long, total: Long) -> Unit) = withClient { client ->
val name = Paths.get(src).fileName
val name = PathUtil.getFileName(src)
val dstPath = "${dst}/$name"
log { "download: ${getPath(src)} to $dstPath" }
val dstOutputStream = File(dstPath).outputStream()
Expand Down Expand Up @@ -191,7 +190,7 @@ class WebDAVClientImpl(private val entity: CloudEntity) : CloudClient {
connect()
PickYouLauncher.apply {
val prefix = "${context.getString(R.string.cloud)}:"
sTraverseBackend = { listFiles(it.pathString.replaceFirst(prefix, "")) }
sTraverseBackend = { listFiles(it.replaceFirst(prefix, "")) }
sMkdirsBackend = { parent, child ->
runCatching { mkdirRecursively(handleOriginalPath("$parent/$child")) }.isSuccess
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.xayah.core.rootservice;

import com.xayah.core.rootservice.parcelables.StatFsParcelable;
import com.xayah.core.rootservice.parcelables.StorageStatsParcelable;

interface IRemoteRootService {
StatFsParcelable readStatFs(String path);
Expand Down Expand Up @@ -28,7 +29,7 @@ interface IRemoteRootService {
boolean queryInstalled(String packageName, int userId);
int getPackageUid(String packageName, int userId);
UserHandle getUserHandle(int userId);
StorageStats queryStatsForPackage(in PackageInfo packageInfo, in UserHandle user);
StorageStatsParcelable queryStatsForPackage(in PackageInfo packageInfo, in UserHandle user);
List<UserInfo> getUsers();
ParcelFileDescriptor walkFileTree(String path);
PackageInfo getPackageArchiveInfo(String path);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package com.xayah.core.rootservice.parcelables;
parcelable StorageStatsParcelable;
Loading
Loading