1 /* |
|
2 * AboutOss is an utility library to retrieve and display |
|
3 * opensource licenses in Android applications. |
|
4 * |
|
5 * Copyright (C) 2023-2025 by Frederic-Charles Barthelery. |
|
6 * |
|
7 * This file is part of AboutOss. |
|
8 * |
|
9 * AboutOss is free software: you can redistribute it and/or modify |
|
10 * it under the terms of the GNU General Public License as published by |
|
11 * the Free Software Foundation, either version 3 of the License, or |
|
12 * (at your option) any later version. |
|
13 * |
|
14 * AboutOss is distributed in the hope that it will be useful, |
|
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 * GNU General Public License for more details. |
|
18 * |
|
19 * You should have received a copy of the GNU General Public License |
|
20 * along with AboutOss. If not, see <http://www.gnu.org/licenses/>. |
|
21 */ |
|
22 package com.geekorum.aboutoss.sampleapp |
|
23 |
|
24 import android.content.Intent |
|
25 import android.os.Bundle |
|
26 import androidx.activity.ComponentActivity |
|
27 import androidx.activity.compose.setContent |
|
28 import androidx.activity.enableEdgeToEdge |
|
29 import com.geekorum.aboutoss.sampleapp.ui.theme.AboutOssTheme |
|
30 import com.geekorum.aboutoss.sampleapp.ui.theme.OpenSourceLicenseTheme |
|
31 import com.geekorum.aboutoss.ui.material3.OpenSourceLicensesActivity |
|
32 import com.geekorum.aboutoss.ui.material.OpenSourceLicensesActivity as Material2OpenSourceLicensesActivity |
|
33 |
|
34 class MainActivity : ComponentActivity() { |
|
35 override fun onCreate(savedInstanceState: Bundle?) { |
|
36 super.onCreate(savedInstanceState) |
|
37 enableEdgeToEdge() |
|
38 setContent { |
|
39 AboutOssTheme { |
|
40 SampleApp( |
|
41 onMaterial2Click = { |
|
42 startMaterial2LicenseActivity() |
|
43 }, |
|
44 onMaterial3Click = { |
|
45 startMaterial3LicenseActivity() |
|
46 } |
|
47 ) |
|
48 } |
|
49 } |
|
50 } |
|
51 |
|
52 private fun startMaterial2LicenseActivity() { |
|
53 val intent = if (BuildConfig.DEBUG) { |
|
54 // we launch a custom activity in debug to display some fake licenses |
|
55 // see Material2AcPrebuiltLicencesMaterial2Activitytivity for more info |
|
56 Intent(this, PrebuiltLicencesMaterial2Activity::class.java) |
|
57 } else { |
|
58 Intent(this, Material2OpenSourceLicensesActivity::class.java) |
|
59 } |
|
60 startActivity(intent) |
|
61 } |
|
62 |
|
63 private fun startMaterial3LicenseActivity() { |
|
64 // Don't use default MaterialTheme but supply our own |
|
65 OpenSourceLicensesActivity.themeProvider = { content -> |
|
66 OpenSourceLicenseTheme(content) |
|
67 } |
|
68 val intent = if (BuildConfig.DEBUG) { |
|
69 // we launch a custom activity in debug to display some fake licenses |
|
70 // see PrebuiltLicencesMaterial3Activity for more info |
|
71 Intent(this, PrebuiltLicencesMaterial3Activity::class.java) |
|
72 } else { |
|
73 Intent(this, OpenSourceLicensesActivity::class.java) |
|
74 } |
|
75 startActivity(intent) |
|
76 } |
|
77 } |
|