• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
<lambda>null2  * 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.systemui.controls.ui
18 
19 import android.os.Bundle
20 import android.view.View
21 import android.view.ViewGroup
22 import android.view.WindowInsets
23 import android.view.WindowInsets.Type
24 
25 import com.android.systemui.R
26 import com.android.systemui.controls.management.ControlsAnimations
27 import com.android.systemui.util.LifecycleActivity
28 import javax.inject.Inject
29 
30 /**
31  * Displays Device Controls inside an activity
32  */
33 class ControlsActivity @Inject constructor(
34     private val uiController: ControlsUiController
35 ) : LifecycleActivity() {
36 
37     private lateinit var parent: ViewGroup
38 
39     override fun onCreate(savedInstanceState: Bundle?) {
40         super.onCreate(savedInstanceState)
41 
42         setContentView(R.layout.controls_fullscreen)
43 
44         getLifecycle().addObserver(
45             ControlsAnimations.observerForAnimations(
46                 requireViewById<ViewGroup>(R.id.control_detail_root),
47                 window,
48                 intent
49             )
50         )
51 
52         requireViewById<ViewGroup>(R.id.control_detail_root).apply {
53             setOnApplyWindowInsetsListener {
54                 v: View, insets: WindowInsets ->
55                     v.apply {
56                         val l = getPaddingLeft()
57                         val t = getPaddingTop()
58                         val r = getPaddingRight()
59                         setPadding(l, t, r, insets.getInsets(Type.systemBars()).bottom)
60                     }
61 
62                 WindowInsets.CONSUMED
63             }
64         }
65     }
66 
67     override fun onResume() {
68         super.onResume()
69 
70         parent = requireViewById<ViewGroup>(R.id.global_actions_controls)
71         parent.alpha = 0f
72         uiController.show(parent, { finish() }, this)
73 
74         ControlsAnimations.enterAnimation(parent).start()
75     }
76 
77     override fun onBackPressed() {
78         finish()
79     }
80 
81     override fun onPause() {
82         super.onPause()
83 
84         uiController.hide()
85     }
86 }
87