add file manager button

This commit is contained in:
qimiko committed 2024-01-06 20:49:38 -07:00
1 parent 3e8764e1e1
commit c3c19629de
2 files changed
+19 -2

No files matched your search

@@ -3,6 +3,7 @@ package com.geode.launcher
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.widget.Toast
@@ -32,11 +33,14 @@ import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.viewmodel.compose.viewModel
import com.geode.launcher.api.ReleaseViewModel
import com.geode.launcher.ui.theme.GeodeLauncherTheme
import com.geode.launcher.ui.theme.Typography
import com.geode.launcher.utils.LaunchUtils
import com.geode.launcher.utils.PreferenceUtils
import java.io.File
import java.net.ConnectException
import java.net.UnknownHostException
@@ -69,7 +73,7 @@ fun onExportSaveData(context: Context) {
*/
fun onOpenFolder(context: Context) {
context.getExternalFilesDir(null)?.let { file ->
val file = LaunchUtils.getBaseDirectory(context)
val clipboardManager =
context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboardManager.setPrimaryClip(
@@ -85,7 +89,15 @@ fun onOpenFolder(context: Context) {
Toast.LENGTH_SHORT
).show()
}
}
fun onOpenFileManager(context: Context) {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
type = "*/*"
}
context.startActivity(intent)
}
@Composable
@@ -210,9 +222,13 @@ fun SettingsScreen(
)
OptionsButton(
title = context.getString(R.string.preferences_copy_external_button),
description = context.getExternalFilesDir(null)?.path,
description = LaunchUtils.getBaseDirectory(context).path,
onClick = { onOpenFolder(context) }
)
OptionsButton(
title = stringResource(R.string.preferences_open_file_manager),
onClick = { onOpenFileManager(context) }
)
}
OptionsGroup(context.getString(R.string.preference_category_updater)) {
+1
View File
@@ -44,6 +44,7 @@
<string name="preference_load_automatically_name">Automatically launch</string>
<string name="preference_load_automatically_description">Launches the game after a short delay.</string>
<string name="preferences_copy_external_button">Copy external files directory</string>
<string name="preferences_open_file_manager">Open file manager</string>
<string name="preference_category_updater">Updates</string>
<string name="preference_update_automatically_name">Enable automatic updates</string>