| author | Da Risk <da_risk@geekorum.com> | 
| Tue, 06 May 2025 12:55:03 -0400 | |
| changeset 89 | 0cc872a9edbf | 
| parent 47 | 246422783c0c | 
| permissions | -rw-r--r-- | 
| 15 | 1  | 
/*  | 
2  | 
* AboutOss is an utility library to retrieve and display  | 
|
3  | 
* opensource licenses in Android applications.  | 
|
4  | 
*  | 
|
| 
34
 
ce299aacc068
build: update license headers
 
Da Risk <da_risk@geekorum.com> 
parents: 
18 
diff
changeset
 | 
5  | 
* Copyright (C) 2023-2025 by Frederic-Charles Barthelery.  | 
| 15 | 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  | 
||
| 
18
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
24  | 
import android.content.Intent  | 
| 15 | 25  | 
import android.os.Bundle  | 
26  | 
import androidx.activity.ComponentActivity  | 
|
27  | 
import androidx.activity.compose.setContent  | 
|
| 
89
 
0cc872a9edbf
sample: make android sample edge to edge and target sdk 35
 
Da Risk <da_risk@geekorum.com> 
parents: 
47 
diff
changeset
 | 
28  | 
import androidx.activity.enableEdgeToEdge  | 
| 15 | 29  | 
import com.geekorum.aboutoss.sampleapp.ui.theme.AboutOssTheme  | 
| 
18
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
30  | 
import com.geekorum.aboutoss.sampleapp.ui.theme.OpenSourceLicenseTheme  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
31  | 
import com.geekorum.aboutoss.ui.material3.OpenSourceLicensesActivity  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
32  | 
import com.geekorum.aboutoss.ui.material.OpenSourceLicensesActivity as Material2OpenSourceLicensesActivity  | 
| 15 | 33  | 
|
34  | 
class MainActivity : ComponentActivity() {
 | 
|
35  | 
    override fun onCreate(savedInstanceState: Bundle?) {
 | 
|
36  | 
super.onCreate(savedInstanceState)  | 
|
| 
89
 
0cc872a9edbf
sample: make android sample edge to edge and target sdk 35
 
Da Risk <da_risk@geekorum.com> 
parents: 
47 
diff
changeset
 | 
37  | 
enableEdgeToEdge()  | 
| 15 | 38  | 
        setContent {
 | 
39  | 
            AboutOssTheme {
 | 
|
| 
47
 
246422783c0c
sample: extract base of sample to common. start implementing desktop
 
Da Risk <da_risk@geekorum.com> 
parents: 
44 
diff
changeset
 | 
40  | 
SampleApp(  | 
| 
18
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
41  | 
                    onMaterial2Click = {
 | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
42  | 
startMaterial2LicenseActivity()  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
43  | 
},  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
44  | 
                    onMaterial3Click = {
 | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
45  | 
startMaterial3LicenseActivity()  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
46  | 
}  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
47  | 
)  | 
| 15 | 48  | 
}  | 
49  | 
}  | 
|
50  | 
}  | 
|
| 
18
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
51  | 
|
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
52  | 
    private fun startMaterial2LicenseActivity() {
 | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
53  | 
        val intent = if (BuildConfig.DEBUG) {
 | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
54  | 
// we launch a custom activity in debug to display some fake licenses  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
55  | 
// see Material2AcPrebuiltLicencesMaterial2Activitytivity for more info  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
56  | 
Intent(this, PrebuiltLicencesMaterial2Activity::class.java)  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
57  | 
        } else {
 | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
58  | 
Intent(this, Material2OpenSourceLicensesActivity::class.java)  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
59  | 
}  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
60  | 
startActivity(intent)  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
61  | 
}  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
62  | 
|
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
63  | 
    private fun startMaterial3LicenseActivity() {
 | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
64  | 
// Don't use default MaterialTheme but supply our own  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
65  | 
        OpenSourceLicensesActivity.themeProvider = { content ->
 | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
66  | 
OpenSourceLicenseTheme(content)  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
67  | 
}  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
68  | 
        val intent = if (BuildConfig.DEBUG) {
 | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
69  | 
// we launch a custom activity in debug to display some fake licenses  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
70  | 
// see PrebuiltLicencesMaterial3Activity for more info  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
71  | 
Intent(this, PrebuiltLicencesMaterial3Activity::class.java)  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
72  | 
        } else {
 | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
73  | 
Intent(this, OpenSourceLicensesActivity::class.java)  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
74  | 
}  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
75  | 
startActivity(intent)  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
76  | 
}  | 
| 
 
ac393491d2eb
sample: complete sample application
 
Da Risk <da_risk@geekorum.com> 
parents: 
15 
diff
changeset
 | 
77  | 
}  |