forked from geode-sdk/android-launcher
add load testing preference
This commit is contained in:
2 files changed
+46
-5
No files matched your search
@@ -25,8 +25,10 @@ import androidx.compose.ui.semantics.Role
|
|||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import dev.xyze.geodelauncher.utils.LaunchUtils
|
import androidx.core.content.edit
|
||||||
import dev.xyze.geodelauncher.ui.theme.GeodeLauncherTheme
|
import dev.xyze.geodelauncher.ui.theme.GeodeLauncherTheme
|
||||||
|
import dev.xyze.geodelauncher.utils.LaunchUtils
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
@@ -56,6 +58,33 @@ fun onSettings(context: Context) {
|
|||||||
Toast.makeText(context, "Settings are not implemented yet!", Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, "Settings are not implemented yet!", Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onOpenFolder(context: Context) {
|
||||||
|
context.getExternalFilesDir(null)?.let { file ->
|
||||||
|
val geodePath = file.path + File.separator + "geode" + File.separator
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun toggleLoadTesting(context: Context): Boolean {
|
||||||
|
val preferences = context.getSharedPreferences(
|
||||||
|
context.getString(R.string.preference_file_key), Context.MODE_PRIVATE)
|
||||||
|
|
||||||
|
val current = preferences.getBoolean(
|
||||||
|
context.getString(R.string.preference_load_testing), false)
|
||||||
|
preferences.edit {
|
||||||
|
putBoolean(context.getString(R.string.preference_load_testing), !current)
|
||||||
|
commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
return preferences.getBoolean(context.getString(R.string.preference_load_testing), false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getLoadTesting(context: Context): Boolean {
|
||||||
|
val preferences = context.getSharedPreferences(
|
||||||
|
context.getString(R.string.preference_file_key), Context.MODE_PRIVATE)
|
||||||
|
|
||||||
|
return preferences.getBoolean(context.getString(R.string.preference_load_testing), false)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MainScreen(gdInstalled: Boolean = true) {
|
fun MainScreen(gdInstalled: Boolean = true) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
@@ -113,7 +142,15 @@ fun MainScreen(gdInstalled: Boolean = true) {
|
|||||||
|
|
||||||
Spacer(modifier = Modifier.height(12.dp))
|
Spacer(modifier = Modifier.height(12.dp))
|
||||||
|
|
||||||
val isLoadTesting = remember { mutableStateOf(true) }
|
TestingUtils()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun TestingUtils() {
|
||||||
|
val context = LocalContext.current
|
||||||
|
|
||||||
|
val isLoadTesting = remember { mutableStateOf(getLoadTesting(context)) }
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
elevation = CardDefaults.elevatedCardElevation(),
|
elevation = CardDefaults.elevatedCardElevation(),
|
||||||
@@ -137,7 +174,7 @@ fun MainScreen(gdInstalled: Boolean = true) {
|
|||||||
.height(48.dp)
|
.height(48.dp)
|
||||||
.toggleable(
|
.toggleable(
|
||||||
value = isLoadTesting.value,
|
value = isLoadTesting.value,
|
||||||
onValueChange = { isLoadTesting.value = !isLoadTesting.value },
|
onValueChange = { isLoadTesting.value = toggleLoadTesting(context) },
|
||||||
role = Role.Checkbox
|
role = Role.Checkbox
|
||||||
)
|
)
|
||||||
.padding(horizontal = 16.dp),
|
.padding(horizontal = 16.dp),
|
||||||
@@ -153,7 +190,9 @@ fun MainScreen(gdInstalled: Boolean = true) {
|
|||||||
modifier = Modifier.padding(start = 16.dp)
|
modifier = Modifier.padding(start = 16.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Button(onClick = { /* TODO: add geode folder open */ }) {
|
Button(
|
||||||
|
onClick = { onOpenFolder(context) }
|
||||||
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
Icons.Filled.ExitToApp,
|
Icons.Filled.ExitToApp,
|
||||||
contentDescription = "Folder Icon"
|
contentDescription = "Folder Icon"
|
||||||
@@ -163,7 +202,6 @@ fun MainScreen(gdInstalled: Boolean = true) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview(showSystemUi = true)
|
@Preview(showSystemUi = true)
|
||||||
|
|||||||
@@ -2,4 +2,7 @@
|
|||||||
<string name="app_name">Geode</string>
|
<string name="app_name">Geode</string>
|
||||||
<string name="title_activity_geometry_dash">GeometryDash</string>
|
<string name="title_activity_geometry_dash">GeometryDash</string>
|
||||||
<string name="failed_mod_core">Failed to load mod core.</string>
|
<string name="failed_mod_core">Failed to load mod core.</string>
|
||||||
|
<string name="no_activity_found">No activity found for this action.</string>
|
||||||
|
<string name="preference_file_key">GeodeLauncherPreferencesFileKey</string>
|
||||||
|
<string name="preference_load_testing">PreferenceLoadTesting</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in new issue
Block a user