-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Review screen ux changes like font style, error icon, not answered te…
…xt color etc. (#1737) * Reduce question text font size in review mode. * Do not show help button in review mode. * Add error icon if text is not answered and set error color to text if value is not answered. * spotless apply * update not answered text color. * Address review comment. * Remove test which is not required. * Address review comments. * Address review comments. * Address review comment. * Fix failed test. * Address review comments. * Refactored the code * Refactore the file name. * Fix local unit tests. * Address review comment. * Add more unit tests. * Remove updateUI call from on review button click. --------- Co-authored-by: Santosh Pingle <[email protected]>
- Loading branch information
1 parent
f87fa04
commit 5937cc6
Showing
11 changed files
with
497 additions
and
91 deletions.
There are no files selected for viewing
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
72 changes: 72 additions & 0 deletions
72
datacapture/src/main/java/com/google/android/fhir/datacapture/extensions/MoreHeaderViews.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,72 @@ | ||
/* | ||
* Copyright 2022 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 | ||
* | ||
* http://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.fhir.datacapture.extensions | ||
|
||
import android.text.Spanned | ||
import android.view.View.GONE | ||
import android.view.View.VISIBLE | ||
import android.widget.Button | ||
import android.widget.TextView | ||
import com.google.android.fhir.datacapture.hasHelpButton | ||
import com.google.android.fhir.datacapture.localizedHelpSpanned | ||
import com.google.android.material.card.MaterialCardView | ||
import org.hl7.fhir.r4.model.Questionnaire | ||
|
||
internal fun TextView.updateTextAndVisibility(localizedText: Spanned? = null) { | ||
text = localizedText | ||
visibility = | ||
if (localizedText.isNullOrEmpty()) { | ||
GONE | ||
} else { | ||
VISIBLE | ||
} | ||
} | ||
|
||
/** Returns [VISIBLE] if any of the [view] is visible, [GONE] otherwise. */ | ||
internal fun getHeaderViewVisibility(vararg view: TextView): Int { | ||
if (view.any { it.visibility == VISIBLE }) { | ||
return VISIBLE | ||
} | ||
return GONE | ||
} | ||
|
||
/** | ||
* Initializes the text for [helpTextView] with instructions on how to use the feature, and sets the | ||
* visibility and click listener for the [helpButton] to allow users to access the help information | ||
* and toggles the visibility for view [helpCardView]. | ||
*/ | ||
internal fun initHelpViews( | ||
helpButton: Button, | ||
helpCardView: MaterialCardView, | ||
helpTextView: TextView, | ||
questionnaireItem: Questionnaire.QuestionnaireItemComponent | ||
) { | ||
helpButton.visibility = | ||
if (questionnaireItem.hasHelpButton) { | ||
VISIBLE | ||
} else { | ||
GONE | ||
} | ||
helpButton.setOnClickListener { | ||
helpCardView.visibility = | ||
when (helpCardView.visibility) { | ||
VISIBLE -> GONE | ||
else -> VISIBLE | ||
} | ||
} | ||
helpTextView.updateTextAndVisibility(questionnaireItem.localizedHelpSpanned) | ||
} |
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
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,14 @@ | ||
<vector | ||
android:autoMirrored="true" | ||
android:height="48dp" | ||
android:tint="?attr/colorControlNormal" | ||
android:viewportHeight="48" | ||
android:viewportWidth="48" | ||
android:width="48dp" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M24,34Q24.7,34 25.175,33.525Q25.65,33.05 25.65,32.35Q25.65,31.65 25.175,31.175Q24.7,30.7 24,30.7Q23.3,30.7 22.825,31.175Q22.35,31.65 22.35,32.35Q22.35,33.05 22.825,33.525Q23.3,34 24,34ZM22.65,26.35H25.65V13.7H22.65ZM24,44Q19.9,44 16.25,42.425Q12.6,40.85 9.875,38.125Q7.15,35.4 5.575,31.75Q4,28.1 4,23.95Q4,19.85 5.575,16.2Q7.15,12.55 9.875,9.85Q12.6,7.15 16.25,5.575Q19.9,4 24.05,4Q28.15,4 31.8,5.575Q35.45,7.15 38.15,9.85Q40.85,12.55 42.425,16.2Q44,19.85 44,24Q44,28.1 42.425,31.75Q40.85,35.4 38.15,38.125Q35.45,40.85 31.8,42.425Q28.15,44 24,44Z" | ||
/> | ||
</vector> |
Oops, something went wrong.