diff --git a/.travis.yml b/.travis.yml index e8bde60..5ae3121 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,9 @@ android: components: - tools - platform-tools - - build-tools-26.0.1 - - android-26 - - doc-26 + - build-tools-27.0.3 + - android-27 + - doc-27 cache: directories: diff --git a/README.md b/README.md index 997cc8c..2f986c0 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Simple yet powerful autocomplete behavior for `EditText`s, to avoid working with `MultiAutoCompleteTextView` APIs. ```groovy -compile 'com.otaliastudios:autocomplete:1.0.2' +implementation 'com.otaliastudios:autocomplete:1.0.3' ``` To see it in action, take a look at the sample app in the `sample` module. diff --git a/autocomplete/build.gradle b/autocomplete/build.gradle index 8b3c9b4..7a4f9b0 100644 --- a/autocomplete/build.gradle +++ b/autocomplete/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' // Required by bintray -version = '1.0.2' +version = '1.0.3' group = 'com.otaliastudios' android { @@ -28,11 +28,12 @@ android { } dependencies { - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + api "com.android.support:recyclerview-v7:$supportLibVersion" + + testImplementation 'junit:junit:4.12' + androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile "com.android.support:recyclerview-v7:$supportLibVersion" - testCompile 'junit:junit:4.12' } install { diff --git a/autocomplete/src/main/java/com/otaliastudios/autocomplete/Autocomplete.java b/autocomplete/src/main/java/com/otaliastudios/autocomplete/Autocomplete.java index 922113b..c39df76 100644 --- a/autocomplete/src/main/java/com/otaliastudios/autocomplete/Autocomplete.java +++ b/autocomplete/src/main/java/com/otaliastudios/autocomplete/Autocomplete.java @@ -1,6 +1,8 @@ package com.otaliastudios.autocomplete; import android.database.DataSetObserver; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Looper; @@ -13,6 +15,8 @@ import android.util.Log; import android.util.TypedValue; import android.view.Gravity; +import android.view.Window; +import android.view.WindowManager; import android.widget.EditText; import android.widget.PopupWindow; @@ -212,6 +216,27 @@ public void click(T item) { builder.clear(); } + /** + * Controls how the popup operates with an input method. + * + * If the popup is showing, calling this method will take effect only + * the next time the popup is shown. + * + * @param mode a {@link PopupWindow} input method mode + */ + public void setInputMethodMode(int mode) { + popup.setInputMethodMode(mode); + } + + /** + * Sets the operating mode for the soft input area. + * + * @param mode The desired mode, see {@link WindowManager.LayoutParams#softInputMode} + */ + public void setSoftInputMode(int mode) { + popup.setSoftInputMode(mode); + } + /** * Shows the popup with the given query. * There is rarely need to call this externally: it is already triggered by events on the anchor. diff --git a/autocomplete/src/main/java/com/otaliastudios/autocomplete/AutocompletePopup.java b/autocomplete/src/main/java/com/otaliastudios/autocomplete/AutocompletePopup.java index 9168d36..f12afd7 100644 --- a/autocomplete/src/main/java/com/otaliastudios/autocomplete/AutocompletePopup.java +++ b/autocomplete/src/main/java/com/otaliastudios/autocomplete/AutocompletePopup.java @@ -342,7 +342,11 @@ void show() { // Update. mPopup.setOutsideTouchable(isOutsideTouchable()); - mPopup.update(getAnchorView(), mHorizontalOffset, mVerticalOffset, widthSpec, heightSpec); + if (heightSpec == 0) { + dismiss(); + } else { + mPopup.update(getAnchorView(), mHorizontalOffset, mVerticalOffset, widthSpec, heightSpec); + } } else { int widthSpec; diff --git a/build.gradle b/build.gradle index 045f257..349c6a4 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' + classpath 'com.android.tools.build:gradle:3.1.1' // https://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en // https://www.theguardian.com/technology/developer-blog/2016/dec/06/how-to-publish-an-android-library-a-mysterious-conversation classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' @@ -25,11 +25,11 @@ allprojects { } ext { - compileSdkVersion = 26 - buildToolsVersion = "26.0.1" - supportLibVersion = '26.0.2' + compileSdkVersion = 27 + buildToolsVersion = "27.0.3" + supportLibVersion = '27.1.1' minSdkVersion = 14 - targetSdkVersion = 26 + targetSdkVersion = 27 } task clean(type: Delete) { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ee3d1c5..e7ae00f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip