Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOBILEAPPS-2089 (#300)
Browse files Browse the repository at this point in the history
* disabled favorite feature below 23 version

* json parsed and architecture created for dynamic form

* removed login changes

* removed commented code
aman-alfresco authored Dec 15, 2023
1 parent eddc7bf commit ffe9809
Showing 21 changed files with 497 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -83,7 +83,7 @@ class ProcessDefinitionsSheet : BottomSheetDialogFragment(), MavericksView {

val intent = Intent(
requireActivity(),
Class.forName("com.alfresco.content.browse.processes.ProcessDetailActivity"),
Class.forName("com.alfresco.content.process.ProcessFormActivity"),
)
intent.putExtra(Mavericks.KEY_ARG, processEntry)
startActivity(intent)
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -54,6 +54,8 @@ android {
viewBinding = true
}



compileOptions {
coreLibraryDesugaringEnabled true
}
1 change: 1 addition & 0 deletions browse/build.gradle
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ dependencies {
implementation project(':viewer-text')
implementation project(':viewer')
implementation project(':component')
implementation project(':process-app')

implementation libs.alfresco.content
implementation libs.alfresco.process
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -41,11 +41,11 @@ subprojects {
afterEvaluate {
if(it.hasProperty('android')) {
android {
compileSdkVersion 33
compileSdkVersion 34

defaultConfig {
minSdkVersion 24
targetSdkVersion 33
targetSdkVersion 34
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
4 changes: 3 additions & 1 deletion data/src/main/kotlin/com/alfresco/content/data/Settings.kt
Original file line number Diff line number Diff line change
@@ -23,7 +23,9 @@ class Settings(
if (key != IS_PROCESS_ENABLED_KEY) {
AnalyticsManager().theme(prefs.getString(key, "") ?: "")
}
preferenceChangedFlow.tryEmit(key)
key?.apply {
preferenceChangedFlow.tryEmit(this)
}
}

fun observeChanges() {
21 changes: 20 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -9,6 +9,12 @@ lifecycle = "2.6.1"
navigation = "2.6.0"
okhttp = "4.11.0"
test = "1.5.0"
activity-compose = "1.7.0"
compose-bom = "2023.03.00"


moshi = "1.15.0"
retrofit = "2.9.0"

[libraries]
alfresco-auth = "com.alfresco.android:auth:0.8.1-SNAPSHOT"
@@ -100,6 +106,8 @@ kotlinx-coroutines-test = "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.2"
leakcanary = "com.squareup.leakcanary:leakcanary-android:2.7"

mavericks = "com.airbnb.android:mavericks:3.0.3"
mavericks-compose = "com.airbnb.android:mavericks-compose:3.0.3"
mavericks-navigation = "com.airbnb.android:mavericks-navigation:3.0.3"
mavericks-testing = "com.airbnb.android:mavericks-testing:3.0.3"

mockito-core = "org.mockito:mockito-core:5.4.0"
@@ -119,4 +127,15 @@ spotless = "com.diffplug.spotless:spotless-plugin-gradle:6.19.0"

subsamplingimageview = "com.davemorrissey.labs:subsampling-scale-image-view:3.10.0"

timber = "com.jakewharton.timber:timber:5.0.1"
timber = "com.jakewharton.timber:timber:5.0.1"
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
ui = { group = "androidx.compose.ui", name = "ui" }
ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
material3 = { group = "androidx.compose.material3", name = "material3" }
navigation-compose = "androidx.navigation:navigation-compose:2.7.5"

1 change: 1 addition & 0 deletions process-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
69 changes: 69 additions & 0 deletions process-app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'com.alfresco.content.process'
compileSdk 33

defaultConfig {
minSdk 26
targetSdk 33
vectorDrawables {
useSupportLibrary true
}
}

buildTypes {
release {
minifyEnabled false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}

buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = "1.5.4"
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}

dependencies {

implementation project(':base')
implementation project(':common')
implementation project(':data')

implementation libs.androidx.core
implementation libs.androidx.appcompat
implementation libs.androidx.lifecycle.runtime
implementation libs.activity.compose
implementation platform(libs.compose.bom)
implementation libs.ui
implementation libs.ui.graphics
implementation libs.ui.tooling.preview
implementation libs.material3

implementation libs.navigation.compose
implementation libs.mavericks.compose

androidTestImplementation platform(libs.compose.bom)
androidTestImplementation libs.ui.test.junit4
debugImplementation libs.ui.tooling
debugImplementation libs.ui.test.manifest

}
11 changes: 11 additions & 0 deletions process-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<activity
android:name=".ProcessFormActivity"
android:configChanges="orientation|screenSize"
android:exported="false"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.alfresco.content.process

import android.content.Context
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MavericksViewModel
import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.Success
import com.airbnb.mvrx.Uninitialized
import com.airbnb.mvrx.ViewModelContext
import com.alfresco.content.data.ProcessEntry
import com.alfresco.content.data.ResponseListForm
import com.alfresco.content.data.TaskRepository
import com.alfresco.coroutines.asFlow
import kotlinx.coroutines.launch

data class FormViewState(
val parent: ProcessEntry,
val requestStartForm: Async<ResponseListForm> = Uninitialized,
) : MavericksState {
constructor(target: ProcessEntry) : this(parent = target)
}

class FormViewModel(
state: FormViewState,
val context: Context,
private val repository: TaskRepository,
) : MavericksViewModel<FormViewState>(state) {

init {
getStartForm(state.parent)
}

private fun getStartForm(processEntry: ProcessEntry) {
requireNotNull(processEntry.id)
viewModelScope.launch {
repository::startForm.asFlow(processEntry.id).execute {
when (it) {
is Loading -> copy(requestStartForm = Loading())
is Fail -> copy(requestStartForm = Fail(it.error))
is Success -> {
println("form-data == ${it()}")
copy(requestStartForm = Success(it()))
}

else -> {
this
}
}
}
}
}

companion object : MavericksViewModelFactory<FormViewModel, FormViewState> {

override fun create(
viewModelContext: ViewModelContext,
state: FormViewState,
) = FormViewModel(state, viewModelContext.activity(), TaskRepository())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.alfresco.content.process

import android.os.Bundle
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.alfresco.content.process.ui.FormFragment

@Composable
fun NavigationComponent(extras: Bundle?) {
val navController = rememberNavController()

Surface(modifier = Modifier.fillMaxSize()) {
NavHost(navController = navController, startDestination = "first_screen") {
composable("first_screen") {
// Replace with the content of your first fragment
FormFragment(navController = navController, extras)
}
// Add more composable entries for other fragments in your navigation graph
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.alfresco.content.process

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.alfresco.content.process.ui.theme.AlfrescoBaseTheme

class ProcessFormActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AlfrescoBaseTheme {
// A surface container using the 'background' color from the theme
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
NavigationComponent(intent.extras)
}
}
}
}
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
AlfrescoBaseTheme {
NavigationComponent(null)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.alfresco.content.process.ui

import android.os.Bundle
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.airbnb.mvrx.compose.mavericksActivityViewModel
import com.alfresco.content.process.FormViewModel
import com.alfresco.content.process.ui.components.TextInputField

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun FormFragment(navController: NavController, extras: Bundle?) {
val context = LocalContext.current
Scaffold(
topBar = {
TopAppBar(
title = {
Text(text = "Form Details")
},
navigationIcon = {
IconButton(onClick = { /* Handle navigation icon click */ }) {
// Add navigation icon here
}
},
actions = {
// Add actions if any
},
)
},
content = { padding ->
FormDetailScreen(padding)
},
)
}

@Composable
fun FormDetailScreen(padding: PaddingValues) {
// This will get or create a ViewModel scoped to the Activity.
val viewModel: FormViewModel = mavericksActivityViewModel()

Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
TextInputField(1)
// Add more Composables here based on your UI requirements
}
}

@Preview
@Composable
fun PreviewProcessDetailScreen() {
FormDetailScreen(PaddingValues(16.dp))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.alfresco.content.process.ui.components

data class ComponentSettings(
val id: String,
val placeHolder: String,
val isRequired: Boolean,
val isReadOnly: Boolean,
val value: String,
val minLength: Int,
val maxLength: Int,
val minValue: String,
val maxValue: String,
val options: ComponentOptions,
)

data class ComponentOptions(
val id: String,
val name: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.alfresco.content.process.ui.components

import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TextInputField(maxLines: Int) {
OutlinedTextField(
value = "", // Initial value of the text field
onValueChange = { /* Handle value changes here */ },
modifier = Modifier.padding(16.dp), // Add padding or other modifiers as needed
label = { Text("Enter text") }, // Label for the text field
placeholder = { Text("Type something") }, // Placeholder text
maxLines = maxLines, // Set the maximum number of lines to 1
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Text), // Set keyboard type
// Other optional parameters like keyboardOptions, keyboardActions, etc., can be added as needed
)
}

@Preview
@Composable
fun TextInputFieldPreview() {
TextInputField(1)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.alfresco.content.process.ui.theme

import androidx.compose.ui.graphics.Color

val AlfrescoBlue900 = Color(0xFF1A43A9)
val AlfrescoBlue700 = Color(0xFF1F74DB)
val AlfrescoBlue300 = Color(0xFF6EACFF)

val AlfrescoGray900 = Color(0xFF212328)

val AlfrescoGray90015 = Color(0x26212328)
val AlfrescoGray90030 = Color(0x4D212328)
val AlfrescoGray90060 = Color(0x99212328)
val AlfrescoGray90070 = Color(0xB3212328)
val AlfrescoGray100 = Color(0xFFF5F5F5)

val AlfrescoError = Color(0xFFB8082A)

val Transparent = Color.Transparent
val White = Color.White
val White15 = Color(0x26FFFFFF)
val White60 = Color(0x99FFFFFF)
val ActionModeColor = AlfrescoBlue700 // Using AlfrescoBlue700 as action mode color
val SeparateColorGray = Color(0xFF212121)
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.alfresco.content.process.ui.theme

import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat

private val DarkColorScheme = darkColorScheme(
primary = Color.White,
)
private val LightColorScheme = lightColorScheme(
primary = AlfrescoBlue700, // Replace with your alfresco_blue_700 color
surface = Color.White,
onSurface = Color(0xFF212121), // Replace with your alfresco_gray_900 color
background = Color.White,
onBackground = Color.Black,

/* Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
)

@Composable
fun AlfrescoBaseTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit,
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}

darkTheme -> DarkColorScheme.copy(
secondary = MaterialTheme.colorScheme.primary, //
)
else -> LightColorScheme.copy(
secondary = MaterialTheme.colorScheme.primary, //
)
}
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = colorScheme.primary.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
}
}

MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.alfresco.content.process.ui.theme

import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp

// Set of Material typography styles to start with
val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp,
),
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)
2 changes: 2 additions & 0 deletions process-app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<resources>
</resources>
5 changes: 5 additions & 0 deletions process-app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Theme.Alfrescomobileworkspaceandroid" parent="android:Theme.Material.Light.NoActionBar" />
</resources>
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ include ':move'
include ':component'
include ':app'
//include ':process'
include ':process-app'
//include ':content'
//include ':content-ktx'

0 comments on commit ffe9809

Please sign in to comment.