├── .gitignore ├── LICENSE.txt ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── fivehundredpx │ │ └── blurdemo │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── fivehundredpx │ │ └── blurdemo │ │ └── MainActivity.java │ └── res │ ├── drawable-xxhdpi │ ├── p0.jpg │ ├── p1.jpg │ ├── p2.jpg │ ├── p3.jpg │ ├── p4.jpg │ ├── p5.jpg │ ├── p6.jpg │ ├── p7.jpg │ ├── p8.jpg │ └── p9.jpg │ ├── layout │ └── activity_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ └── values │ ├── strings.xml │ └── styles.xml ├── blurdemo.gif ├── blurringview ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── fivehundredpx │ │ └── blur │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── fivehundredpx │ │ └── android │ │ └── blur │ │ └── BlurringView.java │ └── res │ └── values │ ├── attrs.xml │ ├── defaults.xml │ └── strings.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── releases └── com │ └── fivehundredpx │ └── blurringview │ ├── 1.0.0 │ ├── blurringview-1.0.0.aar │ ├── blurringview-1.0.0.aar.md5 │ ├── blurringview-1.0.0.aar.sha1 │ ├── blurringview-1.0.0.pom │ ├── blurringview-1.0.0.pom.md5 │ └── blurringview-1.0.0.pom.sha1 │ ├── maven-metadata.xml │ ├── maven-metadata.xml.md5 │ └── maven-metadata.xml.sha1 └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | /.idea 6 | .DS_Store 7 | /build 8 | *.iml 9 | /spoon-output 10 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 500px Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## [Currently unmaintained] 2 | 3 | # 500px Android Blurring View 4 | 5 | For more information, please see [our blog post](http://developers.500px.com/2015/03/17/a-blurring-view-for-android.html). 6 | 7 | ## Download 8 | 9 | Define via Gradle: 10 | 11 | ``` groovy 12 | repositories { 13 | maven { url 'https://github.com/500px/500px-android-blur/raw/master/releases/' } 14 | } 15 | 16 | dependencies { 17 | compile 'com.fivehundredpx:blurringview:1.0.0' 18 | } 19 | ``` 20 | 21 | Enable renderscript in your module's `defaultConfig`: 22 | ```groovy 23 | android { 24 | defaultConfig { 25 | 26 | renderscriptTargetApi 21 27 | renderscriptSupportModeEnabled true 28 | ... 29 | } 30 | } 31 | 32 | ``` 33 | 34 | 35 | ## Usage 36 | 37 | First, give the blurring view a reference to the view to be blurred: 38 | 39 | ``` java 40 | blurringView.setBlurredView(blurredView); 41 | ``` 42 | 43 | and then whenever the blurred view changes, invalidate the blurring view: 44 | 45 | ``` java 46 | blurringView.invalidate(); 47 | ``` 48 | 49 | ## Demo 50 | 51 | ![500px Blurring View Demo](blurdemo.gif "500px Blurring View Demo") 52 | 53 | ## License 54 | 55 | This project is licensed under the terms of [the MIT license](LICENSE.txt). 56 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion '24.0.2' 6 | 7 | defaultConfig { 8 | applicationId "com.fivehundredpx.blurringviewsample" 9 | minSdkVersion 15 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | renderscriptTargetApi 21 14 | renderscriptSupportModeEnabled true 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | compile project(':blurringview') 26 | compile fileTree(include: ['*.jar'], dir: 'libs') 27 | compile 'com.android.support:appcompat-v7:23.1.1' 28 | compile 'com.android.support:support-v4:23.1.1' 29 | } 30 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Developer/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/fivehundredpx/blurdemo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.fivehundredpx.blurdemo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/fivehundredpx/blurdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.fivehundredpx.blurdemo; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorSet; 5 | import android.animation.ObjectAnimator; 6 | import android.animation.ValueAnimator; 7 | import android.os.Bundle; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.view.View; 10 | import android.view.animation.OvershootInterpolator; 11 | import android.widget.ImageView; 12 | 13 | import com.fivehundredpx.android.blur.BlurringView; 14 | 15 | import java.util.Random; 16 | 17 | /** 18 | * Demonstrates the use of the blurring view. 19 | */ 20 | public class MainActivity extends AppCompatActivity { 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_main); 26 | mBlurringView = (BlurringView) findViewById(R.id.blurring_view); 27 | View blurredView = findViewById(R.id.blurred_view); 28 | 29 | // Give the blurring view a reference to the blurred view. 30 | mBlurringView.setBlurredView(blurredView); 31 | 32 | mImageViews[0] = (ImageView) findViewById(R.id.image0); 33 | mImageViews[1] = (ImageView) findViewById(R.id.image1); 34 | mImageViews[2] = (ImageView) findViewById(R.id.image2); 35 | mImageViews[3] = (ImageView) findViewById(R.id.image3); 36 | mImageViews[4] = (ImageView) findViewById(R.id.image4); 37 | mImageViews[5] = (ImageView) findViewById(R.id.image5); 38 | mImageViews[6] = (ImageView) findViewById(R.id.image6); 39 | mImageViews[7] = (ImageView) findViewById(R.id.image7); 40 | mImageViews[8] = (ImageView) findViewById(R.id.image8); 41 | } 42 | 43 | public void shuffle(View view) { 44 | 45 | // Randomly pick a different start in the array of available images. 46 | int newStartIndex; 47 | do { 48 | newStartIndex = IMAGE_IDS[mRandom.nextInt(IMAGE_IDS.length)]; 49 | } while (newStartIndex == mStartIndex); 50 | mStartIndex = newStartIndex; 51 | 52 | // Update the images for the image views contained in the blurred view. 53 | for (int i = 0; i < mImageViews.length; i++) { 54 | int drawableId = IMAGE_IDS[(mStartIndex + i) % IMAGE_IDS.length]; 55 | mImageViews[i].setImageDrawable(getResources().getDrawable(drawableId)); 56 | } 57 | 58 | // Invalidates the blurring view when the content of the blurred view changes. 59 | mBlurringView.invalidate(); 60 | } 61 | 62 | private ValueAnimator.AnimatorUpdateListener listener = new ValueAnimator.AnimatorUpdateListener() { 63 | @Override 64 | public void onAnimationUpdate(ValueAnimator animation) { 65 | mBlurringView.invalidate(); 66 | } 67 | }; 68 | 69 | public void shift(View view) { 70 | if (!mShifted) { 71 | for (ImageView imageView : mImageViews) { 72 | ObjectAnimator tx = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_X, (mRandom.nextFloat() - 0.5f) * 500); 73 | tx.addUpdateListener(listener); 74 | ObjectAnimator ty = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_Y, (mRandom.nextFloat() - 0.5f) * 500); 75 | ty.addUpdateListener(listener); 76 | AnimatorSet set = new AnimatorSet(); 77 | set.playTogether(tx, ty); 78 | set.setDuration(3000); 79 | set.setInterpolator(new OvershootInterpolator()); 80 | set.addListener(new AnimationEndListener(imageView)); 81 | set.start(); 82 | } 83 | mShifted = true; 84 | } else { 85 | for (ImageView imageView : mImageViews) { 86 | ObjectAnimator tx = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_X, 0); 87 | tx.addUpdateListener(listener); 88 | ObjectAnimator ty = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_Y, 0); 89 | ty.addUpdateListener(listener); 90 | AnimatorSet set = new AnimatorSet(); 91 | set.playTogether(tx, ty); 92 | set.setDuration(3000); 93 | set.setInterpolator(new OvershootInterpolator()); 94 | set.addListener(new AnimationEndListener(imageView)); 95 | set.start(); 96 | } 97 | mShifted = false; 98 | } 99 | } 100 | 101 | private BlurringView mBlurringView; 102 | 103 | private static final int[] IMAGE_IDS = { 104 | R.drawable.p0, R.drawable.p1, R.drawable.p2, R.drawable.p3, R.drawable.p4, 105 | R.drawable.p5, R.drawable.p6, R.drawable.p7, R.drawable.p8, R.drawable.p9 106 | }; 107 | 108 | private ImageView[] mImageViews = new ImageView[9]; 109 | private int mStartIndex; 110 | 111 | private Random mRandom = new Random(); 112 | 113 | private boolean mShifted; 114 | 115 | private static class AnimationEndListener implements Animator.AnimatorListener { 116 | 117 | View mView; 118 | 119 | public AnimationEndListener(View v) { 120 | mView = v; 121 | } 122 | 123 | @Override 124 | public void onAnimationStart(Animator animation) { 125 | mView.setLayerType(View.LAYER_TYPE_HARDWARE, null); 126 | } 127 | 128 | @Override 129 | public void onAnimationEnd(Animator animation) { 130 | mView.setLayerType(View.LAYER_TYPE_NONE, null); 131 | } 132 | 133 | @Override 134 | public void onAnimationCancel(Animator animation) { 135 | mView.setLayerType(View.LAYER_TYPE_NONE, null); 136 | } 137 | 138 | @Override 139 | public void onAnimationRepeat(Animator animation) {} 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/p0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/500px/500px-android-blur/01bd56f4d66ef48585041ceafe5aa4eb8248e409/app/src/main/res/drawable-xxhdpi/p0.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/p1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/500px/500px-android-blur/01bd56f4d66ef48585041ceafe5aa4eb8248e409/app/src/main/res/drawable-xxhdpi/p1.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/p2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/500px/500px-android-blur/01bd56f4d66ef48585041ceafe5aa4eb8248e409/app/src/main/res/drawable-xxhdpi/p2.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/p3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/500px/500px-android-blur/01bd56f4d66ef48585041ceafe5aa4eb8248e409/app/src/main/res/drawable-xxhdpi/p3.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/p4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/500px/500px-android-blur/01bd56f4d66ef48585041ceafe5aa4eb8248e409/app/src/main/res/drawable-xxhdpi/p4.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/p5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/500px/500px-android-blur/01bd56f4d66ef48585041ceafe5aa4eb8248e409/app/src/main/res/drawable-xxhdpi/p5.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/p6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/500px/500px-android-blur/01bd56f4d66ef48585041ceafe5aa4eb8248e409/app/src/main/res/drawable-xxhdpi/p6.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/p7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/500px/500px-android-blur/01bd56f4d66ef48585041ceafe5aa4eb8248e409/app/src/main/res/drawable-xxhdpi/p7.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/p8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/500px/500px-android-blur/01bd56f4d66ef48585041ceafe5aa4eb8248e409/app/src/main/res/drawable-xxhdpi/p8.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/p9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/500px/500px-android-blur/01bd56f4d66ef48585041ceafe5aa4eb8248e409/app/src/main/res/drawable-xxhdpi/p9.jpg -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | 14 | 21 | 22 | 29 | 30 | 38 | 39 | 47 | 48 | 56 | 57 | 65 | 66 | 74 | 75 | 83 | 84 | 92 | 93 | 101 | 102 | 103 | 104 | 105 | 106 | 114 | 115 |