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

Commit 1b077203 authored by Merissa Tan's avatar Merissa Tan Committed by Android (Google) Code Review
Browse files

Merge "Create new DesktopNavbarButtonsViewController class."

parents 36e0fd91 d41ce498
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -246,6 +246,10 @@
    <string name="taskbar_button_ime_switcher">IME switcher</string>
    <!-- Content description for recents button [CHAR_LIMIT=16] -->
    <string name="taskbar_button_recents">Recents</string>
    <!-- Content description for notifications button [CHAR_LIMIT=16] -->
    <string name="taskbar_button_notifications">Notifications</string>
    <!-- Content description for quick settings button [CHAR_LIMIT=16] -->
    <string name="taskbar_button_quick_settings">Quick Settings</string>

    <!-- Label for moving drop target to the top or left side of the screen, depending on orientation (from the taskbar only). -->
    <string name="move_drop_target_top_or_left">Move to top&#47;left</string>
+65 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.launcher3.taskbar;

import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_NOTIFICATIONS;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_QUICK_SETTINGS;

import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.android.launcher3.R;

/**
 * Controller for managing buttons and status icons in taskbar in a desktop environment.
 */
public class DesktopNavbarButtonsViewController extends NavbarButtonsViewController {

    private final TaskbarActivityContext mContext;
    private final FrameLayout mNavButtonsView;
    private final ViewGroup mNavButtonContainer;

    private TaskbarControllers mControllers;

    public DesktopNavbarButtonsViewController(TaskbarActivityContext context,
            FrameLayout navButtonsView) {
        super(context, navButtonsView);
        mContext = context;
        mNavButtonsView = navButtonsView;
        mNavButtonContainer = mNavButtonsView.findViewById(R.id.end_nav_buttons);
    }

    /**
     * Initializes the controller
     */
    @Override
    public void init(TaskbarControllers controllers) {
        mControllers = controllers;
        mNavButtonsView.getLayoutParams().height = mContext.getDeviceProfile().taskbarSize;

        // Quick settings and notifications buttons
        addButton(R.drawable.ic_sysbar_quick_settings, BUTTON_QUICK_SETTINGS,
                mNavButtonContainer, mControllers.navButtonController,
                R.id.quick_settings_button);
        addButton(R.drawable.ic_sysbar_notifications, BUTTON_NOTIFICATIONS,
                mNavButtonContainer, mControllers.navButtonController,
                R.id.notifications_button);
    }

    /** Cleans up on destroy */
    @Override
    public void onDestroy() { }
}
+1 −15
Original line number Diff line number Diff line
@@ -15,15 +15,11 @@
 */
package com.android.launcher3.taskbar;

import static android.content.pm.PackageManager.FEATURE_PC;

import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_A11Y;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_BACK;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_HOME;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_IME_SWITCH;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_NOTIFICATIONS;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_QUICK_SETTINGS;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_RECENTS;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_KEYGUARD;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE;
@@ -325,16 +321,6 @@ public class NavbarButtonsViewController {
        applyState();
        mPropertyHolders.forEach(StatePropertyHolder::endAnimation);

        // quick setting and notification buttons
        if (mContext.getPackageManager().hasSystemFeature(FEATURE_PC)) {
            addButton(R.drawable.ic_sysbar_quick_settings, BUTTON_QUICK_SETTINGS,
                    mNavButtonContainer, mControllers.navButtonController,
                    R.id.quick_settings_button);
            addButton(R.drawable.ic_sysbar_notifications, BUTTON_NOTIFICATIONS,
                    mNavButtonContainer, mControllers.navButtonController,
                    R.id.notifications_button);
        }

        // Initialize things needed to move nav buttons to separate window.
        mSeparateWindowParent = new BaseDragLayer<TaskbarActivityContext>(mContext, null, 0) {
            @Override
@@ -546,7 +532,7 @@ public class NavbarButtonsViewController {
        }
    }

    private ImageView addButton(@DrawableRes int drawableId, @TaskbarButton int buttonType,
    protected ImageView addButton(@DrawableRes int drawableId, @TaskbarButton int buttonType,
            ViewGroup parent, TaskbarNavButtonController navButtonController, @IdRes int id) {
        return addButton(drawableId, buttonType, parent, navButtonController, id,
                R.layout.taskbar_nav_button);
+4 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.launcher3.taskbar;

import static android.content.pm.PackageManager.FEATURE_PC;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
@@ -166,6 +167,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        mControllers = new TaskbarControllers(this,
                new TaskbarDragController(this),
                buttonController,
                getPackageManager().hasSystemFeature(FEATURE_PC)
                        ? new DesktopNavbarButtonsViewController(this, navButtonsView) :
                        new NavbarButtonsViewController(this, navButtonsView),
                new RotationButtonController(this,
                        c.getColor(R.color.taskbar_nav_icon_light_color),
+4 −0
Original line number Diff line number Diff line
@@ -143,6 +143,10 @@ public class TaskbarNavButtonController {
                return R.string.taskbar_button_ime_switcher;
            case BUTTON_RECENTS:
                return R.string.taskbar_button_recents;
            case BUTTON_NOTIFICATIONS:
                return R.string.taskbar_button_notifications;
            case BUTTON_QUICK_SETTINGS:
                return R.string.taskbar_button_quick_settings;
            default:
                return 0;
        }