summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java50
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizerController.java59
-rw-r--r--packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java6
3 files changed, 52 insertions, 63 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
index 51a4af87a436..3291aa0e2099 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
@@ -32,17 +32,12 @@ import android.widget.Toolbar;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.RecyclerView;
-import com.android.internal.logging.UiEventLogger;
-import com.android.internal.logging.UiEventLoggerImpl;
import com.android.systemui.R;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.qs.QSDetailClipper;
-import com.android.systemui.qs.QSEditEvent;
import com.android.systemui.statusbar.phone.LightBarController;
import com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer;
-import javax.inject.Inject;
-
/**
* Allows full-screen customization of QS, through show() and hide().
*
@@ -53,15 +48,12 @@ public class QSCustomizer extends LinearLayout {
static final int MENU_RESET = Menu.FIRST;
static final String EXTRA_QS_CUSTOMIZING = "qs_customizing";
- private static final String TAG = "QSCustomizer";
private final QSDetailClipper mClipper;
- private final LightBarController mLightBarController;
private final View mTransparentView;
private boolean isShown;
- private RecyclerView mRecyclerView;
- private Toolbar mToolbar;
+ private final RecyclerView mRecyclerView;
private boolean mCustomizing;
private NotificationsQuickSettingsContainer mNotifQsContainer;
private QS mQs;
@@ -69,59 +61,47 @@ public class QSCustomizer extends LinearLayout {
private int mY;
private boolean mOpening;
private boolean mIsShowingNavBackdrop;
- private UiEventLogger mUiEventLogger = new UiEventLoggerImpl();
- @Inject
- public QSCustomizer(Context context, AttributeSet attrs,
- LightBarController lightBarController) {
+ public QSCustomizer(Context context, AttributeSet attrs) {
super(new ContextThemeWrapper(context, R.style.edit_theme), attrs);
LayoutInflater.from(getContext()).inflate(R.layout.qs_customize_panel_content, this);
mClipper = new QSDetailClipper(findViewById(R.id.customize_container));
- mToolbar = findViewById(com.android.internal.R.id.action_bar);
+ Toolbar toolbar = findViewById(com.android.internal.R.id.action_bar);
TypedValue value = new TypedValue();
mContext.getTheme().resolveAttribute(android.R.attr.homeAsUpIndicator, value, true);
- mToolbar.setNavigationIcon(
+ toolbar.setNavigationIcon(
getResources().getDrawable(value.resourceId, mContext.getTheme()));
- mToolbar.getMenu().add(Menu.NONE, MENU_RESET, 0,
+ toolbar.getMenu().add(Menu.NONE, MENU_RESET, 0,
mContext.getString(com.android.internal.R.string.reset));
- mToolbar.setTitle(R.string.qs_edit);
+ toolbar.setTitle(R.string.qs_edit);
mRecyclerView = findViewById(android.R.id.list);
mTransparentView = findViewById(R.id.customizer_transparent_view);
DefaultItemAnimator animator = new DefaultItemAnimator();
animator.setMoveDuration(TileAdapter.MOVE_DURATION);
mRecyclerView.setItemAnimator(animator);
- mLightBarController = lightBarController;
- updateNavBackDrop(getResources().getConfiguration());
- }
-
- @Override
- protected void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- updateNavBackDrop(newConfig);
- updateResources();
}
- private void updateResources() {
+ void updateResources() {
LayoutParams lp = (LayoutParams) mTransparentView.getLayoutParams();
lp.height = mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.quick_qs_offset_height);
mTransparentView.setLayoutParams(lp);
}
- private void updateNavBackDrop(Configuration newConfig) {
+ void updateNavBackDrop(Configuration newConfig, LightBarController lightBarController) {
View navBackdrop = findViewById(R.id.nav_bar_background);
mIsShowingNavBackdrop = newConfig.smallestScreenWidthDp >= 600
|| newConfig.orientation != Configuration.ORIENTATION_LANDSCAPE;
if (navBackdrop != null) {
navBackdrop.setVisibility(mIsShowingNavBackdrop ? View.VISIBLE : View.GONE);
}
- updateNavColors();
+ updateNavColors(lightBarController);
}
- private void updateNavColors() {
- mLightBarController.setQsCustomizing(mIsShowingNavBackdrop && isShown);
+ void updateNavColors(LightBarController lightBarController) {
+ lightBarController.setQsCustomizing(mIsShowingNavBackdrop && isShown);
}
public void setContainer(NotificationsQuickSettingsContainer notificationsQsContainer) {
@@ -137,17 +117,15 @@ public class QSCustomizer extends LinearLayout {
*/
void show(int x, int y, TileAdapter tileAdapter) {
if (!isShown) {
- int containerLocation[] = findViewById(R.id.customize_container).getLocationOnScreen();
+ int[] containerLocation = findViewById(R.id.customize_container).getLocationOnScreen();
mX = x - containerLocation[0];
mY = y - containerLocation[1];
- mUiEventLogger.log(QSEditEvent.QS_EDIT_OPEN);
isShown = true;
mOpening = true;
setVisibility(View.VISIBLE);
mClipper.animateCircularClip(mX, mY, true, new ExpandAnimatorListener(tileAdapter));
mNotifQsContainer.setCustomizerAnimating(true);
mNotifQsContainer.setCustomizerShowing(true);
- updateNavColors();
}
}
@@ -161,7 +139,6 @@ public class QSCustomizer extends LinearLayout {
setCustomizing(true);
mNotifQsContainer.setCustomizerAnimating(false);
mNotifQsContainer.setCustomizerShowing(true);
- updateNavColors();
}
}
@@ -193,7 +170,6 @@ public class QSCustomizer extends LinearLayout {
}
mNotifQsContainer.setCustomizerAnimating(animate);
mNotifQsContainer.setCustomizerShowing(false);
- updateNavColors();
}
}
@@ -213,7 +189,7 @@ public class QSCustomizer extends LinearLayout {
/** @param x,y Location on screen of animation center.
*/
public void setEditLocation(int x, int y) {
- int containerLocation[] = findViewById(R.id.customize_container).getLocationOnScreen();
+ int[] containerLocation = findViewById(R.id.customize_container).getLocationOnScreen();
mX = x - containerLocation[0];
mY = y - containerLocation[1];
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizerController.java b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizerController.java
index 9cef87eb0479..0f1616768eca 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizerController.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizerController.java
@@ -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_RESET;
+import android.content.res.Configuration;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
@@ -37,7 +38,10 @@ import com.android.systemui.qs.QSEditEvent;
import com.android.systemui.qs.QSFragment;
import com.android.systemui.qs.QSTileHost;
import com.android.systemui.qs.dagger.QSScope;
+import com.android.systemui.statusbar.phone.LightBarController;
import com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer;
+import com.android.systemui.statusbar.policy.ConfigurationController;
+import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.ViewController;
@@ -54,17 +58,17 @@ public class QSCustomizerController extends ViewController<QSCustomizer> {
private final TileAdapter mTileAdapter;
private final ScreenLifecycle mScreenLifecycle;
private final KeyguardStateController mKeyguardStateController;
+ private final LightBarController mLightBarController;
+ private final ConfigurationController mConfigurationController;
private final UiEventLogger mUiEventLogger;
private final Toolbar mToolbar;
private final OnMenuItemClickListener mOnMenuItemClickListener = new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
- switch (item.getItemId()) {
- case MENU_RESET:
- mUiEventLogger.log(QSEditEvent.QS_EDIT_RESET);
- reset();
- break;
+ if (item.getItemId() == MENU_RESET) {
+ mUiEventLogger.log(QSEditEvent.QS_EDIT_RESET);
+ reset();
}
return false;
}
@@ -72,25 +76,36 @@ public class QSCustomizerController extends ViewController<QSCustomizer> {
private final KeyguardStateController.Callback mKeyguardCallback =
new KeyguardStateController.Callback() {
- @Override
- public void onKeyguardShowingChanged() {
- if (!mView.isAttachedToWindow()) return;
- if (mKeyguardStateController.isShowing() && !mView.isOpening()) {
- hide();
- }
- }
- };
+ @Override
+ public void onKeyguardShowingChanged() {
+ if (!mView.isAttachedToWindow()) return;
+ if (mKeyguardStateController.isShowing() && !mView.isOpening()) {
+ hide();
+ }
+ }
+ };
+
+ private final ConfigurationListener mConfigurationListener = new ConfigurationListener() {
+ @Override
+ public void onConfigChanged(Configuration newConfig) {
+ mView.updateNavBackDrop(newConfig, mLightBarController);
+ mView.updateResources();
+ }
+ };
@Inject
protected QSCustomizerController(QSCustomizer view, TileQueryHelper tileQueryHelper,
QSTileHost qsTileHost, TileAdapter tileAdapter, ScreenLifecycle screenLifecycle,
- KeyguardStateController keyguardStateController, UiEventLogger uiEventLogger) {
+ KeyguardStateController keyguardStateController, LightBarController lightBarController,
+ ConfigurationController configurationController, UiEventLogger uiEventLogger) {
super(view);
mTileQueryHelper = tileQueryHelper;
mQsTileHost = qsTileHost;
mTileAdapter = tileAdapter;
mScreenLifecycle = screenLifecycle;
mKeyguardStateController = keyguardStateController;
+ mLightBarController = lightBarController;
+ mConfigurationController = configurationController;
mUiEventLogger = uiEventLogger;
mToolbar = mView.findViewById(com.android.internal.R.id.action_bar);
@@ -98,6 +113,10 @@ public class QSCustomizerController extends ViewController<QSCustomizer> {
@Override
protected void onViewAttached() {
+ mView.updateNavBackDrop(getResources().getConfiguration(), mLightBarController);
+
+ mConfigurationController.addCallback(mConfigurationListener);
+
mTileQueryHelper.setListener(mTileAdapter);
int halfMargin =
getResources().getDimensionPixelSize(R.dimen.qs_tile_margin_horizontal) / 2;
@@ -119,18 +138,14 @@ public class QSCustomizerController extends ViewController<QSCustomizer> {
recyclerView.addItemDecoration(mTileAdapter.getMarginItemDecoration());
mToolbar.setOnMenuItemClickListener(mOnMenuItemClickListener);
- mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- hide();
- }
- });
+ mToolbar.setNavigationOnClickListener(v -> hide());
}
@Override
protected void onViewDetached() {
mTileQueryHelper.setListener(null);
mToolbar.setOnMenuItemClickListener(null);
+ mConfigurationController.removeCallback(mConfigurationListener);
}
@@ -150,9 +165,11 @@ public class QSCustomizerController extends ViewController<QSCustomizer> {
mView.showImmediately();
} else {
mView.show(x, y, mTileAdapter);
+ mUiEventLogger.log(QSEditEvent.QS_EDIT_OPEN);
}
mTileQueryHelper.queryTiles(mQsTileHost);
mKeyguardStateController.addCallback(mKeyguardCallback);
+ mView.updateNavColors(mLightBarController);
}
}
@@ -160,6 +177,7 @@ public class QSCustomizerController extends ViewController<QSCustomizer> {
public void setQs(QSFragment qsFragment) {
mView.setQs(qsFragment);
}
+
/** */
public void restoreInstanceState(Bundle savedInstanceState) {
boolean customizing = savedInstanceState.getBoolean(EXTRA_QS_CUSTOMIZING);
@@ -213,6 +231,7 @@ public class QSCustomizerController extends ViewController<QSCustomizer> {
mView.setCustomizing(false);
save();
mView.hide(animate);
+ mView.updateNavColors(mLightBarController);
mKeyguardStateController.removeCallback(mKeyguardCallback);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java
index e79d432b3b15..4b4e1df21bd0 100644
--- a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java
+++ b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java
@@ -26,7 +26,6 @@ import android.view.View;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.qs.QSPanel;
import com.android.systemui.qs.QuickQSPanel;
-import com.android.systemui.qs.customize.QSCustomizer;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import java.lang.reflect.InvocationTargetException;
@@ -104,11 +103,6 @@ public class InjectionInflationController {
* Creates the QuickQSPanel.
*/
QuickQSPanel createQuickQSPanel();
-
- /**
- * Creates the QSCustomizer.
- */
- QSCustomizer createQSCustomizer();
}