Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobileapps 1821 #250

Merged
merged 3 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ internal fun ProcessDetailFragment.setData(state: ProcessDetailViewState) {
binding.tvDescription.text = dataEntry?.description?.ifEmpty { requireContext().getString(R.string.empty_description) }
binding.tvAssignedValue.apply {
text = if (dataEntry?.startedBy?.groupName?.isEmpty() == true && viewModel.getAPSUser().id == dataEntry.startedBy?.id) {
requireContext().getLocalizedName(dataEntry.startedBy?.let { UserGroupDetails.with(it).name } ?: "")
requireContext().getLocalizedName(dataEntry.startedBy?.let { UserGroupDetails.with(it).name } ?: getString(R.string.text_select_assignee))
} else if (dataEntry?.startedBy?.groupName?.isNotEmpty() == true)
requireContext().getLocalizedName(dataEntry.startedBy?.groupName ?: "")
else requireContext().getLocalizedName(dataEntry?.startedBy?.name ?: "")
requireContext().getLocalizedName(dataEntry.startedBy?.groupName ?: getString(R.string.text_select_assignee))
else requireContext().getLocalizedName(dataEntry?.startedBy?.name ?: getString(R.string.text_select_assignee))
}

if (dataEntry?.processDefinitionId.isNullOrEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class ProcessDetailFragment : BaseDetailFragment(), MavericksView, EntryListener
updateUI(state)
when {
state.requestStartWorkflow is Success && state.requestStartWorkflow.complete -> {
viewModel.updateProcessList()
requireActivity().onBackPressed()
}
}
Expand Down Expand Up @@ -157,7 +158,7 @@ class ProcessDetailFragment : BaseDetailFragment(), MavericksView, EntryListener
.setMessage(getString(R.string.message_content_in_queue))
.setNegativeButton(getString(R.string.dialog_negative_button_task), null)
.setPositiveButton(getString(R.string.dialog_positive_button_task)) { _, _ ->
requireActivity().onBackPressed()
viewModel.startWorkflow()
}
.show()
confirmContentQueueDialog = WeakReference(dialog)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.alfresco.content.browse.processes.details

import com.alfresco.content.browse.processes.list.UpdateProcessData
import com.alfresco.events.EventBus
import kotlinx.coroutines.launch

/**
* update the list of workflow if new entry created
*/
fun ProcessDetailViewModel.updateProcessList() {
viewModelScope.launch {
EventBus.default.send(UpdateProcessData(isRefresh = true))
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
package com.alfresco.content.browse.processes.list

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.TypedValue
import android.view.Gravity
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import androidx.appcompat.widget.ListPopupWindow
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat
import androidx.core.view.setMargins
import com.airbnb.mvrx.Mavericks
import com.airbnb.mvrx.Success
import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
import com.alfresco.content.browse.R
import com.alfresco.content.browse.processes.ProcessDetailActivity
import com.alfresco.content.browse.processes.sheet.ProcessDefinitionsSheet
import com.alfresco.content.data.AnalyticsManager
import com.alfresco.content.data.PageView
import com.alfresco.content.data.ProcessEntry
import com.alfresco.content.getLocalizedName
import com.alfresco.content.listview.processes.ProcessListFragment
import com.google.android.material.floatingactionbutton.FloatingActionButton

/**
* Marked as ProcessesFragment
Expand All @@ -39,6 +47,17 @@ class ProcessesFragment : ProcessListFragment<ProcessesViewModel, ProcessesViewS
super.invalidate()
filterTitle.text = requireContext().getLocalizedName(viewModel.filterName)
rlFilters.contentDescription = getString(R.string.text_filter_option, viewModel.filterName)
scrollToTop()
if (state.request is Success) {
clParent.addView(makeFab(requireContext()))
}
}

private fun scrollToTop() {
if (isResumed && viewModel.scrollToTop) {
recyclerView.layoutManager?.scrollToPosition(0)
viewModel.scrollToTop = false
}
}

private fun setupDropDown() {
Expand All @@ -65,6 +84,27 @@ class ProcessesFragment : ProcessListFragment<ProcessesViewModel, ProcessesViewS
rlFilters.setOnClickListener { filterPopup.show() }
}

private fun makeFab(context: Context) =
FloatingActionButton(context).apply {
layoutParams = CoordinatorLayout.LayoutParams(
CoordinatorLayout.LayoutParams.WRAP_CONTENT,
CoordinatorLayout.LayoutParams.WRAP_CONTENT
).apply {
gravity = Gravity.BOTTOM or Gravity.END
// TODO: define margins
setMargins(
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16f, resources.displayMetrics)
.toInt()
)
}
id = R.id.fab_create_task
contentDescription = context.getString(R.string.title_start_workflow)
setImageResource(R.drawable.ic_add_fab)
setOnClickListener {
ProcessDefinitionsSheet.with().show(parentFragmentManager, null)
}
}

override fun onItemClicked(entry: ProcessEntry) {
startActivity(
Intent(requireActivity(), ProcessDetailActivity::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.alfresco.content.getLocalizedName
import com.alfresco.content.listview.processes.ProcessListViewModel
import com.alfresco.content.listview.processes.ProcessListViewState
import com.alfresco.coroutines.asFlow
import com.alfresco.events.on
import kotlinx.coroutines.launch

/**
Expand All @@ -33,10 +34,17 @@ class ProcessesViewModel(

var filterName: String = ProcessFilters.Active.filter
var filterValue: String = ""
var scrollToTop = false

init {
filterValue = listProcesses.getValue(filterName)
fetchInitial()
viewModelScope.on<UpdateProcessData> {
if (it.isRefresh) {
scrollToTop = true
fetchInitial()
}
}
}

companion object : MavericksViewModelFactory<ProcessesViewModel, ProcessesViewState> {
Expand Down Expand Up @@ -109,3 +117,8 @@ class ProcessesViewModel(
fetchInitial()
}
}

/**
* Mark as UpdateProcessData data class
*/
data class UpdateProcessData(val isRefresh: Boolean)
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ProcessDefinitionsSheet : BottomSheetDialogFragment(), MavericksView {
/**
* returns the instance of ProcessDefinitionsSheet with attached entry as bundle
*/
fun with(entry: Entry) = ProcessDefinitionsSheet().apply {
fun with(entry: Entry? = null) = ProcessDefinitionsSheet().apply {
arguments = bundleOf(Mavericks.KEY_ARG to entry)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.alfresco.content.data.RuntimeProcessDefinitionDataEntry
* Marked as ProcessDefinitionsState
*/
data class ProcessDefinitionsState(
val entry: Entry,
val entry: Entry? = null,
val listProcessDefinitions: List<RuntimeProcessDefinitionDataEntry>? = null
) : MavericksState {
constructor(target: Entry) : this(entry = target)
Expand Down
14 changes: 14 additions & 0 deletions browse/src/main/res/drawable/ic_task.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40dp"
android:height="40dp"
android:viewportWidth="40"
android:viewportHeight="40">
<group>
<clip-path
android:pathData="M8,8h24v24h-24z"/>
<path
android:pathData="M18.95,26L24.6,20.35L23.15,18.9L18.925,23.125L16.825,21.025L15.4,22.45L18.95,26ZM14,30C13.45,30 12.979,29.804 12.587,29.413C12.196,29.021 12,28.55 12,28V12C12,11.45 12.196,10.979 12.587,10.587C12.979,10.196 13.45,10 14,10H22L28,16V28C28,28.55 27.804,29.021 27.413,29.413C27.021,29.804 26.55,30 26,30H14ZM21,17V12H14V28H26V17H21Z"
android:fillColor="?attr/colorControlNormal"
android:fillType="evenOdd"/>
</group>
</vector>
2 changes: 1 addition & 1 deletion browse/src/main/res/layout/fragment_task_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@
android:layout_height="wrap_content"
android:contentDescription="@string/icon_identifier"
android:scaleType="fitCenter"
android:src="@drawable/ic_task_identifier"
android:src="@drawable/ic_task"
app:layout_constraintEnd_toStartOf="@id/tv_tasks_title"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toStartOf="parent"
Expand Down
1 change: 1 addition & 0 deletions browse/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<string name="status_running">Running</string>
<string name="title_workflow">Workflow</string>
<string name="error_select_assignee">Please select assignee</string>
<string name="text_select_assignee">Select assignee</string>


</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ data class ProcessEntry(
/**
* return the ProcessEntry using RuntimeProcessDefinitionDataEntry
*/
fun with(data: RuntimeProcessDefinitionDataEntry, entry: Entry): ProcessEntry {
fun with(data: RuntimeProcessDefinitionDataEntry, entry: Entry?): ProcessEntry {
return ProcessEntry(
id = data.id?.toString() ?: "",
name = data.name ?: "",
Expand Down