summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/src')
-rw-r--r--packages/SystemUI/src/com/android/systemui/ExpandHelper.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/SwipeHelper.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java16
-rw-r--r--packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java27
-rw-r--r--packages/SystemUI/src/com/android/systemui/power/PowerUI.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSDetailClipper.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSPanel.java16
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSTile.java116
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSTileView.java50
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/UsageTracker.java26
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java24
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java19
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java25
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java99
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java45
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java22
-rw-r--r--packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/recent/ScreenPinningRequest.java283
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java89
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/Constants.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java78
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/misc/DozeTrigger.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java35
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java15
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/KeyStoreLruCache.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/RecentsPackageMonitor.java64
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java36
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/Task.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java98
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java96
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java252
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java14
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java30
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java308
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskViewFooter.java98
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java75
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java216
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/ViewPool.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java113
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/DismissViewImageButton.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java20
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java13
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationBackgroundView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java50
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java18
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java44
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java36
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java176
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java68
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java119
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java18
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarTransitions.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java41
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/TrustDrawable.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/AccessPointController.java (renamed from packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiAccessPointController.java)84
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java19
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java81
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java83
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java32
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java103
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java34
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java79
95 files changed, 2436 insertions, 1362 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
index 0f8fe1c..d42ac61 100644
--- a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
@@ -351,6 +351,9 @@ public class ExpandHelper implements Gefingerpoken {
mVelocityTracker.addMovement(event);
break;
case MotionEvent.ACTION_MOVE:
+ if (mVelocityTracker == null) {
+ mVelocityTracker = VelocityTracker.obtain();
+ }
mVelocityTracker.addMovement(event);
break;
default:
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index 0d393bf..f206e56 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -311,11 +311,14 @@ public class SwipeHelper implements Gefingerpoken {
final View animView = mCallback.getChildContentView(view);
final boolean canAnimViewBeDismissed = mCallback.canChildBeDismissed(view);
float newPos;
+ boolean isLayoutRtl = view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
if (velocity < 0
|| (velocity == 0 && getTranslation(animView) < 0)
// if we use the Menu to dismiss an item in landscape, animate up
- || (velocity == 0 && getTranslation(animView) == 0 && mSwipeDirection == Y)) {
+ || (velocity == 0 && getTranslation(animView) == 0 && mSwipeDirection == Y)
+ // if the language is rtl we prefer swiping to the left
+ || (velocity == 0 && getTranslation(animView) == 0 && isLayoutRtl)) {
newPos = -getSize(animView);
} else {
newPos = getSize(animView);
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 4af8499..172aaf6 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -364,7 +364,7 @@ public class KeyguardViewMediator extends SystemUI {
// only force lock screen in case of missing sim if user hasn't
// gone through setup wizard
synchronized (this) {
- if (!mUpdateMonitor.isDeviceProvisioned()) {
+ if (shouldWaitForProvisioning()) {
if (!isShowing()) {
if (DEBUG) Log.d(TAG, "ICC_ABSENT isn't showing,"
+ " we need to show the keyguard since the "
@@ -493,8 +493,7 @@ public class KeyguardViewMediator extends SystemUI {
mLockPatternUtils.setCurrentUser(ActivityManager.getCurrentUser());
// Assume keyguard is showing (unless it's disabled) until we know for sure...
- mShowing = (mUpdateMonitor.isDeviceProvisioned() || mLockPatternUtils.isSecure())
- && !mLockPatternUtils.isLockScreenDisabled();
+ mShowing = !shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled();
mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager(mContext,
mViewMediatorCallback, mLockPatternUtils);
@@ -783,7 +782,7 @@ public class KeyguardViewMediator extends SystemUI {
public void verifyUnlock(IKeyguardExitCallback callback) {
synchronized (this) {
if (DEBUG) Log.d(TAG, "verifyUnlock");
- if (!mUpdateMonitor.isDeviceProvisioned()) {
+ if (shouldWaitForProvisioning()) {
// don't allow this api when the device isn't provisioned
if (DEBUG) Log.d(TAG, "ignoring because device isn't provisioned");
try {
@@ -873,7 +872,7 @@ public class KeyguardViewMediator extends SystemUI {
* was suppressed by an app that disabled the keyguard or we haven't been provisioned yet.
*/
public boolean isInputRestricted() {
- return mShowing || mNeedToReshowWhenReenabled || !mUpdateMonitor.isDeviceProvisioned();
+ return mShowing || mNeedToReshowWhenReenabled || shouldWaitForProvisioning();
}
/**
@@ -905,14 +904,13 @@ public class KeyguardViewMediator extends SystemUI {
// if the setup wizard hasn't run yet, don't show
final boolean requireSim = !SystemProperties.getBoolean("keyguard.no_require_sim",
false);
- final boolean provisioned = mUpdateMonitor.isDeviceProvisioned();
final IccCardConstants.State state = mUpdateMonitor.getSimState();
final boolean lockedOrMissing = state.isPinLocked()
|| ((state == IccCardConstants.State.ABSENT
|| state == IccCardConstants.State.PERM_DISABLED)
&& requireSim);
- if (!lockedOrMissing && !provisioned) {
+ if (!lockedOrMissing && shouldWaitForProvisioning()) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because device isn't provisioned"
+ " and the sim is not locked or missing");
return;
@@ -935,6 +933,10 @@ public class KeyguardViewMediator extends SystemUI {
showLocked(options);
}
+ private boolean shouldWaitForProvisioning() {
+ return !mUpdateMonitor.isDeviceProvisioned() && !isSecure();
+ }
+
/**
* Dismiss the keyguard through the security layers.
*/
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
index f184ad2..4391bfc 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
@@ -43,6 +43,7 @@ import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import java.io.PrintWriter;
+import java.text.NumberFormat;
public class PowerNotificationWarnings implements PowerUI.WarningsUI {
private static final String TAG = PowerUI.TAG + ".Notification";
@@ -65,6 +66,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
private static final String ACTION_SHOW_BATTERY_SETTINGS = "PNW.batterySettings";
private static final String ACTION_START_SAVER = "PNW.startSaver";
private static final String ACTION_STOP_SAVER = "PNW.stopSaver";
+ private static final String ACTION_DISMISSED_WARNING = "PNW.dismissedWarning";
private static final AudioAttributes AUDIO_ATTRIBUTES = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
@@ -143,7 +145,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
showSaverNotification();
mShowing = SHOWING_SAVER;
} else {
- mNoMan.cancel(TAG_NOTIFICATION, ID_NOTIFICATION);
+ mNoMan.cancelAsUser(TAG_NOTIFICATION, ID_NOTIFICATION, UserHandle.ALL);
mShowing = SHOWING_NOTHING;
}
}
@@ -157,7 +159,6 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
.setContentTitle(mContext.getString(R.string.invalid_charger_title))
.setContentText(mContext.getString(R.string.invalid_charger_text))
.setPriority(Notification.PRIORITY_MAX)
- .setCategory(Notification.CATEGORY_SYSTEM)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setColor(mContext.getResources().getColor(
com.android.internal.R.color.system_notification_accent_color));
@@ -165,22 +166,23 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
if (n.headsUpContentView != null) {
n.headsUpContentView.setViewVisibility(com.android.internal.R.id.right_icon, View.GONE);
}
- mNoMan.notifyAsUser(TAG_NOTIFICATION, ID_NOTIFICATION, n, UserHandle.CURRENT);
+ mNoMan.notifyAsUser(TAG_NOTIFICATION, ID_NOTIFICATION, n, UserHandle.ALL);
}
private void showWarningNotification() {
final int textRes = mSaver ? R.string.battery_low_percent_format_saver_started
: R.string.battery_low_percent_format;
+ final String percentage = NumberFormat.getPercentInstance().format((double) mBatteryLevel / 100.0);
final Notification.Builder nb = new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_power_low)
// Bump the notification when the bucket dropped.
.setWhen(mBucketDroppedNegativeTimeMs)
.setShowWhen(false)
.setContentTitle(mContext.getString(R.string.battery_low_title))
- .setContentText(mContext.getString(textRes, mBatteryLevel))
+ .setContentText(mContext.getString(textRes, percentage))
.setOnlyAlertOnce(true)
+ .setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_WARNING))
.setPriority(Notification.PRIORITY_MAX)
- .setCategory(Notification.CATEGORY_SYSTEM)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setColor(mContext.getResources().getColor(
com.android.internal.R.color.battery_saver_mode_color));
@@ -202,7 +204,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
if (n.headsUpContentView != null) {
n.headsUpContentView.setViewVisibility(com.android.internal.R.id.right_icon, View.GONE);
}
- mNoMan.notifyAsUser(TAG_NOTIFICATION, ID_NOTIFICATION, n, UserHandle.CURRENT);
+ mNoMan.notifyAsUser(TAG_NOTIFICATION, ID_NOTIFICATION, n, UserHandle.ALL);
}
private void showSaverNotification() {
@@ -212,7 +214,6 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
.setContentText(mContext.getString(R.string.battery_saver_notification_text))
.setOngoing(true)
.setShowWhen(false)
- .setCategory(Notification.CATEGORY_SYSTEM)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setColor(mContext.getResources().getColor(
com.android.internal.R.color.battery_saver_mode_color));
@@ -220,7 +221,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
if (hasSaverSettings()) {
nb.setContentIntent(pendingActivity(mOpenSaverSettings));
}
- mNoMan.notifyAsUser(TAG_NOTIFICATION, ID_NOTIFICATION, nb.build(), UserHandle.CURRENT);
+ mNoMan.notifyAsUser(TAG_NOTIFICATION, ID_NOTIFICATION, nb.build(), UserHandle.ALL);
}
private void addStopSaverAction(Notification.Builder nb) {
@@ -341,6 +342,11 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
updateNotification();
}
+ @Override
+ public void userSwitched() {
+ updateNotification();
+ }
+
private void showStartSaverConfirmation() {
if (mSaverConfirmation != null) return;
final SystemUIDialog d = new SystemUIDialog(mContext);
@@ -370,7 +376,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
filter.addAction(ACTION_SHOW_BATTERY_SETTINGS);
filter.addAction(ACTION_START_SAVER);
filter.addAction(ACTION_STOP_SAVER);
- mContext.registerReceiver(this, filter, null, mHandler);
+ filter.addAction(ACTION_DISMISSED_WARNING);
+ mContext.registerReceiverAsUser(this, UserHandle.ALL, filter, null, mHandler);
}
@Override
@@ -387,6 +394,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
dismissSaverNotification();
dismissLowBatteryNotification();
setSaverMode(false);
+ } else if (action.equals(ACTION_DISMISSED_WARNING)) {
+ dismissLowBatteryWarning();
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
index d3c7dee..9459740 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
@@ -137,6 +137,7 @@ public class PowerUI extends SystemUI {
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
+ filter.addAction(Intent.ACTION_USER_SWITCHED);
filter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGING);
filter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
mContext.registerReceiver(this, filter, null, mHandler);
@@ -207,6 +208,8 @@ public class PowerUI extends SystemUI {
mScreenOffTime = SystemClock.elapsedRealtime();
} else if (Intent.ACTION_SCREEN_ON.equals(action)) {
mScreenOffTime = -1;
+ } else if (Intent.ACTION_USER_SWITCHED.equals(action)) {
+ mWarnings.userSwitched();
} else if (PowerManager.ACTION_POWER_SAVE_MODE_CHANGED.equals(action)) {
updateSaverMode();
} else if (PowerManager.ACTION_POWER_SAVE_MODE_CHANGING.equals(action)) {
@@ -256,6 +259,7 @@ public class PowerUI extends SystemUI {
void updateLowBatteryWarning();
boolean isInvalidChargerWarningShowing();
void dump(PrintWriter pw);
+ void userSwitched();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDetailClipper.java b/packages/SystemUI/src/com/android/systemui/qs/QSDetailClipper.java
index eb4560d..111484b 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSDetailClipper.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSDetailClipper.java
@@ -55,7 +55,6 @@ public class QSDetailClipper {
if (listener != null) {
mAnimator.addListener(listener);
}
- mDetail.setLayerType(View.LAYER_TYPE_HARDWARE, null);
if (in) {
mBackground.startTransition((int)(mAnimator.getDuration() * 0.6));
mAnimator.addListener(mVisibleOnStart);
@@ -82,7 +81,6 @@ public class QSDetailClipper {
}
public void onAnimationEnd(Animator animation) {
- mDetail.setLayerType(View.LAYER_TYPE_NONE, null);
mAnimator = null;
}
};
@@ -90,7 +88,6 @@ public class QSDetailClipper {
private final AnimatorListenerAdapter mGoneOnEnd = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- mDetail.setLayerType(View.LAYER_TYPE_NONE, null);
mDetail.setVisibility(View.GONE);
mBackground.resetTransition();
mAnimator = null;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index fdebdd3..91b1569 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -203,7 +203,7 @@ public class QSPanel extends ViewGroup {
}
}
- private void refreshAllTiles() {
+ public void refreshAllTiles() {
for (TileRecord r : mRecords) {
r.tile.refreshState();
}
@@ -296,7 +296,14 @@ public class QSPanel extends ViewGroup {
r.tile.secondaryClick();
}
};
- r.tileView.init(click, clickSecondary);
+ final View.OnLongClickListener longClick = new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ r.tile.longClick();
+ return true;
+ }
+ };
+ r.tileView.init(click, clickSecondary, longClick);
r.tile.setListening(mListening);
callback.onStateChanged(r.tile.getState());
r.tile.refreshState();
@@ -542,7 +549,10 @@ public class QSPanel extends ViewGroup {
@Override
public void onAnimationEnd(Animator animation) {
- setGridContentVisibility(false);
+ // Only hide content if still in detail state.
+ if (mDetailRecord != null) {
+ setGridContentVisibility(false);
+ }
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
index 6ef6e9e..1790a4e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
@@ -18,11 +18,13 @@ package com.android.systemui.qs;
import android.content.Context;
import android.content.Intent;
+import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
+import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
@@ -110,6 +112,10 @@ public abstract class QSTile<TState extends State> implements Listenable {
mHandler.sendEmptyMessage(H.SECONDARY_CLICK);
}
+ public void longClick() {
+ mHandler.sendEmptyMessage(H.LONG_CLICK);
+ }
+
public void showDetail(boolean show) {
mHandler.obtainMessage(H.SHOW_DETAIL, show ? 1 : 0, 0).sendToTarget();
}
@@ -153,6 +159,10 @@ public abstract class QSTile<TState extends State> implements Listenable {
// optional
}
+ protected void handleLongClick() {
+ // optional
+ }
+
protected void handleRefreshState(Object arg) {
handleUpdateState(mTmpState, arg);
final boolean changed = mTmpState.copyTo(mState);
@@ -214,12 +224,13 @@ public abstract class QSTile<TState extends State> implements Listenable {
private static final int SET_CALLBACK = 1;
private static final int CLICK = 2;
private static final int SECONDARY_CLICK = 3;
- private static final int REFRESH_STATE = 4;
- private static final int SHOW_DETAIL = 5;
- private static final int USER_SWITCH = 6;
- private static final int TOGGLE_STATE_CHANGED = 7;
- private static final int SCAN_STATE_CHANGED = 8;
- private static final int DESTROY = 9;
+ private static final int LONG_CLICK = 4;
+ private static final int REFRESH_STATE = 5;
+ private static final int SHOW_DETAIL = 6;
+ private static final int USER_SWITCH = 7;
+ private static final int TOGGLE_STATE_CHANGED = 8;
+ private static final int SCAN_STATE_CHANGED = 9;
+ private static final int DESTROY = 10;
private H(Looper looper) {
super(looper);
@@ -239,6 +250,9 @@ public abstract class QSTile<TState extends State> implements Listenable {
} else if (msg.what == SECONDARY_CLICK) {
name = "handleSecondaryClick";
handleSecondaryClick();
+ } else if (msg.what == LONG_CLICK) {
+ name = "handleLongClick";
+ handleLongClick();
} else if (msg.what == REFRESH_STATE) {
name = "handleRefreshState";
handleRefreshState(msg.obj);
@@ -299,10 +313,91 @@ public abstract class QSTile<TState extends State> implements Listenable {
}
}
+ public static abstract class Icon {
+ abstract public Drawable getDrawable(Context context);
+
+ @Override
+ public int hashCode() {
+ return Icon.class.hashCode();
+ }
+ }
+
+ public static class ResourceIcon extends Icon {
+ private static final SparseArray<Icon> ICONS = new SparseArray<Icon>();
+
+ private final int mResId;
+
+ private ResourceIcon(int resId) {
+ mResId = resId;
+ }
+
+ public static Icon get(int resId) {
+ Icon icon = ICONS.get(resId);
+ if (icon == null) {
+ icon = new ResourceIcon(resId);
+ ICONS.put(resId, icon);
+ }
+ return icon;
+ }
+
+ @Override
+ public Drawable getDrawable(Context context) {
+ return context.getDrawable(mResId);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof ResourceIcon && ((ResourceIcon) o).mResId == mResId;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("ResourceIcon[resId=0x%08x]", mResId);
+ }
+ }
+
+ protected class AnimationIcon extends ResourceIcon {
+ private boolean mAllowAnimation;
+
+ public AnimationIcon(int resId) {
+ super(resId);
+ }
+
+ public void setAllowAnimation(boolean allowAnimation) {
+ mAllowAnimation = allowAnimation;
+ }
+
+ @Override
+ public Drawable getDrawable(Context context) {
+ // workaround: get a clean state for every new AVD
+ final AnimatedVectorDrawable d = (AnimatedVectorDrawable) super.getDrawable(context)
+ .getConstantState().newDrawable();
+ d.start();
+ if (mAllowAnimation) {
+ mAllowAnimation = false;
+ } else {
+ d.stop(); // skip directly to end state
+ }
+ return d;
+ }
+ }
+
+ protected enum UserBoolean {
+ USER_TRUE(true, true),
+ USER_FALSE(true, false),
+ BACKGROUND_TRUE(false, true),
+ BACKGROUND_FALSE(false, false);
+ public final boolean value;
+ public final boolean userInitiated;
+ private UserBoolean(boolean userInitiated, boolean value) {
+ this.value = value;
+ this.userInitiated = userInitiated;
+ }
+ }
+
public static class State {
public boolean visible;
- public int iconId;
- public Drawable icon;
+ public Icon icon;
public String label;
public String contentDescription;
public String dualLabelContentDescription;
@@ -312,7 +407,6 @@ public abstract class QSTile<TState extends State> implements Listenable {
if (other == null) throw new IllegalArgumentException();
if (!other.getClass().equals(getClass())) throw new IllegalArgumentException();
final boolean changed = other.visible != visible
- || other.iconId != iconId
|| !Objects.equals(other.icon, icon)
|| !Objects.equals(other.label, label)
|| !Objects.equals(other.contentDescription, contentDescription)
@@ -320,7 +414,6 @@ public abstract class QSTile<TState extends State> implements Listenable {
|| !Objects.equals(other.dualLabelContentDescription,
dualLabelContentDescription);
other.visible = visible;
- other.iconId = iconId;
other.icon = icon;
other.label = label;
other.contentDescription = contentDescription;
@@ -335,9 +428,8 @@ public abstract class QSTile<TState extends State> implements Listenable {
}
protected StringBuilder toStringBuilder() {
- final StringBuilder sb = new StringBuilder( getClass().getSimpleName()).append('[');
+ final StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('[');
sb.append("visible=").append(visible);
- sb.append(",iconId=").append(iconId);
sb.append(",icon=").append(icon);
sb.append(",label=").append(label);
sb.append(",contentDescription=").append(contentDescription);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
index 3574877..bb353d5 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
@@ -21,6 +21,7 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Typeface;
+import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Handler;
@@ -39,6 +40,8 @@ import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile.State;
+import java.util.Objects;
+
/** View that represents a standard quick settings tile. **/
public class QSTileView extends ViewGroup {
private static final Typeface CONDENSED = Typeface.create("sans-serif-condensed",
@@ -60,6 +63,8 @@ public class QSTileView extends ViewGroup {
private boolean mDual;
private OnClickListener mClickPrimary;
private OnClickListener mClickSecondary;
+ private OnLongClickListener mLongClick;
+ private Drawable mTileBackground;
private RippleDrawable mRipple;
public QSTileView(Context context) {
@@ -72,6 +77,7 @@ public class QSTileView extends ViewGroup {
mTilePaddingBelowIconPx = res.getDimensionPixelSize(R.dimen.qs_tile_padding_below_icon);
mDualTileVerticalPaddingPx =
res.getDimensionPixelSize(R.dimen.qs_dual_tile_padding_vertical);
+ mTileBackground = newTileBackground();
recreateLabel();
setClipChildren(false);
@@ -132,6 +138,7 @@ public class QSTileView extends ViewGroup {
mDualLabel = new QSDualTileLabel(mContext);
mDualLabel.setId(android.R.id.title);
mDualLabel.setBackgroundResource(R.drawable.btn_borderless_rect);
+ mDualLabel.setFirstLineCaret(res.getDrawable(R.drawable.qs_dual_tile_caret));
mDualLabel.setTextColor(res.getColor(R.color.qs_tile_text));
mDualLabel.setPadding(0, mDualTileVerticalPaddingPx, 0, mDualTileVerticalPaddingPx);
mDualLabel.setTypeface(CONDENSED);
@@ -171,22 +178,22 @@ public class QSTileView extends ViewGroup {
if (changed) {
recreateLabel();
}
- Drawable tileBackground = getTileBackground();
- if (tileBackground instanceof RippleDrawable) {
- setRipple((RippleDrawable) tileBackground);
+ if (mTileBackground instanceof RippleDrawable) {
+ setRipple((RippleDrawable) mTileBackground);
}
if (dual) {
mTopBackgroundView.setOnClickListener(mClickPrimary);
setOnClickListener(null);
setClickable(false);
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
- mTopBackgroundView.setBackground(tileBackground);
+ mTopBackgroundView.setBackground(mTileBackground);
} else {
mTopBackgroundView.setOnClickListener(null);
mTopBackgroundView.setClickable(false);
setOnClickListener(mClickPrimary);
+ setOnLongClickListener(mLongClick);
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
- setBackground(tileBackground);
+ setBackground(mTileBackground);
}
mTopBackgroundView.setFocusable(dual);
setFocusable(!dual);
@@ -201,9 +208,11 @@ public class QSTileView extends ViewGroup {
}
}
- public void init(OnClickListener clickPrimary, OnClickListener clickSecondary) {
+ public void init(OnClickListener clickPrimary, OnClickListener clickSecondary,
+ OnLongClickListener longClick) {
mClickPrimary = clickPrimary;
mClickSecondary = clickSecondary;
+ mLongClick = longClick;
}
protected View createIcon() {
@@ -213,7 +222,7 @@ public class QSTileView extends ViewGroup {
return icon;
}
- private Drawable getTileBackground() {
+ private Drawable newTileBackground() {
final int[] attrs = new int[] { android.R.attr.selectableItemBackgroundBorderless };
final TypedArray ta = mContext.obtainStyledAttributes(attrs);
final Drawable d = ta.getDrawable(0);
@@ -284,16 +293,7 @@ public class QSTileView extends ViewGroup {
protected void handleStateChanged(QSTile.State state) {
if (mIcon instanceof ImageView) {
- ImageView iv = (ImageView) mIcon;
- if (state.icon != null) {
- iv.setImageDrawable(state.icon);
- } else if (state.iconId > 0) {
- iv.setImageResource(state.iconId);
- }
- Drawable drawable = iv.getDrawable();
- if (state.autoMirrorDrawable && drawable != null) {
- drawable.setAutoMirrored(true);
- }
+ setIcon((ImageView) mIcon, state);
}
if (mDual) {
mDualLabel.setText(state.label);
@@ -305,6 +305,22 @@ public class QSTileView extends ViewGroup {
}
}
+ protected void setIcon(ImageView iv, QSTile.State state) {
+ if (!Objects.equals(state.icon, iv.getTag(R.id.qs_icon_tag))) {
+ Drawable d = state.icon != null ? state.icon.getDrawable(mContext) : null;
+ if (d != null && state.autoMirrorDrawable) {
+ d.setAutoMirrored(true);
+ }
+ iv.setImageDrawable(d);
+ iv.setTag(R.id.qs_icon_tag, state.icon);
+ if (d instanceof Animatable) {
+ if (!iv.isShown()) {
+ ((Animatable) d).stop(); // skip directly to end state
+ }
+ }
+ }
+ }
+
public void onStateChanged(QSTile.State state) {
mHandler.obtainMessage(H.STATE_CHANGED, state).sendToTarget();
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java b/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java
index cfcd74e..9ac7944 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java
@@ -104,7 +104,7 @@ public final class SignalTileView extends QSTileView {
protected void handleStateChanged(QSTile.State state) {
super.handleStateChanged(state);
final SignalState s = (SignalState) state;
- mSignal.setImageResource(s.iconId);
+ setIcon(mSignal, s);
if (s.overlayIconId > 0) {
mOverlay.setVisibility(VISIBLE);
mOverlay.setImageResource(s.overlayIconId);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/UsageTracker.java b/packages/SystemUI/src/com/android/systemui/qs/UsageTracker.java
index ad79aba..e60aa53 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/UsageTracker.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/UsageTracker.java
@@ -18,11 +18,13 @@ package com.android.systemui.qs;
import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.Listenable;
public class UsageTracker implements Listenable {
@@ -35,11 +37,10 @@ public class UsageTracker implements Listenable {
private boolean mRegistered;
- public UsageTracker(Context context, Class<?> tile) {
+ public UsageTracker(Context context, Class<?> tile, int timeoutResource) {
mContext = context;
mPrefKey = tile.getSimpleName() + "LastUsed";
- mTimeToShowTile = MILLIS_PER_DAY * mContext.getResources()
- .getInteger(R.integer.days_to_show_timeout_tiles);
+ mTimeToShowTile = MILLIS_PER_DAY * mContext.getResources().getInteger(timeoutResource);
mResetAction = "com.android.systemui.qs." + tile.getSimpleName() + ".usage_reset";
}
@@ -67,6 +68,25 @@ public class UsageTracker implements Listenable {
getSharedPrefs().edit().remove(mPrefKey).commit();
}
+ public void showResetConfirmation(String title, final Runnable onConfirmed) {
+ final SystemUIDialog d = new SystemUIDialog(mContext);
+ d.setTitle(title);
+ d.setMessage(mContext.getString(R.string.quick_settings_reset_confirmation_message));
+ d.setNegativeButton(android.R.string.cancel, null);
+ d.setPositiveButton(R.string.quick_settings_reset_confirmation_button,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ reset();
+ if (onConfirmed != null) {
+ onConfirmed.run();
+ }
+ }
+ });
+ d.setCanceledOnTouchOutside(true);
+ d.show();
+ }
+
private SharedPreferences getSharedPrefs() {
return mContext.getSharedPreferences(mContext.getPackageName(), 0);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java
index 51401c8..2dd02a5 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java
@@ -29,6 +29,10 @@ import com.android.systemui.qs.QSTile;
/** Quick settings tile: Airplane mode **/
public class AirplaneModeTile extends QSTile<QSTile.BooleanState> {
+ private final AnimationIcon mEnable =
+ new AnimationIcon(R.drawable.ic_signal_airplane_enable_animation);
+ private final AnimationIcon mDisable =
+ new AnimationIcon(R.drawable.ic_signal_airplane_disable_animation);
private final GlobalSetting mSetting;
private boolean mListening;
@@ -52,6 +56,8 @@ public class AirplaneModeTile extends QSTile<QSTile.BooleanState> {
@Override
public void handleClick() {
setEnabled(!mState.value);
+ mEnable.setAllowAnimation(true);
+ mDisable.setAllowAnimation(true);
}
private void setEnabled(boolean enabled) {
@@ -68,11 +74,11 @@ public class AirplaneModeTile extends QSTile<QSTile.BooleanState> {
state.visible = true;
state.label = mContext.getString(R.string.quick_settings_airplane_mode_label);
if (airplaneMode) {
- state.iconId = R.drawable.ic_qs_airplane_on;
+ state.icon = mEnable;
state.contentDescription = mContext.getString(
R.string.accessibility_quick_settings_airplane_on);
} else {
- state.iconId = R.drawable.ic_qs_airplane_off;
+ state.icon = mDisable;
state.contentDescription = mContext.getString(
R.string.accessibility_quick_settings_airplane_off);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
index e99b4c5..4d77348 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
@@ -77,7 +77,7 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
@Override
protected void handleSecondaryClick() {
- mHost.startSettingsActivity(BLUETOOTH_SETTINGS);
+ showDetail(true);
}
@Override
@@ -92,17 +92,17 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
if (enabled) {
state.label = null;
if (connected) {
- state.iconId = R.drawable.ic_qs_bluetooth_connected;
+ state.icon = ResourceIcon.get(R.drawable.ic_qs_bluetooth_connected);
state.contentDescription = mContext.getString(
R.string.accessibility_quick_settings_bluetooth_connected);
state.label = mController.getLastDeviceName();
} else if (connecting) {
- state.iconId = R.drawable.ic_qs_bluetooth_connecting;
+ state.icon = ResourceIcon.get(R.drawable.ic_qs_bluetooth_connecting);
state.contentDescription = mContext.getString(
R.string.accessibility_quick_settings_bluetooth_connecting);
state.label = mContext.getString(R.string.quick_settings_bluetooth_label);
} else {
- state.iconId = R.drawable.ic_qs_bluetooth_on;
+ state.icon = ResourceIcon.get(R.drawable.ic_qs_bluetooth_on);
state.contentDescription = mContext.getString(
R.string.accessibility_quick_settings_bluetooth_on);
}
@@ -110,7 +110,7 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
state.label = mContext.getString(R.string.quick_settings_bluetooth_label);
}
} else {
- state.iconId = R.drawable.ic_qs_bluetooth_off;
+ state.icon = ResourceIcon.get(R.drawable.ic_qs_bluetooth_off);
state.label = mContext.getString(R.string.quick_settings_bluetooth_label);
state.contentDescription = mContext.getString(
R.string.accessibility_quick_settings_bluetooth_off);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java
index 8304291..5bf6fb5 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java
@@ -107,7 +107,8 @@ public class CastTile extends QSTile<QSTile.BooleanState> {
if (!state.value && connecting) {
state.label = mContext.getString(R.string.quick_settings_connecting);
}
- state.iconId = state.value ? R.drawable.ic_qs_cast_on : R.drawable.ic_qs_cast_off;
+ state.icon = ResourceIcon.get(state.value ? R.drawable.ic_qs_cast_on
+ : R.drawable.ic_qs_cast_off);
mDetailAdapter.updateItems(devices);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
index 359a259..178590b 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
@@ -87,16 +87,17 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
if (cb == null) return;
final Resources r = mContext.getResources();
- state.iconId = cb.noSim ? R.drawable.ic_qs_no_sim
+ final int iconId = cb.noSim ? R.drawable.ic_qs_no_sim
: !cb.enabled || cb.airplaneModeEnabled ? R.drawable.ic_qs_signal_disabled
: cb.mobileSignalIconId > 0 ? cb.mobileSignalIconId
: R.drawable.ic_qs_signal_no_signal;
+ state.icon = ResourceIcon.get(iconId);
state.isOverlayIconWide = cb.isDataTypeIconWide;
state.autoMirrorDrawable = !cb.noSim;
state.overlayIconId = cb.enabled && (cb.dataTypeIconId > 0) && !cb.wifiConnected
? cb.dataTypeIconId
: 0;
- state.filter = state.iconId != R.drawable.ic_qs_no_sim;
+ state.filter = iconId != R.drawable.ic_qs_no_sim;
state.activityIn = cb.enabled && cb.activityIn;
state.activityOut = cb.enabled && cb.activityOut;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java
index 01849c1..b565afa 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java
@@ -26,6 +26,10 @@ import com.android.systemui.qs.UsageTracker;
/** Quick settings tile: Invert colors **/
public class ColorInversionTile extends QSTile<QSTile.BooleanState> {
+ private final AnimationIcon mEnable
+ = new AnimationIcon(R.drawable.ic_invert_colors_enable_animation);
+ private final AnimationIcon mDisable
+ = new AnimationIcon(R.drawable.ic_invert_colors_disable_animation);
private final SecureSetting mSetting;
private final UsageTracker mUsageTracker;
@@ -44,7 +48,8 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> {
}
}
};
- mUsageTracker = new UsageTracker(host.getContext(), ColorInversionTile.class);
+ mUsageTracker = new UsageTracker(host.getContext(), ColorInversionTile.class,
+ R.integer.days_to_show_color_inversion_tile);
if (mSetting.getValue() != 0 && !mUsageTracker.isRecentlyUsed()) {
mUsageTracker.trackUsage();
}
@@ -78,6 +83,21 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> {
@Override
protected void handleClick() {
mSetting.setValue(mState.value ? 0 : 1);
+ mEnable.setAllowAnimation(true);
+ mDisable.setAllowAnimation(true);
+ }
+
+ @Override
+ protected void handleLongClick() {
+ if (mState.value) return; // don't allow usage reset if inversion is active
+ final String title = mContext.getString(R.string.quick_settings_reset_confirmation_title,
+ mState.label);
+ mUsageTracker.showResetConfirmation(title, new Runnable() {
+ @Override
+ public void run() {
+ refreshState();
+ }
+ });
}
@Override
@@ -87,7 +107,7 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> {
state.visible = enabled || mUsageTracker.isRecentlyUsed();
state.value = enabled;
state.label = mContext.getString(R.string.quick_settings_inversion_label);
- state.iconId = enabled ? R.drawable.ic_qs_inversion_on : R.drawable.ic_qs_inversion_off;
+ state.icon = enabled ? mEnable : mDisable;
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java
index e6b7f02..5c1a317 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java
@@ -31,6 +31,10 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements
* still available because it was recently on. */
private static final long RECENTLY_ON_DURATION_MILLIS = 500;
+ private final AnimationIcon mEnable
+ = new AnimationIcon(R.drawable.ic_signal_flashlight_enable_animation);
+ private final AnimationIcon mDisable
+ = new AnimationIcon(R.drawable.ic_signal_flashlight_disable_animation);
private final FlashlightController mFlashlightController;
private long mWasLastOn;
@@ -66,7 +70,7 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements
}
boolean newState = !mState.value;
mFlashlightController.setFlashlight(newState);
- refreshState(newState);
+ refreshState(newState ? UserBoolean.USER_TRUE : UserBoolean.USER_FALSE);
}
@Override
@@ -75,8 +79,8 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements
mWasLastOn = SystemClock.uptimeMillis();
}
- if (arg instanceof Boolean) {
- state.value = (Boolean) arg;
+ if (arg instanceof UserBoolean) {
+ state.value = ((UserBoolean) arg).value;
}
if (!state.value && mWasLastOn != 0) {
@@ -92,8 +96,9 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements
// the camera is not available while it is being used for the flashlight.
state.visible = mWasLastOn != 0 || mFlashlightController.isAvailable();
state.label = mHost.getContext().getString(R.string.quick_settings_flashlight_label);
- state.iconId = state.value
- ? R.drawable.ic_qs_flashlight_on : R.drawable.ic_qs_flashlight_off;
+ final AnimationIcon icon = state.value ? mEnable : mDisable;
+ icon.setAllowAnimation(arg instanceof UserBoolean && ((UserBoolean) arg).userInitiated);
+ state.icon = icon;
int onOrOffId = state.value
? R.string.accessibility_quick_settings_flashlight_on
: R.string.accessibility_quick_settings_flashlight_off;
@@ -111,12 +116,12 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements
@Override
public void onFlashlightOff() {
- refreshState(false);
+ refreshState(UserBoolean.BACKGROUND_FALSE);
}
@Override
public void onFlashlightError() {
- refreshState(false);
+ refreshState(UserBoolean.BACKGROUND_FALSE);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
index ce99cc3..374ceab 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
@@ -34,7 +34,7 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
public HotspotTile(Host host) {
super(host);
mController = host.getHotspotController();
- mUsageTracker = new UsageTracker(host.getContext(), HotspotTile.class);
+ mUsageTracker = newUsageTracker(host.getContext());
mUsageTracker.setListening(true);
}
@@ -65,14 +65,27 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
}
@Override
+ protected void handleLongClick() {
+ if (mState.value) return; // don't allow usage reset if hotspot is active
+ final String title = mContext.getString(R.string.quick_settings_reset_confirmation_title,
+ mState.label);
+ mUsageTracker.showResetConfirmation(title, new Runnable() {
+ @Override
+ public void run() {
+ refreshState();
+ }
+ });
+ }
+
+ @Override
protected void handleUpdateState(BooleanState state, Object arg) {
state.visible = mController.isHotspotSupported() && mUsageTracker.isRecentlyUsed()
&& !mController.isProvisioningNeeded();
state.label = mContext.getString(R.string.quick_settings_hotspot_label);
state.value = mController.isHotspotEnabled();
- state.iconId = state.visible && state.value ? R.drawable.ic_qs_hotspot_on
- : R.drawable.ic_qs_hotspot_off;
+ state.icon = ResourceIcon.get(state.visible && state.value ? R.drawable.ic_qs_hotspot_on
+ : R.drawable.ic_qs_hotspot_off);
}
@Override
@@ -84,6 +97,10 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
}
}
+ private static UsageTracker newUsageTracker(Context context) {
+ return new UsageTracker(context, HotspotTile.class, R.integer.days_to_show_hotspot_tile);
+ }
+
private final class Callback implements HotspotController.Callback {
@Override
public void onHotspotChanged(boolean enabled) {
@@ -101,7 +118,7 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
@Override
public void onReceive(Context context, Intent intent) {
if (mUsageTracker == null) {
- mUsageTracker = new UsageTracker(context, HotspotTile.class);
+ mUsageTracker = newUsageTracker(context);
}
mUsageTracker.trackUsage();
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java
index 58587e6..2736530 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java
@@ -31,11 +31,16 @@ import android.util.Log;
import com.android.systemui.qs.QSTile;
+import java.util.Arrays;
+import java.util.Objects;
+
public class IntentTile extends QSTile<QSTile.State> {
public static final String PREFIX = "intent(";
private PendingIntent mOnClick;
private String mOnClickUri;
+ private PendingIntent mOnLongClick;
+ private String mOnLongClickUri;
private int mCurrentUserId;
private IntentTile(Host host, String action) {
@@ -77,15 +82,24 @@ public class IntentTile extends QSTile<QSTile.State> {
@Override
protected void handleClick() {
+ sendIntent("click", mOnClick, mOnClickUri);
+ }
+
+ @Override
+ protected void handleLongClick() {
+ sendIntent("long-click", mOnLongClick, mOnLongClickUri);
+ }
+
+ private void sendIntent(String type, PendingIntent pi, String uri) {
try {
- if (mOnClick != null) {
- mOnClick.send();
- } else if (mOnClickUri != null) {
- final Intent intent = Intent.parseUri(mOnClickUri, Intent.URI_INTENT_SCHEME);
+ if (pi != null) {
+ pi.send();
+ } else if (uri != null) {
+ final Intent intent = Intent.parseUri(uri, Intent.URI_INTENT_SCHEME);
mContext.sendBroadcastAsUser(intent, new UserHandle(mCurrentUserId));
}
} catch (Throwable t) {
- Log.w(TAG, "Error sending click intent", t);
+ Log.w(TAG, "Error sending " + type + " intent", t);
}
}
@@ -96,13 +110,11 @@ public class IntentTile extends QSTile<QSTile.State> {
state.visible = intent.getBooleanExtra("visible", true);
state.contentDescription = intent.getStringExtra("contentDescription");
state.label = intent.getStringExtra("label");
- state.iconId = 0;
state.icon = null;
final byte[] iconBitmap = intent.getByteArrayExtra("iconBitmap");
if (iconBitmap != null) {
try {
- final Bitmap b = BitmapFactory.decodeByteArray(iconBitmap, 0, iconBitmap.length);
- state.icon = new BitmapDrawable(mContext.getResources(), b);
+ state.icon = new BytesIcon(iconBitmap);
} catch (Throwable t) {
Log.w(TAG, "Error loading icon bitmap, length " + iconBitmap.length, t);
}
@@ -111,23 +123,16 @@ public class IntentTile extends QSTile<QSTile.State> {
if (iconId != 0) {
final String iconPackage = intent.getStringExtra("iconPackage");
if (!TextUtils.isEmpty(iconPackage)) {
- state.icon = getPackageDrawable(iconPackage, iconId);
+ state.icon = new PackageDrawableIcon(iconPackage, iconId);
} else {
- state.iconId = iconId;
+ state.icon = ResourceIcon.get(iconId);
}
}
}
mOnClick = intent.getParcelableExtra("onClick");
mOnClickUri = intent.getStringExtra("onClickUri");
- }
-
- private Drawable getPackageDrawable(String pkg, int id) {
- try {
- return mContext.createPackageContext(pkg, 0).getDrawable(id);
- } catch (Throwable t) {
- Log.w(TAG, "Error loading package drawable pkg=" + pkg + " id=" + id, t);
- return null;
- }
+ mOnLongClick = intent.getParcelableExtra("onLongClick");
+ mOnLongClickUri = intent.getStringExtra("onLongClickUri");
}
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@@ -136,4 +141,60 @@ public class IntentTile extends QSTile<QSTile.State> {
refreshState(intent);
}
};
+
+ private static class BytesIcon extends Icon {
+ private final byte[] mBytes;
+
+ public BytesIcon(byte[] bytes) {
+ mBytes = bytes;
+ }
+
+ @Override
+ public Drawable getDrawable(Context context) {
+ final Bitmap b = BitmapFactory.decodeByteArray(mBytes, 0, mBytes.length);
+ return new BitmapDrawable(context.getResources(), b);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof BytesIcon && Arrays.equals(((BytesIcon) o).mBytes, mBytes);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("BytesIcon[len=%s]", mBytes.length);
+ }
+ }
+
+ private class PackageDrawableIcon extends Icon {
+ private final String mPackage;
+ private final int mResId;
+
+ public PackageDrawableIcon(String pkg, int resId) {
+ mPackage = pkg;
+ mResId = resId;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof PackageDrawableIcon)) return false;
+ final PackageDrawableIcon other = (PackageDrawableIcon) o;
+ return Objects.equals(other.mPackage, mPackage) && other.mResId == mResId;
+ }
+
+ @Override
+ public Drawable getDrawable(Context context) {
+ try {
+ return context.createPackageContext(mPackage, 0).getDrawable(mResId);
+ } catch (Throwable t) {
+ Log.w(TAG, "Error loading package drawable pkg=" + mPackage + " id=" + mResId, t);
+ return null;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return String.format("PackageDrawableIcon[pkg=%s,id=0x%08x]", mPackage, mResId);
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java
index d1dc5d2..11ec722 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java
@@ -25,6 +25,11 @@ import com.android.systemui.statusbar.policy.LocationController.LocationSettings
/** Quick settings tile: Location **/
public class LocationTile extends QSTile<QSTile.BooleanState> {
+ private final AnimationIcon mEnable =
+ new AnimationIcon(R.drawable.ic_signal_location_enable_animation);
+ private final AnimationIcon mDisable =
+ new AnimationIcon(R.drawable.ic_signal_location_disable_animation);
+
private final LocationController mController;
private final KeyguardMonitor mKeyguard;
private final Callback mCallback = new Callback();
@@ -55,6 +60,8 @@ public class LocationTile extends QSTile<QSTile.BooleanState> {
protected void handleClick() {
final boolean wasEnabled = (Boolean) mState.value;
mController.setLocationEnabled(!wasEnabled);
+ mEnable.setAllowAnimation(true);
+ mDisable.setAllowAnimation(true);
}
@Override
@@ -67,12 +74,12 @@ public class LocationTile extends QSTile<QSTile.BooleanState> {
state.visible = !mKeyguard.isShowing();
state.value = locationEnabled;
if (locationEnabled) {
- state.iconId = R.drawable.ic_qs_location_on;
+ state.icon = mEnable;
state.label = mContext.getString(R.string.quick_settings_location_label);
state.contentDescription = mContext.getString(
R.string.accessibility_quick_settings_location_on);
} else {
- state.iconId = R.drawable.ic_qs_location_off;
+ state.icon = mDisable;
state.label = mContext.getString(R.string.quick_settings_location_label);
state.contentDescription = mContext.getString(
R.string.accessibility_quick_settings_location_off);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
index ae40a4d..f46b9a6 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
@@ -17,7 +17,6 @@
package com.android.systemui.qs.tiles;
import android.content.res.Configuration;
-import android.content.res.Resources;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
@@ -26,6 +25,15 @@ import com.android.systemui.statusbar.policy.RotationLockController.RotationLock
/** Quick settings tile: Rotation **/
public class RotationLockTile extends QSTile<QSTile.BooleanState> {
+ private final AnimationIcon mPortraitToAuto
+ = new AnimationIcon(R.drawable.ic_portrait_to_auto_rotate_animation);
+ private final AnimationIcon mAutoToPortrait
+ = new AnimationIcon(R.drawable.ic_portrait_from_auto_rotate_animation);
+
+ private final AnimationIcon mLandscapeToAuto
+ = new AnimationIcon(R.drawable.ic_landscape_to_auto_rotate_animation);
+ private final AnimationIcon mAutoToLandscape
+ = new AnimationIcon(R.drawable.ic_landscape_from_auto_rotate_animation);
private final RotationLockController mController;
@@ -51,30 +59,34 @@ public class RotationLockTile extends QSTile<QSTile.BooleanState> {
@Override
protected void handleClick() {
if (mController == null) return;
- mController.setRotationLocked(!mState.value);
+ final boolean newState = !mState.value;
+ mController.setRotationLocked(newState);
+ refreshState(newState ? UserBoolean.USER_TRUE : UserBoolean.USER_FALSE);
}
@Override
protected void handleUpdateState(BooleanState state, Object arg) {
if (mController == null) return;
- final boolean rotationLocked = mController.isRotationLocked();
+ final boolean rotationLocked = arg != null ? ((UserBoolean) arg).value
+ : mController.isRotationLocked();
+ final boolean userInitiated = arg != null ? ((UserBoolean) arg).userInitiated : false;
state.visible = mController.isRotationLockAffordanceVisible();
- final Resources res = mContext.getResources();
state.value = rotationLocked;
+ final boolean portrait = mContext.getResources().getConfiguration().orientation
+ != Configuration.ORIENTATION_LANDSCAPE;
+ final AnimationIcon icon;
if (rotationLocked) {
- final boolean portrait = res.getConfiguration().orientation
- != Configuration.ORIENTATION_LANDSCAPE;
final int label = portrait ? R.string.quick_settings_rotation_locked_portrait_label
: R.string.quick_settings_rotation_locked_landscape_label;
- final int icon = portrait ? R.drawable.ic_qs_rotation_portrait
- : R.drawable.ic_qs_rotation_landscape;
state.label = mContext.getString(label);
- state.icon = mContext.getDrawable(icon);
+ icon = portrait ? mAutoToPortrait : mAutoToLandscape;
} else {
state.label = mContext.getString(R.string.quick_settings_rotation_unlocked_label);
- state.icon = res.getDrawable(R.drawable.ic_qs_rotation_unlocked);
+ icon = portrait ? mPortraitToAuto : mLandscapeToAuto;
}
- state.contentDescription = getAccessibilityString(
+ icon.setAllowAnimation(userInitiated);
+ state.icon = icon;
+ state.contentDescription = getAccessibilityString(rotationLocked,
R.string.accessibility_rotation_lock_on_portrait,
R.string.accessibility_rotation_lock_on_landscape,
R.string.accessibility_rotation_lock_off);
@@ -83,14 +95,16 @@ public class RotationLockTile extends QSTile<QSTile.BooleanState> {
/**
* Get the correct accessibility string based on the state
*
+ * @param locked Whether or not rotation is locked.
* @param idWhenPortrait The id which should be used when locked in portrait.
* @param idWhenLandscape The id which should be used when locked in landscape.
* @param idWhenOff The id which should be used when the rotation lock is off.
* @return
*/
- private String getAccessibilityString(int idWhenPortrait, int idWhenLandscape, int idWhenOff) {
+ private String getAccessibilityString(boolean locked, int idWhenPortrait, int idWhenLandscape,
+ int idWhenOff) {
int stringID;
- if (mState.value) {
+ if (locked) {
final boolean portrait = mContext.getResources().getConfiguration().orientation
!= Configuration.ORIENTATION_LANDSCAPE;
stringID = portrait ? idWhenPortrait: idWhenLandscape;
@@ -102,7 +116,7 @@ public class RotationLockTile extends QSTile<QSTile.BooleanState> {
@Override
protected String composeChangeAnnouncement() {
- return getAccessibilityString(
+ return getAccessibilityString(mState.value,
R.string.accessibility_rotation_lock_on_portrait_changed,
R.string.accessibility_rotation_lock_on_landscape_changed,
R.string.accessibility_rotation_lock_off_changed);
@@ -111,7 +125,8 @@ public class RotationLockTile extends QSTile<QSTile.BooleanState> {
private final RotationLockControllerCallback mCallback = new RotationLockControllerCallback() {
@Override
public void onRotationLockStateChanged(boolean rotationLocked, boolean affordanceVisible) {
- refreshState();
+ refreshState(rotationLocked ? UserBoolean.BACKGROUND_TRUE
+ : UserBoolean.BACKGROUND_FALSE);
}
};
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
index 0985812..7aa884e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
@@ -87,7 +87,15 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
@Override
protected void handleSecondaryClick() {
- mHost.startSettingsActivity(WIFI_SETTINGS);
+ if (!mController.canConfigWifi()) {
+ mHost.startSettingsActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
+ return;
+ }
+ if (!mState.enabled) {
+ mController.setWifiEnabled(true);
+ mState.enabled = true;
+ }
+ showDetail(true);
}
@Override
@@ -112,19 +120,19 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
final String signalContentDescription;
final Resources r = mContext.getResources();
if (!state.enabled) {
- state.iconId = R.drawable.ic_qs_wifi_disabled;
+ state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_disabled);
state.label = r.getString(R.string.quick_settings_wifi_label);
signalContentDescription = r.getString(R.string.accessibility_wifi_off);
} else if (wifiConnected) {
- state.iconId = cb.wifiSignalIconId;
+ state.icon = ResourceIcon.get(cb.wifiSignalIconId);
state.label = removeDoubleQuotes(cb.enabledDesc);
signalContentDescription = cb.wifiSignalContentDescription;
} else if (wifiNotConnected) {
- state.iconId = R.drawable.ic_qs_wifi_0;
+ state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_0);
state.label = r.getString(R.string.quick_settings_wifi_label);
signalContentDescription = r.getString(R.string.accessibility_no_wifi);
} else {
- state.iconId = R.drawable.ic_qs_wifi_no_network;
+ state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_no_network);
state.label = r.getString(R.string.quick_settings_wifi_label);
signalContentDescription = r.getString(R.string.accessibility_wifi_off);
}
@@ -279,7 +287,9 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
if (item == null || item.tag == null) return;
final AccessPoint ap = (AccessPoint) item.tag;
if (!ap.isConnected) {
- mController.connect(ap);
+ if (mController.connect(ap)) {
+ mHost.collapsePanels();
+ }
}
showDetail(false);
}
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
index 2a782cc..4c3460e 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
@@ -728,7 +728,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
final ActivityManager am = (ActivityManager)
getContext().getSystemService(Context.ACTIVITY_SERVICE);
if (am != null) {
- am.removeTask(ad.persistentTaskId, ActivityManager.REMOVE_TASK_KILL_PROCESS);
+ am.removeTask(ad.persistentTaskId);
// Accessibility feedback
setContentDescription(
diff --git a/packages/SystemUI/src/com/android/systemui/recent/ScreenPinningRequest.java b/packages/SystemUI/src/com/android/systemui/recent/ScreenPinningRequest.java
new file mode 100644
index 0000000..2fa0b58
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recent/ScreenPinningRequest.java
@@ -0,0 +1,283 @@
+/*
+ * Copyright (C) 2014 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.recent;
+
+import android.animation.ArgbEvaluator;
+import android.animation.ValueAnimator;
+import android.app.ActivityManager;
+import android.app.ActivityManagerNative;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.res.Configuration;
+import android.graphics.PixelFormat;
+import android.graphics.drawable.ColorDrawable;
+import android.os.RemoteException;
+import android.util.DisplayMetrics;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.view.accessibility.AccessibilityManager;
+import android.view.animation.DecelerateInterpolator;
+import android.widget.Button;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.android.systemui.R;
+import com.android.systemui.recents.model.RecentsTaskLoader;
+
+import java.util.ArrayList;
+
+public class ScreenPinningRequest implements View.OnClickListener {
+ private final Context mContext;
+
+ private final AccessibilityManager mAccessibilityService;
+ private final WindowManager mWindowManager;
+
+ private RequestWindowView mRequestWindow;
+
+ public ScreenPinningRequest(Context context) {
+ mContext = context;
+ mAccessibilityService = (AccessibilityManager)
+ mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
+ mWindowManager = (WindowManager)
+ mContext.getSystemService(Context.WINDOW_SERVICE);
+ }
+
+ public void clearPrompt() {
+ if (mRequestWindow != null) {
+ mWindowManager.removeView(mRequestWindow);
+ mRequestWindow = null;
+ }
+ }
+
+ public void showPrompt(boolean allowCancel) {
+ clearPrompt();
+
+ mRequestWindow = new RequestWindowView(mContext, allowCancel);
+
+ mRequestWindow.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+
+ // show the confirmation
+ WindowManager.LayoutParams lp = getWindowLayoutParams();
+ mWindowManager.addView(mRequestWindow, lp);
+ }
+
+ public void onConfigurationChanged() {
+ if (mRequestWindow != null) {
+ mRequestWindow.onConfigurationChanged();
+ }
+ }
+
+ private WindowManager.LayoutParams getWindowLayoutParams() {
+ final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL,
+ 0
+ | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
+ | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
+ ,
+ PixelFormat.TRANSLUCENT);
+ lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
+ lp.setTitle("ScreenPinningConfirmation");
+ lp.gravity = Gravity.FILL;
+ return lp;
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (v.getId() == R.id.screen_pinning_ok_button || mRequestWindow == v) {
+ try {
+ ActivityManagerNative.getDefault().startLockTaskModeOnCurrent();
+ } catch (RemoteException e) {}
+ }
+ clearPrompt();
+ }
+
+ public FrameLayout.LayoutParams getRequestLayoutParams(boolean isLandscape) {
+ return new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ isLandscape ? (Gravity.CENTER_VERTICAL | Gravity.RIGHT)
+ : (Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM));
+ }
+
+ private class RequestWindowView extends FrameLayout {
+ private static final int OFFSET_DP = 96;
+
+ private final ColorDrawable mColor = new ColorDrawable(0);
+ private ValueAnimator mColorAnim;
+ private ViewGroup mLayout;
+ private boolean mShowCancel;
+
+ public RequestWindowView(Context context, boolean showCancel) {
+ super(context);
+ setClickable(true);
+ setOnClickListener(ScreenPinningRequest.this);
+ setBackground(mColor);
+ mShowCancel = showCancel;
+ }
+
+ @Override
+ public void onAttachedToWindow() {
+ DisplayMetrics metrics = new DisplayMetrics();
+ mWindowManager.getDefaultDisplay().getMetrics(metrics);
+ float density = metrics.density;
+ boolean isLandscape = isLandscapePhone(mContext);
+
+ inflateView(isLandscape);
+ int bgColor = mContext.getResources().getColor(
+ R.color.screen_pinning_request_window_bg);
+ if (ActivityManager.isHighEndGfx()) {
+ mLayout.setAlpha(0f);
+ if (isLandscape) {
+ mLayout.setTranslationX(OFFSET_DP * density);
+ } else {
+ mLayout.setTranslationY(OFFSET_DP * density);
+ }
+ mLayout.animate()
+ .alpha(1f)
+ .translationX(0)
+ .translationY(0)
+ .setDuration(300)
+ .setInterpolator(new DecelerateInterpolator())
+ .start();
+
+ mColorAnim = ValueAnimator.ofObject(new ArgbEvaluator(), 0, bgColor);
+ mColorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ final int c = (Integer) animation.getAnimatedValue();
+ mColor.setColor(c);
+ }
+ });
+ mColorAnim.setDuration(1000);
+ mColorAnim.start();
+ } else {
+ mColor.setColor(bgColor);
+ }
+
+ IntentFilter filter = new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED);
+ filter.addAction(Intent.ACTION_USER_SWITCHED);
+ filter.addAction(Intent.ACTION_SCREEN_OFF);
+ mContext.registerReceiver(mReceiver, filter);
+ }
+
+ private boolean isLandscapePhone(Context context) {
+ Configuration config = mContext.getResources().getConfiguration();
+ return config.orientation == Configuration.ORIENTATION_LANDSCAPE
+ && config.smallestScreenWidthDp < 600;
+ }
+
+ private void inflateView(boolean isLandscape) {
+ // We only want this landscape orientation on <600dp, so rather than handle
+ // resource overlay for -land and -sw600dp-land, just inflate this
+ // other view for this single case.
+ mLayout = (ViewGroup) View.inflate(getContext(), isLandscape
+ ? R.layout.screen_pinning_request_land_phone : R.layout.screen_pinning_request,
+ null);
+ // Catch touches so they don't trigger cancel/activate, like outside does.
+ mLayout.setClickable(true);
+ // Status bar is always on the right.
+ mLayout.setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
+ // Buttons and text do switch sides though.
+ View buttons = mLayout.findViewById(R.id.screen_pinning_buttons);
+ buttons.setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);
+ mLayout.findViewById(R.id.screen_pinning_text_area)
+ .setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);
+ swapChildrenIfRtlAndVertical(buttons);
+
+ ((Button) mLayout.findViewById(R.id.screen_pinning_ok_button))
+ .setOnClickListener(ScreenPinningRequest.this);
+ if (mShowCancel) {
+ ((Button) mLayout.findViewById(R.id.screen_pinning_cancel_button))
+ .setOnClickListener(ScreenPinningRequest.this);
+ } else {
+ ((Button) mLayout.findViewById(R.id.screen_pinning_cancel_button))
+ .setVisibility(View.INVISIBLE);
+ }
+
+ final int description = mAccessibilityService.isEnabled()
+ ? R.string.screen_pinning_description_accessible
+ : R.string.screen_pinning_description;
+ ((TextView) mLayout.findViewById(R.id.screen_pinning_description))
+ .setText(description);
+ final int backBgVisibility =
+ mAccessibilityService.isEnabled() ? View.INVISIBLE : View.VISIBLE;
+ mLayout.findViewById(R.id.screen_pinning_back_bg).setVisibility(backBgVisibility);
+ mLayout.findViewById(R.id.screen_pinning_back_bg_light).setVisibility(backBgVisibility);
+
+ addView(mLayout, getRequestLayoutParams(isLandscape));
+ }
+
+ private void swapChildrenIfRtlAndVertical(View group) {
+ if (mContext.getResources().getConfiguration().getLayoutDirection()
+ != View.LAYOUT_DIRECTION_RTL) {
+ return;
+ }
+ LinearLayout linearLayout = (LinearLayout) group;
+ if (linearLayout.getOrientation() == LinearLayout.VERTICAL) {
+ int childCount = linearLayout.getChildCount();
+ ArrayList<View> childList = new ArrayList<>(childCount);
+ for (int i = 0; i < childCount; i++) {
+ childList.add(linearLayout.getChildAt(i));
+ }
+ linearLayout.removeAllViews();
+ for (int i = childCount - 1; i >= 0; i--) {
+ linearLayout.addView(childList.get(i));
+ }
+ }
+ }
+
+ @Override
+ public void onDetachedFromWindow() {
+ mContext.unregisterReceiver(mReceiver);
+ }
+
+ protected void onConfigurationChanged() {
+ removeAllViews();
+ inflateView(isLandscapePhone(mContext));
+ }
+
+ private final Runnable mUpdateLayoutRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if (mLayout != null && mLayout.getParent() != null) {
+ mLayout.setLayoutParams(getRequestLayoutParams(isLandscapePhone(mContext)));
+ }
+ }
+ };
+
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
+ post(mUpdateLayoutRunnable);
+ } else if (intent.getAction().equals(Intent.ACTION_USER_SWITCHED)
+ || intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
+ clearPrompt();
+ }
+ }
+ };
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
index 1283dcd..2bfdb69 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
@@ -36,6 +36,7 @@ import android.os.UserHandle;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
+
import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.recents.misc.Console;
@@ -59,10 +60,10 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
final public static String EXTRA_FROM_HOME = "recents.triggeredOverHome";
final public static String EXTRA_FROM_SEARCH_HOME = "recents.triggeredOverSearchHome";
final public static String EXTRA_FROM_APP_THUMBNAIL = "recents.animatingWithThumbnail";
- final public static String EXTRA_FROM_APP_FULL_SCREENSHOT = "recents.thumbnail";
final public static String EXTRA_FROM_TASK_ID = "recents.activeTaskId";
final public static String EXTRA_TRIGGERED_FROM_ALT_TAB = "recents.triggeredFromAltTab";
final public static String EXTRA_TRIGGERED_FROM_HOME_KEY = "recents.triggeredFromHomeKey";
+ final public static String EXTRA_REUSE_TASK_STACK_VIEWS = "recents.reuseTaskStackViews";
final public static String ACTION_START_ENTER_ANIMATION = "action_start_enter_animation";
final public static String ACTION_TOGGLE_RECENTS_ACTIVITY = "action_toggle_recents_activity";
@@ -74,7 +75,6 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
final static String sRecentsPackage = "com.android.systemui";
final static String sRecentsActivity = "com.android.systemui.recents.RecentsActivity";
- static Bitmap sLastScreenshot;
static RecentsComponent.Callbacks sRecentsComponentCallbacks;
Context mContext;
@@ -83,6 +83,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
Handler mHandler;
boolean mBootCompleted;
boolean mStartAnimationTriggered;
+ boolean mCanReuseTaskStackViews = true;
// Task launching
RecentsConfiguration mConfig;
@@ -132,6 +133,9 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
}
}
}
+
+ // When we start, preload the metadata associated with the previous tasks
+ RecentsTaskLoader.getInstance().preload(mContext, RecentsTaskLoader.ALL_TASKS);
}
public void onBootCompleted() {
@@ -179,7 +183,9 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
}
public void onPreloadRecents() {
- // Do nothing
+ // When we start, preload the metadata associated with the previous tasks
+ RecentsTaskLoader.getInstance().preload(mContext,
+ Constants.Values.RecentsTaskLoader.PreloadFirstTasksCount);
}
public void onCancelPreloadingRecents() {
@@ -189,7 +195,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
void showRelativeAffiliatedTask(boolean showNextTask) {
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
TaskStack stack = loader.getTaskStack(mSystemServicesProxy, mContext.getResources(),
- -1, -1, false, true, null, null);
+ -1, -1, RecentsTaskLoader.ALL_TASKS, false, true, null, null);
// Return early if there are no tasks
if (stack.getTaskCount() == 0) return;
@@ -202,6 +208,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
Task toTask = null;
ActivityOptions launchOpts = null;
int taskCount = tasks.size();
+ int numAffiliatedTasks = 0;
for (int i = 0; i < taskCount; i++) {
Task task = tasks.get(i);
if (task.key.id == runningTask.id) {
@@ -221,16 +228,23 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
if (toTaskKey != null) {
toTask = stack.findTaskWithId(toTaskKey.id);
}
+ numAffiliatedTasks = group.getTaskCount();
break;
}
}
// Return early if there is no next task
if (toTask == null) {
- if (showNextTask) {
- // XXX: Show the next-task bounce animation
- } else {
- // XXX: Show the prev-task bounce animation
+ if (numAffiliatedTasks > 1) {
+ if (showNextTask) {
+ mSystemServicesProxy.startInPlaceAnimationOnFrontMostApplication(
+ ActivityOptions.makeCustomInPlaceAnimation(mContext,
+ R.anim.recents_launch_next_affiliated_task_bounce));
+ } else {
+ mSystemServicesProxy.startInPlaceAnimationOnFrontMostApplication(
+ ActivityOptions.makeCustomInPlaceAnimation(mContext,
+ R.anim.recents_launch_prev_affiliated_task_bounce));
+ }
}
return;
}
@@ -254,9 +268,10 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
}
public void onConfigurationChanged(Configuration newConfig) {
+ // Don't reuse task stack views if the configuration changes
+ mCanReuseTaskStackViews = false;
// Reload the header bar layout
reloadHeaderBarLayout();
- sLastScreenshot = null;
}
/** Prepares the header bar layout. */
@@ -330,7 +345,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
// If the user has toggled it too quickly, then just eat up the event here (it's better than
// showing a janky screenshot).
// NOTE: Ideally, the screenshot mechanism would take the window transform into account
- if (System.currentTimeMillis() - mLastToggleTime < sMinToggleDelay) {
+ long currentTime = System.currentTimeMillis();
+ if ((currentTime > mLastToggleTime) && (currentTime - mLastToggleTime) < sMinToggleDelay) {
return;
}
@@ -370,7 +386,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
mStartAnimationTriggered = false;
return ActivityOptions.makeCustomAnimation(mContext,
R.anim.recents_from_unknown_enter,
- R.anim.recents_from_unknown_exit, mHandler, this);
+ R.anim.recents_from_unknown_exit,
+ mHandler, this);
}
/**
@@ -381,33 +398,20 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
if (fromSearchHome) {
return ActivityOptions.makeCustomAnimation(mContext,
R.anim.recents_from_search_launcher_enter,
- R.anim.recents_from_search_launcher_exit, mHandler, this);
+ R.anim.recents_from_search_launcher_exit,
+ mHandler, this);
}
return ActivityOptions.makeCustomAnimation(mContext,
R.anim.recents_from_launcher_enter,
- R.anim.recents_from_launcher_exit, mHandler, this);
+ R.anim.recents_from_launcher_exit,
+ mHandler, this);
}
/**
- * Creates the activity options for an app->recents transition. If this method sets the static
- * screenshot, then we will use that for the transition.
+ * Creates the activity options for an app->recents transition.
*/
ActivityOptions getThumbnailTransitionActivityOptions(ActivityManager.RunningTaskInfo topTask,
boolean isTopTaskHome) {
- if (Constants.DebugFlags.App.EnableScreenshotAppTransition) {
- // Recycle the last screenshot
- consumeLastScreenshot();
-
- // Take the full screenshot
- sLastScreenshot = mSystemServicesProxy.takeAppScreenshot();
- if (sLastScreenshot != null) {
- mStartAnimationTriggered = false;
- return ActivityOptions.makeCustomAnimation(mContext,
- R.anim.recents_from_app_enter,
- R.anim.recents_from_app_exit, mHandler, this);
- }
- }
-
// Update the destination rect
Task toTask = new Task();
TaskViewTransform toTransform = getThumbnailTransitionTransform(topTask.id, isTopTaskHome,
@@ -444,7 +448,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
// Get the stack of tasks that we are animating into
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
TaskStack stack = loader.getTaskStack(mSystemServicesProxy, mContext.getResources(),
- runningTaskId, -1, false, isTopTaskHome, null, null);
+ runningTaskId, -1, RecentsTaskLoader.ALL_TASKS, false, isTopTaskHome, null, null);
if (stack.getTaskCount() == 0) {
return null;
}
@@ -493,11 +497,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
// Try starting with a thumbnail transition
ActivityOptions opts = getThumbnailTransitionActivityOptions(topTask, isTopTaskHome);
if (opts != null) {
- if (sLastScreenshot != null) {
- startAlternateRecentsActivity(topTask, opts, EXTRA_FROM_APP_FULL_SCREENSHOT);
- } else {
- startAlternateRecentsActivity(topTask, opts, EXTRA_FROM_APP_THUMBNAIL);
- }
+ startAlternateRecentsActivity(topTask, opts, EXTRA_FROM_APP_THUMBNAIL);
} else {
// Fall through below to the non-thumbnail transition
useThumbnailTransition = false;
@@ -535,7 +535,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
} else {
// Otherwise we do the normal fade from an unknown source
ActivityOptions opts = getUnknownTransitionActivityOptions();
- startAlternateRecentsActivity(topTask, opts, null);
+ startAlternateRecentsActivity(topTask, opts, EXTRA_FROM_HOME);
}
}
mLastToggleTime = System.currentTimeMillis();
@@ -554,24 +554,13 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
}
intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, mTriggeredFromAltTab);
intent.putExtra(EXTRA_FROM_TASK_ID, (topTask != null) ? topTask.id : -1);
+ intent.putExtra(EXTRA_REUSE_TASK_STACK_VIEWS, mCanReuseTaskStackViews);
if (opts != null) {
mContext.startActivityAsUser(intent, opts.toBundle(), UserHandle.CURRENT);
} else {
mContext.startActivityAsUser(intent, UserHandle.CURRENT);
}
- }
-
- /** Returns the last screenshot taken, this will be called by the RecentsActivity. */
- public static Bitmap getLastScreenshot() {
- return sLastScreenshot;
- }
-
- /** Recycles the last screenshot taken, this will be called by the RecentsActivity. */
- public static void consumeLastScreenshot() {
- if (sLastScreenshot != null) {
- sLastScreenshot.recycle();
- sLastScreenshot = null;
- }
+ mCanReuseTaskStackViews = true;
}
/** Sets the RecentsComponent callbacks. */
@@ -610,7 +599,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
public void run() {
onAnimationStarted();
}
- }, 75);
+ }, 25);
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/recents/Constants.java b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
index 85cf077..9b84d2e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Constants.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
@@ -25,8 +25,6 @@ public class Constants {
public static final boolean Verbose = false;
public static class App {
- // Enables the screenshot app->Recents transition
- public static final boolean EnableScreenshotAppTransition = false;
// Enables debug drawing for the transition thumbnail
public static final boolean EnableTransitionThumbnailDebugMode = false;
// Enables the filtering of tasks according to their grouping
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index 01ba5a2..de95ae8 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -27,13 +27,17 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
+import android.content.res.Configuration;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
import android.os.UserHandle;
import android.util.Pair;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewStub;
import android.widget.Toast;
+
import com.android.systemui.R;
import com.android.systemui.recents.misc.DebugTrigger;
import com.android.systemui.recents.misc.ReferenceCountedTrigger;
@@ -47,6 +51,8 @@ import com.android.systemui.recents.views.DebugOverlayView;
import com.android.systemui.recents.views.RecentsView;
import com.android.systemui.recents.views.SystemBarScrimViews;
import com.android.systemui.recents.views.ViewAnimation;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
+import com.android.systemui.SystemUIApplication;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationTargetException;
@@ -79,6 +85,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
// Runnables to finish the Recents activity
FinishRecentsRunnable mFinishLaunchHomeRunnable;
+ private PhoneStatusBar mStatusBar;
+
/**
* A common Runnable to finish Recents either by calling finish() (with a custom animation) or
* launching Home with some ActivityOptions. Generally we always launch home when we exit
@@ -102,8 +110,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
@Override
public void run() {
// Mark Recents as no longer visible
- AlternateRecentsComponent.notifyVisibilityChanged(false);
- mVisible = false;
+ onRecentsActivityVisibilityChanged(false);
// Finish Recents
if (mLaunchIntent != null) {
if (mLaunchOpts != null) {
@@ -142,9 +149,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
// If we are toggling Recents, then first unfilter any filtered stacks first
dismissRecentsToFocusedTaskOrHome(true);
} else if (action.equals(AlternateRecentsComponent.ACTION_START_ENTER_ANIMATION)) {
- // Try and start the enter animation (or restart it on configuration changed)
- ReferenceCountedTrigger t = new ReferenceCountedTrigger(context, null, null, null);
- mRecentsView.startEnterRecentsAnimation(new ViewAnimation.TaskViewEnterContext(t));
+ // Trigger the enter animation
onEnterAnimationTriggered();
// Notify the fallback receiver that we have successfully got the broadcast
// See AlternateRecentsComponent.onAnimationStarted()
@@ -163,6 +168,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
if (action.equals(Intent.ACTION_SCREEN_OFF)) {
// When the screen turns off, dismiss Recents to Home
dismissRecentsToHome(false);
+ // Start preloading some tasks in the background
+ RecentsTaskLoader.getInstance().preload(RecentsActivity.this,
+ Constants.Values.RecentsTaskLoader.PreloadFirstTasksCount);
} else if (action.equals(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED)) {
// When the search activity changes, update the Search widget
refreshSearchWidget();
@@ -189,12 +197,12 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
AlternateRecentsComponent.EXTRA_FROM_HOME, false);
mConfig.launchedFromAppWithThumbnail = launchIntent.getBooleanExtra(
AlternateRecentsComponent.EXTRA_FROM_APP_THUMBNAIL, false);
- mConfig.launchedFromAppWithScreenshot = launchIntent.getBooleanExtra(
- AlternateRecentsComponent.EXTRA_FROM_APP_FULL_SCREENSHOT, false);
mConfig.launchedToTaskId = launchIntent.getIntExtra(
AlternateRecentsComponent.EXTRA_FROM_TASK_ID, -1);
mConfig.launchedWithAltTab = launchIntent.getBooleanExtra(
AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_ALT_TAB, false);
+ mConfig.launchedReuseTaskStackViews = launchIntent.getBooleanExtra(
+ AlternateRecentsComponent.EXTRA_REUSE_TASK_STACK_VIEWS, false);
// Load all the tasks
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
@@ -404,8 +412,12 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
// Update if we are getting a configuration change
if (savedInstanceState != null) {
+ // Update RecentsConfiguration
+ mConfig = RecentsConfiguration.reinitialize(this,
+ RecentsTaskLoader.getInstance().getSystemServicesProxy());
mConfig.updateOnConfigurationChange();
- onConfigurationChange();
+ // Trigger the enter animation
+ onEnterAnimationTriggered();
}
// Start listening for widget package changes if there is one bound, post it since we don't
@@ -423,6 +435,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
}
});
}
+
+ mStatusBar = ((SystemUIApplication) getApplication())
+ .getComponent(PhoneStatusBar.class);
}
/** Inflates the debug overlay if debug mode is enabled. */
@@ -435,15 +450,12 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
}
}
- void onConfigurationChange() {
- // Update RecentsConfiguration
- mConfig = RecentsConfiguration.reinitialize(this,
- RecentsTaskLoader.getInstance().getSystemServicesProxy());
-
- // Try and start the enter animation (or restart it on configuration changed)
- ReferenceCountedTrigger t = new ReferenceCountedTrigger(this, null, null, null);
- mRecentsView.startEnterRecentsAnimation(new ViewAnimation.TaskViewEnterContext(t));
- onEnterAnimationTriggered();
+ /** Handles changes to the activity visibility. */
+ void onRecentsActivityVisibilityChanged(boolean visible) {
+ if (!visible) {
+ AlternateRecentsComponent.notifyVisibilityChanged(visible);
+ }
+ mVisible = visible;
}
@Override
@@ -483,15 +495,15 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
super.onResume();
// Mark Recents as visible
- mVisible = true;
+ onRecentsActivityVisibilityChanged(true);
}
@Override
protected void onStop() {
super.onStop();
- // Remove all the views
- mRecentsView.removeAllTaskStacks();
+ // Notify the views that we are no longer visible
+ mRecentsView.onRecentsHidden();
// Unregister the RecentsService receiver
unregisterReceiver(mServiceBroadcastReceiver);
@@ -513,6 +525,15 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
}
}
+ public void onEnterAnimationTriggered() {
+ // Try and start the enter animation (or restart it on configuration changed)
+ ReferenceCountedTrigger t = new ReferenceCountedTrigger(this, null, null, null);
+ mRecentsView.startEnterRecentsAnimation(new ViewAnimation.TaskViewEnterContext(t));
+
+ // Animate the SystemUI scrim views
+ mScrimViews.startEnterRecentsAnimation();
+ }
+
@Override
public void onTrimMemory(int level) {
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
@@ -572,7 +593,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
/** Called when debug mode is triggered */
public void onDebugModeTriggered() {
-
if (mConfig.developerOptionsEnabled) {
SharedPreferences settings = getSharedPreferences(getPackageName(), 0);
if (settings.getBoolean(Constants.Values.App.Key_DebugModeEnabled, false)) {
@@ -594,12 +614,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
}
}
- /** Called when the enter recents animation is triggered. */
- public void onEnterAnimationTriggered() {
- // Animate the SystemUI scrim views
- mScrimViews.startEnterRecentsAnimation();
- }
-
/**** RecentsView.RecentsViewCallbacks Implementation ****/
@Override
@@ -611,8 +625,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
@Override
public void onTaskViewClicked() {
// Mark recents as no longer visible
- AlternateRecentsComponent.notifyVisibilityChanged(false);
- mVisible = false;
+ onRecentsActivityVisibilityChanged(false);
}
@Override
@@ -626,6 +639,13 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
mFinishLaunchHomeRunnable.run();
}
+ @Override
+ public void onScreenPinningRequest() {
+ if (mStatusBar != null) {
+ mStatusBar.showScreenPinningRequest(false);
+ }
+ }
+
/**** RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks Implementation ****/
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
index 2aca576..e0c76b1 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
@@ -115,8 +115,8 @@ public class RecentsConfiguration {
public boolean launchedWithAltTab;
public boolean launchedWithNoRecentTasks;
public boolean launchedFromAppWithThumbnail;
- public boolean launchedFromAppWithScreenshot;
public boolean launchedFromHome;
+ public boolean launchedReuseTaskStackViews;
public int launchedToTaskId;
/** Misc **/
@@ -307,8 +307,8 @@ public class RecentsConfiguration {
launchedWithAltTab = false;
launchedWithNoRecentTasks = false;
launchedFromAppWithThumbnail = false;
- launchedFromAppWithScreenshot = false;
launchedFromHome = false;
+ launchedReuseTaskStackViews = false;
launchedToTaskId = -1;
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/DozeTrigger.java b/packages/SystemUI/src/com/android/systemui/recents/misc/DozeTrigger.java
index 4456066..735f79f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/DozeTrigger.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/DozeTrigger.java
@@ -82,4 +82,9 @@ public class DozeTrigger {
public boolean hasTriggered() {
return mHasTriggered;
}
+
+ /** Resets the doze trigger state. */
+ public void resetTrigger() {
+ mHasTriggered = false;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
index 71a3ef1..51b3fb5 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
@@ -48,12 +48,14 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Log;
import android.util.Pair;
import android.view.Display;
import android.view.DisplayInfo;
+import android.view.IWindowManager;
import android.view.SurfaceControl;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityManager;
@@ -291,18 +293,18 @@ public class SystemServicesProxy {
}
}
- /** Removes the task and kills the process */
- public void removeTask(int taskId, boolean isDocument) {
+ /** Removes the task */
+ public void removeTask(int taskId) {
if (mAm == null) return;
if (Constants.DebugFlags.App.EnableSystemServicesProxy) return;
- // Remove the task, and only kill the process if it is not a document
- mAm.removeTask(taskId, isDocument ? 0 : ActivityManager.REMOVE_TASK_KILL_PROCESS);
+ // Remove the task.
+ mAm.removeTask(taskId);
}
/**
* Returns the activity info for a given component name.
- *
+ *
* @param cn The component name of the activity.
* @param userId The userId of the user that this is for.
*/
@@ -429,6 +431,7 @@ public class SystemServicesProxy {
opts.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY,
AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX);
if (!mAwm.bindAppWidgetIdIfAllowed(searchWidgetId, searchWidgetInfo.provider, opts)) {
+ host.deleteAppWidgetId(searchWidgetId);
return null;
}
return new Pair<Integer, AppWidgetProviderInfo>(searchWidgetId, searchWidgetInfo);
@@ -492,17 +495,6 @@ public class SystemServicesProxy {
}
/**
- * Locks the current task.
- */
- public void lockCurrentTask() {
- if (mIam == null) return;
-
- try {
- mIam.startLockTaskModeOnCurrent();
- } catch (RemoteException e) {}
- }
-
- /**
* Takes a screenshot of the current surface.
*/
public Bitmap takeScreenshot() {
@@ -532,4 +524,15 @@ public class SystemServicesProxy {
}
return false;
}
+
+ /** Starts an in-place animation on the front most application windows. */
+ public void startInPlaceAnimationOnFrontMostApplication(ActivityOptions opts) {
+ if (mIam == null) return;
+
+ try {
+ mIam.startInPlaceAnimationOnFrontMostApplication(opts);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java b/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
index f01d17c..e1179fa 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
@@ -16,7 +16,7 @@
package com.android.systemui.recents.misc;
-import android.content.Intent;
+import android.animation.Animator;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Rect;
@@ -183,9 +183,14 @@ public class Utilities {
sPropertyMethod.invoke(null, property, value);
}
- /** Returns whether the specified intent is a document. */
- public static boolean isDocument(Intent intent) {
- int flags = intent.getFlags();
- return (flags & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) == Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
+ /**
+ * Cancels an animation ensuring that if it has listeners, onCancel and onEnd
+ * are not called.
+ */
+ public static void cancelAnimationWithoutCallbacks(Animator animator) {
+ if (animator != null) {
+ animator.removeAllListeners();
+ animator.cancel();
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/KeyStoreLruCache.java b/packages/SystemUI/src/com/android/systemui/recents/model/KeyStoreLruCache.java
index 7ccefc6..97e0916 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/KeyStoreLruCache.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/KeyStoreLruCache.java
@@ -21,15 +21,16 @@ import android.util.LruCache;
import java.util.HashMap;
/**
- * An LRU cache that support querying the keys as well as values. By using the Task's key, we can
- * prevent holding onto a reference to the Task resource data, while keeping the cache data in
- * memory where necessary.
+ * An LRU cache that internally support querying the keys as well as values. We use this to keep
+ * track of the task metadata to determine when to invalidate the cache when tasks have been
+ * updated. Generally, this cache will return the last known cache value for the requested task
+ * key.
*/
public class KeyStoreLruCache<V> {
// We keep a set of keys that are associated with the LRU cache, so that we can find out
// information about the Task that was previously in the cache.
HashMap<Integer, Task.TaskKey> mTaskKeys = new HashMap<Integer, Task.TaskKey>();
- // The cache implementation
+ // The cache implementation, mapping task id -> value
LruCache<Integer, V> mCache;
public KeyStoreLruCache(int cacheSize) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsPackageMonitor.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsPackageMonitor.java
index 60e89bf..e48e5f0 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsPackageMonitor.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsPackageMonitor.java
@@ -19,6 +19,7 @@ package com.android.systemui.recents.model;
import android.content.ComponentName;
import android.content.Context;
import android.os.Looper;
+import android.os.UserHandle;
import com.android.internal.content.PackageMonitor;
import com.android.systemui.recents.misc.SystemServicesProxy;
@@ -26,16 +27,16 @@ import java.util.HashSet;
import java.util.List;
/**
- * The package monitor listens for changes from PackageManager to update the contents of the Recents
- * list.
+ * The package monitor listens for changes from PackageManager to update the contents of the
+ * Recents list.
*/
public class RecentsPackageMonitor extends PackageMonitor {
public interface PackageCallbacks {
- public void onComponentRemoved(HashSet<ComponentName> cns);
+ public void onPackagesChanged(RecentsPackageMonitor monitor, String packageName,
+ int userId);
}
PackageCallbacks mCb;
- List<Task.TaskKey> mTasks;
SystemServicesProxy mSystemServicesProxy;
/** Registers the broadcast receivers with the specified callbacks. */
@@ -43,7 +44,9 @@ public class RecentsPackageMonitor extends PackageMonitor {
mSystemServicesProxy = new SystemServicesProxy(context);
mCb = cb;
try {
- register(context, Looper.getMainLooper(), true);
+ // We register for events from all users, but will cross-reference them with
+ // packages for the current user and any profiles they have
+ register(context, Looper.getMainLooper(), UserHandle.ALL, true);
} catch (IllegalStateException e) {
e.printStackTrace();
}
@@ -59,29 +62,15 @@ public class RecentsPackageMonitor extends PackageMonitor {
}
mSystemServicesProxy = null;
mCb = null;
- mTasks.clear();
- }
-
- /** Sets the list of tasks to match against package broadcast changes. */
- void setTasks(List<Task.TaskKey> tasks) {
- mTasks = tasks;
}
@Override
public void onPackageRemoved(String packageName, int uid) {
if (mCb == null) return;
- // Identify all the tasks that should be removed as a result of the package being removed.
- // Using a set to ensure that we callback once per unique component.
- HashSet<ComponentName> componentsToRemove = new HashSet<ComponentName>();
- for (Task.TaskKey t : mTasks) {
- ComponentName cn = t.baseIntent.getComponent();
- if (cn.getPackageName().equals(packageName)) {
- componentsToRemove.add(cn);
- }
- }
- // Notify our callbacks that the components no longer exist
- mCb.onComponentRemoved(componentsToRemove);
+ // Notify callbacks that a package has changed
+ final int eventUserId = getChangingUserId();
+ mCb.onPackagesChanged(this, packageName, eventUserId);
}
@Override
@@ -94,25 +83,38 @@ public class RecentsPackageMonitor extends PackageMonitor {
public void onPackageModified(String packageName) {
if (mCb == null) return;
+ // Notify callbacks that a package has changed
+ final int eventUserId = getChangingUserId();
+ mCb.onPackagesChanged(this, packageName, eventUserId);
+ }
+
+ /**
+ * Computes the components that have been removed as a result of a change in the specified
+ * package.
+ */
+ public HashSet<ComponentName> computeComponentsRemoved(List<Task.TaskKey> taskKeys,
+ String packageName, int userId) {
// Identify all the tasks that should be removed as a result of the package being removed.
// Using a set to ensure that we callback once per unique component.
- HashSet<ComponentName> componentsKnownToExist = new HashSet<ComponentName>();
- HashSet<ComponentName> componentsToRemove = new HashSet<ComponentName>();
- for (Task.TaskKey t : mTasks) {
+ HashSet<ComponentName> existingComponents = new HashSet<ComponentName>();
+ HashSet<ComponentName> removedComponents = new HashSet<ComponentName>();
+ for (Task.TaskKey t : taskKeys) {
+ // Skip if this doesn't apply to the current user
+ if (t.userId != userId) continue;
+
ComponentName cn = t.baseIntent.getComponent();
if (cn.getPackageName().equals(packageName)) {
- if (componentsKnownToExist.contains(cn)) {
+ if (existingComponents.contains(cn)) {
// If we know that the component still exists in the package, then skip
continue;
}
- if (mSystemServicesProxy.getActivityInfo(cn) != null) {
- componentsKnownToExist.add(cn);
+ if (mSystemServicesProxy.getActivityInfo(cn, userId) != null) {
+ existingComponents.add(cn);
} else {
- componentsToRemove.add(cn);
+ removedComponents.add(cn);
}
}
}
- // Notify our callbacks that the components no longer exist
- mCb.onComponentRemoved(componentsToRemove);
+ return removedComponents;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java
index d40e847..390507f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java
@@ -171,6 +171,9 @@ class TaskResourceLoader implements Runnable {
}
} else {
SystemServicesProxy ssp = mSystemServicesProxy;
+ // If we've stopped the loader, then fall thorugh to the above logic to wait on
+ // the load thread
+ if (ssp == null) continue;
// Load the next item from the queue
final Task t = mLoadQueue.nextTask();
@@ -257,6 +260,7 @@ public class RecentsTaskLoader {
private static final String TAG = "RecentsTaskLoader";
static RecentsTaskLoader sInstance;
+ public static final int ALL_TASKS = -1;
SystemServicesProxy mSystemServicesProxy;
DrawableLruCache mApplicationIconCache;
@@ -323,10 +327,9 @@ public class RecentsTaskLoader {
/** Gets the list of recent tasks, ordered from back to front. */
private static List<ActivityManager.RecentTaskInfo> getRecentTasks(SystemServicesProxy ssp,
- boolean isTopTaskHome) {
- RecentsConfiguration config = RecentsConfiguration.getInstance();
+ int numTasksToLoad, boolean isTopTaskHome) {
List<ActivityManager.RecentTaskInfo> tasks =
- ssp.getRecentTasks(config.maxNumTasksToLoad, UserHandle.CURRENT.getIdentifier(),
+ ssp.getRecentTasks(numTasksToLoad, UserHandle.CURRENT.getIdentifier(),
isTopTaskHome);
Collections.reverse(tasks);
return tasks;
@@ -413,27 +416,38 @@ public class RecentsTaskLoader {
ArrayList<Task.TaskKey> taskKeys = new ArrayList<Task.TaskKey>();
ArrayList<Task> tasksToLoad = new ArrayList<Task>();
TaskStack stack = getTaskStack(mSystemServicesProxy, context.getResources(),
- -1, preloadCount, true, isTopTaskHome, taskKeys, tasksToLoad);
+ -1, preloadCount, RecentsTaskLoader.ALL_TASKS, true, isTopTaskHome, taskKeys,
+ tasksToLoad);
SpaceNode root = new SpaceNode();
root.setStack(stack);
// Start the task loader and add all the tasks we need to load
- mLoader.start(context);
mLoadQueue.addTasks(tasksToLoad);
-
- // Update the package monitor with the list of packages to listen for
- mPackageMonitor.setTasks(taskKeys);
+ mLoader.start(context);
return root;
}
+ /** Preloads the set of recent tasks (not including thumbnails). */
+ public void preload(Context context, int numTasksToPreload) {
+ ArrayList<Task> tasksToLoad = new ArrayList<Task>();
+ getTaskStack(mSystemServicesProxy, context.getResources(),
+ -1, -1, numTasksToPreload, true, true, null, tasksToLoad);
+
+ // Start the task loader and add all the tasks we need to load
+ mLoadQueue.addTasks(tasksToLoad);
+ mLoader.start(context);
+ }
+
/** Creates a lightweight stack of the current recent tasks, without thumbnails and icons. */
- public TaskStack getTaskStack(SystemServicesProxy ssp, Resources res,
- int preloadTaskId, int preloadTaskCount,
+ public synchronized TaskStack getTaskStack(SystemServicesProxy ssp, Resources res,
+ int preloadTaskId, int preloadTaskCount, int loadTaskCount,
boolean loadTaskThumbnails, boolean isTopTaskHome,
List<Task.TaskKey> taskKeysOut, List<Task> tasksToLoadOut) {
RecentsConfiguration config = RecentsConfiguration.getInstance();
- List<ActivityManager.RecentTaskInfo> tasks = getRecentTasks(ssp, isTopTaskHome);
+ List<ActivityManager.RecentTaskInfo> tasks = getRecentTasks(ssp,
+ (loadTaskCount == ALL_TASKS ? config.maxNumTasksToLoad : loadTaskCount),
+ isTopTaskHome);
HashMap<Task.ComponentNameKey, ActivityInfoHandle> activityInfoCache =
new HashMap<Task.ComponentNameKey, ActivityInfoHandle>();
ArrayList<Task> tasksToAdd = new ArrayList<Task>();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
index a7e2b0b..55dfe45 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
@@ -129,7 +129,7 @@ public class Task {
TaskCallbacks mCb;
public Task() {
- // Only used by RecentsService for task rect calculations.
+ // Do nothing
}
public Task(TaskKey key, boolean isActive, int taskAffiliation, int taskAffiliationColor,
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
index 1e47b50..a37b9e6 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
@@ -255,6 +255,17 @@ public class TaskStack {
return mTaskList.getTasks().get(mTaskList.size() - 1);
}
+ /** Gets the task keys */
+ public ArrayList<Task.TaskKey> getTaskKeys() {
+ ArrayList<Task.TaskKey> taskKeys = new ArrayList<Task.TaskKey>();
+ ArrayList<Task> tasks = mTaskList.getTasks();
+ int taskCount = tasks.size();
+ for (int i = 0; i < taskCount; i++) {
+ taskKeys.add(tasks.get(i).key);
+ }
+ return taskKeys;
+ }
+
/** Gets the tasks */
public ArrayList<Task> getTasks() {
return mTaskList.getTasks();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java b/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java
index d2fdaff..5f8f3f2 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java
@@ -17,12 +17,10 @@
package com.android.systemui.recents.views;
import android.animation.ObjectAnimator;
-import android.animation.ValueAnimator;
import android.graphics.Outline;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewOutlineProvider;
-
import com.android.systemui.recents.RecentsConfiguration;
/* An outline provider that has a clip and outline that can be animated. */
@@ -31,35 +29,27 @@ public class AnimateableViewBounds extends ViewOutlineProvider {
RecentsConfiguration mConfig;
TaskView mSourceView;
- Rect mTmpRect = new Rect();
Rect mClipRect = new Rect();
Rect mClipBounds = new Rect();
- Rect mOutlineClipRect = new Rect();
int mCornerRadius;
float mAlpha = 1f;
final float mMinAlpha = 0.25f;
- ObjectAnimator mClipTopAnimator;
- ObjectAnimator mClipRightAnimator;
ObjectAnimator mClipBottomAnimator;
public AnimateableViewBounds(TaskView source, int cornerRadius) {
mConfig = RecentsConfiguration.getInstance();
mSourceView = source;
mCornerRadius = cornerRadius;
- setClipTop(getClipTop());
- setClipRight(getClipRight());
setClipBottom(getClipBottom());
- setOutlineClipBottom(getOutlineClipBottom());
}
@Override
public void getOutline(View view, Outline outline) {
outline.setAlpha(mMinAlpha + mAlpha / (1f - mMinAlpha));
- outline.setRoundRect(Math.max(mClipRect.left, mOutlineClipRect.left),
- Math.max(mClipRect.top, mOutlineClipRect.top),
- mSourceView.getWidth() - Math.max(mClipRect.right, mOutlineClipRect.right),
- mSourceView.getHeight() - Math.max(mClipRect.bottom, mOutlineClipRect.bottom),
+ outline.setRoundRect(mClipRect.left, mClipRect.top,
+ mSourceView.getWidth() - mClipRect.right,
+ mSourceView.getHeight() - mClipRect.bottom,
mCornerRadius);
}
@@ -71,73 +61,6 @@ public class AnimateableViewBounds extends ViewOutlineProvider {
}
}
- /** Animates the top clip. */
- void animateClipTop(int top, int duration, ValueAnimator.AnimatorUpdateListener updateListener) {
- if (mClipTopAnimator != null) {
- mClipTopAnimator.removeAllListeners();
- mClipTopAnimator.cancel();
- }
- mClipTopAnimator = ObjectAnimator.ofInt(this, "clipTop", top);
- mClipTopAnimator.setDuration(duration);
- mClipTopAnimator.setInterpolator(mConfig.fastOutSlowInInterpolator);
- if (updateListener != null) {
- mClipTopAnimator.addUpdateListener(updateListener);
- }
- mClipTopAnimator.start();
- }
-
- /** Sets the top clip. */
- public void setClipTop(int top) {
- if (top != mClipRect.top) {
- mClipRect.top = top;
- mSourceView.invalidateOutline();
- updateClipBounds();
- }
- }
-
- /** Returns the top clip. */
- public int getClipTop() {
- return mClipRect.top;
- }
-
- /** Animates the right clip. */
- void animateClipRight(int right, int duration) {
- if (mClipRightAnimator != null) {
- mClipRightAnimator.removeAllListeners();
- mClipRightAnimator.cancel();
- }
- mClipRightAnimator = ObjectAnimator.ofInt(this, "clipRight", right);
- mClipRightAnimator.setDuration(duration);
- mClipRightAnimator.setInterpolator(mConfig.fastOutSlowInInterpolator);
- mClipRightAnimator.start();
- }
-
- /** Sets the right clip. */
- public void setClipRight(int right) {
- if (right != mClipRect.right) {
- mClipRect.right = right;
- mSourceView.invalidateOutline();
- updateClipBounds();
- }
- }
-
- /** Returns the right clip. */
- public int getClipRight() {
- return mClipRect.right;
- }
-
- /** Animates the bottom clip. */
- void animateClipBottom(int bottom, int duration) {
- if (mClipBottomAnimator != null) {
- mClipBottomAnimator.removeAllListeners();
- mClipBottomAnimator.cancel();
- }
- mClipBottomAnimator = ObjectAnimator.ofInt(this, "clipBottom", bottom);
- mClipBottomAnimator.setDuration(duration);
- mClipBottomAnimator.setInterpolator(mConfig.fastOutSlowInInterpolator);
- mClipBottomAnimator.start();
- }
-
/** Sets the bottom clip. */
public void setClipBottom(int bottom) {
if (bottom != mClipRect.bottom) {
@@ -145,7 +68,7 @@ public class AnimateableViewBounds extends ViewOutlineProvider {
mSourceView.invalidateOutline();
updateClipBounds();
if (!mConfig.useHardwareLayers) {
- mSourceView.mThumbnailView.updateVisibility(
+ mSourceView.mThumbnailView.updateThumbnailVisibility(
bottom - mSourceView.getPaddingBottom());
}
}
@@ -156,19 +79,6 @@ public class AnimateableViewBounds extends ViewOutlineProvider {
return mClipRect.bottom;
}
- /** Sets the outline bottom clip. */
- public void setOutlineClipBottom(int bottom) {
- if (bottom != mOutlineClipRect.bottom) {
- mOutlineClipRect.bottom = bottom;
- mSourceView.invalidateOutline();
- }
- }
-
- /** Gets the outline bottom clip. */
- public int getOutlineClipBottom() {
- return mOutlineClipRect.bottom;
- }
-
private void updateClipBounds() {
mClipBounds.set(mClipRect.left, mClipRect.top,
mSourceView.getWidth() - mClipRect.right,
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index 6c22a3b..6093584 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -18,8 +18,6 @@ package com.android.systemui.recents.views;
import android.app.ActivityOptions;
import android.app.TaskStackBuilder;
-import android.content.ActivityNotFoundException;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
@@ -33,18 +31,16 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowInsets;
import android.widget.FrameLayout;
+
import com.android.systemui.recents.Constants;
import com.android.systemui.recents.RecentsConfiguration;
-import com.android.systemui.recents.misc.Console;
import com.android.systemui.recents.misc.SystemServicesProxy;
-import com.android.systemui.recents.misc.Utilities;
import com.android.systemui.recents.model.RecentsPackageMonitor;
import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
import java.util.ArrayList;
-import java.util.HashSet;
/**
* This view is the the top level layout that contains TaskStacks (which are laid out according
@@ -59,6 +55,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
public void onTaskLaunchFailed();
public void onAllTaskViewsDismissed();
public void onExitToHomeAnimationTriggered();
+ public void onScreenPinningRequest();
}
RecentsConfiguration mConfig;
@@ -100,42 +97,57 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
/** Set/get the bsp root node */
public void setTaskStacks(ArrayList<TaskStack> stacks) {
- // Remove all TaskStackViews (but leave the search bar)
+ int numStacks = stacks.size();
+
+ // Make a list of the stack view children only
+ ArrayList<TaskStackView> stackViews = new ArrayList<TaskStackView>();
int childCount = getChildCount();
- for (int i = childCount - 1; i >= 0; i--) {
- View v = getChildAt(i);
- if (v != mSearchBar) {
- removeViewAt(i);
+ for (int i = 0; i < childCount; i++) {
+ View child = getChildAt(i);
+ if (child != mSearchBar) {
+ stackViews.add((TaskStackView) child);
}
}
- // Create and add all the stacks for this partition of space.
+ // Remove all/extra stack views
+ int numTaskStacksToKeep = 0; // Keep no tasks if we are recreating the layout
+ if (mConfig.launchedReuseTaskStackViews) {
+ numTaskStacksToKeep = Math.min(childCount, numStacks);
+ }
+ for (int i = stackViews.size() - 1; i >= numTaskStacksToKeep; i--) {
+ removeView(stackViews.get(i));
+ stackViews.remove(i);
+ }
+
+ // Update the stack views that we are keeping
+ for (int i = 0; i < numTaskStacksToKeep; i++) {
+ stackViews.get(i).setStack(stacks.get(i));
+ }
+
+ // Add remaining/recreate stack views
mStacks = stacks;
- int numStacks = mStacks.size();
- for (int i = 0; i < numStacks; i++) {
- TaskStack stack = mStacks.get(i);
+ for (int i = stackViews.size(); i < numStacks; i++) {
+ TaskStack stack = stacks.get(i);
TaskStackView stackView = new TaskStackView(getContext(), stack);
stackView.setCallbacks(this);
- // Enable debug mode drawing
- if (mConfig.debugModeEnabled) {
- stackView.setDebugOverlay(mDebugOverlay);
- }
addView(stackView);
}
- // Reset the launched state
- mAlreadyLaunchingTask = false;
- }
-
- /** Removes all the task stack views from this recents view. */
- public void removeAllTaskStacks() {
- int childCount = getChildCount();
- for (int i = childCount - 1; i >= 0; i--) {
- View child = getChildAt(i);
- if (child != mSearchBar) {
- removeViewAt(i);
+ // Enable debug mode drawing on all the stacks if necessary
+ if (mConfig.debugModeEnabled) {
+ for (int i = childCount - 1; i >= 0; i--) {
+ View v = getChildAt(i);
+ if (v != mSearchBar) {
+ TaskStackView stackView = (TaskStackView) v;
+ stackView.setDebugOverlay(mDebugOverlay);
+ }
}
}
+
+ // Reset the launched state
+ mAlreadyLaunchingTask = false;
+ // Trigger a new layout
+ requestLayout();
}
/** Launches the focused task from the first stack if possible */
@@ -339,7 +351,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
View child = getChildAt(i);
if (child != mSearchBar) {
TaskStackView stackView = (TaskStackView) child;
- stackView.focusNextTask(forward);
+ stackView.focusNextTask(forward, true);
break;
}
}
@@ -451,7 +463,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
postDelayed(new Runnable() {
@Override
public void run() {
- ssp.lockCurrentTask();
+ mCb.onScreenPinningRequest();
}
}, 350);
mTriggered = true;
@@ -475,7 +487,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
if (ssp.startActivityFromRecents(getContext(), task.key.id,
task.activityLabel, launchOpts)) {
if (launchOpts == null && lockToTask) {
- ssp.lockCurrentTask();
+ mCb.onScreenPinningRequest();
}
} else {
// Dismiss the task and return the user to home if we fail to
@@ -526,8 +538,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
loader.deleteTaskData(t, false);
// Remove the old task from activity manager
- RecentsTaskLoader.getInstance().getSystemServicesProxy().removeTask(t.key.id,
- Utilities.isDocument(t.key.baseIntent));
+ RecentsTaskLoader.getInstance().getSystemServicesProxy().removeTask(t.key.id);
}
@Override
@@ -535,6 +546,19 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
mCb.onAllTaskViewsDismissed();
}
+ /** Final callback after Recents is finally hidden. */
+ public void onRecentsHidden() {
+ // Notify each task stack view
+ int childCount = getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ View child = getChildAt(i);
+ if (child != mSearchBar) {
+ TaskStackView stackView = (TaskStackView) child;
+ stackView.onRecentsHidden();
+ }
+ }
+ }
+
@Override
public void onTaskStackFilterTriggered() {
// Hide the search bar
@@ -566,14 +590,14 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
/**** RecentsPackageMonitor.PackageCallbacks Implementation ****/
@Override
- public void onComponentRemoved(HashSet<ComponentName> cns) {
+ public void onPackagesChanged(RecentsPackageMonitor monitor, String packageName, int userId) {
// Propagate this event down to each task stack view
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
if (child != mSearchBar) {
TaskStackView stackView = (TaskStackView) child;
- stackView.onComponentRemoved(cns);
+ stackView.onPackagesChanged(monitor, packageName, userId);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index 40134da..bef4cd1 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -24,7 +24,6 @@ import android.graphics.Rect;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityEvent;
import android.widget.FrameLayout;
import com.android.systemui.R;
@@ -41,6 +40,7 @@ import com.android.systemui.recents.model.TaskStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
/* The visual representation of a task stack view */
@@ -100,25 +100,11 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
}
};
- // A convenience runnable to return all views to the pool
- Runnable mReturnAllViewsToPoolRunnable = new Runnable() {
- @Override
- public void run() {
- int childCount = getChildCount();
- for (int i = childCount - 1; i >= 0; i--) {
- TaskView tv = (TaskView) getChildAt(i);
- mViewPool.returnViewToPool(tv);
- // Also hide the view since we don't need it anymore
- tv.setVisibility(View.INVISIBLE);
- }
- }
- };
-
public TaskStackView(Context context, TaskStack stack) {
super(context);
+ // Set the stack first
+ setStack(stack);
mConfig = RecentsConfiguration.getInstance();
- mStack = stack;
- mStack.setCallbacks(this);
mViewPool = new ViewPool<TaskView, Task>(context, this);
mInflater = LayoutInflater.from(context);
mLayoutAlgorithm = new TaskStackViewLayoutAlgorithm(mConfig);
@@ -144,11 +130,64 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
mCb = cb;
}
+ /** Sets the task stack */
+ void setStack(TaskStack stack) {
+ // Unset the old stack
+ if (mStack != null) {
+ mStack.setCallbacks(null);
+
+ // Return all existing views to the pool
+ reset();
+ // Layout again with the new stack
+ requestLayout();
+ }
+
+ // Set the new stack
+ mStack = stack;
+ if (mStack != null) {
+ mStack.setCallbacks(this);
+ }
+ }
+
/** Sets the debug overlay */
public void setDebugOverlay(DebugOverlayView overlay) {
mDebugOverlay = overlay;
}
+ /** Resets this TaskStackView for reuse. */
+ void reset() {
+ // Reset the focused task
+ resetFocusedTask();
+
+ // Return all the views to the pool
+ int childCount = getChildCount();
+ for (int i = childCount - 1; i >= 0; i--) {
+ TaskView tv = (TaskView) getChildAt(i);
+ mViewPool.returnViewToPool(tv);
+ }
+
+ // Mark each task view for relayout
+ if (mViewPool != null) {
+ Iterator<TaskView> iter = mViewPool.poolViewIterator();
+ if (iter != null) {
+ while (iter.hasNext()) {
+ TaskView tv = iter.next();
+ tv.reset();
+ }
+ }
+ }
+
+ // Reset the stack state
+ mStackViewsDirty = true;
+ mStackViewsClipDirty = true;
+ mAwaitingFirstLayout = true;
+ mPrevAccessibilityFocusedIndex = -1;
+ if (mUIDozeTrigger != null) {
+ mUIDozeTrigger.stopDozing();
+ mUIDozeTrigger.resetTrigger();
+ }
+ }
+
/** Requests that the views be synchronized with the model */
void requestSynchronizeStackViewsWithModel() {
requestSynchronizeStackViewsWithModel(0);
@@ -415,7 +454,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
}
/** Focuses the task at the specified index in the stack */
- void focusTask(int taskIndex, boolean scrollToNewPosition) {
+ void focusTask(int taskIndex, boolean scrollToNewPosition, final boolean animateFocusedState) {
// Return early if the task is already focused
if (taskIndex == mFocusedTaskIndex) return;
@@ -427,7 +466,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
TaskView tv = getChildViewForTask(t);
Runnable postScrollRunnable = null;
if (tv != null) {
- tv.setFocusedTask();
+ tv.setFocusedTask(animateFocusedState);
} else {
postScrollRunnable = new Runnable() {
@Override
@@ -435,7 +474,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
Task t = mStack.getTasks().get(mFocusedTaskIndex);
TaskView tv = getChildViewForTask(t);
if (tv != null) {
- tv.setFocusedTask();
+ tv.setFocusedTask(animateFocusedState);
}
}
};
@@ -455,18 +494,50 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
}
}
- /** Focuses the next task in the stack */
- void focusNextTask(boolean forward) {
+ /**
+ * Ensures that there is a task focused, if nothign is focused, then we will use the task
+ * at the center of the visible stack.
+ */
+ public boolean ensureFocusedTask() {
+ if (mFocusedTaskIndex < 0) {
+ // If there is no task focused, then find the task that is closes to the center
+ // of the screen and use that as the currently focused task
+ int x = mLayoutAlgorithm.mStackVisibleRect.centerX();
+ int y = mLayoutAlgorithm.mStackVisibleRect.centerY();
+ int childCount = getChildCount();
+ for (int i = childCount - 1; i >= 0; i--) {
+ TaskView tv = (TaskView) getChildAt(i);
+ tv.getHitRect(mTmpRect);
+ if (mTmpRect.contains(x, y)) {
+ mFocusedTaskIndex = mStack.indexOfTask(tv.getTask());
+ break;
+ }
+ }
+ // If we can't find the center task, then use the front most index
+ if (mFocusedTaskIndex < 0 && childCount > 0) {
+ mFocusedTaskIndex = childCount - 1;
+ }
+ }
+ return mFocusedTaskIndex >= 0;
+ }
+
+ /**
+ * Focuses the next task in the stack.
+ * @param animateFocusedState determines whether to actually draw the highlight along with
+ * the change in focus, as well as whether to scroll to fit the
+ * task into view.
+ */
+ public void focusNextTask(boolean forward, boolean animateFocusedState) {
// Find the next index to focus
int numTasks = mStack.getTaskCount();
if (numTasks == 0) return;
- int nextFocusIndex = numTasks - 1;
- if (0 <= mFocusedTaskIndex && mFocusedTaskIndex < numTasks) {
- nextFocusIndex = Math.max(0, Math.min(numTasks - 1,
- mFocusedTaskIndex + (forward ? -1 : 1)));
+ int direction = (forward ? -1 : 1);
+ int newIndex = mFocusedTaskIndex + direction;
+ if (newIndex >= 0 && newIndex <= (numTasks - 1)) {
+ newIndex = Math.max(0, Math.min(numTasks - 1, newIndex));
+ focusTask(newIndex, true, animateFocusedState);
}
- focusTask(nextFocusIndex, true);
}
/** Dismisses the focused task. */
@@ -479,6 +550,16 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
tv.dismissTask();
}
+ /** Resets the focused task. */
+ void resetFocusedTask() {
+ if (mFocusedTaskIndex > -1) {
+ Task t = mStack.getTasks().get(mFocusedTaskIndex);
+ TaskView tv = getChildViewForTask(t);
+ tv.unsetFocusedTask();
+ }
+ mFocusedTaskIndex = -1;
+ }
+
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
@@ -506,7 +587,14 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
}
@Override
+ public boolean onGenericMotionEvent(MotionEvent ev) {
+ return mTouchHandler.onGenericMotionEvent(ev);
+ }
+
+ @Override
public void computeScroll() {
+ if (mStack == null) return;
+
mStackScroller.computeScroll();
// Synchronize the views
synchronizeStackViewsWithModel();
@@ -562,22 +650,18 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
TaskView tv = (TaskView) getChildAt(i);
- if (tv.isFullScreenView()) {
- tv.measure(widthMeasureSpec, heightMeasureSpec);
+ if (tv.getBackground() != null) {
+ tv.getBackground().getPadding(mTmpRect);
} else {
- if (tv.getBackground() != null) {
- tv.getBackground().getPadding(mTmpRect);
- } else {
- mTmpRect.setEmpty();
- }
- tv.measure(
- MeasureSpec.makeMeasureSpec(
- mLayoutAlgorithm.mTaskRect.width() + mTmpRect.left + mTmpRect.right,
- MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(
- mLayoutAlgorithm.mTaskRect.height() + mTmpRect.top + mTmpRect.bottom +
- tv.getMaxFooterHeight(), MeasureSpec.EXACTLY));
+ mTmpRect.setEmpty();
}
+ tv.measure(
+ MeasureSpec.makeMeasureSpec(
+ mLayoutAlgorithm.mTaskRect.width() + mTmpRect.left + mTmpRect.right,
+ MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(
+ mLayoutAlgorithm.mTaskRect.height() + mTmpRect.top + mTmpRect.bottom,
+ MeasureSpec.EXACTLY));
}
setMeasuredDimension(width, height);
@@ -594,20 +678,15 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
TaskView tv = (TaskView) getChildAt(i);
- if (tv.isFullScreenView()) {
- tv.layout(left, top, left + tv.getMeasuredWidth(), top + tv.getMeasuredHeight());
+ if (tv.getBackground() != null) {
+ tv.getBackground().getPadding(mTmpRect);
} else {
- if (tv.getBackground() != null) {
- tv.getBackground().getPadding(mTmpRect);
- } else {
- mTmpRect.setEmpty();
- }
- tv.layout(mLayoutAlgorithm.mTaskRect.left - mTmpRect.left,
- mLayoutAlgorithm.mTaskRect.top - mTmpRect.top,
- mLayoutAlgorithm.mTaskRect.right + mTmpRect.right,
- mLayoutAlgorithm.mTaskRect.bottom + mTmpRect.bottom +
- tv.getMaxFooterHeight());
+ mTmpRect.setEmpty();
}
+ tv.layout(mLayoutAlgorithm.mTaskRect.left - mTmpRect.left,
+ mLayoutAlgorithm.mTaskRect.top - mTmpRect.top,
+ mLayoutAlgorithm.mTaskRect.right + mTmpRect.right,
+ mLayoutAlgorithm.mTaskRect.bottom + mTmpRect.bottom);
}
if (mAwaitingFirstLayout) {
@@ -653,9 +732,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
// When Alt-Tabbing, we scroll to and focus the previous task
if (mConfig.launchedWithAltTab) {
if (mConfig.launchedFromHome) {
- focusTask(Math.max(0, mStack.getTaskCount() - 1), false);
+ focusTask(Math.max(0, mStack.getTaskCount() - 1), false, true);
} else {
- focusTask(Math.max(0, mStack.getTaskCount() - 2), false);
+ focusTask(Math.max(0, mStack.getTaskCount() - 2), false, true);
}
}
}
@@ -731,9 +810,6 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
TaskView tv = (TaskView) getChildAt(i);
tv.startExitToHomeAnimation(ctx);
}
-
- // Add a runnable to the post animation ref counter to clear all the views
- ctx.postAnimationTrigger.addLastDecrementRunnable(mReturnAllViewsToPoolRunnable);
}
/** Animates a task view in this stack as it launches. */
@@ -753,6 +829,12 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
}
}
+ /** Final callback after Recents is finally hidden. */
+ void onRecentsHidden() {
+ reset();
+ setStack(null);
+ }
+
public boolean isTransformedTouchPointInView(float x, float y, View child) {
return isTransformedTouchPointInView(x, y, child, null);
}
@@ -811,6 +893,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
TaskView frontTv = getChildViewForTask(newFrontMostTask);
if (frontTv != null) {
frontTv.onTaskBound(newFrontMostTask);
+ frontTv.fadeInActionButton(false);
}
}
@@ -916,27 +999,23 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
// Reset the view properties
tv.resetViewProperties();
+
+ // Reset the clip state of the task view
+ tv.setClipViewInStack(false);
}
@Override
public void prepareViewToLeavePool(TaskView tv, Task task, boolean isNewView) {
+ // It is possible for a view to be returned to the view pool before it is laid out,
+ // which means that we will need to relayout the view when it is first used next.
+ boolean requiresRelayout = tv.getWidth() <= 0 && !isNewView;
+
// Rebind the task and request that this task's data be filled into the TaskView
tv.onTaskBound(task);
- // Mark the launch task as fullscreen
- if (Constants.DebugFlags.App.EnableScreenshotAppTransition && mAwaitingFirstLayout) {
- if (task.isLaunchTarget) {
- tv.setIsFullScreen(true);
- }
- }
-
// Load the task data
RecentsTaskLoader.getInstance().loadTaskData(task);
- // Sanity check, the task view should always be clipping against the stack at this point,
- // but just in case, re-enable it here
- tv.setClipViewInStack(true);
-
// If the doze trigger has already fired, then update the state for this task view
if (mUIDozeTrigger.hasTriggered()) {
tv.setNoUserInteractionState();
@@ -964,13 +1043,17 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
// Add/attach the view to the hierarchy
if (isNewView) {
addView(tv, insertIndex);
-
- // Set the callbacks and listeners for this new view
- tv.setTouchEnabled(true);
- tv.setCallbacks(this);
} else {
attachViewToParent(tv, insertIndex, tv.getLayoutParams());
+ if (requiresRelayout) {
+ tv.requestLayout();
+ }
}
+
+ // Set the new state for this view, including the callbacks and view clipping
+ tv.setCallbacks(this);
+ tv.setTouchEnabled(true);
+ tv.setClipViewInStack(true);
}
@Override
@@ -1018,14 +1101,18 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
tv.getTask().activityLabel));
// Remove the task from the view
mStack.removeTask(task);
- // If the dismissed task was focused, then we should focus the next task in front
+ // If the dismissed task was focused, then we should focus the new task in the same index
if (taskWasFocused) {
ArrayList<Task> tasks = mStack.getTasks();
- int nextTaskIndex = Math.min(tasks.size() - 1, taskIndex);
+ int nextTaskIndex = Math.min(tasks.size() - 1, taskIndex - 1);
if (nextTaskIndex >= 0) {
Task nextTask = tasks.get(nextTaskIndex);
TaskView nextTv = getChildViewForTask(nextTask);
- nextTv.setFocusedTask();
+ if (nextTv != null) {
+ // Focus the next task, and only animate the visible state if we are launched
+ // from Alt-Tab
+ nextTv.setFocusedTask(mConfig.launchedWithAltTab);
+ }
}
}
}
@@ -1038,11 +1125,6 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
}
@Override
- public void onTaskViewFullScreenTransitionCompleted() {
- requestSynchronizeStackViewsWithModel();
- }
-
- @Override
public void onTaskViewFocusChanged(TaskView tv, boolean focused) {
if (focused) {
mFocusedTaskIndex = mStack.indexOfTask(tv.getTask());
@@ -1061,12 +1143,16 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
/**** RecentsPackageMonitor.PackageCallbacks Implementation ****/
@Override
- public void onComponentRemoved(HashSet<ComponentName> cns) {
+ public void onPackagesChanged(RecentsPackageMonitor monitor, String packageName, int userId) {
+ // Compute which components need to be removed
+ HashSet<ComponentName> removedComponents = monitor.computeComponentsRemoved(
+ mStack.getTaskKeys(), packageName, userId);
+
// For other tasks, just remove them directly if they no longer exist
ArrayList<Task> tasks = mStack.getTasks();
for (int i = tasks.size() - 1; i >= 0; i--) {
final Task t = tasks.get(i);
- if (cns.contains(t.key.baseIntent.getComponent())) {
+ if (removedComponents.contains(t.key.baseIntent.getComponent())) {
TaskView tv = getChildViewForTask(t);
if (tv != null) {
// For visible children, defer removing the task until after the animation
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java
index 31fc701..c549d2b 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java
@@ -199,18 +199,14 @@ public class TaskStackViewLayoutAlgorithm {
return transformOut;
}
- /**
- * Returns the untransformed task view size.
- */
+ /** Returns the untransformed task view size. */
public Rect getUntransformedTaskViewSize() {
Rect tvSize = new Rect(mTaskRect);
tvSize.offsetTo(0, 0);
return tvSize;
}
- /**
- * Returns the scroll to such task top = 1f;
- */
+ /** Returns the scroll to such task top = 1f; */
float getStackScrollForTask(Task t) {
return mTaskProgressMap.get(t.key);
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java
index 5852b88..04f7c6f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java
@@ -23,6 +23,7 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.widget.OverScroller;
import com.android.systemui.recents.RecentsConfiguration;
+import com.android.systemui.recents.misc.Utilities;
/* The scrolling logic for a TaskStackView */
public class TaskStackViewScroller {
@@ -38,6 +39,7 @@ public class TaskStackViewScroller {
OverScroller mScroller;
ObjectAnimator mScrollAnimator;
+ float mFinalAnimatedScroll;
public TaskStackViewScroller(Context context, RecentsConfiguration config, TaskStackViewLayoutAlgorithm layoutAlgorithm) {
mConfig = config;
@@ -128,10 +130,15 @@ public class TaskStackViewScroller {
/** Animates the stack scroll */
void animateScroll(float curScroll, float newScroll, final Runnable postRunnable) {
- // Abort any current animations
+ // Finish any current scrolling animations
+ if (mScrollAnimator != null && mScrollAnimator.isRunning()) {
+ setStackScroll(mFinalAnimatedScroll);
+ mScroller.startScroll(0, progressToScrollRange(mFinalAnimatedScroll), 0, 0, 0);
+ }
stopScroller();
stopBoundScrollAnimation();
+ mFinalAnimatedScroll = newScroll;
mScrollAnimator = ObjectAnimator.ofFloat(this, "stackScroll", curScroll, newScroll);
mScrollAnimator.setDuration(mConfig.taskStackScrollDuration);
mScrollAnimator.setInterpolator(mConfig.linearOutSlowInInterpolator);
@@ -155,10 +162,7 @@ public class TaskStackViewScroller {
/** Aborts any current stack scrolls */
void stopBoundScrollAnimation() {
- if (mScrollAnimator != null) {
- mScrollAnimator.removeAllListeners();
- mScrollAnimator.cancel();
- }
+ Utilities.cancelAnimationWithoutCallbacks(mScrollAnimator);
}
/**** OverScroller ****/
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
index 8f9b4c2..2b173a9 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
@@ -17,6 +17,7 @@
package com.android.systemui.recents.views;
import android.content.Context;
+import android.view.InputDevice;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
@@ -189,7 +190,6 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
/** Handles touch events once we have intercepted them */
public boolean onTouchEvent(MotionEvent ev) {
-
// Short circuit if we have no children
boolean hasChildren = (mSv.getChildCount() > 0);
if (!hasChildren) {
@@ -336,6 +336,30 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
return true;
}
+ /** Handles generic motion events */
+ public boolean onGenericMotionEvent(MotionEvent ev) {
+ if ((ev.getSource() & InputDevice.SOURCE_CLASS_POINTER) ==
+ InputDevice.SOURCE_CLASS_POINTER) {
+ int action = ev.getAction();
+ switch (action & MotionEvent.ACTION_MASK) {
+ case MotionEvent.ACTION_SCROLL:
+ // Find the front most task and scroll the next task to the front
+ float vScroll = ev.getAxisValue(MotionEvent.AXIS_VSCROLL);
+ if (vScroll > 0) {
+ if (mSv.ensureFocusedTask()) {
+ mSv.focusNextTask(true, false);
+ }
+ } else {
+ if (mSv.ensureFocusedTask()) {
+ mSv.focusNextTask(false, false);
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
/**** SwipeHelper Implementation ****/
@Override
@@ -355,8 +379,6 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
tv.setClipViewInStack(false);
// Disallow touch events from this task view
tv.setTouchEnabled(false);
- // Hide the footer
- tv.animateFooterVisibility(false, mSv.mConfig.taskViewLockToAppShortAnimDuration);
// Disallow parents from intercepting touch events
final ViewParent parent = mSv.getParent();
if (parent != null) {
@@ -387,8 +409,6 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
tv.setClipViewInStack(true);
// Re-enable touch events from this task view
tv.setTouchEnabled(true);
- // Restore the footer
- tv.animateFooterVisibility(true, mSv.mConfig.taskViewLockToAppShortAnimDuration);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index 2658176..790130a 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -21,23 +21,22 @@ import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.*;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewOutlineProvider;
+import android.view.ViewPropertyAnimator;
import android.view.animation.AccelerateInterpolator;
import android.widget.FrameLayout;
import com.android.systemui.R;
-import com.android.systemui.recents.AlternateRecentsComponent;
import com.android.systemui.recents.Constants;
import com.android.systemui.recents.RecentsConfiguration;
-import com.android.systemui.recents.model.RecentsTaskLoader;
+import com.android.systemui.recents.misc.Utilities;
import com.android.systemui.recents.model.Task;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
/* A task view */
public class TaskView extends FrameLayout implements Task.TaskCallbacks,
- TaskViewFooter.TaskFooterViewCallbacks, View.OnClickListener, View.OnLongClickListener {
+ View.OnClickListener, View.OnLongClickListener {
/** The TaskView callbacks */
interface TaskViewCallbacks {
@@ -46,7 +45,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
public void onTaskViewClicked(TaskView tv, Task task, boolean lockToTask);
public void onTaskViewDismissed(TaskView tv);
public void onTaskViewClipStateChanged(TaskView tv);
- public void onTaskViewFullScreenTransitionCompleted();
public void onTaskViewFocusChanged(TaskView tv, boolean focused);
}
@@ -54,25 +52,22 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
float mTaskProgress;
ObjectAnimator mTaskProgressAnimator;
- ObjectAnimator mDimAnimator;
float mMaxDimScale;
- int mDim;
+ int mDimAlpha;
AccelerateInterpolator mDimInterpolator = new AccelerateInterpolator(1f);
- PorterDuffColorFilter mDimColorFilter = new PorterDuffColorFilter(0, PorterDuff.Mode.MULTIPLY);
+ PorterDuffColorFilter mDimColorFilter = new PorterDuffColorFilter(0, PorterDuff.Mode.SRC_ATOP);
+ Paint mDimLayerPaint = new Paint();
Task mTask;
boolean mTaskDataLoaded;
boolean mIsFocused;
boolean mFocusAnimationsEnabled;
- boolean mIsFullScreenView;
boolean mClipViewInStack;
AnimateableViewBounds mViewBounds;
- Paint mLayerPaint = new Paint();
View mContent;
TaskViewThumbnail mThumbnailView;
TaskViewHeader mHeaderView;
- TaskViewFooter mFooterView;
View mActionButtonView;
TaskViewCallbacks mCb;
@@ -117,6 +112,14 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
mCb = cb;
}
+ /** Resets this TaskView for reuse. */
+ void reset() {
+ resetViewProperties();
+ resetNoUserInteractionState();
+ setClipViewInStack(false);
+ setCallbacks(null);
+ }
+
/** Gets the task */
Task getTask() {
return mTask;
@@ -133,7 +136,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
mContent = findViewById(R.id.task_view_content);
mHeaderView = (TaskViewHeader) findViewById(R.id.task_view_bar);
mThumbnailView = (TaskViewThumbnail) findViewById(R.id.task_view_thumbnail);
- mThumbnailView.enableTaskBarClip(mHeaderView);
+ mThumbnailView.updateClipToTaskBar(mHeaderView);
mActionButtonView = findViewById(R.id.lock_to_app_fab);
mActionButtonView.setOutlineProvider(new ViewOutlineProvider() {
@Override
@@ -142,9 +145,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
outline.setOval(0, 0, mActionButtonView.getWidth(), mActionButtonView.getHeight());
}
});
- if (mFooterView != null) {
- mFooterView.setCallbacks(this);
- }
}
@Override
@@ -159,29 +159,16 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
mContent.measure(MeasureSpec.makeMeasureSpec(widthWithoutPadding, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(widthWithoutPadding, MeasureSpec.EXACTLY));
- // Measure the bar view, thumbnail, and footer
+ // Measure the bar view, and action button
mHeaderView.measure(MeasureSpec.makeMeasureSpec(widthWithoutPadding, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(mConfig.taskBarHeight, MeasureSpec.EXACTLY));
- if (mFooterView != null) {
- mFooterView.measure(
- MeasureSpec.makeMeasureSpec(widthWithoutPadding, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(mConfig.taskViewLockToAppButtonHeight,
- MeasureSpec.EXACTLY));
- }
mActionButtonView.measure(
MeasureSpec.makeMeasureSpec(widthWithoutPadding, MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(heightWithoutPadding, MeasureSpec.AT_MOST));
- if (mIsFullScreenView) {
- // Measure the thumbnail height to be the full dimensions
- mThumbnailView.measure(
- MeasureSpec.makeMeasureSpec(widthWithoutPadding, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(heightWithoutPadding, MeasureSpec.EXACTLY));
- } else {
- // Measure the thumbnail to be square
- mThumbnailView.measure(
- MeasureSpec.makeMeasureSpec(widthWithoutPadding, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(widthWithoutPadding, MeasureSpec.EXACTLY));
- }
+ // Measure the thumbnail to be square
+ mThumbnailView.measure(
+ MeasureSpec.makeMeasureSpec(widthWithoutPadding, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(widthWithoutPadding, MeasureSpec.EXACTLY));
setMeasuredDimension(width, height);
invalidateOutline();
}
@@ -193,25 +180,12 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
void updateViewPropertiesToTaskTransform(TaskViewTransform toTransform, int duration,
ValueAnimator.AnimatorUpdateListener updateCallback) {
- // If we are a full screen view, then only update the Z to keep it in order
- // XXX: Also update/animate the dim as well
- if (mIsFullScreenView) {
- if (!mConfig.fakeShadows &&
- toTransform.hasTranslationZChangedFrom(getTranslationZ())) {
- setTranslationZ(toTransform.translationZ);
- }
- return;
- }
-
// Apply the transform
toTransform.applyToTaskView(this, duration, mConfig.fastOutSlowInInterpolator, false,
!mConfig.fakeShadows, updateCallback);
// Update the task progress
- if (mTaskProgressAnimator != null) {
- mTaskProgressAnimator.removeAllListeners();
- mTaskProgressAnimator.cancel();
- }
+ Utilities.cancelAnimationWithoutCallbacks(mTaskProgressAnimator);
if (duration <= 0) {
setTaskProgress(toTransform.p);
} else {
@@ -225,6 +199,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
/** Resets this view's properties */
void resetViewProperties() {
setDim(0);
+ setLayerType(View.LAYER_TYPE_NONE, null);
TaskViewTransform.reset(this);
}
@@ -253,22 +228,12 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
void prepareEnterRecentsAnimation(boolean isTaskViewLaunchTargetTask,
boolean occludesLaunchTarget, int offscreenY) {
int initialDim = getDim();
- if (mConfig.launchedFromAppWithScreenshot) {
- if (isTaskViewLaunchTargetTask) {
- // Hide the footer during the transition in, and animate it out afterwards?
- if (mFooterView != null) {
- mFooterView.animateFooterVisibility(false, 0);
- }
- } else {
- // Don't do anything for the side views when animating in
- }
-
- } else if (mConfig.launchedFromAppWithThumbnail) {
+ if (mConfig.launchedFromAppWithThumbnail) {
if (isTaskViewLaunchTargetTask) {
- // Hide the action button if it exists
- mActionButtonView.setAlpha(0f);
// Set the dim to 0 so we can animate it in
initialDim = 0;
+ // Hide the action button
+ mActionButtonView.setAlpha(0f);
} else if (occludesLaunchTarget) {
// Move the task view off screen (below) so we can animate it in
setTranslationY(offscreenY);
@@ -292,74 +257,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
final TaskViewTransform transform = ctx.currentTaskTransform;
int startDelay = 0;
- if (mConfig.launchedFromAppWithScreenshot) {
- if (mTask.isLaunchTarget) {
- Rect taskRect = ctx.currentTaskRect;
- int duration = mConfig.taskViewEnterFromHomeDuration * 10;
- int windowInsetTop = mConfig.systemInsets.top; // XXX: Should be for the window
- float taskScale = ((float) taskRect.width() / getMeasuredWidth()) * transform.scale;
- float scaledYOffset = ((1f - taskScale) * getMeasuredHeight()) / 2;
- float scaledWindowInsetTop = (int) (taskScale * windowInsetTop);
- float scaledTranslationY = taskRect.top + transform.translationY -
- (scaledWindowInsetTop + scaledYOffset);
- startDelay = mConfig.taskViewEnterFromHomeStaggerDelay;
-
- // Animate the top clip
- mViewBounds.animateClipTop(windowInsetTop, duration,
- new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- int y = (Integer) animation.getAnimatedValue();
- mHeaderView.setTranslationY(y);
- }
- });
- // Animate the bottom or right clip
- int size = Math.round((taskRect.width() / taskScale));
- if (mConfig.hasHorizontalLayout()) {
- mViewBounds.animateClipRight(getMeasuredWidth() - size, duration);
- } else {
- mViewBounds.animateClipBottom(getMeasuredHeight() - (windowInsetTop + size), duration);
- }
- // Animate the task bar of the first task view
- animate()
- .scaleX(taskScale)
- .scaleY(taskScale)
- .translationY(scaledTranslationY)
- .setDuration(duration)
- .withEndAction(new Runnable() {
- @Override
- public void run() {
- setIsFullScreen(false);
- requestLayout();
-
- // Reset the clip
- mViewBounds.setClipTop(0);
- mViewBounds.setClipBottom(0);
- mViewBounds.setClipRight(0);
- // Reset the bar translation
- mHeaderView.setTranslationY(0);
- // Animate the footer into view (if it is the front most task)
- animateFooterVisibility(true, mConfig.taskBarEnterAnimDuration);
-
- // Unbind the thumbnail from the screenshot
- RecentsTaskLoader.getInstance().loadTaskData(mTask);
- // Recycle the full screen screenshot
- AlternateRecentsComponent.consumeLastScreenshot();
-
- mCb.onTaskViewFullScreenTransitionCompleted();
-
- // Decrement the post animation trigger
- ctx.postAnimationTrigger.decrement();
- }
- })
- .start();
- } else {
- // Animate the footer into view
- animateFooterVisibility(true, 0);
- }
- ctx.postAnimationTrigger.increment();
-
- } else if (mConfig.launchedFromAppWithThumbnail) {
+ if (mConfig.launchedFromAppWithThumbnail) {
if (mTask.isLaunchTarget) {
// Animate the dim/overlay
if (Constants.DebugFlags.App.EnableThumbnailAlphaOnFrontmost) {
@@ -381,16 +279,8 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
}
ctx.postAnimationTrigger.increment();
- // Animate the footer into view
- animateFooterVisibility(true, mConfig.taskBarEnterAnimDuration);
-
// Animate the action button in
- mActionButtonView.animate().alpha(1f)
- .setStartDelay(mConfig.taskBarEnterAnimDelay)
- .setDuration(mConfig.taskBarEnterAnimDuration)
- .setInterpolator(mConfig.fastOutLinearInInterpolator)
- .withLayer()
- .start();
+ fadeInActionButton(true);
} else {
// Animate the task up if it was occluding the launch target
if (ctx.currentTaskOccludesLaunchTarget) {
@@ -442,14 +332,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
})
.start();
ctx.postAnimationTrigger.increment();
-
- // Animate the footer into view
- animateFooterVisibility(true, mConfig.taskViewEnterFromHomeDuration);
startDelay = delay;
-
- } else {
- // Animate the footer into view
- animateFooterVisibility(true, 0);
}
// Enable the focus animations from this point onwards so that they aren't affected by the
@@ -462,6 +345,21 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
}, (startDelay / 2));
}
+ public void fadeInActionButton(boolean withDelay) {
+ // Hide the action button
+ mActionButtonView.setAlpha(0f);
+
+ // Animate the action button in
+ ViewPropertyAnimator animator = mActionButtonView.animate().alpha(1f)
+ .setDuration(mConfig.taskBarEnterAnimDuration)
+ .setInterpolator(PhoneStatusBar.ALPHA_IN)
+ .withLayer();
+ if (withDelay) {
+ animator.setStartDelay(mConfig.taskBarEnterAnimDelay);
+ }
+ animator.start();
+ }
+
/** Animates this task view as it leaves recents by pressing home. */
void startExitToHomeAnimation(ViewAnimation.TaskViewExitContext ctx) {
animate()
@@ -483,7 +381,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
mThumbnailView.startLaunchTaskAnimation(postAnimRunnable);
// Animate the dim
- if (mDim > 0) {
+ if (mDimAlpha > 0) {
ObjectAnimator anim = ObjectAnimator.ofInt(this, "dim", 0);
anim.setDuration(mConfig.taskBarExitAnimDuration);
anim.setInterpolator(mConfig.fastOutLinearInInterpolator);
@@ -559,6 +457,11 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
mHeaderView.setNoUserInteractionState();
}
+ /** Resets the state tracking that the user has not interacted with the stack after a certain time. */
+ void resetNoUserInteractionState() {
+ mHeaderView.resetNoUserInteractionState();
+ }
+
/** Dismisses this task. */
void dismissTask() {
// Animate out the view and call the callback
@@ -569,23 +472,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
mCb.onTaskViewDismissed(tv);
}
});
- // Hide the footer
- animateFooterVisibility(false, mConfig.taskViewRemoveAnimDuration);
- }
-
- /** Sets whether this task view is full screen or not. */
- void setIsFullScreen(boolean isFullscreen) {
- mIsFullScreenView = isFullscreen;
- mHeaderView.setIsFullscreen(isFullscreen);
- if (isFullscreen) {
- // If we are full screen, then disable the bottom outline clip for the footer
- mViewBounds.setOutlineClipBottom(0);
- }
- }
-
- /** Returns whether this task view should currently be drawn as a full screen view. */
- boolean isFullScreenView() {
- return mIsFullScreenView;
}
/**
@@ -593,7 +479,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
* view.
*/
boolean shouldClipViewInStack() {
- return mClipViewInStack && !mIsFullScreenView && (getVisibility() == View.VISIBLE);
+ return mClipViewInStack && (getVisibility() == View.VISIBLE);
}
/** Sets whether this view should be clipped, or clipped against. */
@@ -604,27 +490,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
}
}
- /** Gets the max footer height. */
- public int getMaxFooterHeight() {
- if (mFooterView != null) {
- return mFooterView.mMaxFooterHeight;
- } else {
- return 0;
- }
- }
-
- /** Animates the footer into and out of view. */
- void animateFooterVisibility(boolean visible, int duration) {
- // Hide the footer if we are a full screen view
- if (mIsFullScreenView) return;
- // Hide the footer if the current task can not be locked to
- if (!mTask.lockToTaskEnabled || !mTask.lockToThisTask) return;
- // Otherwise, animate the visibility
- if (mFooterView != null) {
- mFooterView.animateFooterVisibility(visible, duration);
- }
- }
-
/** Sets the current task progress. */
public void setTaskProgress(float p) {
mTaskProgress = p;
@@ -639,26 +504,16 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
/** Returns the current dim. */
public void setDim(int dim) {
- mDim = dim;
- if (mDimAnimator != null) {
- mDimAnimator.removeAllListeners();
- mDimAnimator.cancel();
- }
+ mDimAlpha = dim;
if (mConfig.useHardwareLayers) {
// Defer setting hardware layers if we have not yet measured, or there is no dim to draw
if (getMeasuredWidth() > 0 && getMeasuredHeight() > 0) {
- if (mDimAnimator != null) {
- mDimAnimator.removeAllListeners();
- mDimAnimator.cancel();
- }
-
- int inverse = 255 - mDim;
- mDimColorFilter.setColor(Color.argb(0xFF, inverse, inverse, inverse));
- mLayerPaint.setColorFilter(mDimColorFilter);
- mContent.setLayerType(LAYER_TYPE_HARDWARE, mLayerPaint);
+ mDimColorFilter.setColor(Color.argb(mDimAlpha, 0, 0, 0));
+ mDimLayerPaint.setColorFilter(mDimColorFilter);
+ mContent.setLayerType(LAYER_TYPE_HARDWARE, mDimLayerPaint);
}
} else {
- float dimAlpha = mDim / 255.0f;
+ float dimAlpha = mDimAlpha / 255.0f;
if (mThumbnailView != null) {
mThumbnailView.setDimAlpha(dimAlpha);
}
@@ -670,7 +525,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
/** Returns the current dim. */
public int getDim() {
- return mDim;
+ return mDimAlpha;
}
/** Animates the dim to the task progress. */
@@ -706,11 +561,11 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
* if the view is not currently visible, or we are in touch state (where we still want to keep
* track of focus).
*/
- public void setFocusedTask() {
+ public void setFocusedTask(boolean animateFocusedState) {
mIsFocused = true;
if (mFocusAnimationsEnabled) {
// Focus the header bar
- mHeaderView.onTaskViewFocusChanged(true);
+ mHeaderView.onTaskViewFocusChanged(true, animateFocusedState);
}
// Update the thumbnail alpha with the focus
mThumbnailView.onFocusChanged(true);
@@ -732,7 +587,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
mIsFocused = false;
if (mFocusAnimationsEnabled) {
// Un-focus the header bar
- mHeaderView.onTaskViewFocusChanged(false);
+ mHeaderView.onTaskViewFocusChanged(false, true);
}
// Update the thumbnail alpha with the focus
@@ -766,7 +621,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
mFocusAnimationsEnabled = true;
if (mIsFocused && !wasFocusAnimationsEnabled) {
// Re-notify the header if we were focused and animations were not previously enabled
- mHeaderView.onTaskViewFocusChanged(true);
+ mHeaderView.onTaskViewFocusChanged(true, true);
}
}
@@ -776,15 +631,12 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
public void onTaskBound(Task t) {
mTask = t;
mTask.setCallbacks(this);
- if (getMeasuredWidth() == 0) {
- // If we haven't yet measured, we should just set the footer height with any animation
- animateFooterVisibility(t.lockToThisTask, 0);
- } else {
- animateFooterVisibility(t.lockToThisTask, mConfig.taskViewLockToAppLongAnimDuration);
- }
- // Hide the action button if lock to app is disabled
- if (!t.lockToTaskEnabled && mActionButtonView.getVisibility() != View.GONE) {
- mActionButtonView.setVisibility(View.GONE);
+
+ // Hide the action button if lock to app is disabled for this view
+ int lockButtonVisibility = (!t.lockToTaskEnabled || !t.lockToThisTask) ? GONE : VISIBLE;
+ if (mActionButtonView.getVisibility() != lockButtonVisibility) {
+ mActionButtonView.setVisibility(lockButtonVisibility);
+ requestLayout();
}
}
@@ -792,18 +644,11 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
public void onTaskDataLoaded() {
if (mThumbnailView != null && mHeaderView != null) {
// Bind each of the views to the new task data
- if (mIsFullScreenView) {
- mThumbnailView.bindToScreenshot(AlternateRecentsComponent.getLastScreenshot());
- } else {
- mThumbnailView.rebindToTask(mTask);
- }
+ mThumbnailView.rebindToTask(mTask);
mHeaderView.rebindToTask(mTask);
// Rebind any listeners
mHeaderView.mApplicationIcon.setOnClickListener(this);
mHeaderView.mDismissButton.setOnClickListener(this);
- if (mFooterView != null) {
- mFooterView.setOnClickListener(this);
- }
mActionButtonView.setOnClickListener(this);
if (Constants.DebugFlags.App.EnableDevAppInfoOnLongPress) {
if (mConfig.developerOptionsEnabled) {
@@ -824,9 +669,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
// Unbind any listeners
mHeaderView.mApplicationIcon.setOnClickListener(null);
mHeaderView.mDismissButton.setOnClickListener(null);
- if (mFooterView != null) {
- mFooterView.setOnClickListener(null);
- }
mActionButtonView.setOnClickListener(null);
if (Constants.DebugFlags.App.EnableDevAppInfoOnLongPress) {
mHeaderView.mApplicationIcon.setOnLongClickListener(null);
@@ -840,19 +682,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
setOnClickListener(enabled ? this : null);
}
- /**** TaskViewFooter.TaskFooterViewCallbacks ****/
-
- @Override
- public void onTaskFooterHeightChanged(int height, int maxHeight) {
- if (mIsFullScreenView) {
- // Disable the bottom outline clip when fullscreen
- mViewBounds.setOutlineClipBottom(0);
- } else {
- // Update the bottom clip in our outline provider
- mViewBounds.setOutlineClipBottom(maxHeight - height);
- }
- }
-
/**** View.OnClickListener Implementation ****/
@Override
@@ -876,8 +705,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
// Reset the translation of the action button before we animate it out
mActionButtonView.setTranslationZ(0f);
}
- mCb.onTaskViewClicked(tv, tv.getTask(),
- (v == mFooterView || v == mActionButtonView));
+ mCb.onTaskViewClicked(tv, tv.getTask(), (v == mActionButtonView));
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewFooter.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewFooter.java
deleted file mode 100644
index 324169e..0000000
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewFooter.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2014 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.recents.views;
-
-import android.animation.ObjectAnimator;
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.FrameLayout;
-import com.android.systemui.recents.RecentsConfiguration;
-
-
-/** The task footer view */
-public class TaskViewFooter extends FrameLayout {
-
- interface TaskFooterViewCallbacks {
- public void onTaskFooterHeightChanged(int height, int maxHeight);
- }
-
- RecentsConfiguration mConfig;
-
- TaskFooterViewCallbacks mCb;
- int mFooterHeight;
- int mMaxFooterHeight;
- ObjectAnimator mFooterAnimator;
-
- public TaskViewFooter(Context context) {
- this(context, null);
- }
-
- public TaskViewFooter(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public TaskViewFooter(Context context, AttributeSet attrs, int defStyleAttr) {
- this(context, attrs, defStyleAttr, 0);
- }
-
- public TaskViewFooter(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- mConfig = RecentsConfiguration.getInstance();
- mMaxFooterHeight = mConfig.taskViewLockToAppButtonHeight;
- setFooterHeight(getFooterHeight());
- }
-
- /** Sets the callbacks for when the footer height changes. */
- void setCallbacks(TaskFooterViewCallbacks cb) {
- mCb = cb;
- mCb.onTaskFooterHeightChanged(mFooterHeight, mMaxFooterHeight);
- }
-
- /** Sets the footer height. */
- public void setFooterHeight(int footerHeight) {
- if (footerHeight != mFooterHeight) {
- mFooterHeight = footerHeight;
- mCb.onTaskFooterHeightChanged(footerHeight, mMaxFooterHeight);
- }
- }
-
- /** Gets the footer height. */
- public int getFooterHeight() {
- return mFooterHeight;
- }
-
- /** Animates the footer into and out of view. */
- void animateFooterVisibility(final boolean visible, int duration) {
- // Return early if there is no footer
- if (mMaxFooterHeight <= 0) return;
-
- // Cancel the previous animation
- if (mFooterAnimator != null) {
- mFooterAnimator.removeAllListeners();
- mFooterAnimator.cancel();
- }
- int finalHeight = visible ? mMaxFooterHeight : 0;
- if (duration > 0) {
- mFooterAnimator = ObjectAnimator.ofInt(this, "footerHeight", finalHeight);
- mFooterAnimator.setDuration(duration);
- mFooterAnimator.setInterpolator(mConfig.fastOutSlowInInterpolator);
- mFooterAnimator.start();
- } else {
- setFooterHeight(finalHeight);
- }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
index 396d441..5de84bd 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
@@ -36,7 +36,6 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.RippleDrawable;
-import android.graphics.drawable.ShapeDrawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
@@ -56,25 +55,27 @@ public class TaskViewHeader extends FrameLayout {
RecentsConfiguration mConfig;
+ // Header views
ImageView mDismissButton;
ImageView mApplicationIcon;
TextView mActivityDescription;
- RippleDrawable mBackground;
- GradientDrawable mBackgroundColorDrawable;
+ // Header drawables
+ boolean mCurrentPrimaryColorIsDark;
+ int mCurrentPrimaryColor;
int mBackgroundColor;
Drawable mLightDismissDrawable;
Drawable mDarkDismissDrawable;
+ RippleDrawable mBackground;
+ GradientDrawable mBackgroundColorDrawable;
AnimatorSet mFocusAnimator;
- ValueAnimator backgroundColorAnimator;
- PorterDuffColorFilter mDimFilter = new PorterDuffColorFilter(0, PorterDuff.Mode.SRC_ATOP);
-
- boolean mIsFullscreen;
- boolean mCurrentPrimaryColorIsDark;
- int mCurrentPrimaryColor;
+ // Static highlight that we draw at the top of each view
static Paint sHighlightPaint;
- private Paint mDimPaint = new Paint();
+
+ // Header dim, which is only used when task view hardware layers are not used
+ Paint mDimLayerPaint = new Paint();
+ PorterDuffColorFilter mDimColorFilter = new PorterDuffColorFilter(0, PorterDuff.Mode.SRC_ATOP);
public TaskViewHeader(Context context) {
this(context, null);
@@ -159,21 +160,14 @@ public class TaskViewHeader extends FrameLayout {
@Override
protected void onDraw(Canvas canvas) {
- if (!mIsFullscreen) {
- // Draw the highlight at the top edge (but put the bottom edge just out of view)
- float offset = (float) Math.ceil(mConfig.taskViewHighlightPx / 2f);
- float radius = mConfig.taskViewRoundedCornerRadiusPx;
- int count = canvas.save(Canvas.CLIP_SAVE_FLAG);
- canvas.clipRect(0, 0, getMeasuredWidth(), getMeasuredHeight());
- canvas.drawRoundRect(-offset, 0f, (float) getMeasuredWidth() + offset,
- getMeasuredHeight() + radius, radius, radius, sHighlightPaint);
- canvas.restoreToCount(count);
- }
- }
-
- /** Sets whether the current task is full screen or not. */
- void setIsFullscreen(boolean isFullscreen) {
- mIsFullscreen = isFullscreen;
+ // Draw the highlight at the top edge (but put the bottom edge just out of view)
+ float offset = (float) Math.ceil(mConfig.taskViewHighlightPx / 2f);
+ float radius = mConfig.taskViewRoundedCornerRadiusPx;
+ int count = canvas.save(Canvas.CLIP_SAVE_FLAG);
+ canvas.clipRect(0, 0, getMeasuredWidth(), getMeasuredHeight());
+ canvas.drawRoundRect(-offset, 0f, (float) getMeasuredWidth() + offset,
+ getMeasuredHeight() + radius, radius, radius, sHighlightPaint);
+ canvas.restoreToCount(count);
}
@Override
@@ -181,6 +175,16 @@ public class TaskViewHeader extends FrameLayout {
return false;
}
+ /**
+ * Sets the dim alpha, only used when we are not using hardware layers.
+ * (see RecentsConfiguration.useHardwareLayers)
+ */
+ void setDimAlpha(int alpha) {
+ mDimColorFilter.setColor(Color.argb(alpha, 0, 0, 0));
+ mDimLayerPaint.setColorFilter(mDimColorFilter);
+ setLayerType(LAYER_TYPE_HARDWARE, mDimLayerPaint);
+ }
+
/** Returns the secondary color for a primary color. */
int getSecondaryColor(int primaryColor, boolean useLightOverlayColor) {
int overlayColor = useLightOverlayColor ? Color.WHITE : Color.BLACK;
@@ -259,6 +263,11 @@ public class TaskViewHeader extends FrameLayout {
}
}
+ /** Resets the state tracking that the user has not interacted with the stack after a certain time. */
+ void resetNoUserInteractionState() {
+ mDismissButton.setVisibility(View.INVISIBLE);
+ }
+
@Override
protected int[] onCreateDrawableState(int extraSpace) {
@@ -268,13 +277,16 @@ public class TaskViewHeader extends FrameLayout {
}
/** Notifies the associated TaskView has been focused. */
- void onTaskViewFocusChanged(boolean focused) {
+ void onTaskViewFocusChanged(boolean focused, boolean animateFocusedState) {
+ // If we are not animating the visible state, just return
+ if (!animateFocusedState) return;
+
boolean isRunning = false;
if (mFocusAnimator != null) {
isRunning = mFocusAnimator.isRunning();
- mFocusAnimator.removeAllListeners();
- mFocusAnimator.cancel();
+ Utilities.cancelAnimationWithoutCallbacks(mFocusAnimator);
}
+
if (focused) {
int secondaryColor = getSecondaryColor(mCurrentPrimaryColor, mCurrentPrimaryColorIsDark);
int[][] states = new int[][] {
@@ -349,11 +361,4 @@ public class TaskViewHeader extends FrameLayout {
}
}
}
-
- public void setDimAlpha(int alpha) {
- int color = Color.argb(alpha, 0, 0, 0);
- mDimFilter.setColor(color);
- mDimPaint.setColorFilter(mDimFilter);
- setLayerType(LAYER_TYPE_HARDWARE, mDimPaint);
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java
index a946a84..c83248e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java
@@ -33,37 +33,48 @@ import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.View;
import com.android.systemui.recents.RecentsConfiguration;
+import com.android.systemui.recents.misc.Utilities;
import com.android.systemui.recents.model.Task;
-/** The task thumbnail view */
+/**
+ * The task thumbnail view. It implements an image view that allows for animating the dim and
+ * alpha of the thumbnail image.
+ */
public class TaskViewThumbnail extends View {
- private final int mCornerRadius;
- private final Matrix mScaleMatrix = new Matrix();
RecentsConfiguration mConfig;
- // Task bar clipping
- Rect mClipRect = new Rect();
+ // Drawing
+ float mDimAlpha;
+ Matrix mScaleMatrix = new Matrix();
Paint mDrawPaint = new Paint();
+ RectF mBitmapRect = new RectF();
+ RectF mLayoutRect = new RectF();
+ BitmapShader mBitmapShader;
LightingColorFilter mLightingColorFilter = new LightingColorFilter(0xffffffff, 0);
- private final RectF mBitmapRect = new RectF();
- private final RectF mLayoutRect = new RectF();
- private BitmapShader mBitmapShader;
- private float mBitmapAlpha;
- private float mDimAlpha;
- private View mTaskBar;
- private boolean mInvisible;
- private ValueAnimator mAlphaAnimator;
- private ValueAnimator.AnimatorUpdateListener mAlphaUpdateListener
+
+ // Thumbnail alpha
+ float mThumbnailAlpha;
+ ValueAnimator mThumbnailAlphaAnimator;
+ ValueAnimator.AnimatorUpdateListener mThumbnailAlphaUpdateListener
= new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
- mBitmapAlpha = (float) animation.getAnimatedValue();
- updateFilter();
+ mThumbnailAlpha = (float) animation.getAnimatedValue();
+ updateThumbnailPaintFilter();
}
};
+ // Task bar clipping, the top of this thumbnail can be clipped against the opaque header
+ // bar that overlaps this thumbnail
+ View mTaskBar;
+ Rect mClipRect = new Rect();
+
+ // Visibility optimization, if the thumbnail height is less than the height of the header
+ // bar for the task view, then just mark this thumbnail view as invisible
+ boolean mInvisible;
+
public TaskViewThumbnail(Context context) {
this(context, null);
}
@@ -79,53 +90,82 @@ public class TaskViewThumbnail extends View {
public TaskViewThumbnail(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
mConfig = RecentsConfiguration.getInstance();
- mCornerRadius = mConfig.taskViewRoundedCornerRadiusPx;
mDrawPaint.setColorFilter(mLightingColorFilter);
mDrawPaint.setFilterBitmap(true);
mDrawPaint.setAntiAlias(true);
}
@Override
+ protected void onFinishInflate() {
+ mThumbnailAlpha = mConfig.taskViewThumbnailAlpha;
+ updateThumbnailPaintFilter();
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ if (changed) {
+ mLayoutRect.set(0, 0, getWidth(), getHeight());
+ updateThumbnailScale();
+ }
+ }
+
+ @Override
protected void onDraw(Canvas canvas) {
if (mInvisible) {
return;
}
- canvas.drawRoundRect(0,
- 0,
- getWidth(),
- getHeight(),
- mCornerRadius,
- mCornerRadius,
- mDrawPaint);
+ // Draw the thumbnail with the rounded corners
+ canvas.drawRoundRect(0, 0, getWidth(), getHeight(),
+ mConfig.taskViewRoundedCornerRadiusPx,
+ mConfig.taskViewRoundedCornerRadiusPx, mDrawPaint);
}
- @Override
- protected void onFinishInflate() {
- mBitmapAlpha = 0.9f;
- updateFilter();
+ /** Sets the thumbnail to a given bitmap. */
+ void setThumbnail(Bitmap bm) {
+ if (bm != null) {
+ mBitmapShader = new BitmapShader(bm, Shader.TileMode.CLAMP,
+ Shader.TileMode.CLAMP);
+ mDrawPaint.setShader(mBitmapShader);
+ mBitmapRect.set(0, 0, bm.getWidth(), bm.getHeight());
+ updateThumbnailScale();
+ } else {
+ mBitmapShader = null;
+ mDrawPaint.setShader(null);
+ }
+ updateThumbnailPaintFilter();
}
- private void updateFilter() {
+ /** Updates the paint to draw the thumbnail. */
+ void updateThumbnailPaintFilter() {
if (mInvisible) {
return;
}
- int mul = (int) ((1.0f - mDimAlpha) * mBitmapAlpha * 255);
- int add = (int) ((1.0f - mDimAlpha) * (1 - mBitmapAlpha) * 255);
+ int mul = (int) ((1.0f - mDimAlpha) * mThumbnailAlpha * 255);
+ int add = (int) ((1.0f - mDimAlpha) * (1 - mThumbnailAlpha) * 255);
if (mBitmapShader != null) {
mLightingColorFilter.setColorMultiply(Color.argb(255, mul, mul, mul));
mLightingColorFilter.setColorAdd(Color.argb(0, add, add, add));
mDrawPaint.setColorFilter(mLightingColorFilter);
mDrawPaint.setColor(0xffffffff);
} else {
- mDrawPaint.setColorFilter(null);
int grey = mul + add;
+ mDrawPaint.setColorFilter(null);
mDrawPaint.setColor(Color.argb(255, grey, grey, grey));
}
invalidate();
}
+ /** Updates the thumbnail shader's scale transform. */
+ void updateThumbnailScale() {
+ if (mBitmapShader != null) {
+ mScaleMatrix.setRectToRect(mBitmapRect, mLayoutRect, Matrix.ScaleToFit.FILL);
+ mBitmapShader.setLocalMatrix(mScaleMatrix);
+ }
+ }
+
/** Updates the clip rect based on the given task bar. */
- void enableTaskBarClip(View taskBar) {
+ void updateClipToTaskBar(View taskBar) {
mTaskBar = taskBar;
int top = (int) Math.max(0, taskBar.getTranslationY() +
taskBar.getMeasuredHeight() - 1);
@@ -133,75 +173,39 @@ public class TaskViewThumbnail extends View {
setClipBounds(mClipRect);
}
- void updateVisibility(int clipBottom) {
- boolean invisible = mTaskBar != null && getHeight() - clipBottom < mTaskBar.getHeight();
+ /** Updates the visibility of the the thumbnail. */
+ void updateThumbnailVisibility(int clipBottom) {
+ boolean invisible = mTaskBar != null && (getHeight() - clipBottom) <= mTaskBar.getHeight();
if (invisible != mInvisible) {
mInvisible = invisible;
if (!mInvisible) {
- updateFilter();
+ updateThumbnailPaintFilter();
}
invalidate();
}
}
- /** Binds the thumbnail view to the screenshot. */
- boolean bindToScreenshot(Bitmap ss) {
- setImageBitmap(ss);
- return ss != null;
- }
-
- /** Unbinds the thumbnail view from the screenshot. */
- void unbindFromScreenshot() {
- setImageBitmap(null);
+ /**
+ * Sets the dim alpha, only used when we are not using hardware layers.
+ * (see RecentsConfiguration.useHardwareLayers)
+ */
+ public void setDimAlpha(float dimAlpha) {
+ mDimAlpha = dimAlpha;
+ updateThumbnailPaintFilter();
}
/** Binds the thumbnail view to the task */
void rebindToTask(Task t) {
if (t.thumbnail != null) {
- setImageBitmap(t.thumbnail);
+ setThumbnail(t.thumbnail);
} else {
- setImageBitmap(null);
+ setThumbnail(null);
}
}
- public void setImageBitmap(Bitmap bm) {
- if (bm != null) {
- mBitmapShader = new BitmapShader(bm, Shader.TileMode.CLAMP,
- Shader.TileMode.CLAMP);
- mDrawPaint.setShader(mBitmapShader);
- mBitmapRect.set(0, 0, bm.getWidth(), bm.getHeight());
- updateBitmapScale();
- } else {
- mBitmapShader = null;
- mDrawPaint.setShader(null);
- }
- updateFilter();
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- super.onLayout(changed, left, top, right, bottom);
- if (changed) {
- mLayoutRect.set(0, 0, getWidth(), getHeight());
- updateBitmapScale();
- }
- }
-
- private void updateBitmapScale() {
- if (mBitmapShader != null) {
- mScaleMatrix.setRectToRect(mBitmapRect, mLayoutRect, Matrix.ScaleToFit.FILL);
- mBitmapShader.setLocalMatrix(mScaleMatrix);
- }
- }
-
- public void setDimAlpha(float dimAlpha) {
- mDimAlpha = dimAlpha;
- updateFilter();
- }
-
/** Unbinds the thumbnail view from the task */
void unbindFromTask() {
- setImageBitmap(null);
+ setThumbnail(null);
}
/** Handles focus changes. */
@@ -217,54 +221,46 @@ public class TaskViewThumbnail extends View {
}
}
- /** Prepares for the enter recents animation. */
+ /**
+ * Prepares for the enter recents animation, this gets called before the the view
+ * is first visible and will be followed by a startEnterRecentsAnimation() call.
+ */
void prepareEnterRecentsAnimation(boolean isTaskViewLaunchTargetTask) {
if (isTaskViewLaunchTargetTask) {
- mBitmapAlpha = 1f;
+ mThumbnailAlpha = 1f;
} else {
- mBitmapAlpha = mConfig.taskViewThumbnailAlpha;
+ mThumbnailAlpha = mConfig.taskViewThumbnailAlpha;
}
- updateFilter();
+ updateThumbnailPaintFilter();
}
- /** Animates this task thumbnail as it enters recents */
+ /** Animates this task thumbnail as it enters Recents. */
void startEnterRecentsAnimation(int delay, Runnable postAnimRunnable) {
startFadeAnimation(mConfig.taskViewThumbnailAlpha, delay,
mConfig.taskBarEnterAnimDuration, postAnimRunnable);
}
- /** Animates this task thumbnail as it exits recents */
+ /** Animates this task thumbnail as it exits Recents. */
void startLaunchTaskAnimation(Runnable postAnimRunnable) {
startFadeAnimation(1f, 0, mConfig.taskBarExitAnimDuration, postAnimRunnable);
}
- /** Animates the thumbnail alpha. */
+ /** Starts a new thumbnail alpha animation. */
void startFadeAnimation(float finalAlpha, int delay, int duration, final Runnable postAnimRunnable) {
- if (mAlphaAnimator != null) {
- mAlphaAnimator.cancel();
- }
- mAlphaAnimator = ValueAnimator.ofFloat(mBitmapAlpha, finalAlpha);
- mAlphaAnimator.addUpdateListener(mAlphaUpdateListener);
- mAlphaAnimator.setStartDelay(delay);
- mAlphaAnimator.setInterpolator(mConfig.fastOutSlowInInterpolator);
- mAlphaAnimator.setDuration(duration);
- mAlphaAnimator.start();
+ Utilities.cancelAnimationWithoutCallbacks(mThumbnailAlphaAnimator);
+ mThumbnailAlphaAnimator = ValueAnimator.ofFloat(mThumbnailAlpha, finalAlpha);
+ mThumbnailAlphaAnimator.setStartDelay(delay);
+ mThumbnailAlphaAnimator.setDuration(duration);
+ mThumbnailAlphaAnimator.setInterpolator(mConfig.fastOutSlowInInterpolator);
+ mThumbnailAlphaAnimator.addUpdateListener(mThumbnailAlphaUpdateListener);
if (postAnimRunnable != null) {
- mAlphaAnimator.addListener(new AnimatorListenerAdapter() {
- public boolean mCancelled;
-
- @Override
- public void onAnimationCancel(Animator animation) {
- mCancelled = true;
- }
-
+ mThumbnailAlphaAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- if (!mCancelled) {
- postAnimRunnable.run();
- }
+ postAnimRunnable.run();
}
});
}
+ mThumbnailAlphaAnimator.start();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/ViewPool.java b/packages/SystemUI/src/com/android/systemui/recents/views/ViewPool.java
index af0094e..12b91af 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/ViewPool.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/ViewPool.java
@@ -75,4 +75,12 @@ public class ViewPool<V, T> {
mViewCreator.prepareViewToLeavePool(v, prepareData, isNewView);
return v;
}
+
+ /** Returns an iterator to the list of the views in the pool. */
+ Iterator<V> poolViewIterator() {
+ if (mPool != null) {
+ return mPool.iterator();
+ }
+ return null;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
index e4faa6a..02b9378 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
@@ -508,7 +508,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
if (mAppearAnimator != null) {
mAppearAnimator.cancel();
}
- mAnimationTranslationY = translationDirection * mActualHeight;
+ mAnimationTranslationY = translationDirection * getActualHeight();
if (mAppearAnimationFraction == -1.0f) {
// not initialized yet, we start anew
if (isAppearing) {
@@ -601,14 +601,15 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
float top;
float bottom;
+ final int actualHeight = getActualHeight();
if (mAnimationTranslationY > 0.0f) {
- bottom = mActualHeight - heightFraction * mAnimationTranslationY * 0.1f
+ bottom = actualHeight - heightFraction * mAnimationTranslationY * 0.1f
- translateYTotalAmount;
top = bottom * heightFraction;
} else {
- top = heightFraction * (mActualHeight + mAnimationTranslationY) * 0.1f -
+ top = heightFraction * (actualHeight + mAnimationTranslationY) * 0.1f -
translateYTotalAmount;
- bottom = mActualHeight * (1 - heightFraction) + top * heightFraction;
+ bottom = actualHeight * (1 - heightFraction) + top * heightFraction;
}
mAppearAnimationRect.set(left, top, right, bottom);
setOutlineRect(left, top + mAppearAnimationTranslation, right,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index f5e5517..725a1a8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -69,6 +69,7 @@ import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
+import android.view.ViewParent;
import android.view.ViewStub;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
@@ -112,6 +113,9 @@ public abstract class BaseStatusBar extends SystemUI implements
public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
public static final boolean MULTIUSER_DEBUG = false;
+ // STOPSHIP disable once we resolve b/18102199
+ private static final boolean NOTIFICATION_CLICK_DEBUG = true;
+
protected static final int MSG_SHOW_RECENT_APPS = 1019;
protected static final int MSG_HIDE_RECENT_APPS = 1020;
protected static final int MSG_TOGGLE_RECENTS_APPS = 1021;
@@ -154,9 +158,6 @@ public abstract class BaseStatusBar extends SystemUI implements
protected HeadsUpNotificationView mHeadsUpNotificationView;
protected int mHeadsUpNotificationDecay;
- // used to notify status bar for suppressing notification LED
- protected boolean mPanelSlightlyVisible;
-
// Search panel
protected SearchPanelView mSearchPanelView;
@@ -168,6 +169,20 @@ public abstract class BaseStatusBar extends SystemUI implements
// on-screen navigation buttons
protected NavigationBarView mNavigationBarView = null;
+
+ protected Boolean mScreenOn;
+
+ // The second field is a bit different from the first one because it only listens to screen on/
+ // screen of events from Keyguard. We need this so we don't have a race condition with the
+ // broadcast. In the future, we should remove the first field altogether and rename the second
+ // field.
+ protected boolean mScreenOnFromKeyguard;
+
+ protected boolean mVisible;
+
+ // mScreenOnFromKeyguard && mVisible.
+ private boolean mVisibleToUser;
+
private Locale mLocale;
private float mFontScale;
@@ -266,6 +281,7 @@ public abstract class BaseStatusBar extends SystemUI implements
if (DEBUG) {
Log.v(TAG, "Notification click handler invoked for intent: " + pendingIntent);
}
+ logActionClick(view);
// The intent we are sending is for the application, which
// won't have permission to immediately start an activity after
// the user switches to home. We know it is safe to do at this
@@ -295,7 +311,8 @@ public abstract class BaseStatusBar extends SystemUI implements
// close the shade if it was open
if (handled) {
- animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
+ animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL,
+ true /* force */);
visibilityChanged(false);
}
// Wait for activity start.
@@ -308,6 +325,40 @@ public abstract class BaseStatusBar extends SystemUI implements
}
}
+ private void logActionClick(View view) {
+ ViewParent parent = view.getParent();
+ String key = getNotificationKeyForParent(parent);
+ if (key == null) {
+ Log.w(TAG, "Couldn't determine notification for click.");
+ return;
+ }
+ int index = -1;
+ // If this is a default template, determine the index of the button.
+ if (view.getId() == com.android.internal.R.id.action0 &&
+ parent != null && parent instanceof ViewGroup) {
+ ViewGroup actionGroup = (ViewGroup) parent;
+ index = actionGroup.indexOfChild(view);
+ }
+ if (NOTIFICATION_CLICK_DEBUG) {
+ Log.d(TAG, "Clicked on button " + index + " for " + key);
+ }
+ try {
+ mBarService.onNotificationActionClick(key, index);
+ } catch (RemoteException e) {
+ // Ignore
+ }
+ }
+
+ private String getNotificationKeyForParent(ViewParent parent) {
+ while (parent != null) {
+ if (parent instanceof ExpandableNotificationRow) {
+ return ((ExpandableNotificationRow) parent).getStatusBarNotification().getKey();
+ }
+ parent = parent.getParent();
+ }
+ return null;
+ }
+
private boolean superOnClickHandler(View view, PendingIntent pendingIntent,
Intent fillInIntent) {
return super.onClickHandler(view, pendingIntent, fillInIntent);
@@ -341,7 +392,8 @@ public abstract class BaseStatusBar extends SystemUI implements
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0);
if (BANNER_ACTION_SETUP.equals(action)) {
- animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
+ animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL,
+ true /* force */);
mContext.startActivity(new Intent(Settings.ACTION_APP_NOTIFICATION_REDACTION)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
@@ -766,7 +818,7 @@ public abstract class BaseStatusBar extends SystemUI implements
}
}
});
- animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
+ animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */);
return true;
}
}, false /* afterKeyguardGone */);
@@ -1480,6 +1532,9 @@ public abstract class BaseStatusBar extends SystemUI implements
}
public void onClick(final View v) {
+ if (NOTIFICATION_CLICK_DEBUG) {
+ Log.d(TAG, "Clicked on content of " + mNotificationKey);
+ }
final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
final boolean afterKeyguardGone = mIntent.isActivity()
&& PreviewInflater.wouldLaunchResolverActivity(mContext, mIntent.getIntent(),
@@ -1531,7 +1586,8 @@ public abstract class BaseStatusBar extends SystemUI implements
}.start();
// close the shade if it was open
- animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
+ animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL,
+ true /* force */);
visibilityChanged(false);
return mIntent != null && mIntent.isActivity();
@@ -1553,28 +1609,41 @@ public abstract class BaseStatusBar extends SystemUI implements
}
}
+ protected void visibilityChanged(boolean visible) {
+ if (mVisible != visible) {
+ mVisible = visible;
+ if (!visible) {
+ dismissPopups();
+ }
+ }
+ updateVisibleToUser();
+ }
+
+ protected void updateVisibleToUser() {
+ boolean oldVisibleToUser = mVisibleToUser;
+ mVisibleToUser = mVisible && mScreenOnFromKeyguard;
+
+ if (oldVisibleToUser != mVisibleToUser) {
+ handleVisibleToUserChanged(mVisibleToUser);
+ }
+ }
+
/**
- * The LEDs are turned o)ff when the notification panel is shown, even just a little bit.
+ * The LEDs are turned off when the notification panel is shown, even just a little bit.
* This was added last-minute and is inconsistent with the way the rest of the notifications
* are handled, because the notification isn't really cancelled. The lights are just
* turned off. If any other notifications happen, the lights will turn back on. Steve says
* this is what he wants. (see bug 1131461)
*/
- protected void visibilityChanged(boolean visible) {
- if (mPanelSlightlyVisible != visible) {
- mPanelSlightlyVisible = visible;
- if (!visible) {
- dismissPopups();
- }
- try {
- if (visible) {
- mBarService.onPanelRevealed();
- } else {
- mBarService.onPanelHidden();
- }
- } catch (RemoteException ex) {
- // Won't fail unless the world has ended.
+ protected void handleVisibleToUserChanged(boolean visibleToUser) {
+ try {
+ if (visibleToUser) {
+ mBarService.onPanelRevealed();
+ } else {
+ mBarService.onPanelHidden();
}
+ } catch (RemoteException ex) {
+ // Won't fail unless the world has ended.
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index 9db875f..0b1b883 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -56,6 +56,7 @@ public class CommandQueue extends IStatusBar.Stub {
private static final int MSG_BUZZ_BEEP_BLINKED = 15 << MSG_SHIFT;
private static final int MSG_NOTIFICATION_LIGHT_OFF = 16 << MSG_SHIFT;
private static final int MSG_NOTIFICATION_LIGHT_PULSE = 17 << MSG_SHIFT;
+ private static final int MSG_SHOW_SCREEN_PIN_REQUEST = 18 << MSG_SHIFT;
public static final int FLAG_EXCLUDE_NONE = 0;
public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -97,6 +98,7 @@ public class CommandQueue extends IStatusBar.Stub {
public void buzzBeepBlinked();
public void notificationLightOff();
public void notificationLightPulse(int argb, int onMillis, int offMillis);
+ public void showScreenPinningRequest();
}
public CommandQueue(Callbacks callbacks, StatusBarIconList list) {
@@ -238,6 +240,12 @@ public class CommandQueue extends IStatusBar.Stub {
}
}
+ public void showScreenPinningRequest() {
+ synchronized (mList) {
+ mHandler.sendEmptyMessage(MSG_SHOW_SCREEN_PIN_REQUEST);
+ }
+ }
+
private final class H extends Handler {
public void handleMessage(Message msg) {
final int what = msg.what & MSG_MASK;
@@ -317,6 +325,9 @@ public class CommandQueue extends IStatusBar.Stub {
case MSG_NOTIFICATION_LIGHT_PULSE:
mCallbacks.notificationLightPulse((Integer) msg.obj, msg.arg1, msg.arg2);
break;
+ case MSG_SHOW_SCREEN_PIN_REQUEST:
+ mCallbacks.showScreenPinningRequest();
+ break;
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java b/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java
index 897dbf2..479c2fb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java
@@ -36,4 +36,11 @@ public class DismissView extends StackScrollerDecorView {
public void setOnButtonClickListener(OnClickListener listener) {
mContent.setOnClickListener(listener);
}
+
+ public boolean isOnEmptySpace(float touchX, float touchY) {
+ return touchX < mContent.getX()
+ || touchX > mContent.getX() + mContent.getWidth()
+ || touchY < mContent.getY()
+ || touchY > mContent.getY() + mContent.getHeight();
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewImageButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewImageButton.java
index d55b0b3..35fd688 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewImageButton.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewImageButton.java
@@ -61,4 +61,9 @@ public class DismissViewImageButton extends ImageButton {
outRect.top += translationY;
outRect.bottom += translationY;
}
+
+ @Override
+ public boolean hasOverlappingRendering() {
+ return false;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 9196dc8..f8332ea 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -22,11 +22,10 @@ import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.service.notification.StatusBarNotification;
import android.util.AttributeSet;
+import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.accessibility.AccessibilityEvent;
-
import android.widget.ImageView;
import com.android.systemui.R;
@@ -70,6 +69,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
private NotificationGuts mGuts;
private StatusBarNotification mStatusBarNotification;
+ private boolean mIsHeadsUp;
public void setIconAnimationRunning(boolean running) {
setIconAnimationRunning(running, mPublicLayout);
@@ -124,6 +124,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
return mStatusBarNotification;
}
+ public void setHeadsUp(boolean isHeadsUp) {
+ mIsHeadsUp = isHeadsUp;
+ }
+
public interface ExpansionLogger {
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
}
@@ -149,13 +153,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
mShowingPublicInitialized = false;
mIsSystemExpanded = false;
mExpansionDisabled = false;
- mPublicLayout.reset();
- mPrivateLayout.reset();
+ mPublicLayout.reset(mIsHeadsUp);
+ mPrivateLayout.reset(mIsHeadsUp);
resetHeight();
logExpansionEvent(false, wasExpanded);
}
public void resetHeight() {
+ if (mIsHeadsUp) {
+ resetActualHeight();
+ }
mMaxExpandHeight = 0;
mWasReset = true;
onHeightReset();
@@ -163,6 +170,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
}
@Override
+ protected boolean filterMotionEvent(MotionEvent event) {
+ return mIsHeadsUp || super.filterMotionEvent(event);
+ }
+
+ @Override
protected void onFinishInflate() {
super.onFinishInflate();
mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java
index f85d32b..a18fff2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java
@@ -41,7 +41,7 @@ public abstract class ExpandableOutlineView extends ExpandableView {
outline.setRect(0,
mClipTopAmount,
getWidth(),
- Math.max(mActualHeight, mClipTopAmount));
+ Math.max(getActualHeight(), mClipTopAmount));
} else {
outline.setRect(mOutlineRect);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
index c8f756e..bf1e78e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
@@ -36,7 +36,7 @@ public abstract class ExpandableView extends FrameLayout {
private final int mMaxNotificationHeight;
private OnHeightChangedListener mOnHeightChangedListener;
- protected int mActualHeight;
+ private int mActualHeight;
protected int mClipTopAmount;
private boolean mActualHeightInitialized;
private ArrayList<View> mMatchParentViews = new ArrayList<View>();
@@ -103,6 +103,15 @@ public abstract class ExpandableView extends FrameLayout {
}
}
+ /**
+ * Resets the height of the view on the next layout pass
+ */
+ protected void resetActualHeight() {
+ mActualHeight = 0;
+ mActualHeightInitialized = false;
+ requestLayout();
+ }
+
protected int getInitialHeight() {
return getHeight();
}
@@ -115,7 +124,7 @@ public abstract class ExpandableView extends FrameLayout {
return false;
}
- private boolean filterMotionEvent(MotionEvent event) {
+ protected boolean filterMotionEvent(MotionEvent event) {
return event.getActionMasked() != MotionEvent.ACTION_DOWN
|| event.getY() > mClipTopAmount && event.getY() < mActualHeight;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
index ce35e4b..58067c3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
@@ -146,8 +146,8 @@ public class KeyguardIndicationController {
try {
long chargingTimeRemaining = mBatteryInfo.computeChargeTimeRemaining();
if (chargingTimeRemaining > 0) {
- String chargingTimeFormatted =
- Formatter.formatShortElapsedTime(mContext, chargingTimeRemaining);
+ String chargingTimeFormatted = Formatter.formatShortElapsedTimeRoundingUpToMinutes(
+ mContext, chargingTimeRemaining);
return mContext.getResources().getString(
R.string.keyguard_indication_charging_time, chargingTimeFormatted);
}
@@ -162,8 +162,9 @@ public class KeyguardIndicationController {
KeyguardUpdateMonitorCallback mUpdateMonitor = new KeyguardUpdateMonitorCallback() {
@Override
public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) {
- mPowerPluggedIn = status.status == BatteryManager.BATTERY_STATUS_CHARGING
+ boolean isChargingOrFull = status.status == BatteryManager.BATTERY_STATUS_CHARGING
|| status.status == BatteryManager.BATTERY_STATUS_FULL;
+ mPowerPluggedIn = status.isPluggedIn() && isChargingOrFull;
mPowerCharged = status.isCharged();
updateIndication();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationBackgroundView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationBackgroundView.java
index 5db680a..0fc46e9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationBackgroundView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationBackgroundView.java
@@ -23,9 +23,7 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.util.AttributeSet;
-import android.view.MotionEvent;
import android.view.View;
-import com.android.systemui.R;
/**
* A view that can be used for both the dimmed and normal background of an notification.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index 502490f..99214a0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -27,11 +27,11 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
+import android.view.ViewTreeObserver;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
-
import com.android.systemui.R;
/**
@@ -60,11 +60,21 @@ public class NotificationContentView extends FrameLayout {
private boolean mDark;
private final Paint mFadePaint = new Paint();
+ private boolean mAnimate;
+ private ViewTreeObserver.OnPreDrawListener mEnableAnimationPredrawListener
+ = new ViewTreeObserver.OnPreDrawListener() {
+ @Override
+ public boolean onPreDraw() {
+ mAnimate = true;
+ getViewTreeObserver().removeOnPreDrawListener(this);
+ return true;
+ }
+ };
public NotificationContentView(Context context, AttributeSet attrs) {
super(context, attrs);
mFadePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.ADD));
- reset();
+ reset(true);
}
@Override
@@ -73,7 +83,13 @@ public class NotificationContentView extends FrameLayout {
updateClipping();
}
- public void reset() {
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ updateVisibility();
+ }
+
+ public void reset(boolean resetActualHeight) {
if (mContractedChild != null) {
mContractedChild.animate().cancel();
}
@@ -84,8 +100,10 @@ public class NotificationContentView extends FrameLayout {
mContractedChild = null;
mExpandedChild = null;
mSmallHeight = getResources().getDimensionPixelSize(R.dimen.notification_min_height);
- mActualHeight = mSmallHeight;
mContractedVisible = true;
+ if (resetActualHeight) {
+ mActualHeight = mSmallHeight;
+ }
}
public View getContractedChild() {
@@ -117,9 +135,31 @@ public class NotificationContentView extends FrameLayout {
selectLayout(false /* animate */, true /* force */);
}
+ @Override
+ protected void onVisibilityChanged(View changedView, int visibility) {
+ super.onVisibilityChanged(changedView, visibility);
+ updateVisibility();
+ }
+
+ private void updateVisibility() {
+ setVisible(isShown());
+ }
+
+ private void setVisible(final boolean isVisible) {
+ if (isVisible) {
+
+ // We only animate if we are drawn at least once, otherwise the view might animate when
+ // it's shown the first time
+ getViewTreeObserver().addOnPreDrawListener(mEnableAnimationPredrawListener);
+ } else {
+ getViewTreeObserver().removeOnPreDrawListener(mEnableAnimationPredrawListener);
+ mAnimate = false;
+ }
+ }
+
public void setActualHeight(int actualHeight) {
mActualHeight = actualHeight;
- selectLayout(true /* animate */, false /* force */);
+ selectLayout(mAnimate /* animate */, false /* force */);
updateClipping();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
index b71c9bf..9154a48 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
@@ -49,7 +49,6 @@ public class SignalClusterView
private boolean mIsAirplaneMode = false;
private int mAirplaneIconId = 0;
private String mWifiDescription, mMobileDescription, mMobileTypeDescription;
- private boolean mRoaming;
private boolean mIsMobileTypeIconWide;
ViewGroup mWifiGroup, mMobileGroup;
@@ -58,6 +57,8 @@ public class SignalClusterView
View mWifiSignalSpacer;
private int mWideTypeIconStartPadding;
+ private int mEndPadding;
+ private int mEndPaddingNothingVisible;
public SignalClusterView(Context context) {
this(context, null);
@@ -88,6 +89,10 @@ public class SignalClusterView
super.onFinishInflate();
mWideTypeIconStartPadding = getContext().getResources().getDimensionPixelSize(
R.dimen.wide_type_icon_start_padding);
+ mEndPadding = getContext().getResources().getDimensionPixelSize(
+ R.dimen.signal_cluster_battery_padding);
+ mEndPaddingNothingVisible = getContext().getResources().getDimensionPixelSize(
+ R.dimen.no_signal_cluster_battery_padding);
}
@Override
@@ -143,14 +148,12 @@ public class SignalClusterView
@Override
public void setMobileDataIndicators(boolean visible, int strengthIcon, int typeIcon,
- String contentDescription, String typeContentDescription, boolean roaming,
- boolean isTypeIconWide) {
+ String contentDescription, String typeContentDescription, boolean isTypeIconWide) {
mMobileVisible = visible;
mMobileStrengthId = strengthIcon;
mMobileTypeId = typeIcon;
mMobileDescription = contentDescription;
mMobileTypeDescription = typeContentDescription;
- mRoaming = roaming;
mIsMobileTypeIconWide = isTypeIconWide;
apply();
@@ -244,7 +247,7 @@ public class SignalClusterView
mWifiAirplaneSpacer.setVisibility(View.GONE);
}
- if (mRoaming && mMobileVisible && mWifiVisible) {
+ if (mMobileVisible && mMobileTypeId != 0 && mWifiVisible) {
mWifiSignalSpacer.setVisibility(View.VISIBLE);
} else {
mWifiSignalSpacer.setVisibility(View.GONE);
@@ -257,7 +260,10 @@ public class SignalClusterView
(mMobileVisible ? "VISIBLE" : "GONE"),
mMobileStrengthId, mMobileTypeId));
- mMobileType.setVisibility((mRoaming || mMobileTypeId != 0) ? View.VISIBLE : View.GONE);
+ mMobileType.setVisibility(mMobileTypeId != 0 ? View.VISIBLE : View.GONE);
+
+ boolean anythingVisible = mWifiVisible || mIsAirplaneMode || mMobileVisible || mVpnVisible;
+ setPaddingRelative(0, 0, anythingVisible ? mEndPadding : mEndPaddingNothingVisible, 0);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
index 32fb567..e89e15d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
@@ -45,6 +45,7 @@ public class BarTransitions {
public static final int MODE_LIGHTS_OUT = 3;
public static final int MODE_TRANSPARENT = 4;
public static final int MODE_WARNING = 5;
+ public static final int MODE_LIGHTS_OUT_TRANSPARENT = 6;
public static final int LIGHTS_IN_DURATION = 250;
public static final int LIGHTS_OUT_DURATION = 750;
@@ -75,6 +76,9 @@ public class BarTransitions {
|| mode == MODE_TRANSPARENT)) {
mode = MODE_OPAQUE;
}
+ if (!HIGH_END && (mode == MODE_LIGHTS_OUT_TRANSPARENT)) {
+ mode = MODE_LIGHTS_OUT;
+ }
if (mMode == mode) return;
int oldMode = mMode;
mMode = mode;
@@ -102,6 +106,7 @@ public class BarTransitions {
if (mode == MODE_LIGHTS_OUT) return "MODE_LIGHTS_OUT";
if (mode == MODE_TRANSPARENT) return "MODE_TRANSPARENT";
if (mode == MODE_WARNING) return "MODE_WARNING";
+ if (mode == MODE_LIGHTS_OUT_TRANSPARENT) return "MODE_LIGHTS_OUT_TRANSPARENT";
throw new IllegalArgumentException("Unknown mode " + mode);
}
@@ -109,6 +114,10 @@ public class BarTransitions {
mBarBackground.finishAnimation();
}
+ protected boolean isLightsOut(int mode) {
+ return mode == MODE_LIGHTS_OUT || mode == MODE_LIGHTS_OUT_TRANSPARENT;
+ }
+
private static class BarBackgroundDrawable extends Drawable {
private final int mOpaque;
private final int mSemiTransparent;
@@ -196,7 +205,7 @@ public class BarTransitions {
targetColor = mSemiTransparent;
} else if (mMode == MODE_SEMI_TRANSPARENT) {
targetColor = mSemiTransparent;
- } else if (mMode == MODE_TRANSPARENT) {
+ } else if (mMode == MODE_TRANSPARENT || mMode == MODE_LIGHTS_OUT_TRANSPARENT) {
targetColor = mTransparent;
} else {
targetColor = mOpaque;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java
index c5d06b9..6cb5bcc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java
@@ -122,9 +122,14 @@ public class DemoStatusIcons extends LinearLayout implements DemoMode {
}
String cast = args.getString("cast");
if (cast != null) {
- int iconId = cast.equals("cast") ? R.drawable.stat_sys_cast : 0;
+ int iconId = cast.equals("show") ? R.drawable.stat_sys_cast : 0;
updateSlot("cast", null, iconId);
}
+ String hotspot = args.getString("hotspot");
+ if (hotspot != null) {
+ int iconId = hotspot.equals("show") ? R.drawable.stat_sys_hotspot : 0;
+ updateSlot("hotspot", null, iconId);
+ }
}
}
@@ -154,7 +159,7 @@ public class DemoStatusIcons extends LinearLayout implements DemoMode {
}
}
StatusBarIcon icon = new StatusBarIcon(iconPkg, UserHandle.CURRENT, iconId, 0, 0, "Demo");
- StatusBarIconView v = new StatusBarIconView(getContext(), null);
+ StatusBarIconView v = new StatusBarIconView(getContext(), null, null);
v.setTag(slot);
v.set(icon);
addView(v, 0, new LinearLayout.LayoutParams(mIconSize, mIconSize));
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java
index b566bbc..6fd6758 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java
@@ -48,6 +48,7 @@ public class DozeParameters {
pw.print(" getDisplayStateSupported(): "); pw.println(getDisplayStateSupported());
pw.print(" getPulseDuration(): "); pw.println(getPulseDuration());
pw.print(" getPulseInDuration(): "); pw.println(getPulseInDuration());
+ pw.print(" getPulseInDelay(): "); pw.println(getPulseInDelay());
pw.print(" getPulseInVisibleDuration(): "); pw.println(getPulseVisibleDuration());
pw.print(" getPulseOutDuration(): "); pw.println(getPulseOutDuration());
pw.print(" getPulseOnSigMotion(): "); pw.println(getPulseOnSigMotion());
@@ -72,6 +73,10 @@ public class DozeParameters {
return getInt("doze.pulse.duration.in", R.integer.doze_pulse_duration_in);
}
+ public int getPulseInDelay() {
+ return getInt("doze.pulse.delay.in", R.integer.doze_pulse_delay_in);
+ }
+
public int getPulseVisibleDuration() {
return getInt("doze.pulse.duration.visible", R.integer.doze_pulse_duration_visible);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index dd5df12..fddbee2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -39,6 +39,8 @@ import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
+import android.view.animation.AnimationUtils;
+import android.view.animation.Interpolator;
import android.widget.FrameLayout;
import android.widget.TextView;
@@ -72,6 +74,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
private static final Intent INSECURE_CAMERA_INTENT =
new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
private static final Intent PHONE_INTENT = new Intent(Intent.ACTION_DIAL);
+ private static final int DOZE_ANIMATION_STAGGER_DELAY = 48;
+ private static final int DOZE_ANIMATION_ELEMENT_DURATION = 250;
private KeyguardAffordanceView mCameraImageView;
private KeyguardAffordanceView mPhoneImageView;
@@ -92,7 +96,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
private PhoneStatusBar mPhoneStatusBar;
private final TrustDrawable mTrustDrawable;
-
+ private final Interpolator mLinearOutSlowInInterpolator;
private int mLastUnlockIconRes = 0;
public KeyguardBottomAreaView(Context context) {
@@ -111,6 +115,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
mTrustDrawable = new TrustDrawable(mContext);
+ mLinearOutSlowInInterpolator =
+ AnimationUtils.loadInterpolator(context, android.R.interpolator.linear_out_slow_in);
}
private AccessibilityDelegate mAccessibilityDelegate = new AccessibilityDelegate() {
@@ -133,7 +139,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
if (action == ACTION_CLICK) {
if (host == mLockIcon) {
mPhoneStatusBar.animateCollapsePanels(
- CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
+ CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */);
return true;
} else if (host == mCameraImageView) {
launchCamera();
@@ -450,6 +456,35 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
}
}
+ public void startFinishDozeAnimation() {
+ long delay = 0;
+ if (mPhoneImageView.getVisibility() == View.VISIBLE) {
+ startFinishDozeAnimationElement(mPhoneImageView, delay);
+ delay += DOZE_ANIMATION_STAGGER_DELAY;
+ }
+ startFinishDozeAnimationElement(mLockIcon, delay);
+ delay += DOZE_ANIMATION_STAGGER_DELAY;
+ if (mCameraImageView.getVisibility() == View.VISIBLE) {
+ startFinishDozeAnimationElement(mCameraImageView, delay);
+ }
+ mIndicationText.setAlpha(0f);
+ mIndicationText.animate()
+ .alpha(1f)
+ .setInterpolator(mLinearOutSlowInInterpolator)
+ .setDuration(NotificationPanelView.DOZE_ANIMATION_DURATION);
+ }
+
+ private void startFinishDozeAnimationElement(View element, long delay) {
+ element.setAlpha(0f);
+ element.setTranslationY(element.getHeight() / 2);
+ element.animate()
+ .alpha(1f)
+ .translationY(0f)
+ .setInterpolator(mLinearOutSlowInInterpolator)
+ .setStartDelay(delay)
+ .setDuration(DOZE_ANIMATION_ELEMENT_DURATION);
+ }
+
private final BroadcastReceiver mDevicePolicyReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
post(new Runnable() {
@@ -477,6 +512,11 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
public void onScreenTurnedOff(int why) {
updateLockIcon();
}
+
+ @Override
+ public void onKeyguardVisibilityChanged(boolean showing) {
+ updateLockIcon();
+ }
};
public void setKeyguardIndicationController(
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
index 650a14f..40c9134 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
@@ -36,6 +36,8 @@ import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
import com.android.systemui.statusbar.policy.UserInfoController;
+import java.text.NumberFormat;
+
/**
* The header group on Keyguard.
*/
@@ -150,7 +152,8 @@ public class KeyguardStatusBarView extends RelativeLayout
@Override
public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
- mBatteryLevel.setText(getResources().getString(R.string.battery_level_template, level));
+ String percentage = NumberFormat.getPercentInstance().format((double) level / 100.0);
+ mBatteryLevel.setText(percentage);
boolean changed = mBatteryCharging != charging;
mBatteryCharging = charging;
if (changed) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java
index f3930ba..15f6dc2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java
@@ -84,7 +84,7 @@ public final class NavigationBarTransitions extends BarTransitions {
applyBackButtonQuiescentAlpha(mode, animate);
// apply to lights out
- applyLightsOut(mode == MODE_LIGHTS_OUT, animate, force);
+ applyLightsOut(isLightsOut(mode), animate, force);
}
private float alphaForMode(int mode) {
@@ -171,7 +171,8 @@ public final class NavigationBarTransitions extends BarTransitions {
applyLightsOut(false, false, false);
try {
- mBarService.setSystemUiVisibility(0, View.SYSTEM_UI_FLAG_LOW_PROFILE);
+ mBarService.setSystemUiVisibility(0, View.SYSTEM_UI_FLAG_LOW_PROFILE,
+ "LightsOutListener");
} catch (android.os.RemoteException ex) {
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 88e71e2..1e4dfb4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -21,6 +21,7 @@ import android.animation.LayoutTransition.TransitionListener;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
+import android.app.ActivityManagerNative;
import android.app.StatusBarManager;
import android.content.Context;
import android.content.res.Configuration;
@@ -30,17 +31,21 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
+import android.os.RemoteException;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Display;
+import android.view.Gravity;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
+import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
+
import com.android.systemui.R;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.DelegateViewHelper;
@@ -330,7 +335,7 @@ public class NavigationBarView extends LinearLayout {
mDisabledFlags = disabledFlags;
final boolean disableHome = ((disabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0);
- final boolean disableRecent = ((disabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0);
+ boolean disableRecent = ((disabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0);
final boolean disableBack = ((disabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0)
&& ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) == 0);
final boolean disableSearch = ((disabledFlags & View.STATUS_BAR_DISABLE_SEARCH) != 0);
@@ -355,6 +360,11 @@ public class NavigationBarView extends LinearLayout {
}
}
}
+ if (inLockTask() && disableRecent && !disableHome) {
+ // Don't hide recents when in lock task, it is used for exiting.
+ // Unless home is hidden, then in DPM locked mode and no exit available.
+ disableRecent = false;
+ }
getBackButton() .setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE);
getHomeButton() .setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE);
@@ -363,6 +373,14 @@ public class NavigationBarView extends LinearLayout {
mBarTransitions.applyBackButtonQuiescentAlpha(mBarTransitions.getMode(), true /*animate*/);
}
+ private boolean inLockTask() {
+ try {
+ return ActivityManagerNative.getDefault().isInLockTaskMode();
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
private void setVisibleOrGone(View view, boolean visible) {
if (view != null) {
view.setVisibility(visible ? VISIBLE : GONE);
@@ -503,15 +521,31 @@ public class NavigationBarView extends LinearLayout {
// We swap all children of the 90 and 270 degree layouts, since they are vertical
View rotation90 = mRotatedViews[Surface.ROTATION_90];
swapChildrenOrderIfVertical(rotation90.findViewById(R.id.nav_buttons));
+ adjustExtraKeyGravity(rotation90, isLayoutRtl);
View rotation270 = mRotatedViews[Surface.ROTATION_270];
if (rotation90 != rotation270) {
swapChildrenOrderIfVertical(rotation270.findViewById(R.id.nav_buttons));
+ adjustExtraKeyGravity(rotation270, isLayoutRtl);
}
mIsLayoutRtl = isLayoutRtl;
}
}
+ private void adjustExtraKeyGravity(View navBar, boolean isLayoutRtl) {
+ View menu = navBar.findViewById(R.id.menu);
+ View imeSwitcher = navBar.findViewById(R.id.ime_switcher);
+ if (menu != null) {
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) menu.getLayoutParams();
+ lp.gravity = isLayoutRtl ? Gravity.BOTTOM : Gravity.TOP;
+ menu.setLayoutParams(lp);
+ }
+ if (imeSwitcher != null) {
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) imeSwitcher.getLayoutParams();
+ lp.gravity = isLayoutRtl ? Gravity.BOTTOM : Gravity.TOP;
+ imeSwitcher.setLayoutParams(lp);
+ }
+ }
/**
* Swaps the children order of a LinearLayout if it's orientation is Vertical
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index a6fccb6..bb992b0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -52,7 +52,7 @@ import com.android.systemui.statusbar.stack.StackStateAnimator;
public class NotificationPanelView extends PanelView implements
ExpandableView.OnHeightChangedListener, ObservableScrollView.Listener,
View.OnClickListener, NotificationStackScrollLayout.OnOverscrollTopChangedListener,
- KeyguardAffordanceHelper.Callback {
+ KeyguardAffordanceHelper.Callback, NotificationStackScrollLayout.OnEmptySpaceClickListener {
// Cap and total height of Roboto font. Needs to be adjusted when font for the big clock is
// changed.
@@ -64,7 +64,7 @@ public class NotificationPanelView extends PanelView implements
private static final int DOZE_BACKGROUND_COLOR = 0xff000000;
private static final int TAG_KEY_ANIM = R.id.scrim;
- private static final long DOZE_BACKGROUND_ANIM_DURATION = ScrimController.ANIMATION_DURATION;
+ public static final long DOZE_ANIMATION_DURATION = 700;
private KeyguardAffordanceHelper mAfforanceHelper;
private StatusBarHeaderView mHeader;
@@ -132,6 +132,7 @@ public class NotificationPanelView extends PanelView implements
private Interpolator mFastOutSlowInInterpolator;
private Interpolator mFastOutLinearInterpolator;
+ private Interpolator mDozeAnimationInterpolator;
private ObjectAnimator mClockAnimator;
private int mClockAnimationTarget = -1;
private int mTopPaddingAdjustment;
@@ -167,6 +168,8 @@ public class NotificationPanelView extends PanelView implements
private boolean mQsTouchAboveFalsingThreshold;
private int mQsFalsingThreshold;
+ private float mKeyguardStatusBarAnimateAlpha = 1f;
+
public NotificationPanelView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@@ -194,11 +197,14 @@ public class NotificationPanelView extends PanelView implements
findViewById(R.id.notification_stack_scroller);
mNotificationStackScroller.setOnHeightChangedListener(this);
mNotificationStackScroller.setOverscrollTopChangedListener(this);
+ mNotificationStackScroller.setOnEmptySpaceClickListener(this);
mNotificationStackScroller.setScrollView(mScrollView);
mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(),
android.R.interpolator.fast_out_slow_in);
mFastOutLinearInterpolator = AnimationUtils.loadInterpolator(getContext(),
android.R.interpolator.fast_out_linear_in);
+ mDozeAnimationInterpolator = AnimationUtils.loadInterpolator(getContext(),
+ android.R.interpolator.linear_out_slow_in);
mKeyguardBottomArea = (KeyguardBottomAreaView) findViewById(R.id.keyguard_bottom_area);
mQsNavbarScrim = findViewById(R.id.qs_navbar_scrim);
mAfforanceHelper = new KeyguardAffordanceHelper(this, getContext());
@@ -285,8 +291,8 @@ public class NotificationPanelView extends PanelView implements
} else {
setQsExpansion(mQsMinExpansionHeight + mLastOverscroll);
mNotificationStackScroller.setStackHeight(getExpandedHeight());
- updateHeader();
}
+ updateHeader();
mNotificationStackScroller.updateIsSmallScreen(
mHeader.getCollapsedHeight() + mQsPeekHeight);
}
@@ -521,13 +527,15 @@ public class NotificationPanelView extends PanelView implements
mIntercepting = false;
break;
}
+ return super.onInterceptTouchEvent(event);
+ }
- // Allow closing the whole panel when in SHADE state.
- if (mStatusBarState == StatusBarState.SHADE) {
- return super.onInterceptTouchEvent(event);
- } else {
- return !mQsExpanded && super.onInterceptTouchEvent(event);
- }
+ @Override
+ protected boolean isInContentBounds(float x, float y) {
+ float yTransformed = y - mNotificationStackScroller.getY();
+ float stackScrollerX = mNotificationStackScroller.getX();
+ return mNotificationStackScroller.isInContentBounds(yTransformed) && stackScrollerX < x
+ && x < stackScrollerX + mNotificationStackScroller.getWidth();
}
private void resetDownStates(MotionEvent event) {
@@ -631,10 +639,9 @@ public class NotificationPanelView extends PanelView implements
}
private boolean isInQsArea(float x, float y) {
- return mStatusBarState != StatusBarState.SHADE ||
- (x >= mScrollView.getLeft() && x <= mScrollView.getRight()) &&
- (y <= mNotificationStackScroller.getBottomMostNotificationBottom()
- || y <= mQsContainer.getY() + mQsContainer.getHeight());
+ return (x >= mScrollView.getLeft() && x <= mScrollView.getRight()) &&
+ (y <= mNotificationStackScroller.getBottomMostNotificationBottom()
+ || y <= mQsContainer.getY() + mQsContainer.getHeight());
}
private void handleQsDown(MotionEvent event) {
@@ -802,6 +809,7 @@ public class NotificationPanelView extends PanelView implements
requestPanelHeightUpdate();
mNotificationStackScroller.setInterceptDelegateEnabled(expanded);
mStatusBar.setQsExpanded(expanded);
+ mQsPanel.setExpanded(expanded);
}
}
@@ -908,6 +916,8 @@ public class NotificationPanelView extends PanelView implements
@Override
public void run() {
mKeyguardStatusBar.setVisibility(View.INVISIBLE);
+ mKeyguardStatusBar.setAlpha(1f);
+ mKeyguardStatusBarAnimateAlpha = 1f;
}
};
@@ -917,10 +927,31 @@ public class NotificationPanelView extends PanelView implements
.setStartDelay(mStatusBar.getKeyguardFadingAwayDelay())
.setDuration(mStatusBar.getKeyguardFadingAwayDuration()/2)
.setInterpolator(PhoneStatusBar.ALPHA_OUT)
+ .setUpdateListener(mStatusBarAnimateAlphaListener)
.withEndAction(mAnimateKeyguardStatusBarInvisibleEndRunnable)
.start();
}
+ private final ValueAnimator.AnimatorUpdateListener mStatusBarAnimateAlphaListener =
+ new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ mKeyguardStatusBarAnimateAlpha = mKeyguardStatusBar.getAlpha();
+ }
+ };
+
+ private void animateKeyguardStatusBarIn() {
+ mKeyguardStatusBar.setVisibility(View.VISIBLE);
+ mKeyguardStatusBar.setAlpha(0f);
+ mKeyguardStatusBar.animate()
+ .alpha(1f)
+ .setStartDelay(0)
+ .setDuration(DOZE_ANIMATION_DURATION)
+ .setInterpolator(mDozeAnimationInterpolator)
+ .setUpdateListener(mStatusBarAnimateAlphaListener)
+ .start();
+ }
+
private final Runnable mAnimateKeyguardBottomAreaInvisibleEndRunnable = new Runnable() {
@Override
public void run() {
@@ -1011,7 +1042,7 @@ public class NotificationPanelView extends PanelView implements
? View.VISIBLE
: View.INVISIBLE);
if (mKeyguardUserSwitcher != null && mQsExpanded && !mStackScrollerOverscrolling) {
- mKeyguardUserSwitcher.hide(true /* animate */);
+ mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */);
}
}
@@ -1081,9 +1112,26 @@ public class NotificationPanelView extends PanelView implements
}
private float calculateQsTopPadding() {
- // We can only do the smoother transition on Keyguard when we also are not collapsing from a
- // scrolled quick settings.
- if (mKeyguardShowing && mScrollYOverride == -1) {
+ if (mKeyguardShowing
+ && (mTwoFingerQsExpand || mIsExpanding && mQsExpandedWhenExpandingStarted)) {
+
+ // Either QS pushes the notifications down when fully expanded, or QS is fully above the
+ // notifications (mostly on tablets). maxNotifications denotes the normal top padding
+ // on Keyguard, maxQs denotes the top padding from the quick settings panel. We need to
+ // take the maximum and linearly interpolate with the panel expansion for a nice motion.
+ int maxNotifications = mClockPositionResult.stackScrollerPadding
+ - mClockPositionResult.stackScrollerPaddingAdjustment
+ - mNotificationTopPadding;
+ int maxQs = getTempQsMaxExpansion();
+ int max = mStatusBarState == StatusBarState.KEYGUARD
+ ? Math.max(maxNotifications, maxQs)
+ : maxQs;
+ return (int) interpolate(getExpandedFraction(),
+ mQsMinExpansionHeight, max);
+ } else if (mKeyguardShowing && mScrollYOverride == -1) {
+
+ // We can only do the smoother transition on Keyguard when we also are not collapsing
+ // from a scrolled quick settings.
return interpolate(getQsExpansionFraction(),
mNotificationStackScroller.getIntrinsicPadding() - mNotificationTopPadding,
mQsMaxExpansionHeight);
@@ -1095,7 +1143,9 @@ public class NotificationPanelView extends PanelView implements
private void requestScrollerTopPaddingUpdate(boolean animate) {
mNotificationStackScroller.updateTopPadding(calculateQsTopPadding(),
mScrollView.getScrollY(),
- mAnimateNextTopPaddingChange || animate);
+ mAnimateNextTopPaddingChange || animate,
+ mKeyguardShowing
+ && (mTwoFingerQsExpand || mIsExpanding && mQsExpandedWhenExpandingStarted));
mAnimateNextTopPaddingChange = false;
}
@@ -1225,18 +1275,27 @@ public class NotificationPanelView extends PanelView implements
@Override
protected void onHeightUpdated(float expandedHeight) {
- if (!mQsExpanded) {
+ if (!mQsExpanded || mTwoFingerQsExpand || mIsExpanding && mQsExpandedWhenExpandingStarted) {
positionClockAndNotifications();
}
if (mTwoFingerQsExpand || mQsExpanded && !mQsTracking && mQsExpansionAnimator == null
&& !mQsExpansionFromOverscroll) {
- float panelHeightQsCollapsed = mNotificationStackScroller.getIntrinsicPadding()
- + mNotificationStackScroller.getMinStackHeight()
- + mNotificationStackScroller.getNotificationTopPadding();
- float panelHeightQsExpanded = calculatePanelHeightQsExpanded();
- float t = (expandedHeight - panelHeightQsCollapsed)
- / (panelHeightQsExpanded - panelHeightQsCollapsed);
+ float t;
+ if (mKeyguardShowing) {
+ // On Keyguard, interpolate the QS expansion linearly to the panel expansion
+ t = expandedHeight / getMaxPanelHeight();
+ } else {
+
+ // In Shade, interpolate linearly such that QS is closed whenever panel height is
+ // minimum QS expansion + minStackHeight
+ float panelHeightQsCollapsed = mNotificationStackScroller.getIntrinsicPadding()
+ + mNotificationStackScroller.getMinStackHeight()
+ + mNotificationStackScroller.getNotificationTopPadding();
+ float panelHeightQsExpanded = calculatePanelHeightQsExpanded();
+ t = (expandedHeight - panelHeightQsCollapsed)
+ / (panelHeightQsExpanded - panelHeightQsCollapsed);
+ }
setQsExpansion(mQsMinExpansionHeight
+ t * (getTempQsMaxExpansion() - mQsMinExpansionHeight));
}
@@ -1270,8 +1329,20 @@ public class NotificationPanelView extends PanelView implements
float notificationHeight = mNotificationStackScroller.getHeight()
- mNotificationStackScroller.getEmptyBottomMargin()
- mNotificationStackScroller.getTopPadding();
- float totalHeight = mQsMaxExpansionHeight + notificationHeight
- + mNotificationStackScroller.getNotificationTopPadding();
+
+ // When only empty shade view is visible in QS collapsed state, simulate that we would have
+ // it in expanded QS state as well so we don't run into troubles when fading the view in/out
+ // and expanding/collapsing the whole panel from/to quick settings.
+ if (mNotificationStackScroller.getNotGoneChildCount() == 0
+ && mShadeEmpty) {
+ notificationHeight = mNotificationStackScroller.getEmptyShadeViewHeight()
+ + mNotificationStackScroller.getBottomStackPeekSize()
+ + mNotificationStackScroller.getCollapseSecondCardPadding();
+ }
+ float totalHeight = Math.max(
+ mQsMaxExpansionHeight + mNotificationStackScroller.getNotificationTopPadding(),
+ mClockPositionResult.stackScrollerPadding - mTopPaddingAdjustment)
+ + notificationHeight;
if (totalHeight > mNotificationStackScroller.getHeight()) {
float fullyCollapsedHeight = mQsMaxExpansionHeight
+ mNotificationStackScroller.getMinStackHeight()
@@ -1386,7 +1457,8 @@ public class NotificationPanelView extends PanelView implements
alphaNotifications = MathUtils.constrain(alphaNotifications, 0, 1);
alphaNotifications = (float) Math.pow(alphaNotifications, 0.75);
float alphaQsExpansion = 1 - Math.min(1, getQsExpansionFraction() * 2);
- mKeyguardStatusBar.setAlpha(Math.min(alphaNotifications, alphaQsExpansion));
+ mKeyguardStatusBar.setAlpha(Math.min(alphaNotifications, alphaQsExpansion)
+ * mKeyguardStatusBarAnimateAlpha);
mKeyguardBottomArea.setAlpha(Math.min(1 - getQsExpansionFraction(), alphaNotifications));
setQsTranslation(mQsExpansionHeight);
}
@@ -1403,7 +1475,7 @@ public class NotificationPanelView extends PanelView implements
super.onExpandingStarted();
mNotificationStackScroller.onExpansionStarted();
mIsExpanding = true;
- mQsExpandedWhenExpandingStarted = mQsExpanded;
+ mQsExpandedWhenExpandingStarted = mQsFullyExpanded;
if (mQsExpanded) {
onQsExpansionStarted();
}
@@ -1457,11 +1529,12 @@ public class NotificationPanelView extends PanelView implements
@Override
protected void onTrackingStarted() {
super.onTrackingStarted();
+ if (mQsFullyExpanded) {
+ mTwoFingerQsExpand = true;
+ }
if (mStatusBar.getBarState() == StatusBarState.KEYGUARD
|| mStatusBar.getBarState() == StatusBarState.SHADE_LOCKED) {
mAfforanceHelper.animateHideLeftRightIcon();
- } else if (mQsExpanded) {
- mTwoFingerQsExpand = true;
}
}
@@ -1735,19 +1808,22 @@ public class NotificationPanelView extends PanelView implements
return (1 - t) * start + t * end;
}
- private void updateKeyguardStatusBarVisibility() {
- mKeyguardStatusBar.setVisibility(mKeyguardShowing && !mDozing ? VISIBLE : INVISIBLE);
- }
-
- public void setDozing(boolean dozing) {
+ public void setDozing(boolean dozing, boolean animate) {
if (dozing == mDozing) return;
mDozing = dozing;
if (mDozing) {
- setBackgroundColorAlpha(this, DOZE_BACKGROUND_COLOR, 0xff, false /*animate*/);
+ setBackgroundColorAlpha(DOZE_BACKGROUND_COLOR, 0xff, false /*animate*/);
+ mKeyguardStatusBar.setVisibility(View.INVISIBLE);
+ mKeyguardBottomArea.setVisibility(View.INVISIBLE);
} else {
- setBackgroundColorAlpha(this, DOZE_BACKGROUND_COLOR, 0, true /*animate*/);
+ setBackgroundColorAlpha(DOZE_BACKGROUND_COLOR, 0, animate);
+ mKeyguardBottomArea.setVisibility(View.VISIBLE);
+ mKeyguardStatusBar.setVisibility(View.VISIBLE);
+ if (animate) {
+ animateKeyguardStatusBarIn();
+ mKeyguardBottomArea.startFinishDozeAnimation();
+ }
}
- updateKeyguardStatusBarVisibility();
}
@Override
@@ -1755,21 +1831,21 @@ public class NotificationPanelView extends PanelView implements
return mDozing;
}
- private static void setBackgroundColorAlpha(final View target, int rgb, int targetAlpha,
+ private void setBackgroundColorAlpha(int rgb, int targetAlpha,
boolean animate) {
- int currentAlpha = getBackgroundAlpha(target);
+ int currentAlpha = getBackgroundAlpha(this);
if (currentAlpha == targetAlpha) {
return;
}
final int r = Color.red(rgb);
final int g = Color.green(rgb);
final int b = Color.blue(rgb);
- Object runningAnim = target.getTag(TAG_KEY_ANIM);
+ Object runningAnim = getTag(TAG_KEY_ANIM);
if (runningAnim instanceof ValueAnimator) {
((ValueAnimator) runningAnim).cancel();
}
if (!animate) {
- target.setBackgroundColor(Color.argb(targetAlpha, r, g, b));
+ setBackgroundColor(Color.argb(targetAlpha, r, g, b));
return;
}
ValueAnimator anim = ValueAnimator.ofInt(currentAlpha, targetAlpha);
@@ -1777,18 +1853,19 @@ public class NotificationPanelView extends PanelView implements
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int value = (int) animation.getAnimatedValue();
- target.setBackgroundColor(Color.argb(value, r, g, b));
+ setBackgroundColor(Color.argb(value, r, g, b));
}
});
- anim.setDuration(DOZE_BACKGROUND_ANIM_DURATION);
+ anim.setInterpolator(mDozeAnimationInterpolator);
+ anim.setDuration(DOZE_ANIMATION_DURATION);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- target.setTag(TAG_KEY_ANIM, null);
+ setTag(TAG_KEY_ANIM, null);
}
});
anim.start();
- target.setTag(TAG_KEY_ANIM, anim);
+ setTag(TAG_KEY_ANIM, anim);
}
private static int getBackgroundAlpha(View view) {
@@ -1833,4 +1910,9 @@ public class NotificationPanelView extends PanelView implements
public void onScreenTurnedOn() {
mKeyguardStatusView.refreshTime();
}
+
+ @Override
+ public void onEmptySpaceClicked(float x, float y) {
+ onEmptySpaceClick(x);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
index f74d2f4..3efaaff 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
@@ -236,4 +236,8 @@ public class PanelBar extends FrameLayout {
public void onExpandingFinished() {
}
+
+ public void onClosingFinished() {
+
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index a7ff0bd..c706ef0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -68,9 +68,9 @@ public abstract class PanelView extends FrameLayout {
protected int mTouchSlop;
protected boolean mHintAnimationRunning;
private boolean mOverExpandedBeforeFling;
- private float mOriginalIndicationY;
private boolean mTouchAboveFalsingThreshold;
private int mUnlockFalsingThreshold;
+ private boolean mTouchStartedInEmptyArea;
private ValueAnimator mHeightAnimator;
private ObjectAnimator mPeekAnimator;
@@ -107,7 +107,7 @@ public abstract class PanelView extends FrameLayout {
};
protected void onExpandingFinished() {
- mClosing = false;
+ endClosing();
mBar.onExpandingFinished();
}
@@ -250,9 +250,7 @@ public abstract class PanelView extends FrameLayout {
trackMovement(event);
if (!waitForTouchSlop || (mHeightAnimator != null && !mHintAnimationRunning) ||
mPeekPending || mPeekAnimator != null) {
- if (mHeightAnimator != null) {
- mHeightAnimator.cancel(); // end any outstanding animations
- }
+ cancelHeightAnimator();
cancelPeek();
mTouchSlopExceeded = (mHeightAnimator != null && !mHintAnimationRunning)
|| mPeekPending || mPeekAnimator != null;
@@ -287,15 +285,13 @@ public abstract class PanelView extends FrameLayout {
|| mInitialOffsetOnTouch == 0f)) {
mTouchSlopExceeded = true;
if (waitForTouchSlop && !mTracking) {
- if (!mJustPeeked) {
+ if (!mJustPeeked && mInitialOffsetOnTouch != 0f) {
mInitialOffsetOnTouch = mExpandedHeight;
mInitialTouchX = x;
mInitialTouchY = y;
h = 0;
}
- if (mHeightAnimator != null) {
- mHeightAnimator.cancel(); // end any outstanding animations
- }
+ cancelHeightAnimator();
removeCallbacks(mPeekRunnable);
mPeekPending = false;
onTrackingStarted();
@@ -372,7 +368,7 @@ public abstract class PanelView extends FrameLayout {
}
protected void onTrackingStarted() {
- mClosing = false;
+ endClosing();
mTracking = true;
mCollapseAfterPeek = false;
mBar.onTrackingStarted(PanelView.this);
@@ -407,15 +403,14 @@ public abstract class PanelView extends FrameLayout {
mStatusBar.userActivity();
if (mHeightAnimator != null && !mHintAnimationRunning ||
mPeekPending || mPeekAnimator != null) {
- if (mHeightAnimator != null) {
- mHeightAnimator.cancel(); // end any outstanding animations
- }
+ cancelHeightAnimator();
cancelPeek();
mTouchSlopExceeded = true;
return true;
}
mInitialTouchY = y;
mInitialTouchX = x;
+ mTouchStartedInEmptyArea = !isInContentBounds(x, y);
mTouchSlopExceeded = false;
mJustPeeked = false;
mPanelClosedOnDown = mExpandedHeight == 0.0f;
@@ -439,11 +434,9 @@ public abstract class PanelView extends FrameLayout {
case MotionEvent.ACTION_MOVE:
final float h = y - mInitialTouchY;
trackMovement(event);
- if (scrolledToBottom) {
+ if (scrolledToBottom || mTouchStartedInEmptyArea) {
if (h < -mTouchSlop && h < -Math.abs(x - mInitialTouchX)) {
- if (mHeightAnimator != null) {
- mHeightAnimator.cancel();
- }
+ cancelHeightAnimator();
mInitialOffsetOnTouch = mExpandedHeight;
mInitialTouchY = y;
mInitialTouchX = x;
@@ -461,6 +454,25 @@ public abstract class PanelView extends FrameLayout {
return false;
}
+ /**
+ * @return Whether a pair of coordinates are inside the visible view content bounds.
+ */
+ protected abstract boolean isInContentBounds(float x, float y);
+
+ private void cancelHeightAnimator() {
+ if (mHeightAnimator != null) {
+ mHeightAnimator.cancel();
+ }
+ endClosing();
+ }
+
+ private void endClosing() {
+ if (mClosing) {
+ mClosing = false;
+ onClosingFinished();
+ }
+ }
+
private void initVelocityTracker() {
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
@@ -627,10 +639,10 @@ public abstract class PanelView extends FrameLayout {
}
mExpandedHeight = Math.max(0, mExpandedHeight);
- onHeightUpdated(mExpandedHeight);
mExpandedFraction = Math.min(1f, fhWithoutOverExpansion == 0
? 0
: mExpandedHeight / fhWithoutOverExpansion);
+ onHeightUpdated(mExpandedHeight);
notifyBarPanelExpansionChanged();
}
@@ -700,9 +712,7 @@ public abstract class PanelView extends FrameLayout {
mPeekRunnable.run();
}
} else if (!isFullyCollapsed() && !mTracking && !mClosing) {
- if (mHeightAnimator != null) {
- mHeightAnimator.cancel();
- }
+ cancelHeightAnimator();
mClosing = true;
notifyExpandingStarted();
if (delayed) {
@@ -785,13 +795,16 @@ public abstract class PanelView extends FrameLayout {
private void abortAnimations() {
cancelPeek();
- if (mHeightAnimator != null) {
- mHeightAnimator.cancel();
- }
+ cancelHeightAnimator();
removeCallbacks(mPostCollapseRunnable);
removeCallbacks(mFlingCollapseRunnable);
}
+ protected void onClosingFinished() {
+ mBar.onClosingFinished();
+ }
+
+
protected void startUnlockHintAnimation() {
// We don't need to hint the user if an animation is already running or the user is changing
@@ -841,16 +854,15 @@ public abstract class PanelView extends FrameLayout {
});
animator.start();
mHeightAnimator = animator;
- mOriginalIndicationY = mKeyguardBottomArea.getIndicationView().getY();
mKeyguardBottomArea.getIndicationView().animate()
- .y(mOriginalIndicationY - mHintDistance)
+ .translationY(-mHintDistance)
.setDuration(250)
.setInterpolator(mFastOutSlowInInterpolator)
.withEndAction(new Runnable() {
@Override
public void run() {
mKeyguardBottomArea.getIndicationView().animate()
- .y(mOriginalIndicationY)
+ .translationY(0)
.setDuration(450)
.setInterpolator(mBounceInterpolator)
.start();
@@ -898,7 +910,7 @@ public abstract class PanelView extends FrameLayout {
*
* @return whether the panel will be expanded after the action performed by this method
*/
- private boolean onEmptySpaceClick(float x) {
+ protected boolean onEmptySpaceClick(float x) {
if (mHintAnimationRunning) {
return true;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 9e3f0f6..820aadf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -23,6 +23,7 @@ import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN;
import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
import static android.app.StatusBarManager.windowStateToString;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSLUCENT;
@@ -40,6 +41,7 @@ import android.app.Notification;
import android.app.PendingIntent;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
+import android.content.ComponentCallbacks2;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -54,7 +56,6 @@ import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
-import android.graphics.Xfermode;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.inputmethodservice.InputMethodService;
@@ -95,8 +96,8 @@ import android.view.ViewPropertyAnimator;
import android.view.ViewStub;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
+import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityManager;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
@@ -122,6 +123,7 @@ import com.android.systemui.doze.DozeHost;
import com.android.systemui.doze.DozeLog;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.qs.QSPanel;
+import com.android.systemui.recent.ScreenPinningRequest;
import com.android.systemui.statusbar.ActivatableNotificationView;
import com.android.systemui.statusbar.BackDropView;
import com.android.systemui.statusbar.BaseStatusBar;
@@ -173,6 +175,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
DragDownHelper.DragDownCallback, ActivityStarter {
@@ -354,6 +357,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
? new GestureRecorder("/sdcard/statusbar_gestures.dat")
: null;
+ private ScreenPinningRequest mScreenPinningRequest;
+
private int mNavigationIconHints = 0;
// ensure quick settings is disabled until the current user makes it through the setup wizard
@@ -406,13 +411,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
private boolean mAutohideSuspended;
private int mStatusBarMode;
private int mNavigationBarMode;
- private Boolean mScreenOn;
-
- // The second field is a bit different from the first one because it only listens to screen on/
- // screen of events from Keyguard. We need this so we don't have a race condition with the
- // broadcast. In the future, we should remove the first field altogether and rename the second
- // field.
- private boolean mScreenOnFromKeyguard;
private ViewMediatorCallback mKeyguardViewMediatorCallback;
private ScrimController mScrimController;
@@ -426,7 +424,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
}};
- private boolean mVisible;
private boolean mWaitingForKeyguardExit;
private boolean mDozing;
private boolean mScrimSrcModeEnabled;
@@ -581,7 +578,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
addNavigationBar();
// Lastly, call to the icon policy to install/update all the icons.
- mIconPolicy = new PhoneStatusBarPolicy(mContext, mCastController);
+ mIconPolicy = new PhoneStatusBarPolicy(mContext, mCastController, mHotspotController);
mSettingsObserver.onChange(false); // set up
mHeadsUpObserver.onChange(true); // set up
@@ -603,6 +600,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
setControllerUsers();
notifyUserAboutHiddenNotifications();
+
+ mScreenPinningRequest = new ScreenPinningRequest(mContext);
}
// ================================================================================
@@ -798,7 +797,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
mUserInfoController = new UserInfoController(mContext);
mVolumeComponent = getComponent(VolumeComponent.class);
- mZenModeController = mVolumeComponent.getZenController();
+ if (mVolumeComponent != null) {
+ mZenModeController = mVolumeComponent.getZenController();
+ }
mCastController = new CastControllerImpl(mContext);
final SignalClusterView signalCluster =
(SignalClusterView) mStatusBarView.findViewById(R.id.signal_cluster);
@@ -2413,6 +2414,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false);
showBouncer();
disable(mDisabledUnmodified, true /* animate */);
+
+ // Trimming will happen later if Keyguard is showing - doing it here might cause a jank in
+ // the bouncer appear animation.
+ if (!mStatusBarKeyguardViewManager.isShowing()) {
+ WindowManagerGlobal.getInstance().trimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
+ }
}
public boolean interceptTouchEvent(MotionEvent event) {
@@ -2599,8 +2606,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
private int barMode(int vis, int transientFlag, int translucentFlag) {
+ int lightsOutTransparent = View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_TRANSPARENT;
return (vis & transientFlag) != 0 ? MODE_SEMI_TRANSPARENT
: (vis & translucentFlag) != 0 ? MODE_TRANSLUCENT
+ : (vis & lightsOutTransparent) == lightsOutTransparent ? MODE_LIGHTS_OUT_TRANSPARENT
: (vis & View.SYSTEM_UI_TRANSPARENT) != 0 ? MODE_TRANSPARENT
: (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0 ? MODE_LIGHTS_OUT
: MODE_OPAQUE;
@@ -2955,6 +2964,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
if (mSecurityController != null) {
mSecurityController.dump(fd, pw, args);
}
+ pw.println("SharedPreferences:");
+ for (Map.Entry<String, ?> entry : mContext.getSharedPreferences(mContext.getPackageName(),
+ Context.MODE_PRIVATE).getAll().entrySet()) {
+ pw.print(" "); pw.print(entry.getKey()); pw.print("="); pw.println(entry.getValue());
+ }
}
private String hunStateToString(Entry entry) {
@@ -3036,7 +3050,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
});
if (dismissShade) {
- animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
+ animateCollapsePanels(
+ CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */);
}
return true;
}
@@ -3060,15 +3075,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
notifyNavigationBarScreenOn(false);
notifyHeadsUpScreenOn(false);
finishBarAnimations();
- stopNotificationLogging();
resetUserExpandedStates();
}
else if (Intent.ACTION_SCREEN_ON.equals(action)) {
mScreenOn = true;
- // work around problem where mDisplay.getRotation() is not stable while screen is off (bug 7086018)
- repositionNavigationBar();
notifyNavigationBarScreenOn(true);
- startNotificationLoggingIfScreenOnAndVisible();
}
else if (ACTION_DEMO.equals(action)) {
Bundle bundle = intent.getExtras();
@@ -3138,6 +3149,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
updateShowSearchHoldoff();
updateRowStates();
+ mScreenPinningRequest.onConfigurationChanged();
}
@Override
@@ -3257,14 +3269,14 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
// Visibility reporting
@Override
- protected void visibilityChanged(boolean visible) {
- mVisible = visible;
- if (visible) {
- startNotificationLoggingIfScreenOnAndVisible();
+ protected void handleVisibleToUserChanged(boolean visibleToUser) {
+ if (visibleToUser) {
+ super.handleVisibleToUserChanged(visibleToUser);
+ startNotificationLogging();
} else {
stopNotificationLogging();
+ super.handleVisibleToUserChanged(visibleToUser);
}
- super.visibilityChanged(visible);
}
private void stopNotificationLogging() {
@@ -3279,17 +3291,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mStackScroller.setChildLocationsChangedListener(null);
}
- private void startNotificationLoggingIfScreenOnAndVisible() {
- if (mVisible && mScreenOn) {
- mStackScroller.setChildLocationsChangedListener(mNotificationLocationsChangedListener);
- // Some transitions like mScreenOn=false -> mScreenOn=true don't
- // cause the scroller to emit child location events. Hence generate
- // one ourselves to guarantee that we're reporting visible
- // notifications.
- // (Note that in cases where the scroller does emit events, this
- // additional event doesn't break anything.)
- mNotificationLocationsChangedListener.onChildLocationsChanged(mStackScroller);
- }
+ private void startNotificationLogging() {
+ mStackScroller.setChildLocationsChangedListener(mNotificationLocationsChangedListener);
+ // Some transitions like mVisibleToUser=false -> mVisibleToUser=true don't
+ // cause the scroller to emit child location events. Hence generate
+ // one ourselves to guarantee that we're reporting visible
+ // notifications.
+ // (Note that in cases where the scroller does emit events, this
+ // additional event doesn't break anything.)
+ mNotificationLocationsChangedListener.onChildLocationsChanged(mStackScroller);
}
private void logNotificationVisibilityChanges(
@@ -3594,6 +3604,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
instantCollapseNotificationPanel();
}
updateKeyguardState(staying, false /* fromShadeLocked */);
+
+ // Keyguard state has changed, but QS is not listening anymore. Make sure to update the tile
+ // visibilities so next time we open the panel we know the correct height already.
+ if (mQSPanel != null) {
+ mQSPanel.refreshAllTiles();
+ }
return staying;
}
@@ -3627,9 +3643,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
private void updatePublicMode() {
- setLockscreenPublicMode(
- (mStatusBarKeyguardViewManager.isShowing() ||
- mStatusBarKeyguardViewManager.isOccluded())
+ setLockscreenPublicMode(mStatusBarKeyguardViewManager.isShowing()
&& mStatusBarKeyguardViewManager.isSecure());
}
@@ -3664,15 +3678,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
if (mState != StatusBarState.KEYGUARD && !mNotificationPanel.isDozing()) {
return;
}
- mNotificationPanel.setDozing(mDozing);
+ mNotificationPanel.setDozing(mDozing, mScrimController.isPulsing() /*animate*/);
if (mDozing) {
- mKeyguardBottomArea.setVisibility(View.INVISIBLE);
mStackScroller.setDark(true, false /*animate*/);
} else {
- mKeyguardBottomArea.setVisibility(View.VISIBLE);
mStackScroller.setDark(false, false /*animate*/);
}
- mScrimController.setDozing(mDozing);
+ mScrimController.setDozing(mDozing, mScrimController.isPulsing() /*animate*/);
}
public void updateStackScrollerState(boolean goingToFullShade) {
@@ -3725,7 +3737,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
public boolean onSpacePressed() {
if (mScreenOn != null && mScreenOn
&& (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) {
- animateCollapsePanels(0 /* flags */, true /* force */);
+ animateCollapsePanels(
+ CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */);
return true;
}
return false;
@@ -3779,6 +3792,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
runPostCollapseRunnables();
}
+ public void onClosingFinished() {
+ runPostCollapseRunnables();
+ }
+
public void onUnlockHintStarted() {
mKeyguardIndicationController.showTransientIndication(R.string.keyguard_unlock);
}
@@ -3922,6 +3939,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mScreenOnFromKeyguard = false;
mScreenOnComingFromTouch = false;
mStackScroller.setAnimationsEnabled(false);
+ updateVisibleToUser();
}
public void onScreenTurnedOn() {
@@ -3929,6 +3947,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mStackScroller.setAnimationsEnabled(true);
mNotificationPanel.onScreenTurnedOn();
mNotificationPanel.setTouchDisabled(false);
+ updateVisibleToUser();
}
/**
@@ -3955,6 +3974,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
// long-pressed 'together'
if ((time - mLastLockToAppLongPress) < LOCK_TO_APP_GESTURE_TOLERENCE) {
activityManager.stopLockTaskModeOnCurrent();
+ // When exiting refresh disabled flags.
+ mNavigationBarView.setDisabledFlags(mDisabled, true);
} else if ((v.getId() == R.id.back)
&& !mNavigationBarView.getRecentsButton().isPressed()) {
// If we aren't pressing recents right now then they presses
@@ -3970,6 +3991,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
// When in accessibility mode a long press that is recents (not back)
// should stop lock task.
activityManager.stopLockTaskModeOnCurrent();
+ // When exiting refresh disabled flags.
+ mNavigationBarView.setDisabledFlags(mDisabled, true);
}
}
if (sendBackLongPress) {
@@ -4019,6 +4042,20 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
notifyUiVisibilityChanged(mSystemUiVisibility);
}
+ @Override
+ public void showScreenPinningRequest() {
+ if (mKeyguardMonitor.isShowing()) {
+ // Don't allow apps to trigger this from keyguard.
+ return;
+ }
+ // Show screen pinning request, since this comes from an app, show 'no thanks', button.
+ showScreenPinningRequest(true);
+ }
+
+ public void showScreenPinningRequest(boolean allowCancel) {
+ mScreenPinningRequest.showPrompt(allowCancel);
+ }
+
public boolean hasActiveNotifications() {
return !mNotificationData.getActiveNotifications().isEmpty();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
index 47e1ab5..60d23ce 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -35,6 +35,7 @@ import com.android.internal.telephony.TelephonyIntents;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.CastController;
import com.android.systemui.statusbar.policy.CastController.CastDevice;
+import com.android.systemui.statusbar.policy.HotspotController;
/**
* This class contains all of the policy about which icons are installed in the status
@@ -49,6 +50,7 @@ public class PhoneStatusBarPolicy {
private static final String SLOT_SYNC_ACTIVE = "sync_active";
private static final String SLOT_CAST = "cast";
+ private static final String SLOT_HOTSPOT = "hotspot";
private static final String SLOT_BLUETOOTH = "bluetooth";
private static final String SLOT_TTY = "tty";
private static final String SLOT_ZEN = "zen";
@@ -60,6 +62,7 @@ public class PhoneStatusBarPolicy {
private final StatusBarManager mService;
private final Handler mHandler = new Handler();
private final CastController mCast;
+ private final HotspotController mHotspot;
// Assume it's all good unless we hear otherwise. We don't always seem
// to get broadcasts that it *is* there.
@@ -102,9 +105,10 @@ public class PhoneStatusBarPolicy {
}
};
- public PhoneStatusBarPolicy(Context context, CastController cast) {
+ public PhoneStatusBarPolicy(Context context, CastController cast, HotspotController hotspot) {
mContext = context;
mCast = cast;
+ mHotspot = hotspot;
mService = (StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE);
// listen for broadcasts
@@ -152,6 +156,11 @@ public class PhoneStatusBarPolicy {
mService.setIcon(SLOT_CAST, R.drawable.stat_sys_cast, 0, null);
mService.setIconVisibility(SLOT_CAST, false);
mCast.addCallback(mCastCallback);
+
+ // hotspot
+ mService.setIcon(SLOT_HOTSPOT, R.drawable.stat_sys_hotspot, 0, null);
+ mService.setIconVisibility(SLOT_HOTSPOT, mHotspot.isHotspotEnabled());
+ mHotspot.addCallback(mHotspotCallback);
}
public void setZenMode(int zen) {
@@ -300,6 +309,13 @@ public class PhoneStatusBarPolicy {
mService.setIconVisibility(SLOT_CAST, isCasting);
}
+ private final HotspotController.Callback mHotspotCallback = new HotspotController.Callback() {
+ @Override
+ public void onHotspotChanged(boolean enabled) {
+ mService.setIconVisibility(SLOT_HOTSPOT, enabled);
+ }
+ };
+
private final CastController.Callback mCastCallback = new CastController.Callback() {
@Override
public void onCastDevicesChanged() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarTransitions.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarTransitions.java
index 8520f40..fb1addf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarTransitions.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarTransitions.java
@@ -57,19 +57,19 @@ public final class PhoneStatusBarTransitions extends BarTransitions {
}
private float getNonBatteryClockAlphaFor(int mode) {
- return mode == MODE_LIGHTS_OUT ? ICON_ALPHA_WHEN_LIGHTS_OUT_NON_BATTERY_CLOCK
+ return isLightsOut(mode) ? ICON_ALPHA_WHEN_LIGHTS_OUT_NON_BATTERY_CLOCK
: !isOpaque(mode) ? ICON_ALPHA_WHEN_NOT_OPAQUE
: mIconAlphaWhenOpaque;
}
private float getBatteryClockAlpha(int mode) {
- return mode == MODE_LIGHTS_OUT ? ICON_ALPHA_WHEN_LIGHTS_OUT_BATTERY_CLOCK
+ return isLightsOut(mode) ? ICON_ALPHA_WHEN_LIGHTS_OUT_BATTERY_CLOCK
: getNonBatteryClockAlphaFor(mode);
}
private boolean isOpaque(int mode) {
return !(mode == MODE_SEMI_TRANSPARENT || mode == MODE_TRANSLUCENT
- || mode == MODE_TRANSPARENT);
+ || mode == MODE_TRANSPARENT || mode == MODE_LIGHTS_OUT_TRANSPARENT);
}
@Override
@@ -94,7 +94,7 @@ public final class PhoneStatusBarTransitions extends BarTransitions {
animateTransitionTo(mBattery, newAlphaBC),
animateTransitionTo(mClock, newAlphaBC)
);
- if (mode == MODE_LIGHTS_OUT) {
+ if (isLightsOut(mode)) {
anims.setDuration(LIGHTS_OUT_DURATION);
}
anims.start();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index 6411fb8..e4eae38 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -20,7 +20,6 @@ import android.content.Context;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.util.EventLog;
-import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
@@ -152,6 +151,12 @@ public class PhoneStatusBarView extends PanelBar {
}
@Override
+ public void onClosingFinished() {
+ super.onClosingFinished();
+ mBar.onClosingFinished();
+ }
+
+ @Override
public void onTrackingStopped(PanelView panel, boolean expand) {
super.onTrackingStopped(panel, expand);
mBar.onTrackingStopped(expand);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
index 2dc08d4..45a1386 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
@@ -21,6 +21,7 @@ import android.content.Intent;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.net.Uri;
+import android.os.Process;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
@@ -108,7 +109,8 @@ public class QSTileHost implements QSTile.Host {
mKeyguard = keyguard;
mSecurity = security;
- final HandlerThread ht = new HandlerThread(QSTileHost.class.getSimpleName());
+ final HandlerThread ht = new HandlerThread(QSTileHost.class.getSimpleName(),
+ Process.THREAD_PRIORITY_BACKGROUND);
ht.start();
mLooper = ht.getLooper();
@@ -120,6 +122,7 @@ public class QSTileHost implements QSTile.Host {
tile.userSwitch(newUserId);
}
mSecurity.onUserSwitched(newUserId);
+ mNetwork.onUserSwitched(newUserId);
mObserver.register();
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index 54adbf4..10d6594 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -28,6 +28,7 @@ import android.view.ViewTreeObserver;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
+import android.view.animation.PathInterpolator;
import com.android.systemui.R;
import com.android.systemui.doze.DozeHost;
@@ -70,9 +71,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
private Runnable mOnAnimationFinished;
private boolean mAnimationStarted;
private boolean mDozing;
+ private boolean mPulsingOut;
private DozeHost.PulseCallback mPulseCallback;
private final Interpolator mInterpolator = new DecelerateInterpolator();
private final Interpolator mLinearOutSlowInInterpolator;
+ private final Interpolator mPulseInInterpolator = PhoneStatusBar.ALPHA_OUT;
+ private final Interpolator mPulseOutInterpolator = PhoneStatusBar.ALPHA_IN;
private BackDropView mBackDropView;
private boolean mScrimSrcEnabled;
@@ -130,14 +134,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
scheduleUpdate();
}
- public void setDozing(boolean dozing) {
+ public void setDozing(boolean dozing, boolean animate) {
if (mDozing == dozing) return;
mDozing = dozing;
if (!mDozing) {
cancelPulsing();
- mAnimateChange = true;
- } else {
- mAnimateChange = false;
+ mAnimateChange = animate;
}
scheduleUpdate();
}
@@ -181,6 +183,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
}
private void pulseFinished() {
+ mPulsingOut = false;
if (mPulseCallback != null) {
mPulseCallback.onPulseFinished();
mPulseCallback = null;
@@ -220,8 +223,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
} else if (mBouncerShowing) {
setScrimInFrontColor(SCRIM_IN_FRONT_ALPHA);
setScrimBehindColor(0f);
+ } else if (mDozing && isPulsing() && !mPulsingOut) {
+ setScrimInFrontColor(0);
+ setScrimBehindColor(SCRIM_BEHIND_ALPHA_KEYGUARD);
} else if (mDozing) {
setScrimInFrontColor(1);
+ setScrimBehindColor(SCRIM_BEHIND_ALPHA_KEYGUARD);
} else {
float fraction = Math.max(0, Math.min(mFraction, 1));
setScrimInFrontColor(0f);
@@ -276,7 +283,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
private void startScrimAnimation(final ScrimView scrim, int targetColor) {
int current = Color.alpha(scrim.getScrimColor());
int target = Color.alpha(targetColor);
- if (current == targetColor) {
+ if (current == target) {
return;
}
ValueAnimator anim = ValueAnimator.ofInt(current, target);
@@ -287,9 +294,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
scrim.setScrimColor(Color.argb(value, 0, 0, 0));
}
});
- anim.setInterpolator(mAnimateKeyguardFadingOut
- ? mLinearOutSlowInInterpolator
- : mInterpolator);
+ anim.setInterpolator(getInterpolator());
anim.setStartDelay(mAnimationDelay);
anim.setDuration(mDurationOverride != -1 ? mDurationOverride : ANIMATION_DURATION);
anim.addListener(new AnimatorListenerAdapter() {
@@ -307,6 +312,18 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
mAnimationStarted = true;
}
+ private Interpolator getInterpolator() {
+ if (mAnimateKeyguardFadingOut) {
+ return mLinearOutSlowInInterpolator;
+ } else if (isPulsing() && !mPulsingOut) {
+ return mPulseInInterpolator;
+ } else if (isPulsing()) {
+ return mPulseOutInterpolator;
+ } else {
+ return mInterpolator;
+ }
+ }
+
@Override
public boolean onPreDraw() {
mScrimBehind.getViewTreeObserver().removeOnPreDrawListener(this);
@@ -332,10 +349,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
if (!mDozing) return;
DozeLog.tracePulseStart();
mDurationOverride = mDozeParameters.getPulseInDuration();
- mAnimationDelay = 0;
+ mAnimationDelay = mDozeParameters.getPulseInDelay();
mAnimateChange = true;
mOnAnimationFinished = mPulseInFinished;
- setScrimColor(mScrimInFront, 0);
+ scheduleUpdate();
// Signal that the pulse is ready to turn the screen on and draw.
pulseStarted();
@@ -357,10 +374,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
if (DEBUG) Log.d(TAG, "Pulse out, mDozing=" + mDozing);
if (!mDozing) return;
mDurationOverride = mDozeParameters.getPulseOutDuration();
- mAnimationDelay = 0;
mAnimateChange = true;
mOnAnimationFinished = mPulseOutFinished;
- setScrimColor(mScrimInFront, 1);
+ mPulsingOut = true;
+ scheduleUpdate();
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
index b0f3ea1..247252c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
@@ -48,6 +48,8 @@ import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.UserInfoController;
+import java.text.NumberFormat;
+
/**
* The view to manage the header area in the expanded status bar.
*/
@@ -300,9 +302,6 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
updateSystemIconsLayoutParams();
updateClickTargets();
updateMultiUserSwitch();
- if (mQSPanel != null) {
- mQSPanel.setExpanded(mExpanded);
- }
updateClockScale();
updateAvatarScale();
updateClockLp();
@@ -395,7 +394,8 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
@Override
public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
- mBatteryLevel.setText(getResources().getString(R.string.battery_level_template, level));
+ String percentage = NumberFormat.getPercentInstance().format((double) level / 100.0);
+ mBatteryLevel.setText(percentage);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index 55c861a..65d231e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.phone;
+import android.content.ComponentCallbacks2;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
@@ -24,6 +25,7 @@ import android.util.Slog;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowManagerGlobal;
import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.widget.LockPatternUtils;
@@ -268,6 +270,8 @@ public class StatusBarKeyguardViewManager {
public void run() {
mStatusBarWindowManager.setKeyguardFadingAway(false);
mPhoneStatusBar.finishKeyguardFadingAway();
+ WindowManagerGlobal.getInstance().trimMemory(
+ ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
}
});
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/TrustDrawable.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/TrustDrawable.java
index dcda2c7..b89aa8f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/TrustDrawable.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/TrustDrawable.java
@@ -133,6 +133,7 @@ public class TrustDrawable extends Drawable {
if (!mAnimating) {
mAnimating = true;
updateState(true);
+ invalidateSelf();
}
}
@@ -146,18 +147,21 @@ public class TrustDrawable extends Drawable {
mState = STATE_UNSET;
mCurAlpha = 0;
mCurInnerRadius = mInnerRadiusEnter;
+ invalidateSelf();
}
}
public void setTrustManaged(boolean trustManaged) {
if (trustManaged == mTrustManaged && mState != STATE_UNSET) return;
mTrustManaged = trustManaged;
- if (mAnimating) {
- updateState(true);
- }
+ updateState(true);
}
- private void updateState(boolean animate) {
+ private void updateState(boolean allowTransientState) {
+ if (!mAnimating) {
+ return;
+ }
+
int nextState = mState;
if (mState == STATE_UNSET) {
nextState = mTrustManaged ? STATE_ENTERING : STATE_GONE;
@@ -170,7 +174,7 @@ public class TrustDrawable extends Drawable {
} else if (mState == STATE_EXITING) {
if (mTrustManaged) nextState = STATE_ENTERING;
}
- if (!animate) {
+ if (!allowTransientState) {
if (nextState == STATE_ENTERING) nextState = STATE_VISIBLE;
if (nextState == STATE_EXITING) nextState = STATE_GONE;
}
@@ -200,9 +204,8 @@ public class TrustDrawable extends Drawable {
mState = nextState;
if (mCurAnimator != null) {
mCurAnimator.start();
- } else {
- invalidateSelf();
}
+ invalidateSelf();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiAccessPointController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AccessPointController.java
index b800fbf..0a385d7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiAccessPointController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AccessPointController.java
@@ -16,15 +16,20 @@
package com.android.systemui.statusbar.policy;
+import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiManager.ActionListener;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.provider.Settings;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -39,9 +44,13 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-public class WifiAccessPointController {
- private static final String TAG = "WifiAccessPointController";
- private static final boolean DEBUG = false;
+public class AccessPointController {
+ private static final String TAG = "AccessPointController";
+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+
+ // This string extra specifies a network to open the connect dialog on, so the user can enter
+ // network credentials. This is used by quick settings for secured networks.
+ private static final String EXTRA_START_CONNECT_SSID = "wifi_start_connect_ssid";
private static final int[] ICONS = {
R.drawable.ic_qs_wifi_0,
@@ -54,13 +63,26 @@ public class WifiAccessPointController {
private final Context mContext;
private final ArrayList<AccessPointCallback> mCallbacks = new ArrayList<AccessPointCallback>();
private final WifiManager mWifiManager;
+ private final UserManager mUserManager;
private final Receiver mReceiver = new Receiver();
private boolean mScanning;
+ private int mCurrentUser;
- public WifiAccessPointController(Context context) {
+ public AccessPointController(Context context) {
mContext = context;
mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
+ mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ mCurrentUser = ActivityManager.getCurrentUser();
+ }
+
+ public boolean canConfigWifi() {
+ return !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI,
+ new UserHandle(mCurrentUser));
+ }
+
+ void onUserSwitched(int newUserId) {
+ mCurrentUser = newUserId;
}
public void addCallback(AccessPointCallback callback) {
@@ -81,22 +103,31 @@ public class WifiAccessPointController {
if (mScanning) return;
if (DEBUG) Log.d(TAG, "scan!");
mScanning = mWifiManager.startScan();
+ // Grab current networks immediately while we wait for scan.
+ updateAccessPoints();
}
- public void connect(AccessPoint ap) {
- if (ap == null || ap.networkId < 0) return;
+ public boolean connect(AccessPoint ap) {
+ if (ap == null) return false;
if (DEBUG) Log.d(TAG, "connect networkId=" + ap.networkId);
- mWifiManager.connect(ap.networkId, new ActionListener() {
- @Override
- public void onSuccess() {
- if (DEBUG) Log.d(TAG, "connect success");
- }
-
- @Override
- public void onFailure(int reason) {
- if (DEBUG) Log.d(TAG, "connect failure reason=" + reason);
+ if (ap.networkId < 0) {
+ // Unknown network, need to add it.
+ if (ap.hasSecurity) {
+ Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
+ intent.putExtra(EXTRA_START_CONNECT_SSID, ap.ssid);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mContext.startActivity(intent);
+ return true;
+ } else {
+ WifiConfiguration config = new WifiConfiguration();
+ config.SSID = "\"" + ap.ssid + "\"";
+ config.allowedKeyManagement.set(KeyMgmt.NONE);
+ mWifiManager.connect(config, mConnectListener);
}
- });
+ } else {
+ mWifiManager.connect(ap.networkId, mConnectListener);
+ }
+ return false;
}
private void fireCallback(AccessPoint[] aps) {
@@ -139,23 +170,40 @@ public class WifiAccessPointController {
}
final String ssid = scanResult.SSID;
if (TextUtils.isEmpty(ssid) || ssids.contains(ssid)) continue;
- if (!configured.containsKey(ssid)) continue;
ssids.add(ssid);
final WifiConfiguration config = configured.get(ssid);
final int level = WifiManager.calculateSignalLevel(scanResult.level, ICONS.length);
final AccessPoint ap = new AccessPoint();
+ ap.isConfigured = config != null;
ap.networkId = config != null ? config.networkId : AccessPoint.NO_NETWORK;
ap.ssid = ssid;
ap.iconId = ICONS[level];
ap.isConnected = ap.networkId != AccessPoint.NO_NETWORK
&& ap.networkId == connectedNetworkId;
ap.level = level;
+ // Based on Settings AccessPoint#getSecurity, keep up to date
+ // with better methods of determining no security or not.
+ ap.hasSecurity = scanResult.capabilities.contains("WEP")
+ || scanResult.capabilities.contains("PSK")
+ || scanResult.capabilities.contains("EAP");
aps.add(ap);
}
Collections.sort(aps, mByStrength);
fireCallback(aps.toArray(new AccessPoint[aps.size()]));
}
+ private final ActionListener mConnectListener = new ActionListener() {
+ @Override
+ public void onSuccess() {
+ if (DEBUG) Log.d(TAG, "connect success");
+ }
+
+ @Override
+ public void onFailure(int reason) {
+ if (DEBUG) Log.d(TAG, "connect failure reason=" + reason);
+ }
+ };
+
private final Comparator<AccessPoint> mByStrength = new Comparator<AccessPoint> () {
@Override
public int compare(AccessPoint lhs, AccessPoint rhs) {
@@ -163,7 +211,7 @@ public class WifiAccessPointController {
}
private int score(AccessPoint ap) {
- return ap.level + (ap.isConnected ? 10 : 0);
+ return ap.level + (ap.isConnected ? 20 : 0) + (ap.isConfigured ? 10 : 0);
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java
index 6f021ac..33f7aff 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java
@@ -308,7 +308,11 @@ public class FlashlightController {
new CameraCaptureSession.StateListener() {
@Override
public void onConfigured(CameraCaptureSession session) {
- mSession = session;
+ if (session.getDevice() == mCameraDevice) {
+ mSession = session;
+ } else {
+ session.close();
+ }
postUpdateFlashlight();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
index 84216a4..11ff272 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
@@ -54,7 +54,6 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
private EdgeSwipeHelper mEdgeSwipeHelper;
private PhoneStatusBar mBar;
- private ExpandHelper mExpandHelper;
private long mStartTouchTime;
private ViewGroup mContentHolder;
@@ -102,6 +101,7 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
if (mHeadsUp != null) {
mHeadsUp.row.setSystemExpanded(true);
mHeadsUp.row.setSensitive(false);
+ mHeadsUp.row.setHeadsUp(true);
mHeadsUp.row.setHideSensitive(
false, false /* animated */, 0 /* delay */, 0 /* duration */);
if (mContentHolder == null) {
@@ -205,7 +205,6 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_min_height);
int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_max_height);
- mExpandHelper = new ExpandHelper(getContext(), this, minHeight, maxHeight);
mContentHolder = (ViewGroup) findViewById(R.id.content_holder);
mContentHolder.setOutlineProvider(CONTENT_HOLDER_OUTLINE_PROVIDER);
@@ -226,7 +225,6 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
}
return mEdgeSwipeHelper.onInterceptTouchEvent(ev)
|| mSwipeHelper.onInterceptTouchEvent(ev)
- || mExpandHelper.onInterceptTouchEvent(ev)
|| super.onInterceptTouchEvent(ev);
}
@@ -254,7 +252,6 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
mBar.resetHeadsUpDecayTimer();
return mEdgeSwipeHelper.onTouchEvent(ev)
|| mSwipeHelper.onTouchEvent(ev)
- || mExpandHelper.onTouchEvent(ev)
|| super.onTouchEvent(ev);
}
@@ -399,15 +396,12 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
final float dY = ev.getY() - mFirstY;
final float daX = Math.abs(ev.getX() - mFirstX);
final float daY = Math.abs(dY);
- if (!mConsuming && (4f * daX) < daY && daY > mTouchSlop) {
+ if (!mConsuming && daX < daY && daY > mTouchSlop) {
+ releaseAndClose();
if (dY > 0) {
if (DEBUG_EDGE_SWIPE) Log.d(TAG, "found an open");
mBar.animateExpandNotificationsPanel();
}
- if (dY < 0) {
- if (DEBUG_EDGE_SWIPE) Log.d(TAG, "found a close");
- mBar.onHeadsUpDismissed();
- }
mConsuming = true;
}
break;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java
index a3765aa..6998791 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java
@@ -102,7 +102,6 @@ public class KeyButtonRipple extends Drawable {
}
}
-
@Override
public void draw(Canvas canvas) {
mSupportHardware = canvas.isHardwareAccelerated();
@@ -176,6 +175,11 @@ public class KeyButtonRipple extends Drawable {
}
@Override
+ public void jumpToCurrentState() {
+ cancelAnimations();
+ }
+
+ @Override
public boolean isStateful() {
return true;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
index 7cc75da..b9cc0f9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
@@ -17,38 +17,27 @@
package com.android.systemui.statusbar.policy;
import android.animation.Animator;
-import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
-import android.animation.TimeInterpolator;
import android.app.ActivityManager;
import android.content.Context;
import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.CanvasProperty;
-import android.graphics.Paint;
-import android.graphics.RectF;
import android.hardware.input.InputManager;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.Log;
-import android.util.MathUtils;
import android.view.HapticFeedbackConstants;
-import android.view.HardwareCanvas;
import android.view.InputDevice;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.MotionEvent;
-import android.view.RenderNodeAnimator;
import android.view.SoundEffectConstants;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ImageView;
-import java.lang.Math;
-import java.util.ArrayList;
import com.android.systemui.R;
@@ -124,6 +113,14 @@ public class KeyButtonView extends ImageView {
}
@Override
+ protected void onWindowVisibilityChanged(int visibility) {
+ super.onWindowVisibilityChanged(visibility);
+ if (visibility != View.VISIBLE) {
+ jumpDrawablesToCurrentState();
+ }
+ }
+
+ @Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
if (action == ACTION_CLICK && mCode != 0) {
sendEvent(KeyEvent.ACTION_DOWN, 0, SystemClock.uptimeMillis());
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
index 8f0000f..297ff70 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
@@ -19,15 +19,16 @@ package com.android.systemui.statusbar.policy;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
-import android.animation.ValueAnimator;
import android.content.Context;
import android.database.DataSetObserver;
+import android.util.AttributeSet;
import android.view.LayoutInflater;
+import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.animation.AnimationUtils;
-import android.widget.TextView;
+import android.widget.FrameLayout;
import com.android.keyguard.AppearAnimationUtils;
import com.android.systemui.R;
@@ -35,8 +36,6 @@ import com.android.systemui.qs.tiles.UserDetailItemView;
import com.android.systemui.statusbar.phone.KeyguardStatusBarView;
import com.android.systemui.statusbar.phone.NotificationPanelView;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
-import com.android.systemui.statusbar.phone.StatusBarHeaderView;
-import com.android.systemui.statusbar.phone.UserAvatarView;
/**
* Manages the user switcher on the Keyguard.
@@ -46,6 +45,7 @@ public class KeyguardUserSwitcher {
private static final String TAG = "KeyguardUserSwitcher";
private static final boolean ALWAYS_ON = false;
+ private final Container mUserSwitcherContainer;
private final ViewGroup mUserSwitcher;
private final KeyguardStatusBarView mStatusBarView;
private final Adapter mAdapter;
@@ -53,24 +53,29 @@ public class KeyguardUserSwitcher {
private final KeyguardUserSwitcherScrim mBackground;
private ObjectAnimator mBgAnimator;
private UserSwitcherController mUserSwitcherController;
+ private boolean mAnimating;
public KeyguardUserSwitcher(Context context, ViewStub userSwitcher,
KeyguardStatusBarView statusBarView, NotificationPanelView panelView,
UserSwitcherController userSwitcherController) {
if (context.getResources().getBoolean(R.bool.config_keyguardUserSwitcher) || ALWAYS_ON) {
- mUserSwitcher = (ViewGroup) userSwitcher.inflate();
+ mUserSwitcherContainer = (Container) userSwitcher.inflate();
+ mUserSwitcher = (ViewGroup)
+ mUserSwitcherContainer.findViewById(R.id.keyguard_user_switcher_inner);
mBackground = new KeyguardUserSwitcherScrim(mUserSwitcher);
mUserSwitcher.setBackground(mBackground);
mStatusBarView = statusBarView;
mStatusBarView.setKeyguardUserSwitcher(this);
panelView.setKeyguardUserSwitcher(this);
- mAdapter = new Adapter(context, userSwitcherController);
+ mAdapter = new Adapter(context, userSwitcherController, this);
mAdapter.registerDataSetObserver(mDataSetObserver);
mUserSwitcherController = userSwitcherController;
mAppearAnimationUtils = new AppearAnimationUtils(context, 400, -0.5f, 0.5f,
AnimationUtils.loadInterpolator(
context, android.R.interpolator.fast_out_slow_in));
+ mUserSwitcherContainer.setKeyguardUserSwitcher(this);
} else {
+ mUserSwitcherContainer = null;
mUserSwitcher = null;
mStatusBarView = null;
mAdapter = null;
@@ -98,9 +103,9 @@ public class KeyguardUserSwitcher {
}
public void show(boolean animate) {
- if (mUserSwitcher != null && mUserSwitcher.getVisibility() != View.VISIBLE) {
+ if (mUserSwitcher != null && mUserSwitcherContainer.getVisibility() != View.VISIBLE) {
cancelAnimations();
- mUserSwitcher.setVisibility(View.VISIBLE);
+ mUserSwitcherContainer.setVisibility(View.VISIBLE);
mStatusBarView.setKeyguardUserSwitcherShowing(true, animate);
if (animate) {
startAppearAnimation();
@@ -108,13 +113,13 @@ public class KeyguardUserSwitcher {
}
}
- public void hide(boolean animate) {
- if (mUserSwitcher != null && mUserSwitcher.getVisibility() == View.VISIBLE) {
+ private void hide(boolean animate) {
+ if (mUserSwitcher != null && mUserSwitcherContainer.getVisibility() == View.VISIBLE) {
cancelAnimations();
if (animate) {
startDisappearAnimation();
} else {
- mUserSwitcher.setVisibility(View.GONE);
+ mUserSwitcherContainer.setVisibility(View.GONE);
}
mStatusBarView.setKeyguardUserSwitcherShowing(false, animate);
}
@@ -129,6 +134,7 @@ public class KeyguardUserSwitcher {
mBgAnimator.cancel();
}
mUserSwitcher.animate().cancel();
+ mAnimating = false;
}
private void startAppearAnimation() {
@@ -146,6 +152,7 @@ public class KeyguardUserSwitcher {
mUserSwitcher.setClipToPadding(true);
}
});
+ mAnimating = true;
mBgAnimator = ObjectAnimator.ofInt(mBackground, "alpha", 0, 255);
mBgAnimator.setDuration(400);
mBgAnimator.setInterpolator(PhoneStatusBar.ALPHA_IN);
@@ -153,12 +160,14 @@ public class KeyguardUserSwitcher {
@Override
public void onAnimationEnd(Animator animation) {
mBgAnimator = null;
+ mAnimating = false;
}
});
mBgAnimator.start();
}
private void startDisappearAnimation() {
+ mAnimating = true;
mUserSwitcher.animate()
.alpha(0f)
.setDuration(300)
@@ -166,8 +175,9 @@ public class KeyguardUserSwitcher {
.withEndAction(new Runnable() {
@Override
public void run() {
- mUserSwitcher.setVisibility(View.GONE);
+ mUserSwitcherContainer.setVisibility(View.GONE);
mUserSwitcher.setAlpha(1f);
+ mAnimating = false;
}
});
}
@@ -198,6 +208,16 @@ public class KeyguardUserSwitcher {
}
}
+ public void hideIfNotSimple(boolean animate) {
+ if (mUserSwitcherContainer != null && !mUserSwitcherController.isSimpleUserSwitcher()) {
+ hide(animate);
+ }
+ }
+
+ boolean isAnimating() {
+ return mAnimating;
+ }
+
public final DataSetObserver mDataSetObserver = new DataSetObserver() {
@Override
public void onChanged() {
@@ -209,10 +229,13 @@ public class KeyguardUserSwitcher {
View.OnClickListener {
private Context mContext;
+ private KeyguardUserSwitcher mKeyguardUserSwitcher;
- public Adapter(Context context, UserSwitcherController controller) {
+ public Adapter(Context context, UserSwitcherController controller,
+ KeyguardUserSwitcher kgu) {
super(controller);
mContext = context;
+ mKeyguardUserSwitcher = kgu;
}
@Override
@@ -240,7 +263,37 @@ public class KeyguardUserSwitcher {
@Override
public void onClick(View v) {
- switchTo(((UserSwitcherController.UserRecord)v.getTag()));
+ UserSwitcherController.UserRecord user = (UserSwitcherController.UserRecord) v.getTag();
+ if (user.isCurrent && !user.isGuest) {
+ // Close the switcher if tapping the current user. Guest is excluded because
+ // tapping the guest user while it's current clears the session.
+ mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */);
+ } else {
+ switchTo(user);
+ }
+ }
+ }
+
+ public static class Container extends FrameLayout {
+
+ private KeyguardUserSwitcher mKeyguardUserSwitcher;
+
+ public Container(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setClipChildren(false);
+ }
+
+ public void setKeyguardUserSwitcher(KeyguardUserSwitcher keyguardUserSwitcher) {
+ mKeyguardUserSwitcher = keyguardUserSwitcher;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent ev) {
+ // Hide switcher if it didn't handle the touch event (and let the event go through).
+ if (mKeyguardUserSwitcher != null && !mKeyguardUserSwitcher.isAnimating()) {
+ mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */);
+ }
+ return false;
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java
index 4363037..a5fc2fe 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java
@@ -42,7 +42,7 @@ public class KeyguardUserSwitcherScrim extends Drawable
private int mDarkColor;
private int mTop;
- private int mAlpha;
+ private int mAlpha = 255;
private Paint mRadialGradientPaint = new Paint();
private int mLayoutWidth;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index 2ed9366..bb29d01 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -39,11 +39,13 @@ public interface NetworkController {
void addAccessPointCallback(AccessPointCallback callback);
void removeAccessPointCallback(AccessPointCallback callback);
void scanForAccessPoints();
- void connect(AccessPoint ap);
+ boolean connect(AccessPoint ap);
boolean isMobileDataSupported();
boolean isMobileDataEnabled();
void setMobileDataEnabled(boolean enabled);
DataUsageInfo getDataUsageInfo();
+ boolean canConfigWifi();
+ void onUserSwitched(int newUserId);
public interface AccessPointCallback {
void onAccessPointsChanged(AccessPoint[] accessPoints);
@@ -56,6 +58,8 @@ public interface NetworkController {
public int iconId;
public String ssid;
public boolean isConnected;
+ public boolean isConfigured;
+ public boolean hasSecurity;
public int level; // 0 - 5
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index 3625997..9cfd26b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -41,6 +41,7 @@ import android.util.Log;
import android.view.View;
import android.widget.TextView;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.cdma.EriInfo;
@@ -164,13 +165,13 @@ public class NetworkControllerImpl extends BroadcastReceiver
public interface SignalCluster {
void setWifiIndicators(boolean visible, int strengthIcon, String contentDescription);
void setMobileDataIndicators(boolean visible, int strengthIcon, int typeIcon,
- String contentDescription, String typeContentDescription, boolean roaming,
- boolean isTypeIconWide);
+ String contentDescription, String typeContentDescription, boolean isTypeIconWide);
void setIsAirplaneMode(boolean is, int airplaneIcon);
}
- private final WifiAccessPointController mAccessPoints;
+ private final AccessPointController mAccessPoints;
private final MobileDataController mMobileDataController;
+ private final ConnectivityManager mConnectivityManager;
/**
* Construct this controller object and register for updates.
@@ -179,9 +180,9 @@ public class NetworkControllerImpl extends BroadcastReceiver
mContext = context;
final Resources res = context.getResources();
- ConnectivityManager cm = (ConnectivityManager)mContext.getSystemService(
- Context.CONNECTIVITY_SERVICE);
- mHasMobileDataFeature = cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
+ mConnectivityManager =
+ (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
+ mHasMobileDataFeature = getCM().isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
mShowPhoneRSSIForData = res.getBoolean(R.bool.config_showPhoneRSSIForData);
mShowAtLeastThreeGees = res.getBoolean(R.bool.config_showMin3G);
@@ -193,13 +194,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
updateWimaxIcons();
// telephony
- mPhone = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
- mPhone.listen(mPhoneStateListener,
- PhoneStateListener.LISTEN_SERVICE_STATE
- | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
- | PhoneStateListener.LISTEN_CALL_STATE
- | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
- | PhoneStateListener.LISTEN_DATA_ACTIVITY);
+ mPhone = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
mHspaDataDistinguishable = mContext.getResources().getBoolean(
R.bool.config_hspa_data_distinguishable);
mNetworkNameSeparator = mContext.getString(R.string.status_bar_network_name_separator);
@@ -216,6 +211,36 @@ public class NetworkControllerImpl extends BroadcastReceiver
mWifiChannel.connect(mContext, handler, wifiMessenger);
}
+ registerListeners();
+
+ // AIRPLANE_MODE_CHANGED is sent at boot; we've probably already missed it
+ updateAirplaneMode();
+
+ mLastLocale = mContext.getResources().getConfiguration().locale;
+ mAccessPoints = new AccessPointController(mContext);
+ mMobileDataController = new MobileDataController(mContext);
+ mMobileDataController.setCallback(new MobileDataController.Callback() {
+ @Override
+ public void onMobileDataEnabled(boolean enabled) {
+ notifyMobileDataEnabled(enabled);
+ }
+ });
+ }
+
+ @VisibleForTesting
+ protected ConnectivityManager getCM() {
+ return mConnectivityManager;
+ }
+
+ @VisibleForTesting
+ protected void registerListeners() {
+ mPhone.listen(mPhoneStateListener,
+ PhoneStateListener.LISTEN_SERVICE_STATE
+ | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
+ | PhoneStateListener.LISTEN_CALL_STATE
+ | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
+ | PhoneStateListener.LISTEN_DATA_ACTIVITY);
+
// broadcasts
IntentFilter filter = new IntentFilter();
filter.addAction(WifiManager.RSSI_CHANGED_ACTION);
@@ -234,20 +259,17 @@ public class NetworkControllerImpl extends BroadcastReceiver
filter.addAction(WimaxManagerConstants.SIGNAL_LEVEL_CHANGED_ACTION);
filter.addAction(WimaxManagerConstants.NET_4G_STATE_CHANGED_ACTION);
}
- context.registerReceiver(this, filter);
+ mContext.registerReceiver(this, filter);
+ }
- // AIRPLANE_MODE_CHANGED is sent at boot; we've probably already missed it
- updateAirplaneMode();
+ @Override
+ public boolean canConfigWifi() {
+ return mAccessPoints.canConfigWifi();
+ }
- mLastLocale = mContext.getResources().getConfiguration().locale;
- mAccessPoints = new WifiAccessPointController(mContext);
- mMobileDataController = new MobileDataController(mContext);
- mMobileDataController.setCallback(new MobileDataController.Callback() {
- @Override
- public void onMobileDataEnabled(boolean enabled) {
- notifyMobileDataEnabled(enabled);
- }
- });
+ @Override
+ public void onUserSwitched(int newUserId) {
+ mAccessPoints.onUserSwitched(newUserId);
}
private void notifyMobileDataEnabled(boolean enabled) {
@@ -314,8 +336,8 @@ public class NetworkControllerImpl extends BroadcastReceiver
}
@Override
- public void connect(AccessPoint ap) {
- mAccessPoints.connect(ap);
+ public boolean connect(AccessPoint ap) {
+ return mAccessPoints.connect(ap);
}
@Override
@@ -386,7 +408,6 @@ public class NetworkControllerImpl extends BroadcastReceiver
mDataTypeIconId,
mContentDescriptionWimax,
mContentDescriptionDataType,
- mDataTypeIconId == TelephonyIcons.ROAMING_ICON,
false /* isTypeIconWide */ );
} else {
// normal mobile data
@@ -396,7 +417,6 @@ public class NetworkControllerImpl extends BroadcastReceiver
mDataTypeIconId,
mContentDescriptionPhoneSignal,
mContentDescriptionDataType,
- mDataTypeIconId == TelephonyIcons.ROAMING_ICON,
isTypeIconWide(mDataTypeIconId));
}
cluster.setIsAirplaneMode(mAirplaneMode, mAirplaneIconId);
@@ -1065,9 +1085,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
Log.d(TAG, "updateConnectivity: intent=" + intent);
}
- final ConnectivityManager connManager = (ConnectivityManager) mContext
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- final NetworkInfo info = connManager.getActiveNetworkInfo();
+ final NetworkInfo info = getCM().getActiveNetworkInfo();
// Are we connected at all, by any interface?
mConnected = info != null && info.isConnected();
@@ -1606,7 +1624,6 @@ public class NetworkControllerImpl extends BroadcastReceiver
mDemoDataTypeIconId,
"Demo",
"Demo",
- mDemoDataTypeIconId == TelephonyIcons.ROAMING_ICON,
isTypeIconWide(mDemoDataTypeIconId));
}
refreshViews();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java
deleted file mode 100644
index f339401..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2010 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.statusbar.policy;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-
-public class Prefs {
- private static final String SHARED_PREFS_NAME = "status_bar";
-
- public static SharedPreferences read(Context context) {
- return context.getSharedPreferences(Prefs.SHARED_PREFS_NAME, Context.MODE_PRIVATE);
- }
-
- public static SharedPreferences.Editor edit(Context context) {
- return context.getSharedPreferences(Prefs.SHARED_PREFS_NAME, Context.MODE_PRIVATE).edit();
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index 4a20406..d543cff 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -40,6 +40,7 @@ import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.ExpandableView;
import com.android.systemui.statusbar.SpeedBumpView;
+import com.android.systemui.statusbar.StackScrollerDecorView;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.policy.ScrollAdapter;
@@ -70,6 +71,12 @@ public class NotificationStackScrollLayout extends ViewGroup
private SwipeHelper mSwipeHelper;
private boolean mSwipingInProgress;
private int mCurrentStackHeight = Integer.MAX_VALUE;
+
+ /**
+ * mCurrentStackHeight is the actual stack height, mLastSetStackHeight is the stack height set
+ * externally from {@link #setStackHeight}
+ */
+ private float mLastSetStackHeight;
private int mOwnScrollY;
private int mMaxLayoutHeight;
@@ -84,6 +91,9 @@ public class NotificationStackScrollLayout extends ViewGroup
private int mLastMotionY;
private int mDownX;
private int mActivePointerId;
+ private boolean mTouchIsClick;
+ private float mInitialTouchX;
+ private float mInitialTouchY;
private int mSidePaddings;
private Paint mDebugPaint;
@@ -133,6 +143,7 @@ public class NotificationStackScrollLayout extends ViewGroup
private OnChildLocationsChangedListener mListener;
private OnOverscrollTopChangedListener mOverscrollTopChangedListener;
private ExpandableView.OnHeightChangedListener mOnHeightChangedListener;
+ private OnEmptySpaceClickListener mOnEmptySpaceClickListener;
private boolean mNeedsAnimation;
private boolean mTopPaddingNeedsAnimation;
private boolean mDimmedNeedsAnimation;
@@ -367,6 +378,9 @@ public class NotificationStackScrollLayout extends ViewGroup
if (childViewState == null) {
return ViewState.LOCATION_UNKNOWN;
}
+ if (childViewState.gone) {
+ return ViewState.LOCATION_GONE;
+ }
return childViewState.location;
}
@@ -445,6 +459,7 @@ public class NotificationStackScrollLayout extends ViewGroup
* @param height the new height of the stack
*/
public void setStackHeight(float height) {
+ mLastSetStackHeight = height;
setIsExpanded(height > 0.0f);
int newStackHeight = (int) height;
int minStackHeight = getMinStackHeight();
@@ -581,7 +596,9 @@ public class NotificationStackScrollLayout extends ViewGroup
final int count = getChildCount();
for (int childIdx = 0; childIdx < count; childIdx++) {
ExpandableView slidingChild = (ExpandableView) getChildAt(childIdx);
- if (slidingChild.getVisibility() == GONE) {
+ if (slidingChild.getVisibility() == GONE
+ || slidingChild instanceof StackScrollerDecorView
+ || slidingChild == mSpeedBumpView) {
continue;
}
float childTop = slidingChild.getTranslationY();
@@ -687,6 +704,7 @@ public class NotificationStackScrollLayout extends ViewGroup
transformTouchEvent(ev, this, mScrollView);
return mScrollView.onTouchEvent(ev);
}
+ handleEmptySpaceClick(ev);
boolean expandWantsIt = false;
if (!mSwipingInProgress && !mOnlyScrollingInThisMotion && isScrollingEnabled()) {
if (isCancelOrUp) {
@@ -1338,7 +1356,19 @@ public class NotificationStackScrollLayout extends ViewGroup
&& initialVelocity > 0;
}
- public void updateTopPadding(float qsHeight, int scrollY, boolean animate) {
+ /**
+ * Updates the top padding of the notifications, taking {@link #getIntrinsicPadding()} into
+ * account.
+ *
+ * @param qsHeight the top padding imposed by the quick settings panel
+ * @param scrollY how much the notifications are scrolled inside the QS/notifications scroll
+ * container
+ * @param animate whether to animate the change
+ * @param ignoreIntrinsicPadding if true, {@link #getIntrinsicPadding()} is ignored and
+ * {@code qsHeight} is the final top padding
+ */
+ public void updateTopPadding(float qsHeight, int scrollY, boolean animate,
+ boolean ignoreIntrinsicPadding) {
float start = qsHeight - scrollY + mNotificationTopPadding;
float stackHeight = getHeight() - start;
int minStackHeight = getMinStackHeight();
@@ -1346,13 +1376,13 @@ public class NotificationStackScrollLayout extends ViewGroup
float overflow = minStackHeight - stackHeight;
stackHeight = minStackHeight;
start = getHeight() - stackHeight;
- setTranslationY(overflow);
mTopPaddingOverflow = overflow;
} else {
- setTranslationY(0);
mTopPaddingOverflow = 0;
}
- setTopPadding(clampPadding((int) start), animate);
+ setTopPadding(ignoreIntrinsicPadding ? (int) start : clampPadding((int) start),
+ animate);
+ setStackHeight(mLastSetStackHeight);
}
public int getNotificationTopPadding() {
@@ -1430,6 +1460,7 @@ public class NotificationStackScrollLayout extends ViewGroup
transformTouchEvent(ev, mScrollView, this);
}
initDownStates(ev);
+ handleEmptySpaceClick(ev);
boolean expandWantsIt = false;
if (!mSwipingInProgress && !mOnlyScrollingInThisMotion && isScrollingEnabled()) {
expandWantsIt = mExpandHelper.onInterceptTouchEvent(ev);
@@ -1448,11 +1479,31 @@ public class NotificationStackScrollLayout extends ViewGroup
return swipeWantsIt || scrollWantsIt || expandWantsIt || super.onInterceptTouchEvent(ev);
}
+ private void handleEmptySpaceClick(MotionEvent ev) {
+ switch (ev.getActionMasked()) {
+ case MotionEvent.ACTION_MOVE:
+ if (mTouchIsClick && (Math.abs(ev.getY() - mInitialTouchY) > mTouchSlop
+ || Math.abs(ev.getX() - mInitialTouchX) > mTouchSlop )) {
+ mTouchIsClick = false;
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ if (mPhoneStatusBar.getBarState() != StatusBarState.KEYGUARD && mTouchIsClick &&
+ isBelowLastNotification(mInitialTouchX, mInitialTouchY)) {
+ mOnEmptySpaceClickListener.onEmptySpaceClicked(mInitialTouchX, mInitialTouchY);
+ }
+ break;
+ }
+ }
+
private void initDownStates(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
mExpandedInThisMotion = false;
mOnlyScrollingInThisMotion = !mScroller.isFinished();
mDisallowScrollingInThisMotion = false;
+ mTouchIsClick = true;
+ mInitialTouchX = ev.getX();
+ mInitialTouchY = ev.getY();
}
}
@@ -1886,7 +1937,14 @@ public class NotificationStackScrollLayout extends ViewGroup
* @return Whether the specified motion event is actually happening over the content.
*/
private boolean isInContentBounds(MotionEvent event) {
- return event.getY() < getHeight() - getEmptyBottomMargin();
+ return isInContentBounds(event.getY());
+ }
+
+ /**
+ * @return Whether a y coordinate is inside the content.
+ */
+ public boolean isInContentBounds(float y) {
+ return y < getHeight() - getEmptyBottomMargin();
}
private void setIsBeingDragged(boolean isDragged) {
@@ -1995,6 +2053,10 @@ public class NotificationStackScrollLayout extends ViewGroup
this.mOnHeightChangedListener = mOnHeightChangedListener;
}
+ public void setOnEmptySpaceClickListener(OnEmptySpaceClickListener listener) {
+ mOnEmptySpaceClickListener = listener;
+ }
+
public void onChildAnimationFinished() {
requestChildrenUpdate();
}
@@ -2210,6 +2272,10 @@ public class NotificationStackScrollLayout extends ViewGroup
return height;
}
+ public int getEmptyShadeViewHeight() {
+ return mEmptyShadeView.getHeight();
+ }
+
public float getBottomMostNotificationBottom() {
final int count = getChildCount();
float max = 0;
@@ -2245,6 +2311,24 @@ public class NotificationStackScrollLayout extends ViewGroup
}
}
+ private boolean isBelowLastNotification(float touchX, float touchY) {
+ ExpandableView lastChildNotGone = (ExpandableView) getLastChildNotGone();
+ if (lastChildNotGone == null) {
+ return touchY > mIntrinsicPadding;
+ }
+ if (lastChildNotGone != mDismissView && lastChildNotGone != mEmptyShadeView) {
+ return touchY > lastChildNotGone.getY() + lastChildNotGone.getActualHeight();
+ } else if (lastChildNotGone == mEmptyShadeView) {
+ return touchY > mEmptyShadeView.getY();
+ } else {
+ float dismissY = mDismissView.getY();
+ boolean belowDismissView = touchY > dismissY + mDismissView.getActualHeight();
+ return belowDismissView || (touchY > dismissY
+ && mDismissView.isOnEmptySpace(touchX - mDismissView.getX(),
+ touchY - dismissY));
+ }
+ }
+
/**
* A listener that is notified when some child locations might have changed.
*/
@@ -2253,6 +2337,13 @@ public class NotificationStackScrollLayout extends ViewGroup
}
/**
+ * A listener that is notified when the empty space below the notifications is clicked on
+ */
+ public interface OnEmptySpaceClickListener {
+ public void onEmptySpaceClicked(float x, float y);
+ }
+
+ /**
* A listener that gets notified when the overscroll at the top has changed.
*/
public interface OnOverscrollTopChangedListener {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
index 853628e..ddc4251 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
@@ -200,15 +200,25 @@ public class StackScrollAlgorithm {
// apply clipping and shadow
float newNotificationEnd = newYTranslation + newHeight;
- // In the unlocked shade we have to clip a little bit higher because of the rounded
- // corners of the notifications.
- float clippingCorrection = state.dimmed ? 0 : mRoundedRectCornerRadius * state.scale;
-
- // When the previous notification is swiped, we don't clip the content to the
- // bottom of it.
- float clipHeight = previousNotificationIsSwiped
- ? newHeight
- : newNotificationEnd - (previousNotificationEnd - clippingCorrection);
+ float clipHeight;
+ if (previousNotificationIsSwiped) {
+ // When the previous notification is swiped, we don't clip the content to the
+ // bottom of it.
+ clipHeight = newHeight;
+ } else {
+ clipHeight = newNotificationEnd - previousNotificationEnd;
+ clipHeight = Math.max(0.0f, clipHeight);
+ if (clipHeight != 0.0f) {
+
+ // In the unlocked shade we have to clip a little bit higher because of the rounded
+ // corners of the notifications, but only if we are not fully overlapped by
+ // the top card.
+ float clippingCorrection = state.dimmed
+ ? 0
+ : mRoundedRectCornerRadius * state.scale;
+ clipHeight += clippingCorrection;
+ }
+ }
updateChildClippingAndBackground(state, newHeight, clipHeight,
newHeight - (previousNotificationStart - newYTranslation));
@@ -669,7 +679,11 @@ public class StackScrollAlgorithm {
StackScrollState.ViewState childViewState = resultState.getViewStateForView(child);
if (i < algorithmState.itemsInTopStack) {
float stackIndex = algorithmState.itemsInTopStack - i;
- stackIndex = Math.min(stackIndex, MAX_ITEMS_IN_TOP_STACK + 2);
+
+ // Ensure that the topmost item is a little bit higher than the rest when fully
+ // scrolled, to avoid drawing errors when swiping it out
+ float max = MAX_ITEMS_IN_TOP_STACK + (i == 0 ? 2.5f : 2);
+ stackIndex = Math.min(stackIndex, max);
if (i == 0 && algorithmState.itemsInTopStack < 2.0f) {
// We only have the top item and an additional item in the top stack,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java
index 0967ecd..4611370 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java
@@ -119,9 +119,7 @@ public class StackScrollState {
}
// apply alpha
- if (!becomesInvisible) {
- child.setAlpha(newAlpha);
- }
+ child.setAlpha(newAlpha);
}
// apply visibility
@@ -236,6 +234,8 @@ public class StackScrollState {
public static final int LOCATION_MAIN_AREA = 0x08;
public static final int LOCATION_BOTTOM_STACK_PEEKING = 0x10;
public static final int LOCATION_BOTTOM_STACK_HIDDEN = 0x20;
+ /** The view isn't layouted at all. */
+ public static final int LOCATION_GONE = 0x40;
float alpha;
float yTranslation;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
index 433357e..674642b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
@@ -477,6 +477,7 @@ public class StackStateAnimator {
if (newEndValue == 0 && !mWasCancelled) {
child.setVisibility(View.INVISIBLE);
}
+ // remove the tag when the animation is finished
child.setTag(TAG_ANIMATOR_ALPHA, null);
child.setTag(TAG_START_ALPHA, null);
child.setTag(TAG_END_ALPHA, null);
@@ -498,13 +499,7 @@ public class StackStateAnimator {
animator.setStartDelay(delay);
}
animator.addListener(getGlobalAnimationFinishedListener());
- // remove the tag when the animation is finished
- animator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- }
- });
startAnimator(animator);
child.setTag(TAG_ANIMATOR_ALPHA, animator);
child.setTag(TAG_START_ALPHA, child.getAlpha());
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
index 1b6a9e1..08732e5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
@@ -178,4 +178,8 @@ public class TvStatusBar extends BaseStatusBar {
@Override
public void onActivationReset(ActivatableNotificationView view) {
}
+
+ @Override
+ public void showScreenPinningRequest() {
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
index 0586a83..0fe6d89 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
@@ -1,7 +1,6 @@
package com.android.systemui.volume;
import android.content.Context;
-import android.content.Intent;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.media.AudioManager;
@@ -11,13 +10,10 @@ import android.media.session.ISessionController;
import android.media.session.MediaController;
import android.media.session.MediaSessionManager;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Handler;
import android.os.RemoteException;
-import android.os.UserHandle;
import android.provider.Settings;
import android.util.Log;
-import android.view.WindowManagerGlobal;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
@@ -53,6 +49,7 @@ public class VolumeUI extends SystemUI {
private final Handler mHandler = new Handler();
+ private boolean mEnabled;
private AudioManager mAudioManager;
private MediaSessionManager mMediaSessionManager;
private VolumeController mVolumeController;
@@ -63,6 +60,8 @@ public class VolumeUI extends SystemUI {
@Override
public void start() {
+ mEnabled = mContext.getResources().getBoolean(R.bool.enable_volume_ui);
+ if (!mEnabled) return;
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
mMediaSessionManager = (MediaSessionManager) mContext
.getSystemService(Context.MEDIA_SESSION_SERVICE);
@@ -84,6 +83,7 @@ public class VolumeUI extends SystemUI {
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.print("mEnabled="); pw.println(mEnabled);
if (mPanel != null) {
mPanel.dump(fd, pw, args);
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
index ea431ae..28ecbf9 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
@@ -31,6 +31,7 @@ import android.provider.Settings;
import android.provider.Settings.Global;
import android.service.notification.Condition;
import android.service.notification.ZenModeConfig;
+import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.MathUtils;
@@ -68,6 +69,7 @@ public class ZenModePanel extends LinearLayout {
private static final int TIME_CONDITION_INDEX = 1;
private static final int FIRST_CONDITION_INDEX = 2;
private static final float SILENT_HINT_PULSE_SCALE = 1.1f;
+ private static final long SELECT_DEFAULT_DELAY = 300;
public static final Intent ZEN_SETTINGS = new Intent(Settings.ACTION_ZEN_MODE_SETTINGS);
@@ -220,7 +222,8 @@ public class ZenModePanel extends LinearLayout {
mBucketIndex = -1;
} else {
mBucketIndex = DEFAULT_BUCKET_INDEX;
- mTimeCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[mBucketIndex]);
+ mTimeCondition = ZenModeConfig.toTimeCondition(mContext,
+ MINUTE_BUCKETS[mBucketIndex]);
}
if (DEBUG) Log.d(mTag, "Initial bucket index: " + mBucketIndex);
mConditions = null; // reset conditions
@@ -339,9 +342,11 @@ public class ZenModePanel extends LinearLayout {
if (condition == null) return null;
final long time = ZenModeConfig.tryParseCountdownConditionId(condition.id);
if (time == 0) return null;
- final long span = time - System.currentTimeMillis();
+ final long now = System.currentTimeMillis();
+ final long span = time - now;
if (span <= 0 || span > MAX_BUCKET_MINUTES * MINUTES_MS) return null;
- return ZenModeConfig.toTimeCondition(time, Math.round(span / (float) MINUTES_MS));
+ return ZenModeConfig.toTimeCondition(mContext,
+ time, Math.round(span / (float) MINUTES_MS), now);
}
private void handleUpdateConditions(Condition[] conditions) {
@@ -369,8 +374,9 @@ public class ZenModePanel extends LinearLayout {
if (isDowntime(mSessionExitCondition) && !foundDowntime) {
bind(mSessionExitCondition, null);
}
- // ensure something is selected
- checkForDefault();
+ // ensure something is selected, after waiting for providers to respond
+ mHandler.removeMessages(H.SELECT_DEFAULT);
+ mHandler.sendEmptyMessageDelayed(H.SELECT_DEFAULT, SELECT_DEFAULT_DELAY);
}
private static boolean isDowntime(Condition c) {
@@ -381,7 +387,8 @@ public class ZenModePanel extends LinearLayout {
return (ConditionTag) mZenConditions.getChildAt(index).getTag();
}
- private void checkForDefault() {
+ private void handleSelectDefault() {
+ if (!mExpanded) return;
// are we left without anything selected? if so, set a default
for (int i = 0; i < mZenConditions.getChildCount(); i++) {
if (getConditionTagAt(i).rb.isChecked()) {
@@ -395,7 +402,7 @@ public class ZenModePanel extends LinearLayout {
if (favoriteIndex == -1) {
getConditionTagAt(FOREVER_CONDITION_INDEX).rb.setChecked(true);
} else {
- mTimeCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[favoriteIndex]);
+ mTimeCondition = ZenModeConfig.toTimeCondition(mContext, MINUTE_BUCKETS[favoriteIndex]);
mBucketIndex = favoriteIndex;
bind(mTimeCondition, mZenConditions.getChildAt(TIME_CONDITION_INDEX));
getConditionTagAt(TIME_CONDITION_INDEX).rb.setChecked(true);
@@ -430,7 +437,8 @@ public class ZenModePanel extends LinearLayout {
}
tag.condition = condition;
tag.rb.setEnabled(enabled);
- if (sameConditionId(mSessionExitCondition, tag.condition)) {
+ if (mSessionExitCondition != null
+ && sameConditionId(mSessionExitCondition, tag.condition)) {
tag.rb.setChecked(true);
}
tag.rb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@@ -450,16 +458,32 @@ public class ZenModePanel extends LinearLayout {
}
});
- if (tag.title == null) {
- tag.title = (TextView) row.findViewById(android.R.id.title);
+ if (tag.lines == null) {
+ tag.lines = row.findViewById(android.R.id.content);
}
+ if (tag.line1 == null) {
+ tag.line1 = (TextView) row.findViewById(android.R.id.text1);
+ }
+ if (tag.line2 == null) {
+ tag.line2 = (TextView) row.findViewById(android.R.id.text2);
+ }
+ final String line1, line2;
if (condition == null) {
- tag.title.setText(mContext.getString(com.android.internal.R.string.zen_mode_forever));
+ line1 = mContext.getString(com.android.internal.R.string.zen_mode_forever);
+ line2 = null;
+ } else {
+ line1 = !TextUtils.isEmpty(condition.line1) ? condition.line1 : condition.summary;
+ line2 = condition.line2;
+ }
+ tag.line1.setText(line1);
+ if (TextUtils.isEmpty(line2)) {
+ tag.line2.setVisibility(GONE);
} else {
- tag.title.setText(condition.summary);
+ tag.line2.setVisibility(VISIBLE);
+ tag.line2.setText(line2);
}
- tag.title.setEnabled(enabled);
- tag.title.setAlpha(enabled ? 1 : .4f);
+ tag.lines.setEnabled(enabled);
+ tag.lines.setAlpha(enabled ? 1 : .4f);
final ImageView button1 = (ImageView) row.findViewById(android.R.id.button1);
button1.setOnClickListener(new OnClickListener() {
@@ -476,7 +500,7 @@ public class ZenModePanel extends LinearLayout {
onClickTimeButton(row, tag, true /*up*/);
}
});
- tag.title.setOnClickListener(new OnClickListener() {
+ tag.lines.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tag.rb.setChecked(true);
@@ -491,7 +515,8 @@ public class ZenModePanel extends LinearLayout {
} else {
final long span = time - System.currentTimeMillis();
button1.setEnabled(span > MIN_BUCKET_MINUTES * MINUTES_MS);
- final Condition maxCondition = ZenModeConfig.toTimeCondition(MAX_BUCKET_MINUTES);
+ final Condition maxCondition = ZenModeConfig.toTimeCondition(mContext,
+ MAX_BUCKET_MINUTES);
button2.setEnabled(!Objects.equals(condition.summary, maxCondition.summary));
}
@@ -504,7 +529,7 @@ public class ZenModePanel extends LinearLayout {
// wire up interaction callbacks for newly-added condition rows
if (convertView == null) {
Interaction.register(tag.rb, mInteractionCallback);
- Interaction.register(tag.title, mInteractionCallback);
+ Interaction.register(tag.lines, mInteractionCallback);
Interaction.register(button1, mInteractionCallback);
Interaction.register(button2, mInteractionCallback);
}
@@ -524,7 +549,7 @@ public class ZenModePanel extends LinearLayout {
return;
}
announceForAccessibility(mContext.getString(R.string.zen_mode_and_condition, modeText,
- tag.title.getText()));
+ tag.line1.getText()));
}
private void onClickTimeButton(View row, ConditionTag tag, boolean up) {
@@ -541,18 +566,21 @@ public class ZenModePanel extends LinearLayout {
final long bucketTime = now + bucketMinutes * MINUTES_MS;
if (up && bucketTime > time || !up && bucketTime < time) {
mBucketIndex = j;
- newCondition = ZenModeConfig.toTimeCondition(bucketTime, bucketMinutes);
+ newCondition = ZenModeConfig.toTimeCondition(mContext,
+ bucketTime, bucketMinutes, now);
break;
}
}
if (newCondition == null) {
mBucketIndex = DEFAULT_BUCKET_INDEX;
- newCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[mBucketIndex]);
+ newCondition = ZenModeConfig.toTimeCondition(mContext,
+ MINUTE_BUCKETS[mBucketIndex]);
}
} else {
// on a known index, simply increment or decrement
mBucketIndex = Math.max(0, Math.min(N - 1, mBucketIndex + (up ? 1 : -1)));
- newCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[mBucketIndex]);
+ newCondition = ZenModeConfig.toTimeCondition(mContext,
+ MINUTE_BUCKETS[mBucketIndex]);
}
mTimeCondition = newCondition;
bind(mTimeCondition, row);
@@ -613,6 +641,7 @@ public class ZenModePanel extends LinearLayout {
private static final int UPDATE_CONDITIONS = 1;
private static final int EXIT_CONDITION_CHANGED = 2;
private static final int UPDATE_ZEN = 3;
+ private static final int SELECT_DEFAULT = 4;
private H() {
super(Looper.getMainLooper());
@@ -626,6 +655,8 @@ public class ZenModePanel extends LinearLayout {
handleExitConditionChanged((Condition) msg.obj);
} else if (msg.what == UPDATE_ZEN) {
handleUpdateZen(msg.arg1);
+ } else if (msg.what == SELECT_DEFAULT) {
+ handleSelectDefault();
}
}
}
@@ -639,7 +670,9 @@ public class ZenModePanel extends LinearLayout {
// used as the view tag on condition rows
private static class ConditionTag {
RadioButton rb;
- TextView title;
+ View lines;
+ TextView line1;
+ TextView line2;
Condition condition;
}
@@ -690,7 +723,7 @@ public class ZenModePanel extends LinearLayout {
}
private SharedPreferences prefs() {
- return mContext.getSharedPreferences(ZenModePanel.class.getSimpleName(), 0);
+ return mContext.getSharedPreferences(mContext.getPackageName(), 0);
}
private void updateMinuteIndex() {