am 4d655e7b: am 4135092c: am 303e5c41: am b9a73d2c: Merge "Stopping chronometers now when the shade is closed" into mnc-dr-dev

* commit '4d655e7b98eebba4e3b4912f508f789719e5e7b1':
  Stopping chronometers now when the shade is closed
This commit is contained in:
Selim Cinek
2015-10-16 23:49:13 +00:00
committed by Android Git Automerger
2 changed files with 55 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ import android.view.View;
import android.view.ViewStub;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.LinearInterpolator;
import android.widget.Chronometer;
import android.widget.ImageView;
import com.android.systemui.R;
@@ -88,6 +89,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
private NotificationGuts mGuts;
private StatusBarNotification mStatusBarNotification;
private boolean mIsHeadsUp;
private boolean mLastChronometerRunning = true;
private View mExpandButton;
private View mExpandButtonDivider;
private ViewStub mExpandButtonStub;
@@ -295,6 +297,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
*/
public void setPinned(boolean pinned) {
mIsPinned = pinned;
setChronometerRunning(mLastChronometerRunning);
}
public boolean isPinned() {
@@ -320,6 +323,41 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
return mJustClicked;
}
public void setChronometerRunning(boolean running) {
mLastChronometerRunning = running;
setChronometerRunning(running, mPrivateLayout);
setChronometerRunning(running, mPublicLayout);
if (mChildrenContainer != null) {
List<ExpandableNotificationRow> notificationChildren =
mChildrenContainer.getNotificationChildren();
for (int i = 0; i < notificationChildren.size(); i++) {
ExpandableNotificationRow child = notificationChildren.get(i);
child.setChronometerRunning(running);
}
}
}
private void setChronometerRunning(boolean running, NotificationContentView layout) {
if (layout != null) {
running = running || isPinned();
View contractedChild = layout.getContractedChild();
View expandedChild = layout.getExpandedChild();
View headsUpChild = layout.getHeadsUpChild();
setChronometerRunningForChild(running, contractedChild);
setChronometerRunningForChild(running, expandedChild);
setChronometerRunningForChild(running, headsUpChild);
}
}
private void setChronometerRunningForChild(boolean running, View child) {
if (child != null) {
View chronometer = child.findViewById(com.android.internal.R.id.chronometer);
if (chronometer instanceof Chronometer) {
((Chronometer) chronometer).setStarted(running);
}
}
}
public interface ExpansionLogger {
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
}

View File

@@ -1789,6 +1789,7 @@ public class NotificationStackScrollLayout extends ViewGroup
((ExpandableView) child).setOnHeightChangedListener(this);
generateAddAnimation(child, false /* fromMoreCard */);
updateAnimationState(child);
updateChronometerForChild(child);
if (canChildBeDismissed(child)) {
// Make sure the dismissButton is visible and not in the animated state.
// We need to do this to avoid a race where a clearable notification is added after the
@@ -2298,6 +2299,21 @@ public class NotificationStackScrollLayout extends ViewGroup
mStackScrollAlgorithm.setIsExpanded(isExpanded);
if (changed) {
updateNotificationAnimationStates();
updateChronometers();
}
}
private void updateChronometers() {
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
updateChronometerForChild(getChildAt(i));
}
}
private void updateChronometerForChild(View child) {
if (child instanceof ExpandableNotificationRow) {
ExpandableNotificationRow row = (ExpandableNotificationRow) child;
row.setChronometerRunning(mIsExpanded);
}
}
@@ -2320,6 +2336,7 @@ public class NotificationStackScrollLayout extends ViewGroup
}
mStackScrollAlgorithm.onReset(view);
updateAnimationState(view);
updateChronometerForChild(view);
}
private void updateScrollPositionOnExpandInBottom(ExpandableView view) {