Skip to content

Commit

Permalink
Mobileapps 1461 (#184)
Browse files Browse the repository at this point in the history
* added message while uploading the content

* fixed accesibility issue
  • Loading branch information
aman-alfresco authored Oct 14, 2022
1 parent 17c0cd0 commit 431d887
Show file tree
Hide file tree
Showing 22 changed files with 45 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TaskViewerActivity : AppCompatActivity() {

private fun setupActionToasts() = Action.showActionToasts(
lifecycleScope,
findViewById(android.R.id.content),
binding.root,
binding.bottomView
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.alfresco.content.browse.preview.LocalPreviewActivity
import com.alfresco.content.browse.tasks.BaseDetailFragment
import com.alfresco.content.browse.tasks.detail.TaskDetailViewModel
import com.alfresco.content.browse.tasks.detail.TaskDetailViewState
import com.alfresco.content.browse.tasks.detail.executePreview
import com.alfresco.content.data.AnalyticsManager
import com.alfresco.content.data.Entry
import com.alfresco.content.data.PageView
Expand Down Expand Up @@ -151,7 +152,7 @@ class AttachedFilesFragment : BaseDetailFragment(), MavericksView, EntryListener

private fun onItemClicked(contentEntry: Entry) {
if (!contentEntry.isUpload)
viewModel.execute(ActionOpenWith(Entry.convertContentEntryToEntry(contentEntry, MimeType.isDocFile(contentEntry.mimeType))))
viewModel.executePreview(ActionOpenWith(Entry.convertContentEntryToEntry(contentEntry, MimeType.isDocFile(contentEntry.mimeType))))
}

override fun onEntryCreated(entry: ParentEntry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ class TaskDetailFragment : BaseDetailFragment(), MavericksView, EntryListener {

binding.tvPriorityValue.updatePriorityView(dataObj.priority)
binding.tvAssignedValue.apply {
if (viewModel.getAPSUser().id == dataObj.assignee?.id) {
text = dataObj.assignee?.let { UserDetails.with(it).name }
} else text = dataObj.assignee?.name
text = if (viewModel.getAPSUser().id == dataObj.assignee?.id) {
dataObj.assignee?.let { UserDetails.with(it).name }
} else dataObj.assignee?.name
}
binding.tvIdentifierValue.text = dataObj.id
binding.tvTaskDescription.text = if (dataObj.description.isNullOrEmpty()) requireContext().getString(R.string.empty_description) else dataObj.description
Expand Down Expand Up @@ -335,7 +335,7 @@ class TaskDetailFragment : BaseDetailFragment(), MavericksView, EntryListener {

private fun onItemClicked(contentEntry: Entry) {
if (!contentEntry.isUpload)
viewModel.execute(ActionOpenWith(Entry.convertContentEntryToEntry(contentEntry, MimeType.isDocFile(contentEntry.mimeType))))
viewModel.executePreview(ActionOpenWith(Entry.convertContentEntryToEntry(contentEntry, MimeType.isDocFile(contentEntry.mimeType))))
}

internal fun taskCompletePrompt() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fun TaskDetailViewModel.updateTaskList() {
/**
* execute "open with" action to download the content data
*/
fun TaskDetailViewModel.execute(action: Action) {
fun TaskDetailViewModel.executePreview(action: Action) {
val entry = action.entry as Entry
val file = File(repository.session.contentDir, entry.fileName)
if (!entry.isDocFile && repository.session.isFileExists(file) && file.length() != 0L) {
Expand All @@ -41,6 +41,5 @@ fun TaskDetailViewModel.isCompleteButtonVisible(state: TaskDetailViewState): Boo
return false
if (hasTaskEditMode)
return true
return if (state.parent?.assignee?.id == repository.getAPSUser().id) true
else state.parent?.involvedPeople?.find { it.id == repository.getAPSUser().id } != null
return state.parent?.assignee?.id == repository.getAPSUser().id
}
6 changes: 3 additions & 3 deletions browse/src/main/res/layout/activity_task_viewer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_height="match_parent"
android:orientation="vertical">

<fragment
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
Expand All @@ -15,9 +15,9 @@
<View
android:id="@+id/bottom_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_height="0dp"
android:background="@android:color/white"
android:backgroundTint="?attr/separatorColor"
android:visibility="gone" />
android:visibility="visible" />

</LinearLayout>
2 changes: 0 additions & 2 deletions browse/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
<string name="title_task_view">Aufgabenansicht</string>
<string name="title_comments">Kommentare</string>
<string name="title_due_date">Fälligkeitsdatum</string>
<string name="title_priority">Priorität</string>
<string name="title_assignee">Zugewiesener Benutzer</string>
<string name="title_status">Status</string>
<string name="title_identifier">Identifikator</string>
<string name="text_add_a_comment">Einen Kommentar hinzufügen...</string>
Expand Down
2 changes: 0 additions & 2 deletions browse/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
<string name="title_task_view">Ver tarea</string>
<string name="title_comments">Comentarios</string>
<string name="title_due_date">Fecha de vencimiento</string>
<string name="title_priority">Prioridad</string>
<string name="title_assignee">Usuario asignado</string>
<string name="title_status">Estado</string>
<string name="title_identifier">Identificador</string>
<string name="text_add_a_comment">Añadir un comentario...</string>
Expand Down
2 changes: 0 additions & 2 deletions browse/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
<string name="title_task_view">Affichage de la tâche</string>
<string name="title_comments">Commentaires</string>
<string name="title_due_date">Date d\'échéance</string>
<string name="title_priority">Priorité</string>
<string name="title_assignee">Personne assignée</string>
<string name="title_status">Statut</string>
<string name="title_identifier">Identifiant</string>
<string name="text_add_a_comment">Ajoutez un commentaire&#8230;</string>
Expand Down
2 changes: 0 additions & 2 deletions browse/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
<string name="title_task_view">Visualizzazione compito</string>
<string name="title_comments">Commenti</string>
<string name="title_due_date">Scadenza</string>
<string name="title_priority">Priorità</string>
<string name="title_assignee">Assegnatario</string>
<string name="title_status">Stato</string>
<string name="title_identifier">Identificativo</string>
<string name="text_add_a_comment">Aggiungere un commento&#8230;</string>
Expand Down
2 changes: 0 additions & 2 deletions browse/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
<string name="title_task_view">Taakweergave</string>
<string name="title_comments">Opmerkingen</string>
<string name="title_due_date">Vervaldatum</string>
<string name="title_priority">Prioriteit</string>
<string name="title_assignee">Toegewezen persoon</string>
<string name="title_status">Status</string>
<string name="title_identifier">Identificatie</string>
<string name="text_add_a_comment">Een opmerking toevoegen&#8230;</string>
Expand Down
2 changes: 0 additions & 2 deletions browse/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
<string name="title_task_view">Task View</string>
<string name="title_comments">Comments</string>
<string name="title_due_date">Due date</string>
<string name="title_priority">Priority</string>
<string name="title_assignee">Assignee</string>
<string name="title_status">Status</string>
<string name="title_identifier">Identifier</string>
<string name="text_add_a_comment">Add a comment&#8230;</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ data class ResponseList(
/**
* return the ResponseList obj using ResultList
*/
fun with(raw: ResultList): ResponseList {
fun with(raw: ResultList, apsUser: UserDetails): ResponseList {
return ResponseList(
size = raw.size ?: 0,
total = raw.total ?: 0,
start = raw.start ?: 0,
listTask = raw.data?.map { TaskEntry.with(it) } ?: emptyList()
listTask = raw.data?.map { TaskEntry.with(it, apsUser) } ?: emptyList()
)
}
}
Expand Down
5 changes: 3 additions & 2 deletions data/src/main/kotlin/com/alfresco/content/data/TaskEntry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ data class TaskEntry(
/**
* return the TaskEntry obj using TaskDataEntry
*/
fun with(data: TaskDataEntry, isNewTaskCreated: Boolean = false): TaskEntry {
fun with(data: TaskDataEntry, apsUser: UserDetails? = null, isNewTaskCreated: Boolean = false): TaskEntry {
val isAssigneeUser = apsUser?.id == data.assignee?.id
return TaskEntry(
id = data.id ?: "",
name = data.name ?: "",
description = data.description,
created = data.created,
assignee = data.assignee?.let { UserDetails.with(it) } ?: UserDetails(),
assignee = if (isAssigneeUser) apsUser?.let { UserDetails.with(it) } else data.assignee?.let { UserDetails.with(it) } ?: UserDetails(),
priority = data.priority?.toInt() ?: 0,
endDate = data.endDate,
dueDate = data.dueDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TaskRepository(val session: Session = SessionManager.requireSession) {
suspend fun getTasks(filters: TaskFiltersPayload) = ResponseList.with(
processService.taskList(
includeFilters(filters)
)
), getAPSUser()
)

/**
Expand Down Expand Up @@ -164,7 +164,7 @@ class TaskRepository(val session: Session = SessionManager.requireSession) {
*/
fun getAPSUser(): UserDetails {
return UserDetails(
id = sharedPrefs.getString(KEY_PROCESS_USER_ID, "")?.toInt() ?: 0,
id = sharedPrefs.getString(KEY_PROCESS_USER_ID, "0")?.toInt() ?: 0,
email = sharedPrefs.getString(KEY_PROCESS_USER_EMAIL, "") ?: "",
firstName = sharedPrefs.getString(KEY_PROCESS_USER_FIRST_NAME, "") ?: "",
lastName = sharedPrefs.getString(KEY_PROCESS_USER_LAST_NAME, "") ?: ""
Expand All @@ -176,7 +176,7 @@ class TaskRepository(val session: Session = SessionManager.requireSession) {
*/
suspend fun createTask(name: String, description: String): TaskEntry {
return TaskEntry.with(
processService.createTask(TaskBodyCreate(name = name, description = description)), true
processService.createTask(TaskBodyCreate(name = name, description = description)), isNewTaskCreated = true
)
}

Expand All @@ -202,7 +202,7 @@ class TaskRepository(val session: Session = SessionManager.requireSession) {
priority = taskEntry.priority.toString(),
dueDate = taskEntry.formattedDueDate
)
), true
), isNewTaskCreated = true
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class ListViewTaskRow @JvmOverloads constructor(
fun setData(entry: TaskEntry) {
binding.title.text = entry.name
binding.subtitle.text = entry.assignee?.name
val accessibilityText = context.getString(
R.string.accessibility_text_task_row, entry.name,
entry.assignee?.name, getTaskPriority(entry.priority).value
)
binding.parent.contentDescription = accessibilityText

binding.tvPriority.updatePriorityView(entry.priority)
}
Expand Down
12 changes: 6 additions & 6 deletions listview/src/main/res/layout/view_list_task_row.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:screenReaderFocusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:paddingStart="24dp"
android:paddingEnd="16dp">
android:paddingEnd="16dp"
android:baselineAligned="false">

<LinearLayout
android:layout_width="0dp"
Expand All @@ -23,8 +24,7 @@
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="?attr/textAppearanceSubtitle1"
tools:text="Title" />
android:textAppearance="?attr/textAppearanceSubtitle1" />

<TextView
android:id="@+id/subtitle"
Expand All @@ -33,8 +33,7 @@
android:ellipsize="start"
android:letterSpacing="0"
android:singleLine="true"
android:textAppearance="?attr/textAppearanceCaption"
tools:text="Subtitle" />
android:textAppearance="?attr/textAppearanceCaption" />
</LinearLayout>

<FrameLayout
Expand All @@ -47,6 +46,7 @@
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:background="@drawable/bg_priority_low"
android:gravity="center"
android:letterSpacing="0.02"
android:paddingStart="12dp"
android:paddingTop="6dp"
Expand Down
2 changes: 2 additions & 0 deletions listview/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
<string name="upload_complete_text_multiple">Hochladen von %d Dateien abgeschlossen</string>
<string name="upload_percentage_text">%.1f%%</string>
<string name="text_read_more_space">...Mehr lesen</string>
<string name="title_priority">Priorität</string>
<string name="title_assignee">Zugewiesener Benutzer</string>
</resources>
2 changes: 2 additions & 0 deletions listview/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
<string name="upload_complete_text_multiple">Finalizada la carga de %d fichero(s)</string>
<string name="upload_percentage_text">%.1f%%</string>
<string name="text_read_more_space">...Leer más</string>
<string name="title_priority">Prioridad</string>
<string name="title_assignee">Usuario asignado</string>
</resources>
2 changes: 2 additions & 0 deletions listview/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
<string name="upload_complete_text_multiple">%d fichier(s) a terminé l\'importation</string>
<string name="upload_percentage_text">%.1f%%</string>
<string name="text_read_more_space">...En savoir plus</string>
<string name="title_priority">Priorité</string>
<string name="title_assignee">Personne assignée</string>
</resources>
2 changes: 2 additions & 0 deletions listview/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
<string name="upload_complete_text_multiple">Caricamento di %d file terminato</string>
<string name="upload_percentage_text">%.1f%%</string>
<string name="text_read_more_space">...Ulteriori informazioni</string>
<string name="title_priority">Priorità</string>
<string name="title_assignee">Assegnatario</string>
</resources>
2 changes: 2 additions & 0 deletions listview/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
<string name="upload_complete_text_multiple">Uploaden van %d bestanden is voltooid</string>
<string name="upload_percentage_text">%.1f%%</string>
<string name="text_read_more_space">...Meer info</string>
<string name="title_priority">Prioriteit</string>
<string name="title_assignee">Toegewezen persoon</string>
</resources>
3 changes: 3 additions & 0 deletions listview/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
<string name="upload_complete_text_multiple">%d file(s) finished uploading</string>
<string name="upload_percentage_text">%.1f%%</string>
<string name="text_read_more_space">...Read more</string>
<string name="title_priority">Priority</string>
<string name="title_assignee">Assignee</string>
<string name="accessibility_text_task_row">Title: %s Assignee: %s Priority %s</string>
</resources>

0 comments on commit 431d887

Please sign in to comment.