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

Commit 0ceef211 authored by Jason Monk's avatar Jason Monk
Browse files

Move QS to a fragment

There is now a bit too much of the view/layout logic touching the
fragment, but sort out that later and get something over to fragments
for now.

Bug: 32609190
Test: Manual
Change-Id: Icf677f4a70e6b92892a0fc27a0e673940ebc7a73
parent bbac121e
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.plugins;

import android.content.Context;
import android.view.View;

/**
 * Interface to deal with lack of multiple inheritance
 *
 * This interface is designed to be used as a base class for plugin interfaces
 * that need fragment methods. Plugins should not extend Fragment directly, so
 * plugins that are fragments should be extending PluginFragment, but in SysUI
 * these same versions should extend Fragment directly.
 *
 * Only methods that are on Fragment should be included here.
 */
public interface FragmentBase {
    View getView();
    Context getContext();
}
+9 −5
Original line number Diff line number Diff line
@@ -25,17 +25,21 @@ import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;

public abstract class QSContainer extends FrameLayout {
import com.android.systemui.plugins.FragmentBase;

/**
 * Fragment that contains QS in the notification shade.  Most of the interface is for
 * handling the expand/collapsing of the view interaction.
 */
public interface QS extends FragmentBase {

    public static final String ACTION = "com.android.systemui.action.PLUGIN_QS";

    // This should be incremented any time this class or ActivityStarter or BaseStatusBarHeader
    // change in incompatible ways.
    public static final int VERSION = 3;
    public static final int VERSION = 4;

    public QSContainer(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }
    String TAG = "QS";

    public abstract void setPanelView(HeightListener notificationPanelView);
    public abstract BaseStatusBarHeader getHeader();
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
     limitations under the License.
-->

<!-- Height is 0 because it will be managed by the QSContainer manually -->
<!-- Height is 0 because it will be managed by the QS manually -->
<com.android.systemui.qs.customize.QSCustomizer
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
+3 −3
Original line number Diff line number Diff line
@@ -39,15 +39,15 @@
        android:clipToPadding="false"
        android:clipChildren="false">

        <com.android.systemui.PluginInflateContainer
            android:id="@+id/qs_auto_reinflate_container"
        <FrameLayout
            android:id="@+id/qs_frame"
            android:layout="@layout/qs_panel"
            android:layout_width="@dimen/notification_panel_width"
            android:layout_height="match_parent"
            android:layout_gravity="@integer/notification_panel_layout_gravity"
            android:clipToPadding="false"
            android:clipChildren="false"
            systemui:viewType="com.android.systemui.plugins.qs.QSContainer" />
            systemui:viewType="com.android.systemui.plugins.qs.QS" />

        <com.android.systemui.statusbar.stack.NotificationStackScrollLayout
            android:id="@+id/notification_stack_scroller"
+15 −11
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import android.view.View.OnAttachStateChangeListener;
import android.view.View.OnLayoutChangeListener;
import android.widget.TextView;

import com.android.systemui.plugins.qs.QSContainer;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.qs.PagedTileLayout.PageListener;
import com.android.systemui.qs.QSPanel.QSTileLayout;
import com.android.systemui.qs.QSTile.Host.Callback;
@@ -47,7 +47,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
    private final ArrayList<View> mTopFiveQs = new ArrayList<>();
    private final QuickQSPanel mQuickQsPanel;
    private final QSPanel mQsPanel;
    private final QSContainer mQsContainer;
    private final QS mQs;

    private PagedTileLayout mPagedLayout;

@@ -67,12 +67,15 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
    private float mLastPosition;
    private QSTileHost mHost;

    public QSAnimator(QSContainer container, QuickQSPanel quickPanel, QSPanel panel) {
        mQsContainer = container;
    public QSAnimator(QS qs, QuickQSPanel quickPanel, QSPanel panel) {
        mQs = qs;
        mQuickQsPanel = quickPanel;
        mQsPanel = panel;
        mQsPanel.addOnAttachStateChangeListener(this);
        container.addOnLayoutChangeListener(this);
        qs.getView().addOnLayoutChangeListener(this);
        if (mQsPanel.isAttachedToWindow()) {
            onViewAttachedToWindow(null);
        }
        QSTileLayout tileLayout = mQsPanel.getTileLayout();
        if (tileLayout instanceof PagedTileLayout) {
            mPagedLayout = ((PagedTileLayout) tileLayout);
@@ -102,7 +105,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha

    @Override
    public void onViewAttachedToWindow(View v) {
        TunerService.get(mQsContainer.getContext()).addTunable(this, ALLOW_FANCY_ANIMATION,
        TunerService.get(mQs.getContext()).addTunable(this, ALLOW_FANCY_ANIMATION,
                MOVE_FULL_ROWS, QuickQSPanel.NUM_QUICK_TILES);
    }

@@ -111,7 +114,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
        if (mHost != null) {
            mHost.removeCallback(this);
        }
        TunerService.get(mQsContainer.getContext()).removeTunable(this);
        TunerService.get(mQs.getContext()).removeTunable(this);
    }

    @Override
@@ -124,7 +127,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
        } else if (MOVE_FULL_ROWS.equals(key)) {
            mFullRows = newValue == null || Integer.parseInt(newValue) != 0;
        } else if (QuickQSPanel.NUM_QUICK_TILES.equals(key)) {
            mNumQuickTiles = mQuickQsPanel.getNumQuickTiles(mQsContainer.getContext());
            mNumQuickTiles = mQuickQsPanel.getNumQuickTiles(mQs.getContext());
            clearAnimationState();
        }
        updateAnimators();
@@ -166,13 +169,14 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
            }
            final TextView label = ((QSTileView) tileView).getLabel();
            final View tileIcon = tileView.getIcon().getIconView();
            View view = mQs.getView();
            if (count < mNumQuickTiles && mAllowFancy) {
                // Quick tiles.
                QSTileBaseView quickTileView = mQuickQsPanel.getTileView(tile);

                lastX = loc1[0];
                getRelativePosition(loc1, quickTileView.getIcon().getIconView(), mQsContainer);
                getRelativePosition(loc2, tileIcon, mQsContainer);
                getRelativePosition(loc1, quickTileView.getIcon().getIconView(), view);
                getRelativePosition(loc2, tileIcon, view);
                final int xDiff = loc2[0] - loc1[0];
                final int yDiff = loc2[1] - loc1[1];
                lastXDiff = loc1[0] - lastX;
@@ -198,7 +202,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
                // This makes the extra icons seems as if they are coming from positions in the
                // quick panel.
                loc1[0] += lastXDiff;
                getRelativePosition(loc2, tileIcon, mQsContainer);
                getRelativePosition(loc2, tileIcon, view);
                final int xDiff = loc2[0] - loc1[0];
                final int yDiff = loc2[1] - loc1[1];

Loading