From 3b9ca0ea1df2cfbce6fac6dc601bcc0782de81cb Mon Sep 17 00:00:00 2001 From: Baptiste Date: Wed, 25 Mar 2015 12:12:13 +0100 Subject: [PATCH 1/6] Upgrade to last build tool --- build.gradle | 2 +- lib/build.gradle | 10 +++++----- sample/build.gradle | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index 6356aab..d3ff69d 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.0.0' + classpath 'com.android.tools.build:gradle:1.1.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/lib/build.gradle b/lib/build.gradle index 303e2cd..73ff07f 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -5,12 +5,12 @@ apply from: '../config/quality.gradle' def version = '1.1.0' android { - compileSdkVersion 21 - buildToolsVersion "21.1.2" + compileSdkVersion 22 + buildToolsVersion "22" defaultConfig { - minSdkVersion 14 - targetSdkVersion 21 + minSdkVersion 9 + targetSdkVersion 22 versionCode 5 versionName "1.4" } @@ -24,7 +24,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:21.0.+' + compile 'com.android.support:appcompat-v7:22.0.+' } uploadArchives { diff --git a/sample/build.gradle b/sample/build.gradle index 5ef96a5..b9bd34f 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 21 - buildToolsVersion "21.1.2" + compileSdkVersion 22 + buildToolsVersion "22" defaultConfig { applicationId "fr.tvbarthel.lib.blurdialogfragment.sample" - minSdkVersion 14 - targetSdkVersion 21 + minSdkVersion 9 + targetSdkVersion 22 versionCode 5 versionName "1.4" } @@ -21,7 +21,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:21.0.+' - compile 'com.android.support:cardview-v7:21.0.+' + compile 'com.android.support:appcompat-v7:22.0.+' + compile 'com.android.support:cardview-v7:22.0.+' compile project (":lib") } From 6706196210148df92b29dfd5b0a7cb0c38124fd9 Mon Sep 17 00:00:00 2001 From: Baptiste Date: Wed, 25 Mar 2015 12:13:14 +0100 Subject: [PATCH 2/6] Change to use the Support V8 library for RenderScript --- lib/build.gradle | 2 ++ .../tvbarthel/lib/blurdialogfragment/FastBlurHelper.java | 8 ++++---- sample/build.gradle | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/build.gradle b/lib/build.gradle index 73ff07f..fd20931 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -13,6 +13,8 @@ android { targetSdkVersion 22 versionCode 5 versionName "1.4" + renderscriptTargetApi 22 + renderscriptSupportModeEnabled true } buildTypes { release { diff --git a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/FastBlurHelper.java b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/FastBlurHelper.java index ac15d38..f533e95 100644 --- a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/FastBlurHelper.java +++ b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/FastBlurHelper.java @@ -4,10 +4,10 @@ import android.content.Context; import android.graphics.Bitmap; import android.os.Build; -import android.renderscript.Allocation; -import android.renderscript.Element; -import android.renderscript.RenderScript; -import android.renderscript.ScriptIntrinsicBlur; +import android.support.v8.renderscript.Allocation; +import android.support.v8.renderscript.Element; +import android.support.v8.renderscript.RenderScript; +import android.support.v8.renderscript.ScriptIntrinsicBlur; /** * Helper used to apply Fast blur algorithm on bitmap. diff --git a/sample/build.gradle b/sample/build.gradle index b9bd34f..0266eb5 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -10,6 +10,8 @@ android { targetSdkVersion 22 versionCode 5 versionName "1.4" + renderscriptTargetApi 22 + renderscriptSupportModeEnabled true } buildTypes { release { From 463b808a3d7fdf748126dcd5ad550d507b9f8896 Mon Sep 17 00:00:00 2001 From: Baptiste Date: Wed, 25 Mar 2015 12:17:10 +0100 Subject: [PATCH 3/6] Add support of min API 9 --- .../lib/blurdialogfragment/BlurDialogEngine.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java index 868ee86..fedbe47 100644 --- a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java +++ b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java @@ -162,7 +162,8 @@ public void onDismiss() { //remove blurred background and clear memory, could be null if dismissed before blur effect //processing ends if (mBlurredBackgroundView != null) { - mBlurredBackgroundView + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) + mBlurredBackgroundView .animate() .alpha(0f) .setDuration(mAnimationDuration) @@ -180,6 +181,8 @@ public void onAnimationCancel(Animator animation) { removeBlurredView(); } }).start(); + else + removeBlurredView(); } //cancel async task @@ -549,13 +552,14 @@ protected Void doInBackground(Void... params) { @Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); - - mBlurredBackgroundView.setAlpha(0f); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) + mBlurredBackgroundView.setAlpha(0f); mHoldingActivity.getWindow().addContentView( mBlurredBackgroundView, mBlurredBackgroundLayoutParams ); - mBlurredBackgroundView + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) + mBlurredBackgroundView .animate() .alpha(1f) .setDuration(mAnimationDuration) From 99a9c019356980e8beb9fccc9866614f2e889e87 Mon Sep 17 00:00:00 2001 From: Ligol Date: Wed, 25 Mar 2015 12:47:38 +0100 Subject: [PATCH 4/6] Update README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index cc50ba0..fea1f2b 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,18 @@ public class SampleDialogFragment extends SupportBlurDialogFragment { } ``` +Use RenderScript in Your Project +====== + +Simply add this line to your build.gradle + +``` + defaultConfig { + renderscriptTargetApi 22 + renderscriptSupportModeEnabled true + } +``` + Customize your blurring effect ====== ```java From 5fe69030931fcf67bf6e9ddb321845b568f4b369 Mon Sep 17 00:00:00 2001 From: Ligol Date: Wed, 25 Mar 2015 12:50:18 +0100 Subject: [PATCH 5/6] Update README.md --- README.md | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index fea1f2b..f6800d8 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ This project allows to display DialogFragment with a burring effect behind. The * [Sample app](#sample-app) * [Example](#example) * [Dependency](#dependency) +* [Use RenderScript in Your Project] (#use-renderscript-in-your-project) * [Simple usage using inheritance](#simple-usage-using-inheritance) * [Customize your blurring effect](#customize-your-blurring-effect) * [Avoiding inheritance](#avoiding-inheritance) @@ -37,6 +38,20 @@ Dependency ======= In order to use this library, just add a new gradle dependency : [BlurDialogFragment dependency](https://github.com/tvbarthel/maven#usage) +Use RenderScript in Your Project +====== + +Simply add this line to your build.gradle + +``` + defaultConfig { + ... + renderscriptTargetApi 22 + renderscriptSupportModeEnabled true + ... + } +``` + Simple usage using inheritance ======= If you are using **android.app.DialogFragment** : extends **BlurDialogFragment**. @@ -67,18 +82,6 @@ public class SampleDialogFragment extends SupportBlurDialogFragment { } ``` -Use RenderScript in Your Project -====== - -Simply add this line to your build.gradle - -``` - defaultConfig { - renderscriptTargetApi 22 - renderscriptSupportModeEnabled true - } -``` - Customize your blurring effect ====== ```java From 1db598efd5e2175c3173278aa6cab1b77f155f3f Mon Sep 17 00:00:00 2001 From: Baptiste Date: Thu, 26 Mar 2015 12:50:50 +0100 Subject: [PATCH 6/6] Commit change to respect PMD and Ignore Lint issue du to TargetApi support checked by If conditions --- lib/build.gradle | 2 +- .../blurdialogfragment/BlurDialogEngine.java | 66 ++++++++++--------- sample/build.gradle | 2 +- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/lib/build.gradle b/lib/build.gradle index fd20931..ae52eab 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -6,7 +6,7 @@ def version = '1.1.0' android { compileSdkVersion 22 - buildToolsVersion "22" + buildToolsVersion "22.0.1" defaultConfig { minSdkVersion 9 diff --git a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java index fedbe47..cf0e9d0 100644 --- a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java +++ b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java @@ -2,6 +2,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; import android.content.res.Resources; @@ -158,31 +159,33 @@ public void onResume(boolean retainedInstance) { /** * Must be linked to the original lifecycle. */ + @SuppressLint("NewApi") public void onDismiss() { //remove blurred background and clear memory, could be null if dismissed before blur effect //processing ends if (mBlurredBackgroundView != null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { mBlurredBackgroundView - .animate() - .alpha(0f) - .setDuration(mAnimationDuration) - .setInterpolator(new AccelerateInterpolator()) - .setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); - removeBlurredView(); - } - - @Override - public void onAnimationCancel(Animator animation) { - super.onAnimationCancel(animation); - removeBlurredView(); - } - }).start(); - else + .animate() + .alpha(0f) + .setDuration(mAnimationDuration) + .setInterpolator(new AccelerateInterpolator()) + .setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + removeBlurredView(); + } + + @Override + public void onAnimationCancel(Animator animation) { + super.onAnimationCancel(animation); + removeBlurredView(); + } + }).start(); + } else { removeBlurredView(); + } } //cancel async task @@ -550,22 +553,25 @@ protected Void doInBackground(Void... params) { } @Override + @SuppressLint("NewApi") protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { mBlurredBackgroundView.setAlpha(0f); - mHoldingActivity.getWindow().addContentView( - mBlurredBackgroundView, - mBlurredBackgroundLayoutParams - ); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) + mHoldingActivity.getWindow().addContentView( + mBlurredBackgroundView, + mBlurredBackgroundLayoutParams + ); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { mBlurredBackgroundView - .animate() - .alpha(1f) - .setDuration(mAnimationDuration) - .setInterpolator(new LinearInterpolator()) - .start(); + .animate() + .alpha(1f) + .setDuration(mAnimationDuration) + .setInterpolator(new LinearInterpolator()) + .start(); + } mBackgroundView = null; mBackground = null; } diff --git a/sample/build.gradle b/sample/build.gradle index 0266eb5..a16bac9 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 22 - buildToolsVersion "22" + buildToolsVersion "22.0.1" defaultConfig { applicationId "fr.tvbarthel.lib.blurdialogfragment.sample"