This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 496
Trace location icon custom view (DEV) #2597
Merged
AlexanderAlferov
merged 5 commits into
release/2.0.x
from
feature/DEV-trace-location-icon-custom-view
Mar 15, 2021
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1d1abd3
Initial commit
AlexanderAlferov 13c6c16
Initial commit
AlexanderAlferov e7c0d47
Merge branch 'release/2.0.x' into feature/DEV-trace-location-icon-cus…
harambasicluka ca35bb0
Merge branch 'release/2.0.x' into feature/DEV-trace-location-icon-cus…
d4rken 01eac61
Add "HighLightView" that allows setting caption text and allows child…
d4rken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...n/java/de/rki/coronawarnapp/ui/eventregistration/common/TraceLocationCardHighlightView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package de.rki.coronawarnapp.ui.eventregistration.common | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import android.widget.TextView | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import androidx.core.content.ContextCompat | ||
import androidx.core.content.withStyledAttributes | ||
import androidx.core.view.children | ||
import de.rki.coronawarnapp.R | ||
|
||
class TraceLocationCardHighlightView @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0 | ||
) : ConstraintLayout(context, attrs, defStyleAttr) { | ||
|
||
private val captionView: TextView by lazy { findViewById(R.id.caption) } | ||
private val containerView: ConstraintLayout by lazy { findViewById(R.id.container) } | ||
|
||
init { | ||
LayoutInflater.from(context).inflate(R.layout.trace_location_view_cardhighlight, this, true) | ||
|
||
background = ContextCompat.getDrawable(context, R.drawable.trace_location_view_cardhighlight_background) | ||
|
||
context.withStyledAttributes(attrs, R.styleable.TraceLocationHighlightView) { | ||
val captionText = getText(R.styleable.TraceLocationHighlightView_android_text) ?: "" | ||
captionView.text = captionText | ||
} | ||
} | ||
|
||
override fun onFinishInflate() { | ||
children | ||
.filter { it != captionView && it != containerView } | ||
.forEach { | ||
removeView(it) | ||
containerView.addView(it) | ||
} | ||
super.onFinishInflate() | ||
} | ||
|
||
fun setCaption(caption: String) { | ||
captionView.text = caption | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
Corona-Warn-App/src/main/res/drawable/ic_qr_code_list_item_icon.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="42dp" | ||
android:height="42dp" | ||
android:viewportWidth="42" | ||
android:viewportHeight="42"> | ||
<path | ||
android:pathData="M0,18.6667H18.6667V0H0V18.6667ZM4.6667,4.6667H14V14H4.6667V4.6667Z" | ||
android:fillColor="#ffffff"/> | ||
<path | ||
android:pathData="M0,41.9987H18.6667V23.332H0V41.9987ZM4.6667,27.9987H14V37.332H4.6667V27.9987Z" | ||
android:fillColor="#ffffff"/> | ||
<path | ||
android:pathData="M23.333,0V18.6667H41.9997V0H23.333ZM37.333,14H27.9997V4.6667H37.333V14Z" | ||
android:fillColor="#ffffff"/> | ||
<path | ||
android:pathData="M41.9997,37.332H37.333V41.9987H41.9997V37.332Z" | ||
android:fillColor="#ffffff"/> | ||
<path | ||
android:pathData="M27.9997,23.332H23.333V27.9987H27.9997V23.332Z" | ||
android:fillColor="#ffffff"/> | ||
<path | ||
android:pathData="M32.6667,28H28V32.6667H32.6667V28Z" | ||
android:fillColor="#ffffff"/> | ||
<path | ||
android:pathData="M27.9997,32.668H23.333V37.3346H27.9997V32.668Z" | ||
android:fillColor="#ffffff"/> | ||
<path | ||
android:pathData="M32.6667,37.332H28V41.9987H32.6667V37.332Z" | ||
android:fillColor="#ffffff"/> | ||
<path | ||
android:pathData="M37.3337,32.668H32.667V37.3346H37.3337V32.668Z" | ||
android:fillColor="#ffffff"/> | ||
<path | ||
android:pathData="M37.3337,23.332H32.667V27.9987H37.3337V23.332Z" | ||
android:fillColor="#ffffff"/> | ||
<path | ||
android:pathData="M41.9997,28H37.333V32.6667H41.9997V28Z" | ||
android:fillColor="#ffffff"/> | ||
</vector> |
9 changes: 9 additions & 0 deletions
9
Corona-Warn-App/src/main/res/drawable/trace_location_view_cardhighlight_background.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<corners | ||
android:bottomLeftRadius="@dimen/radius_card" | ||
android:bottomRightRadius="@dimen/radius_card" | ||
android:radius="0dp" /> | ||
<solid android:color="@color/colorTraceLocationIconDateBackground" /> | ||
</shape> |
13 changes: 13 additions & 0 deletions
13
Corona-Warn-App/src/main/res/drawable/trace_location_view_cardhighlight_gradient.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<corners | ||
android:radius="0dp" | ||
android:topLeftRadius="@dimen/radius_card" | ||
android:topRightRadius="@dimen/radius_card" /> | ||
<gradient | ||
android:angle="135" | ||
android:centerColor="#6C648C" | ||
android:endColor="#3C8CBB" | ||
android:startColor="#A93F45" /> | ||
</shape> |
72 changes: 72 additions & 0 deletions
72
Corona-Warn-App/src/main/res/layout/trace_location_organiser_qr_codes_list_item.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<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:id="@+id/main_box" | ||
style="@style/ContactDiaryExpandableListItem" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<de.rki.coronawarnapp.ui.eventregistration.common.TraceLocationCardHighlightView | ||
android:id="@+id/icon" | ||
android:layout_width="88dp" | ||
android:layout_height="136dp" | ||
android:layout_margin="16dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="21.01.2021"> | ||
|
||
<ImageView | ||
android:layout_width="42dp" | ||
android:layout_height="42dp" | ||
android:importantForAccessibility="no" | ||
android:src="@drawable/ic_qr_code_list_item_icon" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
</de.rki.coronawarnapp.ui.eventregistration.common.TraceLocationCardHighlightView> | ||
|
||
<TextView | ||
android:id="@+id/title" | ||
style="@style/subtitle" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="12dp" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginEnd="18dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toEndOf="@+id/icon" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="Jahrestreffen der deutschen SAP Anwendergruppe" /> | ||
|
||
<TextView | ||
android:id="@+id/location" | ||
style="@style/TextAppearance.MaterialComponents.Body2" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="12dp" | ||
android:layout_marginEnd="18dp" | ||
android:textColor="#6D7072" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toEndOf="@+id/icon" | ||
app:layout_constraintTop_toBottomOf="@+id/title" | ||
tools:text="Hauptstr. 3, 69115 Heidelberg" /> | ||
|
||
<TextView | ||
android:id="@+id/duration" | ||
style="@style/TextAppearance.MaterialComponents.Body2" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="12dp" | ||
android:layout_marginTop="5dp" | ||
android:layout_marginEnd="18dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toEndOf="@+id/icon" | ||
app:layout_constraintTop_toBottomOf="@+id/location" | ||
tools:text="18:00 - 21:00 Uhr" /> | ||
|
||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
36 changes: 36 additions & 0 deletions
36
Corona-Warn-App/src/main/res/layout/trace_location_view_cardhighlight.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<merge 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:background="@drawable/trace_location_view_cardhighlight_background" | ||
tools:layout_height="wrap_content" | ||
tools:layout_width="wrap_content" | ||
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:id="@+id/container" | ||
android:layout_width="88dp" | ||
android:layout_height="96dp" | ||
android:background="@drawable/trace_location_view_cardhighlight_gradient" | ||
android:padding="16dp" | ||
app:layout_constraintBottom_toTopOf="@+id/caption" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/caption" | ||
style="@style/TextAppearance.MaterialComponents.Body2" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:minHeight="40dp" | ||
android:paddingHorizontal="8dp" | ||
android:paddingVertical="8dp" | ||
android:textSize="13sp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="@id/container" | ||
app:layout_constraintStart_toStartOf="@id/container" | ||
app:layout_constraintTop_toBottomOf="@id/container" | ||
tools:text="21.01.2021" /> | ||
</merge> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usage
Set text as caption by using
android:text
onTraceLocationCardHighlightView
, and any qr codes or other text views that should be displayed on top of the gradient, can be added as child ofTraceLocationCardHighlightView
.The container with the gradient as background has a fixed size, while the caption text has a fixed width, but will grow in height to wrap it's content (i.e. line breaks possible).