Search in sources :

Example 26 with MagnificationSpec

use of android.view.MagnificationSpec in project android_frameworks_base by ParanoidAndroid.

the class ScreenMagnifier method handleOnMagnifiedBoundsChanged.

private void handleOnMagnifiedBoundsChanged(Region bounds) {
    // the new display width and height.
    if (mUpdateMagnificationSpecOnNextBoundsChange) {
        mUpdateMagnificationSpecOnNextBoundsChange = false;
        MagnificationSpec spec = mMagnificationController.getMagnificationSpec();
        Rect magnifiedFrame = mTempRect;
        mMagnifiedBounds.getBounds(magnifiedFrame);
        final float scale = spec.scale;
        final float centerX = (-spec.offsetX + magnifiedFrame.width() / 2) / scale;
        final float centerY = (-spec.offsetY + magnifiedFrame.height() / 2) / scale;
        mMagnificationController.setScaleAndMagnifiedRegionCenter(scale, centerX, centerY, false);
    }
    mMagnifiedBounds.set(bounds);
    mAms.onMagnificationStateChanged();
}
Also used : MagnificationSpec(android.view.MagnificationSpec) Rect(android.graphics.Rect)

Example 27 with MagnificationSpec

use of android.view.MagnificationSpec in project android_frameworks_base by ParanoidAndroid.

the class DisplayMagnifier method getMagnificationSpecForWindowLocked.

public MagnificationSpec getMagnificationSpecForWindowLocked(WindowState windowState) {
    MagnificationSpec spec = mMagnifedViewport.getMagnificationSpecLocked();
    if (spec != null && !spec.isNop()) {
        WindowManagerPolicy policy = mWindowManagerService.mPolicy;
        final int windowType = windowState.mAttrs.type;
        if (!policy.isTopLevelWindow(windowType) && windowState.mAttachedWindow != null && !policy.canMagnifyWindow(windowType)) {
            return null;
        }
        if (!policy.canMagnifyWindow(windowState.mAttrs.type)) {
            return null;
        }
    }
    return spec;
}
Also used : MagnificationSpec(android.view.MagnificationSpec) WindowManagerPolicy(android.view.WindowManagerPolicy) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 28 with MagnificationSpec

use of android.view.MagnificationSpec in project android_frameworks_base by AOSPA.

the class MagnificationController method offsetMagnifiedRegionCenter.

/**
     * Offsets the center of the magnified region.
     *
     * @param offsetX the amount in pixels to offset the X center
     * @param offsetY the amount in pixels to offset the Y center
     * @param id the ID of the service requesting the change
     */
public void offsetMagnifiedRegionCenter(float offsetX, float offsetY, int id) {
    synchronized (mLock) {
        if (!mRegistered) {
            return;
        }
        final MagnificationSpec currSpec = mCurrentMagnificationSpec;
        final float nonNormOffsetX = currSpec.offsetX - offsetX;
        currSpec.offsetX = MathUtils.constrain(nonNormOffsetX, getMinOffsetXLocked(), 0);
        final float nonNormOffsetY = currSpec.offsetY - offsetY;
        currSpec.offsetY = MathUtils.constrain(nonNormOffsetY, getMinOffsetYLocked(), 0);
        if (id != INVALID_ID) {
            mIdOfLastServiceToMagnify = id;
        }
        mSpecAnimationBridge.updateSentSpec(currSpec, false);
    }
}
Also used : MagnificationSpec(android.view.MagnificationSpec)

Example 29 with MagnificationSpec

use of android.view.MagnificationSpec in project android_frameworks_base by AOSPA.

the class MagnificationController method resetLocked.

private boolean resetLocked(boolean animate) {
    if (!mRegistered) {
        return false;
    }
    final MagnificationSpec spec = mCurrentMagnificationSpec;
    final boolean changed = !spec.isNop();
    if (changed) {
        spec.clear();
        onMagnificationChangedLocked();
    }
    mIdOfLastServiceToMagnify = INVALID_ID;
    mSpecAnimationBridge.updateSentSpec(spec, animate);
    return changed;
}
Also used : MagnificationSpec(android.view.MagnificationSpec)

Example 30 with MagnificationSpec

use of android.view.MagnificationSpec in project android_frameworks_base by DirtyUnicorns.

the class MagnificationController method onMagnificationRegionChanged.

/**
     * Update our copy of the current magnification region
     *
     * @param magnified the magnified region
     * @param updateSpec {@code true} to update the scale and center based on
     *                   the region bounds, {@code false} to leave them as-is
     */
private void onMagnificationRegionChanged(Region magnified, boolean updateSpec) {
    synchronized (mLock) {
        if (!mRegistered) {
            // Don't update if we've unregistered
            return;
        }
        boolean magnificationChanged = false;
        boolean boundsChanged = false;
        if (!mMagnificationRegion.equals(magnified)) {
            mMagnificationRegion.set(magnified);
            mMagnificationRegion.getBounds(mMagnificationBounds);
            boundsChanged = true;
        }
        if (updateSpec) {
            final MagnificationSpec sentSpec = mSpecAnimationBridge.mSentMagnificationSpec;
            final float scale = sentSpec.scale;
            final float offsetX = sentSpec.offsetX;
            final float offsetY = sentSpec.offsetY;
            // Compute the new center and update spec as needed.
            final float centerX = (mMagnificationBounds.width() / 2.0f + mMagnificationBounds.left - offsetX) / scale;
            final float centerY = (mMagnificationBounds.height() / 2.0f + mMagnificationBounds.top - offsetY) / scale;
            magnificationChanged = setScaleAndCenterLocked(scale, centerX, centerY, false, INVALID_ID);
        }
        // If magnification changed we already notified for the change.
        if (boundsChanged && updateSpec && !magnificationChanged) {
            onMagnificationChangedLocked();
        }
    }
}
Also used : MagnificationSpec(android.view.MagnificationSpec)

Aggregations

MagnificationSpec (android.view.MagnificationSpec)35 Rect (android.graphics.Rect)12 Point (android.graphics.Point)7 Matrix (android.graphics.Matrix)5 Transformation (android.view.animation.Transformation)5 AccessibilityService (android.accessibilityservice.AccessibilityService)1 Paint (android.graphics.Paint)1 WindowManagerPolicy (android.view.WindowManagerPolicy)1 AccessibilityInteractionClient (android.view.accessibility.AccessibilityInteractionClient)1 AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)1 IStatusBarService (com.android.internal.statusbar.IStatusBarService)1