forked from google/android-fhir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Catalog, show questionnaire response when submit questionnaire button…
… get clicked. (google#1097) * Sdc gallery app landing page 1. Show Bottom navigation bar with Components and Layouts menus. 2. Implements components screen. 3. Implements layouts screen. 4. Handles bottom navigation clicks. 5. Update actionbar. * Rename file name. * Update components and layouts vector icons. * Sdc gallery app single choice workflow. * Update it as boolean choice. * Address review comments. * Boolean choice component icon. * Spotless apply * Build failures * Delete gallery drawables. * fix package name in nav graph * Spotless apply. * Delete gallery color resource * theme attributes for color value. * bottom view margin * default layout workflow. * apply layout theme * Add filename field to the layout enum. * Update catalog title in toolbar when user navigate back from defalult layout screen. * Display questionnaire response. * Review comment. * Remove commented code * Add submit menu to overflow menu. * Address review comments. * Address review comment.
- Loading branch information
1 parent
b02f8d8
commit e6bb4c4
Showing
9 changed files
with
241 additions
and
6 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
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
82 changes: 82 additions & 0 deletions
82
catalog/src/main/java/com/google/android/fhir/catalog/QuestionnaireResponseFragment.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,82 @@ | ||
/* | ||
* 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 | ||
* | ||
* http: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.fhir.catalog | ||
|
||
import android.os.Bundle | ||
import android.view.Gravity | ||
import android.view.LayoutInflater | ||
import android.view.MenuItem | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Button | ||
import android.widget.TextView | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.fragment.app.Fragment | ||
import androidx.navigation.fragment.NavHostFragment | ||
import androidx.navigation.fragment.navArgs | ||
import org.json.JSONObject | ||
|
||
class QuestionnaireResponseFragment : Fragment() { | ||
private val args: QuestionnaireResponseFragmentArgs by navArgs() | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
return inflater.inflate(R.layout.fragment_questionnaire_response, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
setCloseOnClickListener() | ||
view.findViewById<TextView>(R.id.questionnaire_response_tv).text = | ||
JSONObject(args.questionnaireResponse).toString(2) | ||
} | ||
|
||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
return when (item.itemId) { | ||
android.R.id.home -> { | ||
NavHostFragment.findNavController(this).navigateUp() | ||
true | ||
} | ||
else -> super.onOptionsItemSelected(item) | ||
} | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
setUpActionBar() | ||
} | ||
|
||
private fun setUpActionBar() { | ||
(requireActivity() as AppCompatActivity).supportActionBar?.apply { | ||
setDisplayHomeAsUpEnabled(true) | ||
} | ||
(requireActivity() as MainActivity).setActionBar( | ||
getString(R.string.questionnaire_response_title), | ||
Gravity.START | ||
) | ||
setHasOptionsMenu(true) | ||
} | ||
|
||
private fun setCloseOnClickListener() { | ||
view?.findViewById<Button>(R.id.close_button)?.setOnClickListener { | ||
NavHostFragment.findNavController(this).navigateUp() | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
catalog/src/main/res/layout/fragment_questionnaire_response.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,64 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ScrollView | ||
xmlns:android="http:https://schemas.android.com/apk/res/android" | ||
xmlns:app="http:https://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http:https://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".QuestionnaireResponseFragment" | ||
> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_marginStart="24dp" | ||
android:layout_marginEnd="24dp" | ||
android:paddingBottom="38dp" | ||
> | ||
<TextView | ||
style="@style/TextAppearance.MyQuestionnaire.Header.Text" | ||
android:id="@+id/title_textView" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/questionnaire_submitted" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
/> | ||
<TextView | ||
style="@style/TextAppearance.MyQuestionnaire.Body1" | ||
android:id="@+id/subTitle_tv" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:text="@string/questionnaire_response_subtitle" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/title_textView" | ||
/> | ||
<View | ||
android:id="@+id/line_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="1dp" | ||
android:layout_marginTop="8dp" | ||
android:background="@color/line_24" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/subTitle_tv" | ||
/> | ||
<TextView | ||
style="@style/TextAppearance.MyQuestionnaire.Body1" | ||
android:id="@+id/questionnaire_response_tv" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="20dp" | ||
app:layout_constraintTop_toBottomOf="@id/line_view" | ||
/> | ||
<Button | ||
android:id="@+id/close_button" | ||
android:layout_width="132dp" | ||
android:layout_height="wrap_content" | ||
android:text="@string/close" | ||
android:textAllCaps="false" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/questionnaire_response_tv" | ||
/> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</ScrollView> |
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,12 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<menu | ||
xmlns:android="http:https://schemas.android.com/apk/res/android" | ||
xmlns:app="http:https://schemas.android.com/apk/res-auto" | ||
> | ||
<item | ||
android:id="@+id/submit_questionnaire" | ||
android:title="@string/submit" | ||
app:showAsAction="never" | ||
> | ||
</item> | ||
</menu> |
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