feat: opensource licenses screen

This commit is contained in:
Ushie 2022-10-02 16:45:59 +03:00
parent d4443d309e
commit bd2424611d
No known key found for this signature in database
GPG Key ID: 0EF73F1CA38B2D5F
8 changed files with 85 additions and 5 deletions

1
.gitignore vendored
View File

@ -79,3 +79,4 @@ lint/outputs/
lint/tmp/
*.hprof
/.idea/deploymentTargetDropDown.xml
.idea/discord.xml

View File

@ -3,6 +3,7 @@ plugins {
id("org.jetbrains.kotlin.android")
id("com.google.devtools.ksp")
id("kotlin-parcelize")
id("com.mikepenz.aboutlibraries.plugin") version "10.4.0"
kotlin("plugin.serialization") version "1.7.10"
}
@ -127,4 +128,6 @@ dependencies {
implementation("org.bouncycastle:bcpkix-jdk15on:1.70")
implementation("com.android.tools.build:apksig:7.2.2")
// Licenses
implementation("com.mikepenz:aboutlibraries-compose:10.4.0")
}

View File

@ -17,6 +17,7 @@ import app.revanced.manager.ui.navigation.AppDestination
import app.revanced.manager.ui.screen.MainDashboardScreen
import app.revanced.manager.ui.screen.PatchingScreen
import app.revanced.manager.ui.screen.subscreens.AppSelectorSubscreen
import app.revanced.manager.ui.screen.subscreens.LicensesSubscreen
import app.revanced.manager.ui.screen.subscreens.PatchesSelectorSubscreen
import app.revanced.manager.ui.theme.ReVancedManagerTheme
import app.revanced.manager.ui.theme.Theme
@ -51,6 +52,7 @@ class MainActivity : ComponentActivity() {
is AppDestination.Dashboard -> MainDashboardScreen(navigator = navigator)
is AppDestination.AppSelector -> AppSelectorSubscreen(navigator = navigator)
is AppDestination.PatchSelector -> PatchesSelectorSubscreen(navigator = navigator)
is AppDestination.Licenses -> LicensesSubscreen(navigator = navigator)
is AppDestination.Patcher -> PatchingScreen(navigator = navigator)
}
}

View File

@ -24,6 +24,9 @@ sealed interface AppDestination : Destination {
@Parcelize
object Patcher : AppDestination
@Parcelize
object Licenses : AppDestination
}
@Parcelize

View File

@ -72,7 +72,9 @@ fun MainDashboardScreen(navigator: BackstackNavigator<AppDestination>) {
onClickPatchSelector = { navigator.push(AppDestination.PatchSelector) },
onClickPatch = { navigator.push(AppDestination.Patcher) },
)
DashboardDestination.SETTINGS -> SettingsScreen()
DashboardDestination.SETTINGS -> SettingsScreen(
onClickLicenses = { navigator.push(AppDestination.Licenses) }
)
}
}
}

View File

@ -7,6 +7,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Code
import androidx.compose.material.icons.filled.LibraryBooks
import androidx.compose.material.icons.filled.Palette
import androidx.compose.material.icons.filled.Style
import androidx.compose.material3.*
@ -26,7 +27,10 @@ import org.koin.androidx.compose.getViewModel
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingsScreen(viewModel: SettingsViewModel = getViewModel()) {
fun SettingsScreen(
onClickLicenses: () -> Unit,
viewModel: SettingsViewModel = getViewModel()
) {
val prefs = viewModel.prefs
Column(
@ -47,9 +51,11 @@ fun SettingsScreen(viewModel: SettingsViewModel = getViewModel()) {
modifier = Modifier.clickable { viewModel.showThemePicker() },
headlineText = { Text(stringResource(R.string.theme)) },
leadingContent = { Icon(Icons.Default.Style, contentDescription = null) },
trailingContent = { FilledTonalButton(onClick = { viewModel.showThemePicker() }) {
trailingContent = {
FilledTonalButton(onClick = { viewModel.showThemePicker() }) {
Text(text = prefs.theme.displayName)
} }
}
}
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
ListItem(
@ -66,6 +72,11 @@ fun SettingsScreen(viewModel: SettingsViewModel = getViewModel()) {
}
Divider()
ListItem(
modifier = Modifier.clickable(onClick = onClickLicenses),
headlineText = { Text(stringResource(R.string.opensource_licenses)) },
leadingContent = { Icon(Icons.Default.LibraryBooks, contentDescription = null) },
)
SocialItem(R.string.github, Icons.Default.Code, viewModel::openGitHub)
}
}

View File

@ -0,0 +1,57 @@
package app.revanced.manager.ui.screen.subscreens
import androidx.compose.foundation.layout.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.res.stringResource
import app.revanced.manager.R
import app.revanced.manager.ui.navigation.AppDestination
import com.mikepenz.aboutlibraries.ui.compose.LibrariesContainer
import com.mikepenz.aboutlibraries.ui.compose.LibraryDefaults
import com.xinto.taxi.BackstackNavigator
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun LicensesSubscreen(
navigator: BackstackNavigator<AppDestination>,
) {
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(
state = rememberTopAppBarState(),
canScroll = { true }
)
Scaffold(
modifier = Modifier
.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
LargeTopAppBar(
title = { Text(stringResource(R.string.opensource_licenses)) },
navigationIcon = {
IconButton(onClick = navigator::pop) {
Icon(
imageVector = Icons.Default.ArrowBack,
contentDescription = null
)
}
},
scrollBehavior = scrollBehavior
)
}
) { paddingValues ->
Column(modifier = Modifier.padding(paddingValues)) {
LibrariesContainer(
modifier = Modifier
.fillMaxSize(),
colors = LibraryDefaults.libraryColors(
backgroundColor = MaterialTheme.colorScheme.background,
contentColor = MaterialTheme.colorScheme.onBackground,
badgeBackgroundColor = MaterialTheme.colorScheme.primary,
badgeContentColor = MaterialTheme.colorScheme.onPrimary,
),
)
}
}
}

View File

@ -78,4 +78,5 @@
<string name="apply">Apply</string>
<string name="warning">Warning</string>
<string name="split_apk_warning">You have selected a resource patch and a split APK installation was detected so patching errors can occur.\nAre you sure you want to proceed with patching a split base APK?</string>
<string name="opensource_licenses">Open source licenses</string>
</resources>