code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
844 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
protected void flingThenSpringFirstBubbleWithStackFollowing( DynamicAnimation.ViewProperty property, float vel, float friction, SpringForce spring, Float finalPosition) { if (!isActiveController()) { return; } Log.d(TAG, String.format("Flinging %s.", PhysicsAnimationLayout.getReadablePropertyName(property))); StackPositionProperty firstBubbleProperty = new StackPositionProperty(property); final float currentValue = firstBubbleProperty.getValue(this); final RectF bounds = mPositioner.getAllowableStackPositionRegion(getBubbleCount()); final float min = property.equals(DynamicAnimation.TRANSLATION_X) ? bounds.left : bounds.top; final float max = property.equals(DynamicAnimation.TRANSLATION_X) ? bounds.right : bounds.bottom; FlingAnimation flingAnimation = new FlingAnimation(this, firstBubbleProperty); flingAnimation.setFriction(friction) .setStartVelocity(vel) // If the bubble's property value starts beyond the desired min/max, use that value // instead so that the animation won't immediately end. If, for example, the user // drags the bubbles into the navigation bar, but then flings them upward, we want // the fling to occur despite temporarily having a value outside of the min/max. If // the bubbles are out of bounds and flung even farther out of bounds, the fling // animation will halt immediately and the SpringAnimation will take over, springing // it in reverse to the (legal) final position. .setMinValue(Math.min(currentValue, min)) .setMaxValue(Math.max(currentValue, max)) .addEndListener((animation, canceled, endValue, endVelocity) -> { if (!canceled) { mPositioner.setRestingPosition(mStackPosition); springFirstBubbleWithStackFollowing(property, spring, endVelocity, finalPosition != null ? finalPosition : Math.max(min, Math.min(max, endValue))); } }); cancelStackPositionAnimation(property); mStackPositionAnimations.put(property, flingAnimation); flingAnimation.start(); }
Flings the first bubble along the given property's axis, using the provided configuration values. When the animation ends - either by hitting the min/max, or by friction sufficiently reducing momentum - a SpringAnimation takes over to snap the bubble to the given final position.
StackAnimationController::flingThenSpringFirstBubbleWithStackFollowing
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
public void cancelStackPositionAnimations() { cancelStackPositionAnimation(DynamicAnimation.TRANSLATION_X); cancelStackPositionAnimation(DynamicAnimation.TRANSLATION_Y); removeEndActionForProperty(DynamicAnimation.TRANSLATION_X); removeEndActionForProperty(DynamicAnimation.TRANSLATION_Y); }
Cancel any stack position animations that were started by calling @link #flingThenSpringFirstBubbleWithStackFollowing}, and remove any corresponding end listeners.
StackAnimationController::cancelStackPositionAnimations
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
public float animateForImeVisibility(boolean imeVisible) { final float maxBubbleY = mPositioner.getAllowableStackPositionRegion( getBubbleCount()).bottom; float destinationY = UNSET; if (imeVisible) { // Stack is lower than it should be and overlaps the now-visible IME. if (mStackPosition.y > maxBubbleY && mPreImeY == UNSET) { mPreImeY = mStackPosition.y; destinationY = maxBubbleY; } } else { if (mPreImeY != UNSET) { destinationY = mPreImeY; mPreImeY = UNSET; } } if (destinationY != UNSET) { springFirstBubbleWithStackFollowing( DynamicAnimation.TRANSLATION_Y, getSpringForce(DynamicAnimation.TRANSLATION_Y, /* view */ null) .setStiffness(IME_ANIMATION_STIFFNESS), /* startVel */ 0f, destinationY); notifyFloatingCoordinatorStackAnimatingTo(mStackPosition.x, destinationY); } return destinationY != UNSET ? destinationY : mStackPosition.y; }
Animates the stack either away from the newly visible IME, or back to its original position due to the IME going away. @return The destination Y value of the stack due to the IME movement (or the current position of the stack if it's not moving).
StackAnimationController::animateForImeVisibility
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
private void notifyFloatingCoordinatorStackAnimatingTo(float x, float y) { final Rect floatingBounds = mStackFloatingContent.getFloatingBoundsOnScreen(); floatingBounds.offsetTo((int) x, (int) y); mAnimatingToBounds = floatingBounds; mFloatingContentCoordinator.onContentMoved(mStackFloatingContent); }
Notifies the floating coordinator that we're moving, and sets {@link #mAnimatingToBounds} so we return these bounds from {@link FloatingContentCoordinator.FloatingContent#getFloatingBoundsOnScreen()}.
StackAnimationController::notifyFloatingCoordinatorStackAnimatingTo
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
public void moveStackFromTouch(float x, float y) { // Begin the spring-to-touch catch up animation if needed. if (mSpringToTouchOnNextMotionEvent) { springStack(x, y, SPRING_TO_TOUCH_STIFFNESS); mSpringToTouchOnNextMotionEvent = false; mFirstBubbleSpringingToTouch = true; } else if (mFirstBubbleSpringingToTouch) { final SpringAnimation springToTouchX = (SpringAnimation) mStackPositionAnimations.get( DynamicAnimation.TRANSLATION_X); final SpringAnimation springToTouchY = (SpringAnimation) mStackPositionAnimations.get( DynamicAnimation.TRANSLATION_Y); // If either animation is still running, we haven't caught up. Update the animations. if (springToTouchX.isRunning() || springToTouchY.isRunning()) { springToTouchX.animateToFinalPosition(x); springToTouchY.animateToFinalPosition(y); } else { // If the animations have finished, the stack is now at the touch point. We can // resume moving the bubble directly. mFirstBubbleSpringingToTouch = false; } } if (!mFirstBubbleSpringingToTouch && !isStackStuckToTarget()) { moveFirstBubbleWithStackFollowing(x, y); } }
Notifies the floating coordinator that we're moving, and sets {@link #mAnimatingToBounds} so we return these bounds from {@link FloatingContentCoordinator.FloatingContent#getFloatingBoundsOnScreen()}. private void notifyFloatingCoordinatorStackAnimatingTo(float x, float y) { final Rect floatingBounds = mStackFloatingContent.getFloatingBoundsOnScreen(); floatingBounds.offsetTo((int) x, (int) y); mAnimatingToBounds = floatingBounds; mFloatingContentCoordinator.onContentMoved(mStackFloatingContent); } /** Moves the stack in response to a touch event.
StackAnimationController::moveStackFromTouch
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
public void onUnstuckFromTarget() { mSpringToTouchOnNextMotionEvent = true; }
Notifies the floating coordinator that we're moving, and sets {@link #mAnimatingToBounds} so we return these bounds from {@link FloatingContentCoordinator.FloatingContent#getFloatingBoundsOnScreen()}. private void notifyFloatingCoordinatorStackAnimatingTo(float x, float y) { final Rect floatingBounds = mStackFloatingContent.getFloatingBoundsOnScreen(); floatingBounds.offsetTo((int) x, (int) y); mAnimatingToBounds = floatingBounds; mFloatingContentCoordinator.onContentMoved(mStackFloatingContent); } /** Moves the stack in response to a touch event. public void moveStackFromTouch(float x, float y) { // Begin the spring-to-touch catch up animation if needed. if (mSpringToTouchOnNextMotionEvent) { springStack(x, y, SPRING_TO_TOUCH_STIFFNESS); mSpringToTouchOnNextMotionEvent = false; mFirstBubbleSpringingToTouch = true; } else if (mFirstBubbleSpringingToTouch) { final SpringAnimation springToTouchX = (SpringAnimation) mStackPositionAnimations.get( DynamicAnimation.TRANSLATION_X); final SpringAnimation springToTouchY = (SpringAnimation) mStackPositionAnimations.get( DynamicAnimation.TRANSLATION_Y); // If either animation is still running, we haven't caught up. Update the animations. if (springToTouchX.isRunning() || springToTouchY.isRunning()) { springToTouchX.animateToFinalPosition(x); springToTouchY.animateToFinalPosition(y); } else { // If the animations have finished, the stack is now at the touch point. We can // resume moving the bubble directly. mFirstBubbleSpringingToTouch = false; } } if (!mFirstBubbleSpringingToTouch && !isStackStuckToTarget()) { moveFirstBubbleWithStackFollowing(x, y); } } /** Notify the controller that the stack has been unstuck from the dismiss target.
StackAnimationController::onUnstuckFromTarget
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
public void animateStackDismissal(float translationYBy, Runnable after) { animationsForChildrenFromIndex(0, (index, animation) -> animation .scaleX(0f) .scaleY(0f) .alpha(0f) .translationY( mLayout.getChildAt(index).getTranslationY() + translationYBy) .withStiffness(SpringForce.STIFFNESS_HIGH)) .startAll(after); }
'Implode' the stack by shrinking the bubbles, fading them out, and translating them down.
StackAnimationController::animateStackDismissal
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
protected void springFirstBubbleWithStackFollowing( DynamicAnimation.ViewProperty property, SpringForce spring, float vel, float finalPosition, @Nullable Runnable... after) { if (mLayout.getChildCount() == 0 || !isActiveController()) { return; } Log.d(TAG, String.format("Springing %s to final position %f.", PhysicsAnimationLayout.getReadablePropertyName(property), finalPosition)); // Whether we're springing towards the touch location, rather than to a position on the // sides of the screen. final boolean isSpringingTowardsTouch = mSpringToTouchOnNextMotionEvent; StackPositionProperty firstBubbleProperty = new StackPositionProperty(property); SpringAnimation springAnimation = new SpringAnimation(this, firstBubbleProperty) .setSpring(spring) .addEndListener((dynamicAnimation, b, v, v1) -> { if (!isSpringingTowardsTouch) { // If we're springing towards the touch position, don't save the // resting position - the touch location is not a valid resting // position. We'll set this when the stack springs to the left or // right side of the screen after the touch gesture ends. mPositioner.setRestingPosition(mStackPosition); } if (mOnStackAnimationFinished != null) { mOnStackAnimationFinished.run(); } if (after != null) { for (Runnable callback : after) { callback.run(); } } }) .setStartVelocity(vel); cancelStackPositionAnimation(property); mStackPositionAnimations.put(property, springAnimation); springAnimation.animateToFinalPosition(finalPosition); }
Springs the first bubble to the given final position, with the rest of the stack 'following'.
StackAnimationController::springFirstBubbleWithStackFollowing
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
public void updateResources() { if (mLayout != null) { Resources res = mLayout.getContext().getResources(); mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top); } }
Update resources.
StackAnimationController::updateResources
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
private void moveStackToStartPosition() { // Post to ensure that the layout's width and height have been calculated. mLayout.setVisibility(View.INVISIBLE); mLayout.post(() -> { setStackPosition(mPositioner.getRestingPosition()); mStackMovedToStartPosition = true; mLayout.setVisibility(View.VISIBLE); // Animate in the top bubble now that we're visible. if (mLayout.getChildCount() > 0) { // Add the stack to the floating content coordinator now that we have a bubble and // are visible. mFloatingContentCoordinator.onContentAdded(mStackFloatingContent); animateInBubble(mLayout.getChildAt(0), 0 /* index */); } }); }
Update resources. public void updateResources() { if (mLayout != null) { Resources res = mLayout.getContext().getResources(); mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top); } } private boolean isStackStuckToTarget() { return mMagnetizedStack != null && mMagnetizedStack.getObjectStuckToTarget(); } /** Moves the stack, without any animation, to the starting position.
StackAnimationController::moveStackToStartPosition
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
private void moveFirstBubbleWithStackFollowing( DynamicAnimation.ViewProperty property, float value) { // Update the canonical stack position. if (property.equals(DynamicAnimation.TRANSLATION_X)) { mStackPosition.x = value; } else if (property.equals(DynamicAnimation.TRANSLATION_Y)) { mStackPosition.y = value; } if (mLayout.getChildCount() > 0) { property.setValue(mLayout.getChildAt(0), value); if (mLayout.getChildCount() > 1) { float newValue = value + getOffsetForChainedPropertyAnimation(property, 0); animationForChildAtIndex(1) .property(property, newValue) .start(); } } }
Moves the first bubble instantly to the given X or Y translation, and instructs subsequent bubbles to animate 'following' to the new location.
StackAnimationController::moveFirstBubbleWithStackFollowing
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
public void setStackPosition(PointF pos) { Log.d(TAG, String.format("Setting position to (%f, %f).", pos.x, pos.y)); mStackPosition.set(pos.x, pos.y); mPositioner.setRestingPosition(mStackPosition); // If we're not the active controller, we don't want to physically move the bubble views. if (isActiveController()) { // Cancel animations that could be moving the views. mLayout.cancelAllAnimationsOfProperties( DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y); cancelStackPositionAnimations(); // Since we're not using the chained animations, apply the offsets manually. final float xOffset = getOffsetForChainedPropertyAnimation( DynamicAnimation.TRANSLATION_X, 0); final float yOffset = getOffsetForChainedPropertyAnimation( DynamicAnimation.TRANSLATION_Y, 0); for (int i = 0; i < mLayout.getChildCount(); i++) { float index = Math.min(i, NUM_VISIBLE_WHEN_RESTING - 1); mLayout.getChildAt(i).setTranslationX(pos.x + (index * xOffset)); mLayout.getChildAt(i).setTranslationY(pos.y + (index * yOffset)); } } }
Moves the first bubble instantly to the given X or Y translation, and instructs subsequent bubbles to animate 'following' to the new location. private void moveFirstBubbleWithStackFollowing( DynamicAnimation.ViewProperty property, float value) { // Update the canonical stack position. if (property.equals(DynamicAnimation.TRANSLATION_X)) { mStackPosition.x = value; } else if (property.equals(DynamicAnimation.TRANSLATION_Y)) { mStackPosition.y = value; } if (mLayout.getChildCount() > 0) { property.setValue(mLayout.getChildAt(0), value); if (mLayout.getChildCount() > 1) { float newValue = value + getOffsetForChainedPropertyAnimation(property, 0); animationForChildAtIndex(1) .property(property, newValue) .start(); } } } /** Moves the stack to a position instantly, with no animation.
StackAnimationController::setStackPosition
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
private void animateInBubble(View v, int index) { if (!isActiveController()) { return; } final float yOffset = getOffsetForChainedPropertyAnimation(DynamicAnimation.TRANSLATION_Y, 0); float endY = mStackPosition.y + yOffset * index; float endX = mStackPosition.x; if (mPositioner.showBubblesVertically()) { v.setTranslationY(endY); final float startX = isStackOnLeftSide() ? endX - NEW_BUBBLE_START_Y : endX + NEW_BUBBLE_START_Y; v.setTranslationX(startX); } else { v.setTranslationX(mStackPosition.x); final float startY = endY + NEW_BUBBLE_START_Y; v.setTranslationY(startY); } v.setScaleX(NEW_BUBBLE_START_SCALE); v.setScaleY(NEW_BUBBLE_START_SCALE); v.setAlpha(0f); final ViewPropertyAnimator animator = v.animate() .scaleX(1f) .scaleY(1f) .alpha(1f) .setDuration(BUBBLE_SWAP_DURATION) .withEndAction(() -> { v.setTag(R.id.reorder_animator_tag, null); }); v.setTag(R.id.reorder_animator_tag, animator); if (mPositioner.showBubblesVertically()) { animator.translationX(endX); } else { animator.translationY(endY); } }
Moves the first bubble instantly to the given X or Y translation, and instructs subsequent bubbles to animate 'following' to the new location. private void moveFirstBubbleWithStackFollowing( DynamicAnimation.ViewProperty property, float value) { // Update the canonical stack position. if (property.equals(DynamicAnimation.TRANSLATION_X)) { mStackPosition.x = value; } else if (property.equals(DynamicAnimation.TRANSLATION_Y)) { mStackPosition.y = value; } if (mLayout.getChildCount() > 0) { property.setValue(mLayout.getChildAt(0), value); if (mLayout.getChildCount() > 1) { float newValue = value + getOffsetForChainedPropertyAnimation(property, 0); animationForChildAtIndex(1) .property(property, newValue) .start(); } } } /** Moves the stack to a position instantly, with no animation. public void setStackPosition(PointF pos) { Log.d(TAG, String.format("Setting position to (%f, %f).", pos.x, pos.y)); mStackPosition.set(pos.x, pos.y); mPositioner.setRestingPosition(mStackPosition); // If we're not the active controller, we don't want to physically move the bubble views. if (isActiveController()) { // Cancel animations that could be moving the views. mLayout.cancelAllAnimationsOfProperties( DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y); cancelStackPositionAnimations(); // Since we're not using the chained animations, apply the offsets manually. final float xOffset = getOffsetForChainedPropertyAnimation( DynamicAnimation.TRANSLATION_X, 0); final float yOffset = getOffsetForChainedPropertyAnimation( DynamicAnimation.TRANSLATION_Y, 0); for (int i = 0; i < mLayout.getChildCount(); i++) { float index = Math.min(i, NUM_VISIBLE_WHEN_RESTING - 1); mLayout.getChildAt(i).setTranslationX(pos.x + (index * xOffset)); mLayout.getChildAt(i).setTranslationY(pos.y + (index * yOffset)); } } } public void setStackPosition(BubbleStackView.RelativeStackPosition position) { setStackPosition(position.getAbsolutePositionInRegion( mPositioner.getAllowableStackPositionRegion(getBubbleCount()))); } private boolean isStackPositionSet() { return mStackMovedToStartPosition; } /** Animates in the given bubble.
StackAnimationController::animateInBubble
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
private void cancelStackPositionAnimation(DynamicAnimation.ViewProperty property) { if (mStackPositionAnimations.containsKey(property)) { mStackPositionAnimations.get(property).cancel(); } }
Cancels any outstanding first bubble property animations that are running. This does not affect the SpringAnimations controlling the individual bubbles' 'following' effect - it only cancels animations started from {@link #springFirstBubbleWithStackFollowing} and {@link #flingThenSpringFirstBubbleWithStackFollowing}.
StackAnimationController::cancelStackPositionAnimation
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
public MagnetizedObject<StackAnimationController> getMagnetizedStack() { if (mMagnetizedStack == null) { mMagnetizedStack = new MagnetizedObject<StackAnimationController>( mLayout.getContext(), this, new StackPositionProperty(DynamicAnimation.TRANSLATION_X), new StackPositionProperty(DynamicAnimation.TRANSLATION_Y) ) { @Override public float getWidth(@NonNull StackAnimationController underlyingObject) { return mBubbleSize; } @Override public float getHeight(@NonNull StackAnimationController underlyingObject) { return mBubbleSize; } @Override public void getLocationOnScreen(@NonNull StackAnimationController underlyingObject, @NonNull int[] loc) { loc[0] = (int) mStackPosition.x; loc[1] = (int) mStackPosition.y; } }; mMagnetizedStack.setHapticsEnabled(true); mMagnetizedStack.setFlingToTargetMinVelocity(FLING_TO_DISMISS_MIN_VELOCITY); mMagnetizedStack.setFlingToTargetEnabled(ENABLE_FLING_TO_DISMISS_BUBBLE); } final ContentResolver contentResolver = mLayout.getContext().getContentResolver(); final float minVelocity = Settings.Secure.getFloat(contentResolver, "bubble_dismiss_fling_min_velocity", mMagnetizedStack.getFlingToTargetMinVelocity() /* default */); final float maxVelocity = Settings.Secure.getFloat(contentResolver, "bubble_dismiss_stick_max_velocity", mMagnetizedStack.getStickToTargetMaxXVelocity() /* default */); final float targetWidth = Settings.Secure.getFloat(contentResolver, "bubble_dismiss_target_width_percent", mMagnetizedStack.getFlingToTargetWidthPercent() /* default */); mMagnetizedStack.setFlingToTargetMinVelocity(minVelocity); mMagnetizedStack.setStickToTargetMaxXVelocity(maxVelocity); mMagnetizedStack.setFlingToTargetWidthPercent(targetWidth); return mMagnetizedStack; }
Returns the {@link MagnetizedObject} instance for the bubble stack.
StackAnimationController::getMagnetizedStack
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
private int getBubbleCount() { return mBubbleCountSupplier.getAsInt(); }
Returns the {@link MagnetizedObject} instance for the bubble stack. public MagnetizedObject<StackAnimationController> getMagnetizedStack() { if (mMagnetizedStack == null) { mMagnetizedStack = new MagnetizedObject<StackAnimationController>( mLayout.getContext(), this, new StackPositionProperty(DynamicAnimation.TRANSLATION_X), new StackPositionProperty(DynamicAnimation.TRANSLATION_Y) ) { @Override public float getWidth(@NonNull StackAnimationController underlyingObject) { return mBubbleSize; } @Override public float getHeight(@NonNull StackAnimationController underlyingObject) { return mBubbleSize; } @Override public void getLocationOnScreen(@NonNull StackAnimationController underlyingObject, @NonNull int[] loc) { loc[0] = (int) mStackPosition.x; loc[1] = (int) mStackPosition.y; } }; mMagnetizedStack.setHapticsEnabled(true); mMagnetizedStack.setFlingToTargetMinVelocity(FLING_TO_DISMISS_MIN_VELOCITY); mMagnetizedStack.setFlingToTargetEnabled(ENABLE_FLING_TO_DISMISS_BUBBLE); } final ContentResolver contentResolver = mLayout.getContext().getContentResolver(); final float minVelocity = Settings.Secure.getFloat(contentResolver, "bubble_dismiss_fling_min_velocity", mMagnetizedStack.getFlingToTargetMinVelocity() /* default */); final float maxVelocity = Settings.Secure.getFloat(contentResolver, "bubble_dismiss_stick_max_velocity", mMagnetizedStack.getStickToTargetMaxXVelocity() /* default */); final float targetWidth = Settings.Secure.getFloat(contentResolver, "bubble_dismiss_target_width_percent", mMagnetizedStack.getFlingToTargetWidthPercent() /* default */); mMagnetizedStack.setFlingToTargetMinVelocity(minVelocity); mMagnetizedStack.setStickToTargetMaxXVelocity(maxVelocity); mMagnetizedStack.setFlingToTargetWidthPercent(targetWidth); return mMagnetizedStack; } /** Returns the number of 'real' bubbles (excluding overflow).
StackAnimationController::getBubbleCount
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
MIT
public Element getChild(String localName) { return getChild("", localName); }
Gets the child element with the given name. Uses an empty string as the namespace.
Element::getChild
java
Reginer/aosp-android-jar
android-35/src/android/sax/Element.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/sax/Element.java
MIT
public Element getChild(String uri, String localName) { if (endTextElementListener != null) { throw new IllegalStateException("This element already has an end" + " text element listener. It cannot have children."); } if (children == null) { children = new Children(); } return children.getOrCreate(this, uri, localName); }
Gets the child element with the given name.
Element::getChild
java
Reginer/aosp-android-jar
android-35/src/android/sax/Element.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/sax/Element.java
MIT
public Element requireChild(String localName) { return requireChild("", localName); }
Gets the child element with the given name. Uses an empty string as the namespace. We will throw a {@link org.xml.sax.SAXException} at parsing time if the specified child is missing. This helps you ensure that your listeners are called.
Element::requireChild
java
Reginer/aosp-android-jar
android-35/src/android/sax/Element.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/sax/Element.java
MIT
public Element requireChild(String uri, String localName) { Element child = getChild(uri, localName); if (requiredChilden == null) { requiredChilden = new ArrayList<Element>(); requiredChilden.add(child); } else { if (!requiredChilden.contains(child)) { requiredChilden.add(child); } } return child; }
Gets the child element with the given name. We will throw a {@link org.xml.sax.SAXException} at parsing time if the specified child is missing. This helps you ensure that your listeners are called.
Element::requireChild
java
Reginer/aosp-android-jar
android-35/src/android/sax/Element.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/sax/Element.java
MIT
public void setElementListener(ElementListener elementListener) { setStartElementListener(elementListener); setEndElementListener(elementListener); }
Sets start and end element listeners at the same time.
Element::setElementListener
java
Reginer/aosp-android-jar
android-35/src/android/sax/Element.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/sax/Element.java
MIT
public void setTextElementListener(TextElementListener elementListener) { setStartElementListener(elementListener); setEndTextElementListener(elementListener); }
Sets start and end text element listeners at the same time.
Element::setTextElementListener
java
Reginer/aosp-android-jar
android-35/src/android/sax/Element.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/sax/Element.java
MIT
public void setStartElementListener( StartElementListener startElementListener) { if (this.startElementListener != null) { throw new IllegalStateException( "Start element listener has already been set."); } this.startElementListener = startElementListener; }
Sets a listener for the start of this element.
Element::setStartElementListener
java
Reginer/aosp-android-jar
android-35/src/android/sax/Element.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/sax/Element.java
MIT
public void setEndElementListener(EndElementListener endElementListener) { if (this.endElementListener != null) { throw new IllegalStateException( "End element listener has already been set."); } this.endElementListener = endElementListener; }
Sets a listener for the end of this element.
Element::setEndElementListener
java
Reginer/aosp-android-jar
android-35/src/android/sax/Element.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/sax/Element.java
MIT
public void setEndTextElementListener( EndTextElementListener endTextElementListener) { if (this.endTextElementListener != null) { throw new IllegalStateException( "End text element listener has already been set."); } if (children != null) { throw new IllegalStateException("This element already has children." + " It cannot have an end text element listener."); } this.endTextElementListener = endTextElementListener; }
Sets a listener for the end of this text element.
Element::setEndTextElementListener
java
Reginer/aosp-android-jar
android-35/src/android/sax/Element.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/sax/Element.java
MIT
void resetRequiredChildren() { ArrayList<Element> requiredChildren = this.requiredChilden; if (requiredChildren != null) { for (int i = requiredChildren.size() - 1; i >= 0; i--) { requiredChildren.get(i).visited = false; } } }
Clears flags on required children.
Element::resetRequiredChildren
java
Reginer/aosp-android-jar
android-35/src/android/sax/Element.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/sax/Element.java
MIT
void checkRequiredChildren(Locator locator) throws SAXParseException { ArrayList<Element> requiredChildren = this.requiredChilden; if (requiredChildren != null) { for (int i = requiredChildren.size() - 1; i >= 0; i--) { Element child = requiredChildren.get(i); if (!child.visited) { throw new BadXmlException( "Element named " + this + " is missing required" + " child element named " + child + ".", locator); } } } }
Throws an exception if a required child was not present.
Element::checkRequiredChildren
java
Reginer/aosp-android-jar
android-35/src/android/sax/Element.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/sax/Element.java
MIT
default void reloadResources() {}
Acts as a source of truth for appropriate size spec for PIP. public class PipSizeSpecHandler { private static final String TAG = PipSizeSpecHandler.class.getSimpleName(); @NonNull private final PipDisplayLayoutState mPipDisplayLayoutState; private final SizeSpecSource mSizeSpecSourceImpl; /** The preferred minimum (and default minimum) size specified by apps. @Nullable private Size mOverrideMinSize; private int mOverridableMinSize; /** Used to store values obtained from resource files. private Point mScreenEdgeInsets; private float mMinAspectRatioForMinSize; private float mMaxAspectRatioForMinSize; private int mDefaultMinSize; @NonNull private final Context mContext; private interface SizeSpecSource { /** Returns max size allowed for the PIP window Size getMaxSize(float aspectRatio); /** Returns default size for the PIP window Size getDefaultSize(float aspectRatio); /** Returns min size allowed for the PIP window Size getMinSize(float aspectRatio); /** Returns the adjusted size based on current size and target aspect ratio Size getSizeForAspectRatio(Size size, float aspectRatio); /** Updates internal resources on configuration changes
getSimpleName::reloadResources
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
MIT
public void onConfigurationChanged() { reloadResources(); }
Returns the size for target aspect ratio making sure new size conforms with the rules. <p>Recalculates the dimensions such that the target aspect ratio is achieved, while maintaining the same maximum size to current size ratio. @param size current size @param aspectRatio target aspect ratio @Override public Size getSizeForAspectRatio(Size size, float aspectRatio) { float currAspectRatio = (float) size.getWidth() / size.getHeight(); // getting the percentage of the max size that current size takes Size currentMaxSize = getMaxSize(currAspectRatio); float currentPercent = (float) size.getWidth() / currentMaxSize.getWidth(); // getting the max size for the target aspect ratio Size updatedMaxSize = getMaxSize(aspectRatio); int width = Math.round(updatedMaxSize.getWidth() * currentPercent); int height = Math.round(updatedMaxSize.getHeight() * currentPercent); // adjust the dimensions if below allowed min edge size if (width < getMinEdgeSize() && aspectRatio <= 1) { width = getMinEdgeSize(); height = Math.round(width / aspectRatio); } else if (height < getMinEdgeSize() && aspectRatio > 1) { height = getMinEdgeSize(); width = Math.round(height * aspectRatio); } // reduce the dimensions of the updated size to the calculated percentage return new Size(width, height); } } private class SizeSpecDefaultImpl implements SizeSpecSource { private float mDefaultSizePercent; private float mMinimumSizePercent; @Override public void reloadResources() { final Resources res = mContext.getResources(); mMaxAspectRatioForMinSize = res.getFloat( R.dimen.config_pictureInPictureAspectRatioLimitForMinSize); mMinAspectRatioForMinSize = 1f / mMaxAspectRatioForMinSize; mDefaultSizePercent = res.getFloat(R.dimen.config_pictureInPictureDefaultSizePercent); mMinimumSizePercent = res.getFraction(R.fraction.config_pipShortestEdgePercent, 1, 1); } @Override public Size getMaxSize(float aspectRatio) { final int shorterLength = Math.min(getDisplayBounds().width(), getDisplayBounds().height()); final int totalHorizontalPadding = getInsetBounds().left + (getDisplayBounds().width() - getInsetBounds().right); final int totalVerticalPadding = getInsetBounds().top + (getDisplayBounds().height() - getInsetBounds().bottom); final int maxWidth, maxHeight; if (aspectRatio > 1f) { maxWidth = (int) Math.max(getDefaultSize(aspectRatio).getWidth(), shorterLength - totalHorizontalPadding); maxHeight = (int) (maxWidth / aspectRatio); } else { maxHeight = (int) Math.max(getDefaultSize(aspectRatio).getHeight(), shorterLength - totalVerticalPadding); maxWidth = (int) (maxHeight * aspectRatio); } return new Size(maxWidth, maxHeight); } @Override public Size getDefaultSize(float aspectRatio) { if (mOverrideMinSize != null) { return this.getMinSize(aspectRatio); } final int smallestDisplaySize = Math.min(getDisplayBounds().width(), getDisplayBounds().height()); final int minSize = (int) Math.max(getMinEdgeSize(), smallestDisplaySize * mDefaultSizePercent); final int width; final int height; if (aspectRatio <= mMinAspectRatioForMinSize || aspectRatio > mMaxAspectRatioForMinSize) { // Beyond these points, we can just use the min size as the shorter edge if (aspectRatio <= 1) { // Portrait, width is the minimum size width = minSize; height = Math.round(width / aspectRatio); } else { // Landscape, height is the minimum size height = minSize; width = Math.round(height * aspectRatio); } } else { // Within these points, ensure that the bounds fit within the radius of the limits // at the points final float widthAtMaxAspectRatioForMinSize = mMaxAspectRatioForMinSize * minSize; final float radius = PointF.length(widthAtMaxAspectRatioForMinSize, minSize); height = (int) Math.round(Math.sqrt((radius * radius) / (aspectRatio * aspectRatio + 1))); width = Math.round(height * aspectRatio); } return new Size(width, height); } @Override public Size getMinSize(float aspectRatio) { if (mOverrideMinSize != null) { return adjustOverrideMinSizeToAspectRatio(aspectRatio); } final int shorterLength = Math.min(getDisplayBounds().width(), getDisplayBounds().height()); final int minWidth, minHeight; if (aspectRatio > 1f) { minWidth = (int) Math.min(getDefaultSize(aspectRatio).getWidth(), shorterLength * mMinimumSizePercent); minHeight = (int) (minWidth / aspectRatio); } else { minHeight = (int) Math.min(getDefaultSize(aspectRatio).getHeight(), shorterLength * mMinimumSizePercent); minWidth = (int) (minHeight * aspectRatio); } return new Size(minWidth, minHeight); } @Override public Size getSizeForAspectRatio(Size size, float aspectRatio) { final int smallestSize = Math.min(size.getWidth(), size.getHeight()); final int minSize = Math.max(getMinEdgeSize(), smallestSize); final int width; final int height; if (aspectRatio <= 1) { // Portrait, width is the minimum size. width = minSize; height = Math.round(width / aspectRatio); } else { // Landscape, height is the minimum size height = minSize; width = Math.round(height * aspectRatio); } return new Size(width, height); } } public PipSizeSpecHandler(Context context, PipDisplayLayoutState pipDisplayLayoutState) { mContext = context; mPipDisplayLayoutState = pipDisplayLayoutState; // choose between two implementations of size spec logic if (supportsPipSizeLargeScreen()) { mSizeSpecSourceImpl = new SizeSpecLargeScreenOptimizedImpl(); } else { mSizeSpecSourceImpl = new SizeSpecDefaultImpl(); } reloadResources(); } /** Reloads the resources
SizeSpecDefaultImpl::onConfigurationChanged
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
MIT
public Rect getInsetBounds() { Rect insetBounds = new Rect(); DisplayLayout displayLayout = mPipDisplayLayoutState.getDisplayLayout(); Rect insets = displayLayout.stableInsets(); insetBounds.set(insets.left + mScreenEdgeInsets.x, insets.top + mScreenEdgeInsets.y, displayLayout.width() - insets.right - mScreenEdgeInsets.x, displayLayout.height() - insets.bottom - mScreenEdgeInsets.y); return insetBounds; }
Returns the inset bounds the PIP window can be visible in.
SizeSpecDefaultImpl::getInsetBounds
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
MIT
public void setOverrideMinSize(@Nullable Size overrideMinSize) { mOverrideMinSize = overrideMinSize; }
Returns the inset bounds the PIP window can be visible in. public Rect getInsetBounds() { Rect insetBounds = new Rect(); DisplayLayout displayLayout = mPipDisplayLayoutState.getDisplayLayout(); Rect insets = displayLayout.stableInsets(); insetBounds.set(insets.left + mScreenEdgeInsets.x, insets.top + mScreenEdgeInsets.y, displayLayout.width() - insets.right - mScreenEdgeInsets.x, displayLayout.height() - insets.bottom - mScreenEdgeInsets.y); return insetBounds; } /** Sets the preferred size of PIP as specified by the activity in PIP mode.
SizeSpecDefaultImpl::setOverrideMinSize
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
MIT
public int getOverrideMinEdgeSize() { if (mOverrideMinSize == null) return 0; return Math.min(getOverrideMinSize().getWidth(), getOverrideMinSize().getHeight()); }
Returns the inset bounds the PIP window can be visible in. public Rect getInsetBounds() { Rect insetBounds = new Rect(); DisplayLayout displayLayout = mPipDisplayLayoutState.getDisplayLayout(); Rect insets = displayLayout.stableInsets(); insetBounds.set(insets.left + mScreenEdgeInsets.x, insets.top + mScreenEdgeInsets.y, displayLayout.width() - insets.right - mScreenEdgeInsets.x, displayLayout.height() - insets.bottom - mScreenEdgeInsets.y); return insetBounds; } /** Sets the preferred size of PIP as specified by the activity in PIP mode. public void setOverrideMinSize(@Nullable Size overrideMinSize) { mOverrideMinSize = overrideMinSize; } /** Returns the preferred minimal size specified by the activity in PIP. @Nullable public Size getOverrideMinSize() { if (mOverrideMinSize != null && (mOverrideMinSize.getWidth() < mOverridableMinSize || mOverrideMinSize.getHeight() < mOverridableMinSize)) { return new Size(mOverridableMinSize, mOverridableMinSize); } return mOverrideMinSize; } /** Returns the minimum edge size of the override minimum size, or 0 if not set.
SizeSpecDefaultImpl::getOverrideMinEdgeSize
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
MIT
public Size getMaxSize(float aspectRatio) { return mSizeSpecSourceImpl.getMaxSize(aspectRatio); }
Returns the size for the max size spec.
SizeSpecDefaultImpl::getMaxSize
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
MIT
public Size getDefaultSize(float aspectRatio) { return mSizeSpecSourceImpl.getDefaultSize(aspectRatio); }
Returns the size for the default size spec.
SizeSpecDefaultImpl::getDefaultSize
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
MIT
public Size getMinSize(float aspectRatio) { return mSizeSpecSourceImpl.getMinSize(aspectRatio); }
Returns the size for the min size spec.
SizeSpecDefaultImpl::getMinSize
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
MIT
public Size getSizeForAspectRatio(@NonNull Size size, float aspectRatio) { if (size.equals(mOverrideMinSize)) { return adjustOverrideMinSizeToAspectRatio(aspectRatio); } return mSizeSpecSourceImpl.getSizeForAspectRatio(size, aspectRatio); }
Returns the adjusted size so that it conforms to the given aspectRatio. @param size current size @param aspectRatio target aspect ratio
SizeSpecDefaultImpl::getSizeForAspectRatio
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
MIT
public void dump(PrintWriter pw, String prefix) { final String innerPrefix = prefix + " "; pw.println(prefix + TAG); pw.println(innerPrefix + "mSizeSpecSourceImpl=" + mSizeSpecSourceImpl); pw.println(innerPrefix + "mOverrideMinSize=" + mOverrideMinSize); pw.println(innerPrefix + "mScreenEdgeInsets=" + mScreenEdgeInsets); }
Returns the adjusted overridden min size if it is set; otherwise, returns null. <p>Overridden min size needs to be adjusted in its own way while making sure that the target aspect ratio is maintained @param aspectRatio target aspect ratio @Nullable @VisibleForTesting Size adjustOverrideMinSizeToAspectRatio(float aspectRatio) { if (mOverrideMinSize == null) { return null; } final Size size = getOverrideMinSize(); final float sizeAspectRatio = size.getWidth() / (float) size.getHeight(); if (sizeAspectRatio > aspectRatio) { // Size is wider, fix the width and increase the height return new Size(size.getWidth(), (int) (size.getWidth() / aspectRatio)); } else { // Size is taller, fix the height and adjust the width. return new Size((int) (size.getHeight() * aspectRatio), size.getHeight()); } } @VisibleForTesting boolean supportsPipSizeLargeScreen() { // TODO(b/271468706): switch Tv to having a dedicated SizeSpecSource once the SizeSpecSource // can be injected return SystemProperties .getBoolean("persist.wm.debug.enable_pip_size_large_screen", true) && !isTv(); } private boolean isTv() { return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK); } /** Dumps internal state.
SizeSpecDefaultImpl::dump
java
Reginer/aosp-android-jar
android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java
MIT
public void setListener(com.android.ims.internal.IImsCallSessionListener listener) { }
Sets the listener to listen to the session events. An {@link ImsCallSession} can only hold one listener at a time. Subsequent calls to this method override the previous listener. @param listener to listen to the session events of this object
ImsCallSessionImplBase::setListener
java
Reginer/aosp-android-jar
android-31/src/android/telephony/ims/compat/stub/ImsCallSessionImplBase.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/telephony/ims/compat/stub/ImsCallSessionImplBase.java
MIT
public ReadOnlyFileSystemException() { }
Constructs an instance of this class.
ReadOnlyFileSystemException::ReadOnlyFileSystemException
java
Reginer/aosp-android-jar
android-35/src/java/nio/file/ReadOnlyFileSystemException.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/nio/file/ReadOnlyFileSystemException.java
MIT
public hc_nodeinsertbeforenewchilddiffdocument(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { super(factory); // // check if loaded documents are supported for content type // String contentType = getContentType(); preload(contentType, "hc_staff", false); preload(contentType, "hc_staff", true); }
Constructor. @param factory document factory, may not be null @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
hc_nodeinsertbeforenewchilddiffdocument::hc_nodeinsertbeforenewchilddiffdocument
java
Reginer/aosp-android-jar
android-33/src/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchilddiffdocument.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchilddiffdocument.java
MIT
public void runTest() throws Throwable { Document doc1; Document doc2; Node refChild; Node newChild; NodeList elementList; Node elementNode; Node insertedNode; doc1 = (Document) load("hc_staff", false); doc2 = (Document) load("hc_staff", true); newChild = doc1.createElement("br"); elementList = doc2.getElementsByTagName("p"); elementNode = elementList.item(1); refChild = elementNode.getFirstChild(); { boolean success = false; try { insertedNode = elementNode.insertBefore(newChild, refChild); } catch (DOMException ex) { success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); } assertTrue("throw_WRONG_DOCUMENT_ERR", success); } }
Runs the test case. @throws Throwable Any uncaught exception causes test to fail
hc_nodeinsertbeforenewchilddiffdocument::runTest
java
Reginer/aosp-android-jar
android-33/src/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchilddiffdocument.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchilddiffdocument.java
MIT
public String getTargetURI() { return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeinsertbeforenewchilddiffdocument"; }
Gets URI that identifies the test. @return uri identifier of test
hc_nodeinsertbeforenewchilddiffdocument::getTargetURI
java
Reginer/aosp-android-jar
android-33/src/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchilddiffdocument.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchilddiffdocument.java
MIT
public static void main(final String[] args) { DOMTestCase.doMain(hc_nodeinsertbeforenewchilddiffdocument.class, args); }
Runs this test from the command line. @param args command line arguments
hc_nodeinsertbeforenewchilddiffdocument::main
java
Reginer/aosp-android-jar
android-33/src/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchilddiffdocument.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchilddiffdocument.java
MIT
public boolean isGrayscale(Bitmap bitmap) { int height = bitmap.getHeight(); int width = bitmap.getWidth(); // shrink to a more manageable (yet hopefully no more or less colorful) size if (height > COMPACT_BITMAP_SIZE || width > COMPACT_BITMAP_SIZE) { if (mTempCompactBitmap == null) { mTempCompactBitmap = Bitmap.createBitmap( COMPACT_BITMAP_SIZE, COMPACT_BITMAP_SIZE, Bitmap.Config.ARGB_8888 ); mTempCompactBitmapCanvas = new Canvas(mTempCompactBitmap); mTempCompactBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTempCompactBitmapPaint.setFilterBitmap(true); } mTempMatrix.reset(); mTempMatrix.setScale( (float) COMPACT_BITMAP_SIZE / width, (float) COMPACT_BITMAP_SIZE / height, 0, 0); mTempCompactBitmapCanvas.drawColor(0, PorterDuff.Mode.SRC); // select all, erase mTempCompactBitmapCanvas.drawBitmap(bitmap, mTempMatrix, mTempCompactBitmapPaint); bitmap = mTempCompactBitmap; width = height = COMPACT_BITMAP_SIZE; } final int size = height * width; ensureBufferSize(size); bitmap.getPixels(mTempBuffer, 0, width, 0, 0, width, height); for (int i = 0; i < size; i++) { if (!isGrayscale(mTempBuffer[i])) { return false; } } return true; }
Checks whether a bitmap is grayscale. Grayscale here means "very close to a perfect gray". Instead of scanning every pixel in the bitmap, we first resize the bitmap to no more than COMPACT_BITMAP_SIZE^2 pixels using filtering. The hope is that any non-gray color elements will survive the squeezing process, contaminating the result with color.
ImageUtils::isGrayscale
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/util/ImageUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/util/ImageUtils.java
MIT
private void ensureBufferSize(int size) { if (mTempBuffer == null || mTempBuffer.length < size) { mTempBuffer = new int[size]; } }
Makes sure that {@code mTempBuffer} has at least length {@code size}.
ImageUtils::ensureBufferSize
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/util/ImageUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/util/ImageUtils.java
MIT
public static boolean isGrayscale(int color) { int alpha = 0xFF & (color >> 24); if (alpha < ALPHA_TOLERANCE) { return true; } int r = 0xFF & (color >> 16); int g = 0xFF & (color >> 8); int b = 0xFF & color; return Math.abs(r - g) < TOLERANCE && Math.abs(r - b) < TOLERANCE && Math.abs(g - b) < TOLERANCE; }
Classifies a color as grayscale or not. Grayscale here means "very close to a perfect gray"; if all three channels are approximately equal, this will return true. Note that really transparent colors are always grayscale.
ImageUtils::isGrayscale
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/util/ImageUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/util/ImageUtils.java
MIT
public static Bitmap buildScaledBitmap(Drawable drawable, int maxWidth, int maxHeight) { return buildScaledBitmap(drawable, maxWidth, maxHeight, false); }
Convert a drawable to a bitmap, scaled to fit within maxWidth and maxHeight.
ImageUtils::buildScaledBitmap
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/util/ImageUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/util/ImageUtils.java
MIT
public static Bitmap buildScaledBitmap(Drawable drawable, int maxWidth, int maxHeight, boolean allowUpscaling) { if (drawable == null) { return null; } int originalWidth = drawable.getIntrinsicWidth(); int originalHeight = drawable.getIntrinsicHeight(); if ((originalWidth <= maxWidth) && (originalHeight <= maxHeight) && (drawable instanceof BitmapDrawable)) { return ((BitmapDrawable) drawable).getBitmap(); } if (originalHeight <= 0 || originalWidth <= 0) { return null; } // create a new bitmap, scaling down to fit the max dimensions of // a large notification icon if necessary float ratio = Math.min((float) maxWidth / (float) originalWidth, (float) maxHeight / (float) originalHeight); if (!allowUpscaling) { ratio = Math.min(1.0f, ratio); } int scaledWidth = (int) (ratio * originalWidth); int scaledHeight = (int) (ratio * originalHeight); Bitmap result = Bitmap.createBitmap(scaledWidth, scaledHeight, Config.ARGB_8888); // and paint our app bitmap on it Canvas canvas = new Canvas(result); drawable.setBounds(0, 0, scaledWidth, scaledHeight); drawable.draw(canvas); return result; }
Convert a drawable to a bitmap, scaled to fit within maxWidth and maxHeight. @param allowUpscaling if true, the drawable will not only be scaled down, but also scaled up to fit within the maximum size given. This is useful for converting vectorized icons which usually have a very small intrinsic size.
ImageUtils::buildScaledBitmap
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/util/ImageUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/util/ImageUtils.java
MIT
public static int calculateSampleSize(Size currentSize, Size requestedSize) { int inSampleSize = 1; if (currentSize.getHeight() > requestedSize.getHeight() || currentSize.getWidth() > requestedSize.getWidth()) { final int halfHeight = currentSize.getHeight() / 2; final int halfWidth = currentSize.getWidth() / 2; // Calculate the largest inSampleSize value that is a power of 2 and keeps both // height and width larger than the requested height and width. while ((halfHeight / inSampleSize) >= requestedSize.getHeight() && (halfWidth / inSampleSize) >= requestedSize.getWidth()) { inSampleSize *= 2; } } return inSampleSize; }
@see https://developer.android.com/topic/performance/graphics/load-bitmap
ImageUtils::calculateSampleSize
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/util/ImageUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/util/ImageUtils.java
MIT
public static Bitmap loadThumbnail(ContentResolver resolver, Uri uri, Size size) throws IOException { try (ContentProviderClient client = resolver.acquireContentProviderClient(uri)) { final Bundle opts = new Bundle(); opts.putParcelable(ContentResolver.EXTRA_SIZE, new Point(size.getWidth(), size.getHeight())); return ImageDecoder.decodeBitmap(ImageDecoder.createSource(() -> { return client.openTypedAssetFile(uri, "image/*", opts, null); }), (ImageDecoder decoder, ImageInfo info, Source source) -> { decoder.setAllocator(ImageDecoder.ALLOCATOR_SOFTWARE); final int sample = calculateSampleSize(info.getSize(), size); if (sample > 1) { decoder.setTargetSampleSize(sample); } }); } }
Load a bitmap, and attempt to downscale to the required size, to save on memory. Updated to use newer and more compatible ImageDecoder. @see https://developer.android.com/topic/performance/graphics/load-bitmap
ImageUtils::loadThumbnail
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/util/ImageUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/util/ImageUtils.java
MIT
private boolean isValid(CharSequence text) { for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); // as defined by http://www.w3.org/TR/REC-xml/#charsets. boolean valid = c == 0x9 || c == 0xA || c == 0xD || (c >= 0x20 && c <= 0xd7ff) || (c >= 0xe000 && c <= 0xfffd); if (!valid) { return false; } } return true; }
Returns true if all of the characters in the text are permitted for use in XML documents.
BooleanParameter::isValid
java
Reginer/aosp-android-jar
android-35/src/org/apache/harmony/xml/dom/DOMConfigurationImpl.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/harmony/xml/dom/DOMConfigurationImpl.java
MIT
public String getFriendlyDisplayName() { return mDeviceAlias != null ? mDeviceAlias : mDeviceName; }
Gets the name to show in the UI. Uses the device alias if available, otherwise uses the device name.
WifiDisplay::getFriendlyDisplayName
java
Reginer/aosp-android-jar
android-33/src/android/hardware/display/WifiDisplay.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/hardware/display/WifiDisplay.java
MIT
public boolean hasSameAddress(WifiDisplay other) { return other != null && mDeviceAddress.equals(other.mDeviceAddress); }
Returns true if the other display is not null and has the same address as this one. Can be used to perform identity comparisons on displays ignoring properties that might change during a connection such as the name or alias.
WifiDisplay::hasSameAddress
java
Reginer/aosp-android-jar
android-33/src/android/hardware/display/WifiDisplay.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/hardware/display/WifiDisplay.java
MIT
public MemoryFile(String name, int length) throws IOException { try { mSharedMemory = SharedMemory.create(name, length); mMapping = mSharedMemory.mapReadWrite(); } catch (ErrnoException ex) { ex.rethrowAsIOException(); } }
Allocates a new ashmem region. The region is initially not purgable. @param name optional name for the file (can be null). @param length of the memory file in bytes, must be positive. @throws IOException if the memory file could not be created.
MemoryFile::MemoryFile
java
Reginer/aosp-android-jar
android-32/src/android/os/MemoryFile.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/MemoryFile.java
MIT
public void close() { deactivate(); mSharedMemory.close(); }
Closes the memory file. If there are no other open references to the memory file, it will be deleted.
MemoryFile::close
java
Reginer/aosp-android-jar
android-32/src/android/os/MemoryFile.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/MemoryFile.java
MIT
public int length() { return mSharedMemory.getSize(); }
Returns the length of the memory file. @return file length.
MemoryFile::length
java
Reginer/aosp-android-jar
android-32/src/android/os/MemoryFile.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/MemoryFile.java
MIT
public InputStream getInputStream() { return new MemoryInputStream(); }
Creates a new InputStream for reading from the memory file. @return InputStream
MemoryFile::getInputStream
java
Reginer/aosp-android-jar
android-32/src/android/os/MemoryFile.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/MemoryFile.java
MIT
public OutputStream getOutputStream() { return new MemoryOutputStream(); }
Creates a new OutputStream for writing to the memory file. @return OutputStream
MemoryFile::getOutputStream
java
Reginer/aosp-android-jar
android-32/src/android/os/MemoryFile.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/MemoryFile.java
MIT
public int readBytes(byte[] buffer, int srcOffset, int destOffset, int count) throws IOException { beginAccess(); try { mMapping.position(srcOffset); mMapping.get(buffer, destOffset, count); } finally { endAccess(); } return count; }
Reads bytes from the memory file. Will throw an IOException if the file has been purged. @param buffer byte array to read bytes into. @param srcOffset offset into the memory file to read from. @param destOffset offset into the byte array buffer to read into. @param count number of bytes to read. @return number of bytes read. @throws IOException if the memory file has been purged or deactivated.
MemoryFile::readBytes
java
Reginer/aosp-android-jar
android-32/src/android/os/MemoryFile.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/MemoryFile.java
MIT
public void writeBytes(byte[] buffer, int srcOffset, int destOffset, int count) throws IOException { beginAccess(); try { mMapping.position(destOffset); mMapping.put(buffer, srcOffset, count); } finally { endAccess(); } }
Write bytes to the memory file. Will throw an IOException if the file has been purged. @param buffer byte array to write bytes from. @param srcOffset offset into the byte array buffer to write from. @param destOffset offset into the memory file to write to. @param count number of bytes to write. @throws IOException if the memory file has been purged or deactivated.
MemoryFile::writeBytes
java
Reginer/aosp-android-jar
android-32/src/android/os/MemoryFile.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/MemoryFile.java
MIT
EntityConfidence(@NonNull Map<String, Float> source) { Objects.requireNonNull(source); // Prune non-existent entities and clamp to 1. mEntityConfidence.ensureCapacity(source.size()); for (Map.Entry<String, Float> it : source.entrySet()) { if (it.getValue() <= 0) continue; mEntityConfidence.put(it.getKey(), Math.min(1, it.getValue())); } resetSortedEntitiesFromMap(); }
Constructs an EntityConfidence from a map of entity to confidence. Map entries that have 0 confidence are removed, and values greater than 1 are clamped to 1. @param source a map from entity to a confidence value in the range 0 (low confidence) to 1 (high confidence).
EntityConfidence::EntityConfidence
java
Reginer/aosp-android-jar
android-32/src/android/view/textclassifier/EntityConfidence.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/view/textclassifier/EntityConfidence.java
MIT
public ScaleGestureDetector(@NonNull Context context, @NonNull OnScaleGestureListener listener, @Nullable Handler handler) { mContext = context; mListener = listener; final ViewConfiguration viewConfiguration = ViewConfiguration.get(context); mSpanSlop = viewConfiguration.getScaledTouchSlop() * 2; mMinSpan = viewConfiguration.getScaledMinimumScalingSpan(); mHandler = handler; // Quick scale is enabled by default after JB_MR2 final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion; if (targetSdkVersion > Build.VERSION_CODES.JELLY_BEAN_MR2) { setQuickScaleEnabled(true); } // Stylus scale is enabled by default after LOLLIPOP_MR1 if (targetSdkVersion > Build.VERSION_CODES.LOLLIPOP_MR1) { setStylusScaleEnabled(true); } }
Creates a ScaleGestureDetector with the supplied listener. @see android.os.Handler#Handler() @param context the application's context @param listener the listener invoked for all the callbacks, this must not be null. @param handler the handler to use for running deferred listener events. @throws NullPointerException if {@code listener} is null.
SimpleOnScaleGestureListener::ScaleGestureDetector
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public boolean onTouchEvent(@NonNull MotionEvent event) { if (mInputEventConsistencyVerifier != null) { mInputEventConsistencyVerifier.onTouchEvent(event, 0); } mCurrTime = event.getEventTime(); final int action = event.getActionMasked(); // Forward the event to check for double tap gesture if (mQuickScaleEnabled) { mGestureDetector.onTouchEvent(event); } final int count = event.getPointerCount(); final boolean isStylusButtonDown = (event.getButtonState() & MotionEvent.BUTTON_STYLUS_PRIMARY) != 0; final boolean anchoredScaleCancelled = mAnchoredScaleMode == ANCHORED_SCALE_MODE_STYLUS && !isStylusButtonDown; final boolean streamComplete = action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL || anchoredScaleCancelled; if (action == MotionEvent.ACTION_DOWN || streamComplete) { // Reset any scale in progress with the listener. // If it's an ACTION_DOWN we're beginning a new event stream. // This means the app probably didn't give us all the events. Shame on it. if (mInProgress) { mListener.onScaleEnd(this); mInProgress = false; mInitialSpan = 0; mAnchoredScaleMode = ANCHORED_SCALE_MODE_NONE; } else if (inAnchoredScaleMode() && streamComplete) { mInProgress = false; mInitialSpan = 0; mAnchoredScaleMode = ANCHORED_SCALE_MODE_NONE; } if (streamComplete) { return true; } } if (!mInProgress && mStylusScaleEnabled && !inAnchoredScaleMode() && !streamComplete && isStylusButtonDown) { // Start of a button scale gesture mAnchoredScaleStartX = event.getX(); mAnchoredScaleStartY = event.getY(); mAnchoredScaleMode = ANCHORED_SCALE_MODE_STYLUS; mInitialSpan = 0; } final boolean configChanged = action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_UP || action == MotionEvent.ACTION_POINTER_DOWN || anchoredScaleCancelled; final boolean pointerUp = action == MotionEvent.ACTION_POINTER_UP; final int skipIndex = pointerUp ? event.getActionIndex() : -1; // Determine focal point float sumX = 0, sumY = 0; final int div = pointerUp ? count - 1 : count; final float focusX; final float focusY; if (inAnchoredScaleMode()) { // In anchored scale mode, the focal pt is always where the double tap // or button down gesture started focusX = mAnchoredScaleStartX; focusY = mAnchoredScaleStartY; if (event.getY() < focusY) { mEventBeforeOrAboveStartingGestureEvent = true; } else { mEventBeforeOrAboveStartingGestureEvent = false; } } else { for (int i = 0; i < count; i++) { if (skipIndex == i) continue; sumX += event.getX(i); sumY += event.getY(i); } focusX = sumX / div; focusY = sumY / div; } // Determine average deviation from focal point float devSumX = 0, devSumY = 0; for (int i = 0; i < count; i++) { if (skipIndex == i) continue; // Convert the resulting diameter into a radius. devSumX += Math.abs(event.getX(i) - focusX); devSumY += Math.abs(event.getY(i) - focusY); } final float devX = devSumX / div; final float devY = devSumY / div; // Span is the average distance between touch points through the focal point; // i.e. the diameter of the circle with a radius of the average deviation from // the focal point. final float spanX = devX * 2; final float spanY = devY * 2; final float span; if (inAnchoredScaleMode()) { span = spanY; } else { span = (float) Math.hypot(spanX, spanY); } // Dispatch begin/end events as needed. // If the configuration changes, notify the app to reset its current state by beginning // a fresh scale event stream. final boolean wasInProgress = mInProgress; mFocusX = focusX; mFocusY = focusY; if (!inAnchoredScaleMode() && mInProgress && (span < mMinSpan || configChanged)) { mListener.onScaleEnd(this); mInProgress = false; mInitialSpan = span; } if (configChanged) { mPrevSpanX = mCurrSpanX = spanX; mPrevSpanY = mCurrSpanY = spanY; mInitialSpan = mPrevSpan = mCurrSpan = span; } final int minSpan = inAnchoredScaleMode() ? mSpanSlop : mMinSpan; if (!mInProgress && span >= minSpan && (wasInProgress || Math.abs(span - mInitialSpan) > mSpanSlop)) { mPrevSpanX = mCurrSpanX = spanX; mPrevSpanY = mCurrSpanY = spanY; mPrevSpan = mCurrSpan = span; mPrevTime = mCurrTime; mInProgress = mListener.onScaleBegin(this); } // Handle motion; focal point and span/scale factor are changing. if (action == MotionEvent.ACTION_MOVE) { mCurrSpanX = spanX; mCurrSpanY = spanY; mCurrSpan = span; boolean updatePrev = true; if (mInProgress) { updatePrev = mListener.onScale(this); } if (updatePrev) { mPrevSpanX = mCurrSpanX; mPrevSpanY = mCurrSpanY; mPrevSpan = mCurrSpan; mPrevTime = mCurrTime; } } return true; }
Accepts MotionEvents and dispatches events to a {@link OnScaleGestureListener} when appropriate. <p>Applications should pass a complete and consistent event stream to this method. A complete and consistent event stream involves all MotionEvents from the initial ACTION_DOWN to the final ACTION_UP or ACTION_CANCEL.</p> @param event The event to process @return true if the event was processed and the detector wants to receive the rest of the MotionEvents in this event stream.
SimpleOnScaleGestureListener::onTouchEvent
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public void setQuickScaleEnabled(boolean scales) { mQuickScaleEnabled = scales; if (mQuickScaleEnabled && mGestureDetector == null) { GestureDetector.SimpleOnGestureListener gestureListener = new GestureDetector.SimpleOnGestureListener() { @Override public boolean onDoubleTap(MotionEvent e) { // Double tap: start watching for a swipe mAnchoredScaleStartX = e.getX(); mAnchoredScaleStartY = e.getY(); mAnchoredScaleMode = ANCHORED_SCALE_MODE_DOUBLE_TAP; return true; } }; mGestureDetector = new GestureDetector(mContext, gestureListener, mHandler); } }
Set whether the associated {@link OnScaleGestureListener} should receive onScale callbacks when the user performs a doubleTap followed by a swipe. Note that this is enabled by default if the app targets API 19 and newer. @param scales true to enable quick scaling, false to disable
SimpleOnScaleGestureListener::setQuickScaleEnabled
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public boolean isQuickScaleEnabled() { return mQuickScaleEnabled; }
Return whether the quick scale gesture, in which the user performs a double tap followed by a swipe, should perform scaling. {@see #setQuickScaleEnabled(boolean)}.
SimpleOnScaleGestureListener::isQuickScaleEnabled
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public void setStylusScaleEnabled(boolean scales) { mStylusScaleEnabled = scales; }
Sets whether the associates {@link OnScaleGestureListener} should receive onScale callbacks when the user uses a stylus and presses the button. Note that this is enabled by default if the app targets API 23 and newer. @param scales true to enable stylus scaling, false to disable.
SimpleOnScaleGestureListener::setStylusScaleEnabled
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public boolean isStylusScaleEnabled() { return mStylusScaleEnabled; }
Return whether the stylus scale gesture, in which the user uses a stylus and presses the button, should perform scaling. {@see #setStylusScaleEnabled(boolean)}
SimpleOnScaleGestureListener::isStylusScaleEnabled
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public boolean isInProgress() { return mInProgress; }
Returns {@code true} if a scale gesture is in progress.
SimpleOnScaleGestureListener::isInProgress
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public float getFocusX() { return mFocusX; }
Get the X coordinate of the current gesture's focal point. If a gesture is in progress, the focal point is between each of the pointers forming the gesture. If {@link #isInProgress()} would return false, the result of this function is undefined. @return X coordinate of the focal point in pixels.
SimpleOnScaleGestureListener::getFocusX
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public float getFocusY() { return mFocusY; }
Get the Y coordinate of the current gesture's focal point. If a gesture is in progress, the focal point is between each of the pointers forming the gesture. If {@link #isInProgress()} would return false, the result of this function is undefined. @return Y coordinate of the focal point in pixels.
SimpleOnScaleGestureListener::getFocusY
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public float getCurrentSpan() { return mCurrSpan; }
Return the average distance between each of the pointers forming the gesture in progress through the focal point. @return Distance between pointers in pixels.
SimpleOnScaleGestureListener::getCurrentSpan
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public float getCurrentSpanX() { return mCurrSpanX; }
Return the average X distance between each of the pointers forming the gesture in progress through the focal point. @return Distance between pointers in pixels.
SimpleOnScaleGestureListener::getCurrentSpanX
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public float getCurrentSpanY() { return mCurrSpanY; }
Return the average Y distance between each of the pointers forming the gesture in progress through the focal point. @return Distance between pointers in pixels.
SimpleOnScaleGestureListener::getCurrentSpanY
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public float getPreviousSpan() { return mPrevSpan; }
Return the previous average distance between each of the pointers forming the gesture in progress through the focal point. @return Previous distance between pointers in pixels.
SimpleOnScaleGestureListener::getPreviousSpan
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public float getPreviousSpanX() { return mPrevSpanX; }
Return the previous average X distance between each of the pointers forming the gesture in progress through the focal point. @return Previous distance between pointers in pixels.
SimpleOnScaleGestureListener::getPreviousSpanX
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public float getPreviousSpanY() { return mPrevSpanY; }
Return the previous average Y distance between each of the pointers forming the gesture in progress through the focal point. @return Previous distance between pointers in pixels.
SimpleOnScaleGestureListener::getPreviousSpanY
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public float getScaleFactor() { if (inAnchoredScaleMode()) { // Drag is moving up; the further away from the gesture // start, the smaller the span should be, the closer, // the larger the span, and therefore the larger the scale final boolean scaleUp = (mEventBeforeOrAboveStartingGestureEvent && (mCurrSpan < mPrevSpan)) || (!mEventBeforeOrAboveStartingGestureEvent && (mCurrSpan > mPrevSpan)); final float spanDiff = (Math.abs(1 - (mCurrSpan / mPrevSpan)) * SCALE_FACTOR); return mPrevSpan <= mSpanSlop ? 1 : scaleUp ? (1 + spanDiff) : (1 - spanDiff); } return mPrevSpan > 0 ? mCurrSpan / mPrevSpan : 1; }
Return the scaling factor from the previous scale event to the current event. This value is defined as ({@link #getCurrentSpan()} / {@link #getPreviousSpan()}). @return The current scaling factor.
SimpleOnScaleGestureListener::getScaleFactor
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public long getTimeDelta() { return mCurrTime - mPrevTime; }
Return the time difference in milliseconds between the previous accepted scaling event and the current scaling event. @return Time difference since the last scaling event in milliseconds.
SimpleOnScaleGestureListener::getTimeDelta
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public long getEventTime() { return mCurrTime; }
Return the event time of the current event being processed. @return Current event time in milliseconds.
SimpleOnScaleGestureListener::getEventTime
java
Reginer/aosp-android-jar
android-34/src/android/view/ScaleGestureDetector.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/view/ScaleGestureDetector.java
MIT
public @KeyProperties.PurposeEnum int getPurposes() { return mPurposes; }
Gets the set of purposes (e.g., encrypt, decrypt, sign) for which the key can be used. Attempts to use the key for any other purpose will be rejected. <p>See {@link KeyProperties}.{@code PURPOSE} flags.
KeyProtection::getPurposes
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public boolean isDigestsSpecified() { return mDigests != null; }
Returns {@code true} if the set of digest algorithms with which the key can be used has been specified. @see #getDigests()
KeyProtection::isDigestsSpecified
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public boolean isRandomizedEncryptionRequired() { return mRandomizedEncryptionRequired; }
Returns {@code true} if encryption using this key must be sufficiently randomized to produce different ciphertexts for the same plaintext every time. The formal cryptographic property being required is <em>indistinguishability under chosen-plaintext attack ({@code IND-CPA})</em>. This property is important because it mitigates several classes of weaknesses due to which ciphertext may leak information about plaintext. For example, if a given plaintext always produces the same ciphertext, an attacker may see the repeated ciphertexts and be able to deduce something about the plaintext.
KeyProtection::isRandomizedEncryptionRequired
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public boolean isUserAuthenticationRequired() { return mUserAuthenticationRequired; }
Returns {@code true} if the key is authorized to be used only if the user has been authenticated. <p>This authorization applies only to secret key and private key operations. Public key operations are not restricted. @see #getUserAuthenticationValidityDurationSeconds() @see Builder#setUserAuthenticationRequired(boolean)
KeyProtection::isUserAuthenticationRequired
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public boolean isUserConfirmationRequired() { return mUserConfirmationRequired; }
Returns {@code true} if the key is authorized to be used only for messages confirmed by the user. Confirmation is separate from user authentication (see {@link #isUserAuthenticationRequired()}). Keys can be created that require confirmation but not user authentication, or user authentication but not confirmation, or both. Confirmation verifies that some user with physical possession of the device has approved a displayed message. User authentication verifies that the correct user is present and has authenticated. <p>This authorization applies only to secret key and private key operations. Public key operations are not restricted. @see Builder#setUserConfirmationRequired(boolean)
KeyProtection::isUserConfirmationRequired
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public int getUserAuthenticationValidityDurationSeconds() { return mUserAuthenticationValidityDurationSeconds; }
Gets the duration of time (seconds) for which this key is authorized to be used after the user is successfully authenticated. This has effect only if user authentication is required (see {@link #isUserAuthenticationRequired()}). <p>This authorization applies only to secret key and private key operations. Public key operations are not restricted. @return duration in seconds or {@code -1} if authentication is required for every use of the key. @see #isUserAuthenticationRequired() @see Builder#setUserAuthenticationValidityDurationSeconds(int)
KeyProtection::getUserAuthenticationValidityDurationSeconds
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public boolean isUserPresenceRequired() { return mUserPresenceRequred; }
Returns {@code true} if the key is authorized to be used only if a test of user presence has been performed between the {@code Signature.initSign()} and {@code Signature.sign()} calls. It requires that the KeyStore implementation have a direct way to validate the user presence for example a KeyStore hardware backed strongbox can use a button press that is observable in hardware. A test for user presence is tangential to authentication. The test can be part of an authentication step as long as this step can be validated by the hardware protecting the key and cannot be spoofed. For example, a physical button press can be used as a test of user presence if the other pins connected to the button are not able to simulate a button press. There must be no way for the primary processor to fake a button press, or that button must not be used as a test of user presence.
KeyProtection::isUserPresenceRequired
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public boolean isUserAuthenticationValidWhileOnBody() { return mUserAuthenticationValidWhileOnBody; }
Returns {@code true} if the key will be de-authorized when the device is removed from the user's body. This option has no effect on keys that don't have an authentication validity duration, and has no effect if the device lacks an on-body sensor. <p>Authorization applies only to secret key and private key operations. Public key operations are not restricted. @see #isUserAuthenticationRequired() @see #getUserAuthenticationValidityDurationSeconds() @see Builder#setUserAuthenticationValidWhileOnBody(boolean)
KeyProtection::isUserAuthenticationValidWhileOnBody
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public boolean isInvalidatedByBiometricEnrollment() { return mInvalidatedByBiometricEnrollment; }
Returns {@code true} if the key is irreversibly invalidated when a new biometric is enrolled or all enrolled biometrics are removed. This has effect only for keys that require biometric user authentication for every use. @see #isUserAuthenticationRequired() @see #getUserAuthenticationValidityDurationSeconds() @see Builder#setInvalidatedByBiometricEnrollment(boolean)
KeyProtection::isInvalidatedByBiometricEnrollment
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public boolean isCriticalToDeviceEncryption() { return mCriticalToDeviceEncryption; }
Return whether this key is critical to the device encryption flow. @see Builder#setCriticalToDeviceEncryption(boolean) @hide
KeyProtection::isCriticalToDeviceEncryption
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public boolean isUnlockedDeviceRequired() { return mUnlockedDeviceRequired; }
Returns {@code true} if the key is authorized to be used only while the device is unlocked. @see Builder#setUnlockedDeviceRequired(boolean)
KeyProtection::isUnlockedDeviceRequired
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public boolean isStrongBoxBacked() { return mIsStrongBoxBacked; }
Returns {@code true} if the key is protected by a Strongbox security chip. @hide
KeyProtection::isStrongBoxBacked
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public int getMaxUsageCount() { return mMaxUsageCount; }
Returns the maximum number of times the limited use key is allowed to be used or {@link KeyProperties#UNRESTRICTED_USAGE_COUNT} if there’s no restriction on the number of times the key can be used. @see Builder#setMaxUsageCount(int)
KeyProtection::getMaxUsageCount
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public boolean isRollbackResistant() { return mRollbackResistant; }
Returns {@code true} if the key is rollback-resistant, meaning that when deleted it is guaranteed to be permanently deleted and unusable. @see Builder#setRollbackResistant(boolean) @hide
KeyProtection::isRollbackResistant
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public Builder(@KeyProperties.PurposeEnum int purposes) { mPurposes = purposes; }
Creates a new instance of the {@code Builder}. @param purposes set of purposes (e.g., encrypt, decrypt, sign) for which the key can be used. Attempts to use the key for any other purpose will be rejected. <p>See {@link KeyProperties}.{@code PURPOSE} flags.
Builder::Builder
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public Builder setCriticalToDeviceEncryption(boolean critical) { mCriticalToDeviceEncryption = critical; return this; }
Set whether this key is critical to the device encryption flow This is a special flag only available to system servers to indicate the current key is part of the device encryption flow. Setting this flag causes the key to not be cryptographically bound to the LSKF even if the key is otherwise authentication bound. @hide
Builder::setCriticalToDeviceEncryption
java
Reginer/aosp-android-jar
android-35/src/android/security/keystore/KeyProtection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/security/keystore/KeyProtection.java
MIT
public static TestSuite suite() throws Exception { Class testClass = ClassLoader.getSystemClassLoader().loadClass( "org.w3c.domts.level3.xpath.alltests"); Constructor testConstructor = testClass.getConstructor( new Class[] { DOMTestDocumentBuilderFactory.class }); DOMTestDocumentBuilderFactory factory = new LSDocumentBuilderFactory( JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); Object test = testConstructor.newInstance(new Object[] { factory }); return new JUnitTestSuiteAdapter((DOMTestSuite) test); }
Create a new instance of the test suite @return test suite @throws Exception if tests or implementation not loaded
TestDefaultLSAltConfig::suite
java
Reginer/aosp-android-jar
android-33/src/org/w3c/domts/level3/xpath/TestDefaultLSAltConfig.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level3/xpath/TestDefaultLSAltConfig.java
MIT
public hc_characterdataindexsizeerrreplacedataoffsetnegative(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { org.w3c.domts.DocumentBuilderSetting[] settings = new org.w3c.domts.DocumentBuilderSetting[] { org.w3c.domts.DocumentBuilderSetting.signed }; DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); setFactory(testFactory); // // check if loaded documents are supported for content type // String contentType = getContentType(); preload(contentType, "hc_staff", true); }
Constructor. @param factory document factory, may not be null @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
hc_characterdataindexsizeerrreplacedataoffsetnegative::hc_characterdataindexsizeerrreplacedataoffsetnegative
java
Reginer/aosp-android-jar
android-33/src/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative.java
MIT
public void runTest() throws Throwable { Document doc; NodeList elementList; Node nameNode; CharacterData child; doc = (Document) load("hc_staff", true); elementList = doc.getElementsByTagName("acronym"); nameNode = elementList.item(0); child = (CharacterData) nameNode.getFirstChild(); { boolean success = false; try { child.replaceData(-5, 3, "ABC"); } catch (DOMException ex) { success = (ex.code == DOMException.INDEX_SIZE_ERR); } assertTrue("throws_INDEX_SIZE_ERR", success); } }
Runs the test case. @throws Throwable Any uncaught exception causes test to fail
hc_characterdataindexsizeerrreplacedataoffsetnegative::runTest
java
Reginer/aosp-android-jar
android-33/src/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative.java
MIT
public String getTargetURI() { return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative"; }
Gets URI that identifies the test. @return uri identifier of test
hc_characterdataindexsizeerrreplacedataoffsetnegative::getTargetURI
java
Reginer/aosp-android-jar
android-33/src/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative.java
MIT
public static void main(final String[] args) { DOMTestCase.doMain(hc_characterdataindexsizeerrreplacedataoffsetnegative.class, args); }
Runs this test from the command line. @param args command line arguments
hc_characterdataindexsizeerrreplacedataoffsetnegative::main
java
Reginer/aosp-android-jar
android-33/src/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative.java
MIT