Skip to content

Commit 1846b07

Browse files
authored
Merge pull request #48 from osservatorionessuno/ux-fixes
Fix Acquisition-progress and Analysis-progress UX
2 parents 6595dfc + bab463c commit 1846b07

10 files changed

Lines changed: 410 additions & 56 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ gradlew.bat
88
local.properties
99
*.class
1010
.DS_Store
11+
*.code-workspace

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
android:name=".ScanDetailActivity"
4848
android:exported="false"
4949
android:theme="@style/Theme.Theme" />
50+
<activity
51+
android:name=".AboutActivity"
52+
android:exported="false"
53+
android:theme="@style/Theme.Theme" />
5054
<service
5155
android:name=".utils.AdbPairingService"
5256
android:exported="false"
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
package org.osservatorionessuno.bugbane
2+
3+
import android.content.Intent
4+
import android.net.Uri
5+
import android.os.Bundle
6+
import androidx.activity.ComponentActivity
7+
import androidx.activity.compose.setContent
8+
import androidx.activity.enableEdgeToEdge
9+
import androidx.compose.foundation.layout.*
10+
import androidx.compose.foundation.rememberScrollState
11+
import androidx.compose.foundation.verticalScroll
12+
import androidx.compose.material.icons.Icons
13+
import androidx.compose.material.icons.automirrored.filled.ArrowBack
14+
import androidx.compose.material.icons.filled.Email
15+
import androidx.compose.material.icons.filled.Favorite
16+
import androidx.compose.material3.*
17+
import androidx.compose.runtime.*
18+
import androidx.compose.ui.Alignment
19+
import androidx.compose.ui.Modifier
20+
import androidx.compose.ui.platform.LocalContext
21+
import androidx.compose.ui.res.stringResource
22+
import androidx.compose.ui.text.font.FontWeight
23+
import androidx.compose.ui.unit.dp
24+
import org.osservatorionessuno.bugbane.ui.theme.Theme
25+
26+
class AboutActivity : ComponentActivity() {
27+
override fun onCreate(savedInstanceState: Bundle?) {
28+
super.onCreate(savedInstanceState)
29+
30+
enableEdgeToEdge()
31+
setContent {
32+
Theme {
33+
AboutContent()
34+
}
35+
}
36+
}
37+
}
38+
39+
@OptIn(ExperimentalMaterial3Api::class)
40+
@Composable
41+
fun AboutContent() {
42+
val context = LocalContext.current
43+
44+
val contactUrl = stringResource(R.string.about_contact_url)
45+
val donateUrl = stringResource(R.string.about_donate_url)
46+
47+
Scaffold(
48+
topBar = {
49+
TopAppBar(
50+
title = { Text(stringResource(R.string.about_title)) },
51+
navigationIcon = {
52+
IconButton(onClick = { (context as? ComponentActivity)?.finish() }) {
53+
Icon(
54+
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
55+
contentDescription = "Back"
56+
)
57+
}
58+
},
59+
colors = TopAppBarDefaults.topAppBarColors(
60+
containerColor = MaterialTheme.colorScheme.primary,
61+
titleContentColor = MaterialTheme.colorScheme.onPrimary,
62+
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary
63+
)
64+
)
65+
}
66+
) { padding ->
67+
Column(
68+
modifier = Modifier
69+
.fillMaxSize()
70+
.padding(padding)
71+
.padding(16.dp)
72+
.verticalScroll(rememberScrollState()),
73+
verticalArrangement = Arrangement.spacedBy(16.dp)
74+
) {
75+
Card(
76+
modifier = Modifier.fillMaxWidth(),
77+
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
78+
) {
79+
Column(
80+
modifier = Modifier.padding(20.dp)
81+
) {
82+
Text(
83+
text = stringResource(R.string.about_organization_title),
84+
style = MaterialTheme.typography.headlineSmall,
85+
fontWeight = FontWeight.Bold
86+
)
87+
Spacer(modifier = Modifier.height(8.dp))
88+
Text(
89+
text = stringResource(R.string.about_organization_description),
90+
style = MaterialTheme.typography.bodyMedium,
91+
lineHeight = MaterialTheme.typography.bodyMedium.lineHeight * 1.2
92+
)
93+
Spacer(modifier = Modifier.height(12.dp))
94+
Button(
95+
onClick = {
96+
val intent = Intent(Intent.ACTION_VIEW).apply {
97+
data = Uri.parse(contactUrl)
98+
}
99+
context.startActivity(intent)
100+
},
101+
modifier = Modifier.fillMaxWidth(),
102+
colors = ButtonDefaults.buttonColors(
103+
containerColor = MaterialTheme.colorScheme.secondary,
104+
contentColor = MaterialTheme.colorScheme.onSecondary
105+
)
106+
) {
107+
Icon(
108+
imageVector = Icons.Default.Email,
109+
contentDescription = null,
110+
modifier = Modifier.size(20.dp)
111+
)
112+
Spacer(modifier = Modifier.width(8.dp))
113+
Text(
114+
text = stringResource(R.string.about_contact_button),
115+
style = MaterialTheme.typography.bodyLarge.copy(
116+
fontWeight = FontWeight.Medium
117+
)
118+
)
119+
}
120+
Button(
121+
onClick = {
122+
val intent = Intent(Intent.ACTION_VIEW).apply {
123+
data = Uri.parse(donateUrl)
124+
}
125+
context.startActivity(intent)
126+
},
127+
modifier = Modifier.fillMaxWidth(),
128+
colors = ButtonDefaults.buttonColors(
129+
containerColor = MaterialTheme.colorScheme.error,
130+
contentColor = MaterialTheme.colorScheme.onError
131+
)
132+
) {
133+
Icon(
134+
imageVector = Icons.Default.Favorite,
135+
contentDescription = null,
136+
modifier = Modifier.size(20.dp)
137+
)
138+
Spacer(modifier = Modifier.width(8.dp))
139+
Text(
140+
text = stringResource(R.string.about_donate_button),
141+
style = MaterialTheme.typography.bodyLarge.copy(
142+
fontWeight = FontWeight.Medium
143+
)
144+
)
145+
}
146+
}
147+
}
148+
}
149+
}
150+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package org.osservatorionessuno.bugbane.components
2+
3+
import androidx.compose.foundation.layout.Box
4+
import androidx.compose.foundation.layout.Spacer
5+
import androidx.compose.foundation.layout.height
6+
import androidx.compose.foundation.layout.size
7+
import androidx.compose.material3.CircularProgressIndicator
8+
import androidx.compose.material3.MaterialTheme
9+
import androidx.compose.material3.Text
10+
import androidx.compose.runtime.Composable
11+
import androidx.compose.ui.Alignment
12+
import androidx.compose.ui.Modifier
13+
import androidx.compose.ui.graphics.Color
14+
import androidx.compose.ui.unit.Dp
15+
import androidx.compose.ui.unit.dp
16+
17+
@Composable
18+
fun LayeredProgressIndicator(
19+
totalModules: Int = 0,
20+
completedModules: Int = 0,
21+
modifier: Modifier = Modifier,
22+
size: Dp = 48.dp,
23+
strokeWidth: Dp = 4.dp,
24+
backgroundColor: Color = MaterialTheme.colorScheme.surfaceVariant,
25+
progressColor: Color = MaterialTheme.colorScheme.primary,
26+
continuousColor: Color = MaterialTheme.colorScheme.primary.copy(alpha = 0.3f)
27+
) {
28+
Box(
29+
modifier = modifier.size(size),
30+
contentAlignment = Alignment.Center
31+
) {
32+
CircularProgressIndicator(
33+
modifier = Modifier.size(size),
34+
strokeWidth = strokeWidth,
35+
color = continuousColor.copy(alpha = 0.4f),
36+
trackColor = backgroundColor.copy(alpha = 0.4f)
37+
)
38+
39+
if (totalModules > 0) {
40+
CircularProgressIndicator(
41+
progress = { (completedModules / totalModules.toFloat()).coerceIn(0f, 1f) },
42+
modifier = Modifier.size(size),
43+
strokeWidth = strokeWidth,
44+
color = progressColor,
45+
trackColor = Color.Transparent
46+
)
47+
Spacer(modifier = Modifier.height(8.dp))
48+
Text("$completedModules / $totalModules")
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)