Flags for qs labels

Test: atest SystemUITests
Test: manual
Fixes: 178390389

Change-Id: If7c6371ccd58b49cec0e9fdedc2bbbb120e4788e
This commit is contained in:
Fabian Kozynski
2021-01-25 16:51:36 -05:00
parent 4936643625
commit d908739dc0
17 changed files with 112 additions and 35 deletions

View File

@@ -14,10 +14,4 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.android.systemui.qs.SideLabelTileLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tile_page"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false" />
<include layout="@layout/qs_paged_page" />

View File

@@ -15,13 +15,4 @@
~ limitations under the License.
-->
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/textColorSecondary"
/>
<View />

View File

@@ -24,4 +24,6 @@
<!-- b/171917882 -->
<bool name="flag_notification_twocolumn">false</bool>
<bool name="flag_qs_labels">false</bool>
</resources>

View File

@@ -2808,4 +2808,7 @@
<!-- Text to display in a notification when ACTION_BATTERY_CHANGED.EXTRA_PRESENT field is false
[CHAR LIMIT=NONE] -->
<string name="battery_state_unknown_notification_text">Tap for more information</string>
<!-- No translation [CHAR LIMIT=0] -->
<string name="qs_remove_labels" translatable="false"></string>
</resources>

View File

@@ -26,7 +26,6 @@ import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
import android.util.AttributeSet;
import android.util.Pair;
import android.view.Gravity;
@@ -113,7 +112,7 @@ public class QSPanel extends LinearLayout implements Tunable {
private int mMediaTotalBottomMargin;
private int mFooterMarginStartHorizontal;
private Consumer<Boolean> mMediaVisibilityChangedListener;
private final boolean mSideLabels;
private boolean mSideLabels;
public QSPanel(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -121,12 +120,15 @@ public class QSPanel extends LinearLayout implements Tunable {
mMediaTotalBottomMargin = getResources().getDimensionPixelSize(
R.dimen.quick_settings_bottom_margin_media);
mContext = context;
mSideLabels = Settings.Secure.getInt(
mContext.getContentResolver(), "sysui_side_labels", 0) != 0;
setOrientation(VERTICAL);
mMovableContentStartIndex = getChildCount();
}
void initialize(boolean sideLabels) {
mSideLabels = sideLabels;
mRegularTileLayout = createRegularTileLayout();
mTileLayout = mRegularTileLayout;

View File

@@ -18,6 +18,8 @@ package com.android.systemui.qs;
import static com.android.systemui.media.dagger.MediaModule.QS_PANEL;
import static com.android.systemui.qs.QSPanel.QS_SHOW_BRIGHTNESS;
import static com.android.systemui.qs.dagger.QSFlagsModule.QS_LABELS_FLAG;
import static com.android.systemui.qs.dagger.QSFlagsModule.QS_SIDE_LABELS;
import static com.android.systemui.qs.dagger.QSFragmentModule.QS_USING_MEDIA_PLAYER;
import android.annotation.NonNull;
@@ -64,6 +66,7 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
private BrightnessMirrorController mBrightnessMirrorController;
private boolean mGridContentVisible = true;
private boolean mQsLabelsFlag;
private final QSPanel.OnConfigurationChangedListener mOnConfigurationChangedListener =
new QSPanel.OnConfigurationChangedListener() {
@@ -89,7 +92,9 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
QSTileRevealController.Factory qsTileRevealControllerFactory,
DumpManager dumpManager, MetricsLogger metricsLogger, UiEventLogger uiEventLogger,
QSLogger qsLogger, BrightnessController.Factory brightnessControllerFactory,
BrightnessSlider.Factory brightnessSliderFactory) {
BrightnessSlider.Factory brightnessSliderFactory,
@Named(QS_LABELS_FLAG) boolean qsLabelsFlag,
@Named(QS_SIDE_LABELS) boolean useSideLabels) {
super(view, qstileHost, qsCustomizerController, usingMediaPlayer, mediaHost,
metricsLogger, uiEventLogger, qsLogger, dumpManager);
mQsSecurityFooter = qsSecurityFooter;
@@ -103,6 +108,9 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
mView.setBrightnessView(mBrightnessSlider.getRootView());
mBrightnessController = brightnessControllerFactory.create(mBrightnessSlider);
mQsLabelsFlag = qsLabelsFlag;
mSideLabels = useSideLabels;
}
@Override
@@ -321,6 +329,7 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
@Override
public void onTuningChanged(String key, String newValue) {
if (QS_REMOVE_LABELS.equals(key)) {
if (!mQsLabelsFlag) return;
boolean newShowLabels = newValue == null || "0".equals(newValue);
if (mShowLabels == newShowLabels) return;
mShowLabels = newShowLabels;

View File

@@ -72,6 +72,7 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
private final QSHost.Callback mQSHostCallback = this::setTiles;
protected boolean mShowLabels = true;
protected boolean mSideLabels;
private final QSPanel.OnConfigurationChangedListener mOnConfigurationChangedListener =
new QSPanel.OnConfigurationChangedListener() {
@@ -110,6 +111,7 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
@Override
protected void onInit() {
mView.initialize(mSideLabels);
mQSLogger.logAllTilesChangeListening(mView.isListening(), mView.getDumpableTag(), "");
}

View File

@@ -47,6 +47,11 @@ public class QuickQSPanel extends QSPanel {
super(context, attrs);
mMaxTiles = Math.min(DEFAULT_MAX_TILES,
getResources().getInteger(R.integer.quick_qs_panel_max_columns));
}
@Override
void initialize(boolean sideLabels) {
super.initialize(sideLabels);
applyBottomMargin((View) mRegularTileLayout);
}

View File

@@ -36,7 +36,7 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
private int mCellMarginTop;
protected boolean mListening;
protected int mMaxAllowedRows = 3;
private boolean mShowLabels;
private boolean mShowLabels = true;
// Prototyping with less rows
private final boolean mLessRows;
@@ -51,8 +51,6 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
public TileLayout(Context context, AttributeSet attrs) {
super(context, attrs);
setFocusableInTouchMode(true);
mShowLabels = Settings.Secure.getInt(context.getContentResolver(),
QSPanelController.QS_REMOVE_LABELS, 0) == 0;
mLessRows = ((Settings.System.getInt(context.getContentResolver(), "qs_less_rows", 0) != 0)
|| useQsMediaPlayer(context));
updateResources();

View File

@@ -20,12 +20,12 @@ import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toolbar;
@@ -79,9 +79,8 @@ public class QSCustomizer extends LinearLayout {
mContext.getString(com.android.internal.R.string.reset));
// Prototype menu item
toolbar.getMenu()
.add(Menu.NONE, MENU_REMOVE_LABELS, Menu.NONE, "Remove labels")
.setCheckable(true)
.setVisible(Build.IS_ENG || Build.IS_USERDEBUG);
.add(Menu.NONE, MENU_REMOVE_LABELS, Menu.NONE, R.string.qs_remove_labels)
.setCheckable(true);
toolbar.setTitle(R.string.qs_edit);
mRecyclerView = findViewById(android.R.id.list);
mTransparentView = findViewById(R.id.customizer_transparent_view);
@@ -90,6 +89,11 @@ public class QSCustomizer extends LinearLayout {
mRecyclerView.setItemAnimator(animator);
}
MenuItem getRemoveItem() {
return ((Toolbar) findViewById(com.android.internal.R.id.action_bar))
.getMenu().findItem(MENU_REMOVE_LABELS);
}
void updateResources() {
LayoutParams lp = (LayoutParams) mTransparentView.getLayoutParams();
lp.height = mContext.getResources().getDimensionPixelSize(

View File

@@ -19,6 +19,7 @@ package com.android.systemui.qs.customize;
import static com.android.systemui.qs.customize.QSCustomizer.EXTRA_QS_CUSTOMIZING;
import static com.android.systemui.qs.customize.QSCustomizer.MENU_REMOVE_LABELS;
import static com.android.systemui.qs.customize.QSCustomizer.MENU_RESET;
import static com.android.systemui.qs.dagger.QSFlagsModule.QS_LABELS_FLAG;
import android.content.res.Configuration;
import android.os.Bundle;
@@ -52,6 +53,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
/** {@link ViewController} for {@link QSCustomizer}. */
@QSScope
@@ -66,6 +68,7 @@ public class QSCustomizerController extends ViewController<QSCustomizer> {
private final UiEventLogger mUiEventLogger;
private final Toolbar mToolbar;
private final TunerService mTunerService;
private final boolean mQsLabelsFlag;
private final OnMenuItemClickListener mOnMenuItemClickListener = new OnMenuItemClickListener() {
@Override
@@ -115,7 +118,7 @@ public class QSCustomizerController extends ViewController<QSCustomizer> {
QSTileHost qsTileHost, TileAdapter tileAdapter, ScreenLifecycle screenLifecycle,
KeyguardStateController keyguardStateController, LightBarController lightBarController,
ConfigurationController configurationController, UiEventLogger uiEventLogger,
TunerService tunerService) {
TunerService tunerService, @Named(QS_LABELS_FLAG) boolean qsLabelsFlag) {
super(view);
mTileQueryHelper = tileQueryHelper;
mQsTileHost = qsTileHost;
@@ -127,10 +130,17 @@ public class QSCustomizerController extends ViewController<QSCustomizer> {
mUiEventLogger = uiEventLogger;
mToolbar = mView.findViewById(com.android.internal.R.id.action_bar);
mQsLabelsFlag = qsLabelsFlag;
mTunerService = tunerService;
}
@Override
protected void onInit() {
super.onInit();
mView.getRemoveItem().setVisible(mQsLabelsFlag);
}
@Override
protected void onViewAttached() {
mView.updateNavBackDrop(getResources().getConfiguration(), mLightBarController);

View File

@@ -0,0 +1,47 @@
/*
* 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.
*/
package com.android.systemui.qs.dagger;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.util.settings.SecureSettings;
import javax.inject.Named;
import dagger.Module;
import dagger.Provides;
@Module
public interface QSFlagsModule {
String QS_LABELS_FLAG = "qs_labels_flag";
String QS_SIDE_LABELS = "qs_side_labels";
@Provides
@SysUISingleton
@Named(QS_LABELS_FLAG)
static boolean provideQSFlag(FeatureFlags featureFlags) {
return featureFlags.isQSLabelsEnabled();
}
@Provides
@SysUISingleton
@Named(QS_SIDE_LABELS)
static boolean provideSideLabels(SecureSettings secureSettings,
@Named(QS_LABELS_FLAG) boolean qsLabels) {
return qsLabels && secureSettings.getInt("sysui_side_labels", 0) != 0;
}
}

View File

@@ -40,7 +40,7 @@ import dagger.Provides;
* Module for QS dependencies
*/
@Module(subcomponents = {QSFragmentComponent.class},
includes = {MediaModule.class})
includes = {MediaModule.class, QSFlagsModule.class})
public interface QSModule {
@Provides
@@ -74,4 +74,5 @@ public interface QSModule {
/** */
@Binds
QSHost provideQsHost(QSTileHost controllerImpl);
}

View File

@@ -14,6 +14,8 @@
package com.android.systemui.qs.tileimpl;
import static com.android.systemui.qs.dagger.QSFlagsModule.QS_SIDE_LABELS;
import android.content.Context;
import android.os.Build;
import android.util.Log;
@@ -51,9 +53,9 @@ import com.android.systemui.qs.tiles.UserTile;
import com.android.systemui.qs.tiles.WifiTile;
import com.android.systemui.qs.tiles.WorkModeTile;
import com.android.systemui.util.leak.GarbageMonitor;
import com.android.systemui.util.settings.SecureSettings;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import dagger.Lazy;
@@ -96,7 +98,7 @@ public class QSFactoryImpl implements QSFactory {
@Inject
public QSFactoryImpl(
Lazy<QSHost> qsHostLazy,
SecureSettings settings,
@Named(QS_SIDE_LABELS) boolean useSideLabels,
Provider<CustomTile.Builder> customTileBuilderProvider,
Provider<WifiTile> wifiTileProvider,
Provider<InternetTile> internetTileProvider,
@@ -125,7 +127,7 @@ public class QSFactoryImpl implements QSFactory {
mQsHostLazy = qsHostLazy;
mCustomTileBuilderProvider = customTileBuilderProvider;
mSideLabels = settings.getInt("sysui_side_labels", 0) != 0;
mSideLabels = useSideLabels;
mWifiTileProvider = wifiTileProvider;
mInternetTileProvider = internetTileProvider;

View File

@@ -52,4 +52,9 @@ public class FeatureFlags {
public boolean isTwoColumnNotificationShadeEnabled() {
return mFlagReader.isEnabled(R.bool.flag_notification_twocolumn);
}
// Does not support runtime changes
public boolean isQSLabelsEnabled() {
return mFlagReader.isEnabled(R.bool.flag_qs_labels);
}
}

View File

@@ -117,7 +117,8 @@ public class QSPanelControllerTest extends SysuiTestCase {
mController = new QSPanelController(mQSPanel, mQSSecurityFooter, mTunerService,
mQSTileHost, mQSCustomizerController, true, mMediaHost,
mQSTileRevealControllerFactory, mDumpManager, mMetricsLogger, mUiEventLogger,
mQSLogger, mBrightnessControllerFactory, mToggleSliderViewControllerFactory);
mQSLogger, mBrightnessControllerFactory, mToggleSliderViewControllerFactory,
/* labelsFlag */ false, /* sideLabels */ false);
mController.init();
}

View File

@@ -81,6 +81,7 @@ public class QSPanelTest extends SysuiTestCase {
mTestableLooper.runWithLooper(() -> {
mQsPanel = new QSPanel(mContext, null);
mQsPanel.initialize(false);
mQsPanel.onFinishInflate();
// Provides a parent with non-zero size for QSPanel
mParentView = new FrameLayout(mContext);