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.
add cancel button in QuestionareFragment (google#1837)
* add cancel button in QuestionareFragment * sync coverage * add confirmation dialog before canceling the questionnaire * Run spotless * Remove incorrect string in styles.xml * Remove duplicate layout style attributes * Use Android system strings for ok/cancel * Remove duplicate review mode * Fix build * Fix cancel string * Remove reading visibility of buttons from theme * Set show cancel button default value to false * Fix build warnings * Remove incorrect use of custom view * Remove unnecessary cancel button handler in the catalog app * Remove duplicate code * Remove duplicate code --------- Co-authored-by: Jing Tang <[email protected]>
- Loading branch information
1 parent
e9e5af3
commit 18e41c0
Showing
11 changed files
with
613 additions
and
241 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...re/src/main/java/com/google/android/fhir/datacapture/QuestionnaireCancelDialogFragment.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,49 @@ | ||
/* | ||
* Copyright 2022-2023 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.datacapture | ||
|
||
import android.app.Dialog | ||
import android.os.Bundle | ||
import androidx.core.os.bundleOf | ||
import androidx.fragment.app.DialogFragment | ||
import androidx.fragment.app.setFragmentResult | ||
import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
|
||
internal class QuestionnaireCancelDialogFragment : DialogFragment() { | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
return MaterialAlertDialogBuilder(requireContext()) | ||
.setMessage(R.string.questionnaire_cancel_text) | ||
.setPositiveButton(android.R.string.ok) { dialog, _ -> | ||
setFragmentResult(REQUEST_KEY, bundleOf(RESULT_KEY to RESULT_YES)) | ||
dialog?.dismiss() | ||
} | ||
.setNegativeButton(android.R.string.cancel) { dialog, _ -> | ||
setFragmentResult(REQUEST_KEY, bundleOf(RESULT_KEY to RESULT_NO)) | ||
dialog?.dismiss() | ||
} | ||
.create() | ||
} | ||
|
||
companion object { | ||
const val TAG = "QuestionnaireCancelDialogFragment" | ||
const val REQUEST_KEY = "request-key" | ||
const val RESULT_KEY = "result-key" | ||
const val RESULT_NO = "no" | ||
const val RESULT_YES = "yes" | ||
} | ||
} |
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
Oops, something went wrong.