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

Commit c28bc186 authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Android (Google) Code Review
Browse files

Merge "Prototype to use details or settings panels"

parents 9cb206f2 99cf798e
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -50,10 +50,19 @@ public final class SystemUiDeviceConfigFlags {
    // Flags related to controls

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

    /**
     * (int) Open settings panels for WiFi and BT tiles
     * 0 - default behavior, link to settings
     * 1 - open panel on long press, click remains the same
     * 2 - open panel on click, long press remains the same
     * 3 - use details on long press
     */
    public static final String QS_USE_SETTINGS_PANELS = "qs_use_settings_panels";

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

    /** (boolean) Whether to enable smart suggestions in notifications. */
+0 −5
Original line number Diff line number Diff line
@@ -106,11 +106,6 @@ public class QuickQSPanel extends QSPanel {
        mFullPanel = fullPanel;
    }

    @Override
    protected boolean shouldShowDetail() {
        return !mExpanded;
    }

    @Override
    protected void drawTile(TileRecord r, State state) {
        if (state instanceof SignalState) {
+13 −0
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.qs.PagedTileLayout.TilePage;
import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.QuickStatusBarHeader;
import com.android.systemui.qs.tiles.QSSettingsControllerKt;
import com.android.systemui.qs.tiles.QSSettingsPanel;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -121,9 +123,16 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy
     */
    abstract public int getMetricsCategory();

    /**
     * Experimental option on whether to use settings panels. Only loaded on creation, so the tile
     * needs to be removed and added for this to take effect.
     */
    protected final QSSettingsPanel mQSSettingsPanelOption;

    protected QSTileImpl(QSHost host) {
        mHost = host;
        mContext = host.getContext();
        mQSSettingsPanelOption = QSSettingsControllerKt.getQSSettingsPanelOption();
    }

    @NonNull
@@ -288,6 +297,10 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy
    }

    protected void handleLongClick() {
        if (mQSSettingsPanelOption == QSSettingsPanel.USE_DETAIL) {
            showDetail(true);
            return;
        }
        Dependency.get(ActivityStarter.class).postStartActivityDismissingKeyguard(
                getLongClickIntent(), 0);
    }
+36 −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.qs.tiles

import android.provider.DeviceConfig
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags

enum class QSSettingsPanel {
    DEFAULT,
    OPEN_LONG_PRESS,
    OPEN_CLICK,
    USE_DETAIL
}

fun getQSSettingsPanelOption(): QSSettingsPanel =
        when (DeviceConfig.getInt(DeviceConfig.NAMESPACE_SYSTEMUI,
                SystemUiDeviceConfigFlags.QS_USE_SETTINGS_PANELS, 0)) {
            1 -> QSSettingsPanel.OPEN_LONG_PRESS
            2 -> QSSettingsPanel.OPEN_CLICK
            3 -> QSSettingsPanel.USE_DETAIL
            else -> QSSettingsPanel.DEFAULT
        }
 No newline at end of file
+7 −1
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import javax.inject.Inject;
/** Quick settings tile: Wifi **/
public class WifiTile extends QSTileImpl<SignalState> {
    private static final Intent WIFI_SETTINGS = new Intent(Settings.ACTION_WIFI_SETTINGS);
    private static final Intent WIFI_PANEL = new Intent(Settings.Panel.ACTION_WIFI);

    protected final NetworkController mController;
    private final AccessPointController mWifiController;
@@ -112,11 +113,16 @@ public class WifiTile extends QSTileImpl<SignalState> {

    @Override
    public Intent getLongClickIntent() {
        return WIFI_SETTINGS;
        if (mQSSettingsPanelOption == QSSettingsPanel.OPEN_LONG_PRESS) return WIFI_PANEL;
        else return WIFI_SETTINGS;
    }

    @Override
    protected void handleClick() {
        if (mQSSettingsPanelOption == QSSettingsPanel.OPEN_CLICK) {
            mActivityStarter.postStartActivityDismissingKeyguard(WIFI_PANEL, 0);
            return;
        }
        // Secondary clicks are header clicks, just toggle.
        mState.copyTo(mStateBeforeClick);
        boolean wifiEnabled = mState.value;