Skip to content

Commit c56104c

Browse files
committed
Version 1.4: license page and privacy declaration
1 parent b815413 commit c56104c

File tree

6 files changed

+118
-48
lines changed

6 files changed

+118
-48
lines changed

app/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'com.android.application'
33
id 'org.jetbrains.kotlin.android'
4+
id 'com.mikepenz.aboutlibraries.plugin'
45
}
56

67
Properties properties = new Properties()
@@ -16,8 +17,8 @@ android {
1617
applicationId "com.henrikherzig.playintegritychecker"
1718
minSdk 26
1819
targetSdk 33
19-
versionCode 6
20-
versionName "1.3.0"
20+
versionCode 7
21+
versionName "1.4.0"
2122

2223
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2324
vectorDrawables {
@@ -87,6 +88,8 @@ dependencies {
8788

8889
implementation "com.google.accompanist:accompanist-pager:0.23.1"
8990

91+
implementation "com.mikepenz:aboutlibraries-compose:10.5.2"
92+
9093
testImplementation 'junit:junit:4.13.2'
9194
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
9295
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

app/src/main/java/com/henrikherzig/playintegritychecker/ui/about/AboutPage.kt

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ package com.henrikherzig.playintegritychecker.ui.about
33
import androidx.compose.foundation.layout.*
44
import androidx.compose.foundation.rememberScrollState
55
import androidx.compose.foundation.verticalScroll
6-
import androidx.compose.material.Text
6+
import androidx.compose.material.*
77
import androidx.compose.material.icons.Icons
88
import androidx.compose.material.icons.outlined.Code
99
import androidx.compose.material.icons.outlined.OpenInNew
10+
import androidx.compose.material.icons.outlined.ReadMore
1011
import androidx.compose.runtime.Composable
12+
import androidx.compose.runtime.mutableStateOf
13+
import androidx.compose.runtime.remember
1114
import androidx.compose.ui.Alignment
1215
import androidx.compose.ui.Modifier
1316
import androidx.compose.ui.platform.LocalContext
1417
import androidx.compose.ui.res.stringResource
1518
import androidx.compose.ui.unit.dp
19+
import androidx.navigation.NavHostController
1620
import com.henrikherzig.playintegritychecker.R
17-
import androidx.compose.material.icons.outlined.ReadMore
18-
import com.henrikherzig.playintegritychecker.ui.CustomButton
19-
import com.henrikherzig.playintegritychecker.ui.CustomCard
20-
import com.henrikherzig.playintegritychecker.ui.CustomCardTitle
21-
import com.henrikherzig.playintegritychecker.ui.openLink
21+
import com.henrikherzig.playintegritychecker.ui.*
2222

2323
@Composable
24-
fun AboutPage(playServiceVersion: String?) {
24+
fun AboutPage(navController: NavHostController) {
2525
val context = LocalContext.current
2626
Box(
2727
modifier = Modifier
@@ -86,11 +86,10 @@ fun AboutPage(playServiceVersion: String?) {
8686
Row(
8787
modifier = Modifier
8888
.fillMaxWidth(),
89-
//.padding(16.dp),
9089
horizontalArrangement = Arrangement.spacedBy(16.dp)
9190
) {
9291
/* workaround: .weight is not accessible in button directly and also not if box
93-
is extracted to other method, have to investigate this */
92+
is extracted to other method */
9493
Box(
9594
modifier = Modifier
9695
.fillMaxWidth()
@@ -131,26 +130,35 @@ fun AboutPage(playServiceVersion: String?) {
131130
.fillMaxWidth()
132131
.weight(1f)
133132
) {
134-
/* Source Code Link */
133+
/* License */
134+
val openedRecognition = remember { mutableStateOf(false) }
135135
CustomButton(
136-
{ },
136+
{ openedRecognition.value = true },
137137
Icons.Outlined.ReadMore,
138138
stringResource(id = R.string.about_licenseButton)
139139
)
140+
if (openedRecognition.value) {
141+
openedRecognition.value=false
142+
navController.navigate("licence") {
143+
144+
}
145+
}
140146
}
141147
Box(
142148
modifier = Modifier
143149
.fillMaxWidth()
144150
.weight(1f)
145151
) {
146-
/* Play Integrity API Link */
152+
/* Privacy */
153+
val link = stringResource(id = R.string.about_privacyLink)
147154
CustomButton(
148-
{ },
155+
{ openLink(link, context) },
149156
Icons.Outlined.ReadMore,
150157
stringResource(id = R.string.about_privacyButton) // policy
151158
)
152159
}
153160
}
161+
154162
}
155163
}
156164
}

app/src/main/java/com/henrikherzig/playintegritychecker/ui/navigationbar/NavigationBarWrapper.kt

Lines changed: 78 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@ package com.henrikherzig.playintegritychecker.ui.navigationbar
22

33
import androidx.compose.foundation.isSystemInDarkTheme
44
import androidx.compose.foundation.layout.*
5+
import androidx.compose.foundation.rememberScrollState
6+
import androidx.compose.foundation.verticalScroll
57
import androidx.compose.material.*
8+
import androidx.compose.material.icons.Icons
9+
import androidx.compose.material.icons.filled.ArrowBack
610
import androidx.compose.runtime.*
711
import androidx.compose.runtime.livedata.observeAsState
812
import androidx.compose.ui.Alignment
913
import androidx.compose.ui.Modifier
1014
import androidx.compose.ui.graphics.Color
1115
import androidx.compose.ui.platform.LocalContext
16+
import androidx.compose.ui.res.painterResource
1217
import androidx.compose.ui.res.stringResource
18+
import androidx.compose.ui.text.style.TextAlign
19+
import androidx.compose.ui.unit.dp
1320
import androidx.compose.ui.unit.sp
1421
import androidx.navigation.NavDestination.Companion.hierarchy
1522
import androidx.navigation.NavGraph.Companion.findStartDestination
@@ -22,12 +29,14 @@ import com.henrikherzig.playintegritychecker.R
2229
import com.henrikherzig.playintegritychecker.attestation.PlayIntegrityStatement
2330
import com.henrikherzig.playintegritychecker.attestation.safetynet.SafetyNetStatement
2431
import com.henrikherzig.playintegritychecker.dataStore
32+
import com.henrikherzig.playintegritychecker.ui.CustomCardTitle
2533
import com.henrikherzig.playintegritychecker.ui.about.AboutPage
2634
import com.henrikherzig.playintegritychecker.ui.playintegrity.PlayIntegrity
2735
import com.henrikherzig.playintegritychecker.ui.safetynet.SafetyNet
2836
import com.henrikherzig.playintegritychecker.ui.ResponseType
2937
import com.henrikherzig.playintegritychecker.ui.settings.Settings
3038
import com.henrikherzig.playintegritychecker.ui.CustomViewModel
39+
import com.mikepenz.aboutlibraries.ui.compose.LibrariesContainer
3140

3241
@Composable
3342
fun BottomNavigationBar(
@@ -47,6 +56,7 @@ fun BottomNavigationBar(
4756
BottomNavItem.Settings,
4857
BottomNavItem.About,
4958
)
59+
val navBackStackEntry by navController.currentBackStackEntryAsState()
5060

5161
// TODO: very ugly better solution in the future
5262
// check
@@ -87,6 +97,11 @@ fun BottomNavigationBar(
8797
}
8898
val urlValue = viewModel.stateURL.observeAsState().value
8999

100+
val appBarHorizontalPadding = 0.dp
101+
val titleIconModifier = Modifier
102+
.fillMaxHeight()
103+
.width(72.dp - appBarHorizontalPadding)
104+
90105
Scaffold(
91106
topBar = {
92107
TopAppBar(
@@ -95,30 +110,64 @@ fun BottomNavigationBar(
95110
* first line: short app name variant in bigger font
96111
* second line: full app name variant in smaller font
97112
*/
113+
modifier= Modifier.fillMaxWidth(),
98114
title = {
99-
Column(
100-
modifier = Modifier.fillMaxSize(),
101-
verticalArrangement = Arrangement.Center,
102-
) {
103-
Text(
104-
text = stringResource(id = R.string.app_name_short),
105-
style = MaterialTheme.typography.subtitle2,
106-
fontSize = 18.sp,
107-
modifier = Modifier.align(Alignment.CenterHorizontally)
108-
)
109-
Text(
110-
text = stringResource(id = R.string.app_name),
111-
style = MaterialTheme.typography.caption,
112-
modifier = Modifier.align(Alignment.CenterHorizontally)
113-
)
115+
// TopAppBar Content
116+
Box(Modifier.height(40.dp)) {
117+
118+
// Navigation Icon
119+
if (navBackStackEntry?.destination?.route == "licence") {
120+
Row(titleIconModifier, verticalAlignment = Alignment.CenterVertically) {
121+
IconButton(
122+
onClick = { navController.navigateUp() },
123+
enabled = true,
124+
) {
125+
Icon(
126+
imageVector = Icons.Filled.ArrowBack,
127+
contentDescription = "Back",
128+
)
129+
}
130+
}
131+
}
132+
133+
// Title
134+
Row(Modifier.fillMaxSize(),
135+
verticalAlignment = Alignment.CenterVertically) {
136+
Column(
137+
modifier = Modifier.fillMaxSize(),
138+
verticalArrangement = Arrangement.Center,
139+
) {
140+
Text(
141+
text = stringResource(id = R.string.app_name_short),
142+
style = MaterialTheme.typography.subtitle2,
143+
fontSize = 18.sp,
144+
modifier = Modifier.align(Alignment.CenterHorizontally)
145+
)
146+
Text(
147+
text = stringResource(id = R.string.app_name),
148+
style = MaterialTheme.typography.caption,
149+
modifier = Modifier.align(Alignment.CenterHorizontally)
150+
)
151+
152+
}
153+
154+
}
155+
156+
// Actions
157+
/* CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
158+
Row(
159+
Modifier.fillMaxHeight(),
160+
horizontalArrangement = Arrangement.End,
161+
verticalAlignment = Alignment.CenterVertically,
162+
){}
163+
} */
114164
}
115165
},
116-
modifier = Modifier.fillMaxWidth()
117166
)
118167
},
119168
bottomBar = {
120169
BottomNavigation {
121-
val navBackStackEntry by navController.currentBackStackEntryAsState()
170+
// val navBackStackEntry by navController.currentBackStackEntryAsState()
122171
val currentDestination = navBackStackEntry?.destination
123172
appPages.forEach { screen ->
124173
BottomNavigationItem(
@@ -134,7 +183,7 @@ fun BottomNavigationBar(
134183
// Avoid multiple versions of same page
135184
launchSingleTop = true
136185
// Restore state when selecting a previous page again
137-
restoreState = true
186+
// restoreState = true
138187
}
139188
}
140189
)
@@ -188,7 +237,17 @@ fun BottomNavigationBar(
188237
Settings(playServiceVersion)
189238
}
190239
composable(BottomNavItem.About.screen_route) {
191-
AboutPage(playServiceVersion)
240+
AboutPage(navController)
241+
}
242+
composable("licence") {
243+
// Licenses Page
244+
Column(
245+
modifier = Modifier
246+
.padding(all = 12.dp)
247+
) {
248+
CustomCardTitle(stringResource(id = R.string.about_licenseButton))
249+
LibrariesContainer()
250+
}
192251
}
193252
}
194253
}

app/src/main/res/values-de-rDE/strings.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,15 @@
9090

9191
<string name="about_api">API Info</string>
9292
<string name="about_api_playIntegrityButton">Play Integrity</string>
93-
<string name="about_api_playIntegrityLink">https://developer.android.com/google/play/integrity</string>
9493
<string name="about_api_safetyNetButton">SafetyNet</string>
95-
<string name="about_api_safetyNetLink">https://developer.android.com/training/safetynet/attestation</string>
9694

9795
<string name="about_sourceCode">Source Code</string>
9896
<string name="about_sourceCode_appButton">Android App</string>
99-
<string name="about_sourceCode_appLink">https://github.com/herzhenr/spic-android</string>
10097
<string name="about_sourceCode_serverButton">Check Server</string>
101-
<string name="about_sourceCode_serverLink">https://github.com/herzhenr/spic-server</string>
10298

10399
<string name="about_licenseAndPrivacy">Lizenz und Privatsphäre</string>
104-
<string name="about_licenseButton">Lizenz</string>
105-
<string name="about_licenseLink">TODO</string>
100+
<string name="about_licenseButton">Lizenzen</string>
106101
<string name="about_privacyButton">Privatsphäre</string>
107-
<string name="about_privacyLink">https://github.com/herzhenr/spic-android/blob/main/privacyPolicy.md</string>
108102

109103
<!-- BottomNavigationBar -->
110104
<string name="bottomBar_playIntegrity">PlayIntegrity</string>

app/src/main/res/values/strings.xml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,20 @@
9191

9292
<string name="about_api">API Info</string>
9393
<string name="about_api_playIntegrityButton">Play Integrity</string>
94-
<string name="about_api_playIntegrityLink">https://developer.android.com/google/play/integrity</string>
94+
<string name="about_api_playIntegrityLink" translatable="false">https://developer.android.com/google/play/integrity</string>
9595
<string name="about_api_safetyNetButton">SafetyNet</string>
96-
<string name="about_api_safetyNetLink">https://developer.android.com/training/safetynet/attestation</string>
96+
<string name="about_api_safetyNetLink" translatable="false">https://developer.android.com/training/safetynet/attestation</string>
9797

9898
<string name="about_sourceCode">Source Code</string>
9999
<string name="about_sourceCode_appButton">Android App</string>
100-
<string name="about_sourceCode_appLink">https://github.com/herzhenr/spic-android</string>
100+
<string name="about_sourceCode_appLink" translatable="false">https://github.com/herzhenr/spic-android</string>
101101
<string name="about_sourceCode_serverButton">Check Server</string>
102-
<string name="about_sourceCode_serverLink">https://github.com/herzhenr/spic-server</string>
102+
<string name="about_sourceCode_serverLink" translatable="false">https://github.com/herzhenr/spic-server</string>
103103

104104
<string name="about_licenseAndPrivacy">License and privacy policy</string>
105-
<string name="about_licenseButton">License</string>
106-
<string name="about_licenseLink">TODO</string>
105+
<string name="about_licenseButton">Licenses</string>
107106
<string name="about_privacyButton">Privacy</string>
108-
<string name="about_privacyLink">https://github.com/herzhenr/spic-android/blob/main/privacyPolicy.md</string>
107+
<string name="about_privacyLink" translatable="false">https://github.com/herzhenr/spic-android/blob/main/privacyPolicy.md</string>
109108

110109
<!-- BottomNavigationBar -->
111110
<string name="bottomBar_playIntegrity">Play Integ.</string>

build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ buildscript {
33
compose_version = '1.3.0-beta01'
44
accompanist_version = '0.24.12-rc'
55
}
6+
repositories {
7+
google() // maven { url "https://maven.google.com" } for Gradle <= 3
8+
}
9+
dependencies {
10+
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.6'
11+
}
612
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
713
plugins {
814
id 'com.android.application' version '7.2.2' apply false
915
id 'com.android.library' version '7.2.2' apply false
1016
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
17+
id 'com.mikepenz.aboutlibraries.plugin' version "10.5.2" apply false
1118
}
1219

1320
task clean(type: Delete) {

0 commit comments

Comments
 (0)