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

Commit 786974f1 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Prototype dual panel swipe

This CL only reroutes swipes on the right side of the screen (left side
for RTL) to perform a two-finger swipe, opening QS instead of
notification shade.

Enable: "adb shell device_config put systemui qs_split_enabled false"

Test: manual

Change-Id: I96feed6440121b0c07606b398c9e2bb82570ef11
parent 8bcae646
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -47,6 +47,13 @@ public final class SystemUiDeviceConfigFlags {
     */
    public static final String NAS_MAX_SUGGESTIONS = "nas_max_suggestions";

    // Flags related to controls

    /**
     * (boolean) Wether to have split behavior when opening QS
     */
    public static final String QS_SPLIT_ENABLED = "qs_split_enabled";

    // Flags related to Smart Suggestions - these are read in SmartReplyConstants.

    /** (boolean) Whether to enable smart suggestions in notifications. */
+26 −0
Original line number Diff line number Diff line
@@ -42,6 +42,32 @@
        android:visibility="gone"
        />

    <LinearLayout
        android:id="@+id/divider_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:background="@color/transparent" >

        <android.widget.Space
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:layout_weight="@integer/qqs_split_fraction" />

        <com.android.systemui.DarkReceiverImpl
            android:id="@+id/divider"
            android:layout_height="match_parent"
            android:layout_width="1dp"
            android:layout_marginTop="4dp"
            android:layout_marginBottom="4dp" />

        <android.widget.Space
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:layout_weight="@integer/qs_split_fraction" />

    </LinearLayout>

    <LinearLayout android:id="@+id/status_bar_contents"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
+5 −0
Original line number Diff line number Diff line
@@ -27,4 +27,9 @@
         performance issues arise. -->
    <integer name="bubbles_max_rendered">5</integer>

    <!-- Ratio of "left" end of status bar that will swipe to QQS. -->
    <integer name="qqs_split_fraction">3</integer>
    <!-- Ratio of "right" end of status bar that will swipe to QS. -->
    <integer name="qs_split_fraction">2</integer>

</resources>
 No newline at end of file
+42 −0
Original line number Diff line number Diff line
/*
 * 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.systemui

import android.content.Context
import android.graphics.Rect
import android.util.AttributeSet
import android.view.View
import com.android.systemui.plugins.DarkIconDispatcher

class DarkReceiverImpl @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyle: Int = 0,
    defStyleRes: Int = 0
) : View(context, attrs, defStyle, defStyleRes), DarkIconDispatcher.DarkReceiver {

    private val dualToneHandler = DualToneHandler(context)

    init {
        onDarkChanged(Rect(), 1f, DarkIconDispatcher.DEFAULT_ICON_TINT)
    }

    override fun onDarkChanged(area: Rect?, darkIntensity: Float, tint: Int) {
        val intensity = if (DarkIconDispatcher.isInArea(area, this)) darkIntensity else 0f
        setBackgroundColor(dualToneHandler.getSingleColor(intensity))
    }
}
 No newline at end of file
+26 −1
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.graphics.Rect;
import android.graphics.Region;
import android.os.PowerManager;
import android.os.SystemClock;
import android.provider.DeviceConfig;
import android.util.AttributeSet;
import android.util.Log;
import android.util.MathUtils;
@@ -54,6 +55,7 @@ import android.view.accessibility.AccessibilityManager;
import android.widget.FrameLayout;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.keyguard.KeyguardClockSwitch;
@@ -135,6 +137,8 @@ public class NotificationPanelView extends PanelView implements
     */
    public static final int FLING_HIDE = 2;

    private double mQqsSplitFraction;

    // Cap and total height of Roboto font. Needs to be adjusted when font for the big clock is
    // changed.
    private static final int CAP_HEIGHT = 1456;
@@ -527,6 +531,9 @@ public class NotificationPanelView extends PanelView implements
                com.android.internal.R.dimen.status_bar_height);
        mHeadsUpInset = statusbarHeight + getResources().getDimensionPixelSize(
                R.dimen.heads_up_status_bar_padding);
        mQqsSplitFraction = ((float) getResources().getInteger(R.integer.qqs_split_fraction)) / (
                getResources().getInteger(R.integer.qqs_split_fraction)
                        + getResources().getInteger(R.integer.qs_split_fraction));
    }

    /**
@@ -1269,6 +1276,17 @@ public class NotificationPanelView extends PanelView implements
                || y <= mQs.getView().getY() + mQs.getView().getHeight());
    }

    private boolean isOnQsEndArea(float x) {
        if (!isQsSplitEnabled()) return false;
        if (getLayoutDirection() == LAYOUT_DIRECTION_LTR) {
            return x >= mQsFrame.getX() + mQqsSplitFraction * mQsFrame.getWidth()
                    && x <= mQsFrame.getX() + mQsFrame.getWidth();
        } else {
            return x >= mQsFrame.getX()
                    && x <= mQsFrame.getX() + (1 - mQqsSplitFraction) * mQsFrame.getWidth();
        }
    }

    private boolean isOpenQsEvent(MotionEvent event) {
        final int pointerCount = event.getPointerCount();
        final int action = event.getActionMasked();
@@ -1284,7 +1302,9 @@ public class NotificationPanelView extends PanelView implements
                && (event.isButtonPressed(MotionEvent.BUTTON_SECONDARY)
                || event.isButtonPressed(MotionEvent.BUTTON_TERTIARY));

        return twoFingerDrag || stylusButtonClickDrag || mouseButtonClickDrag;
        final boolean onHeaderRight = isOnQsEndArea(event.getX());

        return twoFingerDrag || stylusButtonClickDrag || mouseButtonClickDrag || onHeaderRight;
    }

    private void handleQsDown(MotionEvent event) {
@@ -1538,6 +1558,7 @@ public class NotificationPanelView extends PanelView implements
        } else {
            mKeyguardStatusBar.setAlpha(1f);
            mKeyguardStatusBar.setVisibility(keyguardShowing ? View.VISIBLE : View.INVISIBLE);
            ((PhoneStatusBarView) mBar).maybeShowDivider(keyguardShowing);
            if (keyguardShowing && oldState != mBarState) {
                if (mQs != null) {
                    mQs.hideImmediately();
@@ -3422,4 +3443,8 @@ public class NotificationPanelView extends PanelView implements
        mOnReinflationListener = onReinflationListener;
    }

    public static boolean isQsSplitEnabled() {
        return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
                SystemUiDeviceConfigFlags.QS_SPLIT_ENABLED, false);
    }
}
Loading