Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d5962e1 authored by Pat Manning's avatar Pat Manning Committed by Android (Google) Code Review
Browse files

Merge "Create taskbar for kids mode."

parents 922084e5 2c4a1d8f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24">
  <path
      android:fillColor="@android:color/white"
      android:pathData="M21,11.4v1c0,1 -0.8,1.8 -1.8,1.8l0,0h-8.8l2.7,2.7c0.7,0.7 0.7,1.8 0,2.5c0,0 0,0 0,0l-0.7,0.7c-0.7,0.7 -1.8,0.7 -2.5,0c0,0 0,0 0,0l-5.9,-5.9C2.6,13 2.6,11 3.9,9.7l5.9,-5.9c0.7,-0.7 1.8,-0.7 2.5,0c0,0 0,0 0,0l0.7,0.7c0.7,0.7 0.7,1.8 0,2.5c0,0 0,0 0,0l-2.6,2.6h8.7C20.2,9.6 21,10.5 21,11.4z"/>
</vector>
+9 −0
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24">
  <path
      android:fillColor="@android:color/white"
      android:pathData="M22.7,11l-7.9,-7c-1.6,-1.4 -3.9,-1.4 -5.5,0L7.4,5.7V4.1C7.4,3.5 6.9,3 6.3,3H5.2C4.5,3 4,3.5 4,4.1c0,0 0,0 0,0v4.6L1.4,11c-0.5,0.4 -0.5,1.1 -0.1,1.5c0,0 0,0 0,0c0.2,0.2 0.5,0.4 0.8,0.4H4v5c0,1.3 1,2.3 2.3,2.3c0,0 0,0 0,0h11.4c1.3,0 2.3,-1 2.3,-2.3v-5h2c0.6,0 1.1,-0.5 1.1,-1.1C23,11.5 22.9,11.2 22.7,11L22.7,11zM14.3,15.6c0,0.6 -0.5,1.1 -1.1,1.2h-2.3c-0.6,0 -1.1,-0.5 -1.1,-1.1v-1.3c0,-0.6 0.5,-1.1 1.1,-1.1c0,0 0,0 0,0h2.3c0.6,0 1.1,0.5 1.1,1.1c0,0 0,0 0,0L14.3,15.6z"/>
</vector>
+6 −0
Original line number Diff line number Diff line
@@ -231,4 +231,10 @@
    <dimen name="taskbar_stashed_handle_height">4dp</dimen>
    <dimen name="taskbar_edu_wave_anim_trans_y">25dp</dimen>
    <dimen name="taskbar_edu_wave_anim_trans_y_return_overshoot">4dp</dimen>
    <dimen name="taskbar_nav_buttons_width_kids">88dp</dimen>
    <dimen name="taskbar_nav_buttons_height_kids">40dp</dimen>
    <dimen name="taskbar_nav_buttons_corner_radius_kids">40dp</dimen>
    <dimen name="taskbar_back_button_left_margin_kids">96dp</dimen>
    <dimen name="taskbar_home_button_left_margin_kids">48dp</dimen>
    <dimen name="taskbar_icon_size_kids">32dp</dimen>
</resources>
+70 −7
Original line number Diff line number Diff line
@@ -45,10 +45,12 @@ import android.annotation.LayoutRes;
import android.content.pm.ActivityInfo.Config;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Region.Op;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.PaintDrawable;
import android.util.Property;
import android.view.Gravity;
import android.view.MotionEvent;
@@ -58,6 +60,7 @@ import android.view.View.OnHoverListener;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.R;
@@ -128,6 +131,7 @@ public class NavbarButtonsViewController {
    private View mA11yButton;
    private int mSysuiStateFlags;
    private View mBackButton;
    private View mHomeButton;
    private FloatingRotationButton mFloatingRotationButton;

    public NavbarButtonsViewController(TaskbarActivityContext context, FrameLayout navButtonsView) {
@@ -171,6 +175,7 @@ public class NavbarButtonsViewController {

        // Force nav buttons (specifically back button) to be visible during setup wizard.
        boolean isInSetup = !mContext.isUserSetupComplete();
        boolean isInKidsMode = mContext.isNavBarKidsModeActive();
        boolean alwaysShowButtons = isThreeButtonNav || isInSetup;

        // Make sure to remove nav bar buttons translation when notification shade is expanded or
@@ -208,6 +213,64 @@ public class NavbarButtonsViewController {
                        & Configuration.UI_MODE_NIGHT_MASK;
                boolean isDarkTheme = mode == Configuration.UI_MODE_NIGHT_YES;
                mTaskbarNavButtonDarkIntensity.updateValue(isDarkTheme ? 0 : 1);
            } else if (isInKidsMode) {
                int iconSize = mContext.getResources().getDimensionPixelSize(
                        R.dimen.taskbar_icon_size_kids);
                int buttonWidth = mContext.getResources().getDimensionPixelSize(
                        R.dimen.taskbar_nav_buttons_width_kids);
                int buttonHeight = mContext.getResources().getDimensionPixelSize(
                        R.dimen.taskbar_nav_buttons_height_kids);
                int buttonRadius = mContext.getResources().getDimensionPixelSize(
                        R.dimen.taskbar_nav_buttons_corner_radius_kids);
                int paddingleft = (buttonWidth - iconSize) / 2;
                int paddingRight = paddingleft;
                int paddingTop = (buttonHeight - iconSize) / 2;
                int paddingBottom = paddingTop;

                // Update icons
                ((ImageView) mBackButton).setImageDrawable(
                        mBackButton.getContext().getDrawable(R.drawable.ic_sysbar_back_kids));
                ((ImageView) mBackButton).setScaleType(ImageView.ScaleType.FIT_CENTER);
                mBackButton.setPadding(paddingleft, paddingTop, paddingRight, paddingBottom);
                ((ImageView) mHomeButton).setImageDrawable(
                        mHomeButton.getContext().getDrawable(R.drawable.ic_sysbar_home_kids));
                ((ImageView) mHomeButton).setScaleType(ImageView.ScaleType.FIT_CENTER);
                mHomeButton.setPadding(paddingleft, paddingTop, paddingRight, paddingBottom);

                // Home button layout
                LinearLayout.LayoutParams homeLayoutparams = new LinearLayout.LayoutParams(
                        buttonWidth,
                        buttonHeight
                );
                int homeButtonLeftMargin = mContext.getResources().getDimensionPixelSize(
                        R.dimen.taskbar_home_button_left_margin_kids);
                homeLayoutparams.setMargins(homeButtonLeftMargin, 0, 0, 0);
                mHomeButton.setLayoutParams(homeLayoutparams);

                // Back button layout
                LinearLayout.LayoutParams backLayoutParams = new LinearLayout.LayoutParams(
                        buttonWidth,
                        buttonHeight
                );
                int backButtonLeftMargin = mContext.getResources().getDimensionPixelSize(
                        R.dimen.taskbar_back_button_left_margin_kids);
                backLayoutParams.setMargins(backButtonLeftMargin, 0, 0, 0);
                mBackButton.setLayoutParams(backLayoutParams);

                // Button backgrounds
                int whiteWith10PctAlpha = Color.argb(0.1f, 1, 1, 1);
                PaintDrawable buttonBackground = new PaintDrawable(whiteWith10PctAlpha);
                buttonBackground.setCornerRadius(buttonRadius);
                mHomeButton.setBackground(buttonBackground);
                mBackButton.setBackground(buttonBackground);

                // Update alignment within taskbar
                FrameLayout.LayoutParams navButtonsLayoutParams = (FrameLayout.LayoutParams)
                        mNavButtonContainer.getLayoutParams();
                navButtonsLayoutParams.setMarginStart(navButtonsLayoutParams.getMarginEnd() / 2);
                navButtonsLayoutParams.setMarginEnd(navButtonsLayoutParams.getMarginStart());
                navButtonsLayoutParams.gravity = Gravity.CENTER;
                mNavButtonContainer.requestLayout();
            }

            // Animate taskbar background when any of these flags are enabled
@@ -276,9 +339,9 @@ public class NavbarButtonsViewController {
                            && ((flags & FLAG_KEYGUARD_VISIBLE) == 0 || showingOnKeyguard);
                }));
        boolean isRtl = Utilities.isRtl(mContext.getResources());
        mPropertyHolders.add(new StatePropertyHolder(
                mBackButton, flags -> (flags & FLAG_IME_VISIBLE) != 0, View.ROTATION,
                isRtl ? 90 : -90, 0));
        mPropertyHolders.add(new StatePropertyHolder(mBackButton,
                flags -> (flags & FLAG_IME_VISIBLE) != 0 && !mContext.isNavBarKidsModeActive(),
                View.ROTATION, isRtl ? 90 : -90, 0));
        // Translate back button to be at end/start of other buttons for keyguard
        int navButtonSize = mContext.getResources().getDimensionPixelSize(
                R.dimen.taskbar_nav_buttons_size);
@@ -289,16 +352,16 @@ public class NavbarButtonsViewController {


        // home and recents buttons
        View homeButton = addButton(R.drawable.ic_sysbar_home, BUTTON_HOME, navContainer,
        mHomeButton = addButton(R.drawable.ic_sysbar_home, BUTTON_HOME, navContainer,
                navButtonController, R.id.home);
        mPropertyHolders.add(new StatePropertyHolder(homeButton,
        mPropertyHolders.add(new StatePropertyHolder(mHomeButton,
                flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0 &&
                        (flags & FLAG_DISABLE_HOME) == 0));
        View recentsButton = addButton(R.drawable.ic_sysbar_recent, BUTTON_RECENTS,
                navContainer, navButtonController, R.id.recent_apps);
        mPropertyHolders.add(new StatePropertyHolder(recentsButton,
                flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0 &&
                        (flags & FLAG_DISABLE_RECENTS) == 0));
                flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0 && (flags & FLAG_DISABLE_RECENTS) == 0
                        && !mContext.isNavBarKidsModeActive()));

        // A11y button
        mA11yButton = addButton(R.drawable.ic_sysbar_accessibility_button, BUTTON_A11Y,
+9 −1
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ

    private final boolean mIsSafeModeEnabled;
    private final boolean mIsUserSetupComplete;
    private final boolean mIsNavBarKidsMode;
    private boolean mIsDestroyed = false;
    // The flag to know if the window is excluded from magnification region computation.
    private boolean mIsExcludeFromMagnificationRegion = false;
@@ -129,6 +130,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
                () -> getPackageManager().isSafeMode());
        mIsUserSetupComplete = SettingsCache.INSTANCE.get(this).getValue(
                Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0);
        mIsNavBarKidsMode = SettingsCache.INSTANCE.get(this).getValue(
                Settings.Secure.getUriFor(Settings.Secure.NAV_BAR_KIDS_MODE), 0);

        final Resources resources = getResources();
        float taskbarIconSize = resources.getDimension(R.dimen.taskbar_icon_size);
@@ -385,7 +388,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
                | SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
        onNotificationShadeExpandChanged((systemUiStateFlags & shadeExpandedFlags) != 0, fromInit);
        mControllers.taskbarViewController.setRecentsButtonDisabled(
                mControllers.navbarButtonsViewController.isRecentsDisabled());
                mControllers.navbarButtonsViewController.isRecentsDisabled()
                        || isNavBarKidsModeActive());
        mControllers.stashedHandleViewController.setIsHomeButtonDisabled(
                mControllers.navbarButtonsViewController.isHomeDisabled());
        mControllers.taskbarKeyguardController.updateStateForSysuiFlags(systemUiStateFlags);
@@ -587,6 +591,10 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        return mIsUserSetupComplete;
    }

    protected boolean isNavBarKidsModeActive() {
        return mIsNavBarKidsMode && isThreeButtonNav();
    }

    /**
     * Called when we determine the touchable region.
     *
Loading