Skip to content

Commit

Permalink
Replace licenses viewer with FOSS version
Browse files Browse the repository at this point in the history
  • Loading branch information
fibelatti committed Jan 13, 2024
1 parent 3673cfb commit 435f486
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 19 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
alias(libs.plugins.ksp)
alias(libs.plugins.hilt)
alias(libs.plugins.room)
id("com.google.android.gms.oss-licenses-plugin")
alias(libs.plugins.about.libraries)
}

val jacocoEnabled: Boolean by project
Expand Down Expand Up @@ -213,7 +213,7 @@ dependencies {

implementation(libs.jsoup)

implementation(libs.oss.licenses.library)
implementation(libs.about.libraries)

debugImplementation(libs.leakcanary)

Expand Down
7 changes: 2 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,8 @@
</activity>

<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/AppTheme.WithActionBar" />
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/AppTheme.WithActionBar" />
android:name=".features.licenses.OssLicensesActivity"
android:exported="false" />

<provider
android:name="androidx.startup.InitializationProvider"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.fibelatti.pinboard.features.licenses

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import com.fibelatti.pinboard.R
import com.fibelatti.pinboard.core.android.composable.AppTheme
import com.mikepenz.aboutlibraries.ui.compose.LibrariesContainer
import com.mikepenz.aboutlibraries.ui.compose.LibraryDefaults
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class OssLicensesActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContent {
AppTheme {
OssLicensesScreen()
}
}
}

@Composable
@OptIn(ExperimentalFoundationApi::class)
private fun OssLicensesScreen() {
LibrariesContainer(
modifier = Modifier.fillMaxSize(),
colors = LibraryDefaults.libraryColors(
backgroundColor = MaterialTheme.colorScheme.background,
contentColor = MaterialTheme.colorScheme.onBackground,
badgeBackgroundColor = MaterialTheme.colorScheme.primaryContainer,
badgeContentColor = MaterialTheme.colorScheme.onPrimaryContainer,
dialogConfirmButtonColor = MaterialTheme.colorScheme.primary,
),
header = {
stickyHeader {
Row(
modifier = Modifier
.fillMaxWidth()
.background(color = MaterialTheme.colorScheme.background),
) {
IconButton(onClick = { finish() }) {
Icon(
painter = painterResource(id = R.drawable.ic_back_arrow),
contentDescription = "",
tint = MaterialTheme.colorScheme.primary,
)
}
}
}
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.fibelatti.core.extension.shareText
import com.fibelatti.pinboard.R
import com.fibelatti.pinboard.core.AppConfig
import com.fibelatti.pinboard.core.android.ComposeBottomSheetDialog
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
import com.fibelatti.pinboard.features.licenses.OssLicensesActivity

object NavigationMenu {

Expand All @@ -32,7 +32,7 @@ object NavigationMenu {
activity.startActivity(intent)
},
onLicensesClicked = {
activity.startActivity(Intent(activity, OssLicensesMenuActivity::class.java))
activity.startActivity(Intent(activity, OssLicensesActivity::class.java))
},
onOptionSelected = { dismiss() },
)
Expand Down
6 changes: 2 additions & 4 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<item name="android:navigationBarColor">@color/color_navigation_bar</item>
<item name="android:windowBackground">@color/color_background</item>

<item name="colorPrimary">#0051E1</item>

<item name="android:windowAnimationStyle">@style/AppTheme.AppActivityAnimation</item>

<item name="enableEdgeToEdge">true</item>
Expand All @@ -14,10 +16,6 @@
<item name="materialAlertDialogTheme">@style/AppTheme.MaterialDialog</item>
</style>

<style name="AppTheme.WithActionBar" parent="Theme.Material3.DayNight">
<item name="colorPrimary">#0051E1</item>
</style>

<style name="AppTheme.Overlay" parent="ThemeOverlay.Material3.DynamicColors.DayNight">
<item name="android:colorBackground">@color/color_background</item>
</style>
Expand Down
5 changes: 1 addition & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ plugins {
alias(libs.plugins.hilt) apply false
alias(libs.plugins.spotless) apply false
alias(libs.plugins.cache.fix) apply false
alias(libs.plugins.about.libraries) apply false
}

buildscript {
Expand All @@ -21,10 +22,6 @@ buildscript {

val jacocoEnabled: String? by project
extra["jacocoEnabled"] = jacocoEnabled?.toBoolean() ?: false

dependencies {
classpath(libs.oss.licenses.plugin)
}
}

allprojects {
Expand Down
5 changes: 3 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ moshi = "1.15.0"
okhttp = "4.12.0"
retrofit = "2.9.0"
room = "2.6.1"
aboutLibraries = "10.10.0"
junit5 = "5.10.1"

[libraries]
Expand Down Expand Up @@ -61,8 +62,7 @@ converter-moshi = { module = "com.squareup.retrofit2:converter-moshi", version.r

jsoup = { module = "org.jsoup:jsoup", version = "1.17.2" }

oss-licenses-plugin = { module = "com.google.android.gms:oss-licenses-plugin", version = "0.10.6" }
oss-licenses-library = { module = "com.google.android.gms:play-services-oss-licenses", version = "17.0.1" }
about-libraries = { module = "com.mikepenz:aboutlibraries-compose", version.ref = "aboutLibraries" }

leakcanary = { module = "com.squareup.leakcanary:leakcanary-android", version = "2.13" }

Expand Down Expand Up @@ -98,3 +98,4 @@ hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
room = { id = "androidx.room", version.ref = "room" }
spotless = { id = "com.diffplug.spotless", version = "6.23.3" }
cache-fix = { id = "org.gradle.android.cache-fix", version = "3.0" }
about-libraries = { id = "com.mikepenz.aboutlibraries.plugin", version.ref = "aboutLibraries" }

0 comments on commit 435f486

Please sign in to comment.