diff --git a/build.gradle b/build.gradle index 064a5e0..e57404d 100644 --- a/build.gradle +++ b/build.gradle @@ -44,4 +44,10 @@ allprojects { } } } + + gradle.projectsEvaluated { + tasks.withType(JavaCompile) { + options.compilerArgs << "-Xlint:deprecation" + } + } } diff --git a/library/src/main/java/com/alexvasilkov/gestures/GestureController.java b/library/src/main/java/com/alexvasilkov/gestures/GestureController.java index 79624f1..b769532 100644 --- a/library/src/main/java/com/alexvasilkov/gestures/GestureController.java +++ b/library/src/main/java/com/alexvasilkov/gestures/GestureController.java @@ -180,18 +180,6 @@ public void removeOnStateChangeListener(@NonNull OnStateChangeListener listener) stateListeners.remove(listener); } - /** - * @param enabled Whether long press should be enabled or not - * @deprecated In order to enable long clicks you should either set - * {@link View#setOnLongClickListener(View.OnLongClickListener)} or use - * {@link View#setLongClickable(boolean)}. - */ - @SuppressWarnings({ "unused", "WeakerAccess" }) // Public API - @Deprecated - public void setLongPressEnabled(boolean enabled) { - targetView.setLongClickable(true); - } - /** * Returns settings that can be updated. *
diff --git a/library/src/main/java/com/alexvasilkov/gestures/Settings.java b/library/src/main/java/com/alexvasilkov/gestures/Settings.java index 1233320..1adf11f 100644 --- a/library/src/main/java/com/alexvasilkov/gestures/Settings.java +++ b/library/src/main/java/com/alexvasilkov/gestures/Settings.java @@ -601,22 +601,6 @@ public Settings enableBounds() { return this; } - /** - * @param restrict Whether image bounds should be restricted or not - * @return Current settings object for calls chaining - * @deprecated Use {@link #disableBounds()} and {@link #enableBounds()} methods instead. - */ - @SuppressWarnings("unused") // Public API - @Deprecated - @NonNull - public Settings setRestrictBounds(boolean restrict) { - boundsDisableCount += restrict ? -1 : 1; - if (boundsDisableCount < 0) { // In case someone explicitly used this method during setup - boundsDisableCount = 0; - } - return this; - } - /** * Duration of animations. * diff --git a/library/src/main/java/com/alexvasilkov/gestures/StateController.java b/library/src/main/java/com/alexvasilkov/gestures/StateController.java index 383b1b6..586696e 100644 --- a/library/src/main/java/com/alexvasilkov/gestures/StateController.java +++ b/library/src/main/java/com/alexvasilkov/gestures/StateController.java @@ -11,7 +11,6 @@ import com.alexvasilkov.gestures.internal.MovementBounds; import com.alexvasilkov.gestures.internal.ZoomBounds; import com.alexvasilkov.gestures.utils.GravityUtils; -import com.alexvasilkov.gestures.utils.MathUtils; /** * Helper class that holds reference to {@link Settings} object and controls some aspects of view @@ -324,112 +323,4 @@ public void getMovementArea(@NonNull State state, @NonNull RectF out) { movBounds.set(state).getExternalBounds(out); } - - /* - * Deprecated methods. - */ - - /** - * @return Min zoom level - * @deprecated Use {@link #getMinZoom(State)} instead. - */ - @SuppressWarnings("unused") // Public API - @Deprecated - public float getEffectiveMinZoom() { - return zoomBounds.getMinZoom(); - } - - /** - * @return Max zoom level - * @deprecated Use {@link #getMaxZoom(State)} instead. - */ - @SuppressWarnings("unused") // Public API - @Deprecated - public float getEffectiveMaxZoom() { - return zoomBounds.getMaxZoom(); - } - - /** - * @param out Output movement area rectangle - * @param state Current state - * @deprecated User {@link #getMovementArea(State, RectF)} instead. - */ - @SuppressWarnings("unused") // Public API - @Deprecated - public void getEffectiveMovementArea(RectF out, State state) { - getMovementArea(state, out); - } - - /** - * @param value Value to be restricted - * @param minValue Min value - * @param maxValue Max value - * @return Restricted value - * @deprecated Use {@link MathUtils#restrict(float, float, float)}. - */ - @SuppressWarnings("unused") // Public API - @Deprecated - public static float restrict(float value, float minValue, float maxValue) { - return Math.max(minValue, Math.min(value, maxValue)); - } - - /** - * @param out Interpolated state (output) - * @param start Start state - * @param end End state - * @param factor Factor - * @deprecated Use {@link MathUtils#interpolate(State, State, State, float)}. - */ - @SuppressWarnings("unused") // Public API - @Deprecated - public static void interpolate(State out, State start, State end, float factor) { - MathUtils.interpolate(out, start, end, factor); - } - - /** - * @param out Interpolated state (output) - * @param start Start state - * @param startPivotX Pivot point's X coordinate in start state coordinates - * @param startPivotY Pivot point's Y coordinate in start state coordinates - * @param end End state - * @param endPivotX Pivot point's X coordinate in end state coordinates - * @param endPivotY Pivot point's Y coordinate in end state coordinates - * @param factor Factor - * @deprecated Use - * {@link MathUtils#interpolate(State, State, float, float, State, float, float, float)}. - */ - @SuppressWarnings("unused") // Public API - @Deprecated - public static void interpolate(State out, State start, float startPivotX, float startPivotY, - State end, float endPivotX, float endPivotY, float factor) { - MathUtils.interpolate(out, start, startPivotX, startPivotY, - end, endPivotX, endPivotY, factor); - } - - /** - * @param start Start value - * @param end End value - * @param factor Factor - * @return Interpolated value - * @deprecated Use {@link MathUtils#interpolate(float, float, float)}. - */ - @SuppressWarnings("unused") // Public API - @Deprecated - public static float interpolate(float start, float end, float factor) { - return MathUtils.interpolate(start, end, factor); - } - - /** - * @param out Interpolated rectangle (output) - * @param start Start rectangle - * @param end End rectangle - * @param factor Factor - * @deprecated Use {@link MathUtils#interpolate(RectF, RectF, RectF, float)}, - */ - @SuppressWarnings("unused") // Public API - @Deprecated - public static void interpolate(RectF out, RectF start, RectF end, float factor) { - MathUtils.interpolate(out, start, end, factor); - } - } diff --git a/library/src/main/java/com/alexvasilkov/gestures/animation/ViewPositionAnimator.java b/library/src/main/java/com/alexvasilkov/gestures/animation/ViewPositionAnimator.java index 2c5de55..9de5c3f 100644 --- a/library/src/main/java/com/alexvasilkov/gestures/animation/ViewPositionAnimator.java +++ b/library/src/main/java/com/alexvasilkov/gestures/animation/ViewPositionAnimator.java @@ -385,27 +385,6 @@ private void ensurePositionUpdateListenersRemoved() { listenersToRemove.clear(); } - /** - * @return Animation duration - * @deprecated Use {@link Settings#getAnimationsDuration()} instead. - */ - @SuppressWarnings("unused") // Public API - @Deprecated - public long getDuration() { - return toController.getSettings().getAnimationsDuration(); - } - - /** - * @param duration Animation duration - * @deprecated Use {@link Settings#setAnimationsDuration(long)} instead. - */ - @SuppressWarnings("unused") // Public API - @Deprecated - public void setDuration(long duration) { - toController.getSettings().setAnimationsDuration(duration); - } - - /** * @return Target (to) position as set by {@link #setToState(State, float)}. * Maybe useful to determine real animation position during exit gesture. @@ -430,16 +409,6 @@ public float getPosition() { return position; } - /** - * @return Current position - * @deprecated Use {@link #getPosition()} method instead. - */ - @SuppressWarnings("unused") // Public API - @Deprecated - public float getPositionState() { - return position; - } - /** * @return Whether animator is in leaving state. Means that animation direction is * from final (to) position back to initial (from) position. @@ -785,10 +754,13 @@ private float compareAndSetClipBound(float origBound, int viewPos, int visiblePo } + @SuppressWarnings("deprecation") private static void getDisplaySize(Context context, Rect rect) { WindowManager wm = getActivity(context).getWindowManager(); DisplayMetrics metrics = new DisplayMetrics(); - if (Build.VERSION.SDK_INT >= 17) { + if (Build.VERSION.SDK_INT >= 30) { + context.getDisplay().getRealMetrics(metrics); + } else if (Build.VERSION.SDK_INT >= 17) { wm.getDefaultDisplay().getRealMetrics(metrics); } else { wm.getDefaultDisplay().getMetrics(metrics); diff --git a/library/src/main/java/com/alexvasilkov/gestures/commons/FinderView.java b/library/src/main/java/com/alexvasilkov/gestures/commons/FinderView.java deleted file mode 100644 index 6aab20a..0000000 --- a/library/src/main/java/com/alexvasilkov/gestures/commons/FinderView.java +++ /dev/null @@ -1,189 +0,0 @@ -package com.alexvasilkov.gestures.commons; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffXfermode; -import android.graphics.Rect; -import android.graphics.RectF; -import android.os.Build; -import android.util.AttributeSet; -import android.util.TypedValue; -import android.view.View; - -import androidx.annotation.ColorInt; - -import com.alexvasilkov.gestures.Settings; -import com.alexvasilkov.gestures.internal.UnitsUtils; -import com.alexvasilkov.gestures.utils.GravityUtils; -import com.alexvasilkov.gestures.views.GestureImageView; - -/** - * View to draw movement area above {@link GestureImageView}, useful when implementing cropping. - *
- * To use this view you should set corresponding {@link Settings} with - * {@link #setSettings(Settings)} method. Then whenever movement area is changed - * (see {@link Settings#setMovementArea(int, int)}) you will need to call {@link #update()} - * method to apply changes. - *
- * You may also use rounded corners with {@link #setRounded(boolean)} method, changes between
- * rounded and non-rounded mode can optionally be animated.
- *
- * @deprecated Use {@link CropAreaView} instead.
- */
-@Deprecated
-@SuppressWarnings("unused") // Kept for backward compatibility
-public class FinderView extends View {
-
- public static final int DEFAULT_BACK_COLOR = Color.argb(128, 0, 0, 0);
- public static final int DEFAULT_BORDER_COLOR = Color.WHITE;
- public static final float DEFAULT_BORDER_WIDTH = 2f;
-
- // Temporary objects
- private static final Rect tmpRect = new Rect();
-
- private final RectF rect = new RectF();
- private float rounding = 0f;
-
- private final RectF strokeRect = new RectF();
-
- private final Paint paintStroke = new Paint();
- private final Paint paintClear = new Paint();
-
- private int backColor;
- private Settings settings;
-
- public FinderView(Context context) {
- this(context, null);
- }
-
- public FinderView(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- paintClear.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
- paintClear.setAntiAlias(true);
-
- paintStroke.setStyle(Paint.Style.STROKE);
- paintStroke.setAntiAlias(true);
-
- // Default values
- setBackColor(DEFAULT_BACK_COLOR);
- setBorderColor(DEFAULT_BORDER_COLOR);
- setBorderWidth(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_BORDER_WIDTH);
- }
-
- /**
- * Sets background color. Default value is {@link #DEFAULT_BACK_COLOR}.
- *
- * @param color Background color
- */
- public void setBackColor(@ColorInt int color) {
- backColor = color;
- }
-
- /**
- * Sets borders color. Default value is {@link #DEFAULT_BORDER_COLOR}.
- *
- * @param color Finder area borders color
- */
- public void setBorderColor(@ColorInt int color) {
- paintStroke.setColor(color);
- }
-
- /**
- * Sets borders width in pixels. Default value is {@link #DEFAULT_BORDER_WIDTH} dp.
- *
- * @param width Finder area borders width in pixels
- */
- public void setBorderWidth(float width) {
- paintStroke.setStrokeWidth(width);
- }
-
- /**
- * Sets borders width in particular units. Default value is {@link #DEFAULT_BORDER_WIDTH} dp.
- *
- * @param unit One of {@link TypedValue}.COMPLEX_UNIT_* constants
- * @param width Finder area borders width in given unit
- */
- public void setBorderWidth(int unit, float width) {
- setBorderWidth(UnitsUtils.toPixels(getContext(), unit, width));
- }
-
- /**
- * Sets settings to get movement area from.
- *
- * @param settings Settings of the corresponding {@link GestureImageView}
- */
- public void setSettings(Settings settings) {
- this.settings = settings;
- update();
- }
-
- /**
- * Whether to round bounds' corners.
- *
- * @param rounded Whether finder area should be rounded or not
- */
- public void setRounded(boolean rounded) {
- rounding = rounded ? 1f : 0f;
- update();
- }
-
- /**
- * Applies area size, area position and corners rounding.
- *
- * @param animate This paratemter is ignored
- */
- public void update(boolean animate) {
- update();
- }
-
- /**
- * Updates finder area size and position. Should be called whenever
- * corresponding settings are changed, see {@link #setSettings(Settings)}
- */
- public void update() {
- if (settings != null && getWidth() > 0 && getHeight() > 0) {
- // Updating finder area rectangle
- GravityUtils.getMovementAreaPosition(settings, tmpRect);
- rect.set(tmpRect);
- rect.offset(getPaddingLeft(), getPaddingTop());
-
- // We want to stroke outside of finder rectangle, while by default stroke is centered
- strokeRect.set(rect);
- float halfStroke = 0.5f * paintStroke.getStrokeWidth();
- strokeRect.inset(-halfStroke, -halfStroke);
-
- invalidate();
- }
- }
-
- @Override
- protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
- update();
- }
-
- @SuppressLint("CanvasSize")
- @SuppressWarnings("deprecation")
- @Override
- protected void onDraw(Canvas canvas) {
- float rx = rounding * 0.5f * rect.width();
- float ry = rounding * 0.5f * rect.height();
-
- // Punching hole in background color requires offscreen drawing
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- canvas.saveLayer(0, 0, canvas.getWidth(), canvas.getHeight(), null);
- } else {
- canvas.saveLayer(0, 0, canvas.getWidth(), canvas.getHeight(), null, 0);
- }
- canvas.drawColor(backColor);
- canvas.drawRoundRect(rect, rx, ry, paintClear);
- canvas.restore();
-
- canvas.drawRoundRect(strokeRect, rx, ry, paintStroke);
- }
-
-}
diff --git a/library/src/main/java/com/alexvasilkov/gestures/transition/GestureTransitions.java b/library/src/main/java/com/alexvasilkov/gestures/transition/GestureTransitions.java
index 31c0e61..3e7d4c2 100644
--- a/library/src/main/java/com/alexvasilkov/gestures/transition/GestureTransitions.java
+++ b/library/src/main/java/com/alexvasilkov/gestures/transition/GestureTransitions.java
@@ -22,7 +22,6 @@
public class GestureTransitions
@@ -228,14 +213,4 @@ private static Drawable getDrawable(Context context, @DrawableRes int id) {
}
}
-
- /**
- * @deprecated Use {@link #crop()} method instead.
- */
- @SuppressWarnings("WeakerAccess") // Public API
- @Deprecated
- public interface OnSnapshotLoadedListener {
- void onSnapshotLoaded(@Nullable Bitmap bitmap);
- }
-
}
diff --git a/sample/src/main/java/com/alexvasilkov/gestures/sample/demo/DemoActivity.java b/sample/src/main/java/com/alexvasilkov/gestures/sample/demo/DemoActivity.java
index 6564b51..1d46c3f 100644
--- a/sample/src/main/java/com/alexvasilkov/gestures/sample/demo/DemoActivity.java
+++ b/sample/src/main/java/com/alexvasilkov/gestures/sample/demo/DemoActivity.java
@@ -216,8 +216,12 @@ public void onPageSelected(int position) {
showSystemUi(!isSystemUiShown());
}
});
- getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(
- visibility -> views.pagerToolbar.animate().alpha(isSystemUiShown() ? 1f : 0f));
+
+ DecorUtils.onInsetsChanged(views.pagerToolbar, () -> {
+ float alpha = isSystemUiShown() ? 1f : 0f;
+ views.pagerToolbar.animate().alpha(alpha);
+ views.pagerTitle.animate().alpha(alpha);
+ });
}
/**
@@ -286,6 +290,7 @@ private void applyFullPagerState(float position, boolean isLeaving) {
/**
* Checks if system UI (status bar and navigation bar) is shown or we are in fullscreen mode.
*/
+ @SuppressWarnings("deprecation") // New insets controller API is not back-ported yet
private boolean isSystemUiShown() {
return (getWindow().getDecorView().getSystemUiVisibility()
& View.SYSTEM_UI_FLAG_FULLSCREEN) == 0;
@@ -294,6 +299,7 @@ private boolean isSystemUiShown() {
/**
* Shows or hides system UI (status bar and navigation bar).
*/
+ @SuppressWarnings("deprecation") // New insets controller API is not back-ported yet
private void showSystemUi(boolean show) {
int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
diff --git a/sample/src/main/java/com/alexvasilkov/gestures/sample/demo/utils/DecorUtils.java b/sample/src/main/java/com/alexvasilkov/gestures/sample/demo/utils/DecorUtils.java
index f303bf8..089521a 100644
--- a/sample/src/main/java/com/alexvasilkov/gestures/sample/demo/utils/DecorUtils.java
+++ b/sample/src/main/java/com/alexvasilkov/gestures/sample/demo/utils/DecorUtils.java
@@ -82,6 +82,11 @@ public static void size(View view, int direction) {
});
}
+ public static void onInsetsChanged(View view, Runnable action) {
+ addListener(view, insets -> action.run());
+ }
+
+
private static Rect getExtraInsets(View view, Insets insets, int direction, int tagId) {
Rect oldInsets = (Rect) view.getTag(tagId);
oldInsets = oldInsets == null ? new Rect() : oldInsets;