{"id":20101909,"url":"https://github.com/manabu-gt/etsyblur","last_synced_at":"2025-04-12T22:37:21.399Z","repository":{"id":75159243,"uuid":"20775048","full_name":"Manabu-GT/EtsyBlur","owner":"Manabu-GT","description":"EtsyBlur is an Android library that allows developers to easily add a glass-like blur effect implemented in the  Etsy app.","archived":false,"fork":false,"pushed_at":"2020-01-13T07:17:42.000Z","size":16305,"stargazers_count":757,"open_issues_count":13,"forks_count":151,"subscribers_count":30,"default_branch":"master","last_synced_at":"2024-07-31T18:17:26.159Z","etag":null,"topics":["android-library","blur","dialogfragment","etsy","etsyblur","java"],"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/Manabu-GT.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,"governance":null}},"created_at":"2014-06-12T16:38:27.000Z","updated_at":"2024-07-16T02:02:42.000Z","dependencies_parsed_at":"2023-03-11T18:30:00.299Z","dependency_job_id":null,"html_url":"https://github.com/Manabu-GT/EtsyBlur","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Manabu-GT%2FEtsyBlur","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Manabu-GT%2FEtsyBlur/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Manabu-GT%2FEtsyBlur/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Manabu-GT%2FEtsyBlur/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Manabu-GT","download_url":"https://codeload.github.com/Manabu-GT/EtsyBlur/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248643007,"owners_count":21138353,"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":["android-library","blur","dialogfragment","etsy","etsyblur","java"],"created_at":"2024-11-13T17:27:21.737Z","updated_at":"2025-04-12T22:37:21.377Z","avatar_url":"https://github.com/Manabu-GT.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"EtsyBlur\n===========\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.ms-square/etsyblur/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.ms-square/etsyblur)\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-EtsyBlur-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1202)\n\nEtsyBlur is an Android library that allows developers to easily add a glass-like blur effect \nimplemented in the past [Etsy][1] app.\n\n\u003cimg src=\"https://raw.github.com/Manabu-GT/EtsyBlur/master/art/sample_launch_screen.png\" width=221 height=379 alt=\"Sample App's Launch Screen\"\u003e\n\u003cimg src=\"https://raw.github.com/Manabu-GT/EtsyBlur/master/art/readme_demo.gif\" width=221 height=379 alt=\"Quick Demo\"\u003e\n\nTry out the sample application:\n\n\u003ca href=\"https://play.google.com/store/apps/details?id=com.ms.square.android.etsyblurdemo\"\u003e\n  \u003cimg alt=\"Android app on Google Play\"\n       src=\"https://developer.android.com/images/brand/en_app_rgb_wo_45.png\" /\u003e\n\u003c/a\u003e\n\nRequirements\n-------------\nAPI Level 11 (Honeycomb) and above.\n\nSetup\n------\nThe library is pushed to Maven Central as an AAR, \nso you just need to add the followings to your ***build.gradle*** file:\n\n```groovy\ndependencies {\n    compile 'com.ms-square:etsyblur:0.2.1'\n}\n\nandroid {\n    defaultConfig {\n        renderscriptTargetApi 25\n        renderscriptSupportModeEnabled true\n    }\n}\n```\n\nUsage\n------\nUsing the library is really simple, read the following instructions or your can also look at the source code of the [provided sample][2].\n\n### For NavigationView\n```java\n// ex...Inside Activity's onCreate()\ndrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);\nBlurSupport.addTo(drawerLayout);\n```\n\nThe above code just works if you have the **com.ms_square.etsyblur.BlurringView** with id set to **@id/blurring_view** within your layout xml file.\nPlease place it between the first child view of your DrawerLayout and NavigationView; otherwise, it will not work as expected.\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003candroid.support.v4.widget.DrawerLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:id=\"@+id/drawer_layout\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:fitsSystemWindows=\"true\"\n    tools:openDrawer=\"start\"\u003e\n\n    \u003cLinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\"\u003e\n\n        \u003candroid.support.v7.widget.Toolbar\n            android:id=\"@+id/toolbar\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\"\n            android:minHeight=\"?attr/actionBarSize\"\n            android:background=\"?attr/colorPrimary\"/\u003e\n\n        \u003c!-- main content view --\u003e\n        \u003cFrameLayout\n            android:id=\"@+id/content_view\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\" /\u003e\n    \u003c/LinearLayout\u003e\n\n    \u003c!-- needed w/this id for EtsyBlur Lib to work --\u003e\n    \u003ccom.ms_square.etsyblur.BlurringView\n        android:id=\"@id/blurring_view\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\u003e\n    \u003c/com.ms_square.etsyblur.BlurringView\u003e\n\n    \u003candroid.support.design.widget.NavigationView\n        android:id=\"@+id/nav_view\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"match_parent\"\n        android:layout_gravity=\"start\"\n        android:fitsSystemWindows=\"true\"\n        android:background=\"@color/bg_drawer\"\n        app:itemTextColor=\"@android:color/white\"\n        app:menu=\"@menu/navigation_view_drawer\" /\u003e\n\n\u003c/android.support.v4.widget.DrawerLayout\u003e\n```\n\n### For NavigationDrawer\n\n```java\n// ex...Inside Activity's onCreate()\ndrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);\nnavigationDrawerFragment.setUp(R.id.navigation_drawer, drawerLayout);\nBlurSupport.addTo(drawerLayout);\n```\n\nThe above code just works if you have the **com.ms_square.etsyblur.BlurringView** with id set to **@id/blurring_view** within your layout xml file.\nPlease place it between the first child view of your DrawerLayout and NavigationDrawerFragment; otherwise, it will not work as expected.\n\n```xml\n\u003candroid.support.v4.widget.DrawerLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:id=\"@+id/drawer_layout\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    tools:context=\".NavigationDrawerActivity\"\u003e\n\n    \u003c!-- As the main content view, the view below consumes the entire\n         space available using match_parent in both dimensions. --\u003e\n    \u003cFrameLayout\n        android:id=\"@+id/content_view\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\" /\u003e\n\n    \u003c!-- needed w/this id for EtsyBlur Lib to work --\u003e\n    \u003ccom.ms_square.etsyblur.BlurringView\n        android:id=\"@id/blurring_view\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\u003e\n    \u003c/com.ms_square.etsyblur.BlurringView\u003e\n\n    \u003cfragment android:id=\"@+id/navigation_drawer\"\n        android:layout_width=\"@dimen/navigation_drawer_width\"\n        android:layout_height=\"match_parent\"\n        android:layout_gravity=\"start\"\n        android:name=\"com.ms.square.android.etsyblurdemo.NavigationDrawerFragment\"\n        tools:layout=\"@layout/fragment_navigation_drawer\" /\u003e\n\n\u003c/android.support.v4.widget.DrawerLayout\u003e\n```\n\n### For DialogFragment\n\n* `BlurDialogFragment`\n\nThis is an abstract class to make the dialog background into the blurred image of its holding activity's content. BlurDialogFragment supports asynchronous blur operation provided via [Blur - for Simple Blur Effect on bitmaps](#blur---for-simple-blur-effect-on-bitmaps). Its asynchronous execution policy is determined by the given [AsyncPolicy](#asyncpolicy).\n\n#### Simple usage using inheritance\n\nIf you are using **android.support.v4.app.DialogFragment**, just extend **BlurDialogFragment**.\nUsing [BlurConfig](#blurconfig), experiment with the blur radius, the down scale factor, and the overlay coloring to obtain the blur effect you want for your app.\n\n```java\n/**\n * Simple dialog fragment with background blurring effect.\n */\npublic class CreateDialogDialogFragment extends BlurDialogFragment {\n@Override\n    public Dialog onCreateDialog(Bundle savedInstanceState) {\n        AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.EtsyBlurAlertDialogTheme)\n                .setIcon(R.drawable.ic_launcher)\n                .setTitle(\"Hello\")\n                .setPositiveButton(\"OK\", null)\n                .create();\n        return dialog;\n    }\n    \n    @NonNull\n    protected BlurConfig blurConfig() {\n        return new BlurConfig.Builder()\n                .asyncPolicy(SmartAsyncPolicyHolder.INSTANCE.smartAsyncPolicy())\n                .debug(true)\n                .build();\n    }\n}\n```\n\nNote:\n\nIn your DialogFragment, override either onCreateDialog() or onCreateView(), not both.\nFor a onCreateView() example, please look at the CreateViewDialogFragment in [provided sample][6].\nI quickly wrote this minimum BlurDialogFragment just to mimic old-Etsy app's blurring dialog implementation.\nSo, there are missing options/features I should probably add in the future such as a toolbar/actionbar exclusion option, non-support library's DialogFragment support...etc.\n\n### BlurringView\n\nBlurringView can blur the target view's content automatically.\nIn this library, it's being used to automatically blur the content within DrawerLayout.\n\n#### Available custom attributes in layout xml\n\n* radius - [integer]\n\u003eRadius used to blur the target view.\n\n* downScaleFactor - [integer]\n\u003eFactor used to down scale the target view before blurring.\n Making this value higher results in faster blurring time and less memory allocation, but degreades final rendering quality.\n \n* overlayColor - [color]\n\u003eColor used to overrlay the blurred image\n\n* allowFallback - [boolean]\n\u003eIf true, it fall backs to Java's fastblur implementation when rederscript is not available. If false, performs no blurring in such case.\n\n* debug - [boolean]\n\u003eWhen set to true, it will output logcat debug messages of blur operations such as blur method used, if executing in background, and time each blur operation took.\n\n#### [BlurConfig][4]\n\nYou can also set the configuration dynamically by calling **void blurConfig(BlurConfig config)** method of BlurringView at runtime. Please not that it must be called before BlurringView's onAttachedToWindow() gets called. When called, it will overwrite the configuration pased through custom attributes in your layout xml file.\nAll the custom attribute options plus the following parameter is currently  available.\n\n* asyncPolicy - [AsyncPolicy](#asyncpolicy)\n\n\u003ePolicy used to determine whether to execute blurring operation in background thread or not.\n\n*NOTE:*\n\nBlurringView is based on the implementation of [500px Android Blurring View][3].\nCompared with its original implementation, there are several changes such as the followings.\n\n* If renderscript is not available, it can optionally fallback to the Java's fastblur implementation.\n* No need to call invalidate manually on the target blurredView.\n* The number of bitmaps used is reduced to 1.\n* Does not crash if the target blurredView is set to the BlurringView's parent.\n* Support for the layout preview UI via the isInEditMode() method\n* Support to work with ViewPager\n\nBlurringView currently does not support asynchronous execution of a blur operation. For now, just adjust downSampleFactor and blurRadius to get fast enough performance to just run it on the UI thread. I will ponder if the need for asynchronous suppport justifies added code complexity mainly due to threading.\n\n###  Blur - for Simple Blur Effect on bitmaps\n\nBlur class is being used internally for both BlurringView and BlurDialogFragment to provide the blur operation as well.\n\n#### Simple Usage\n\n```java\nBlur blur = new Blur(context, blurConfig)\n\n// Run synchronously\n// true if inBitmap is reusable as the output\nBitmap blurredBitmap = blur.execute(inBitmap, true);\n\n// Run synchronously or asynchronously depending on the given AsyncPolicy\n// via blurConfig.\nblur.execute(inBitmap, true, new BlurEngine.Callback() {\n    @Override\n    public void onFinished(@Nullable Bitmap blurredBitmap) {\n    \tblurImgView.setImageBitmap(blurredBitmap);\n    }\n});\n\n// when done, make sure to call destroy() which will clean up used resources and \n// cancel any remaining backgroud work\nblur.destroy();\n```\n\n----------\n#### [AsyncPolicy][5]\nThis IF defines policy used to determine whether to execute blurring operation in background thread or not.\nCurrently, the follwing policies are provided.\n\n* **SimpleAsyncPolicy** (Default)\n\u003eIf renderscript is available to use, always execute blur operation synchronously; otherwis execute asynchronously.\n\n* AlwaysAsyncPolicy\n\u003eAlways execute blur operation asynchronously.\n\n* SmartAsyncPolicy\n\u003eDynamically guess computation time required and determins to execute blur operation asynchronously or not.\n\u003eIf the estimated computation time exceeds 16ms, it will run asynchronously.\n\nChange logs\n----------\n* 0.2.1 : Fixed BlurringView to work with ViewPager (3/2017)\n* 0.2.0 : Mostly re-wrote old outdated code and updated IFs. Noticed Etsy app no longer uses blur... Might re-consider current library structures (3/2017)\n* 0.1.4 : Fix to fall back to Java's fast blur when renderscript is unavailable. (3/2017)\n* 0.1.3 : Fix issues when window has a navigation bar in BlurDialogFragmentHelper. (11/2015)\n* 0.1.2 : Fix zero width/height exception in BlurDialogFragmentHelper. (8/2015)\n* 0.1.1 : Fix NullPointerExcepiton if DialogFragment implements onCreateDialog. (5/2015)\n* 0.1.0 : Initial Release. (12/2014)\n\nLicense\n----------\n\n    Copyright 2014 Manabu Shimobe\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n[1]: https://play.google.com/store/apps/details?id=com.etsy.android\n[2]: https://github.com/Manabu-GT/EtsyBlur/tree/master/sample/src/main/java/com/ms/square/android/etsyblurdemo/\n[3]: https://github.com/500px/500px-android-blur\n[4]: https://github.com/Manabu-GT/EtsyBlur/blob/master/lib/src/main/java/com/ms_square/etsyblur/BlurConfig.java\n[5]: https://github.com/Manabu-GT/EtsyBlur/blob/master/lib/src/main/java/com/ms_square/etsyblur/AsyncPolicy.java\n[6]: https://github.com/Manabu-GT/EtsyBlur/tree/master/sample/src/main/java/com/ms/square/android/etsyblurdemo/ui/fragment/CreateViewDialogFragment.java\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanabu-gt%2Fetsyblur","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanabu-gt%2Fetsyblur","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanabu-gt%2Fetsyblur/lists"}