1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.healthconnect.controller.exportimport
18 
19 import android.os.Bundle
20 import android.view.LayoutInflater
21 import android.view.View
22 import android.view.ViewGroup
23 import android.widget.Button
24 import android.widget.ImageView
25 import android.widget.TextView
26 import androidx.fragment.app.Fragment
27 import com.android.healthconnect.controller.R
28 import dagger.hilt.android.AndroidEntryPoint
29 import com.android.healthconnect.controller.utils.convertTextViewIntoLink
30 
31 /**
32  * Fragment to collect user's password to decrypt the imported backup file.
33  */
34 @AndroidEntryPoint(Fragment::class)
35 class ImportDecryptionFragment : Hilt_ImportDecryptionFragment() {
onCreateViewnull36     override fun onCreateView(
37             inflater: LayoutInflater,
38             container: ViewGroup?,
39             savedInstanceState: Bundle?
40     ): View? {
41         val view = inflater.inflate(R.layout.import_decryption_screen, container, false)
42         val pageHeaderView = view.findViewById<TextView>(R.id.page_header_text)
43         val pageHeaderIconView = view.findViewById<ImageView>(R.id.page_header_icon)
44         val cancelButton = view.findViewById<Button>(R.id.export_import_cancel_button)
45         val nextButton = view.findViewById<Button>(R.id.export_import_next_button)
46 
47         val forgottenPasswordLink = view.findViewById<TextView>(R.id.import_decryption_forgotten_password_link)
48 
49         pageHeaderView.text = getString(R.string.import_decryption_title)
50         pageHeaderIconView.setImageResource(R.drawable.ic_password)
51         cancelButton.text = getString(R.string.import_cancel_button)
52         nextButton.text = getString(R.string.import_next_button)
53 
54         val forgottenPasswordLinkText = view.context.getString(R.string.import_decryption_forgotten_password_link_text)
55         val forgottenPasswordLinkAction: View.OnClickListener? = null
56         convertTextViewIntoLink(
57                 forgottenPasswordLink,
58                 forgottenPasswordLinkText,
59                 0,
60                 forgottenPasswordLinkText.length,
61                 forgottenPasswordLinkAction)
62 
63         // TODO(b/325917291): update import state to show appropriate loading notifications on return
64         nextButton.setOnClickListener { requireActivity().finish() }
65         cancelButton.setOnClickListener { requireActivity().finish() }
66 
67         return view
68 
69     }
70 }