Coder Social home page Coder Social logo

blurbehind's Introduction

##[DEPRECATED]

BlurBehind Build Status

Easily have blurred and transparent background effect on your Android views.

Before API level 14 there was a Window flag called FLAG_BLUR_BEHIND. It was used for "blurring everything behind a window" and is no longer supported by Android.

BlurBehind provides an easy way to have that effect, with customization, for your window without API level restrictions.

Usage

Invoke BlurBehind.getInstance().execute() method with caller Activity and the actual work as a Runnable.

dummyButton.setOnClickListener(new View.OnClickListener() {
	@Override
	public void onClick(View v) {

		BlurBehind.getInstance().execute(MainActivity.this, new OnBlurCompleteListener() {
            @Override
            public void onBlurComplete() {
                Intent intent = new Intent(MainActivity.this, BlurredActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

                startActivity(intent);
            }
        });
	}
});

And use BlurBehind.getInstance().setBackground(Activity a) method on new View, which is an Activity in sample project:

BlurBehind.getInstance().setBackground(this);

You can optionally set alpha and filterColor:

BlurBehind.getInstance()
    .withAlpha(80)
    .withFilterColor(Color.parseColor("#0075c0")) //or Color.RED
    .setBackground(this);

Which will result in this:

Dependency

  • Run gradle install on blur-behind library project.
  • In your build.gradle:
repositories {
    mavenCentral()
    mavenLocal() //Add local m2 repository of yours
}
dependencies {
    compile 'com.faradaj:blur-behind:[LATEST_RELEASE_VERSION]'
}

or

  • In your pom.xml:
<dependency>
  <groupId>com.faradaj</groupId>
  <artifactId>blur-behind</artifactId>
  <version>[LATEST_RELEASE_VERSION]</version>
</dependency>

or you can clone and add blur-behind as a library project to yours.

Credits

License

The MIT License (MIT)

Copyright (c) 2014 Gokberk Ergun

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

blurbehind's People

Contributors

faradaj avatar kishanjvaghela avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blurbehind's Issues

Bitmap not update

Hi, your library is awesome but i got problem.

the bitmap is not update after first time new activity launched.

eg. First time activity launched, background image set correctly. But after that (2nd, 3rd and so on... ) background image is the same as first one.

I've look into library and try to play with your decorView

        decorView = activity.getWindow().getDecorView();
        decorView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
        decorView.setDrawingCacheEnabled(true);
        decorView.buildDrawingCache();
        image = Bitmap.createBitmap(decorView.getDrawingCache());
        decorView.destroyDrawingCache();
        decorView.setDrawingCacheEnabled(false);

no luck...

Do you know how to fix this?

By the way, I forgot to mention that the i use recyclerview for the original activity. Is this related? Is it a problem with recyclerview?

Canvas: trying to use a recycled bitmap android.graphics.Bitmap

Hi there ,
This is cool work and i just copy blur and blurBehind 2 class is work well but i got this issue when i test it .

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:848)
Caused by: java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@432c02b8
at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1084)
at android.graphics.Canvas.drawBitmap(Canvas.java:1170)
at android.graphics.Bitmap.createBitmap(Bitmap.java:745)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:602)
at com.xxx.utils.v.doInBackground(BlurBehind.java:71)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:848)


look like cause by bitmap recycle .Do you have any idea ? Thanks .

blurbehind not working for fragment

I used your blurbehind to my fragment class but it is not showing any thing
Code:
BlurBehind.getInstance()
.withAlpha(80)
.withFilterColor(Color.parseColor("#0075c0"))
.setBackground(getActivity());
plz help me out

You're just kidding me!!!!Waste things!!!!

Do you know "FLAG_BLUR_BEHIND"? You know???? You're just implementing a simple demo.However,you made a lib to show your blur! It must not work well on SurfaceView or WebView! Do you dare to have a try?Don't publish an article with a big face!!Don't publish an article with a big face!!Don't publish an article with a big face!!Don't publish an article with a big face!!Don't publish an article with a big face!!

Use RenderScript compat library

Why not to use RenderScript compatibility library instead of an algorithm for API's lower than 16 and the regular RenderScript for 16 and up? It's not only more performant for older devices but also reduces the complexity of the Blur class since you don't have to have different blur methods for different API's.

Enable the RenderScript compat by adding the below to gradle.build file

defaultConfig {
    renderscriptTargetApi 19
    renderscriptSupportMode true
}

Can't add the library in gradle

When I try to add this library like this,

repositories {
mavenCentral()
    mavenLocal()
}

dependencies {
    compile 'com.faradaj:blur-behind:1.1.0'
}

"Dependency 'com.faradaj:blur-behind:1.1.0' not found"

How can i solve it? 😟

p.s Run 'gradle install' on 'blur-behind' library project. <= What does it mean

Running an intent from a notification

If I have a main activity called A and I put .execute code inside it to go to another activity B where blurring happens, how can I have the same blurred background if I create activity B from a notification?

Thanks,

Deprecated

Can you explain, why it's deprecated? Provide something info how to implement same behavior with another libraries/default SDK, please

Blurring particular layout

Rather than complete activity I just want to blur particular layout?That way the layout underneath appear to be out of focus.How can i do that?

Distribute the library via JCenter

Gradle features great dependency management that is intended to work with remote repositories.
Distributing your library via JCenter will make the consumption of your library much easier and will increase the adoption.

Currently developers don't know how to consume your library (see example).

Publishing to JCenter is very simple and can be fully automated using the Gradle Bintray plugin.

Not blurring over Map area

I've tested the library with an Activity that has a Relative Layout and some more elements and it works just fine and it blurs well and just like the demo on the main page.

However when I try the exact same code for another Activity that has a Google Maps map fragment and some other elements on the top and bottom of that Activity, all those elements get blurred except for the map. Here is the screenshot of this issue and I find it very strange, I even just tried to put the map inside another Relative Layout just to see, it didn't make any difference.

Wrong blurring activity: http://i.imgur.com/LyXNGTU.png?1

Correctly blurring Activity: http://i.imgur.com/1ohw0RS.png?1

Any ideas @faradaj or @jbaruch ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.