[MWA-5265] Meta Demo: Theming via xml
{cr fixes}
This commit is contained in:
parent
22a13ded99
commit
907e74114a
@ -57,6 +57,7 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.compose.foundation:foundation-layout:1.9.4'
|
||||
implementation 'androidx.compose.foundation:foundation:1.9.5'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
@ -84,15 +85,9 @@ dependencies {
|
||||
|
||||
implementation("de.webid-solutions:android_document_scanner:20.3.0-SNAPSHOT")
|
||||
|
||||
api("de.webid-solutions:android_ui_components:20.3.+") {
|
||||
changing = true
|
||||
}
|
||||
|
||||
// Compose Core Dependencies
|
||||
implementation 'androidx.compose.ui:ui'
|
||||
implementation 'androidx.compose.ui:ui-graphics'
|
||||
implementation 'androidx.compose.ui:ui-tooling-preview'
|
||||
implementation 'androidx.compose.material3:material3'
|
||||
implementation 'androidx.activity:activity-compose:1.9.3'
|
||||
implementation 'androidx.compose.ui:ui-tooling-preview'
|
||||
debugImplementation 'androidx.compose.ui:ui-tooling'
|
||||
|
||||
@ -51,7 +51,7 @@ private val config = VideoOptionsConfig(
|
||||
)
|
||||
|
||||
// TODO insert your Action id
|
||||
private const val actionId = "<9_digit_webid_transaction_id>"
|
||||
private const val actionId = "347397703"
|
||||
|
||||
// TODO choose your environment
|
||||
private val chosenEnvironment: EWebIDEnv = EWebIDEnv.TEST
|
||||
@ -78,8 +78,8 @@ internal class MainActivity : ComponentActivity
|
||||
MetaPluginDemoScene(
|
||||
result = result,
|
||||
onStartClicked = { userConfiguration ->
|
||||
clearLog()
|
||||
writeLog(getString(R.string.starting))
|
||||
clearResult()
|
||||
showResult(getString(R.string.starting))
|
||||
createCoreSdk(
|
||||
userConfiguration = userConfiguration
|
||||
)
|
||||
@ -99,7 +99,7 @@ internal class MainActivity : ComponentActivity
|
||||
private fun createCoreSdk(
|
||||
userConfiguration: UserConfiguration
|
||||
) {
|
||||
writeLog(getString(R.string.creating_core_sdk))
|
||||
showResult(getString(R.string.creating_core_sdk))
|
||||
|
||||
// should be provided to you -> currently just using demo credentials
|
||||
val selectedUri: URI = chosenEnvironment.uri
|
||||
@ -112,14 +112,14 @@ internal class MainActivity : ComponentActivity
|
||||
*chosenEnvironment.shaPins
|
||||
)
|
||||
|
||||
writeLog(getString(R.string.core_sdk_creation_successful))
|
||||
showResult(getString(R.string.core_sdk_creation_successful))
|
||||
validateActionId()
|
||||
|
||||
val selectProductPlugins = getSelectedPlugins(
|
||||
useAutoIdent = userConfiguration.useAutoIdent,
|
||||
usePayOnServer = userConfiguration.useAcountId,
|
||||
useEidOnServer = userConfiguration.useEId,
|
||||
useVideo = userConfiguration.useVideoIdent
|
||||
useVideoIdent = userConfiguration.useVideoIdent
|
||||
)
|
||||
|
||||
val metaPlugin = WebIdMetaPlugin(
|
||||
@ -143,7 +143,7 @@ internal class MainActivity : ComponentActivity
|
||||
* Validates the WebID actionID
|
||||
*/
|
||||
private fun validateActionId() {
|
||||
writeLog(getString(R.string.validate_action_id))
|
||||
showResult(getString(R.string.validate_action_id))
|
||||
|
||||
try {
|
||||
parseInt(actionId)
|
||||
@ -151,7 +151,7 @@ internal class MainActivity : ComponentActivity
|
||||
throw NumberFormatException()
|
||||
}
|
||||
} catch (e: NumberFormatException) {
|
||||
writeLog(getString(R.string.action_id_not_valid))
|
||||
showResult(getString(R.string.action_id_not_valid))
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,14 +165,14 @@ internal class MainActivity : ComponentActivity
|
||||
useAutoIdent: Boolean,
|
||||
usePayOnServer: Boolean,
|
||||
useEidOnServer: Boolean,
|
||||
useVideo: Boolean
|
||||
useVideoIdent: Boolean
|
||||
): ArrayList<IProductPluginWebId> {
|
||||
return ArrayList(
|
||||
listOfNotNull(
|
||||
if (useAutoIdent) AutoIdProductPlugin() else null,
|
||||
if (usePayOnServer) AccountIdProductPlugin() else null,
|
||||
if (useEidOnServer) EIdProductPlugin() else null,
|
||||
if (useVideo) VideoIdProductPlugin(config) else null,
|
||||
if (useVideoIdent) VideoIdProductPlugin(config) else null,
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -205,11 +205,11 @@ internal class MainActivity : ComponentActivity
|
||||
}
|
||||
} catch (e: WebIdMobileAppSdkException) {
|
||||
e.printStackTrace()
|
||||
writeLog(e.message.toString())
|
||||
showResult(e.message.toString())
|
||||
}
|
||||
} else {
|
||||
val metaPluginVerifyError = result.errorResult
|
||||
writeLog(metaPluginVerifyError.toString())
|
||||
showResult(metaPluginVerifyError.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -233,7 +233,7 @@ internal class MainActivity : ComponentActivity
|
||||
result += " $resultInfo"
|
||||
// your code to handle the successful plugin execution
|
||||
}
|
||||
writeLog(result)
|
||||
showResult(result)
|
||||
} else {
|
||||
// failure case
|
||||
if (failReason.specificResult != null) {
|
||||
@ -243,53 +243,53 @@ internal class MainActivity : ComponentActivity
|
||||
if (specificResult is EMetaPluginFailReason) {
|
||||
if (specificResult == EMetaPluginFailReason.EID_PENDING_AUTHADA) {
|
||||
// handle EID_PENDING_AUTHADA as described in code documentation
|
||||
writeLog("EID_PENDING_AUTHADA")
|
||||
showResult("EID_PENDING_AUTHADA")
|
||||
} else {
|
||||
// handle all other EMetaPluginFailReason as described in code documentation
|
||||
writeLog("MetaPluginFailReason: $specificResult")
|
||||
showResult("MetaPluginFailReason: $specificResult")
|
||||
}
|
||||
} else {
|
||||
// handle EVideoIdentProductPluginFailReasons
|
||||
if (specificResult is VideoIdProductFailReason) {
|
||||
if (specificResult == VideoIdProductFailReason.CALL_CENTER_CLOSED) {
|
||||
// handle CALL_CENTER_CLOSED as described in code documentation
|
||||
writeLog("CALL_CENTER_CLOSED")
|
||||
showResult("CALL_CENTER_CLOSED")
|
||||
} else {
|
||||
// handle all other EVideoIdentProductPluginFailReasons errors as described in the code documentation
|
||||
writeLog("VideoIdentFailReason: $specificResult")
|
||||
showResult("VideoIdentFailReason: $specificResult")
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (failReason.genericResult == EProductPluginErrors.UNKNOWN) {
|
||||
// handle UNKNOWN as described in code documentation
|
||||
writeLog("Unknown Error")
|
||||
showResult("Unknown Error")
|
||||
} else {
|
||||
// handle all other EProductPluginErrors errors as described in the code documentation
|
||||
writeLog("Error: ${failReason.genericResult}")
|
||||
showResult("Error: ${failReason.genericResult}")
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: WebIdPluginInterruptedException) {
|
||||
// Handle interruption in your preferred way
|
||||
writeLog("Plugin interrupted: ${e.message}")
|
||||
showResult("Plugin interrupted: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
/* MISC */
|
||||
|
||||
/**
|
||||
* Add an entry to the log.
|
||||
* Add an entry to the result.
|
||||
*/
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun writeLog(entry: String) {
|
||||
private fun showResult(entry: String) {
|
||||
result += "$entry\n"
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the text log of this activity.
|
||||
* Resets the text result of this activity.
|
||||
*/
|
||||
private fun clearLog() {
|
||||
private fun clearResult() {
|
||||
result = ""
|
||||
}
|
||||
|
||||
|
||||
@ -10,10 +10,8 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.systemBarsPadding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
@ -21,11 +19,12 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import de.webidsolutions.android_ui_components.theming.v4.SpacingV4
|
||||
import de.webidsolutions.android_ui_components.theming.v4.WebIdThemeProviderV4
|
||||
import de.webidsolutions.android_ui_components.theming.v4.components.checkbox.CheckboxTyp
|
||||
import de.webidsolutions.android_ui_components.theming.v4.components.checkbox.CheckboxV4
|
||||
import de.webidsolutions.android_ui_components.theming.v4.components.primary_button.PrimaryButtonV4
|
||||
import de.webidsolutions.android_ui_components.theming.v4.components.surface.Surface
|
||||
import de.webidsolutions.android_ui_components.theming.v4.components.text.TextV4
|
||||
import de.webidsolutions.metaplugindemo.R
|
||||
|
||||
@ -39,133 +38,147 @@ fun MetaPluginDemoScene(
|
||||
var useAutoIdent by remember { mutableStateOf(false) }
|
||||
var usePayOnServer by remember { mutableStateOf(false) }
|
||||
var useEidOnServer by remember { mutableStateOf(false) }
|
||||
var useVideo by remember { mutableStateOf(false) }
|
||||
var useVideoIdent by remember { mutableStateOf(false) }
|
||||
var useXmlTheming by remember { mutableStateOf(ThemingChoice.COMPOSE) }
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(
|
||||
start = SpacingV4.S.size,
|
||||
top = SpacingV4.N.size,
|
||||
end = SpacingV4.N.size
|
||||
)
|
||||
.systemBarsPadding()
|
||||
.padding(top = SpacingV4.N.size)
|
||||
) {
|
||||
TextV4(
|
||||
text = stringResource(R.string.choose_plugins),
|
||||
modifier = Modifier.padding(start = SpacingV4.N.size)
|
||||
)
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(
|
||||
start = SpacingV4.S.size,
|
||||
top = SpacingV4.N.size,
|
||||
end = SpacingV4.N.size
|
||||
)
|
||||
) {
|
||||
item {
|
||||
TextV4(
|
||||
text = stringResource(R.string.choose_plugins),
|
||||
)
|
||||
|
||||
SpacingV4.S.VSpacer()
|
||||
SpacingV4.S.VSpacer()
|
||||
|
||||
Column {
|
||||
CheckboxWithLabel(
|
||||
checked = useAutoIdent,
|
||||
onCheckedChange = { useAutoIdent = it },
|
||||
label = stringResource(R.string.autoid)
|
||||
)
|
||||
Column {
|
||||
CheckboxWithLabel(
|
||||
checked = useAutoIdent,
|
||||
onCheckedChange = { useAutoIdent = it },
|
||||
label = stringResource(R.string.autoid)
|
||||
)
|
||||
|
||||
CheckboxWithLabel(
|
||||
checked = usePayOnServer,
|
||||
onCheckedChange = { usePayOnServer = it },
|
||||
label = stringResource(R.string.accountid)
|
||||
)
|
||||
CheckboxWithLabel(
|
||||
checked = usePayOnServer,
|
||||
onCheckedChange = { usePayOnServer = it },
|
||||
label = stringResource(R.string.accountid)
|
||||
)
|
||||
|
||||
CheckboxWithLabel(
|
||||
checked = useEidOnServer,
|
||||
onCheckedChange = { useEidOnServer = it },
|
||||
label = stringResource(R.string.eid)
|
||||
)
|
||||
CheckboxWithLabel(
|
||||
checked = useEidOnServer,
|
||||
onCheckedChange = { useEidOnServer = it },
|
||||
label = stringResource(R.string.eid)
|
||||
)
|
||||
|
||||
CheckboxWithLabel(
|
||||
checked = useVideo,
|
||||
onCheckedChange = { useVideo = it },
|
||||
label = stringResource(R.string.videoid)
|
||||
)
|
||||
CheckboxWithLabel(
|
||||
checked = useVideoIdent,
|
||||
onCheckedChange = { useVideoIdent = it },
|
||||
label = stringResource(R.string.videoid)
|
||||
)
|
||||
}
|
||||
|
||||
SpacingV4.L.VSpacer()
|
||||
|
||||
TextV4(
|
||||
text = stringResource(R.string.choose_theming),
|
||||
)
|
||||
|
||||
SpacingV4.S.VSpacer()
|
||||
|
||||
Column {
|
||||
CheckboxWithLabel(
|
||||
checked = useXmlTheming == ThemingChoice.COMPOSE,
|
||||
onCheckedChange = { isChecked ->
|
||||
if (isChecked) {
|
||||
useXmlTheming = ThemingChoice.COMPOSE
|
||||
}
|
||||
},
|
||||
label = stringResource(R.string.choose_theming_compose)
|
||||
)
|
||||
|
||||
CheckboxWithLabel(
|
||||
checked = useXmlTheming == ThemingChoice.XML,
|
||||
onCheckedChange = { isChecked ->
|
||||
if (isChecked) {
|
||||
useXmlTheming = ThemingChoice.XML
|
||||
}
|
||||
},
|
||||
label = stringResource(R.string.choose_theming_xml)
|
||||
)
|
||||
}
|
||||
|
||||
SpacingV4.L.VSpacer()
|
||||
|
||||
TextV4(
|
||||
text = stringResource(R.string.log_headline),
|
||||
)
|
||||
|
||||
SpacingV4.S.VSpacer()
|
||||
|
||||
ResultView(result = result.split("\n"))
|
||||
|
||||
SpacingV4.M.VSpacer()
|
||||
}
|
||||
}
|
||||
|
||||
SpacingV4.L.VSpacer()
|
||||
|
||||
TextV4(
|
||||
text = stringResource(R.string.choose_theming),
|
||||
modifier = Modifier.padding(start = SpacingV4.N.size)
|
||||
)
|
||||
|
||||
SpacingV4.S.VSpacer()
|
||||
|
||||
Column {
|
||||
CheckboxWithLabel(
|
||||
checked = useXmlTheming == ThemingChoice.COMPOSE,
|
||||
onCheckedChange = { isChecked ->
|
||||
if (isChecked) {
|
||||
useXmlTheming = ThemingChoice.COMPOSE
|
||||
}
|
||||
},
|
||||
label = "Theming with Compose"
|
||||
)
|
||||
|
||||
CheckboxWithLabel(
|
||||
checked = useXmlTheming == ThemingChoice.XML,
|
||||
onCheckedChange = { isChecked ->
|
||||
if (isChecked) {
|
||||
useXmlTheming = ThemingChoice.XML
|
||||
}
|
||||
},
|
||||
label = "Theming with XML"
|
||||
)
|
||||
}
|
||||
|
||||
SpacingV4.L.VSpacer()
|
||||
|
||||
TextV4(
|
||||
text = stringResource(R.string.log_headline),
|
||||
modifier = Modifier.padding(start = SpacingV4.N.size)
|
||||
)
|
||||
|
||||
SpacingV4.S.VSpacer()
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = SpacingV4.N.size)
|
||||
.padding(
|
||||
start = SpacingV4.S.size,
|
||||
end = SpacingV4.N.size,
|
||||
bottom = SpacingV4.S.size
|
||||
)
|
||||
) {
|
||||
val scrollState = rememberScrollState()
|
||||
|
||||
LaunchedEffect(result) {
|
||||
scrollState.animateScrollTo(scrollState.maxValue)
|
||||
}
|
||||
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
) {
|
||||
TextV4(
|
||||
text = result.ifEmpty { stringResource(R.string.log_placeholder) },
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(scrollState)
|
||||
.padding(SpacingV4.S.size),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
SpacingV4.M.VSpacer()
|
||||
|
||||
PrimaryButtonV4(
|
||||
onClick = {
|
||||
onStartClicked(
|
||||
UserConfiguration(
|
||||
useAutoIdent = useAutoIdent,
|
||||
useAcountId = usePayOnServer,
|
||||
useEId = useEidOnServer,
|
||||
useVideoIdent = useVideo,
|
||||
themingChoice = useXmlTheming
|
||||
PrimaryButtonV4(
|
||||
onClick = {
|
||||
onStartClicked(
|
||||
UserConfiguration(
|
||||
useAutoIdent = useAutoIdent,
|
||||
useAcountId = usePayOnServer,
|
||||
useEId = useEidOnServer,
|
||||
useVideoIdent = useVideoIdent,
|
||||
themingChoice = useXmlTheming
|
||||
)
|
||||
)
|
||||
},
|
||||
title = stringResource(R.string.start_button),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ResultView(
|
||||
result: List<String>,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
if (result.isNotEmpty()) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp)
|
||||
) {
|
||||
result.forEach { result ->
|
||||
TextV4(
|
||||
text = result,
|
||||
modifier = Modifier.padding(vertical = 4.dp)
|
||||
)
|
||||
},
|
||||
title = stringResource(R.string.start_button),
|
||||
)
|
||||
}
|
||||
SpacingV4.S.VSpacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,6 +193,7 @@ private fun CheckboxWithLabel(
|
||||
isRequired = false,
|
||||
onCheckedChange = onCheckedChange,
|
||||
text = label,
|
||||
textTyp = CheckboxTyp.Label,
|
||||
modifier = Modifier.padding(start = SpacingV4.N.size)
|
||||
)
|
||||
|
||||
@ -188,6 +202,7 @@ private fun CheckboxWithLabel(
|
||||
|
||||
|
||||
|
||||
|
||||
@Preview(
|
||||
name = "MetaPluginDemoScreen - Long Log",
|
||||
showBackground = true,
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* Created by WebID Solutions GmbH | www.webid-solutions.de.
|
||||
* See the file "LICENSE" for the full license governing this code.
|
||||
*/
|
||||
package de.webidsolutions.metaplugindemo.scenes
|
||||
|
||||
data class UserConfiguration(
|
||||
|
||||
@ -6,14 +6,15 @@
|
||||
<item name="actionPrimary">#FFD32D1F</item>
|
||||
<item name="actionPrimaryPressed">#FF8A1E15</item>
|
||||
<item name="actionPrimaryHover">#FFE57373</item>
|
||||
<item name="actionPrimaryInvert">#FFFFFFFF</item>
|
||||
<item name="actionDisabled">#FFBDBDBD</item>
|
||||
<item name="actionPrimaryInvert">#FF000000</item>
|
||||
<item name="actionDisabled">#FF666666</item>
|
||||
|
||||
<item name="brandPrimary">#FFD32D1F</item>
|
||||
<item name="brandSecondary">#FF8A1E15</item>
|
||||
|
||||
<item name="backgroundPrimary">#FFFFFFFF</item>
|
||||
<item name="backgroundSecondary">#FFFFFF</item>
|
||||
|
||||
<item name="backgroundPrimary">#FF121212</item>
|
||||
<item name="backgroundSecondary">#FF1E1E1E</item>
|
||||
<item name="android:fontFamily">monospace</item>
|
||||
<item name="primaryButtonCornerRadius">@dimen/webid_button_corner_radius</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@ -3,4 +3,5 @@
|
||||
<dimen name="grid_margin">24dp</dimen>
|
||||
<dimen name="button_height">60dp</dimen>
|
||||
<dimen name="log_margin">40dp</dimen>
|
||||
<dimen name="webid_button_corner_radius">8dp</dimen>
|
||||
</resources>
|
||||
@ -9,4 +9,6 @@
|
||||
<string name="validate_action_id">Validate Action-ID…</string>
|
||||
<string name="action_id_not_valid">Failure: The transaction number (Action-ID) was not set to 9-digit number string in MainActivity.kt file.</string>
|
||||
<string name="choose_theming">Choose A Theme:</string>
|
||||
<string name="choose_theming_compose">Theming with Compose</string>
|
||||
<string name="choose_theming_xml">Theming with XML</string>
|
||||
</resources>
|
||||
@ -11,9 +11,10 @@
|
||||
|
||||
<item name="brandPrimary">#FFD32D1F</item>
|
||||
<item name="brandSecondary">#FF8A1E15</item>
|
||||
<!-- ===== Background Colors ===== -->
|
||||
|
||||
<item name="backgroundPrimary">#FFFFFFFF</item> <!-- Light Cyan (Cyan 50) -->
|
||||
<item name="backgroundSecondary">#FFFFFF</item> <!-- White -->
|
||||
<item name="android:fontFamily">monospace</item>
|
||||
<item name="primaryButtonCornerRadius">@dimen/webid_button_corner_radius</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user