generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into config-rework
Signed-off-by: Mr-Kanister <[email protected]>
- Loading branch information
Showing
39 changed files
with
914 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
frontend/app/src/main/java/de/amosproj3/ziofa/api/InstalledPackageInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// SPDX-FileCopyrightText: 2024 Luca Bretting <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
package de.amosproj3.ziofa.api | ||
|
||
import android.graphics.drawable.Drawable | ||
|
||
data class InstalledPackageInfo(val displayName: String, val icon: Drawable) |
39 changes: 39 additions & 0 deletions
39
frontend/app/src/main/java/de/amosproj3/ziofa/bl/PackageInformationProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-FileCopyrightText: 2024 Luca Bretting <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
package de.amosproj3.ziofa.bl | ||
|
||
import android.content.pm.PackageInfo | ||
import android.content.pm.PackageManager | ||
import android.graphics.drawable.Drawable | ||
import de.amosproj3.ziofa.api.InstalledPackageInfo | ||
import timber.log.Timber | ||
|
||
class PackageInformationProvider(private val packageManager: PackageManager) { | ||
|
||
private val installedPackages: Map<String, PackageInfo> by lazy { | ||
packageManager.getInstalledPackages(PackageManager.GET_META_DATA).associateBy { | ||
it.packageName | ||
} | ||
} | ||
|
||
/** | ||
* Returns the [InstalledPackageInfo] or null if: | ||
* - an error occurred | ||
* - the application info was not found | ||
* - the package name was not found in the installed packages. | ||
*/ | ||
fun getPackageInfo(packageName: String): InstalledPackageInfo? { | ||
return try { | ||
installedPackages[packageName]?.applicationInfo?.let { | ||
val displayName = packageManager.getApplicationLabel(it).toString() | ||
val appIcon: Drawable = packageManager.getApplicationIcon(it) | ||
InstalledPackageInfo(displayName, appIcon) | ||
} | ||
} catch (e: Exception) { | ||
Timber.w(e.stackTraceToString()) | ||
return null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
frontend/app/src/main/java/de/amosproj3/ziofa/ui/navigation/ConfigurationMenu.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// SPDX-FileCopyrightText: 2024 Luca Bretting <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
package de.amosproj3.ziofa.ui.navigation | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import de.amosproj3.ziofa.ui.navigation.composables.MenuOptionData | ||
import de.amosproj3.ziofa.ui.navigation.composables.MenuOptions | ||
import de.amosproj3.ziofa.ui.navigation.data.Emoji | ||
|
||
@Composable | ||
fun ConfigurationMenu( | ||
modifier: Modifier = Modifier, | ||
toPresets: () -> Unit, | ||
toProcesses: () -> Unit, | ||
toGlobalConfiguration: () -> Unit, | ||
) { | ||
|
||
Box( | ||
modifier = | ||
modifier | ||
.fillMaxSize() | ||
.background(MaterialTheme.colorScheme.background) | ||
.padding(horizontal = 50.dp, vertical = 40.dp) | ||
) { | ||
Column(modifier = Modifier.fillMaxWidth()) { | ||
MenuOptions( | ||
menuOptions = | ||
listOf( | ||
MenuOptionData( | ||
title = "Presets", | ||
logoEmoji = Emoji.Bookmarks.unicode, | ||
onClick = toPresets, | ||
), | ||
MenuOptionData( | ||
title = "Global", | ||
logoEmoji = Emoji.Globe.unicode, | ||
onClick = toGlobalConfiguration, | ||
), | ||
MenuOptionData( | ||
title = "Per Process", | ||
logoEmoji = Emoji.MagnifyingGlass.unicode, | ||
onClick = toProcesses, | ||
), | ||
) | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.