diff options
Diffstat (limited to 'java/com/android/dialer/compat')
-rw-r--r-- | java/com/android/dialer/compat/ActivityCompat.java | 29 | ||||
-rw-r--r-- | java/com/android/dialer/compat/CompatUtils.java | 21 | ||||
-rw-r--r-- | java/com/android/dialer/compat/PathInterpolatorCompat.java | 120 |
3 files changed, 10 insertions, 160 deletions
diff --git a/java/com/android/dialer/compat/ActivityCompat.java b/java/com/android/dialer/compat/ActivityCompat.java deleted file mode 100644 index e59b11593..000000000 --- a/java/com/android/dialer/compat/ActivityCompat.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dialer.compat; - -import android.app.Activity; -import android.os.Build.VERSION; -import android.os.Build.VERSION_CODES; - -/** Utility for calling methods introduced after Marshmallow for Activities. */ -public class ActivityCompat { - - public static boolean isInMultiWindowMode(Activity activity) { - return VERSION.SDK_INT >= VERSION_CODES.N && activity.isInMultiWindowMode(); - } -} diff --git a/java/com/android/dialer/compat/CompatUtils.java b/java/com/android/dialer/compat/CompatUtils.java index d09f8b0e1..f0039e930 100644 --- a/java/com/android/dialer/compat/CompatUtils.java +++ b/java/com/android/dialer/compat/CompatUtils.java @@ -16,15 +16,14 @@ package com.android.dialer.compat; import android.content.Context; -import android.os.Build.VERSION; -import android.os.Build.VERSION_CODES; import android.os.LocaleList; import java.util.Locale; -/** TODO(calderwoodra): documentation */ +/** TODO(linyuh): Remove deprecated methods and rename this class. */ public final class CompatUtils { /** PrioritizedMimeType is added in API level 23. */ + @Deprecated public static boolean hasPrioritizedMimeType() { return true; } @@ -35,6 +34,7 @@ public final class CompatUtils { * * @return {@code true} if multi-SIM capability is available, {@code false} otherwise. */ + @Deprecated public static boolean isMSIMCompatible() { return true; } @@ -45,6 +45,7 @@ public final class CompatUtils { * * @return {@code true} if video calling is allowed, {@code false} otherwise. */ + @Deprecated public static boolean isVideoCompatible() { return true; } @@ -55,6 +56,7 @@ public final class CompatUtils { * * @return {@code true} if video presence checking is allowed, {@code false} otherwise. */ + @Deprecated public static boolean isVideoPresenceCompatible() { return true; } @@ -65,20 +67,17 @@ public final class CompatUtils { * * @return {@code true} if call subject is a feature on this device, {@code false} otherwise. */ + @Deprecated public static boolean isCallSubjectCompatible() { return true; } /** Returns locale of the device. */ public static Locale getLocale(Context context) { - if (VERSION.SDK_INT >= VERSION_CODES.N) { - LocaleList localList = context.getResources().getConfiguration().getLocales(); - if (!localList.isEmpty()) { - return localList.get(0); - } - return Locale.getDefault(); - } else { - return context.getResources().getConfiguration().locale; + LocaleList localList = context.getResources().getConfiguration().getLocales(); + if (!localList.isEmpty()) { + return localList.get(0); } + return Locale.getDefault(); } } diff --git a/java/com/android/dialer/compat/PathInterpolatorCompat.java b/java/com/android/dialer/compat/PathInterpolatorCompat.java deleted file mode 100644 index d0d410d7b..000000000 --- a/java/com/android/dialer/compat/PathInterpolatorCompat.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.dialer.compat; - -import android.graphics.Path; -import android.graphics.PathMeasure; -import android.os.Build; -import android.view.animation.Interpolator; -import android.view.animation.PathInterpolator; - -public class PathInterpolatorCompat { - - public static Interpolator create( - float controlX1, float controlY1, float controlX2, float controlY2) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - return new PathInterpolator(controlX1, controlY1, controlX2, controlY2); - } - return new PathInterpolatorBase(controlX1, controlY1, controlX2, controlY2); - } - - private static class PathInterpolatorBase implements Interpolator { - - /** Governs the accuracy of the approximation of the {@link Path}. */ - private static final float PRECISION = 0.002f; - - private final float[] x; - private final float[] y; - - public PathInterpolatorBase(Path path) { - final PathMeasure pathMeasure = new PathMeasure(path, false /* forceClosed */); - - final float pathLength = pathMeasure.getLength(); - final int numPoints = (int) (pathLength / PRECISION) + 1; - - x = new float[numPoints]; - y = new float[numPoints]; - - final float[] position = new float[2]; - for (int i = 0; i < numPoints; ++i) { - final float distance = (i * pathLength) / (numPoints - 1); - pathMeasure.getPosTan(distance, position, null /* tangent */); - - x[i] = position[0]; - y[i] = position[1]; - } - } - - public PathInterpolatorBase(float controlX, float controlY) { - this(createQuad(controlX, controlY)); - } - - public PathInterpolatorBase( - float controlX1, float controlY1, float controlX2, float controlY2) { - this(createCubic(controlX1, controlY1, controlX2, controlY2)); - } - - private static Path createQuad(float controlX, float controlY) { - final Path path = new Path(); - path.moveTo(0.0f, 0.0f); - path.quadTo(controlX, controlY, 1.0f, 1.0f); - return path; - } - - private static Path createCubic( - float controlX1, float controlY1, float controlX2, float controlY2) { - final Path path = new Path(); - path.moveTo(0.0f, 0.0f); - path.cubicTo(controlX1, controlY1, controlX2, controlY2, 1.0f, 1.0f); - return path; - } - - @Override - public float getInterpolation(float t) { - if (t <= 0.0f) { - return 0.0f; - } else if (t >= 1.0f) { - return 1.0f; - } - - // Do a binary search for the correct x to interpolate between. - int startIndex = 0; - int endIndex = x.length - 1; - while (endIndex - startIndex > 1) { - int midIndex = (startIndex + endIndex) / 2; - if (t < x[midIndex]) { - endIndex = midIndex; - } else { - startIndex = midIndex; - } - } - - final float xRange = x[endIndex] - x[startIndex]; - if (xRange == 0) { - return y[startIndex]; - } - - final float tInRange = t - x[startIndex]; - final float fraction = tInRange / xRange; - - final float startY = y[startIndex]; - final float endY = y[endIndex]; - - return startY + (fraction * (endY - startY)); - } - } -} |