Skip to content

Commit

Permalink
Merge pull request #51 from seatgeek/pr-extract_mode_fix
Browse files Browse the repository at this point in the history
Update versions and add in override from TextInputEditText to fix extract mode hint
  • Loading branch information
sddamico committed Jul 25, 2017
2 parents 1d51ccc + a77526d commit acf857b
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 29 deletions.
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
language: android
android:
components:
- build-tools-21.1.2
- extra-android-m2repository
- extra-google-m2repository
- android-21
- tools
- platform-tools
- tools
- build-tools-26.0.1
- extra-android-m2repository
- extra-google-m2repository
- android-26
jdk:
- oraclejdk8
before_install:
Expand Down
3 changes: 3 additions & 0 deletions demo-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ buildscript {

repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}

apply plugin: 'com.android.application'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.seatgeek.placesautocompletedemo;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;

Expand All @@ -16,7 +16,7 @@
import butterknife.ButterKnife;
import butterknife.InjectView;

public class PlacesAutocompleteActivity extends Activity {
public class PlacesAutocompleteActivity extends AppCompatActivity {

@InjectView(R.id.autocomplete)
PlacesAutocompleteTextView mAutocomplete;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="16dp"
android:hint="Address"
app:pacv_languageCode="en"
app:pacv_resultType="no_type"
app:pacv_googleMapsApiKey="@string/google_maps_api_key"
Expand Down
4 changes: 2 additions & 2 deletions demo-app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>

<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<item name="pacv_placesAutoCompleteTextViewStyle">@android:style/Widget.Material.EditText</item>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">"
<item name="pacv_placesAutoCompleteTextViewStyle">@style/Widget.AppCompat.EditText</item>
</style>

</resources>
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=seatgeek
POM_DEVELOPER_NAME=SeatGeek, Inc

ANDROID_PLUGIN_VERSION=1.3.0
BUILD_TOOLS_VERSION=21.1.2
SUPPORT_LIBRARY_VERSION=22.2.1
TARGET_SDK_VERSION=21
ANDROID_PLUGIN_VERSION=2.3.3
BUILD_TOOLS_VERSION=26.0.1
SUPPORT_LIBRARY_VERSION=26.0.0
TARGET_SDK_VERSION=26
MIN_SDK_VERSION=14
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 @@
#Sun Jan 18 10:56:08 EST 2015
#Mon Jul 24 16:31:52 EDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
6 changes: 5 additions & 1 deletion placesautocomplete/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ apply plugin: 'com.bmuschko.nexus'

repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}

android {
Expand All @@ -39,7 +42,8 @@ android {
}

dependencies {
compile "com.android.support:support-v4:${SUPPORT_LIBRARY_VERSION}"
compile "com.android.support:appcompat-v7:${SUPPORT_LIBRARY_VERSION}"
compile "com.android.support:design:${SUPPORT_LIBRARY_VERSION}"
provided 'com.google.code.gson:gson:2.3.1'
provided 'com.squareup.okhttp:okhttp:2.2.0'
testCompile 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package com.seatgeek.placesautocomplete;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.location.Location;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TextInputLayout;
import android.support.v7.widget.AppCompatAutoCompleteTextView;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.InflateException;
import android.view.View;
import android.view.ViewParent;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.AdapterView;
import android.widget.AutoCompleteTextView;
import android.widget.Filterable;
import android.widget.ListAdapter;

Expand All @@ -30,7 +32,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class PlacesAutocompleteTextView extends AutoCompleteTextView {
public class PlacesAutocompleteTextView extends AppCompatAutoCompleteTextView {

public static final boolean DEBUG = true;

Expand Down Expand Up @@ -90,16 +92,6 @@ public PlacesAutocompleteTextView(final Context context, final AttributeSet attr
init(context, attrs, defAttr, R.style.PACV_Widget_PlacesAutoCompleteTextView, null, context.getString(R.string.pacv_default_history_file_name));
}

/**
* Constructor for layout inflation
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public PlacesAutocompleteTextView(final Context context, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);

init(context, attrs, defStyleAttr, defStyleRes, null, context.getString(R.string.pacv_default_history_file_name));
}

// perform basic initialization of the view by fetching layout attributes and creating the api, etc.
private void init(@NonNull final Context context, final AttributeSet attrs, final int defAttr, final int defStyle, final String googleApiKey, final String historyFileName) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.PlacesAutocompleteTextView, defAttr, defStyle);
Expand Down Expand Up @@ -439,4 +431,23 @@ public void setLanguageCode(@Nullable String languageCode) {
this.languageCode = languageCode;
api.setLanguageCode(this.languageCode);
}

// Copied from TextInputEditText to ensure extract mode hint works
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
final InputConnection ic = super.onCreateInputConnection(outAttrs);
if (ic != null && outAttrs.hintText == null) {
// If we don't have a hint and our parent is a TextInputLayout, use it's hint for the
// EditorInfo. This allows us to display a hint in 'extract mode'.
ViewParent parent = getParent();
while (parent instanceof View) {
if (parent instanceof TextInputLayout) {
outAttrs.hintText = ((TextInputLayout) parent).getHint();
break;
}
parent = parent.getParent();
}
}
return ic;
}
}

0 comments on commit acf857b

Please sign in to comment.