<commit_before>BlurDialogFragment
==================

This project allows to display DialogFragment with a burring effect behind. The blurring part is achieved through FastBlur algorithm thanks to the impressive work of <NAME> (cf [Special Thanks](https://github.com/tvbarthel/BlurDialogFragment/#special-thanks-to-)). 

[![Maven Central](http://img.shields.io/maven-central/v/fr.tvbarthel.blurdialogfragment/lib.svg)](http://search.maven.org/#search%7Cga%7C1%7Cblurdialogfragment)

[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-BlurDialogFragment-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1064)

* [Sample app](#sample-app)
* [Gradle dependency](#gradle-dependency)
* [Example](#example)
* [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)
* [Benchmark](#benchmark)
* [Known bugs](#known-bugs)
* [RenderScript or not RenderScript](#renderscript-or-not-renderscript)
* [Change logs](#change-logs)
* [Contributing](#contributing)
* [Credits](#credits)
* [License](#license)
* [Special Thanks](#special-thanks-to-)

Sample app
=======
[Download the sample app on the Google Play store.](https://play.google.com/store/apps/details?id=fr.tvbarthel.lib.blurdialogfragment.sample)

Gradle dependency
=======
Since the library is promoted on maven central, just add a new gradle dependency :

```groovy
    compile 'fr.tvbarthel.blurdialogfragment:lib:2.2.0'
```

Don't forget to check the [Use RenderScript in Your Project] (#use-renderscript-in-your-project) if you're planning to use it.

Example
=======
Activity with action bar [blurRadius 4, downScaleFactor 5.0] : 
![action bar blur](/static/action_bar_blur.png)

Fullscreen activity [blurRadius 2, downScaleFactor 8.0] : 
![full screen blur](/static/full_screen_blur.png)

Use RenderScript in Your Project
======

Simply add this line to your build.gradle

```groovy
defaultConfig {
    ...
    renderscriptTargetApi 22
    renderscriptSupportModeEnabled true
    ...
}
```

Simple usage using inheritance
=======
If you are using **android.app.DialogFragment** : extends **BlurDialogFragment**. 
Play with the blur radius and the down scale factor to obtain the perfect blur.

Don't forget to enable log if you want to keep on eye the performance.

```java
/**
 * Simple fragment with blurring effect behind.
 */
public class SampleDialogFragment extends BlurDialogFragment {

}
```

If you are using **android.support.v4.app.DialogFragment** : extends **SupportBlurDialogFragment**. 
Play with the blur radius and the down scale factor to obtain the perfect blur.

Don't forget to enable log in order to keep on eye the performance.

```java
/**
 * Simple fragment with blurring effect behind.
 */
public class SampleDialogFragment extends SupportBlurDialogFragment {

}
```

Customize your blurring effect
======
```java

/**
 * Simple fragment with a customized blurring effect.
 */
public class SampleDialogFragment extends BlurDialogFragment {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        ...
    }
    
    @Override
    protected float getDownScaleFactor() {
        // Allow to customize the down scale factor.
        return 5.0;
    }

    @Override
    protected int getBlurRadius() {
        // Allow to customize the blur radius factor.
        return 7;
    }
    
    @Override
    protected boolean isActionBarBlurred() {
        // Enable or disable the blur effect on the action bar.
        // Disabled by default.
        return true;
    }
    
    @Override
    protected boolean isDimmingEnable() {
        // Enable or disable the dimming effect.
        // Disabled by default.
        return true;
    }

    @Override
    protected boolean isRenderScriptEnable() {
        // Enable or disable the use of RenderScript for blurring effect
        // Disabled by default.
        return true;
    }
    
    @Override
    protected boolean isDebugEnable() {
        // Enable or disable debug mode.
        // False by default.
        return true;
    }
    ...
```

Default values are set to : 
 ```java
/**
 * Since image is going to be blurred, we don't care about resolution.
 * Down scale factor to reduce blurring time and memory allocation.
 */
static final float DEFAULT_BLUR_DOWN_SCALE_FACTOR = 4.0f;

/**
 * Radius used to blur the background
 */
static final int DEFAULT_BLUR_RADIUS = 8;

/**
 * Default dimming policy.
 */
static final boolean DEFAULT_DIMMING_POLICY = false;

/**
 * Default debug policy.
 */
static final boolean DEFAULT_DEBUG_POLICY = false;

/**
 * Default action bar blurred policy.
 */
static final boolean DEFAULT_ACTION_BAR_BLUR = false;

/**
 * Default use of RenderScript.
 */
static final boolean DEFAULT_USE_RENDERSCRIPT = false;
```

Avoiding inheritance
=======

If you want to **avoid inheritance**, use directly the **BlurEngine**. 
Don't forget to link the engine to the lifecycle of your DialogFragment.

```java
/**
 * Your blur fragment directly using BlurEngine.
 */
public class SampleDialogFragment extends MyCustomDialogFragment {

     /**
     * Engine used to blur.
     */
    private BlurDialogEngine mBlurEngine;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        mBlurEngine = new BlurDialogEngine(getActivity());
        mBlurEngine.debug(mDebugEnable);
        mBlurEngine.setBlurRadius(8);
        mBlurEngine.setDownScaleFactor(8f);
        mBlurEngine.debug(true);
        mBlurEngine.setBlurActionBar(true);
        mBlurEngine.setUseRenderScript(true);
    }
    
    @Override
    public void onResume() {
        super.onResume();
        mBlurEngine.onResume(getRetainInstance());
    }
    
     @Override
    public void onDismiss(DialogInterface dialog) {
        super.onDismiss(dialog);
        mBlurEngine.onDismiss();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mBlurEngine.onDestroy();<commit_msg>Fix typo README.md<commit_after>BlurDialogFragment
==================

This project allows to display DialogFragment with a burring effect behind. The blurring part is achieved through FastBlur algorithm thanks to the impressive work of <NAME> (cf [Special Thanks](https://github.com/tvbarthel/BlurDialogFragment/#special-thanks-to-)). 

[![Maven Central](http://img.shields.io/maven-central/v/fr.tvbarthel.blurdialogfragment/lib.svg)](http://search.maven.org/#search%7Cga%7C1%7Cblurdialogfragment)

[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-BlurDialogFragment-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1064)

* [Sample app](#sample-app)
* [Gradle dependency](#gradle-dependency)
* [Example](#example)
* [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)
* [Benchmark](#benchmark)
* [Known bugs](#known-bugs)
* [RenderScript or not RenderScript](#renderscript-or-not-renderscript)
* [Change logs](#change-logs)
* [Contributing](#contributing)
* [Credits](#credits)
* [License](#license)
* [Special Thanks](#special-thanks-to-)

Sample app
=======
[Download the sample app on the Google Play store.](https://play.google.com/store/apps/details?id=fr.tvbarthel.lib.blurdialogfragment.sample)

Gradle dependency
=======
Since the library is promoted on maven central, just add a new gradle dependency :

```groovy
    compile 'fr.tvbarthel.blurdialogfragment:lib:2.2.0'
```

Don't forget to check the [Use RenderScript in Your Project] (#use-renderscript-in-your-project) if you're planning to use it.

Example
=======
Activity with action bar [blurRadius 4, downScaleFactor 5.0] : 
![action bar blur](/static/action_bar_blur.png)

Fullscreen activity [blurRadius 2, downScaleFactor 8.0] : 
![full screen blur](/static/full_screen_blur.png)

Use RenderScript in Your Project
======

Simply add this line to your build.gradle

```groovy
defaultConfig {
    ...
    renderscriptTargetApi 22
    renderscriptSupportModeEnabled true
    ...
}
```

Simple usage using inheritance
=======
If you are using **android.app.DialogFragment** : extends **BlurDialogFragment**. 
Play with the blur radius and the down scale factor to obtain the perfect blur.

Don't forget to enable log if you want to keep on eye the performance.

```java
/**
 * Simple fragment with blurring effect behind.
 */
public class SampleDialogFragment extends BlurDialogFragment {

}
```

If you are using **android.support.v4.app.DialogFragment** : extends **SupportBlurDialogFragment**. 
Play with the blur radius and the down scale factor to obtain the perfect blur.

Don't forget to enable log in order to keep on eye the performance.

```java
/**
 * Simple fragment with blurring effect behind.
 */
public class SampleDialogFragment extends SupportBlurDialogFragment {

}
```

Customize your blurring effect
======
```java

/**
 * Simple fragment with a customized blurring effect.
 */
public class SampleDialogFragment extends BlurDialogFragment {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        ...
    }
    
    @Override
    protected float getDownScaleFactor() {
        // Allow to customize the down scale factor.
        return 5.0;
    }

    @Override
    protected int getBlurRadius() {
        // Allow to customize the blur radius factor.
        return 7;
    }
    
    @Override
    protected boolean isActionBarBlurred() {
        // Enable or disable the blur effect on the action bar.
        // Disabled by default.
        return true;
    }
    
    @Override
    protected boolean isDimmingEnable() {
        // Enable or disable the dimming effect.
        // Disabled by default.
        return true;
    }

    @Override
    protected boolean isRenderScriptEnable() {
        // Enable or disable the use of RenderScript for blurring effect
        // Disabled by default.
        return true;
    }
    
    @Override
    protected boolean isDebugEnable() {
        // Enable or disable debug mode.
        // False by default.
        return true;
    }
    ...
```

Default values are set to : 
 ```java
/**
 * Since image is going to be blurred, we don't care about resolution.
 * Down scale factor to reduce blurring time and memory allocation.
 */
static final float DEFAULT_BLUR_DOWN_SCALE_FACTOR = 4.0f;

/**
 * Radius used to blur the background
 */
static final int DEFAULT_BLUR_RADIUS = 8;

/**
 * Default dimming policy.
 */
static final boolean DEFAULT_DIMMING_POLICY = false;

/**
 * Default debug policy.
 */
static final boolean DEFAULT_DEBUG_POLICY = false;

/**
 * Default action bar blurred policy.
 */
static final boolean DEFAULT_ACTION_BAR_BLUR = false;

/**
 * Default use of RenderScript.
 */
static final boolean DEFAULT_USE_RENDERSCRIPT = false;
```

Avoiding inheritance
=======

If you want to **avoid inheritance**, use directly the **BlurEngine**. 
Don't forget to link the engine to the lifecycle of your DialogFragment.

```java
/**
 * Your blur fragment directly using BlurEngine.
 */
public class SampleDialogFragment extends MyCustomDialogFragment {

     /**
     * Engine used to blur.
     */
    private BlurDialogEngine mBlurEngine;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        mBlurEngine = new BlurDialogEngine(getActivity());
        mBlurEngine.setBlurRadius(8);
        mBlurEngine.setDownScaleFactor(8f);
        mBlurEngine.debug(true);
        mBlurEngine.setBlurActionBar(true);
        mBlurEngine.setUseRenderScript(true);
    }
    
    @Override
    public void onResume() {
        super.onResume();
        mBlurEngine.onResume(getRetainInstance());
    }
    
     @Override
    public void onDismiss(DialogInterface dialog) {
        super.onDismiss(dialog);
        mBlurEngine.onDismiss();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mBlurEngine.onDetach();
{'fraction_non_alphanumeric': 0.11022403258655805, 'fraction_numerical': 0.00505091649694501, 'mean_word_length': 3.5, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4056109', 'n_tokens_mistral': 3679, 'n_tokens_neox': 3468, 'n_words': 1050}