GithubHelp home page GithubHelp logo

anthrax3 / fogger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from allegro/fogger

0.0 0.0 0.0 20.24 MB

Fogger - a library to create blurred background under Android's UI elements

Home Page: http://allegro.tech/android-fogger.html

License: Apache License 2.0

Java 100.00%

fogger's Introduction

Fogger

Build Status

Lib to create blurred background under:

  • dialogs
  • drawer
  • context menu

Features

You can blur view behind drawer, dialog window and context menu.

Fogger Demo on Google Play

example

How to get it

Grab via Maven:

<dependency>
  <groupId>pl.allegro.android</groupId>
  <artifactId>fogger</artifactId>
  <version>0.9.0</version>
  <type>aar</type>
</dependency>

or Gradle:

compile 'pl.allegro.android:fogger:0.9.0'

Motivation

All over the internet there are pieces of code that show how to make blur effect on Android. But there is not any library that helps you to blur background under all mostly used UI items. I want to make it as easy to use as possible so you do not have to change architecture of you app.

Examples

Drawer

To make drawer with fluent, blurred you have to provide only two changes to standard Android drawer. At the first the root view must be pl.allegro.fogger.ui.drawer.DrawerLayoutWithBlurredBackground instead of DrawerLayout

The second modification is to add tag value

 android:tag="fragmentPlaceholder"

to main content layout. You could also use string resource id provided with aar

 android:tag="@string/view_with_drawer_tag"

The full example:

<?xml version="1.0" encoding="utf-8"?>

<pl.allegro.fogger.ui.drawer.DrawerLayoutWithBlurredBackground
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        
    <FrameLayout
        android:id="@+id/fragmentPlaceholder"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:tag="@string/view_with_drawer_tag"/>

    <FrameLayout
            android:id="@+id/drawer_container"
            android:tag="@string/drawer_content_view_tag"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="start">
            <include layout="@layout/settings"/>
    </FrameLayout>
    
</pl.allegro.fogger.ui.drawer.DrawerLayoutWithBlurredBackground>

Working example of drawer with dynamically blurred background you could find in the example app

Dialog

Showing dialog with blurred background is as simply as showing traditional Dialog window. All you have to do is use special dialog launcher.

public class MyActivity extends Activity {

 ...
 
     public void showDialog() {
         DialogWithBlurredBackgroundLauncher dialogWithBlurredBackgroundLauncher
                     = new SimpleDialogWithBlurredBackgroundLauncher(this);
             Dialog dialog = new Dialog(this);
             dialog.setTitle(R.string.example_dialog_title);
             dialogWithBlurredBackgroundLauncher.showDialog(dialog);
     }
 }

As you can see, it is just one more line of code compare to dialog window with standard background.

Working example of dialog window with blurred background you could find in the example app

Context Menu

To create context window with blurred background you must prepare Activity that extends

public abstract class ActivityWithContextMenu extends Activity {

then you must implements one required abstract method

    protected abstract int getContextMenuResId(View view);

The method must provide resource id form context menu to show eg.

    @Override
    protected int getContextMenuResId(View view) {
        return R.menu.context_menu;
    }

The rest of context menu flow is unchanged, so you have to register context menu on some View and listen click event with Androids method

public boolean onContextItemSelected(MenuItem item) {

Road Map

  • Substitute SafeAsyncTask (from Roboguice) with RxJava

If you have any idea please let me know.

License

Copyright 2014 original author or authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

fogger's People

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.