blob: 0e5689330bf4033601d6e3c6c979ec23394fa368 [file] [log] [blame]
/*
* Copyright (C) 2019 The Android Open Source Project
*
* 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://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.android.car.setupwizardlib.util;
import android.app.Activity;
import android.graphics.Color;
import android.view.View;
import android.view.Window;
import androidx.core.util.Preconditions;
/**
* Utilities to aid in UI for car setup wizard flow.
*
* @deprecated This class has been deprecated in favour of {@link ImmersiveModeHelper} that offers
* the same functionalities without the static approach.
*/
@Deprecated
public final class CarSetupWizardUiUtils {
private static final String TAG = CarSetupWizardUiUtils.class.getSimpleName();
/** Hide system UI */
public static void hideSystemUI(Activity activity) {
maybeHideSystemUI(activity);
}
/** Hide system UI
* @deprecated Use {@code hideSystemUI}
**/
@Deprecated
public static void maybeHideSystemUI(Activity activity) {
enableImmersiveMode(activity.getWindow());
}
/**
* Enables immersive mode hiding system UI.
*
* @param window to apply immersive mode.
*/
public static void enableImmersiveMode(Window window) {
Preconditions.checkNotNull(window);
// See https://developer.android.com/training/system-ui/immersive#EnableFullscreen
// Enables regular immersive mode.
// For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
// Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
window.getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
// Set the content to appear under the system bars so that the
// content doesn't resize when the system bars hide and show.
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// Hide the nav bar and status bar
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
// Workaround for the issue, StatusBar background hides the buttons (b/154227638).
window.setNavigationBarColor(Color.TRANSPARENT);
window.setStatusBarColor(Color.TRANSPARENT);
}
private CarSetupWizardUiUtils() {
}
}