diff options
Diffstat (limited to 'src/android')
3 files changed, 45 insertions, 9 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt index 22c9b05de..5fe235dba 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt | |||
| @@ -5,6 +5,7 @@ package org.yuzu.yuzu_emu | |||
| 5 | 5 | ||
| 6 | import android.app.Dialog | 6 | import android.app.Dialog |
| 7 | import android.content.DialogInterface | 7 | import android.content.DialogInterface |
| 8 | import android.net.Uri | ||
| 8 | import android.os.Bundle | 9 | import android.os.Bundle |
| 9 | import android.text.Html | 10 | import android.text.Html |
| 10 | import android.text.method.LinkMovementMethod | 11 | import android.text.method.LinkMovementMethod |
| @@ -16,7 +17,7 @@ import androidx.fragment.app.DialogFragment | |||
| 16 | import com.google.android.material.dialog.MaterialAlertDialogBuilder | 17 | import com.google.android.material.dialog.MaterialAlertDialogBuilder |
| 17 | import java.lang.ref.WeakReference | 18 | import java.lang.ref.WeakReference |
| 18 | import org.yuzu.yuzu_emu.activities.EmulationActivity | 19 | import org.yuzu.yuzu_emu.activities.EmulationActivity |
| 19 | import org.yuzu.yuzu_emu.utils.DocumentsTree.Companion.isNativePath | 20 | import org.yuzu.yuzu_emu.utils.DocumentsTree |
| 20 | import org.yuzu.yuzu_emu.utils.FileUtil | 21 | import org.yuzu.yuzu_emu.utils.FileUtil |
| 21 | import org.yuzu.yuzu_emu.utils.Log | 22 | import org.yuzu.yuzu_emu.utils.Log |
| 22 | import org.yuzu.yuzu_emu.utils.SerializableHelper.serializable | 23 | import org.yuzu.yuzu_emu.utils.SerializableHelper.serializable |
| @@ -68,7 +69,7 @@ object NativeLibrary { | |||
| 68 | @Keep | 69 | @Keep |
| 69 | @JvmStatic | 70 | @JvmStatic |
| 70 | fun openContentUri(path: String?, openmode: String?): Int { | 71 | fun openContentUri(path: String?, openmode: String?): Int { |
| 71 | return if (isNativePath(path!!)) { | 72 | return if (DocumentsTree.isNativePath(path!!)) { |
| 72 | YuzuApplication.documentsTree!!.openContentUri(path, openmode) | 73 | YuzuApplication.documentsTree!!.openContentUri(path, openmode) |
| 73 | } else { | 74 | } else { |
| 74 | FileUtil.openContentUri(path, openmode) | 75 | FileUtil.openContentUri(path, openmode) |
| @@ -78,7 +79,7 @@ object NativeLibrary { | |||
| 78 | @Keep | 79 | @Keep |
| 79 | @JvmStatic | 80 | @JvmStatic |
| 80 | fun getSize(path: String?): Long { | 81 | fun getSize(path: String?): Long { |
| 81 | return if (isNativePath(path!!)) { | 82 | return if (DocumentsTree.isNativePath(path!!)) { |
| 82 | YuzuApplication.documentsTree!!.getFileSize(path) | 83 | YuzuApplication.documentsTree!!.getFileSize(path) |
| 83 | } else { | 84 | } else { |
| 84 | FileUtil.getFileSize(path) | 85 | FileUtil.getFileSize(path) |
| @@ -88,7 +89,7 @@ object NativeLibrary { | |||
| 88 | @Keep | 89 | @Keep |
| 89 | @JvmStatic | 90 | @JvmStatic |
| 90 | fun exists(path: String?): Boolean { | 91 | fun exists(path: String?): Boolean { |
| 91 | return if (isNativePath(path!!)) { | 92 | return if (DocumentsTree.isNativePath(path!!)) { |
| 92 | YuzuApplication.documentsTree!!.exists(path) | 93 | YuzuApplication.documentsTree!!.exists(path) |
| 93 | } else { | 94 | } else { |
| 94 | FileUtil.exists(path) | 95 | FileUtil.exists(path) |
| @@ -98,13 +99,31 @@ object NativeLibrary { | |||
| 98 | @Keep | 99 | @Keep |
| 99 | @JvmStatic | 100 | @JvmStatic |
| 100 | fun isDirectory(path: String?): Boolean { | 101 | fun isDirectory(path: String?): Boolean { |
| 101 | return if (isNativePath(path!!)) { | 102 | return if (DocumentsTree.isNativePath(path!!)) { |
| 102 | YuzuApplication.documentsTree!!.isDirectory(path) | 103 | YuzuApplication.documentsTree!!.isDirectory(path) |
| 103 | } else { | 104 | } else { |
| 104 | FileUtil.isDirectory(path) | 105 | FileUtil.isDirectory(path) |
| 105 | } | 106 | } |
| 106 | } | 107 | } |
| 107 | 108 | ||
| 109 | @Keep | ||
| 110 | @JvmStatic | ||
| 111 | fun getParentDirectory(path: String): String = | ||
| 112 | if (DocumentsTree.isNativePath(path)) { | ||
| 113 | YuzuApplication.documentsTree!!.getParentDirectory(path) | ||
| 114 | } else { | ||
| 115 | path | ||
| 116 | } | ||
| 117 | |||
| 118 | @Keep | ||
| 119 | @JvmStatic | ||
| 120 | fun getFilename(path: String): String = | ||
| 121 | if (DocumentsTree.isNativePath(path)) { | ||
| 122 | YuzuApplication.documentsTree!!.getFilename(path) | ||
| 123 | } else { | ||
| 124 | FileUtil.getFilename(Uri.parse(path)) | ||
| 125 | } | ||
| 126 | |||
| 108 | /** | 127 | /** |
| 109 | * Returns true if pro controller isn't available and handheld is | 128 | * Returns true if pro controller isn't available and handheld is |
| 110 | */ | 129 | */ |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt index eafcf9e42..738275297 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt | |||
| @@ -42,6 +42,23 @@ class DocumentsTree { | |||
| 42 | return node != null && node.isDirectory | 42 | return node != null && node.isDirectory |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | fun getParentDirectory(filepath: String): String { | ||
| 46 | val node = resolvePath(filepath)!! | ||
| 47 | val parentNode = node.parent | ||
| 48 | if (parentNode != null && parentNode.isDirectory) { | ||
| 49 | return parentNode.uri!!.toString() | ||
| 50 | } | ||
| 51 | return node.uri!!.toString() | ||
| 52 | } | ||
| 53 | |||
| 54 | fun getFilename(filepath: String): String { | ||
| 55 | val node = resolvePath(filepath) | ||
| 56 | if (node != null) { | ||
| 57 | return node.name!! | ||
| 58 | } | ||
| 59 | return filepath | ||
| 60 | } | ||
| 61 | |||
| 45 | private fun resolvePath(filepath: String): DocumentsNode? { | 62 | private fun resolvePath(filepath: String): DocumentsNode? { |
| 46 | val tokens = StringTokenizer(filepath, File.separator, false) | 63 | val tokens = StringTokenizer(filepath, File.separator, false) |
| 47 | var iterator = root | 64 | var iterator = root |
diff --git a/src/android/app/src/main/jni/native.h b/src/android/app/src/main/jni/native.h index 2eb5c4349..b1db87e41 100644 --- a/src/android/app/src/main/jni/native.h +++ b/src/android/app/src/main/jni/native.h | |||
| @@ -2,14 +2,14 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <android/native_window_jni.h> | 4 | #include <android/native_window_jni.h> |
| 5 | #include "common/detached_tasks.h" | ||
| 5 | #include "core/core.h" | 6 | #include "core/core.h" |
| 7 | #include "core/file_sys/registered_cache.h" | ||
| 8 | #include "core/hle/service/acc/profile_manager.h" | ||
| 6 | #include "core/perf_stats.h" | 9 | #include "core/perf_stats.h" |
| 7 | #include "jni/emu_window/emu_window.h" | ||
| 8 | #include "jni/applets/software_keyboard.h" | 10 | #include "jni/applets/software_keyboard.h" |
| 11 | #include "jni/emu_window/emu_window.h" | ||
| 9 | #include "video_core/rasterizer_interface.h" | 12 | #include "video_core/rasterizer_interface.h" |
| 10 | #include "common/detached_tasks.h" | ||
| 11 | #include "core/hle/service/acc/profile_manager.h" | ||
| 12 | #include "core/file_sys/registered_cache.h" | ||
| 13 | 13 | ||
| 14 | #pragma once | 14 | #pragma once |
| 15 | 15 | ||