Methods Summary |
---|
public void | adjustFrame(int challengeTop)
int frameHeight = challengeTop + getPaddingBottom();
setFrameHeight(frameHeight);
|
public void | cancelLongPress()
super.cancelLongPress();
mLongPressHelper.cancelLongPress();
|
public void | disableHardwareLayersForContent()Because this view has fading outlines, it is essential that we enable hardware
layers on the content (child) so that updating the alpha of the outlines doesn't
result in the content layer being recreated.
View widget = getContent();
if (widget != null) {
widget.setLayerType(LAYER_TYPE_NONE, null);
}
|
protected void | dispatchDraw(android.graphics.Canvas canvas)
if (ENABLE_HOVER_OVER_DELETE_DROP_TARGET_OVERLAY) {
canvas.save();
}
drawBg(canvas);
super.dispatchDraw(canvas);
drawGradientOverlay(canvas);
if (ENABLE_HOVER_OVER_DELETE_DROP_TARGET_OVERLAY) {
drawHoveringOverDeleteOverlay(canvas);
canvas.restore();
}
|
protected void | drawBg(android.graphics.Canvas canvas)
if (mBackgroundAlpha > 0.0f) {
Drawable bg = mBackgroundDrawable;
bg.setAlpha((int) (mBackgroundAlpha * mBackgroundAlphaMultiplier * 255));
bg.setBounds(mBackgroundRect);
bg.draw(canvas);
}
|
private void | drawGradientOverlay(android.graphics.Canvas c)
mGradientPaint.setShader(mForegroundGradient);
mGradientPaint.setAlpha(mForegroundAlpha);
c.drawRect(mForegroundRect, mGradientPaint);
|
private void | drawHoveringOverDeleteOverlay(android.graphics.Canvas c)
if (mIsHoveringOverDeleteDropTarget) {
c.drawColor(HOVER_OVER_DELETE_DROP_TARGET_OVERLAY_COLOR);
}
|
public void | enableHardwareLayersForContent()Because this view has fading outlines, it is essential that we enable hardware
layers on the content (child) so that updating the alpha of the outlines doesn't
result in the content layer being recreated.
View widget = getContent();
if (widget != null && widget.isHardwareAccelerated()) {
widget.setLayerType(LAYER_TYPE_HARDWARE, null);
}
|
public void | fadeFrame(java.lang.Object caller, boolean takeControl, float alpha, int duration)
if (takeControl) {
mBgAlphaController = caller;
}
if (mBgAlphaController != caller && mBgAlphaController != null) {
return;
}
if (mFrameFade != null) {
mFrameFade.cancel();
mFrameFade = null;
}
PropertyValuesHolder bgAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", alpha);
mFrameFade = ObjectAnimator.ofPropertyValuesHolder(this, bgAlpha);
mFrameFade.setDuration(duration);
mFrameFade.start();
|
public float | getBackgroundAlpha()
return mBackgroundAlpha;
|
public float | getBackgroundAlphaMultiplier()
return mBackgroundAlphaMultiplier;
|
public android.view.View | getContent()
return getChildAt(0);
|
public float | getContentAlpha()
return mContentAlpha;
|
public int | getContentAppWidgetId()
View content = getContent();
if (content instanceof AppWidgetHostView) {
return ((AppWidgetHostView) content).getAppWidgetId();
} else if (content instanceof KeyguardStatusView) {
return ((KeyguardStatusView) content).getAppWidgetId();
} else {
return AppWidgetManager.INVALID_APPWIDGET_ID;
}
|
public int | getSmallFrameHeight()
return mSmallFrameHeight;
|
public android.os.Handler | getWorkerHandler()
return mWorkerHandler;
|
public void | hideFrame(java.lang.Object caller)
fadeFrame(caller, false, 0f, KeyguardWidgetPager.CHILDREN_OUTLINE_FADE_OUT_DURATION);
|
public boolean | isSmall()
return mIsSmall;
|
public void | onActive(boolean isActive)
// hook for subclasses
|
protected void | onAttachedToWindow()
super.onAttachedToWindow();
KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallbacks);
|
public void | onBouncerShowing(boolean showing)
// hook for subclasses
|
protected void | onDetachedFromWindow()
super.onDetachedFromWindow();
cancelLongPress();
KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateMonitorCallbacks);
|
public boolean | onInterceptTouchEvent(android.view.MotionEvent ev)
// Watch for longpress events at this level to make sure
// users can always pick up this widget
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
mLongPressHelper.postCheckForLongPress(ev);
break;
case MotionEvent.ACTION_MOVE:
mLongPressHelper.onMove(ev);
break;
case MotionEvent.ACTION_POINTER_DOWN:
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mLongPressHelper.cancelLongPress();
break;
}
// Otherwise continue letting touch events fall through to children
return false;
|
protected void | onMeasure(int widthMeasureSpec, int heightMeasureSpec)
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
performAppWidgetSizeCallbacksIfNecessary();
|
protected void | onSizeChanged(int w, int h, int oldw, int oldh)
super.onSizeChanged(w, h, oldw, oldh);
if (!mIsSmall) {
mFrameHeight = h;
}
// mFrameStrokeAdjustment is a cludge to prevent the overlay from drawing outside the
// rounded rect background.
mForegroundRect.set(mFrameStrokeAdjustment, mFrameStrokeAdjustment,
w - mFrameStrokeAdjustment, Math.min(h, mFrameHeight) - mFrameStrokeAdjustment);
mBackgroundRect.set(0, 0, getMeasuredWidth(), Math.min(h, mFrameHeight));
updateGradient();
invalidate();
|
public boolean | onTouchEvent(android.view.MotionEvent ev)
// Watch for longpress events at this level to make sure
// users can always pick up this widget
switch (ev.getAction()) {
case MotionEvent.ACTION_MOVE:
mLongPressHelper.onMove(ev);
break;
case MotionEvent.ACTION_POINTER_DOWN:
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mLongPressHelper.cancelLongPress();
break;
}
// We return true here to ensure that we will get cancel / up signal
// even if none of our children have requested touch.
return true;
|
public boolean | onUserInteraction(android.view.MotionEvent event)
// hook for subclasses
return false;
|
private void | performAppWidgetSizeCallbacksIfNecessary()
View content = getContent();
if (!(content instanceof AppWidgetHostView)) return;
if (!KeyguardUpdateMonitor.getInstance(mContext).hasBootCompleted()) {
mPerformAppWidgetSizeUpdateOnBootComplete = true;
return;
}
// TODO: there's no reason to force the AppWidgetHostView to catch duplicate size calls.
// We can do that even more cheaply here. It's not an issue right now since we're in the
// system process and hence no binder calls.
AppWidgetHostView awhv = (AppWidgetHostView) content;
float density = getResources().getDisplayMetrics().density;
int width = (int) (content.getMeasuredWidth() / density);
int height = (int) (content.getMeasuredHeight() / density);
awhv.updateAppWidgetSize(null, width, height, width, height, true);
|
public void | requestDisallowInterceptTouchEvent(boolean disallowIntercept)
super.requestDisallowInterceptTouchEvent(disallowIntercept);
cancelLongPress();
|
public void | resetSize()
mIsSmall = false;
if (!mWidgetLockedSmall) {
setWidgetHeight(LayoutParams.MATCH_PARENT);
}
setFrameHeight(getMeasuredHeight());
|
public void | setBackgroundAlpha(float alpha)
if (Float.compare(mBackgroundAlpha, alpha) != 0) {
mBackgroundAlpha = alpha;
invalidate();
}
|
public void | setBackgroundAlphaMultiplier(float multiplier)
if (Float.compare(mBackgroundAlphaMultiplier, multiplier) != 0) {
mBackgroundAlphaMultiplier = multiplier;
invalidate();
}
|
public void | setContentAlpha(float alpha)
mContentAlpha = alpha;
View content = getContent();
if (content != null) {
content.setAlpha(alpha);
}
|
public void | setFrameHeight(int height)
mFrameHeight = height;
mBackgroundRect.set(0, 0, getMeasuredWidth(), Math.min(mFrameHeight, getMeasuredHeight()));
mForegroundRect.set(mFrameStrokeAdjustment, mFrameStrokeAdjustment,getMeasuredWidth() -
mFrameStrokeAdjustment, Math.min(getMeasuredHeight(), mFrameHeight) -
mFrameStrokeAdjustment);
updateGradient();
invalidate();
|
void | setIsHoveringOverDeleteDropTarget(boolean isHovering)
if (ENABLE_HOVER_OVER_DELETE_DROP_TARGET_OVERLAY) {
if (mIsHoveringOverDeleteDropTarget != isHovering) {
mIsHoveringOverDeleteDropTarget = isHovering;
int resId = isHovering ? R.string.keyguard_accessibility_delete_widget_start
: R.string.keyguard_accessibility_delete_widget_end;
String text = getContext().getResources().getString(resId, getContentDescription());
announceForAccessibility(text);
invalidate();
}
}
|
public void | setMaxChallengeTop(int top)
boolean dirty = mMaxChallengeTop != top;
mMaxChallengeTop = top;
mSmallWidgetHeight = top - getPaddingTop();
mSmallFrameHeight = top + getPaddingBottom();
if (dirty && mIsSmall) {
setWidgetHeight(mSmallWidgetHeight);
setFrameHeight(mSmallFrameHeight);
} else if (dirty && mWidgetLockedSmall) {
setWidgetHeight(mSmallWidgetHeight);
}
|
void | setOverScrollAmount(float r, boolean left)
if (Float.compare(mOverScrollAmount, r) != 0) {
mOverScrollAmount = r;
mForegroundGradient = left ? mLeftToRightGradient : mRightToLeftGradient;
mForegroundAlpha = (int) Math.round((0.5f * r * 255));
// We bump up the alpha of the outline to hide the fact that the overlay is drawing
// over the rounded part of the frame.
float bgAlpha = Math.min(OUTLINE_ALPHA_MULTIPLIER + r * (1 - OUTLINE_ALPHA_MULTIPLIER),
1f);
setBackgroundAlpha(bgAlpha);
invalidate();
}
|
private void | setWidgetHeight(int height)Depending on whether the security is up, the widget size needs to change
boolean needLayout = false;
View widget = getContent();
if (widget != null) {
LayoutParams lp = (LayoutParams) widget.getLayoutParams();
if (lp.height != height) {
needLayout = true;
lp.height = height;
}
}
if (needLayout) {
requestLayout();
}
|
public void | setWidgetLockedSmall(boolean locked)
if (locked) {
setWidgetHeight(mSmallWidgetHeight);
}
mWidgetLockedSmall = locked;
|
public void | setWorkerHandler(android.os.Handler workerHandler)
mWorkerHandler = workerHandler;
|
public void | showFrame(java.lang.Object caller)
fadeFrame(caller, true, OUTLINE_ALPHA_MULTIPLIER,
KeyguardWidgetPager.CHILDREN_OUTLINE_FADE_IN_DURATION);
|
public void | shrinkWidget(boolean alsoShrinkFrame)
mIsSmall = true;
setWidgetHeight(mSmallWidgetHeight);
if (alsoShrinkFrame) {
setFrameHeight(mSmallFrameHeight);
}
|
private void | updateGradient()
float x0 = mLeftToRight ? 0 : mForegroundRect.width();
float x1 = mLeftToRight ? mForegroundRect.width(): 0;
mLeftToRightGradient = new LinearGradient(x0, 0f, x1, 0f,
mGradientColor, 0, Shader.TileMode.CLAMP);
mRightToLeftGradient = new LinearGradient(x1, 0f, x0, 0f,
mGradientColor, 0, Shader.TileMode.CLAMP);
|