1 /*
2  * Copyright (C) 2021 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.permissioncontroller.permission.ui.handheld
18 
19 import android.os.Bundle
20 import android.view.LayoutInflater
21 import android.view.View
22 import android.view.ViewGroup
23 import com.android.permissioncontroller.R
24 import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseFragment
25 
26 /**
27  * Wrapper over HandheldUnusedAppsFragment
28  */
29 class HandheldUnusedAppsWrapperFragment : CollapsingToolbarBaseFragment() {
30     companion object {
31         /** Create a new instance of this fragment.  */
32         @JvmStatic
33         fun newInstance(): HandheldUnusedAppsWrapperFragment {
34             return HandheldUnusedAppsWrapperFragment()
35         }
36     }
37 
38     override fun onCreateView(
39         inflater: LayoutInflater,
40         container: ViewGroup?,
41         savedInstanceState: Bundle?
42     ): View? {
43         val view = super.onCreateView(inflater, container, savedInstanceState)
44         inflater.inflate(R.layout.settings_fragment_include, contentFrameLayout)
45         return view
46     }
47 
48     override fun onActivityCreated(savedInstanceState: Bundle?) {
49         super.onActivityCreated(savedInstanceState)
50         var preferenceFragment = childFragmentManager
51                 .findFragmentById(R.id.preference_fragment_container)
52                 as HandheldUnusedAppsFragment?
53         if (preferenceFragment == null) {
54             preferenceFragment = HandheldUnusedAppsFragment.newInstance()
55             preferenceFragment.arguments = arguments
56             childFragmentManager.beginTransaction()
57                     .add(R.id.preference_fragment_container, preferenceFragment)
58                     .commit()
59         }
60     }
61 }
62