{"id":13396394,"url":"https://github.com/tvbarthel/BlurDialogFragment","last_synced_at":"2025-03-13T23:31:09.767Z","repository":{"id":19542928,"uuid":"22791072","full_name":"tvbarthel/BlurDialogFragment","owner":"tvbarthel","description":"Library project to display DialogFragment with a blur effect.","archived":false,"fork":false,"pushed_at":"2019-08-27T09:53:06.000Z","size":50538,"stargazers_count":2088,"open_issues_count":34,"forks_count":338,"subscribers_count":58,"default_branch":"master","last_synced_at":"2024-07-31T18:17:26.081Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tvbarthel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-09T17:15:04.000Z","updated_at":"2024-07-26T10:15:48.000Z","dependencies_parsed_at":"2022-08-02T15:00:25.001Z","dependency_job_id":null,"html_url":"https://github.com/tvbarthel/BlurDialogFragment","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tvbarthel%2FBlurDialogFragment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tvbarthel%2FBlurDialogFragment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tvbarthel%2FBlurDialogFragment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tvbarthel%2FBlurDialogFragment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tvbarthel","download_url":"https://codeload.github.com/tvbarthel/BlurDialogFragment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243499958,"owners_count":20300726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T18:00:49.704Z","updated_at":"2025-03-13T23:31:08.467Z","avatar_url":"https://github.com/tvbarthel.png","language":"Java","readme":"BlurDialogFragment\n==================\n\nThis project allows to display DialogFragment with a burring effect behind. The blurring part is achieved through FastBlur algorithm thanks to the impressive work of Pavlo Dudka (cf [Special Thanks](https://github.com/tvbarthel/BlurDialogFragment/#special-thanks-to-)). \n\n[![Maven Central](http://img.shields.io/maven-central/v/fr.tvbarthel.blurdialogfragment/lib.svg)](http://search.maven.org/#search%7Cga%7C1%7Cblurdialogfragment)\n\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-BlurDialogFragment-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1064)\n\n* [Sample app](#sample-app)\n* [Gradle dependency](#gradle-dependency)\n* [Example](#example)\n* [Use RenderScript in Your Project] (#use-renderscript-in-your-project)\n* [Simple usage using inheritance](#simple-usage-using-inheritance)\n* [Customize your blurring effect](#customize-your-blurring-effect)\n* [Avoiding inheritance](#avoiding-inheritance)\n* [Benchmark](#benchmark)\n* [Known bugs](#known-bugs)\n* [RenderScript or not RenderScript](#renderscript-or-not-renderscript)\n* [Change logs](#change-logs)\n* [Contributing](#contributing)\n* [Credits](#credits)\n* [License](#license)\n* [Special Thanks](#special-thanks-to-)\n\nSample app\n=======\n[Download the sample app on the Google Play store.](https://play.google.com/store/apps/details?id=fr.tvbarthel.lib.blurdialogfragment.sample)\n\nGradle dependency\n=======\nSince the library is promoted on maven central, just add a new gradle dependency :\n\n```groovy\n    compile 'fr.tvbarthel.blurdialogfragment:lib:2.2.0'\n```\n\nDon't forget to check the [Use RenderScript in Your Project] (#use-renderscript-in-your-project) if you're planning to use it.\n\nExample\n=======\nActivity with action bar [blurRadius 4, downScaleFactor 5.0] : \n![action bar blur](/static/action_bar_blur.png)\n\nFullscreen activity [blurRadius 2, downScaleFactor 8.0] : \n![full screen blur](/static/full_screen_blur.png)\n\nUse RenderScript in Your Project\n======\n\nSimply add this line to your build.gradle\n\n```groovy\ndefaultConfig {\n    ...\n    renderscriptTargetApi 22\n    renderscriptSupportModeEnabled true\n    ...\n}\n```\n\nSimple usage using inheritance\n=======\nIf you are using **android.app.DialogFragment** : extends **BlurDialogFragment**. \nPlay with the blur radius and the down scale factor to obtain the perfect blur.\n\nDon't forget to enable log if you want to keep on eye the performance.\n\n```java\n/**\n * Simple fragment with blurring effect behind.\n */\npublic class SampleDialogFragment extends BlurDialogFragment {\n\n}\n```\n\nIf you are using **android.support.v4.app.DialogFragment** : extends **SupportBlurDialogFragment**. \nPlay with the blur radius and the down scale factor to obtain the perfect blur.\n\nDon't forget to enable log in order to keep on eye the performance.\n\n```java\n/**\n * Simple fragment with blurring effect behind.\n */\npublic class SampleDialogFragment extends SupportBlurDialogFragment {\n\n}\n```\n\nCustomize your blurring effect\n======\n```java\n\n/**\n * Simple fragment with a customized blurring effect.\n */\npublic class SampleDialogFragment extends BlurDialogFragment {\n\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        ...\n    }\n    \n    @Override\n    protected float getDownScaleFactor() {\n        // Allow to customize the down scale factor.\n        return 5.0;\n    }\n\n    @Override\n    protected int getBlurRadius() {\n        // Allow to customize the blur radius factor.\n        return 7;\n    }\n    \n    @Override\n    protected boolean isActionBarBlurred() {\n        // Enable or disable the blur effect on the action bar.\n        // Disabled by default.\n        return true;\n    }\n    \n    @Override\n    protected boolean isDimmingEnable() {\n        // Enable or disable the dimming effect.\n        // Disabled by default.\n        return true;\n    }\n\n    @Override\n    protected boolean isRenderScriptEnable() {\n        // Enable or disable the use of RenderScript for blurring effect\n        // Disabled by default.\n        return true;\n    }\n    \n    @Override\n    protected boolean isDebugEnable() {\n        // Enable or disable debug mode.\n        // False by default.\n        return true;\n    }\n    ...\n```\n\nDefault values are set to : \n ```java\n/**\n * Since image is going to be blurred, we don't care about resolution.\n * Down scale factor to reduce blurring time and memory allocation.\n */\nstatic final float DEFAULT_BLUR_DOWN_SCALE_FACTOR = 4.0f;\n\n/**\n * Radius used to blur the background\n */\nstatic final int DEFAULT_BLUR_RADIUS = 8;\n\n/**\n * Default dimming policy.\n */\nstatic final boolean DEFAULT_DIMMING_POLICY = false;\n\n/**\n * Default debug policy.\n */\nstatic final boolean DEFAULT_DEBUG_POLICY = false;\n\n/**\n * Default action bar blurred policy.\n */\nstatic final boolean DEFAULT_ACTION_BAR_BLUR = false;\n\n/**\n * Default use of RenderScript.\n */\nstatic final boolean DEFAULT_USE_RENDERSCRIPT = false;\n```\n\nAvoiding inheritance\n=======\n\nIf you want to **avoid inheritance**, use directly the **BlurEngine**. \nDon't forget to link the engine to the lifecycle of your DialogFragment.\n\n```java\n/**\n * Your blur fragment directly using BlurEngine.\n */\npublic class SampleDialogFragment extends MyCustomDialogFragment {\n\n     /**\n     * Engine used to blur.\n     */\n    private BlurDialogEngine mBlurEngine;\n\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        \n        mBlurEngine = new BlurDialogEngine(getActivity());\n        mBlurEngine.setBlurRadius(8);\n        mBlurEngine.setDownScaleFactor(8f);\n        mBlurEngine.debug(true);\n        mBlurEngine.setBlurActionBar(true);\n        mBlurEngine.setUseRenderScript(true);\n    }\n    \n    @Override\n    public void onResume() {\n        super.onResume();\n        mBlurEngine.onResume(getRetainInstance());\n    }\n    \n     @Override\n    public void onDismiss(DialogInterface dialog) {\n        super.onDismiss(dialog);\n        mBlurEngine.onDismiss();\n    }\n\n    @Override\n    public void onDestroy() {\n        super.onDestroy();\n        mBlurEngine.onDetach();\n    }\n\n    @Override\n    public void onDestroyView() {\n        if (getDialog() != null) {\n            getDialog().setDismissMessage(null);\n        }\n        super.onDestroyView();\n    }\n    \n    ...\n}\n```\n\nBenchmark\n=======\n\n# Benchmark outdated. Please refer to the debug option of the sample in order to compare FastBlur and RenderScript.\n\nWe used a Nexus 5 running a 4.4.4 stock rom for this bench.\n\nDown scale factor 8.0 \u0026 Blur Radius 8 : [Screenshot](/static/blur_8.0_8.png)\n```javascript\nRadius : 8\nDown Scale Factor : 8.0\nBlurred achieved in : 18 ms\nAllocation : 4320ko (screen capture) + 270ko (FastBlur)\n```\n\nDown scale factor 6.0 \u0026 Blur Radius 12 : [Screenshot](/static/blur_6.0_12.png)\n```javascript\nRadius : 12\nDown Scale Factor : 6.0\nBlurred achieved in : 31 ms\nAllocation : 4320ko (screen capture) + 360ko (FastBlur)\n```\n\nDown scale factor 4.0 \u0026 Blur Radius 20 : [Screenshot](/static/blur_4.0_20.png)\n```javascript\nRadius : 20\nDown Scale Factor : 4.0\nBlurred achieved in : 75 ms\nAllocation : 4320ko (screen capture) + 540ko (FastBlur)\n```\n\n\nKnown bugs\n=======\n* Wrong top offset when using the following line in application Theme :\n```xml\n\u003citem name=\"android:windowActionBarOverlay\"\u003etrue\u003c/item\u003e\n```\n\nRenderScript or not RenderScript\n=======\nThanks to [amasciul](https://github.com/amasciul) blurring effect can now be achieved using ScriptIntrinsicBlur (v1.1.0).\n\nFind more information on the [memory trace](http://tvbarthel.github.io/blur-dialog-fragment.html) and on the [execution time](http://trickyandroid.com/advanced-blurring-techniques/#comment-1557039595).\n\n\nChange logs\n=======\n* 2.2.0 : Fix preDrawListener registration when there was no certitude that onPreDraw will be called thanks to [Serkan Modoğlu](https://github.com/sekomod) and [Mark Mooibroek](https://github.com/markmooibroek) reports.\n* 2.1.6 : Fix orientation change as well as retainInstance thanks to [IskuhiSargsyan](https://github.com/IskuhiSargsyan) report and tweak FastBlur implementation to avoid the allocation of 3 additional arrays for RGB channels thanks to [sh1](https://disqus.com/by/sh1sh1sh1/) feedback.\n* 2.1.5 : Minor fixes thanks to [Edward S](https://github.com/edward-s) and [Tommy Chan](https://github.com/tommytcchan).\n* 2.1.4 : Fix NPE during the blurring process thanks to [Anth06ny](https://github.com/Anth06ny), [jacobtabak](https://github.com/jacobtabak) and [serega2593](https://github.com/serega2593) reports.\n* 2.1.3 : Remove unused resources thanks to [ligol](https://github.com/ligol) report.\n* 2.1.2 : Rework support of translucent status bar thanks to [wangsai-silence](https://github.com/wangsai-silence) report.\n* 2.1.1 : Fix usage without renderscript as VerifyError was fired.\n* 2.1.0 : Support AppCompatActivity and fix several bugs thanks to [jacobtabak](https://github.com/jacobtabak).\n* 2.0.1 : BlurEngine is back again (restore \"avoiding inheritance\" usage, thanks to [sergiopantoja](https://github.com/sergiopantoja) report).\n* 2.0.0 : Min SDK 9+, don't forget to check the above section \"Use RenderScript in Your Project\". (thanks to [ligol](https://github.com/ligol)).\n* 1.1.0 : Allow to use RenderScript (thank to [amasciul](https://github.com/amasciul)).\n* 1.0.0 : Animate blurring effect, support tablet, tweak nav bar offset and reduce memory allocation.\n* 0.1.2 : Fix bottom offset introduce by the navigation bar on Lollipop.\n* 0.1.1 : Fix top offset when using Toolbar.\n* 0.1.0 : Support appcompat-v7:21.\n* 0.0.9 : Change default blur radius (8) and default down scale factor (4).\n* 0.0.8 : Fix NoClassDefFound.\n* 0.0.7 : Avoid using inheritance through BlurDialogEngine if needed.\n\nContributing\n=======\n\nContributions are welcome (: You can contribute through GitHub by forking the repository and sending a pull request.\n\nWhen submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. Please also make sure your code fit these convention by running gradlew check.\n\nCredits\n========\nCredits go to Thomas Barthélémy [https://github.com/tbarthel-fr](https://github.com/tbarthel-fr) and Vincent Barthélémy [https://github.com/vbarthel-fr](https://github.com/vbarthel-fr).\n\nLicense\n=====================\n```\nCopyright (C) 2014 tvbarthel\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\nSpecial Thanks to ...\n========\nPavlo Dudka [https://github.com/paveldudka/](https://github.com/paveldudka/) , for his impressive article on [Advanced blurring techniques](http://trickyandroid.com/advanced-blurring-techniques/).\n\nVincent Brison [https://github.com/vincentbrison](https://github.com/vincentbrison) , for his early day support.\n\nAlexandre Masciulli [https://github.com/amasciul](https://github.com/amasciul) , for the integration of RenderScript.\n","funding_links":[],"categories":["Index `(light-weight pages)`","Java","对话框","Index","Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftvbarthel%2FBlurDialogFragment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftvbarthel%2FBlurDialogFragment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftvbarthel%2FBlurDialogFragment/lists"}