android.util.Rational Java Examples

The following examples show how to use android.util.Rational. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From journaldev with MIT License 7 votes vote down vote up
private Preview setPreview() {

        Rational aspectRatio = new Rational(textureView.getWidth(), textureView.getHeight());
        Size screen = new Size(textureView.getWidth(), textureView.getHeight()); //size of the screen


        PreviewConfig pConfig = new PreviewConfig.Builder().setTargetAspectRatio(aspectRatio).setTargetResolution(screen).build();
        Preview preview = new Preview(pConfig);

        preview.setOnPreviewOutputUpdateListener(
                new Preview.OnPreviewOutputUpdateListener() {
                    @Override
                    public void onUpdated(Preview.PreviewOutput output) {
                        ViewGroup parent = (ViewGroup) textureView.getParent();
                        parent.removeView(textureView);
                        parent.addView(textureView, 0);

                        textureView.setSurfaceTexture(output.getSurfaceTexture());
                        updateTransform();
                    }
                });

        return preview;
    }
 
Example #2
Source File: MarshalQueryablePrimitive.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isTypeMappingSupported(TypeReference<T> managedType, int nativeType) {
    if (managedType.getType() instanceof Class<?>) {
        Class<?> klass = (Class<?>)managedType.getType();

        if (klass == byte.class || klass == Byte.class) {
            return nativeType == TYPE_BYTE;
        } else if (klass == int.class || klass == Integer.class) {
            return nativeType == TYPE_INT32;
        } else if (klass == float.class || klass == Float.class) {
            return nativeType == TYPE_FLOAT;
        } else if (klass == long.class || klass == Long.class) {
            return nativeType == TYPE_INT64;
        } else if (klass == double.class || klass == Double.class) {
            return nativeType == TYPE_DOUBLE;
        } else if (klass == Rational.class) {
            return nativeType == TYPE_RATIONAL;
        }
    }
    return false;
}
 
Example #3
Source File: MarshalQueryablePrimitive.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private Object unmarshalObject(ByteBuffer buffer) {
    switch (mNativeType) {
        case TYPE_INT32:
            return buffer.getInt();
        case TYPE_FLOAT:
            return buffer.getFloat();
        case TYPE_INT64:
            return buffer.getLong();
        case TYPE_RATIONAL:
            int numerator = buffer.getInt();
            int denominator = buffer.getInt();
            return new Rational(numerator, denominator);
        case TYPE_DOUBLE:
            return buffer.getDouble();
        case TYPE_BYTE:
            return buffer.get(); // getByte
        default:
            throw new UnsupportedOperationException(
                    "Can't unmarshal native type " + mNativeType);
    }
}
 
Example #4
Source File: MarshalHelpers.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Checks whether or not {@code klass} is one of the metadata-primitive classes.
 *
 * <p>The following types (whether boxed or unboxed) are considered primitive:
 * <ul>
 * <li>byte
 * <li>int
 * <li>float
 * <li>double
 * <li>Rational
 * </ul>
 * </p>
 *
 * <p>This doesn't strictly follow the java understanding of primitive since
 * boxed objects are included, Rational is included, and other types such as char and
 * short are not included.</p>
 *
 * @param klass a {@link Class} instance; using {@code null} will return {@code false}
 * @return {@code true} if primitive, {@code false} otherwise
 */
public static <T> boolean isPrimitiveClass(Class<T> klass) {
    if (klass == null) {
        return false;
    }

    if (klass == byte.class || klass == Byte.class) {
        return true;
    } else if (klass == int.class || klass == Integer.class) {
        return true;
    } else if (klass == float.class || klass == Float.class) {
        return true;
    } else if (klass == long.class || klass == Long.class) {
        return true;
    } else if (klass == double.class || klass == Double.class) {
        return true;
    } else if (klass == Rational.class) {
        return true;
    }

    return false;
}
 
Example #5
Source File: ColorSpaceTransform.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Check if this {@link ColorSpaceTransform} is equal to another {@link ColorSpaceTransform}.
 *
 * <p>Two color space transforms are equal if and only if all of their elements are
 * {@link Object#equals equal}.</p>
 *
 * @return {@code true} if the objects were equal, {@code false} otherwise
 */
@Override
public boolean equals(final Object obj) {
    if (obj == null) {
        return false;
    }
    if (this == obj) {
        return true;
    }
    if (obj instanceof ColorSpaceTransform) {
        final ColorSpaceTransform other = (ColorSpaceTransform) obj;
        for (int i = 0, j = 0; i < COUNT; ++i, j += RATIONAL_SIZE) {
            int numerator = mElements[j + OFFSET_NUMERATOR];
            int denominator = mElements[j + OFFSET_DENOMINATOR];
            int numeratorOther = other.mElements[j + OFFSET_NUMERATOR];
            int denominatorOther = other.mElements[j + OFFSET_DENOMINATOR];
            Rational r = new Rational(numerator, denominator);
            Rational rOther = new Rational(numeratorOther, denominatorOther);
            if (!r.equals(rOther)) {
                return false;
            }
        }
        return true;
    }
    return false;
}
 
Example #6
Source File: ColorSpaceTransform.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new immutable {@link ColorSpaceTransform} instance from a {@link Rational} array.
 *
 * <p>The elements must be stored in a row-major order.</p>
 *
 * @param elements An array of {@code 9} elements
 *
 * @throws IllegalArgumentException
 *            if the count of {@code elements} is not {@code 9}
 * @throws NullPointerException
 *            if {@code elements} or any sub-element is {@code null}
 */
public ColorSpaceTransform(Rational[] elements) {

    checkNotNull(elements, "elements must not be null");
    if (elements.length != COUNT) {
        throw new IllegalArgumentException("elements must be " + COUNT + " length");
    }

    mElements = new int[COUNT_INT];

    for (int i = 0; i < elements.length; ++i) {
        checkNotNull(elements, "element[" + i + "] must not be null");
        mElements[i * RATIONAL_SIZE + OFFSET_NUMERATOR] = elements[i].getNumerator();
        mElements[i * RATIONAL_SIZE + OFFSET_DENOMINATOR] = elements[i].getDenominator();
    }
}
 
Example #7
Source File: RtpSessionActivity.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.O)
private void startPictureInPicture() {
    try {
        enterPictureInPictureMode(
                new PictureInPictureParams.Builder()
                        .setAspectRatio(new Rational(10, 16))
                        .build()
        );
    } catch (final IllegalStateException e) {
        //this sometimes happens on Samsung phones (possibly when Knox is enabled)
        Log.w(Config.LOGTAG, "unable to enter picture in picture mode", e);
    }
}
 
Example #8
Source File: MediaSessionPlaybackActivity.java    From media-samples with Apache License 2.0 5 votes vote down vote up
/** Enters Picture-in-Picture mode. */
void minimize() {
    if (mMovieView == null) {
        return;
    }
    // Hide the controls in picture-in-picture mode.
    mMovieView.hideControls();
    // Calculate the aspect ratio of the PiP screen.
    Rational aspectRatio = new Rational(mMovieView.getWidth(), mMovieView.getHeight());
    mPictureInPictureParamsBuilder.setAspectRatio(aspectRatio).build();
    enterPictureInPictureMode(mPictureInPictureParamsBuilder.build());
}
 
Example #9
Source File: RtpSessionActivity.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.O)
private void startPictureInPicture() {
    try {
        enterPictureInPictureMode(
                new PictureInPictureParams.Builder()
                        .setAspectRatio(new Rational(10, 16))
                        .build()
        );
    } catch (final IllegalStateException e) {
        //this sometimes happens on Samsung phones (possibly when Knox is enabled)
        Log.w(Config.LOGTAG, "unable to enter picture in picture mode", e);
    }
}
 
Example #10
Source File: PiPActivity.java    From journaldev with MIT License 5 votes vote down vote up
@Override
public void onUserLeaveHint() {
    if (!isInPictureInPictureMode()) {
        Rational aspectRatio = new Rational(videoView.getWidth(), videoView.getHeight());
        pictureInPictureParamsBuilder.setAspectRatio(aspectRatio).build();
        enterPictureInPictureMode(pictureInPictureParamsBuilder.build());
    }
}
 
Example #11
Source File: PiPActivity.java    From journaldev with MIT License 5 votes vote down vote up
private void startPictureInPictureFeature() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

            Rational aspectRatio = new Rational(videoView.getWidth(), videoView.getHeight());
            pictureInPictureParamsBuilder.setAspectRatio(aspectRatio).build();
            enterPictureInPictureMode(pictureInPictureParamsBuilder.build());
        }
    }
 
Example #12
Source File: MainActivity.java    From android-PictureInPicture with Apache License 2.0 5 votes vote down vote up
/** Enters Picture-in-Picture mode. */
void minimize() {
    if (mMovieView == null) {
        return;
    }
    // Hide the controls in picture-in-picture mode.
    mMovieView.hideControls();
    // Calculate the aspect ratio of the PiP screen.
    Rational aspectRatio = new Rational(mMovieView.getWidth(), mMovieView.getHeight());
    mPictureInPictureParamsBuilder.setAspectRatio(aspectRatio).build();
    enterPictureInPictureMode(mPictureInPictureParamsBuilder.build());
}
 
Example #13
Source File: MediaSessionPlaybackActivity.java    From android-PictureInPicture with Apache License 2.0 5 votes vote down vote up
/** Enters Picture-in-Picture mode. */
void minimize() {
    if (mMovieView == null) {
        return;
    }
    // Hide the controls in picture-in-picture mode.
    mMovieView.hideControls();
    // Calculate the aspect ratio of the PiP screen.
    Rational aspectRatio = new Rational(mMovieView.getWidth(), mMovieView.getHeight());
    mPictureInPictureParamsBuilder.setAspectRatio(aspectRatio).build();
    enterPictureInPictureMode(mPictureInPictureParamsBuilder.build());
}
 
Example #14
Source File: OneCameraCharacteristicsImpl.java    From Camera2 with Apache License 2.0 5 votes vote down vote up
@Override
public float getExposureCompensationStep()
{
    if (!isExposureCompensationSupported())
    {
        return -1.0f;
    }
    Rational compensationStep = mCameraCharacteristics.get(
            CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP);
    return (float) compensationStep.getNumerator() / compensationStep.getDenominator();
}
 
Example #15
Source File: ParamsUtils.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Create a {@link Rational} value by approximating the float value as a rational.
 *
 * <p>Floating points too large to be represented as an integer will be converted to
 * to {@link Integer#MAX_VALUE}; floating points too small to be represented as an integer
 * will be converted to {@link Integer#MIN_VALUE}.</p>
 *
 * @param value a floating point value
 * @return the rational representation of the float
 */
public static Rational createRational(float value) {
    if (Float.isNaN(value)) {
        return Rational.NaN;
    } else if (value == Float.POSITIVE_INFINITY) {
        return Rational.POSITIVE_INFINITY;
    } else if (value == Float.NEGATIVE_INFINITY) {
        return Rational.NEGATIVE_INFINITY;
    } else if (value == 0.0f) {
        return Rational.ZERO;
    }

    // normal finite value: approximate it

    /*
     * Start out trying to approximate with denominator = 1million,
     * but if the numerator doesn't fit into an Int then keep making the denominator
     * smaller until it does.
     */
    int den = RATIONAL_DENOMINATOR;
    float numF;
    do {
        numF = value * den;

        if ((numF > Integer.MIN_VALUE && numF < Integer.MAX_VALUE) || (den == 1)) {
            break;
        }

        den /= 10;
    } while (true);

    /*
     *  By float -> int narrowing conversion in JLS 5.1.3, this will automatically become
     *  MIN_VALUE or MAX_VALUE if numF is too small/large to be represented by an integer
     */
    int num = (int) numF;

    return new Rational(num, den);
 }
 
Example #16
Source File: ColorSpaceTransform.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Copy the {@link Rational} elements in row-major order from this matrix into the destination.
 *
 * @param destination
 *          an array big enough to hold at least {@code 9} elements after the
 *          {@code offset}
 * @param offset
 *          a non-negative offset into the array
 * @throws NullPointerException
 *          If {@code destination} was {@code null}
 * @throws ArrayIndexOutOfBoundsException
 *          If there's not enough room to write the elements at the specified destination and
 *          offset.
 */
public void copyElements(Rational[] destination, int offset) {
    checkArgumentNonnegative(offset, "offset must not be negative");
    checkNotNull(destination, "destination must not be null");
    if (destination.length - offset < COUNT) {
        throw new ArrayIndexOutOfBoundsException("destination too small to fit elements");
    }

    for (int i = 0, j = 0; i < COUNT; ++i, j += RATIONAL_SIZE) {
        int numerator = mElements[j + OFFSET_NUMERATOR];
        int denominator = mElements[j + OFFSET_DENOMINATOR];

        destination[i + offset] = new Rational(numerator, denominator);
    }
}
 
Example #17
Source File: PictureInPictureParams.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** {@hide} */
PictureInPictureParams(Rational aspectRatio, List<RemoteAction> actions,
        Rect sourceRectHint) {
    mAspectRatio = aspectRatio;
    mUserActions = actions;
    mSourceRectHint = sourceRectHint;
}
 
Example #18
Source File: MainActivity.java    From media-samples with Apache License 2.0 5 votes vote down vote up
/** Enters Picture-in-Picture mode. */
void minimize() {
    if (mMovieView == null) {
        return;
    }
    // Hide the controls in picture-in-picture mode.
    mMovieView.hideControls();
    // Calculate the aspect ratio of the PiP screen.
    Rational aspectRatio = new Rational(mMovieView.getWidth(), mMovieView.getHeight());
    mPictureInPictureParamsBuilder.setAspectRatio(aspectRatio).build();
    enterPictureInPictureMode(mPictureInPictureParamsBuilder.build());
}
 
Example #19
Source File: CameraXUtil.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(21)
public static @NonNull Size buildResolutionForRatio(int longDimension, @NonNull Rational ratio, boolean isPortrait) {
  int shortDimension = longDimension * ratio.getDenominator() / ratio.getNumerator();

  if (isPortrait) {
    return new Size(shortDimension, longDimension);
  } else {
    return new Size(longDimension, shortDimension);
  }
}
 
Example #20
Source File: CameraXModule.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private void updateViewInfo() {
  if (mImageCapture != null) {
    mImageCapture.setCropAspectRatio(new Rational(getWidth(), getHeight()));
    mImageCapture.setTargetRotation(getDisplaySurfaceRotation());
  }

  if (mVideoCapture != null && MediaConstraints.isVideoTranscodeAvailable()) {
    mVideoCapture.setTargetRotation(getDisplaySurfaceRotation());
  }
}
 
Example #21
Source File: WebRtcCallActivity.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onUserLeaveHint() {
  if (deviceSupportsPipMode()) {
    PictureInPictureParams params = new PictureInPictureParams.Builder()
                                                              .setAspectRatio(new Rational(16, 9))
                                                              .build();
    setPictureInPictureParams(params);

    //noinspection deprecation
    enterPictureInPictureMode();
  }
}
 
Example #22
Source File: BrowserActivity.java    From GotoBrowser with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onUserLeaveHint() {
    boolean pipEnabled = sharedPref.getBoolean(PREF_PIP_MODE, false);
    if (supportsPiPMode() && pipEnabled) {
        PictureInPictureParams params = new PictureInPictureParams.Builder()
                .setAspectRatio(new Rational(1200, 720)).build();
        enterPictureInPictureMode(params);
    }
}
 
Example #23
Source File: PictureInPictureParams.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** {@hide} */
PictureInPictureParams(Parcel in) {
    if (in.readInt() != 0) {
        mAspectRatio = new Rational(in.readInt(), in.readInt());
    }
    if (in.readInt() != 0) {
        mUserActions = new ArrayList<>();
        in.readParcelableList(mUserActions, RemoteAction.class.getClassLoader());
    }
    if (in.readInt() != 0) {
        mSourceRectHint = Rect.CREATOR.createFromParcel(in);
    }
}
 
Example #24
Source File: ColorSpaceTransform.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Get an element of this matrix by its row and column.
 *
 * <p>The rows must be within the range [0, 3),
 * and the column must be within the range [0, 3).</p>
 *
 * @return element (non-{@code null})
 *
 * @throws IllegalArgumentException if column or row was out of range
 */
public Rational getElement(int column, int row) {
    if (column < 0 || column >= COLUMNS) {
        throw new IllegalArgumentException("column out of range");
    } else if (row < 0 || row >= ROWS) {
        throw new IllegalArgumentException("row out of range");
    }

    int numerator = mElements[(row * COLUMNS + column) * RATIONAL_SIZE + OFFSET_NUMERATOR];
    int denominator = mElements[(row * COLUMNS + column) * RATIONAL_SIZE + OFFSET_DENOMINATOR];

    return new Rational(numerator, denominator);
}
 
Example #25
Source File: PictureInPictureArgs.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private PictureInPictureArgs(Parcel in) {
    if (in.readInt() != 0) {
        mAspectRatio = new Rational(in.readInt(), in.readInt());
    }
    if (in.readInt() != 0) {
        mUserActions = new ArrayList<>();
        in.readParcelableList(mUserActions, RemoteAction.class.getClassLoader());
    }
    if (in.readInt() != 0) {
        mSourceRectHint = Rect.CREATOR.createFromParcel(in);
    }
}
 
Example #26
Source File: PreviewActivity.java    From EnhancedScreenshotNotification with GNU General Public License v3.0 4 votes vote down vote up
private void loadImage() {
    mImageView.setImageBitmap(null);

    InputStream input = null;
    if (mImageUri.toString().startsWith("content://")) {
        try {
            input = getContentResolver().openInputStream(mImageUri);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    } else {
        throw new IllegalArgumentException("Unsupported uri: " + mImageUri);
    }

    if (input == null) {
        Log.e(TAG, "Cannot open input stream for " + mImageUri);
        if (!isFinishing()) {
            finish();
        }
        return;
    }

    final InputStream is = input;
    if (mImageLoadFuture != null) {
        try {
            mImageLoadFuture.cancel(true);
        } catch (Exception ignored) {

        }
    }
    mImageLoadFuture = CompletableFuture.supplyAsync(() -> BitmapFactory.decodeStream(is))
            .whenCompleteAsync((bitmap, err) -> {
                if (err != null) {
                    err.printStackTrace();
                    if (!isFinishing()) {
                        finish();
                    }
                    return;
                }
                updatePictureInPictureParams(new Rational(bitmap.getWidth(), bitmap.getHeight()));
                mImageView.setImageBitmap(bitmap);
            }, Executors.mainThread());
}
 
Example #27
Source File: PreviewActivity.java    From EnhancedScreenshotNotification with GNU General Public License v3.0 4 votes vote down vote up
private synchronized void updatePictureInPictureParams(@Nullable Rational aspect) {
    if (aspect == null) {
        aspect = ScreenUtils.getDefaultDisplayRational(this);
    }

    final List<RemoteAction> remoteActions = new ArrayList<>();

    if (mShareIntent != null) {
        final RemoteAction shareAction = new RemoteAction(
                Icon.createWithResource(this, R.drawable.ic_share_white_24dp),
                getString(R.string.action_share_screenshot),
                getString(R.string.action_share_screenshot),
                PendingIntent.getBroadcast(this, 0,
                        new Intent(ACTION_SHARE), PendingIntent.FLAG_UPDATE_CURRENT)
        );
        remoteActions.add(shareAction);
    }

    if (mDeleteIntent != null) {
        final RemoteAction deleteAction = new RemoteAction(
                Icon.createWithResource(this, R.drawable.ic_delete_white_24dp),
                getString(R.string.action_delete_screenshot),
                getString(R.string.action_delete_screenshot),
                PendingIntent.getBroadcast(this, 0,
                        new Intent(ACTION_DELETE), PendingIntent.FLAG_UPDATE_CURRENT)
        );
        remoteActions.add(deleteAction);
    }

    if (mEditIntent != null) {
        final RemoteAction editAction = new RemoteAction(
                Icon.createWithResource(this, R.drawable.ic_edit_white_24dp),
                getString(R.string.action_edit),
                getString(R.string.action_edit),
                PendingIntent.getBroadcast(this, 0,
                        new Intent(ACTION_EDIT), PendingIntent.FLAG_UPDATE_CURRENT)
        );
        remoteActions.add(editAction);
    }

    mPIPParams = new PictureInPictureParams.Builder()
            .setAspectRatio(aspect)
            .setActions(remoteActions)
            .build();

    if (isInPictureInPictureMode()) {
        setPictureInPictureParams(mPIPParams);
    }
}
 
Example #28
Source File: PictureInPictureParams.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/** @hide */
public Rational getAspectRatioRational() {
    return mAspectRatio;
}
 
Example #29
Source File: AndroidCamera2Capabilities.java    From Camera2 with Apache License 2.0 4 votes vote down vote up
AndroidCamera2Capabilities(CameraCharacteristics p) {
    super(new Stringifier());

    StreamConfigurationMap s = p.get(SCALER_STREAM_CONFIGURATION_MAP);

    for (Range<Integer> fpsRange : p.get(CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES)) {
        mSupportedPreviewFpsRange.add(new int[] { fpsRange.getLower(), fpsRange.getUpper() });
    }

    // TODO: We only support TextureView preview rendering
    mSupportedPreviewSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList(
            s.getOutputSizes(SurfaceTexture.class))));
    for (int format : s.getOutputFormats()) {
        mSupportedPreviewFormats.add(format);
    }

    // TODO: We only support MediaRecorder video capture
    mSupportedVideoSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList(
            s.getOutputSizes(MediaRecorder.class))));

    // TODO: We only support JPEG image capture
    mSupportedPhotoSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList(
            s.getOutputSizes(ImageFormat.JPEG))));
    mSupportedPhotoFormats.addAll(mSupportedPreviewFormats);

    buildSceneModes(p);
    buildFlashModes(p);
    buildFocusModes(p);
    buildWhiteBalances(p);
    // TODO: Populate mSupportedFeatures

    // TODO: Populate mPreferredPreviewSizeForVideo

    Range<Integer> ecRange = p.get(CONTROL_AE_COMPENSATION_RANGE);
    mMinExposureCompensation = ecRange.getLower();
    mMaxExposureCompensation = ecRange.getUpper();

    Rational ecStep = p.get(CONTROL_AE_COMPENSATION_STEP);
    mExposureCompensationStep = (float) ecStep.getNumerator() / ecStep.getDenominator();

    mMaxNumOfFacesSupported = p.get(STATISTICS_INFO_MAX_FACE_COUNT);
    mMaxNumOfMeteringArea = p.get(CONTROL_MAX_REGIONS_AE);

    mMaxZoomRatio = p.get(SCALER_AVAILABLE_MAX_DIGITAL_ZOOM);
    // TODO: Populate mHorizontalViewAngle
    // TODO: Populate mVerticalViewAngle
    // TODO: Populate mZoomRatioList
    // TODO: Populate mMaxZoomIndex

    if (supports(FocusMode.AUTO)) {
        mMaxNumOfFocusAreas = p.get(CONTROL_MAX_REGIONS_AF);
        if (mMaxNumOfFocusAreas > 0) {
            mSupportedFeatures.add(Feature.FOCUS_AREA);
        }
    }
    if (mMaxNumOfMeteringArea > 0) {
        mSupportedFeatures.add(Feature.METERING_AREA);
    }

    if (mMaxZoomRatio > CameraCapabilities.ZOOM_RATIO_UNZOOMED) {
        mSupportedFeatures.add(Feature.ZOOM);
    }

    // TODO: Detect other features
}
 
Example #30
Source File: AndroidOPiPActivity.java    From DKVideoPlayer with Apache License 2.0 4 votes vote down vote up
public void startFloatWindow(View view) {
    Rational aspectRatio = new Rational(16, 9);
    mPictureInPictureParamsBuilder.setAspectRatio(aspectRatio).build();
    enterPictureInPictureMode(mPictureInPictureParamsBuilder.build());
}