Methods Summary |
---|
private void | animateInIconOfFirstTask()
if (mItemToAnimateInWhenWindowAnimationIsFinished != null &&
!mRecentTasksLoader.isFirstScreenful()) {
int timeSinceWindowAnimation =
(int) (System.currentTimeMillis() - mWindowAnimationStartTime);
final int minStartDelay = 150;
final int startDelay = Math.max(0, Math.min(
minStartDelay - timeSinceWindowAnimation, minStartDelay));
final int duration = 250;
final ViewHolder holder = mItemToAnimateInWhenWindowAnimationIsFinished;
final TimeInterpolator cubic = new DecelerateInterpolator(1.5f);
FirstFrameAnimatorHelper.initializeDrawListener(holder.iconView);
for (View v :
new View[] { holder.iconView, holder.labelView, holder.calloutLine }) {
if (v != null) {
ViewPropertyAnimator vpa = v.animate().translationX(0).translationY(0)
.alpha(1f).setStartDelay(startDelay)
.setDuration(duration).setInterpolator(cubic);
FirstFrameAnimatorHelper h = new FirstFrameAnimatorHelper(vpa, v);
}
}
mItemToAnimateInWhenWindowAnimationIsFinished = null;
mAnimateIconOfFirstTask = false;
}
|
public void | clearRecentTasksList()
// Clear memory used by screenshots
if (mRecentTaskDescriptions != null) {
mRecentTasksLoader.cancelLoadingThumbnailsAndIcons(this);
onTaskLoadingCancelled();
}
|
private void | createCustomAnimations(android.animation.LayoutTransition transitioner)
transitioner.setDuration(200);
transitioner.setStartDelay(LayoutTransition.CHANGE_DISAPPEARING, 0);
transitioner.setAnimator(LayoutTransition.DISAPPEARING, null);
|
public void | dismiss()
((RecentsActivity) getContext()).dismissAndGoHome();
|
public void | dismissAndGoBack()
((RecentsActivity) getContext()).dismissAndGoBack();
|
protected void | dispatchDraw(android.graphics.Canvas canvas)
super.dispatchDraw(canvas);
int paddingLeft = getPaddingLeft();
final boolean offsetRequired = isPaddingOffsetRequired();
if (offsetRequired) {
paddingLeft += getLeftPaddingOffset();
}
int left = getScrollX() + paddingLeft;
int right = left + getRight() - getLeft() - getPaddingRight() - paddingLeft;
int top = getScrollY() + getFadeTop(offsetRequired);
int bottom = top + getFadeHeight(offsetRequired);
if (offsetRequired) {
right += getRightPaddingOffset();
bottom += getBottomPaddingOffset();
}
mRecentsContainer.drawFadedEdges(canvas, left, right, top, bottom);
|
public boolean | dispatchHoverEvent(android.view.MotionEvent event)
// Ignore hover events outside of this panel bounds since such events
// generate spurious accessibility events with the panel content when
// tapping outside of it, thus confusing the user.
final int x = (int) event.getX();
final int y = (int) event.getY();
if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) {
return super.dispatchHoverEvent(event);
}
return true;
|
public void | handleLongPress(android.view.View selectedView, android.view.View anchorView, android.view.View thumbnailView)
thumbnailView.setSelected(true);
final PopupMenu popup =
new PopupMenu(getContext(), anchorView == null ? selectedView : anchorView);
mPopup = popup;
popup.getMenuInflater().inflate(R.menu.recent_popup_menu, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == R.id.recent_remove_item) {
((ViewGroup) mRecentsContainer).removeViewInLayout(selectedView);
} else if (item.getItemId() == R.id.recent_inspect_item) {
ViewHolder viewHolder = (ViewHolder) selectedView.getTag();
if (viewHolder != null) {
final TaskDescription ad = viewHolder.taskDescription;
startApplicationDetailsActivity(ad.packageName, ad.userId);
show(false);
} else {
throw new IllegalStateException("Oops, no tag on view " + selectedView);
}
} else {
return false;
}
return true;
}
});
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
public void onDismiss(PopupMenu menu) {
thumbnailView.setSelected(false);
mPopup = null;
}
});
popup.show();
|
public void | handleOnClick(android.view.View view)
ViewHolder holder = (ViewHolder) view.getTag();
TaskDescription ad = holder.taskDescription;
final Context context = view.getContext();
final ActivityManager am = (ActivityManager)
context.getSystemService(Context.ACTIVITY_SERVICE);
Bitmap bm = null;
boolean usingDrawingCache = true;
if (holder.thumbnailViewDrawable instanceof BitmapDrawable) {
bm = ((BitmapDrawable) holder.thumbnailViewDrawable).getBitmap();
if (bm.getWidth() == holder.thumbnailViewImage.getWidth() &&
bm.getHeight() == holder.thumbnailViewImage.getHeight()) {
usingDrawingCache = false;
}
}
if (usingDrawingCache) {
holder.thumbnailViewImage.setDrawingCacheEnabled(true);
bm = holder.thumbnailViewImage.getDrawingCache();
}
Bundle opts = (bm == null) ?
null :
ActivityOptions.makeThumbnailScaleUpAnimation(
holder.thumbnailViewImage, bm, 0, 0, null).toBundle();
show(false);
if (ad.taskId >= 0) {
// This is an active task; it should just go to the foreground.
am.moveTaskToFront(ad.taskId, ActivityManager.MOVE_TASK_WITH_HOME,
opts);
} else {
Intent intent = ad.intent;
intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
| Intent.FLAG_ACTIVITY_TASK_ON_HOME
| Intent.FLAG_ACTIVITY_NEW_TASK);
if (DEBUG) Log.v(TAG, "Starting activity " + intent);
try {
context.startActivityAsUser(intent, opts,
new UserHandle(ad.userId));
} catch (SecurityException e) {
Log.e(TAG, "Recents does not have the permission to launch " + intent, e);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Error launching activity " + intent, e);
}
}
if (usingDrawingCache) {
holder.thumbnailViewImage.setDrawingCacheEnabled(false);
}
|
public void | handleSwipe(android.view.View view)
TaskDescription ad = ((ViewHolder) view.getTag()).taskDescription;
if (ad == null) {
Log.v(TAG, "Not able to find activity description for swiped task; view=" + view +
" tag=" + view.getTag());
return;
}
if (DEBUG) Log.v(TAG, "Jettison " + ad.getLabel());
mRecentTaskDescriptions.remove(ad);
mRecentTasksLoader.remove(ad);
// Handled by widget containers to enable LayoutTransitions properly
// mListAdapter.notifyDataSetChanged();
if (mRecentTaskDescriptions.size() == 0) {
dismissAndGoBack();
}
// Currently, either direction means the same thing, so ignore direction and remove
// the task.
final ActivityManager am = (ActivityManager)
getContext().getSystemService(Context.ACTIVITY_SERVICE);
if (am != null) {
am.removeTask(ad.persistentTaskId);
// Accessibility feedback
setContentDescription(
getContext().getString(R.string.accessibility_recents_item_dismissed, ad.getLabel()));
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
setContentDescription(null);
}
|
public boolean | isInContentArea(int x, int y)
return pointInside(x, y, (View) mRecentsContainer);
|
public boolean | isShowing()Whether the panel is showing, or, if it's animating, whether it will be
when the animation is done.
return mShowing;
|
public int | numItemsInOneScreenful()
return mRecentsContainer.numItemsInOneScreenful();
|
public void | onAnimationCancel(android.animation.Animator animation)
|
public void | onAnimationEnd(android.animation.Animator animation)
if (mShowing) {
final LayoutTransition transitioner = new LayoutTransition();
((ViewGroup)mRecentsContainer).setLayoutTransition(transitioner);
createCustomAnimations(transitioner);
} else {
((ViewGroup)mRecentsContainer).setLayoutTransition(null);
}
|
public void | onAnimationRepeat(android.animation.Animator animation)
|
public void | onAnimationStart(android.animation.Animator animation)
|
protected void | onAttachedToWindow()
super.onAttachedToWindow();
final ViewRootImpl root = getViewRootImpl();
if (root != null) {
root.setDrawDuringWindowsAnimating(true);
}
|
protected void | onFinishInflate()
super.onFinishInflate();
mRecentsContainer = (RecentsScrollView) findViewById(R.id.recents_container);
mRecentsContainer.setOnScrollListener(new Runnable() {
public void run() {
// need to redraw the faded edges
invalidate();
}
});
mListAdapter = new TaskDescriptionAdapter(getContext());
mRecentsContainer.setAdapter(mListAdapter);
mRecentsContainer.setCallback(this);
mRecentsScrim = findViewById(R.id.recents_bg_protect);
mRecentsNoApps = findViewById(R.id.recents_no_apps);
if (mRecentsScrim != null) {
mHighEndGfx = ActivityManager.isHighEndGfx();
if (!mHighEndGfx) {
mRecentsScrim.setBackground(null);
} else if (mRecentsScrim.getBackground() instanceof BitmapDrawable) {
// In order to save space, we make the background texture repeat in the Y direction
((BitmapDrawable) mRecentsScrim.getBackground()).setTileModeY(TileMode.REPEAT);
}
}
|
public boolean | onInterceptTouchEvent(android.view.MotionEvent ev)
if (mPopup != null) {
return true;
} else {
return super.onInterceptTouchEvent(ev);
}
|
public void | onItemClick(android.widget.AdapterView parent, android.view.View view, int position, long id)
handleOnClick(view);
|
public void | onTaskLoadingCancelled()
// Gets called by RecentTasksLoader when it's cancelled
if (mRecentTaskDescriptions != null) {
mRecentTaskDescriptions = null;
mListAdapter.notifyDataSetInvalidated();
}
|
void | onTaskThumbnailLoaded(TaskDescription td)
synchronized (td) {
if (mRecentsContainer != null) {
ViewGroup container = (ViewGroup) mRecentsContainer;
if (container instanceof RecentsScrollView) {
container = (ViewGroup) container.findViewById(
R.id.recents_linear_layout);
}
// Look for a view showing this thumbnail, to update.
for (int i=0; i < container.getChildCount(); i++) {
View v = container.getChildAt(i);
if (v.getTag() instanceof ViewHolder) {
ViewHolder h = (ViewHolder)v.getTag();
if (!h.loadedThumbnailAndIcon && h.taskDescription == td) {
// only fade in the thumbnail if recents is already visible-- we
// show it immediately otherwise
//boolean animateShow = mShowing &&
// mRecentsContainer.getAlpha() > ViewConfiguration.ALPHA_THRESHOLD;
boolean animateShow = false;
updateIcon(h, td.getIcon(), true, animateShow);
updateThumbnail(h, td.getThumbnail(), true, animateShow);
h.loadedThumbnailAndIcon = true;
}
}
}
}
}
showIfReady();
|
public void | onTasksLoaded(java.util.ArrayList tasks, boolean firstScreenful)
if (mRecentTaskDescriptions == null) {
mRecentTaskDescriptions = new ArrayList<TaskDescription>(tasks);
} else {
mRecentTaskDescriptions.addAll(tasks);
}
if (((RecentsActivity) getContext()).isActivityShowing()) {
refreshViews();
}
|
public void | onUiHidden()
mCallUiHiddenBeforeNextReload = false;
if (!mShowing && mRecentTaskDescriptions != null) {
onAnimationEnd(null);
clearRecentTasksList();
}
|
public void | onWindowAnimationStart()
mWaitingForWindowAnimation = false;
mWindowAnimationStartTime = System.currentTimeMillis();
animateInIconOfFirstTask();
|
private boolean | pointInside(int x, int y, android.view.View v)
final int l = v.getLeft();
final int r = v.getRight();
final int t = v.getTop();
final int b = v.getBottom();
return x >= l && x < r && y >= t && y < b;
|
public void | refreshRecentTasksList()
refreshRecentTasksList(null, false);
|
private void | refreshRecentTasksList(java.util.ArrayList recentTasksList, boolean firstScreenful)
if (mRecentTaskDescriptions == null && recentTasksList != null) {
onTasksLoaded(recentTasksList, firstScreenful);
} else {
mRecentTasksLoader.loadTasksInBackground();
}
|
public void | refreshViews()
mListAdapter.notifyDataSetInvalidated();
updateUiElements();
showIfReady();
|
static void | sendCloseSystemWindows(android.content.Context context, java.lang.String reason)
if (ActivityManagerNative.isSystemReady()) {
try {
ActivityManagerNative.getDefault().closeSystemDialogs(reason);
} catch (RemoteException e) {
}
}
|
public void | setMinSwipeAlpha(float minAlpha)
mRecentsContainer.setMinSwipeAlpha(minAlpha);
|
public void | setRecentTasksLoader(RecentTasksLoader loader)
mRecentTasksLoader = loader;
|
public void | show(boolean show)
show(show, null, false, false);
|
public void | show(boolean show, java.util.ArrayList recentTaskDescriptions, boolean firstScreenful, boolean animateIconOfFirstTask)
if (show && mCallUiHiddenBeforeNextReload) {
onUiHidden();
recentTaskDescriptions = null;
mAnimateIconOfFirstTask = false;
mWaitingForWindowAnimation = false;
} else {
mAnimateIconOfFirstTask = animateIconOfFirstTask;
mWaitingForWindowAnimation = animateIconOfFirstTask;
}
if (show) {
mWaitingToShow = true;
refreshRecentTasksList(recentTaskDescriptions, firstScreenful);
showIfReady();
} else {
showImpl(false);
}
|
private void | showIfReady()
// mWaitingToShow => there was a touch up on the recents button
// mRecentTaskDescriptions != null => we've created views for the first screenful of items
if (mWaitingToShow && mRecentTaskDescriptions != null) {
showImpl(true);
}
|
private void | showImpl(boolean show)
sendCloseSystemWindows(getContext(), BaseStatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS);
mShowing = show;
if (show) {
// if there are no apps, bring up a "No recent apps" message
boolean noApps = mRecentTaskDescriptions != null
&& (mRecentTaskDescriptions.size() == 0);
mRecentsNoApps.setAlpha(1f);
mRecentsNoApps.setVisibility(noApps ? View.VISIBLE : View.INVISIBLE);
onAnimationEnd(null);
setFocusable(true);
setFocusableInTouchMode(true);
requestFocus();
} else {
mWaitingToShow = false;
// call onAnimationEnd() and clearRecentTasksList() in onUiHidden()
mCallUiHiddenBeforeNextReload = true;
if (mPopup != null) {
mPopup.dismiss();
}
}
|
public boolean | simulateClick(int persistentTaskId)
View v = mRecentsContainer.findViewForTask(persistentTaskId);
if (v != null) {
handleOnClick(v);
return true;
}
return false;
|
private void | startApplicationDetailsActivity(java.lang.String packageName, int userId)
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts("package", packageName, null));
intent.setComponent(intent.resolveActivity(getContext().getPackageManager()));
TaskStackBuilder.create(getContext())
.addNextIntentWithParentStack(intent).startActivities(null, new UserHandle(userId));
|
private void | updateIcon(com.android.systemui.recent.RecentsPanelView$ViewHolder h, android.graphics.drawable.Drawable icon, boolean show, boolean anim)
if (icon != null) {
h.iconView.setImageDrawable(icon);
if (show && h.iconView.getVisibility() != View.VISIBLE) {
if (anim) {
h.iconView.setAnimation(
AnimationUtils.loadAnimation(getContext(), R.anim.recent_appear));
}
h.iconView.setVisibility(View.VISIBLE);
}
}
|
private void | updateThumbnail(com.android.systemui.recent.RecentsPanelView$ViewHolder h, android.graphics.drawable.Drawable thumbnail, boolean show, boolean anim)
if (thumbnail != null) {
// Should remove the default image in the frame
// that this now covers, to improve scrolling speed.
// That can't be done until the anim is complete though.
h.thumbnailViewImage.setImageDrawable(thumbnail);
// scale the image to fill the full width of the ImageView. do this only if
// we haven't set a bitmap before, or if the bitmap size has changed
if (h.thumbnailViewDrawable == null ||
h.thumbnailViewDrawable.getIntrinsicWidth() != thumbnail.getIntrinsicWidth() ||
h.thumbnailViewDrawable.getIntrinsicHeight() != thumbnail.getIntrinsicHeight()) {
if (mFitThumbnailToXY) {
h.thumbnailViewImage.setScaleType(ScaleType.FIT_XY);
} else {
Matrix scaleMatrix = new Matrix();
float scale = mThumbnailWidth / (float) thumbnail.getIntrinsicWidth();
scaleMatrix.setScale(scale, scale);
h.thumbnailViewImage.setScaleType(ScaleType.MATRIX);
h.thumbnailViewImage.setImageMatrix(scaleMatrix);
}
}
if (show && h.thumbnailView.getVisibility() != View.VISIBLE) {
if (anim) {
h.thumbnailView.setAnimation(
AnimationUtils.loadAnimation(getContext(), R.anim.recent_appear));
}
h.thumbnailView.setVisibility(View.VISIBLE);
}
h.thumbnailViewDrawable = thumbnail;
}
|
private void | updateUiElements()
final int items = mRecentTaskDescriptions != null
? mRecentTaskDescriptions.size() : 0;
((View) mRecentsContainer).setVisibility(items > 0 ? View.VISIBLE : View.GONE);
// Set description for accessibility
int numRecentApps = mRecentTaskDescriptions != null
? mRecentTaskDescriptions.size() : 0;
String recentAppsAccessibilityDescription;
if (numRecentApps == 0) {
recentAppsAccessibilityDescription =
getResources().getString(R.string.status_bar_no_recent_apps);
} else {
recentAppsAccessibilityDescription = getResources().getQuantityString(
R.plurals.status_bar_accessibility_recent_apps, numRecentApps, numRecentApps);
}
setContentDescription(recentAppsAccessibilityDescription);
|
public void | updateValuesFromResources()
final Resources res = getContext().getResources();
mThumbnailWidth = Math.round(res.getDimension(R.dimen.status_bar_recents_thumbnail_width));
mFitThumbnailToXY = res.getBoolean(R.bool.config_recents_thumbnail_image_fits_to_xy);
|