Skip to content

Commit

Permalink
[MBL-17457][Teacher] Bulk publish updates (#2385)
Browse files Browse the repository at this point in the history
refs: MBL-17457
affects: Teacher
release note: none

* Updated touch targets.

* Fixed callback.

* Fixed tests.
  • Loading branch information
tamaskozmer authored Mar 22, 2024
1 parent 27908ea commit bef25f7
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class ModulesPage : BasePage() {
}

fun assertModuleNotPublished(moduleTitle: String) {
onView(withId(R.id.unpublishedIcon) + hasSibling(withId(R.id.moduleName) + withText(moduleTitle))).assertDisplayed()
onView(withId(R.id.publishedIcon) + hasSibling(withId(R.id.moduleName) + withText(moduleTitle))).assertNotDisplayed()
onView(withId(R.id.unpublishedIcon) + withParent(hasSibling(withId(R.id.moduleName) + withText(moduleTitle)))).assertDisplayed()
onView(withId(R.id.publishedIcon) + withParent(hasSibling(withId(R.id.moduleName) + withText(moduleTitle)))).assertNotDisplayed()
}

/**
Expand All @@ -53,8 +53,8 @@ class ModulesPage : BasePage() {
}

fun assertModuleIsPublished(moduleTitle: String) {
onView(withId(R.id.unpublishedIcon) + hasSibling(withId(R.id.moduleName) + withText(moduleTitle))).assertNotDisplayed()
onView(withId(R.id.publishedIcon) + hasSibling(withId(R.id.moduleName) + withText(moduleTitle))).assertDisplayed()
onView(withId(R.id.unpublishedIcon) + withParent(hasSibling(withId(R.id.moduleName) + withText(moduleTitle)))).assertNotDisplayed()
onView(withId(R.id.publishedIcon) + withParent(hasSibling(withId(R.id.moduleName) + withText(moduleTitle)))).assertDisplayed()
}

/**
Expand Down Expand Up @@ -142,7 +142,7 @@ class ModulesPage : BasePage() {
}

fun clickItemOverflow(itemName: String) {
onView(withParent(withChild(withText(itemName))) + withId(R.id.overflow)).scrollTo().click()
onView(withParent(withChild(withText(itemName))) + withId(R.id.publishActions)).scrollTo().click()
}

fun assertModuleMenuItems() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ModuleListItemBinder :
}
moduleItemLoadingView.setVisible(item.isLoading)

overflow.onClickWithRequireNetwork {
publishActions.onClickWithRequireNetwork {
if (item.type == ModuleItem.Type.File) {
item.contentId?.let {
callback.updateFileModuleItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ModuleListModuleBinder : ListItemBinder<ModuleListItemData.ModuleData, Mod

loadingView.setVisible(item.isLoading)

overflow.onClickWithRequireNetwork {
publishActions.onClickWithRequireNetwork {
val popup = PopupMenu(it.context, it, Gravity.START.and(Gravity.TOP))
popup.inflate(R.menu.menu_module)

Expand All @@ -66,7 +66,7 @@ class ModuleListModuleBinder : ListItemBinder<ModuleListItemData.ModuleData, Mod
}
}

overflow.contentDescription = it.context.getString(R.string.a11y_contentDescription_moduleOptions, item.name)
publishActions.contentDescription = it.context.getString(R.string.a11y_contentDescription_moduleOptions, item.name)
popup.show()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,36 @@ class ModuleListSubHeaderBinder : ListItemBinder<ModuleListItemData.SubHeader, M

moduleItemLoadingView.setVisible(item.isLoading)

overflow.onClickWithRequireNetwork {
publishActions.onClickWithRequireNetwork {
val popup = PopupMenu(it.context, it, Gravity.START.and(Gravity.TOP))
val menu = popup.menu

when (item.published) {
true -> menu.add(0, 0, 0, R.string.unpublish)
false -> menu.add(0, 0, 0, R.string.publish)
false -> menu.add(0, 1, 1, R.string.publish)
else -> {
menu.add(0, 0, 0, R.string.unpublish)
menu.add(0, 1, 1, R.string.publish)
}
}

overflow.contentDescription = it.context.getString(R.string.a11y_contentDescription_moduleOptions, item.title)
popup.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
0 -> {
callback.updateModuleItem(item.id, false)
true
}

1 -> {
callback.updateModuleItem(item.id, true)
true
}

else -> false
}
}

publishActions.contentDescription = it.context.getString(R.string.a11y_contentDescription_moduleOptions, item.title)
popup.show()
}
}
Expand Down
83 changes: 46 additions & 37 deletions apps/teacher/src/main/res/layout/adapter_module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,46 +57,55 @@
android:textStyle="bold"
tools:text="This is for week 1: Origin of the Earth and the Problem with Complexity and Diversity" />

<ImageView
android:id="@+id/publishedIcon"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
android:contentDescription="@string/published"
android:src="@drawable/ic_complete_solid"
android:tint="@color/textSuccess" />
<LinearLayout
android:id="@+id/publishActions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="?attr/selectableItemBackground"
android:paddingStart="8dp"
android:clickable="true"
android:focusable="true"
android:contentDescription="@string/moduleOptions"
android:orientation="horizontal">

<ImageView
android:id="@+id/unpublishedIcon"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
android:contentDescription="@string/not_published"
android:src="@drawable/ic_no"
android:tint="@color/textDark"
tools:visibility="gone" />
<ProgressBar
android:id="@+id/loadingView"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
android:visibility="gone" />

<ProgressBar
android:id="@+id/loadingView"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
android:visibility="gone" />
<ImageView
android:id="@+id/publishedIcon"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
android:contentDescription="@string/published"
android:src="@drawable/ic_complete_solid"
android:tint="@color/textSuccess" />

<ImageView
android:id="@+id/overflow"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:contentDescription="@string/moduleOptions"
android:focusable="true"
android:paddingStart="14dp"
android:paddingTop="14dp"
android:paddingEnd="14dp"
android:paddingBottom="14dp"
android:tint="@color/textDark"
app:srcCompat="@drawable/ic_overflow_white_18dp" />
<ImageView
android:id="@+id/unpublishedIcon"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
android:contentDescription="@string/not_published"
android:src="@drawable/ic_no"
android:tint="@color/textDark"
tools:visibility="gone" />

<ImageView
android:id="@+id/overflow"
android:layout_width="48dp"
android:layout_height="48dp"
android:paddingStart="14dp"
android:paddingTop="14dp"
android:paddingEnd="14dp"
android:paddingBottom="14dp"
android:importantForAccessibility="no"
android:tint="@color/textDark"
app:srcCompat="@drawable/ic_overflow_white_18dp" />
</LinearLayout>

</LinearLayout>

Expand Down
46 changes: 23 additions & 23 deletions apps/teacher/src/main/res/layout/adapter_module_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
android:textColor="@color/textDarkest"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/moduleItemSubtitle"
app:layout_constraintEnd_toStartOf="@+id/statusWrapper"
app:layout_constraintEnd_toStartOf="@+id/publishActions"
app:layout_constraintStart_toEndOf="@id/moduleItemIcon"
app:layout_constraintTop_toTopOf="parent"
tools:text="General Questions &amp; Answers" />
Expand All @@ -72,7 +72,7 @@
android:maxLines="1"
android:textColor="@color/textDark"
app:layout_constraintBottom_toTopOf="@+id/moduleItemSubtitle2"
app:layout_constraintEnd_toStartOf="@+id/statusWrapper"
app:layout_constraintEnd_toStartOf="@+id/publishActions"
app:layout_constraintStart_toEndOf="@id/moduleItemIcon"
app:layout_constraintTop_toBottomOf="@id/moduleItemTitle"
tools:text="Due Apr 25 at 11:59pm" />
Expand All @@ -86,18 +86,23 @@
android:maxLines="1"
android:textColor="@color/textDark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/statusWrapper"
app:layout_constraintEnd_toStartOf="@+id/publishActions"
app:layout_constraintStart_toEndOf="@id/moduleItemIcon"
app:layout_constraintTop_toBottomOf="@id/moduleItemSubtitle"
tools:text="100 pts" />

<LinearLayout
android:id="@+id/statusWrapper"
android:id="@+id/publishActions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="?attr/selectableItemBackground"
android:paddingStart="8dp"
android:orientation="horizontal"
android:clickable="true"
android:focusable="true"
android:contentDescription="@string/moduleOptions"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/overflow"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
Expand All @@ -116,24 +121,19 @@
android:layout_gravity="center_vertical"
android:visibility="gone" />

</LinearLayout>
<ImageView
android:id="@+id/overflow"
android:layout_width="48dp"
android:layout_height="48dp"
android:focusable="true"
android:paddingStart="14dp"
android:paddingTop="14dp"
android:paddingEnd="14dp"
android:paddingBottom="14dp"
android:importantForAccessibility="no"
android:tint="@color/textDark"
app:srcCompat="@drawable/ic_overflow_white_18dp" />

<ImageView
android:id="@+id/overflow"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:contentDescription="@string/moduleOptions"
android:focusable="true"
android:paddingStart="14dp"
android:paddingTop="14dp"
android:paddingEnd="14dp"
android:paddingBottom="14dp"
android:tint="@color/textDark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_overflow_white_18dp" />
</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
41 changes: 20 additions & 21 deletions apps/teacher/src/main/res/layout/adapter_module_sub_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
android:maxLines="1"
android:textColor="@color/textDark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/statusWrapper"
app:layout_constraintEnd_toStartOf="@+id/publishActions"
app:layout_constraintStart_toEndOf="@id/moduleItemIndent"
app:layout_constraintTop_toTopOf="parent"
tools:text="SubHeader title" />
Expand All @@ -53,10 +53,15 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/statusWrapper"
android:id="@+id/publishActions"
android:foreground="?attr/selectableItemBackground"
android:paddingStart="8dp"
android:orientation="horizontal"
android:clickable="true"
android:focusable="true"
android:contentDescription="@string/moduleOptions"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/overflow"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
Expand Down Expand Up @@ -92,24 +97,18 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

</LinearLayout>
<ImageView
android:id="@+id/overflow"
android:layout_width="48dp"
android:layout_height="48dp"
android:paddingStart="14dp"
android:paddingTop="14dp"
android:paddingEnd="14dp"
android:paddingBottom="14dp"
android:importantForAccessibility="no"
android:tint="@color/textDark"
app:srcCompat="@drawable/ic_overflow_white_18dp" />

<ImageView
android:id="@+id/overflow"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:contentDescription="@string/moduleOptions"
android:focusable="true"
android:paddingStart="14dp"
android:paddingTop="14dp"
android:paddingEnd="14dp"
android:paddingBottom="14dp"
android:tint="@color/textDark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_overflow_white_18dp" />
</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit bef25f7

Please sign in to comment.