Skip to content

Commit

Permalink
Refactored Project to "Slidr" to be more 'hip' as "SlidableActivity" …
Browse files Browse the repository at this point in the history
…sucked.

Added functionality to modulate the status bar colors based on the slide progress
  • Loading branch information
r0adkll committed Jan 10, 2015
1 parent 1f0ac79 commit 2a2b83b
Show file tree
Hide file tree
Showing 20 changed files with 104 additions and 30 deletions.
Empty file added .gitignore
Empty file.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/libraries/support_annotations_21_0_3.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/support_v4_21_0_3.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions SlidableActivity.iml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/classes/main" />
<output-test url="file://$MODULE_DIR$/build/classes/test" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.+'
classpath 'com.android.tools.build:gradle:1.0.0'
}
}

Expand Down
Binary file modified build/intermediates/model_data.bin
Binary file not shown.
7 changes: 4 additions & 3 deletions example/example.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="SlidableActivity" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down Expand Up @@ -79,10 +79,11 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 21 Platform (1)" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-21.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="module" module-name="library" exported="" />
</component>
</module>
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Nov 14 14:49:06 EST 2014
#Fri Jan 09 23:49:06 EST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
5 changes: 4 additions & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ android {
buildToolsVersion "21.1.1"

defaultConfig {
applicationId "com.r0adkll.slidableactivity"
minSdkVersion 14
targetSdkVersion 21
versionCode 2
versionName "1.0.1"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}

dependencies {
Expand Down
12 changes: 4 additions & 8 deletions library/library.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="SlidableActivity" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down Expand Up @@ -47,7 +47,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
Expand All @@ -60,7 +59,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
Expand All @@ -80,15 +78,13 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 21 Platform (1)" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-21.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
</component>
</module>

2 changes: 1 addition & 1 deletion library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.r0adkll.slidableactivity">
package="com.r0adkll.slidr">
<application />
</manifest>
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.r0adkll.slidableactivity;
package com.r0adkll.slidr;

import android.animation.ArgbEvaluator;
import android.app.Activity;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;

import com.r0adkll.slidableactivity.widget.SliderPanel;
import com.r0adkll.slidr.widget.SliderPanel;

/**
* This attacher class is used to attach the sliding mechanism to any {@link android.app.Activity}
Expand All @@ -14,16 +16,16 @@
*
* Created by r0adkll on 8/18/14.
*/
public class SlidableAttacher {
public class Slidr {

/**
* Attach a slideable mechanism to an activity that adds the slide to dismiss functionality
*
* @param activity the activity to attach the slider to
* @return a {@link com.r0adkll.slidableactivity.SlideLockInterface} that allows
* @return a {@link com.r0adkll.slidr.SlidrInterface} that allows
* the user to lock/unlock the sliding mechanism for whatever purpose.
*/
public static SlideLockInterface attach(final Activity activity){
public static SlidrInterface attach(final Activity activity, final int statusBarColor1, final int statusBarColor2){

// Hijack the decorview
ViewGroup decorView = (ViewGroup)activity.getWindow().getDecorView();
Expand All @@ -38,6 +40,9 @@ public static SlideLockInterface attach(final Activity activity){

// Set the panel slide listener for when it becomes closed or opened
panel.setOnPanelSlideListener(new SliderPanel.OnPanelSlideListener() {

private final ArgbEvaluator mEvaluator = new ArgbEvaluator();

@Override
public void onClosed() {
activity.finish();
Expand All @@ -46,10 +51,19 @@ public void onClosed() {

@Override
public void onOpened() {}

@Override
public void onSlideChange(float percent) {
// Interpolate the statusbar color
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
int newColor = (int) mEvaluator.evaluate(percent, statusBarColor1, statusBarColor2);
activity.getWindow().setStatusBarColor(newColor);
}
}
});

// Setup the lock interface
SlideLockInterface lockInterface = new SlideLockInterface() {
SlidrInterface slidrInterface = new SlidrInterface() {
@Override
public void lock() {
panel.lock();
Expand All @@ -62,7 +76,7 @@ public void unlock() {
};

// Return the lock interface
return lockInterface;
return slidrInterface;
}

}
9 changes: 9 additions & 0 deletions library/src/main/java/com/r0adkll/slidr/SlidrInterface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.r0adkll.slidr;

/**
* Created by r0adkll on 1/9/15.
*/
public interface SlidrInterface {
public void lock();
public void unlock();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* All Rights Reserved.
*/

package com.r0adkll.slidableactivity.widget;
package com.r0adkll.slidr.widget;

import android.content.Context;
import android.graphics.Color;
Expand All @@ -14,8 +14,6 @@
import android.view.View;
import android.widget.FrameLayout;

import com.r0adkll.slidableactivity.SlidableAttacher;

/**
* Project: PilotPass
* Package: com.ftinc.mariner.pilotpass.widgets
Expand Down Expand Up @@ -177,6 +175,8 @@ public void onViewPositionChanged(View changedView, int left, int top, int dx, i
super.onViewPositionChanged(changedView, left, top, dx, dy);
float percent = 1 - ((float)left / (float)mScreenWidth);

if(mListener != null) mListener.onSlideChange(percent);

// Update the dimmer alpha
float alpha = percent * MAX_DIM_ALPHA;
mDimView.setAlpha(alpha);
Expand Down Expand Up @@ -226,6 +226,7 @@ public static int clamp(int value, int min, int max){
public static interface OnPanelSlideListener{
public void onClosed();
public void onOpened();
public void onSlideChange(float percent);
}

}
4 changes: 4 additions & 0 deletions library/src/main/res/values/ids.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="slidable_panel" type="id" />
</resources>
4 changes: 2 additions & 2 deletions local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Fri Nov 14 14:45:20 EST 2014
sdk.dir=/Users/drew.heavner/android-sdk
#Fri Jan 09 23:44:30 EST 2015
sdk.dir=/Users/r0adkll/Documents/Developer/android-sdk

0 comments on commit 2a2b83b

Please sign in to comment.