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

Commit 673faf59 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Add IME switcher/hide button bar when IME showing

Bug: 180046394
Change-Id: Ic2bd919ab3d27e0a430b081c771ea8dc5827be81
parent 16fd8562
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2021 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
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="20dp"
    android:height="20dp"
    android:viewportWidth="24"
    android:viewportHeight="24">
    <path
        android:pathData="M19,7h2v2h-2V7zM15,7h2v2h-2V7zM3,7h2v2H3V7zM7,7h2v2H7V7zM11,7h2v2h-2V7zM19,11h2v2h-2V11zM15,11h2v2h-2V11zM3,11h2v2H3V11zM7,11h2v2H7V11zM11,11h2v2h-2V11zM7,15h10v2H7V15z"
        android:fillColor="@android:color/white" />
</vector>
+6 −0
Original line number Diff line number Diff line
@@ -26,4 +26,10 @@
        android:layout_height="wrap_content"
        android:gravity="center"/>

    <com.android.launcher3.taskbar.ImeBarView
        android:id="@+id/ime_bar_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone"/>

</com.android.launcher3.taskbar.TaskbarContainerView>
 No newline at end of file
+34 −0
Original line number Diff line number Diff line
@@ -30,8 +30,11 @@ import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.IBinder;
import android.view.View;

import androidx.annotation.Nullable;
@@ -61,6 +64,7 @@ import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.TaskUtils;
import com.android.quickstep.TouchInteractionService;
import com.android.quickstep.util.RemoteAnimationProvider;
import com.android.quickstep.util.RemoteFadeOutAnimationListener;
import com.android.quickstep.util.SplitSelectStateController;
@@ -82,6 +86,8 @@ public abstract class BaseQuickstepLauncher extends Launcher

    private DepthController mDepthController = new DepthController(this);
    private QuickstepTransitionManager mAppTransitionManager;
    private ServiceConnection mTisBinderConnection;
    protected TouchInteractionService.TISBinder mTisBinder;

    /**
     * Reusable command for applying the back button alpha on the background thread.
@@ -103,6 +109,24 @@ public abstract class BaseQuickstepLauncher extends Launcher
        super.onCreate(savedInstanceState);
        SysUINavigationMode.INSTANCE.get(this).addModeChangeListener(this);
        addMultiWindowModeChangedListener(mDepthController);
        setupTouchInteractionServiceBinder();
    }

    private void setupTouchInteractionServiceBinder() {
        Intent intent = new Intent(this, TouchInteractionService.class);
        mTisBinderConnection = new ServiceConnection() {
            @Override
            public void onServiceConnected(ComponentName componentName, IBinder binder) {
                mTisBinder = ((TouchInteractionService.TISBinder) binder);
                mTisBinder.setTaskbarOverviewProxyDelegate(mTaskbarController);
            }

            @Override
            public void onServiceDisconnected(ComponentName componentName) {
                mTisBinder = null;
            }
        };
        bindService(intent, mTisBinderConnection, 0);
    }

    @Override
@@ -113,6 +137,10 @@ public abstract class BaseQuickstepLauncher extends Launcher
        if (mTaskbarController != null) {
            mTaskbarController.cleanup();
            mTaskbarController = null;
            if (mTisBinder != null) {
                mTisBinder.setTaskbarOverviewProxyDelegate(null);
                unbindService(mTisBinderConnection);
            }
        }

        super.onDestroy();
@@ -248,6 +276,9 @@ public abstract class BaseQuickstepLauncher extends Launcher
    private void addTaskbarIfNecessary() {
        if (mTaskbarController != null) {
            mTaskbarController.cleanup();
            if (mTisBinder != null) {
                mTisBinder.setTaskbarOverviewProxyDelegate(null);
            }
            mTaskbarController = null;
        }
        if (mDeviceProfile.isTaskbarPresent) {
@@ -256,6 +287,9 @@ public abstract class BaseQuickstepLauncher extends Launcher
            mTaskbarController = new TaskbarController(this,
                    taskbarActivityContext.getTaskbarContainerView(), taskbarViewOnHome);
            mTaskbarController.init();
            if (mTisBinder != null) {
                mTisBinder.setTaskbarOverviewProxyDelegate(mTaskbarController);
            }
        }
    }

+76 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 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 android.annotation.DrawableRes;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.android.launcher3.R;

/**
 * Creates Buttons for Taskbar for 3 button nav.
 * Can add animations and state management for buttons in this class as things progress.
 */
public class ButtonProvider {

    private int mMarginLeftRight;
    private final Context mContext;

    public ButtonProvider(Context context) {
        mContext = context;
    }

    public void setMarginLeftRight(int margin) {
        mMarginLeftRight = margin;
    }

    public View getBack() {
        // Back button
        return getButtonForDrawable(R.drawable.ic_sysbar_back);
    }

    public View getDown() {
        // Ime down button
        return getButtonForDrawable(R.drawable.ic_sysbar_back);
    }

    public View getHome() {
        // Home button
        return getButtonForDrawable(R.drawable.ic_sysbar_home);
    }

    public View getRecents() {
        // Recents button
        return getButtonForDrawable(R.drawable.ic_sysbar_recent);
    }

    public View getImeSwitcher() {
        // IME Switcher Button
        return getButtonForDrawable(R.drawable.ic_ime_switcher);
    }

    private View getButtonForDrawable(@DrawableRes int drawableId) {
        ImageView buttonView = new ImageView(mContext);
        buttonView.setImageResource(drawableId);
        buttonView.setBackgroundResource(R.drawable.taskbar_icon_click_feedback_roundrect);
        buttonView.setPadding(mMarginLeftRight, 0, mMarginLeftRight, 0);
        return buttonView;
    }

}
+92 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 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_BACK;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_IME_SWITCH;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;

import com.android.launcher3.views.ActivityContext;

public class ImeBarView extends RelativeLayout {

    private ButtonProvider mButtonProvider;
    private TaskbarController.TaskbarViewCallbacks mControllerCallbacks;
    private View mImeView;

    public ImeBarView(Context context) {
        this(context, null);
    }

    public ImeBarView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ImeBarView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public void construct(ButtonProvider buttonProvider) {
        mButtonProvider = buttonProvider;
    }

    public void init(TaskbarController.TaskbarViewCallbacks taskbarCallbacks) {
        mControllerCallbacks = taskbarCallbacks;
        ActivityContext context = getActivityContext();
        RelativeLayout.LayoutParams imeParams = new RelativeLayout.LayoutParams(
                context.getDeviceProfile().iconSizePx,
                context.getDeviceProfile().iconSizePx
        );
        RelativeLayout.LayoutParams downParams = new RelativeLayout.LayoutParams(imeParams);

        imeParams.addRule(ALIGN_PARENT_END);
        imeParams.setMarginEnd(context.getDeviceProfile().iconSizePx);
        downParams.setMarginStart(context.getDeviceProfile().iconSizePx);
        downParams.addRule(ALIGN_PARENT_START);

        // Down Arrow
        View downView = mButtonProvider.getDown();
        downView.setOnClickListener(view -> mControllerCallbacks.onNavigationButtonClick(
                BUTTON_BACK));
        downView.setLayoutParams(downParams);
        downView.setRotation(-90);
        addView(downView);

        // IME switcher button
        mImeView = mButtonProvider.getImeSwitcher();
        mImeView.setOnClickListener(view -> mControllerCallbacks.onNavigationButtonClick(
                BUTTON_IME_SWITCH));
        mImeView.setLayoutParams(imeParams);
        addView(mImeView);
    }

    public void cleanup() {
        removeAllViews();
    }

    public void setImeSwitcherVisibility(boolean show) {
        mImeView.setVisibility(show ? VISIBLE : GONE);
    }

    private <T extends Context & ActivityContext> T getActivityContext() {
        return ActivityContext.lookupContext(getContext());
    }
}
Loading