[MWA-5265] Meta Demo: Theming via xml
{CR fixes}
This commit is contained in:
parent
74845b8cb1
commit
ac84869d1e
@ -1,56 +0,0 @@
|
||||
apply plugin: "maven-publish"
|
||||
|
||||
configurations.maybeCreate("default")
|
||||
def publishArtifact = artifacts.add("default", file('src/lib/ahoysdk.aar'))
|
||||
|
||||
// set maven repository URL
|
||||
ext.isSnapshot = ahoy_library_versionName.endsWith("-SNAPSHOT")
|
||||
def mavenUrl = isSnapshot ? ahoy_publish_snapshotRepositoryUrl : ahoy_publish_releaseRepositoryUrl
|
||||
if (ahoy_publish_toBuildDir.toBoolean()) {
|
||||
mavenUrl = "file://$buildDir/repos/" + isSnapshot ? 'snapshots' : 'releases'
|
||||
}
|
||||
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
aar(MavenPublication) {
|
||||
groupId = ahoy_library_groupId
|
||||
artifactId = ahoy_library_artifactId
|
||||
version = ahoy_library_versionName
|
||||
artifact publishArtifact
|
||||
|
||||
pom.withXml {
|
||||
// 2. add dependencies
|
||||
def dependenciesNode = asNode().appendNode('dependencies')
|
||||
def node = dependenciesNode.appendNode('dependency')
|
||||
node.appendNode('groupId', 'org.java-websocket')
|
||||
node.appendNode('artifactId', 'Java-WebSocket')
|
||||
node.appendNode('version', '1.5.7')
|
||||
node.appendNode('scope', 'compile')
|
||||
|
||||
// 3. configure pom.xml extra information
|
||||
asNode().children().last() + {
|
||||
resolveStrategy = Closure.DELEGATE_FIRST
|
||||
name ahoy_library_name
|
||||
url ahoy_library_url
|
||||
description ahoy_library_description
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Config maven repository
|
||||
repositories {
|
||||
maven {
|
||||
url mavenUrl
|
||||
credentials {
|
||||
username = ahoy_publish_username
|
||||
password = ahoy_publish_password
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
|
||||
ahoy_library_name = Ahoy's native android SDK
|
||||
ahoy_library_description = Ahoy's mobile app SDK for android.
|
||||
ahoy_library_url = https://ahoyrtc.com/
|
||||
|
||||
ahoy_library_groupId = com.ahoyrtc
|
||||
ahoy_library_artifactId= sdk
|
||||
ahoy_library_versionName = 1.47
|
||||
|
||||
|
||||
# url including scheme, host and port
|
||||
ahoy_publish_toBuildDir = false
|
||||
ahoy_publish_snapshotRepositoryUrl=https://api.webid-solutions.de/releases/android/maven/repository/snapshots
|
||||
ahoy_publish_releaseRepositoryUrl=https://api.webid-solutions.de/releases/android/maven/repository/internal
|
||||
|
||||
# Do not put real credentials here!
|
||||
# Instead, copy to ~/.gradle/gradle.properties and set the values there.
|
||||
ahoy_publish_username =
|
||||
ahoy_publish_password =
|
||||
@ -1 +0,0 @@
|
||||
|
||||
Binary file not shown.
@ -56,7 +56,6 @@ dependencies {
|
||||
implementation 'androidx.core:core-ktx:1.12.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.compose.material3:material3:1.4.0'
|
||||
implementation 'androidx.compose.foundation:foundation-layout:1.9.4'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
@ -85,10 +84,9 @@ dependencies {
|
||||
|
||||
implementation("de.webid-solutions:android_document_scanner:20.3.0-SNAPSHOT")
|
||||
|
||||
|
||||
def composeBom = platform('androidx.compose:compose-bom:2025.11.00')
|
||||
implementation composeBom
|
||||
androidTestImplementation composeBom
|
||||
api("de.webid-solutions:android_ui_components:20.3.+") {
|
||||
changing = true
|
||||
}
|
||||
|
||||
// Compose Core Dependencies
|
||||
implementation 'androidx.compose.ui:ui'
|
||||
|
||||
@ -11,16 +11,17 @@ import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.result.ActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import de.webidsolutions.android_ui_components.theming.v4.WebIdThemeProviderV4
|
||||
import de.webidsolutions.auto_ident_product_plugin.AutoIdProductPlugin
|
||||
import de.webidsolutions.eid_product_plugin.EIdProductPlugin
|
||||
import de.webidsolutions.meta_plugin.EMetaPluginFailReason
|
||||
import de.webidsolutions.meta_plugin.WebIdMetaPlugin
|
||||
import de.webidsolutions.metaplugindemo.scenes.MetaPluginDemoScreen
|
||||
import de.webidsolutions.metaplugindemo.scenes.MetaPluginDemoScene
|
||||
import de.webidsolutions.metaplugindemo.scenes.ThemingChoice
|
||||
import de.webidsolutions.metaplugindemo.scenes.UserConfiguration
|
||||
import de.webidsolutions.metaplugindemo.tasks.EApiResult
|
||||
import de.webidsolutions.metaplugindemo.tasks.MetaPluginVerifyTask
|
||||
import de.webidsolutions.mobile_app.sdk.WebIdMobileAppSdkException
|
||||
@ -61,7 +62,7 @@ private val chosenEnvironment: EWebIDEnv = EWebIDEnv.TEST
|
||||
internal class MainActivity : ComponentActivity
|
||||
() {
|
||||
|
||||
private var logText by mutableStateOf("")
|
||||
private var result by mutableStateOf("")
|
||||
|
||||
|
||||
// private lateinit var coreSdk: IWebIdMobileAppSdk
|
||||
@ -69,21 +70,19 @@ internal class MainActivity : ComponentActivity
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContent {
|
||||
MaterialTheme {
|
||||
MetaPluginDemoScreen(
|
||||
logText = logText,
|
||||
onStartClicked = { useAutoIdent, usePayOnServer, useEidOnServer, useVideo, themingChoice ->
|
||||
WebIdThemeProviderV4{
|
||||
MetaPluginDemoScene(
|
||||
result = result,
|
||||
onStartClicked = { userConfiguration ->
|
||||
clearLog()
|
||||
writeLog(getString(R.string.starting))
|
||||
createCoreSdk(
|
||||
useAutoIdent = useAutoIdent,
|
||||
usePayOnServer = usePayOnServer,
|
||||
useEidOnServer = useEidOnServer,
|
||||
useVideo = useVideo,
|
||||
themingChoice = themingChoice
|
||||
userConfiguration = userConfiguration
|
||||
)
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,11 +94,7 @@ internal class MainActivity : ComponentActivity
|
||||
* Creates the Core SDK from the existing credentials.
|
||||
*/
|
||||
private fun createCoreSdk(
|
||||
useAutoIdent: Boolean,
|
||||
usePayOnServer: Boolean,
|
||||
useEidOnServer: Boolean,
|
||||
useVideo: Boolean,
|
||||
themingChoice: ThemingChoice
|
||||
userConfiguration: UserConfiguration
|
||||
) {
|
||||
writeLog(getString(R.string.creating_core_sdk))
|
||||
|
||||
@ -118,10 +113,10 @@ internal class MainActivity : ComponentActivity
|
||||
validateActionId()
|
||||
|
||||
val selectProductPlugins = getSelectedPlugins(
|
||||
useAutoIdent = useAutoIdent,
|
||||
usePayOnServer = usePayOnServer,
|
||||
useEidOnServer = useEidOnServer,
|
||||
useVideo = useVideo
|
||||
useAutoIdent = userConfiguration.useAutoIdent,
|
||||
usePayOnServer = userConfiguration.useAcountId,
|
||||
useEidOnServer = userConfiguration.useEId,
|
||||
useVideo = userConfiguration.useVideoIdent
|
||||
)
|
||||
|
||||
val metaPlugin = WebIdMetaPlugin(
|
||||
@ -135,7 +130,7 @@ internal class MainActivity : ComponentActivity
|
||||
.setOnPostExecuteCallback(
|
||||
metaPluginVerifyCallback(
|
||||
metaPlugin = metaPlugin,
|
||||
themingChoice = themingChoice
|
||||
themingChoice = userConfiguration.themingChoice
|
||||
)
|
||||
)
|
||||
.execute(actionId)
|
||||
@ -171,7 +166,7 @@ internal class MainActivity : ComponentActivity
|
||||
): ArrayList<IProductPluginWebId> {
|
||||
return ArrayList(
|
||||
listOfNotNull(
|
||||
if (useAutoIdent) AutoIdProductPlugin() else null,
|
||||
if (useAutoIdent) AutoIdProductPlugin() else null,
|
||||
if (usePayOnServer) AccountIdProductPlugin() else null,
|
||||
if (useEidOnServer) EIdProductPlugin() else null,
|
||||
if (useVideo) VideoIdProductPlugin(config) else null,
|
||||
@ -179,8 +174,9 @@ internal class MainActivity : ComponentActivity
|
||||
)
|
||||
}
|
||||
|
||||
private fun metaPluginVerifyCallback(metaPlugin: WebIdMetaPlugin,
|
||||
themingChoice: ThemingChoice
|
||||
private fun metaPluginVerifyCallback(
|
||||
metaPlugin: WebIdMetaPlugin,
|
||||
themingChoice: ThemingChoice
|
||||
): (AsyncTaskResultGeneric<VerifyActionIdResult?, EApiResult>) -> Unit {
|
||||
|
||||
return { result ->
|
||||
@ -196,12 +192,12 @@ internal class MainActivity : ComponentActivity
|
||||
}
|
||||
|
||||
ThemingChoice.COMPOSE -> {
|
||||
metaPlugin.startPlugin(
|
||||
this,
|
||||
activityResultLauncher,
|
||||
null,
|
||||
null
|
||||
)
|
||||
metaPlugin.startPlugin(
|
||||
this,
|
||||
activityResultLauncher,
|
||||
null,
|
||||
null
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (e: WebIdMobileAppSdkException) {
|
||||
@ -284,14 +280,14 @@ internal class MainActivity : ComponentActivity
|
||||
*/
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun writeLog(entry: String) {
|
||||
logText += "$entry\n"
|
||||
result += "$entry\n"
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the text log of this activity.
|
||||
*/
|
||||
private fun clearLog() {
|
||||
logText = ""
|
||||
result = ""
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,52 +1,39 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.systemBarsPadding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Checkbox
|
||||
import androidx.compose.material3.CheckboxDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
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
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
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.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
|
||||
|
||||
enum class ThemingChoice() {
|
||||
COMPOSE,
|
||||
XML
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun MetaPluginDemoScreen(
|
||||
logText: String,
|
||||
fun MetaPluginDemoScene(
|
||||
result: String,
|
||||
onStartClicked: (
|
||||
useAutoIdent: Boolean,
|
||||
usePayOnServer: Boolean,
|
||||
useEidOnServer: Boolean,
|
||||
useVideo: Boolean,
|
||||
themingChoice: ThemingChoice
|
||||
UserConfiguration
|
||||
) -> Unit
|
||||
) {
|
||||
var useAutoIdent by remember { mutableStateOf(false) }
|
||||
@ -58,16 +45,19 @@ fun MetaPluginDemoScreen(
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(start = 10.dp, top = 10.dp, end = 10.dp)
|
||||
.padding(
|
||||
start = SpacingV4.S.size,
|
||||
top = SpacingV4.N.size,
|
||||
end = SpacingV4.N.size
|
||||
)
|
||||
.systemBarsPadding()
|
||||
) {
|
||||
Text(
|
||||
TextV4(
|
||||
text = stringResource(R.string.choose_plugins),
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
modifier = Modifier.padding(start = 10.dp)
|
||||
modifier = Modifier.padding(start = SpacingV4.N.size)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
SpacingV4.S.VSpacer()
|
||||
|
||||
Column {
|
||||
CheckboxWithLabel(
|
||||
@ -95,15 +85,14 @@ fun MetaPluginDemoScreen(
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
SpacingV4.L.VSpacer()
|
||||
|
||||
Text(
|
||||
TextV4(
|
||||
text = stringResource(R.string.choose_theming),
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
modifier = Modifier.padding(start = 10.dp)
|
||||
modifier = Modifier.padding(start = SpacingV4.N.size)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
SpacingV4.S.VSpacer()
|
||||
|
||||
Column {
|
||||
CheckboxWithLabel(
|
||||
@ -113,7 +102,7 @@ fun MetaPluginDemoScreen(
|
||||
useXmlTheming = ThemingChoice.COMPOSE
|
||||
}
|
||||
},
|
||||
label = "Standard Theme"
|
||||
label = "Theming with Compose"
|
||||
)
|
||||
|
||||
CheckboxWithLabel(
|
||||
@ -123,72 +112,60 @@ fun MetaPluginDemoScreen(
|
||||
useXmlTheming = ThemingChoice.XML
|
||||
}
|
||||
},
|
||||
label = "Custom Theme (XML)"
|
||||
label = "Theming with XML"
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
SpacingV4.L.VSpacer()
|
||||
|
||||
Text(
|
||||
TextV4(
|
||||
text = stringResource(R.string.log_headline),
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
modifier = Modifier.padding(start = 10.dp)
|
||||
modifier = Modifier.padding(start = SpacingV4.N.size)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
SpacingV4.S.VSpacer()
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 10.dp)
|
||||
.padding(horizontal = SpacingV4.N.size)
|
||||
) {
|
||||
val scrollState = rememberScrollState()
|
||||
|
||||
LaunchedEffect(logText) {
|
||||
LaunchedEffect(result) {
|
||||
scrollState.animateScrollTo(scrollState.maxValue)
|
||||
}
|
||||
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
shape = MaterialTheme.shapes.small
|
||||
) {
|
||||
Text(
|
||||
text = logText.ifEmpty { stringResource(R.string.log_placeholder) },
|
||||
TextV4(
|
||||
text = result.ifEmpty { stringResource(R.string.log_placeholder) },
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(scrollState)
|
||||
.padding(16.dp)
|
||||
.padding(bottom = 80.dp),
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
|
||||
onStartClicked(
|
||||
useAutoIdent,
|
||||
usePayOnServer,
|
||||
useEidOnServer,
|
||||
useVideo,
|
||||
useXmlTheming
|
||||
)
|
||||
},
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.fillMaxWidth()
|
||||
.height(60.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Color(0xFF05B1FB)
|
||||
)
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.start_button),
|
||||
color = Color.White
|
||||
.padding(SpacingV4.S.size),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
SpacingV4.M.VSpacer()
|
||||
|
||||
PrimaryButtonV4(
|
||||
onClick = {
|
||||
onStartClicked(
|
||||
UserConfiguration(
|
||||
useAutoIdent = useAutoIdent,
|
||||
useAcountId = usePayOnServer,
|
||||
useEId = useEidOnServer,
|
||||
useVideoIdent = useVideo,
|
||||
themingChoice = useXmlTheming
|
||||
)
|
||||
)
|
||||
},
|
||||
title = stringResource(R.string.start_button),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,38 +175,33 @@ private fun CheckboxWithLabel(
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
label: String
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Checkbox(
|
||||
checked = checked,
|
||||
onCheckedChange = onCheckedChange,
|
||||
colors = CheckboxDefaults.colors(
|
||||
checkedColor = Color(0xFF05B1FB),
|
||||
checkmarkColor = Color.White
|
||||
)
|
||||
)
|
||||
CheckboxV4(
|
||||
checked = checked,
|
||||
isRequired = false,
|
||||
onCheckedChange = onCheckedChange,
|
||||
text = label,
|
||||
modifier = Modifier.padding(start = SpacingV4.N.size)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.width(2.dp))
|
||||
Text(text = label)
|
||||
}
|
||||
SpacingV4.XXS.VSpacer()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Preview(
|
||||
name = "MetaPluginDemoScreen - Long Log",
|
||||
showBackground = true,
|
||||
showSystemUi = true
|
||||
)
|
||||
@Composable
|
||||
private fun MetaPluginDemoScreenLongLogPreview() {
|
||||
MaterialTheme {
|
||||
MetaPluginDemoScreen(
|
||||
logText = buildString {
|
||||
repeat(20) { index ->
|
||||
appendLine("Log entry ${index + 1}: Processing...")
|
||||
}
|
||||
private fun MetaPluginDemoSceneLongLogPreview() {
|
||||
WebIdThemeProviderV4 {
|
||||
MetaPluginDemoScene(
|
||||
result = buildString {
|
||||
appendLine("Log entry: Processing...")
|
||||
|
||||
},
|
||||
onStartClicked = { _, _, _, _, _ -> }
|
||||
onStartClicked = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
enum class ThemingChoice() {
|
||||
COMPOSE,
|
||||
XML
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package de.webidsolutions.metaplugindemo.scenes
|
||||
|
||||
data class UserConfiguration(
|
||||
val useAutoIdent: Boolean,
|
||||
val useAcountId: Boolean,
|
||||
val useEId: Boolean,
|
||||
val useVideoIdent: Boolean,
|
||||
val themingChoice: ThemingChoice
|
||||
)
|
||||
@ -16,5 +16,4 @@
|
||||
<item name="backgroundSecondary">#FFFFFF</item>
|
||||
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user