• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.google.android.car.kitchensink.insets;
18 
19 import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
20 
21 import android.app.Activity;
22 import android.os.Bundle;
23 import android.view.View;
24 import android.view.WindowInsets;
25 import android.view.WindowInsetsController;
26 
27 import androidx.annotation.Nullable;
28 
29 import com.google.android.car.kitchensink.R;
30 
31 /**
32  * {@link WindowInsetsTestActivity} shows usage of {@link WindowInsetsController} api's to hide
33  * systems bars to present the activity in full screen.
34  */
35 public final class WindowInsetsTestActivity extends Activity {
36     @Override
onCreate(@ullable Bundle savedInstanceState)37     protected void onCreate(@Nullable Bundle savedInstanceState) {
38         super.onCreate(savedInstanceState);
39         hideSysUI();
40 
41         setContentView(R.layout.fullscreen_activity);
42         findViewById(R.id.cancel_button).setOnClickListener(l -> finish());
43     }
44 
hideSysUI()45     private void hideSysUI() {
46         View decorView = getWindow().getDecorView();
47         WindowInsetsController windowInsetsController = decorView.getWindowInsetsController();
48         windowInsetsController.hide(WindowInsets.Type.systemBars());
49         windowInsetsController.setSystemBarsBehavior(BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
50     }
51 }
52