Skip to content

Commit

Permalink
Fix missing labels on some tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
JSunde committed Oct 2, 2023
1 parent c765e70 commit e626841
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import android.view.WindowManager
import android.widget.PopupWindow
import com.google.android.ground.databinding.PopupLayoutBinding

/** PopupView for displaying label for [TaskViewWithoutHeader]. */
/** PopupView for displaying label for tasks. */
class TaskHeaderPopupView(val context: Context) {
private var binding: PopupLayoutBinding
private var window: PopupWindow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.google.android.ground.databinding.TaskFragWithCombinedHeaderBinding
import com.google.android.ground.databinding.TaskFragWithHeaderBinding
import com.google.android.ground.databinding.TaskFragWithoutHeaderBinding
import com.google.android.ground.ui.datacollection.tasks.AbstractTaskViewModel

/** Wrapper class for holding entire task's view (except toolbar). */
Expand Down Expand Up @@ -56,23 +55,6 @@ data class TaskViewWithHeader(private val binding: TaskFragWithHeaderBinding) :
}
}

/** Implementation of [TaskView] without an embedded header. */
data class TaskViewWithoutHeader(private val binding: TaskFragWithoutHeaderBinding) : TaskView {

override val actionButtonsContainer = binding.actionButtonsContainer

override val root = binding.root

override fun bind(fragment: Fragment, viewModel: AbstractTaskViewModel) {
binding.viewModel = viewModel
binding.lifecycleOwner = fragment
}

override fun addTaskView(view: View) {
binding.taskContainer.addView(view)
}
}

/** Implementation of [TaskView] with a header that is an extension of the title bar. */
data class TaskViewWithCombinedHeader(private val binding: TaskFragWithCombinedHeaderBinding) :
TaskView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@ import androidx.annotation.StringRes
import androidx.appcompat.content.res.AppCompatResources
import com.google.android.ground.databinding.TaskFragWithCombinedHeaderBinding
import com.google.android.ground.databinding.TaskFragWithHeaderBinding
import com.google.android.ground.databinding.TaskFragWithoutHeaderBinding

/** Factory for creating a [TaskView]. */
object TaskViewFactory {

fun createWithHeader(layoutInflater: LayoutInflater): TaskView =
TaskViewWithHeader(TaskFragWithHeaderBinding.inflate(layoutInflater))

fun createWithoutHeader(layoutInflater: LayoutInflater): TaskView =
TaskViewWithoutHeader(TaskFragWithoutHeaderBinding.inflate(layoutInflater))

/** Creates a TaskView with a header that is an extension of the app bar. */
fun createWithCombinedHeader(
layoutInflater: LayoutInflater,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ class CaptureLocationTaskFragment :
@Inject lateinit var map: MapFragment

override fun onCreateTaskView(inflater: LayoutInflater, container: ViewGroup?): TaskView =
TaskViewFactory.createWithCombinedHeader(
inflater,
R.drawable.outline_pin_drop,
R.string.capture_location
)
TaskViewFactory.createWithCombinedHeader(inflater, R.drawable.outline_pin_drop)

override fun onCreateTaskBody(inflater: LayoutInflater): View {
val rowLayout = LinearLayout(requireContext()).apply { id = View.generateViewId() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ class DropAPinTaskFragment : Hilt_DropAPinTaskFragment<DropAPinTaskViewModel>()
@Inject lateinit var map: MapFragment

override fun onCreateTaskView(inflater: LayoutInflater, container: ViewGroup?): TaskView =
TaskViewFactory.createWithCombinedHeader(
inflater,
R.drawable.outline_pin_drop,
R.string.drop_a_pin
)
TaskViewFactory.createWithCombinedHeader(inflater, R.drawable.outline_pin_drop)

override fun onCreateTaskBody(inflater: LayoutInflater): View {
val rowLayout = LinearLayout(requireContext()).apply { id = View.generateViewId() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ class PolygonDrawingTaskFragment : Hilt_PolygonDrawingTaskFragment<PolygonDrawin
private lateinit var polygonDrawingMapFragment: PolygonDrawingMapFragment

override fun onCreateTaskView(inflater: LayoutInflater, container: ViewGroup?): TaskView =
TaskViewFactory.createWithCombinedHeader(
inflater,
R.drawable.outline_draw,
R.string.draw_an_area
)
TaskViewFactory.createWithCombinedHeader(inflater, R.drawable.outline_draw)

override fun onCreateTaskBody(inflater: LayoutInflater): View {
val rowLayout = LinearLayout(requireContext()).apply { id = View.generateViewId() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
android:gravity="center_vertical"
android:textColor="?attr/colorOnSurface"
android:textSize="16sp"
android:text="@{viewModel.task.label}"
tools:text="Task label" />
</LinearLayout>

Expand Down
3 changes: 0 additions & 3 deletions ground/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@

<string name="new_site">New data collection site</string>
<string name="new_site_hint_text">Add new site and submit related data</string>
<string name="drop_a_pin">Drop a pin</string>
<string name="drop_a_pin_tooltip_text">Drag your map until the center pin is on the desired location</string>
<string name="draw_an_area">Draw an area</string>
<string name="current_location">Current location</string>
<string name="loading">Loading…</string>
<string name="skip_dialog_title">Skip this step?</string>
Expand All @@ -165,7 +163,6 @@
<string name="offline_area_size_loading_symbol">…</string>
<string name="offline_area_select_cancel_button">Cancel</string>
<string name="offline_area_selector_title">Download this area?</string>
<string name="capture_location">Capture location</string>
<string name="capture">Capture</string>
<string name="surveys">Surveys</string>
<string name="offline_icon_description">Icon shown when the survey is available offline</string>
Expand Down

0 comments on commit e626841

Please sign in to comment.