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

Render the draw vertex to be open to prevent occluding the target point. #2241

Merged
merged 8 commits into from
Feb 23, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import com.google.android.ground.model.geometry.LineString
import com.google.android.ground.model.geometry.LinearRing
import com.google.android.ground.model.geometry.Polygon
import com.google.android.ground.model.job.Job
import com.google.android.ground.model.job.getDefaultColor
import com.google.android.ground.model.submission.Value
import com.google.android.ground.model.task.Task
import com.google.android.ground.persistence.uuid.OfflineUuidGenerator
import com.google.android.ground.ui.common.SharedViewModel
import com.google.android.ground.ui.datacollection.tasks.AbstractTaskViewModel
import com.google.android.ground.ui.map.Feature
import com.google.android.ground.ui.map.FeatureType
import com.google.android.ground.ui.util.ColorUtil
import javax.inject.Inject
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -43,7 +43,8 @@ class DrawAreaTaskViewModel
@Inject
internal constructor(
private val uuidGenerator: OfflineUuidGenerator,
private val resources: Resources
private val resources: Resources,
private val colorUtil: ColorUtil
) : AbstractTaskViewModel(resources) {

/** Polygon [Feature] being drawn by the user. */
Expand All @@ -64,7 +65,7 @@ internal constructor(

override fun initialize(job: Job, task: Task, value: Value?) {
super.initialize(job, task, value)
strokeColor = job.getDefaultColor()
strokeColor = colorUtil.getColor(R.color.drawAreaLineStringStrokeColor)
}

fun isMarkedComplete(): Boolean = isMarkedComplete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ data class Feature(

enum class VertexStyle {
NONE,
CIRCLE
CIRCLE,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ constructor(private val resources: Resources, private val bitmapUtil: BitmapUtil
// initialization.
private val defaultStrokeWidth by lazy { resources.getDimension(R.dimen.line_geometry_width) }
private val circleCap by lazy {
val bitmap = bitmapUtil.fromVector(R.drawable.ic_endpoint)
val bitmap = bitmapUtil.fromVector(R.drawable.ic_vertex)
CustomCap(BitmapDescriptorFactory.fromBitmap(bitmap))
}

Expand All @@ -65,6 +65,7 @@ constructor(private val resources: Resources, private val bitmapUtil: BitmapUtil
startCap = circleCap
endCap = circleCap
}

val strokeScale = if (selected) 2f else 1f
width = defaultStrokeWidth * strokeScale
color = style.color
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.ground.ui.util

import android.content.Context
import androidx.core.content.ContextCompat
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject

class ColorUtil @Inject internal constructor(@ApplicationContext private val context: Context) {
fun getColor(resId: Int): Int {
return ContextCompat.getColor(context, resId)
}
}
37 changes: 37 additions & 0 deletions ground/src/main/res/drawable/ic_draw_target.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
~ Copyright 2021 Google LLC
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:viewportWidth="8"
android:viewportHeight="8">
<path
android:fillAlpha="0"
android:pathData="M4 1L4 7"
android:strokeWidth="2"
android:strokeColor="@color/drawAreaLineStringStrokeColor"
android:strokeLineCap="round" />
<path
android:fillAlpha="0"
android:pathData="M7 4L1 4"
android:strokeWidth="2"
android:strokeColor="@color/drawAreaLineStringStrokeColor"
android:strokeLineCap="round"/>
</vector>

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
~ Copyright 2021 Google LLC
~ Copyright 2024 Google LLC
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand All @@ -17,13 +17,14 @@
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,12m-10.5,0a10.5,10.5 0,1 1,21 0a10.5,10.5 0,1 1,-21 0"
android:strokeWidth="3"
android:fillColor="#ffffff"
android:strokeColor="#E59810"/>
android:strokeColor="@color/drawAreaLineStringStrokeColor"/>
</vector>

8 changes: 4 additions & 4 deletions ground/src/main/res/layout/map_task_frag.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
layout="@layout/basemap_layout"
app:fragment="@{fragment}"
app:viewModel="@{viewModel}" />

<androidx.constraintlayout.utils.widget.ImageFilterView
android:id="@+id/centerMarker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_gps_lock"
android:tint="@android:color/white" />

android:scaleType="centerInside"
android:scaleX="0.5"
android:scaleY="0.5"
android:src="@drawable/ic_draw_target" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/hintIcon"
android:layout_width="wrap_content"
Expand Down
2 changes: 2 additions & 0 deletions ground/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<color name="clusterBalloonStrokeColor">#4B6DDD81</color>
<color name="textOverMap">#FCFDF7</color>
<color name="blackOverlay">#000000</color>
<!-- DrawArea color palette -->
<color name="drawAreaLineStringStrokeColor">#EDAE3D</color>

<!-- Updated Color palette -->
<color name="md_theme_primary">#006E2C</color>
Expand Down
2 changes: 1 addition & 1 deletion ground/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<resources>
<!-- Map -->
<dimen name="line_geometry_width">4dp</dimen>
<dimen name="line_geometry_width">2dp</dimen>
<item name="default_marker_scale_factor" format="float" type="dimen">2</item>
<item name="selected_marker_scale_factor" format="float" type="dimen">1.5</item>

Expand Down