Skip to content

Commit

Permalink
✨ Open source licenses: include screen to display them
Browse files Browse the repository at this point in the history
  • Loading branch information
berlix committed Jun 25, 2024
1 parent 08f883d commit 90a0d1e
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 22 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ buildscript {
classpath("io.objectbox:objectbox-gradle-plugin:${Versions.objectBox}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
classpath("com.google.dagger:hilt-android-gradle-plugin:${Versions.hilt}")
classpath("com.google.android.gms:oss-licenses-plugin:0.10.6")

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
3 changes: 3 additions & 0 deletions integration-test-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins {
id("dagger.hilt.android.plugin")
kotlin("plugin.serialization") version Versions.kotlin
id("org.jetbrains.kotlin.plugin.compose") version Versions.kotlin
id("com.google.android.gms.oss-licenses-plugin")
}

val version = getAppVersion()
Expand Down Expand Up @@ -78,6 +79,7 @@ dependencies {
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.2")
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
implementation("com.google.android.gms:play-services-oss-licenses:17.1.0")

// Compose
implementation("androidx.compose.ui:ui:${Versions.compose}")
Expand All @@ -88,6 +90,7 @@ dependencies {
implementation("androidx.navigation:navigation-compose:${Versions.navigation}")
implementation("androidx.compose.material:material-icons-extended:${Versions.compose}")
implementation("androidx.activity:activity-compose:1.9.0")
debugImplementation("androidx.compose.ui:ui-tooling:${Versions.compose}")

// Hilt/Dagger DI
implementation("com.google.dagger:hilt-android:${Versions.hilt}")
Expand Down
9 changes: 9 additions & 0 deletions integration-test-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,14 @@
android:name=".infrastructure.AssetProvider"
android:exported="true"
tools:ignore="ExportedContentProvider" />

<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/Theme.EIDUIntegrationTestApp" />

<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/Theme.EIDUIntegrationTestApp" />

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.eidu.integration.test.app.ui.screens.LearningUnitsScreen
import com.eidu.integration.test.app.ui.theme.EIDUIntegrationTestAppTheme
import com.eidu.integration.test.app.ui.viewmodel.LearningAppViewModel
import com.eidu.integration.test.app.ui.viewmodel.Result
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand Down Expand Up @@ -73,11 +74,13 @@ class MainActivity : ComponentActivity() {
learningApps.value,
learningAppViewModel.importStatus,
learningAppViewModel::dismissStatus,
{ learningApp -> navController.navigate("learning-apps/${learningApp.packageName}/units") },
{ learningApp -> learningAppViewModel.deleteLearningApp(learningApp) },
{ learningApp -> navController.navigate("learning-apps/${learningApp.packageName}/edit") },
{ packageFilePicker.launch(arrayOf("application/zip")) }
) { navController.navigate("learning-apps/create") }
navigateToUnits = { learningApp -> navController.navigate("learning-apps/${learningApp.packageName}/units") },
deleteLearningApp = { learningApp -> learningAppViewModel.deleteLearningApp(learningApp) },
editLearningApp = { learningApp -> navController.navigate("learning-apps/${learningApp.packageName}/edit") },
openFilePicker = { packageFilePicker.launch(arrayOf("application/zip")) },
addLearningApp = { navController.navigate("learning-apps/create") },
navigateToOpenSourceLicenses = { startActivity(Intent(this@MainActivity, OssLicensesMenuActivity::class.java)) }
)
}
composable("learning-apps/{app}/units") { backStackEntry ->
when (val app: Result<LearningApp> = getAppNameState(backStackEntry)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.material.FloatingActionButton
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.ListItem
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.material.icons.Icons
Expand Down Expand Up @@ -60,7 +61,8 @@ fun LearningAppsScreen(
deleteLearningApp: (app: LearningApp) -> Unit,
editLearningApp: (app: LearningApp) -> Unit,
openFilePicker: () -> Unit,
addLearningApp: () -> Unit
addLearningApp: () -> Unit,
navigateToOpenSourceLicenses: () -> Unit
) {
val currentStatus = importStatus.observeAsState().value

Expand Down Expand Up @@ -129,14 +131,24 @@ fun LearningAppsScreen(
ListItem(
modifier = Modifier.padding(vertical = 8.dp),
text = {
Text(
"Upload your learning package to this device (e.g. `adb push learning-package.zip" +
" /sdcard/`) and add it via 'Add learning package', or" +
" add an app manually if you don't have a learning package yet.\n\n" +
"Note: You need to install the APK yourself!",
fontSize = 12.sp,
lineHeight = 18.sp
)
Column() {
Text(
"Upload your learning package to this device (e.g. `adb push learning-package.zip" +
" /sdcard/`) and add it via 'Add learning package', or" +
" add an app manually if you don't have a learning package yet.\n\n" +
"Note: You need to install the APK yourself!",
fontSize = 12.sp,
lineHeight = 18.sp
)
Spacer(modifier = Modifier.height(16.dp))
Text(
text = "View open source licenses",
fontSize = 12.sp,
lineHeight = 18.sp,
color = MaterialTheme.colors.primary,
modifier = Modifier.clickable { navigateToOpenSourceLicenses() }
)
}
},
icon = { Icon(Icons.Default.Info, "How to add a learning package") }
)
Expand Down Expand Up @@ -223,8 +235,10 @@ private fun LearningAppScreenPreview() {
navigateToUnits = {},
deleteLearningApp = {},
editLearningApp = {},
openFilePicker = {}
) {}
openFilePicker = {},
addLearningApp = {},
navigateToOpenSourceLicenses = {}
)
}

@Preview(showBackground = true, device = Devices.NEXUS_5)
Expand All @@ -237,8 +251,10 @@ private fun LearningAppScreenPreviewLoading() {
navigateToUnits = {},
deleteLearningApp = {},
editLearningApp = {},
openFilePicker = {}
) {}
openFilePicker = {},
addLearningApp = {},
navigateToOpenSourceLicenses = {}
)
}

@Preview(showBackground = true, device = Devices.NEXUS_5)
Expand All @@ -251,8 +267,10 @@ private fun LearningAppScreenPreviewSuccess() {
navigateToUnits = {},
deleteLearningApp = {},
editLearningApp = {},
openFilePicker = {}
) {}
openFilePicker = {},
addLearningApp = {},
navigateToOpenSourceLicenses = {}
)
}

@Preview(showBackground = true, device = Devices.NEXUS_5)
Expand All @@ -265,6 +283,8 @@ private fun LearningAppScreenPreviewError() {
navigateToUnits = {},
deleteLearningApp = {},
editLearningApp = {},
openFilePicker = {}
) {}
openFilePicker = {},
addLearningApp = {},
navigateToOpenSourceLicenses = {}
)
}

0 comments on commit 90a0d1e

Please sign in to comment.