Skip to content
  • Sponsor
  • Notifications You must be signed in to change notification settings
  • Fork 0

Commit 32dfef6

Browse files
committedFeb 1, 2025
chore: format
1 parent 148d90e commit 32dfef6

File tree

12 files changed

+1532
-1513
lines changed

12 files changed

+1532
-1513
lines changed
 

‎app/src/main/java/dev/davwheat/railway/gateline_errors/MainActivity.kt

+65-59
Original file line numberDiff line numberDiff line change
@@ -17,83 +17,89 @@ import com.google.android.ump.ConsentRequestParameters
1717
import com.google.android.ump.UserMessagingPlatform
1818
import dev.davwheat.railway.gateline_errors.composable.MainUi
1919
import dev.davwheat.railway.gateline_errors.ui.theme.AppTheme
20-
import timber.log.Timber
2120
import java.util.concurrent.atomic.AtomicBoolean
21+
import timber.log.Timber
2222

2323
class MainActivity : ComponentActivity() {
24-
private lateinit var consentInformation: ConsentInformation
25-
private var isMobileAdsInitializeCalled = AtomicBoolean(false)
24+
private lateinit var consentInformation: ConsentInformation
25+
private var isMobileAdsInitializeCalled = AtomicBoolean(false)
2626

27-
override fun onCreate(savedInstanceState: Bundle?) {
28-
super.onCreate(savedInstanceState)
27+
override fun onCreate(savedInstanceState: Bundle?) {
28+
super.onCreate(savedInstanceState)
2929

30-
setContent {
31-
enableEdgeToEdge()
30+
setContent {
31+
enableEdgeToEdge()
3232

33-
var showAds by rememberSaveable { mutableStateOf(false) }
33+
var showAds by rememberSaveable { mutableStateOf(false) }
3434

35-
LaunchedEffect(true) {
36-
obtainAdsConsent {
37-
Timber.d("Ads consent obtained")
38-
showAds = true
39-
}
40-
}
35+
LaunchedEffect(true) {
36+
obtainAdsConsent {
37+
Timber.d("Ads consent obtained")
38+
showAds = true
39+
}
40+
}
4141

42-
AppTheme { MainUi(modifier = Modifier, showAds = showAds) }
42+
AppTheme { MainUi(modifier = Modifier, showAds = showAds) }
43+
}
4344
}
44-
}
4545

46-
private fun obtainAdsConsent(callback: () -> Unit) {
47-
val params = ConsentRequestParameters.Builder().setTagForUnderAgeOfConsent(false).build()
46+
private fun obtainAdsConsent(callback: () -> Unit) {
47+
val params = ConsentRequestParameters.Builder().setTagForUnderAgeOfConsent(false).build()
4848

49-
consentInformation = UserMessagingPlatform.getConsentInformation(this)
50-
consentInformation.requestConsentInfoUpdate(
51-
this,
52-
params,
53-
{
54-
UserMessagingPlatform.loadAndShowConsentFormIfRequired(this@MainActivity) { loadAndShowError ->
55-
// Consent gathering failed.
56-
Timber.w(
57-
String.format("%s: %s", loadAndShowError?.errorCode, loadAndShowError?.message)
58-
)
49+
consentInformation = UserMessagingPlatform.getConsentInformation(this)
50+
consentInformation.requestConsentInfoUpdate(
51+
this,
52+
params,
53+
{
54+
UserMessagingPlatform.loadAndShowConsentFormIfRequired(this@MainActivity) {
55+
loadAndShowError ->
56+
// Consent gathering failed.
57+
Timber.w(
58+
String.format(
59+
"%s: %s",
60+
loadAndShowError?.errorCode,
61+
loadAndShowError?.message,
62+
)
63+
)
5964

60-
// Consent has been gathered.
61-
initializeMobileAdsSdk(callback)
62-
}
63-
},
64-
{ requestConsentError ->
65-
// Consent gathering failed.
66-
Timber.w(
67-
String.format("%s: %s", requestConsentError.errorCode, requestConsentError.message)
65+
// Consent has been gathered.
66+
initializeMobileAdsSdk(callback)
67+
}
68+
},
69+
{ requestConsentError ->
70+
// Consent gathering failed.
71+
Timber.w(
72+
String.format(
73+
"%s: %s",
74+
requestConsentError.errorCode,
75+
requestConsentError.message,
76+
)
77+
)
78+
},
6879
)
69-
})
7080

71-
if (consentInformation.canRequestAds()) {
72-
initializeMobileAdsSdk(callback)
81+
if (consentInformation.canRequestAds()) {
82+
initializeMobileAdsSdk(callback)
83+
}
7384
}
74-
}
7585

76-
private fun initializeMobileAdsSdk(callback: () -> Unit) {
77-
if (isMobileAdsInitializeCalled.getAndSet(true)) {
78-
callback()
79-
return
80-
}
86+
private fun initializeMobileAdsSdk(callback: () -> Unit) {
87+
if (isMobileAdsInitializeCalled.getAndSet(true)) {
88+
callback()
89+
return
90+
}
8191

82-
// Initialize the Google Mobile Ads SDK.
83-
MobileAds.initialize(this)
92+
// Initialize the Google Mobile Ads SDK.
93+
MobileAds.initialize(this)
8494

85-
MobileAds.setRequestConfiguration(
86-
RequestConfiguration.Builder()
87-
.setTestDeviceIds(
88-
if (BuildConfig.DEBUG)
89-
listOf(
90-
"077F865A83D45A5C09CB4C8C845ADCA1",
91-
)
92-
else null,
95+
MobileAds.setRequestConfiguration(
96+
RequestConfiguration.Builder()
97+
.setTestDeviceIds(
98+
if (BuildConfig.DEBUG) listOf("077F865A83D45A5C09CB4C8C845ADCA1") else null
99+
)
100+
.build()
93101
)
94-
.build(),
95-
)
96102

97-
callback()
98-
}
103+
callback()
104+
}
99105
}

‎app/src/main/java/dev/davwheat/railway/gateline_errors/composable/AdmobBanner.kt

+16-16
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ import com.google.android.gms.ads.AdView
1010

1111
@Composable
1212
fun AdmobBanner(modifier: Modifier = Modifier) {
13-
AndroidView(
14-
modifier = modifier.fillMaxWidth(),
15-
factory = { context ->
16-
// on below line specifying ad view.
17-
AdView(context).apply {
18-
// on below line specifying ad size
19-
// adSize = AdSize.BANNER
20-
// on below line specifying ad unit id
21-
// currently added a test ad unit id.
22-
setAdSize(AdSize.BANNER)
23-
adUnitId = "ca-app-pub-2701335557132384/6293742813"
24-
// calling load ad to load our ad.
25-
loadAd(AdRequest.Builder().build())
26-
}
27-
},
28-
)
13+
AndroidView(
14+
modifier = modifier.fillMaxWidth(),
15+
factory = { context ->
16+
// on below line specifying ad view.
17+
AdView(context).apply {
18+
// on below line specifying ad size
19+
// adSize = AdSize.BANNER
20+
// on below line specifying ad unit id
21+
// currently added a test ad unit id.
22+
setAdSize(AdSize.BANNER)
23+
adUnitId = "ca-app-pub-2701335557132384/6293742813"
24+
// calling load ad to load our ad.
25+
loadAd(AdRequest.Builder().build())
26+
}
27+
},
28+
)
2929
}

‎app/src/main/java/dev/davwheat/railway/gateline_errors/composable/ErrorCodeDetail.kt

+66-72
Original file line numberDiff line numberDiff line change
@@ -22,97 +22,91 @@ import dev.davwheat.railway.gateline_errors.ui.theme.AppTheme
2222
import dev.davwheat.railway.gateline_errors.ui.theme.LcdDisplayFont
2323

2424
@Composable
25-
fun ErrorCodeDetail(
26-
modifier: Modifier = Modifier,
27-
errorCode: Rejection,
28-
) {
29-
Column(
30-
modifier,
31-
verticalArrangement = Arrangement.spacedBy(8.dp),
32-
) {
33-
Text(
34-
stringResource(R.string.seek_assistance, errorCode.code),
35-
modifier = Modifier.fillMaxWidth(),
36-
fontFamily = LcdDisplayFont,
37-
fontSize = 28.sp,
38-
color = MaterialTheme.colorScheme.onSurfaceVariant,
39-
textAlign = TextAlign.Center,
40-
)
41-
42-
errorCode.textCode?.let { code ->
43-
DataPair(
44-
heading = "Text Error",
45-
text = { _modifier, style, align ->
46-
Text(
47-
modifier = _modifier,
48-
text = code,
49-
style = style,
25+
fun ErrorCodeDetail(modifier: Modifier = Modifier, errorCode: Rejection) {
26+
Column(modifier, verticalArrangement = Arrangement.spacedBy(8.dp)) {
27+
Text(
28+
stringResource(R.string.seek_assistance, errorCode.code),
29+
modifier = Modifier.fillMaxWidth(),
5030
fontFamily = LcdDisplayFont,
31+
fontSize = 28.sp,
5132
color = MaterialTheme.colorScheme.onSurfaceVariant,
52-
fontSize = 18.sp,
53-
textAlign = align,
54-
)
55-
},
56-
modifier = Modifier.align(Alignment.CenterHorizontally),
57-
align = TextAlign.Center,
58-
)
59-
}
33+
textAlign = TextAlign.Center,
34+
)
6035

61-
DataPair(heading = "Definition") { _modifier, style, align ->
62-
Text(
63-
modifier = _modifier,
64-
text = errorCode.definition,
65-
style = style,
66-
textAlign = align,
67-
fontWeight = FontWeight.Bold,
68-
)
69-
}
36+
errorCode.textCode?.let { code ->
37+
DataPair(
38+
heading = "Text Error",
39+
text = { _modifier, style, align ->
40+
Text(
41+
modifier = _modifier,
42+
text = code,
43+
style = style,
44+
fontFamily = LcdDisplayFont,
45+
color = MaterialTheme.colorScheme.onSurfaceVariant,
46+
fontSize = 18.sp,
47+
textAlign = align,
48+
)
49+
},
50+
modifier = Modifier.align(Alignment.CenterHorizontally),
51+
align = TextAlign.Center,
52+
)
53+
}
7054

71-
DataPair(heading = "Explanation", text = errorCode.helpText)
55+
DataPair(heading = "Definition") { _modifier, style, align ->
56+
Text(
57+
modifier = _modifier,
58+
text = errorCode.definition,
59+
style = style,
60+
textAlign = align,
61+
fontWeight = FontWeight.Bold,
62+
)
63+
}
7264

73-
errorCode.laymansReason?.let { DataPair(heading = "Possible reason(s)", text = it) }
65+
DataPair(heading = "Explanation", text = errorCode.helpText)
7466

75-
DataPair(heading = "Action needed", text = errorCode.actionByStaff)
76-
}
67+
errorCode.laymansReason?.let { DataPair(heading = "Possible reason(s)", text = it) }
68+
69+
DataPair(heading = "Action needed", text = errorCode.actionByStaff)
70+
}
7771
}
7872

7973
@Composable
8074
private fun DataPair(
81-
modifier: Modifier = Modifier,
82-
align: TextAlign = TextAlign.Start,
83-
heading: String,
84-
text: String,
75+
modifier: Modifier = Modifier,
76+
align: TextAlign = TextAlign.Start,
77+
heading: String,
78+
text: String,
8579
) {
86-
DataPair(
87-
modifier = modifier,
88-
heading = heading,
89-
text = { _modifier, style, _ ->
90-
Text(modifier = _modifier, text = text, style = style, textAlign = align)
91-
},
92-
align = align,
93-
)
80+
DataPair(
81+
modifier = modifier,
82+
heading = heading,
83+
text = { _modifier, style, _ ->
84+
Text(modifier = _modifier, text = text, style = style, textAlign = align)
85+
},
86+
align = align,
87+
)
9488
}
9589

9690
@Composable
9791
private fun DataPair(
98-
modifier: Modifier = Modifier,
99-
align: TextAlign = TextAlign.Start,
100-
heading: String,
101-
text: @Composable (modifier: Modifier, defaultStyle: TextStyle, textAlign: TextAlign) -> Unit,
92+
modifier: Modifier = Modifier,
93+
align: TextAlign = TextAlign.Start,
94+
heading: String,
95+
text: @Composable (modifier: Modifier, defaultStyle: TextStyle, textAlign: TextAlign) -> Unit,
10296
) {
103-
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(4.dp)) {
104-
Text(
105-
modifier = Modifier.fillMaxWidth(),
106-
text = heading,
107-
style = MaterialTheme.typography.bodySmall,
108-
textAlign = align,
109-
)
110-
text(Modifier.fillMaxWidth(), MaterialTheme.typography.bodyMedium, align)
111-
}
97+
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(4.dp)) {
98+
Text(
99+
modifier = Modifier.fillMaxWidth(),
100+
text = heading,
101+
style = MaterialTheme.typography.bodySmall,
102+
textAlign = align,
103+
)
104+
text(Modifier.fillMaxWidth(), MaterialTheme.typography.bodyMedium, align)
105+
}
112106
}
113107

114108
@Preview(showBackground = true)
115109
@Composable
116110
private fun ErrorCodeDetailPreview() {
117-
AppTheme { ErrorCodeDetail(errorCode = ErrorCodes[1]!!) }
111+
AppTheme { ErrorCodeDetail(errorCode = ErrorCodes[1]!!) }
118112
}

‎app/src/main/java/dev/davwheat/railway/gateline_errors/composable/ErrorCodeDisplay.kt

+48-51
Original file line numberDiff line numberDiff line change
@@ -23,78 +23,75 @@ import dev.davwheat.railway.gateline_errors.data.ErrorCodes
2323
import dev.davwheat.railway.gateline_errors.ui.theme.AppTheme
2424

2525
@Composable
26-
fun ErrorCodeDisplay(
27-
modifier: Modifier = Modifier,
28-
errorCode: String,
29-
) {
30-
Card(modifier = modifier.animateContentSize()) {
31-
Column(modifier = Modifier.padding(16.dp)) {
32-
AnimatedContent(
33-
targetState = errorCode,
34-
label = "ErrorCodeDisplay",
35-
transitionSpec = { fadeIn() togetherWith fadeOut() },
36-
) {
37-
if (it.isBlank()) {
38-
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
39-
Text(
40-
stringResource(R.string.no_code_blurb_1),
41-
textAlign = TextAlign.Center,
42-
modifier = Modifier.fillMaxWidth(),
43-
style = MaterialTheme.typography.bodyLarge,
44-
)
45-
Text(
46-
stringResource(R.string.no_code_blurb_2),
47-
textAlign = TextAlign.Center,
48-
modifier = Modifier.fillMaxWidth(),
49-
style = MaterialTheme.typography.bodyLarge,
50-
)
51-
}
52-
} else {
53-
val num = it.toIntOrNull()
26+
fun ErrorCodeDisplay(modifier: Modifier = Modifier, errorCode: String) {
27+
Card(modifier = modifier.animateContentSize()) {
28+
Column(modifier = Modifier.padding(16.dp)) {
29+
AnimatedContent(
30+
targetState = errorCode,
31+
label = "ErrorCodeDisplay",
32+
transitionSpec = { fadeIn() togetherWith fadeOut() },
33+
) {
34+
if (it.isBlank()) {
35+
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
36+
Text(
37+
stringResource(R.string.no_code_blurb_1),
38+
textAlign = TextAlign.Center,
39+
modifier = Modifier.fillMaxWidth(),
40+
style = MaterialTheme.typography.bodyLarge,
41+
)
42+
Text(
43+
stringResource(R.string.no_code_blurb_2),
44+
textAlign = TextAlign.Center,
45+
modifier = Modifier.fillMaxWidth(),
46+
style = MaterialTheme.typography.bodyLarge,
47+
)
48+
}
49+
} else {
50+
val num = it.toIntOrNull()
5451

55-
if (num == null) {
56-
Text(
57-
stringResource(R.string.error_code_invalid_int),
58-
textAlign = TextAlign.Center,
59-
modifier = Modifier.fillMaxWidth(),
60-
style = MaterialTheme.typography.bodyLarge,
61-
)
62-
} else if (ErrorCodes.containsKey(num)) {
63-
ErrorCodeDetail(errorCode = ErrorCodes[num]!!)
64-
} else {
65-
Text(
66-
stringResource(R.string.error_code_unknown, num),
67-
textAlign = TextAlign.Center,
68-
modifier = Modifier.fillMaxWidth(),
69-
style = MaterialTheme.typography.bodyLarge,
70-
)
71-
}
52+
if (num == null) {
53+
Text(
54+
stringResource(R.string.error_code_invalid_int),
55+
textAlign = TextAlign.Center,
56+
modifier = Modifier.fillMaxWidth(),
57+
style = MaterialTheme.typography.bodyLarge,
58+
)
59+
} else if (ErrorCodes.containsKey(num)) {
60+
ErrorCodeDetail(errorCode = ErrorCodes[num]!!)
61+
} else {
62+
Text(
63+
stringResource(R.string.error_code_unknown, num),
64+
textAlign = TextAlign.Center,
65+
modifier = Modifier.fillMaxWidth(),
66+
style = MaterialTheme.typography.bodyLarge,
67+
)
68+
}
69+
}
70+
}
7271
}
73-
}
7472
}
75-
}
7673
}
7774

7875
@Preview
7976
@Composable
8077
fun ErrorCodeDisplayPreviewValid() {
81-
AppTheme { ErrorCodeDisplay(errorCode = "01") }
78+
AppTheme { ErrorCodeDisplay(errorCode = "01") }
8279
}
8380

8481
@Preview
8582
@Composable
8683
fun ErrorCodeDisplayPreviewInvalid() {
87-
AppTheme { ErrorCodeDisplay(errorCode = "abc") }
84+
AppTheme { ErrorCodeDisplay(errorCode = "abc") }
8885
}
8986

9087
@Preview
9188
@Composable
9289
fun ErrorCodeDisplayPreviewEmpty() {
93-
AppTheme { ErrorCodeDisplay(errorCode = "") }
90+
AppTheme { ErrorCodeDisplay(errorCode = "") }
9491
}
9592

9693
@Preview
9794
@Composable
9895
fun ErrorCodeDisplayPreviewUnknown() {
99-
AppTheme { ErrorCodeDisplay(errorCode = "999") }
96+
AppTheme { ErrorCodeDisplay(errorCode = "999") }
10097
}

‎app/src/main/java/dev/davwheat/railway/gateline_errors/composable/ErrorCodeEntry.kt

+28-28
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,38 @@ import dev.davwheat.railway.gateline_errors.ui.theme.AppTheme
1818

1919
@Composable
2020
fun ErrorCodeEntry(modifier: Modifier = Modifier, value: String, onInput: (String) -> Unit) {
21-
Column(modifier = modifier) {
22-
OutlinedTextField(
23-
modifier = Modifier.fillMaxWidth(),
24-
value = value,
25-
onValueChange = {
26-
if (it.length >= 3) {
27-
onInput(it.substring(0, 3))
28-
} else {
29-
onInput(it)
30-
}
31-
},
32-
label = { Text(stringResource(R.string.error_code_input_label)) },
33-
supportingText = {
34-
Text(
35-
modifier = Modifier.fillMaxWidth(),
36-
text = stringResource(R.string.error_code_input_char_count, value.length),
37-
textAlign = TextAlign.End,
21+
Column(modifier = modifier) {
22+
OutlinedTextField(
23+
modifier = Modifier.fillMaxWidth(),
24+
value = value,
25+
onValueChange = {
26+
if (it.length >= 3) {
27+
onInput(it.substring(0, 3))
28+
} else {
29+
onInput(it)
30+
}
31+
},
32+
label = { Text(stringResource(R.string.error_code_input_label)) },
33+
supportingText = {
34+
Text(
35+
modifier = Modifier.fillMaxWidth(),
36+
text = stringResource(R.string.error_code_input_char_count, value.length),
37+
textAlign = TextAlign.End,
38+
)
39+
},
40+
keyboardOptions =
41+
KeyboardOptions(
42+
autoCorrectEnabled = false,
43+
capitalization = KeyboardCapitalization.None,
44+
imeAction = ImeAction.Search,
45+
keyboardType = KeyboardType.Number,
46+
),
3847
)
39-
},
40-
keyboardOptions =
41-
KeyboardOptions(
42-
autoCorrectEnabled = false,
43-
capitalization = KeyboardCapitalization.None,
44-
imeAction = ImeAction.Search,
45-
keyboardType = KeyboardType.Number,
46-
),
47-
)
48-
}
48+
}
4949
}
5050

5151
@Preview
5252
@Composable
5353
private fun ErrorCodeEntryPreview() {
54-
AppTheme { ErrorCodeEntry(value = "123", onInput = {}) }
54+
AppTheme { ErrorCodeEntry(value = "123", onInput = {}) }
5555
}

‎app/src/main/java/dev/davwheat/railway/gateline_errors/composable/MainUi.kt

+83-80
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import androidx.compose.foundation.layout.Arrangement
99
import androidx.compose.foundation.layout.Box
1010
import androidx.compose.foundation.layout.Column
1111
import androidx.compose.foundation.layout.ExperimentalLayoutApi
12-
import androidx.compose.foundation.layout.consumeWindowInsets
1312
import androidx.compose.foundation.layout.fillMaxSize
1413
import androidx.compose.foundation.layout.fillMaxWidth
1514
import androidx.compose.foundation.layout.padding
16-
import androidx.compose.foundation.layout.safeDrawingPadding
1715
import androidx.compose.foundation.rememberScrollState
1816
import androidx.compose.foundation.verticalScroll
1917
import androidx.compose.material3.BottomSheetScaffold
@@ -40,94 +38,99 @@ import dev.davwheat.railway.gateline_errors.ui.theme.AppTheme
4038
@OptIn(ExperimentalLayoutApi::class, ExperimentalMaterial3Api::class)
4139
@Composable
4240
fun MainUi(modifier: Modifier = Modifier, showAds: Boolean) {
43-
var errorCodeEntry by rememberSaveable { mutableStateOf("") }
44-
val intErrorCode = errorCodeEntry.toIntOrNull()
41+
var errorCodeEntry by rememberSaveable { mutableStateOf("") }
42+
val intErrorCode = errorCodeEntry.toIntOrNull()
4543

46-
var adHeight by remember { mutableIntStateOf(0) }
47-
val adHeightDp = with(LocalDensity.current) { adHeight.toDp() }
44+
var adHeight by remember { mutableIntStateOf(0) }
45+
val adHeightDp = with(LocalDensity.current) { adHeight.toDp() }
4846

49-
val scaffoldState =
50-
rememberBottomSheetScaffoldState(
51-
bottomSheetState =
52-
SheetState(
53-
initialValue = SheetValue.Expanded,
54-
confirmValueChange = { false },
55-
skipHiddenState = true,
56-
skipPartiallyExpanded = true,
57-
density = LocalDensity.current,
58-
),
59-
)
47+
val scaffoldState =
48+
rememberBottomSheetScaffoldState(
49+
bottomSheetState =
50+
SheetState(
51+
initialValue = SheetValue.Expanded,
52+
confirmValueChange = { false },
53+
skipHiddenState = true,
54+
skipPartiallyExpanded = true,
55+
density = LocalDensity.current,
56+
)
57+
)
6058

61-
Scaffold(modifier) { innerPadding ->
62-
Box(modifier = Modifier.fillMaxSize()) {
63-
BottomSheetScaffold(
64-
sheetDragHandle = {},
65-
sheetSwipeEnabled = false,
66-
scaffoldState = scaffoldState,
67-
sheetContent = {
68-
Column(
69-
modifier =
70-
Modifier.padding(start = 36.dp, end = 36.dp, top = 24.dp, bottom = 36.dp),
71-
verticalArrangement = Arrangement.Bottom,
72-
) {
73-
ErrorCodeEntry(
74-
modifier = Modifier.fillMaxWidth(),
75-
value = errorCodeEntry,
76-
onInput = { text -> errorCodeEntry = text },
77-
)
78-
}
79-
},
80-
) {
81-
Box(modifier = Modifier
82-
.padding(innerPadding)
83-
.padding(it)
84-
.fillMaxSize()
85-
.padding(bottom = 84.dp)) {
86-
Column(
87-
modifier =
88-
Modifier
89-
.fillMaxSize()
90-
.verticalScroll(rememberScrollState())
91-
.padding(
92-
top = 24.dp,
93-
start = 24.dp,
94-
end = 24.dp,
95-
bottom = 24.dp + adHeightDp + 8.dp,
96-
),
97-
verticalArrangement = Arrangement.spacedBy(16.dp),
98-
) {
99-
ErrorCodeDisplay(
100-
modifier = Modifier.fillMaxWidth(),
101-
errorCode = errorCodeEntry,
102-
)
103-
104-
AnimatedVisibility(
105-
visible = (intErrorCode ?: -1) >= 100,
106-
enter = fadeIn() + expandVertically(),
107-
exit = fadeOut() + shrinkVertically(),
59+
Scaffold(modifier) { innerPadding ->
60+
Box(modifier = Modifier.fillMaxSize()) {
61+
BottomSheetScaffold(
62+
sheetDragHandle = {},
63+
sheetSwipeEnabled = false,
64+
scaffoldState = scaffoldState,
65+
sheetContent = {
66+
Column(
67+
modifier =
68+
Modifier.padding(
69+
start = 36.dp,
70+
end = 36.dp,
71+
top = 24.dp,
72+
bottom = 36.dp,
73+
),
74+
verticalArrangement = Arrangement.Bottom,
75+
) {
76+
ErrorCodeEntry(
77+
modifier = Modifier.fillMaxWidth(),
78+
value = errorCodeEntry,
79+
onInput = { text -> errorCodeEntry = text },
80+
)
81+
}
82+
},
10883
) {
109-
NrValidationGlossary()
110-
}
111-
}
84+
Box(
85+
modifier =
86+
Modifier.padding(innerPadding)
87+
.padding(it)
88+
.fillMaxSize()
89+
.padding(bottom = 84.dp)
90+
) {
91+
Column(
92+
modifier =
93+
Modifier.fillMaxSize()
94+
.verticalScroll(rememberScrollState())
95+
.padding(
96+
top = 24.dp,
97+
start = 24.dp,
98+
end = 24.dp,
99+
bottom = 24.dp + adHeightDp + 8.dp,
100+
),
101+
verticalArrangement = Arrangement.spacedBy(16.dp),
102+
) {
103+
ErrorCodeDisplay(
104+
modifier = Modifier.fillMaxWidth(),
105+
errorCode = errorCodeEntry,
106+
)
112107

113-
if (showAds) {
114-
AdmobBanner(
115-
modifier =
116-
Modifier
117-
.fillMaxWidth()
118-
.padding(bottom = 8.dp)
119-
.align(Alignment.BottomCenter)
120-
.onGloballyPositioned { adHeight = it.size.height },
121-
)
122-
}
108+
AnimatedVisibility(
109+
visible = (intErrorCode ?: -1) >= 100,
110+
enter = fadeIn() + expandVertically(),
111+
exit = fadeOut() + shrinkVertically(),
112+
) {
113+
NrValidationGlossary()
114+
}
115+
}
116+
117+
if (showAds) {
118+
AdmobBanner(
119+
modifier =
120+
Modifier.fillMaxWidth()
121+
.padding(bottom = 8.dp)
122+
.align(Alignment.BottomCenter)
123+
.onGloballyPositioned { adHeight = it.size.height }
124+
)
125+
}
126+
}
127+
}
123128
}
124-
}
125129
}
126-
}
127130
}
128131

129132
@Preview
130133
@Composable
131134
private fun MainUiPreview() {
132-
AppTheme { MainUi(showAds = false) }
135+
AppTheme { MainUi(showAds = false) }
133136
}

‎app/src/main/java/dev/davwheat/railway/gateline_errors/composable/NrValidationGlossary.kt

+55-55
Original file line numberDiff line numberDiff line change
@@ -24,70 +24,70 @@ import dev.davwheat.railway.gateline_errors.ui.theme.AppTheme
2424
import dev.davwheat.railway.gateline_errors.ui.theme.LcdDisplayFont
2525

2626
private val glossaryData =
27-
listOf(
28-
Pair("DDDD", "Destination station code"),
29-
Pair("OOOO", "Origin station code"),
30-
Pair("DDMMYY", "Date"),
31-
Pair("FFFF", "Fare"),
32-
Pair("LLLL", "London Underground station code"),
33-
Pair("PP", "Passenger type"),
34-
Pair("PZ", "Ticket pass zone"),
35-
Pair("RR", "Special rule number"),
36-
Pair("TTTT", "Ticket type"),
37-
Pair("YY", "London Underground ticket type"),
38-
Pair("XX", "National Rail ticket type"),
39-
)
27+
listOf(
28+
Pair("DDDD", "Destination station code"),
29+
Pair("OOOO", "Origin station code"),
30+
Pair("DDMMYY", "Date"),
31+
Pair("FFFF", "Fare"),
32+
Pair("LLLL", "London Underground station code"),
33+
Pair("PP", "Passenger type"),
34+
Pair("PZ", "Ticket pass zone"),
35+
Pair("RR", "Special rule number"),
36+
Pair("TTTT", "Ticket type"),
37+
Pair("YY", "London Underground ticket type"),
38+
Pair("XX", "National Rail ticket type"),
39+
)
4040

4141
@Composable
4242
fun NrValidationGlossary(modifier: Modifier = Modifier) {
43-
Card(modifier = modifier) {
44-
Column(
45-
modifier = Modifier.padding(16.dp),
46-
verticalArrangement = Arrangement.spacedBy(8.dp),
47-
) {
48-
Row(
49-
horizontalArrangement = Arrangement.spacedBy(8.dp),
50-
modifier = Modifier.padding(bottom = 4.dp),
51-
verticalAlignment = Alignment.CenterVertically,
52-
) {
53-
Icon(
54-
Icons.Rounded.Info,
55-
contentDescription = stringResource(R.string.icon_info_description),
56-
)
57-
Text(
58-
stringResource(R.string.glossary_note),
59-
modifier = Modifier.weight(1f),
60-
fontWeight = FontWeight.SemiBold,
61-
style = MaterialTheme.typography.bodyMedium,
62-
)
63-
}
64-
65-
glossaryData.forEach {
66-
Row(
67-
horizontalArrangement = Arrangement.spacedBy(0.dp),
68-
verticalAlignment = Alignment.CenterVertically,
43+
Card(modifier = modifier) {
44+
Column(
45+
modifier = Modifier.padding(16.dp),
46+
verticalArrangement = Arrangement.spacedBy(8.dp),
6947
) {
70-
Text(
71-
it.first,
72-
style = MaterialTheme.typography.bodyMedium,
73-
fontFamily = LcdDisplayFont,
74-
color = MaterialTheme.colorScheme.onSurfaceVariant,
75-
fontSize = 20.sp,
76-
)
77-
Text(
78-
it.second,
79-
style = MaterialTheme.typography.bodyMedium,
80-
modifier = Modifier.weight(1f),
81-
textAlign = TextAlign.End,
82-
)
48+
Row(
49+
horizontalArrangement = Arrangement.spacedBy(8.dp),
50+
modifier = Modifier.padding(bottom = 4.dp),
51+
verticalAlignment = Alignment.CenterVertically,
52+
) {
53+
Icon(
54+
Icons.Rounded.Info,
55+
contentDescription = stringResource(R.string.icon_info_description),
56+
)
57+
Text(
58+
stringResource(R.string.glossary_note),
59+
modifier = Modifier.weight(1f),
60+
fontWeight = FontWeight.SemiBold,
61+
style = MaterialTheme.typography.bodyMedium,
62+
)
63+
}
64+
65+
glossaryData.forEach {
66+
Row(
67+
horizontalArrangement = Arrangement.spacedBy(0.dp),
68+
verticalAlignment = Alignment.CenterVertically,
69+
) {
70+
Text(
71+
it.first,
72+
style = MaterialTheme.typography.bodyMedium,
73+
fontFamily = LcdDisplayFont,
74+
color = MaterialTheme.colorScheme.onSurfaceVariant,
75+
fontSize = 20.sp,
76+
)
77+
Text(
78+
it.second,
79+
style = MaterialTheme.typography.bodyMedium,
80+
modifier = Modifier.weight(1f),
81+
textAlign = TextAlign.End,
82+
)
83+
}
84+
}
8385
}
84-
}
8586
}
86-
}
8787
}
8888

8989
@Preview
9090
@Composable
9191
private fun NrValidationGlossaryPreview() {
92-
AppTheme { NrValidationGlossary() }
92+
AppTheme { NrValidationGlossary() }
9393
}

‎app/src/main/java/dev/davwheat/railway/gateline_errors/data/ErrorCodeData.kt

+1,034-1,029
Large diffs are not rendered by default.

‎app/src/main/java/dev/davwheat/railway/gateline_errors/models/ActionByStaff.kt

+46-46
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,53 @@ package dev.davwheat.railway.gateline_errors.models
22

33
enum class ActionByStaff {
44

5-
NONE,
6-
TO_TICKET_OFFICE,
7-
IRREG_TRAVEL,
8-
TOP_UP_CARD,
9-
HELPDESK,
10-
CHECK_CARD,
11-
ALTN_PAYMENT,
12-
REFER_CARD_ISSUER,
13-
TRY_AGAIN,
14-
TRY_AGAIN_CARD,
15-
TRY_AGAIN_ONE_CARD,
16-
CHECK_RCI,
17-
CONTACT_CTS,
18-
DISABLE_TEST_MODE,
19-
REPLACE_TICKET,
20-
REPLACE_ITSO_CARD,
21-
REPRESENT_ONE_CARD,
22-
SEEK_ASSISTANCE,
23-
TFL_CHECK_JOURNEY_HISTORY,
24-
USE_OTHER,
25-
CHECK_VALIDITY_THEN_TO;
5+
NONE,
6+
TO_TICKET_OFFICE,
7+
IRREG_TRAVEL,
8+
TOP_UP_CARD,
9+
HELPDESK,
10+
CHECK_CARD,
11+
ALTN_PAYMENT,
12+
REFER_CARD_ISSUER,
13+
TRY_AGAIN,
14+
TRY_AGAIN_CARD,
15+
TRY_AGAIN_ONE_CARD,
16+
CHECK_RCI,
17+
CONTACT_CTS,
18+
DISABLE_TEST_MODE,
19+
REPLACE_TICKET,
20+
REPLACE_ITSO_CARD,
21+
REPRESENT_ONE_CARD,
22+
SEEK_ASSISTANCE,
23+
TFL_CHECK_JOURNEY_HISTORY,
24+
USE_OTHER,
25+
CHECK_VALIDITY_THEN_TO;
2626

27-
override fun toString(): String {
28-
return when (this) {
29-
TO_TICKET_OFFICE -> "Refer to ticket office or seek assistance"
30-
IRREG_TRAVEL -> "Suspicious or irregular travel - seek assistance from staff"
31-
TOP_UP_CARD -> "Top up Oyster or smartcard PAYG balance"
32-
HELPDESK -> "Refer to helpdesk"
33-
CHECK_CARD -> "Manually check card validity"
34-
ALTN_PAYMENT -> "Use alternative payment method"
35-
REFER_CARD_ISSUER -> "Refer to card issuer"
36-
TRY_AGAIN -> "Try again or seek assistance"
37-
TRY_AGAIN_CARD -> "Represent card"
38-
TRY_AGAIN_ONE_CARD -> "Represent only one card"
39-
CHECK_RCI -> "Check RCI list - seek assistance"
40-
CONTACT_CTS ->
41-
"Seek assistance - Staff: contact the Cubic Transportation Systems Report Centre"
27+
override fun toString(): String {
28+
return when (this) {
29+
TO_TICKET_OFFICE -> "Refer to ticket office or seek assistance"
30+
IRREG_TRAVEL -> "Suspicious or irregular travel - seek assistance from staff"
31+
TOP_UP_CARD -> "Top up Oyster or smartcard PAYG balance"
32+
HELPDESK -> "Refer to helpdesk"
33+
CHECK_CARD -> "Manually check card validity"
34+
ALTN_PAYMENT -> "Use alternative payment method"
35+
REFER_CARD_ISSUER -> "Refer to card issuer"
36+
TRY_AGAIN -> "Try again or seek assistance"
37+
TRY_AGAIN_CARD -> "Represent card"
38+
TRY_AGAIN_ONE_CARD -> "Represent only one card"
39+
CHECK_RCI -> "Check RCI list - seek assistance"
40+
CONTACT_CTS ->
41+
"Seek assistance - Staff: contact the Cubic Transportation Systems Report Centre"
4242

43-
DISABLE_TEST_MODE -> "Disable test mode - seek assistance"
44-
REPLACE_TICKET -> "Replace ticket - seek assistance"
45-
REPLACE_ITSO_CARD -> "You need a replacement smartcard - seek assistance"
46-
REPRESENT_ONE_CARD -> "Represent one card only"
47-
SEEK_ASSISTANCE -> "Seek assistance from a member of staff"
48-
TFL_CHECK_JOURNEY_HISTORY -> "TfL: check journey history at tfl.gov.uk"
49-
USE_OTHER -> "Use another card or ticket"
50-
CHECK_VALIDITY_THEN_TO -> "Ensure the ticket is not valid, then see ticket office"
51-
NONE -> "No action needed"
43+
DISABLE_TEST_MODE -> "Disable test mode - seek assistance"
44+
REPLACE_TICKET -> "Replace ticket - seek assistance"
45+
REPLACE_ITSO_CARD -> "You need a replacement smartcard - seek assistance"
46+
REPRESENT_ONE_CARD -> "Represent one card only"
47+
SEEK_ASSISTANCE -> "Seek assistance from a member of staff"
48+
TFL_CHECK_JOURNEY_HISTORY -> "TfL: check journey history at tfl.gov.uk"
49+
USE_OTHER -> "Use another card or ticket"
50+
CHECK_VALIDITY_THEN_TO -> "Ensure the ticket is not valid, then see ticket office"
51+
NONE -> "No action needed"
52+
}
5253
}
53-
}
5454
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package dev.davwheat.railway.gateline_errors.models
22

33
data class Rejection(
4-
val code: String,
5-
val textCode: String?,
6-
val definition: String,
7-
val helpText: String,
8-
val action: ActionByStaff = ActionByStaff.NONE,
9-
val laymansReason: String? = null,
4+
val code: String,
5+
val textCode: String?,
6+
val definition: String,
7+
val helpText: String,
8+
val action: ActionByStaff = ActionByStaff.NONE,
9+
val laymansReason: String? = null,
1010
) {
11-
val integerCode: Int = code.toInt()
12-
val actionByStaff = action.toString()
11+
val integerCode: Int = code.toInt()
12+
val actionByStaff = action.toString()
1313
}

‎app/src/main/java/dev/davwheat/railway/gateline_errors/ui/theme/Theme.kt

+69-69
Original file line numberDiff line numberDiff line change
@@ -7,79 +7,79 @@ import androidx.compose.material3.lightColorScheme
77
import androidx.compose.runtime.Composable
88

99
private val LightColors =
10-
lightColorScheme(
11-
primary = md_theme_light_primary,
12-
onPrimary = md_theme_light_onPrimary,
13-
primaryContainer = md_theme_light_primaryContainer,
14-
onPrimaryContainer = md_theme_light_onPrimaryContainer,
15-
secondary = md_theme_light_secondary,
16-
onSecondary = md_theme_light_onSecondary,
17-
secondaryContainer = md_theme_light_secondaryContainer,
18-
onSecondaryContainer = md_theme_light_onSecondaryContainer,
19-
tertiary = md_theme_light_tertiary,
20-
onTertiary = md_theme_light_onTertiary,
21-
tertiaryContainer = md_theme_light_tertiaryContainer,
22-
onTertiaryContainer = md_theme_light_onTertiaryContainer,
23-
error = md_theme_light_error,
24-
errorContainer = md_theme_light_errorContainer,
25-
onError = md_theme_light_onError,
26-
onErrorContainer = md_theme_light_onErrorContainer,
27-
background = md_theme_light_background,
28-
onBackground = md_theme_light_onBackground,
29-
surface = md_theme_light_surface,
30-
onSurface = md_theme_light_onSurface,
31-
surfaceVariant = md_theme_light_surfaceVariant,
32-
onSurfaceVariant = md_theme_light_onSurfaceVariant,
33-
outline = md_theme_light_outline,
34-
inverseOnSurface = md_theme_light_inverseOnSurface,
35-
inverseSurface = md_theme_light_inverseSurface,
36-
inversePrimary = md_theme_light_inversePrimary,
37-
surfaceTint = md_theme_light_surfaceTint,
38-
outlineVariant = md_theme_light_outlineVariant,
39-
scrim = md_theme_light_scrim,
40-
)
10+
lightColorScheme(
11+
primary = md_theme_light_primary,
12+
onPrimary = md_theme_light_onPrimary,
13+
primaryContainer = md_theme_light_primaryContainer,
14+
onPrimaryContainer = md_theme_light_onPrimaryContainer,
15+
secondary = md_theme_light_secondary,
16+
onSecondary = md_theme_light_onSecondary,
17+
secondaryContainer = md_theme_light_secondaryContainer,
18+
onSecondaryContainer = md_theme_light_onSecondaryContainer,
19+
tertiary = md_theme_light_tertiary,
20+
onTertiary = md_theme_light_onTertiary,
21+
tertiaryContainer = md_theme_light_tertiaryContainer,
22+
onTertiaryContainer = md_theme_light_onTertiaryContainer,
23+
error = md_theme_light_error,
24+
errorContainer = md_theme_light_errorContainer,
25+
onError = md_theme_light_onError,
26+
onErrorContainer = md_theme_light_onErrorContainer,
27+
background = md_theme_light_background,
28+
onBackground = md_theme_light_onBackground,
29+
surface = md_theme_light_surface,
30+
onSurface = md_theme_light_onSurface,
31+
surfaceVariant = md_theme_light_surfaceVariant,
32+
onSurfaceVariant = md_theme_light_onSurfaceVariant,
33+
outline = md_theme_light_outline,
34+
inverseOnSurface = md_theme_light_inverseOnSurface,
35+
inverseSurface = md_theme_light_inverseSurface,
36+
inversePrimary = md_theme_light_inversePrimary,
37+
surfaceTint = md_theme_light_surfaceTint,
38+
outlineVariant = md_theme_light_outlineVariant,
39+
scrim = md_theme_light_scrim,
40+
)
4141

4242
private val DarkColors =
43-
darkColorScheme(
44-
primary = md_theme_dark_primary,
45-
onPrimary = md_theme_dark_onPrimary,
46-
primaryContainer = md_theme_dark_primaryContainer,
47-
onPrimaryContainer = md_theme_dark_onPrimaryContainer,
48-
secondary = md_theme_dark_secondary,
49-
onSecondary = md_theme_dark_onSecondary,
50-
secondaryContainer = md_theme_dark_secondaryContainer,
51-
onSecondaryContainer = md_theme_dark_onSecondaryContainer,
52-
tertiary = md_theme_dark_tertiary,
53-
onTertiary = md_theme_dark_onTertiary,
54-
tertiaryContainer = md_theme_dark_tertiaryContainer,
55-
onTertiaryContainer = md_theme_dark_onTertiaryContainer,
56-
error = md_theme_dark_error,
57-
errorContainer = md_theme_dark_errorContainer,
58-
onError = md_theme_dark_onError,
59-
onErrorContainer = md_theme_dark_onErrorContainer,
60-
background = md_theme_dark_background,
61-
onBackground = md_theme_dark_onBackground,
62-
surface = md_theme_dark_surface,
63-
onSurface = md_theme_dark_onSurface,
64-
surfaceVariant = md_theme_dark_surfaceVariant,
65-
onSurfaceVariant = md_theme_dark_onSurfaceVariant,
66-
outline = md_theme_dark_outline,
67-
inverseOnSurface = md_theme_dark_inverseOnSurface,
68-
inverseSurface = md_theme_dark_inverseSurface,
69-
inversePrimary = md_theme_dark_inversePrimary,
70-
surfaceTint = md_theme_dark_surfaceTint,
71-
outlineVariant = md_theme_dark_outlineVariant,
72-
scrim = md_theme_dark_scrim,
73-
)
43+
darkColorScheme(
44+
primary = md_theme_dark_primary,
45+
onPrimary = md_theme_dark_onPrimary,
46+
primaryContainer = md_theme_dark_primaryContainer,
47+
onPrimaryContainer = md_theme_dark_onPrimaryContainer,
48+
secondary = md_theme_dark_secondary,
49+
onSecondary = md_theme_dark_onSecondary,
50+
secondaryContainer = md_theme_dark_secondaryContainer,
51+
onSecondaryContainer = md_theme_dark_onSecondaryContainer,
52+
tertiary = md_theme_dark_tertiary,
53+
onTertiary = md_theme_dark_onTertiary,
54+
tertiaryContainer = md_theme_dark_tertiaryContainer,
55+
onTertiaryContainer = md_theme_dark_onTertiaryContainer,
56+
error = md_theme_dark_error,
57+
errorContainer = md_theme_dark_errorContainer,
58+
onError = md_theme_dark_onError,
59+
onErrorContainer = md_theme_dark_onErrorContainer,
60+
background = md_theme_dark_background,
61+
onBackground = md_theme_dark_onBackground,
62+
surface = md_theme_dark_surface,
63+
onSurface = md_theme_dark_onSurface,
64+
surfaceVariant = md_theme_dark_surfaceVariant,
65+
onSurfaceVariant = md_theme_dark_onSurfaceVariant,
66+
outline = md_theme_dark_outline,
67+
inverseOnSurface = md_theme_dark_inverseOnSurface,
68+
inverseSurface = md_theme_dark_inverseSurface,
69+
inversePrimary = md_theme_dark_inversePrimary,
70+
surfaceTint = md_theme_dark_surfaceTint,
71+
outlineVariant = md_theme_dark_outlineVariant,
72+
scrim = md_theme_dark_scrim,
73+
)
7474

7575
@Composable
7676
fun AppTheme(useDarkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
77-
val colors =
78-
if (!useDarkTheme) {
79-
LightColors
80-
} else {
81-
DarkColors
82-
}
77+
val colors =
78+
if (!useDarkTheme) {
79+
LightColors
80+
} else {
81+
DarkColors
82+
}
8383

84-
MaterialTheme(colorScheme = colors, content = content)
84+
MaterialTheme(colorScheme = colors, content = content)
8585
}

‎build.gradle.kts

+14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
plugins {
22
alias(libs.plugins.androidApplication) apply false
33
alias(libs.plugins.kotlinAndroid) apply false
4+
id("com.diffplug.spotless") version "6.25.0"
5+
}
6+
7+
spotless {
8+
java {
9+
target("app/src/**/*.java", "data/src/**/*.java")
10+
googleJavaFormat("1.22.0").reflowLongStrings()
11+
formatAnnotations()
12+
}
13+
14+
kotlin {
15+
target("app/src/**/*.kt", "data/src/**/*.kt")
16+
ktfmt("0.54").kotlinlangStyle()
17+
}
418
}

0 commit comments

Comments
 (0)
Please sign in to comment.