Skip to content

Commit

Permalink
Merge pull request #23 from Manabu-GT/develop
Browse files Browse the repository at this point in the history
Develop-v0.2.1
  • Loading branch information
Manabu-GT authored Mar 25, 2017
2 parents bd95472 + d8884f7 commit 2b8abb1
Show file tree
Hide file tree
Showing 68 changed files with 909 additions and 93 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ EtsyBlur
EtsyBlur is an Android library that allows developers to easily add a glass-like blur effect
implemented in the past [Etsy][1] app.

<img src="https://raw.github.com/Manabu-GT/EtsyBlur/master/art/readme_demo.gif" width=245 height=421 alt="Quick Demo">
<img src="https://raw.github.com/Manabu-GT/EtsyBlur/master/art/sample_launch_screen.png" width=221 height=379 alt="Sample App's Launch Screen">
<img src="https://raw.github.com/Manabu-GT/EtsyBlur/master/art/readme_demo.gif" width=221 height=379 alt="Quick Demo">

Try out the sample application:

Expand Down Expand Up @@ -227,9 +228,10 @@ Compared with its original implementation, there are several changes such as the

* If renderscript is not available, it can optionally fallback to the Java's fastblur implementation.
* No need to call invalidate manually on the target blurredView.
* The number of bitmaps used is reduced.
* The number of bitmaps used is reduced to 1.
* Does not crash if the target blurredView is set to the BlurringView's parent.
* Support for the layout preview UI via the isInEditMode() method
* Support to work with ViewPager

BlurringView 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.

Expand Down Expand Up @@ -277,6 +279,7 @@ Currently, the follwing policies are provided.
Change logs
----------
* 0.2.1 : Fixed BlurringView to work with ViewPager (3/2017)
* 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)
* 0.1.4 : Fix to fall back to Java's fast blur when renderscript is unavailable. (3/2017)
* 0.1.3 : Fix issues when window has a navigation bar in BlurDialogFragmentHelper. (11/2015)
Expand Down Expand Up @@ -306,4 +309,4 @@ License
[3]: https://github.com/500px/500px-android-blur
[4]: https://github.com/Manabu-GT/EtsyBlur/blob/master/lib/src/main/java/com/ms_square/etsyblur/BlurConfig.java
[5]: https://github.com/Manabu-GT/EtsyBlur/blob/master/lib/src/main/java/com/ms_square/etsyblur/AsyncPolicy.java
[6]: https://github.com/Manabu-GT/EtsyBlur/tree/master/sample/src/main/java/com/ms/square/android/etsyblurdemo/CreateViewDialogFragment.java
[6]: https://github.com/Manabu-GT/EtsyBlur/tree/master/sample/src/main/java/com/ms/square/android/etsyblurdemo/ui/fragment/CreateViewDialogFragment.java
Binary file added art/sample_launch_screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ org.gradle.parallel=true
android.enableBuildCache=true

# For maven central
VERSION_NAME=0.2.0
VERSION_CODE=6
VERSION_NAME=0.2.1
VERSION_CODE=7
GROUP=com.ms-square

POM_DESCRIPTION=Android library to easily add a glass-like blur effect implemented in the Etsy app
Expand Down
3 changes: 3 additions & 0 deletions lib/src/main/java/com/ms_square/etsyblur/BlurringView.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ protected void onDraw(Canvas canvas) {
bitmapToBlur.eraseColor(Color.TRANSPARENT);
}

blurringCanvas.save();
blurringCanvas.translate(-blurredView.getScrollX(), -blurredView.getScrollY());
blurredView.draw(blurringCanvas);
blurringCanvas.restore();

Bitmap blurred = blur.execute(bitmapToBlur, true);

Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "com.ms.square.android.etsyblurdemo"
minSdkVersion project.ANDROID_MIN_SDK_VERSION
targetSdkVersion project.ANDROID_TARGET_SDK_VERSION
versionCode 5
versionName "0.2.0"
versionCode 6
versionName "0.2.1"
renderscriptTargetApi project.ANDROID_RS_TARGET_VERSION
renderscriptSupportModeEnabled true
}
Expand Down
28 changes: 22 additions & 6 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
package="com.ms.square.android.etsyblurdemo" >

<application
android:name=".EtsyBlurDemoApplication"
android:name=".app.EtsyBlurDemoApplication"
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".NavigationDrawerActivity"
android:name=".ui.activity.SampleLaunchActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -18,9 +18,25 @@
</intent-filter>
</activity>
<activity
android:name=".NavigationViewActivity"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
android:name=".ui.activity.NavigationDrawerActivity"
android:label="@string/title_activity_nav_drawer"
android:theme="@style/AppTheme.ActionBar">
</activity>
<activity
android:name=".ui.activity.NavigationViewActivity"
android:label="@string/title_activity_nav_view">
</activity>
<activity
android:name=".ui.activity.ListViewActivity"
android:label="@string/title_activity_list_view">
</activity>
<activity
android:name=".ui.activity.RecyclerViewActivity"
android:label="@string/title_activity_recycler_view">
</activity>
<activity
android:name=".ui.activity.ViewPagerActivity"
android:label="@string/title_activity_view_pager">
</activity>
</application>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ms.square.android.etsyblurdemo;
package com.ms.square.android.etsyblurdemo.app;

import android.app.Application;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ms.square.android.etsyblurdemo;
package com.ms.square.android.etsyblurdemo.app;

import android.content.Context;
import android.support.annotation.NonNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.ms.square.android.etsyblurdemo.data;

import android.support.annotation.DrawableRes;

public class ListItemData {
@DrawableRes
public final int imageRes;
public final String title;
public final String description;

public ListItemData(@DrawableRes int imageRes, String title, String description) {
this.imageRes = imageRes;
this.title = title;
this.description = description;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.ms.square.android.etsyblurdemo.data;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.NonNull;

import com.ms.square.android.etsyblurdemo.R;

import java.util.ArrayList;
import java.util.List;

public class ListItemDataProvider {

public static List<ListItemData> generateSample(@NonNull Context context, int repeatCount) {
List<ListItemData> list = new ArrayList<>();
TypedArray images = context.getResources().obtainTypedArray(R.array.list_item_images);
String[] titles = context.getResources().getStringArray(R.array.list_item_titles);
String[] descriptions = context.getResources().getStringArray(R.array.list_item_descriptions);

int imagesCount = images.length();
if (imagesCount== titles.length && imagesCount == descriptions.length) {
// add 5 times to make the list longer
for (int repeat = 0; repeat < repeatCount; repeat++) {
for (int i = 0; i < imagesCount; i++) {
list.add(new ListItemData(images.getResourceId(i, 0), titles[i], descriptions[i]));
}
}
}

images.recycle();

return list;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.ms.square.android.etsyblurdemo.ui.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.ListAdapter;
import android.widget.ListView;

import com.ms.square.android.etsyblurdemo.R;
import com.ms.square.android.etsyblurdemo.data.ListItemDataProvider;
import com.ms.square.android.etsyblurdemo.ui.adapter.ListItemArrayAdapter;
import com.ms_square.etsyblur.BlurringView;

public class ListViewActivity extends AppCompatActivity {

private Toolbar toolbar;
private ListView listView;
private BlurringView blurringView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listview);

toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

listView = (ListView) findViewById(R.id.list_view);
ListAdapter adapter = new ListItemArrayAdapter(this, 0, ListItemDataProvider.generateSample(this, 5));
listView.setAdapter(adapter);

blurringView = (BlurringView) findViewById(R.id.blurring_view);
blurringView.blurredView(listView);
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package com.ms.square.android.etsyblurdemo;
package com.ms.square.android.etsyblurdemo.ui.activity;

import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v4.app.FragmentManager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;

import com.ms.square.android.etsyblurdemo.R;
import com.ms.square.android.etsyblurdemo.ui.fragment.CreateDialogDialogFragment;
import com.ms.square.android.etsyblurdemo.ui.fragment.CreateViewDialogFragment;
import com.ms.square.android.etsyblurdemo.ui.fragment.NavigationDrawerFragment;
import com.ms.square.android.etsyblurdemo.ui.fragment.PlaceholderFragment;
import com.ms_square.etsyblur.BlurSupport;


Expand Down Expand Up @@ -38,9 +42,6 @@ protected void onCreate(Bundle savedInstanceState) {
final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
navigationDrawerFragment.setUp(R.id.navigation_drawer, drawerLayout);
BlurSupport.addTo(drawerLayout);

// Shows the prompt.
Snackbar.make(drawerLayout, getString(R.string.prompt_fab),Snackbar.LENGTH_LONG).show();
}

@Override
Expand All @@ -49,7 +50,7 @@ public void onNavigationDrawerItemSelected(int position) {
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.content_view, PlaceholderFragment.newInstance(position + 1,
R.layout.fragment_place_holder_fab))
R.layout.fragment_place_holder))
.commit();
}

Expand Down Expand Up @@ -95,11 +96,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_dialog1) {
CreateViewDialogFragment fragment = CreateViewDialogFragment.newInstance();
CreateDialogDialogFragment fragment = CreateDialogDialogFragment.newInstance();
fragment.show(getSupportFragmentManager(), "dialog1");
return true;
} else if (id == R.id.action_dialog2) {
CreateDialogDialogFragment fragment = CreateDialogDialogFragment.newInstance();
CreateViewDialogFragment fragment = CreateViewDialogFragment.newInstance();
fragment.show(getSupportFragmentManager(), "dialog2");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ms.square.android.etsyblurdemo;
package com.ms.square.android.etsyblurdemo.ui.activity;

import android.os.Bundle;
import android.support.annotation.NonNull;
Expand All @@ -14,6 +14,10 @@
import android.view.MenuItem;
import android.view.View;

import com.ms.square.android.etsyblurdemo.R;
import com.ms.square.android.etsyblurdemo.ui.fragment.CreateDialogDialogFragment;
import com.ms.square.android.etsyblurdemo.ui.fragment.CreateViewDialogFragment;
import com.ms.square.android.etsyblurdemo.ui.fragment.PlaceholderFragment;
import com.ms_square.etsyblur.BlurSupport;

public class NavigationViewActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener,
Expand Down Expand Up @@ -64,11 +68,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_dialog1) {
CreateViewDialogFragment fragment = CreateViewDialogFragment.newInstance();
CreateDialogDialogFragment fragment = CreateDialogDialogFragment.newInstance();
fragment.show(getSupportFragmentManager(), "dialog1");
return true;
} else if (id == R.id.action_dialog2) {
CreateDialogDialogFragment fragment = CreateDialogDialogFragment.newInstance();
CreateViewDialogFragment fragment = CreateViewDialogFragment.newInstance();
fragment.show(getSupportFragmentManager(), "dialog2");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.ms.square.android.etsyblurdemo.ui.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;

import com.ms.square.android.etsyblurdemo.R;
import com.ms.square.android.etsyblurdemo.data.ListItemDataProvider;
import com.ms.square.android.etsyblurdemo.ui.adapter.ListItemRecyclerViewAdapter;
import com.ms_square.etsyblur.BlurringView;

public class RecyclerViewActivity extends AppCompatActivity {

private Toolbar toolbar;
private RecyclerView recyclerView;
private BlurringView blurringView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recycler_view);

toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
recyclerView.setAdapter(new ListItemRecyclerViewAdapter(ListItemDataProvider.generateSample(this, 5)));

blurringView = (BlurringView) findViewById(R.id.blurring_view);
blurringView.blurredView(recyclerView);
}
}
Loading

0 comments on commit 2b8abb1

Please sign in to comment.