Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to dismiss view on back key press #73

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
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:1.5.0'
classpath 'com.android.tools.build:gradle:2.3.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
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 @@
#Mon Dec 28 10:00:20 PST 2015
#Thu Jun 15 11:14:36 MYT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
11 changes: 5 additions & 6 deletions materialintro/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 25
buildToolsVersion "25.0.3"

defaultConfig {
minSdkVersion 14
targetSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
Expand All @@ -21,7 +21,6 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
}

This file was deleted.

11 changes: 1 addition & 10 deletions materialintro/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
<manifest package="co.mobiwise.materialintro"
xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
>

</application>
<manifest package="co.mobiwise.materialintro">

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class MaterialIntroConfiguration {

private boolean dismissOnTouch;

private boolean dismissOnBackPress;

private int colorTextViewInfo;

private boolean isDotViewEnabled;
Expand Down Expand Up @@ -96,6 +98,14 @@ public void setDismissOnTouch(boolean dismissOnTouch) {
this.dismissOnTouch = dismissOnTouch;
}

public boolean isDismissOnBackPress() {
return dismissOnBackPress;
}

public void setDismissOnBackPress(boolean dismissOnBackPress) {
this.dismissOnBackPress = dismissOnBackPress;
}

public int getColorTextViewInfo() {
return colorTextViewInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
Expand Down Expand Up @@ -130,6 +131,7 @@ public class MaterialIntroView extends RelativeLayout {
* Dismiss on touch any position
*/
private boolean dismissOnTouch;
private boolean dismissOnBackPress;

/**
* Info dialog view
Expand Down Expand Up @@ -259,6 +261,7 @@ private void init(Context context) {
isReady = false;
isFadeAnimationEnabled = true;
dismissOnTouch = false;
dismissOnBackPress = false;
isLayoutCompleted = false;
isInfoEnabled = false;
isDotViewEnabled = false;
Expand Down Expand Up @@ -419,6 +422,9 @@ public void onAnimationStart() {
});
else
setVisibility(VISIBLE);
if (dismissOnBackPress) {
requestFocus();
}
}
}, delayMillis);

Expand Down Expand Up @@ -573,6 +579,10 @@ private void setDismissOnTouch(boolean dismissOnTouch) {
this.dismissOnTouch = dismissOnTouch;
}

private void setDismissOnBackPress(boolean dismissOnBackPress) {
this.dismissOnBackPress = dismissOnBackPress;
}

private void setFocusGravity(FocusGravity focusGravity) {
this.focusGravity = focusGravity;
}
Expand Down Expand Up @@ -606,6 +616,11 @@ private void enableDotView(boolean isDotViewEnabled){
this.isDotViewEnabled = isDotViewEnabled;
}

private void enableDismissOnBackPress() {
setFocusableInTouchMode(true);
setFocusable(true);
}

public void setConfiguration(MaterialIntroConfiguration configuration) {

if (configuration != null) {
Expand All @@ -615,6 +630,7 @@ public void setConfiguration(MaterialIntroConfiguration configuration) {
this.colorTextViewInfo = configuration.getColorTextViewInfo();
this.isDotViewEnabled = configuration.isDotViewEnabled();
this.dismissOnTouch = configuration.isDismissOnTouch();
this.dismissOnBackPress = configuration.isDismissOnBackPress();
this.colorTextViewInfo = configuration.getColorTextViewInfo();
this.focusType = configuration.getFocusType();
this.focusGravity = configuration.getFocusGravity();
Expand Down Expand Up @@ -710,6 +726,11 @@ public Builder dismissOnTouch(boolean dismissOnTouch) {
return this;
}

public Builder dismissOnBackPress(boolean dismissOnBackPress) {
materialIntroView.setDismissOnBackPress(dismissOnBackPress);
return this;
}

public Builder setUsageId(String materialIntroViewId) {
materialIntroView.setUsageId(materialIntroViewId);
return this;
Expand Down Expand Up @@ -774,6 +795,10 @@ public MaterialIntroView build() {
}

materialIntroView.setShape(shape);

if (materialIntroView.dismissOnBackPress) {
materialIntroView.enableDismissOnBackPress();
}
return materialIntroView;
}

Expand All @@ -784,4 +809,15 @@ public MaterialIntroView show() {

}

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (dismissOnBackPress && event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
if (event.getAction() == KeyEvent.ACTION_UP) {
dismiss();
}
return true;
}
return super.dispatchKeyEvent(event);
}

}

This file was deleted.

12 changes: 5 additions & 7 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 25
buildToolsVersion "25.0.3"

defaultConfig {
applicationId "co.mobiwise.sample"
minSdkVersion 14
targetSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
Expand All @@ -21,10 +21,8 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
//compile 'com.github.iammert:MaterialIntroView:1.5.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile project(':materialintro')
compile 'com.squareup.picasso:picasso:2.5.2'
}

This file was deleted.

15 changes: 0 additions & 15 deletions sample/src/test/java/co/mobiwise/sample/ExampleUnitTest.java

This file was deleted.