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

Added canScroll and onClickListener options to Tooltip.Builder, and upgraded gradle build tools #97

Open
wants to merge 1 commit 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
9 changes: 2 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion ANDROID_BUILD_SDK_VERSION as int
buildToolsVersion ANDROID_BUILD_TOOLS_VERSION

defaultConfig {
minSdkVersion 14
targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION as int
versionCode 1
versionName VERSION_NAME

jackOptions {
enabled false
}
}
buildTypes {
release {
Expand All @@ -22,8 +17,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
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 {
}

dependencies {
classpath 'com.android.tools.build:gradle:2.3.0-beta2'
classpath 'com.android.tools.build:gradle:3.0.1'
}
}

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 @@
#Tue Jan 24 16:36:36 EST 2017
#Thu Jan 11 12:22:21 PST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
5 changes: 2 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ version VERSION_NAME

android {
compileSdkVersion ANDROID_BUILD_SDK_VERSION as int
buildToolsVersion ANDROID_BUILD_TOOLS_VERSION

defaultConfig {
minSdkVersion 14
Expand All @@ -24,8 +23,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.support.annotation.StringRes;
import android.text.Html;
import android.text.TextUtils;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
Expand Down Expand Up @@ -208,6 +209,8 @@ public interface TooltipView {
void setTextColor(final ColorStateList color);

void requestLayout();

TextView getTextView();
}

public interface Callback {
Expand Down Expand Up @@ -259,6 +262,7 @@ static class TooltipViewImpl extends ViewGroup implements TooltipView {
private final Point mTmpPoint = new Point();
private final Rect mHitRect = new Rect();
private final float mTextViewElevation;
private final boolean mCanScroll;
private Callback mCallback;
private int[] mOldLocation;
private Gravity mGravity;
Expand Down Expand Up @@ -394,6 +398,7 @@ public void onGlobalLayout() {
};

private boolean mIsCustomView;
private OnClickListener mOnClickListener;

public TooltipViewImpl(Context context, final Builder builder) {
super(context);
Expand Down Expand Up @@ -428,6 +433,8 @@ public TooltipViewImpl(Context context, final Builder builder) {
this.mCallback = builder.closeCallback;
this.mFloatingAnimation = builder.floatingAnimation;
this.mSizeTolerance = (int) (context.getResources().getDisplayMetrics().density * TOLERANCE_VALUE);
this.mCanScroll = builder.canScroll;
this.mOnClickListener = builder.onClickListener;

if (builder.typeface != null) {
mTypeface = builder.typeface;
Expand Down Expand Up @@ -641,6 +648,11 @@ public void setTextColor(final ColorStateList color) {
}
}

@Override
public TextView getTextView() {
return mTextView;
}

@Override
public boolean isAttached() {
return mAttached;
Expand Down Expand Up @@ -823,6 +835,14 @@ private void initializeView() {
if (!mIsCustomView && mTextViewElevation > 0 && Build.VERSION.SDK_INT >= 21) {
setupElevation();
}

if (mCanScroll) {
mTextView.setMovementMethod(ScrollingMovementMethod.getInstance());
}

if (mOnClickListener != null) {
mTextView.setOnClickListener(mOnClickListener);
}
}

private void showInternal() {
Expand Down Expand Up @@ -1477,6 +1497,8 @@ public static final class Builder {
boolean overlay = true;
AnimationBuilder floatingAnimation;
Typeface typeface;
boolean canScroll;
View.OnClickListener onClickListener;

public Builder(int id) {
this.id = id;
Expand Down Expand Up @@ -1651,6 +1673,16 @@ public Builder showDelay(long ms) {
return this;
}

public Builder canScroll(boolean enabled) {
this.canScroll = enabled;
return this;
}

public Builder onClickListener(View.OnClickListener onClickListener) {
this.onClickListener = onClickListener;
return this;
}

public Builder build() {
throwIfCompleted();
if (floatingAnimation != null) {
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/layout/tooltip_textview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
android:layout_height="wrap_content"
android:autoLink="all"
android:clipToPadding="false"
android:scrollbars="vertical"
android:textAppearance="?android:attr/textAppearanceSmallInverse" />
</FrameLayout>