Use 4 columns in QS portrait
This changes the default number of columns in QS and QQS portrait to 4. This means 4 tiles in QQS and 4/8 tiles in QS. Test: manual Change-Id: Idf017e3b7e8bd4b790e2f6fdbb4c568c4487b974
This commit is contained in:
@@ -20,6 +20,9 @@
|
||||
<!-- These resources are around just to allow their values to be customized
|
||||
for different hardware and product builds. -->
|
||||
<resources>
|
||||
<!-- The maximum number of tiles in the QuickQSPanel -->
|
||||
<integer name="quick_qs_panel_max_columns">6</integer>
|
||||
|
||||
<!-- The maximum number of rows in the QuickSettings -->
|
||||
<integer name="quick_settings_max_rows">2</integer>
|
||||
|
||||
|
||||
@@ -93,10 +93,10 @@
|
||||
<bool name="config_navigation_bar_enable_auto_dim_no_visible_wallpaper">true</bool>
|
||||
|
||||
<!-- The maximum number of tiles in the QuickQSPanel -->
|
||||
<integer name="quick_qs_panel_max_columns">6</integer>
|
||||
<integer name="quick_qs_panel_max_columns">4</integer>
|
||||
|
||||
<!-- The number of columns in the QuickSettings -->
|
||||
<integer name="quick_settings_num_columns">3</integer>
|
||||
<integer name="quick_settings_num_columns">4</integer>
|
||||
|
||||
<!-- The number of rows in the QuickSettings -->
|
||||
<integer name="quick_settings_max_rows">3</integer>
|
||||
|
||||
@@ -200,8 +200,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
|
||||
int count = 0;
|
||||
int[] loc1 = new int[2];
|
||||
int[] loc2 = new int[2];
|
||||
int lastXDiff = 0;
|
||||
int lastX = 0;
|
||||
|
||||
clearAnimationState();
|
||||
mAllViews.clear();
|
||||
@@ -231,12 +229,11 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
|
||||
QSTileView quickTileView = mQuickQSPanelController.getTileView(tile);
|
||||
if (quickTileView == null) continue;
|
||||
|
||||
lastX = loc1[0];
|
||||
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;
|
||||
|
||||
|
||||
if (count < tileLayout.getNumVisibleTiles()) {
|
||||
// Move the quick tile right from its location to the new one.
|
||||
@@ -267,19 +264,8 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
|
||||
mAllViews.add(tileView.getIcon());
|
||||
mAllViews.add(quickTileView);
|
||||
} else if (mFullRows && isIconInAnimatedRow(count)) {
|
||||
// TODO: Refactor some of this, it shares a lot with the above block.
|
||||
// Move the last tile position over by the last difference between quick tiles.
|
||||
// This makes the extra icons seems as if they are coming from positions in the
|
||||
// quick panel.
|
||||
loc1[0] += lastXDiff;
|
||||
getRelativePosition(loc2, tileIcon, view);
|
||||
final int xDiff = loc2[0] - loc1[0];
|
||||
final int yDiff = loc2[1] - loc1[1];
|
||||
|
||||
firstPageBuilder.addFloat(tileView, "translationY", heightDiff, 0);
|
||||
translationXBuilder.addFloat(tileView, "translationX", -xDiff, 0);
|
||||
translationYBuilder.addFloat(tileView, "translationY", -yDiff, 0);
|
||||
translationYBuilder.addFloat(tileIcon, "translationY", -yDiff, 0);
|
||||
firstPageBuilder.addFloat(tileView, "translationY", -heightDiff, 0);
|
||||
|
||||
mAllViews.add(tileIcon);
|
||||
} else {
|
||||
|
||||
@@ -47,7 +47,7 @@ public class QuickQSPanel extends QSPanel {
|
||||
public static final String NUM_QUICK_TILES = "sysui_qqs_count";
|
||||
private static final String TAG = "QuickQSPanel";
|
||||
// A default value so that we never return 0.
|
||||
private static int sDefaultMaxTiles = 6;
|
||||
public static final int DEFAULT_MAX_TILES = 6;
|
||||
|
||||
private boolean mDisabledByPolicy;
|
||||
private int mMaxTiles;
|
||||
@@ -62,8 +62,8 @@ public class QuickQSPanel extends QSPanel {
|
||||
@Named(QUICK_QS_PANEL) MediaHost mediaHost,
|
||||
UiEventLogger uiEventLogger) {
|
||||
super(context, attrs, qsLogger, mediaHost, uiEventLogger);
|
||||
sDefaultMaxTiles = getResources().getInteger(R.integer.quick_qs_panel_max_columns);
|
||||
mMaxTiles = sDefaultMaxTiles;
|
||||
mMaxTiles = Math.min(DEFAULT_MAX_TILES,
|
||||
getResources().getInteger(R.integer.quick_qs_panel_max_columns));
|
||||
applyBottomMargin((View) mRegularTileLayout);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class QuickQSPanel extends QSPanel {
|
||||
}
|
||||
|
||||
public void setMaxTiles(int maxTiles) {
|
||||
mMaxTiles = maxTiles;
|
||||
mMaxTiles = Math.min(maxTiles, DEFAULT_MAX_TILES);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,7 +167,7 @@ public class QuickQSPanel extends QSPanel {
|
||||
return Integer.parseInt(numTilesValue);
|
||||
} catch (NumberFormatException e) {
|
||||
// Couldn't read an int from the new setting value. Use default.
|
||||
return sDefaultMaxTiles;
|
||||
return DEFAULT_MAX_TILES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,52 +16,53 @@
|
||||
|
||||
package com.android.systemui.qs;
|
||||
|
||||
import static com.android.systemui.qs.QuickQSPanel.NUM_QUICK_TILES;
|
||||
import static com.android.systemui.qs.QuickQSPanel.parseNumTiles;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dump.DumpManager;
|
||||
import com.android.systemui.plugins.qs.QSTile;
|
||||
import com.android.systemui.qs.customize.QSCustomizerController;
|
||||
import com.android.systemui.qs.dagger.QSScope;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
import com.android.systemui.tuner.TunerService.Tunable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/** Controller for {@link QuickQSPanel}. */
|
||||
@QSScope
|
||||
public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> {
|
||||
private final Tunable mNumTiles =
|
||||
(key, newValue) -> setMaxTiles(parseNumTiles(newValue));
|
||||
|
||||
private final TunerService mTunerService;
|
||||
private List<QSTile> mAllTiles = new ArrayList<>();
|
||||
|
||||
private final QSPanel.OnConfigurationChangedListener mOnConfigurationChangedListener =
|
||||
newConfig -> {
|
||||
int newMaxTiles = getResources().getInteger(R.integer.quick_qs_panel_max_columns);
|
||||
if (newMaxTiles != mView.getNumQuickTiles()) {
|
||||
setMaxTiles(newMaxTiles);
|
||||
}
|
||||
};
|
||||
|
||||
@Inject
|
||||
QuickQSPanelController(QuickQSPanel view, TunerService tunerService, QSTileHost qsTileHost,
|
||||
QuickQSPanelController(QuickQSPanel view, QSTileHost qsTileHost,
|
||||
QSCustomizerController qsCustomizerController,
|
||||
QSTileRevealController.Factory qsTileRevealControllerFactory,
|
||||
MetricsLogger metricsLogger, UiEventLogger uiEventLogger,
|
||||
DumpManager dumpManager) {
|
||||
super(view, qsTileHost, qsCustomizerController, qsTileRevealControllerFactory,
|
||||
metricsLogger, uiEventLogger, dumpManager);
|
||||
mTunerService = tunerService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewAttached() {
|
||||
super.onViewAttached();
|
||||
mTunerService.addTunable(mNumTiles, NUM_QUICK_TILES);
|
||||
|
||||
mView.addOnConfigurationChangedListener(mOnConfigurationChangedListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewDetached() {
|
||||
super.onViewDetached();
|
||||
mTunerService.removeTunable(mNumTiles);
|
||||
mView.removeOnConfigurationChangedListener(mOnConfigurationChangedListener);
|
||||
}
|
||||
|
||||
public boolean isListening() {
|
||||
@@ -75,14 +76,14 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel>
|
||||
|
||||
@Override
|
||||
public void setTiles() {
|
||||
ArrayList<QSTile> quickTiles = new ArrayList<>();
|
||||
mAllTiles.clear();
|
||||
for (QSTile tile : mHost.getTiles()) {
|
||||
quickTiles.add(tile);
|
||||
if (quickTiles.size() == mView.getNumQuickTiles()) {
|
||||
mAllTiles.add(tile);
|
||||
if (mAllTiles.size() == QuickQSPanel.DEFAULT_MAX_TILES) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.setTiles(quickTiles, true);
|
||||
super.setTiles(mAllTiles.subList(0, mView.getNumQuickTiles()), true);
|
||||
}
|
||||
|
||||
public int getNumQuickTiles() {
|
||||
|
||||
@@ -125,7 +125,7 @@ public class QSCustomizerController extends ViewController<QSCustomizer> {
|
||||
RecyclerView recyclerView = mView.getRecyclerView();
|
||||
recyclerView.setAdapter(mTileAdapter);
|
||||
mTileAdapter.getItemTouchHelper().attachToRecyclerView(recyclerView);
|
||||
GridLayoutManager layout = new GridLayoutManager(getContext(), 3) {
|
||||
GridLayoutManager layout = new GridLayoutManager(getContext(), TileAdapter.NUM_COLUMNS) {
|
||||
@Override
|
||||
public void onInitializeAccessibilityNodeInfoForItem(RecyclerView.Recycler recycler,
|
||||
RecyclerView.State state, View host, AccessibilityNodeInfoCompat info) {
|
||||
|
||||
@@ -61,6 +61,7 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
|
||||
private static final long DRAG_LENGTH = 100;
|
||||
private static final float DRAG_SCALE = 1.2f;
|
||||
public static final long MOVE_DURATION = 150;
|
||||
public static final int NUM_COLUMNS = 4;
|
||||
|
||||
private static final int TYPE_TILE = 0;
|
||||
private static final int TYPE_EDIT = 1;
|
||||
@@ -600,7 +601,11 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
final int type = getItemViewType(position);
|
||||
return type == TYPE_EDIT || type == TYPE_DIVIDER || type == TYPE_HEADER ? 3 : 1;
|
||||
if (type == TYPE_EDIT || type == TYPE_DIVIDER || type == TYPE_HEADER) {
|
||||
return NUM_COLUMNS;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user