From afce3ead78fedaf4112317a2d7aa608c6362d9a4 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Fri, 13 Jan 2017 13:28:17 +0500 Subject: [PATCH] supporting sdk from 14 --- .../arcnavigationview/ArcNavigationView.java | 32 +++++++++++-------- build.gradle | 4 +-- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/arcnavigationview/src/main/java/com/rom4ek/arcnavigationview/ArcNavigationView.java b/arcnavigationview/src/main/java/com/rom4ek/arcnavigationview/ArcNavigationView.java index 9bab62b..50228d9 100644 --- a/arcnavigationview/src/main/java/com/rom4ek/arcnavigationview/ArcNavigationView.java +++ b/arcnavigationview/src/main/java/com/rom4ek/arcnavigationview/ArcNavigationView.java @@ -1,5 +1,6 @@ package com.rom4ek.arcnavigationview; +import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; @@ -64,6 +65,7 @@ public void init(Context context, AttributeSet attrs) { THRESHOLD = Math.round(ArcViewSettings.dpToPx(getContext(), 15)); //some threshold for child views while remeasuring them } + @SuppressLint("RtlHardcoded") private Path createClipPath() { final Path path = new Path(); arcPath = new Path(); @@ -154,20 +156,21 @@ private void calculateLayoutAndChildren() { width = getMeasuredWidth(); if (width > 0 && height > 0) { clipPath = createClipPath(); - ViewCompat.setElevation(this, settings.getElevation()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - setOutlineProvider(new ViewOutlineProvider() { - @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) - @Override - public void getOutline(View view, Outline outline) { - if (clipPath.isConvex()) { - outline.setConvexPath(clipPath); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { + ViewCompat.setElevation(this, settings.getElevation()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + setOutlineProvider(new ViewOutlineProvider() { + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + @Override + public void getOutline(View view, Outline outline) { + if (clipPath.isConvex()) { + outline.setConvexPath(clipPath); + } } - } - }); + }); + } } -// if (settings.isCropInside()) { final int count = getChildCount(); for (int i = 0; i < count; i++) { final View v = getChildAt(i); @@ -178,8 +181,9 @@ public void getOutline(View view, Outline outline) { } else { v.setBackgroundDrawable(settings.getBackgroundDrawable()); } - ViewCompat.setElevation(v, settings.getElevation()); - + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { + ViewCompat.setElevation(v, settings.getElevation()); + } //TODO: adjusting child views to new width in their rightmost/leftmost points related to path // adjustChildViews((ViewGroup) v); } @@ -187,6 +191,8 @@ public void getOutline(View view, Outline outline) { } } + @SuppressWarnings("unused") + @SuppressLint("RtlHardcoded") private void adjustChildViews(ViewGroup container) { final int containerChildCount = container.getChildCount(); PathMeasure pathMeasure = new PathMeasure(arcPath, false); diff --git a/build.gradle b/build.gradle index 3cdd321..676e994 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ allprojects { ext { sdk = 25 buildTools = "25.0.1" - minSdk = 16 - libraryVersion = "1.0.1" + minSdk = 14 + libraryVersion = "1.0.2" supportVersion = "25.1.0" }