From 7f47d5c0c32a7908e1a8d4c8ce509218cd14d197 Mon Sep 17 00:00:00 2001 From: zagum Date: Mon, 13 Aug 2018 17:27:15 +0300 Subject: [PATCH] - fixed clipPath deprecation on android P - updated versions --- build.gradle | 6 +++--- switchicon-sample/build.gradle | 4 ++-- switchicon/build.gradle | 12 ++++++------ .../com/github/zagum/switchicon/SwitchIconView.java | 6 +++++- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index ff18da2..bf32549 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.0' + classpath 'com.android.tools.build:gradle:3.1.4' } } @@ -17,11 +17,11 @@ allprojects { ext { compileSdkVersion = 27 - buildToolsVersion = '27.0.0' + buildToolsVersion = '27.0.3' minSdkVersion = 15 targetSdkVersion = compileSdkVersion - supportLibVersion = '27.1.0' + supportLibVersion = '27.1.1' } task clean(type: Delete) { diff --git a/switchicon-sample/build.gradle b/switchicon-sample/build.gradle index 50da031..b561442 100644 --- a/switchicon-sample/build.gradle +++ b/switchicon-sample/build.gradle @@ -1,8 +1,8 @@ apply plugin: 'com.android.application' dependencies { - compile project(":switchicon") - compile "com.android.support:appcompat-v7:$supportLibVersion" + implementation project(":switchicon") + implementation "com.android.support:appcompat-v7:$supportLibVersion" } android { diff --git a/switchicon/build.gradle b/switchicon/build.gradle index 9548ef6..7536eae 100644 --- a/switchicon/build.gradle +++ b/switchicon/build.gradle @@ -1,14 +1,14 @@ apply plugin: 'com.android.library' dependencies { - compile "com.android.support:appcompat-v7:$supportLibVersion" + implementation "com.android.support:appcompat-v7:$supportLibVersion" } android { - compileSdkVersion rootProject.ext.compileSdkVersion - buildToolsVersion rootProject.ext.buildToolsVersion + compileSdkVersion rootProject.ext.compileSdkVersion + buildToolsVersion rootProject.ext.buildToolsVersion - defaultConfig { - minSdkVersion rootProject.ext.minSdkVersion - } + defaultConfig { + minSdkVersion rootProject.ext.minSdkVersion + } } diff --git a/switchicon/src/main/java/com/github/zagum/switchicon/SwitchIconView.java b/switchicon/src/main/java/com/github/zagum/switchicon/SwitchIconView.java index 0d932de..0b7ef60 100644 --- a/switchicon/src/main/java/com/github/zagum/switchicon/SwitchIconView.java +++ b/switchicon/src/main/java/com/github/zagum/switchicon/SwitchIconView.java @@ -208,7 +208,11 @@ protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) protected void onDraw(Canvas canvas) { if (!noDash) { drawDash(canvas); - canvas.clipPath(clipPath, Region.Op.XOR); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + canvas.clipOutPath(clipPath); + } else { + canvas.clipPath(clipPath, Region.Op.XOR); + } } super.onDraw(canvas); }