Merge "[QS] Add PageIndicator to footer" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-04-17 01:28:06 +00:00
committed by Android (Google) Code Review
10 changed files with 135 additions and 31 deletions

View File

@@ -38,35 +38,49 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:layout_gravity="center_vertical"
android:gravity="end" >
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start"
android:layout_marginEnd="8dp"
android:visibility="gone"
layout="@layout/mobile_signal_group" />
<com.android.keyguard.CarrierText
android:id="@+id/qs_carrier_text"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_gravity="center_vertical|start"
android:layout_marginEnd="32dp"
android:ellipsize="marquee"
android:textAppearance="@style/TextAppearance.QS.TileLabel"
android:textColor="?android:attr/textColorPrimary"
android:textDirection="locale"
android:singleLine="true" />
android:gravity="center_vertical|start"
android:paddingStart="16dp">
<include
layout="@layout/mobile_signal_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:visibility="gone" />
<com.android.keyguard.CarrierText
android:id="@+id/qs_carrier_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="32dp"
android:ellipsize="marquee"
android:textAppearance="@style/TextAppearance.QS.TileLabel"
android:textColor="?android:attr/textColorPrimary"
android:textDirection="locale"
android:singleLine="true" />
</LinearLayout>
<com.android.systemui.qs.PageIndicator
android:id="@+id/footer_page_indicator"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:visibility="gone" />
<com.android.keyguard.AlphaOptimizedLinearLayout
android:id="@+id/qs_footer_actions_container"
android:layout_width="wrap_content"
android:layout_width="@integer/qs_footer_actions_width"
android:layout_height="match_parent"
android:layout_weight="@integer/qs_footer_actions_weight"
android:gravity="center_vertical|end" >
<com.android.systemui.statusbar.phone.MultiUserSwitch
android:id="@+id/multi_user_switch"

View File

@@ -19,9 +19,9 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="24dp"
android:clipChildren="false"
android:clipToPadding="false">
android:clipToPadding="false"
android:paddingBottom="@dimen/qs_paged_tile_layout_padding_bottom">
<FrameLayout
android:id="@+id/page_decor"

View File

@@ -35,4 +35,5 @@
<integer name="quick_settings_num_columns">4</integer>
<bool name="quick_settings_wide">true</bool>
<dimen name="qs_detail_margin_top">0dp</dimen>
<dimen name="qs_paged_tile_layout_padding_bottom">0dp</dimen>
</resources>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2018 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
-->
<resources>
<!-- Action footer width is set to 0 to allow it to stretch (through a weight of 1) and center
the page indicator in between the footer and the carrier text.-->
<integer name="qs_footer_actions_width">0</integer>
<integer name="qs_footer_actions_weight">1</integer>
</resources>

View File

@@ -382,6 +382,7 @@
<dimen name="qs_footer_padding_start">16dp</dimen>
<dimen name="qs_footer_padding_end">16dp</dimen>
<dimen name="qs_footer_icon_size">16dp</dimen>
<dimen name="qs_paged_tile_layout_padding_bottom">24dp</dimen>
<dimen name="qs_notif_collapsed_space">64dp</dimen>

View File

@@ -16,4 +16,9 @@
-->
<resources>
<integer name="fingerprint_dialog_text_gravity">8388611</integer> <!-- gravity start -->
<!-- Action footer width used for layout_width to indicate WRAP_CONTENT (along with a weight of
0) as we can allow the carrier text to stretch as far as needed in the QS footer. -->
<integer name="qs_footer_actions_width">-2</integer>
<integer name="qs_footer_actions_weight">0</integer>
</resources>

View File

@@ -45,7 +45,7 @@ public class PageIndicator extends ViewGroup {
}
public void setNumPages(int numPages) {
setVisibility(numPages > 1 ? View.VISIBLE : View.INVISIBLE);
setVisibility(numPages > 1 ? View.VISIBLE : View.GONE);
if (mAnimating) {
Log.w(TAG, "setNumPages during animation");
}

View File

@@ -46,6 +46,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
private final ArrayList<TilePage> mPages = new ArrayList<>();
private PageIndicator mPageIndicator;
private float mPageIndicatorPosition;
private int mNumPages;
private PageListener mPageListener;
@@ -145,6 +146,8 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
public void setPageIndicator(PageIndicator indicator) {
mPageIndicator = indicator;
mPageIndicator.setNumPages(mNumPages);
mPageIndicator.setLocation(mPageIndicatorPosition);
}
@Override
@@ -212,7 +215,6 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
}
if (DEBUG) Log.d(TAG, "Size: " + mNumPages);
mPageIndicator.setNumPages(mNumPages);
mPageIndicator.setVisibility(mNumPages > 1 ? View.VISIBLE : View.GONE);
setAdapter(mAdapter);
mAdapter.notifyDataSetChanged();
setCurrentItem(0, false);
@@ -221,6 +223,12 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
@Override
public boolean updateResources() {
// Update bottom padding, useful for removing extra space once the panel page indicator is
// hidden.
setPadding(0, 0, 0,
getContext().getResources().getDimensionPixelSize(
R.dimen.qs_paged_tile_layout_padding_bottom));
boolean changed = false;
for (int i = 0; i < mPages.size(); i++) {
changed |= mPages.get(i).updateResources();
@@ -326,7 +334,8 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
public void onPageScrolled(int position, float positionOffset,
int positionOffsetPixels) {
if (mPageIndicator == null) return;
mPageIndicator.setLocation(position + positionOffset);
mPageIndicatorPosition = position + positionOffset;
mPageIndicator.setLocation(mPageIndicatorPosition);
if (mPageListener != null) {
mPageListener.onPageChanged(positionOffsetPixels == 0 &&
(isLayoutRtl() ? position == mPages.size() - 1 : position == 0));

View File

@@ -17,6 +17,7 @@
package com.android.systemui.qs;
import static android.app.StatusBarManager.DISABLE2_QUICK_SETTINGS;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import android.content.Context;
import android.content.Intent;
@@ -35,6 +36,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.android.internal.logging.MetricsLogger;
@@ -66,6 +68,7 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
private UserInfoController mUserInfoController;
private SettingsButton mSettingsButton;
protected View mSettingsContainer;
private PageIndicator mPageIndicator;
private CarrierText mCarrierText;
private boolean mQsDisabled;
@@ -108,6 +111,8 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
Dependency.get(ActivityStarter.class).postQSRunnableDismissingKeyguard(() ->
mQsPanel.showEdit(view)));
mPageIndicator = findViewById(R.id.footer_page_indicator);
mSettingsButton = findViewById(R.id.settings_button);
mSettingsContainer = findViewById(R.id.settings_button_container);
mSettingsButton.setOnClickListener(this);
@@ -167,6 +172,14 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
private void updateResources() {
updateFooterAnimator();
// Update the width and weight of the actions container as the page indicator can sometimes
// show and the layout needs to center it between the carrier text and actions container.
LinearLayout.LayoutParams params =
(LinearLayout.LayoutParams) mActionsContainer.getLayoutParams();
params.width = mContext.getResources().getInteger(R.integer.qs_footer_actions_width);
params.weight = mContext.getResources().getInteger(R.integer.qs_footer_actions_weight);
mActionsContainer.setLayoutParams(params);
}
private void updateFooterAnimator() {
@@ -181,6 +194,7 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
.addFloat(mMobileGroup, "alpha", 0, 1)
.addFloat(mActionsContainer, "alpha", 0, 1)
.addFloat(mDragHandle, "alpha", 1, 0, 0)
.addFloat(mPageIndicator, "alpha", 0, 1)
.setStartDelay(0.15f)
.build();
}
@@ -291,6 +305,7 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
mQsPanel = qsPanel;
if (mQsPanel != null) {
mMultiUserSwitch.setQsPanel(qsPanel);
mQsPanel.setFooterPageIndicator(mPageIndicator);
}
}

View File

@@ -16,6 +16,7 @@
package com.android.systemui.qs;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static com.android.systemui.qs.tileimpl.QSTileImpl.getColorForState;
import android.annotation.Nullable;
@@ -63,7 +64,6 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
protected final View mBrightnessView;
private final H mHandler = new H();
private final View mPageIndicator;
private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
private final QSTileRevealController mQsTileRevealController;
@@ -75,6 +75,8 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
protected QSTileHost mHost;
protected QSSecurityFooter mFooter;
private PageIndicator mPanelPageIndicator;
private PageIndicator mFooterPageIndicator;
private boolean mGridContentVisible = true;
protected QSTileLayout mTileLayout;
@@ -104,13 +106,13 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
mTileLayout.setListening(mListening);
addView((View) mTileLayout);
mPageIndicator = LayoutInflater.from(context).inflate(
mPanelPageIndicator = (PageIndicator) LayoutInflater.from(context).inflate(
R.layout.qs_page_indicator, this, false);
addView(mPageIndicator);
addView(mPanelPageIndicator);
((PagedTileLayout) mTileLayout).setPageIndicator((PageIndicator) mPageIndicator);
((PagedTileLayout) mTileLayout).setPageIndicator(mPanelPageIndicator);
mQsTileRevealController = new QSTileRevealController(mContext, this,
((PagedTileLayout) mTileLayout));
(PagedTileLayout) mTileLayout);
addDivider();
@@ -136,7 +138,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
}
public View getPageIndicator() {
return mPageIndicator;
return mPanelPageIndicator;
}
public QSTileRevealController getQsTileRevealController() {
@@ -241,6 +243,38 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
}
}
/**
* Links the footer's page indicator, which is used in landscape orientation to save space.
*
* @param pageIndicator indicator to use for page scrolling
*/
public void setFooterPageIndicator(PageIndicator pageIndicator) {
if (mTileLayout instanceof PagedTileLayout) {
mFooterPageIndicator = pageIndicator;
updatePageIndicator();
}
}
private void updatePageIndicator() {
if (mTileLayout instanceof PagedTileLayout) {
// If we're in landscape, and we have the footer page indicator (which we should if the
// footer has been initialized & linked), then we'll show the footer page indicator to
// save space in the main QS tile area. Otherwise, we'll use the default one under the
// tiles/above the footer.
boolean shouldUseFooterPageIndicator =
getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE
&& mFooterPageIndicator != null;
mPanelPageIndicator.setVisibility(View.GONE);
if (mFooterPageIndicator != null) {
mFooterPageIndicator.setVisibility(View.GONE);
}
((PagedTileLayout) mTileLayout).setPageIndicator(
shouldUseFooterPageIndicator ? mFooterPageIndicator : mPanelPageIndicator);
}
}
public QSTileHost getHost() {
return mHost;
}
@@ -248,6 +282,9 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
public void updateResources() {
final Resources res = mContext.getResources();
setPadding(0, res.getDimensionPixelSize(R.dimen.qs_panel_padding_top), 0, res.getDimensionPixelSize(R.dimen.qs_panel_padding_bottom));
updatePageIndicator();
for (TileRecord r : mRecords) {
r.tile.clearState();
}