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

Enhance edit cell and search layouts #67

Merged
merged 3 commits into from
Jul 23, 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 @@ -62,22 +62,22 @@ class EditBoardCellFragment : Fragment(R.layout.fragment_edit_board_cell) {
viewModel.state.let { uiStateFlow ->
diff(uiStateFlow, { it.pictogram }, ::onPictogramChanged)
diff(uiStateFlow, { it.exit }, ::onExitChanged)
diff(uiStateFlow, {it.column}, ::onColumnChanged)
diff(uiStateFlow, {it.row}, ::onRowChanged)
diff(uiStateFlow, { it.column }, ::onColumnChanged)
diff(uiStateFlow, { it.row }, ::onRowChanged)
}
}

private fun onColumnChanged(column: Int) {
binding.columnLabel.text = getString(R.string.column_label, column)
binding.columnText.setText(column.toString())
}

private fun onRowChanged(row: Int) {
binding.rowLabel.text = getString(R.string.row_label, row)
binding.rowText.setText(row.toString())
}

private fun onPictogramChanged(pictogram: PictogramUI?) {
pictogram?.let {
if(it.url.isNotEmpty()){
if (it.url.isNotEmpty()) {
binding.pictogram.loadUrl(it.url)
binding.keyword.setText(it.keyword)
}
Expand Down
163 changes: 108 additions & 55 deletions app/src/main/res/layout/fragment_edit_board_cell.xml
Original file line number Diff line number Diff line change
@@ -1,71 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:background="@drawable/background_item_cell"
android:orientation="vertical"
android:padding="2dp">
android:layout_height="match_parent">

<TextView
android:id="@+id/rowLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Row: x"/>

<TextView
android:id="@+id/columnLabel"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/keyword_layout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Column: y" />
android:layout_margin="8dp"
android:hint="@string/text"
app:endIconMode="clear_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/pictogram"
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
app:srcCompat="@drawable/ic_image_search"
android:layout_gravity="center_horizontal"/>
<TextView
android:id="@+id/keywordLabel"
android:labelFor="@+id/keyword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/text" />
<EditText
android:id="@+id/keyword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:maxLines="1"
android:maxLength="40"
tools:text="animal"
android:gravity="center"
android:importantForAutofill="no"/>
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/keyword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
tools:text="Ejemplo" />

<LinearLayout
android:layout_width="match_parent"
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/column_layout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/cancel_button"
android:layout_width="0dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:hint="@string/column_label"
app:endIconMode="clear_text"
app:layout_constraintBottom_toTopOf="@id/row_layout"
app:layout_constraintEnd_toStartOf="@id/pictogram"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/pictogram">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/column_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:text="@string/cancel"
android:layout_weight="6"/>
<Button
android:id="@+id/save_button"
android:layout_width="0dp"
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="number"
android:maxLines="1"
tools:text="2" />

</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/row_layout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:hint="@string/row_label"
app:endIconMode="clear_text"
app:layout_constraintBottom_toBottomOf="@id/pictogram"
app:layout_constraintEnd_toStartOf="@id/pictogram"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/column_layout">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/row_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:text="@string/save"
android:layout_weight="6"/>
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="number"
android:maxLines="1"
tools:text="1" />
</com.google.android.material.textfield.TextInputLayout>

</LinearLayout>
<ImageView
android:id="@+id/pictogram"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:contentDescription="@string/picto_description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/keyword_layout"
app:srcCompat="@drawable/ic_image_search" />

<com.google.android.material.button.MaterialButton
android:id="@+id/cancel_button"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:padding="16dp"
android:text="@string/cancel"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/save_button"
app:layout_constraintStart_toStartOf="parent"
app:strokeColor="@color/purple_500" />

</LinearLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/save_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:padding="16dp"
android:text="@string/save"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/cancel_button" />
</androidx.constraintlayout.widget.ConstraintLayout>
83 changes: 46 additions & 37 deletions app/src/main/res/layout/fragment_search_pictograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,54 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/query_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:labelFor="@+id/query_text"
android:text="@string/query_string"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<EditText

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/query_text_layout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:hint="@string/query_string"
android:paddingVertical="16dp"
app:endIconMode="clear_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/query_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
android:maxLength="40"
tools:text="animal"
android:importantForAutofill="no"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/query_label" />
<Button
android:id="@+id/cancel_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:text="@string/cancel"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/search_button"
app:layout_constraintTop_toBottomOf="@id/query_text"
app:layout_constraintHorizontal_weight="1"/>
<Button
android:id="@+id/search_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:text="@string/search"
app:layout_constraintStart_toEndOf="@id/cancel_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/query_text"
app:layout_constraintHorizontal_weight="1"/>
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>


<com.google.android.material.button.MaterialButton
android:id="@+id/cancel_button"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:padding="16dp"
android:text="@string/cancel"
app:layout_constraintEnd_toStartOf="@+id/search_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/query_text_layout"
app:strokeColor="@color/purple_500" />

<com.google.android.material.button.MaterialButton
android:id="@+id/search_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:padding="16dp"
android:text="@string/search"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/cancel_button"
app:layout_constraintTop_toBottomOf="@+id/query_text_layout" />
</androidx.constraintlayout.widget.ConstraintLayout>

<ViewAnimator
Expand Down Expand Up @@ -76,9 +85,9 @@

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/pictogram_list"
android:layout_marginEnd="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:layout_marginEnd="8dp" />

</LinearLayout>

Expand Down
9 changes: 5 additions & 4 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
<string name="select_dashboard">Selecciona tu tablero preferido de la lista</string>
<string name="create_dashboard">Crea tu primer tablero de pictogramas</string>
<string name="new_dashboard">Nuevo tablero</string>
<string name="query_string">Texto de consulta:</string>
<string name="query_string">Texto de consulta</string>
<string name="save">Guardar</string>
<string name="search">Buscar</string>
<string name="cancel">Cancelar</string>
<string name="serverError">Error del servidor: %d</string>
<string name="connectivityError">Error de conectividad</string>
<string name="unknownError">Error desconocido</string>
<string name="noMatchFoundError">No se encontró ningún pictograma para la búsqueda solicitada</string>
<string name="text">Texto:</string>
<string name="column_label">Columna: %d</string>
<string name="row_label">Fila: %d</string>
<string name="text">Texto</string>
<string name="column_label">Columna</string>
<string name="row_label">Fila</string>
<string name="editCell">Editar Celda</string>
<string name="picto_description">Picotograma de la celda</string>
<string name="search_arasaac">Buscar en Arasaac</string>
<string name="new_dashboard_toolbar">Nuevo Tablero</string>
<string name="new_dashboard_name">Nombre</string>
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
<string name="select_dashboard">Select your preferred dashboard from the list</string>
<string name="create_dashboard">Create your first panel of pictograms</string>
<string name="new_dashboard">New dashboard</string>
<string name="query_string">Query string:</string>
<string name="query_string">Query string</string>
<string name="save">Save</string>
<string name="search">Search</string>
<string name="cancel">Cancel</string>
<string name="serverError">Server error: %d</string>
<string name="connectivityError">Connectivity error</string>
<string name="unknownError">Unknown error</string>
<string name="noMatchFoundError">No pictogram found for the requested search</string>
<string name="text">Text:</string>
<string name="column_label">Column: %d\</string>
<string name="row_label">Row: %d\</string>
<string name="text">Text</string>
<string name="column_label">Column</string>
<string name="row_label">Row</string>
<string name="editCell">Edit Cell</string>
<string name="picto_description">Cell pictogram</string>
<string name="search_arasaac">Search Arasaac</string>
<string name="new_dashboard_toolbar">New Dashboard</string>
<string name="new_dashboard_name">Name</string>
Expand Down
Loading