Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added blurBackground attribute for SlidingUpPanelLayout. If true, vie…
…w behind panel will blur while sliding
  • Loading branch information
alberto.manzano committed May 21, 2016
commit b826b8f43367b954ab99ed73022cd8fb12b22251
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
buildscript {
repositories {
mavenCentral()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.android.tools.build:gradle:2.1.0'
}
}

Expand All @@ -14,11 +15,12 @@ def isReleaseBuild() {
}

allprojects {
version = VERSION_NAME
group = GROUP
// version = VERSION_NAME
// group = GROUP

repositories {
mavenCentral()
jcenter()
}
}

Expand Down
17 changes: 13 additions & 4 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
apply plugin: 'com.android.application'

repositories {
maven { url 'http://Manabu-GT.github.com/GlassView/mvn-repo' }
}

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
buildToolsVersion "23.0.3"

lintOptions {
abortOnError false
Expand All @@ -11,11 +15,16 @@ android {
defaultConfig {
minSdkVersion 11
targetSdkVersion 23

renderscriptTargetApi 21
renderscriptSupportModeEnabled true
}
}


dependencies {
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile project(':library')
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'

compile project(':library')
}
3 changes: 1 addition & 2 deletions demo/res/layout/activity_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
<!-- MAIN CONTENT -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
xmlns:sothree="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
Expand Down
Binary file added demo/src/main/res/drawable-nodpi/androidbg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions demo/src/main/res/layout/activity_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
sothree:umanoPanelHeight="68dp"
sothree:umanoShadowHeight="4dp"
sothree:umanoParallaxOffset="100dp"
sothree:umanoBlurBackground="true"
sothree:umanoDragView="@+id/dragView"
sothree:umanoOverlay="true"
sothree:umanoScrollableView="@+id/list">
Expand All @@ -17,7 +18,9 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="vertical"
android:background="@drawable/androidbg"
>
<android.support.v7.widget.Toolbar
xmlns:sothree="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
Expand All @@ -26,17 +29,14 @@
android:background="?attr/colorPrimary"
sothree:theme="@style/ActionBar"
android:layout_width="match_parent"/>
<TextView
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:gravity="center"
android:text="Main Content"
android:clickable="true"
android:focusable="false"
android:focusableInTouchMode="true"
android:textSize="16sp" />
<!--<TextView-->
<!--android:id="@+id/main"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:layout_marginTop="?attr/actionBarSize"-->
<!--android:gravity="top"-->
<!--android:text="Main Content"-->
<!--android:textSize="16sp" />-->
</FrameLayout>

<!-- SLIDING LAYOUT -->
Expand Down
11 changes: 7 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
apply plugin: 'com.android.library'

repositories {
maven { url 'http://Manabu-GT.github.com/GlassView/mvn-repo' }
mavenCentral()
}

dependencies {
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:support-annotations:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:support-annotations:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.ms.square:glassview:0.1.0'
}

android {
Expand All @@ -19,4 +21,5 @@ android {
}
}

apply from: '../maven_push.gradle'

//apply from: '../maven_push.gradle'
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.sothree.slidinguppanel;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
Expand All @@ -13,12 +12,13 @@
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -27,6 +27,7 @@
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;

import com.ms.square.android.glassview.GlassView;
import com.nineoldandroids.view.animation.AnimatorProxy;
import com.sothree.slidinguppanel.library.R;

Expand All @@ -52,6 +53,11 @@ public class SlidingUpPanelLayout extends ViewGroup {
*/
private static final boolean DEFAULT_PANEL_OFF_SCREEN = false;

/**
* No blur by default
*/
private static final boolean DEFAULT_BLUR_BACKGROUND = false;

/**
* Default initial state for the component
*/
Expand Down Expand Up @@ -121,6 +127,11 @@ public class SlidingUpPanelLayout extends ViewGroup {
*/
private boolean mPanelOffScreen;

/**
* If true, view behind sliding panel will be blurred while sliding
*/
private boolean mBlurBackground;

/**
* The size of the shadow in pixels.
*/
Expand Down Expand Up @@ -230,6 +241,8 @@ public enum PanelState {

private final ViewDragHelper mDragHelper;

private GlassView mBlurView;

private Context mContext;

/**
Expand Down Expand Up @@ -330,7 +343,9 @@ public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
scrollerInterpolator = AnimationUtils.loadInterpolator(context, interpolatorResId);
}

mPanelOffScreen = ta.getBoolean(R.styleable.SlidingUpPanelLayout_panelOffScreen, DEFAULT_PANEL_OFF_SCREEN);
mPanelOffScreen = ta.getBoolean(R.styleable.SlidingUpPanelLayout_umanoPanelOffScreen, DEFAULT_PANEL_OFF_SCREEN);

mBlurBackground = ta.getBoolean(R.styleable.SlidingUpPanelLayout_umanoBlurBackground, DEFAULT_BLUR_BACKGROUND);
}

ta.recycle();
Expand Down Expand Up @@ -378,6 +393,13 @@ protected void onFinishInflate() {
View slidingUpPanelLayout = getChildAt(1);
setExpandedPanelOffScreen(slidingUpPanelLayout);
}

if (mBlurBackground) {
// Add blur view as the last child of the slidingUpPanelLayout's first child, with
// both height and width math_parent to blur the whole screen
setBlurBackground();
}

if (mDragViewResId != -1) {
setDragView(findViewById(mDragViewResId));
}
Expand All @@ -386,20 +408,39 @@ protected void onFinishInflate() {
}
}

public void setBlurBackground() {
LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View blurView = vi.inflate(R.layout.blur, null);

ViewGroup insertPoint = (ViewGroup) getChildAt(0);
insertPoint.addView(blurView, insertPoint.getChildCount(), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

mBlurView = (GlassView) findViewById(R.id.glass_view);
mBlurView.setBlurRadius(0f);
}

/**
* Expands the height of the SlidingUpPanelLayout by 'mPanelHeight' so that there's no
* empty space at the bottom when the view is expanded
*
* @param slidingUpPanelLayout (SlidingUpPanelLayout)
*/
@TargetApi(13)
public void setExpandedPanelOffScreen(View slidingUpPanelLayout) {
if (slidingUpPanelLayout != null) {
// Get screen dimensions
final Point size = new Point();
((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getSize(size);
final int screenHeight = size.y;
final int screenWidth = size.x;
int screenHeight;
int screenWidth;

if (Build.VERSION.SDK_INT >= 13) {
final Point size = new Point();
((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getSize(size);
screenHeight = size.y;
screenWidth = size.x;
} else {
Display display = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
screenHeight = display.getHeight();
screenWidth = display.getWidth();
}

SlidingUpPanelLayout.LayoutParams params;
params = new SlidingUpPanelLayout.LayoutParams(screenWidth, screenHeight + mPanelHeight - getNotificationBarHeight());
Expand Down Expand Up @@ -1237,6 +1278,15 @@ protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
mCoveredFadePaint.setColor(color);
canvas.drawRect(mTmpRect, mCoveredFadePaint);
}

if (mBlurBackground && mSlideOffset > 0) {
mBlurView.setVisibility(View.VISIBLE);
mBlurView.setBlurRadius(mSlideOffset * 25);
} else if (mBlurView != null) {
mBlurView.setVisibility(View.INVISIBLE);
}


} else {
result = super.drawChild(canvas, child, drawingTime);
}
Expand Down
8 changes: 8 additions & 0 deletions library/src/main/res/layout/blur.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<com.ms.square.android.glassview.GlassView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:glassview="http://schemas.android.com/apk/res-auto"
android:id="@+id/glass_view"
android:visibility="invisible"
android:layout_width="match_parent"
android:layout_height="match_parent"
glassview:blurRadius="0" />
3 changes: 2 additions & 1 deletion library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<attr name="umanoOverlay" format="boolean"/>
<attr name="umanoClipPanel" format="boolean"/>
<attr name="umanoAnchorPoint" format="float" />
<attr name="panelOffScreen" format="boolean" />
<attr name="umanoPanelOffScreen" format="boolean" />
<attr name="umanoBlurBackground" format="boolean" />
<attr name="umanoInitialState" format="enum">
<enum name="expanded" value="0" />
<enum name="collapsed" value="1" />
Expand Down
1 change: 1 addition & 0 deletions maven_push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,5 @@ afterEvaluate { project ->
archives androidSourcesJar
archives androidJavadocsJar
}

}