Skip to content

Commit

Permalink
Updated library to 1.0.0-alpha06-SNAPSHOT
Browse files Browse the repository at this point in the history
PopupWindow#showAtLocation for android 10 to fast fix tooltip position updating #60
Fixed setting compound drawables for pre 17 API for simple Tooltip
  • Loading branch information
ViHtarb committed Feb 14, 2020
1 parent ef802ca commit 56a5065
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0-rc01'
classpath 'com.android.tools.build:gradle:4.0.0-alpha09'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
7 changes: 6 additions & 1 deletion core/src/main/java/com/tooltip/core/Tooltip.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import android.graphics.RectF;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.view.ViewTreeObserverCompat;
import android.util.Log;
import android.view.Gravity;
Expand Down Expand Up @@ -203,7 +204,11 @@ public void show() {
mAnchorView.addOnAttachStateChangeListener(mOnAttachStateChangeListener);
mAnchorView.post(() -> {
if (mAnchorView.isShown()) {
mPopupWindow.showAsDropDown(mAnchorView);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
mPopupWindow.showAtLocation(mAnchorView, Gravity.NO_GRAVITY, 0, 0);
} else {
mPopupWindow.showAsDropDown(mAnchorView);
}
} else {
Log.e(TAG, "Tooltip cannot be shown, root view is invalid or has been closed");
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android.useAndroidX=true
android.enableJetifier=true

#-SNAPSHOT
version=1.0.0-alpha05-SNAPSHOT
version=1.0.0-alpha06-SNAPSHOT
group=com.github.vihtarb

POM_DESCRIPTION=Android Tooltips library based on PopupWindow.
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 @@
#Thu Jan 02 16:30:15 EET 2020
#Fri Feb 14 00:41:25 EET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-rc-1-all.zip
3 changes: 2 additions & 1 deletion library/src/main/java/com/tooltip/Tooltip.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.view.ViewCompat;
import androidx.core.widget.TextViewCompat;

/**
* Simple text {@code Tooltip} implementation
Expand All @@ -62,11 +63,11 @@ private Tooltip(Builder builder) {
protected View createContentView(@NonNull Builder builder) {
AppCompatTextView textView = new AppCompatTextView(mContext);
textView.setTextAppearance(mContext, builder.mTextAppearance);
textView.setCompoundDrawablesRelativeWithIntrinsicBounds(builder.mDrawableStart, builder.mDrawableTop, builder.mDrawableEnd, builder.mDrawableBottom);
textView.setText(builder.mText);
textView.setPadding(builder.mPadding, builder.mPadding, builder.mPadding, builder.mPadding);
textView.setLineSpacing(builder.mLineSpacingExtra, builder.mLineSpacingMultiplier);
textView.setCompoundDrawablePadding(builder.mDrawablePadding);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(textView, builder.mDrawableStart, builder.mDrawableTop, builder.mDrawableEnd, builder.mDrawableBottom);

if (builder.mTextStyle >= 0) {
textView.setTypeface(Typeface.create(textView.getTypeface(), builder.mTextStyle));
Expand Down

0 comments on commit 56a5065

Please sign in to comment.