Commit d0803376 authored by csashi's avatar csashi Committed by Commit bot

Clears Android keyboard when user touches any of the dropdown menu views.

Both Local Credit Card and Server Credit card forms have a billing
address.
The Local Credit Card form additionally has the expiration date and expiration month.

BUG=623563

Review-Url: https://chromiumcodereview.appspot.com/2437143004
Cr-Commit-Position: refs/heads/master@{#426927}
parent 8397f04a
...@@ -72,4 +72,15 @@ abstract class AutofillCreditCardEditor extends AutofillEditorBase { ...@@ -72,4 +72,15 @@ abstract class AutofillCreditCardEditor extends AutofillEditorBase {
return v; return v;
} }
@Override
protected void initializeButtons(View v) {
super.initializeButtons(v);
mBillingAddress.setOnItemSelectedListener(this);
// Listen for touch events on billing address field. We clear the keyboard when user touches
// the billing address field because it is a drop down menu.
mBillingAddress.setOnTouchListener(this);
}
} }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.preferences.autofill; package org.chromium.chrome.browser.preferences.autofill;
import android.annotation.SuppressLint;
import android.app.Fragment; import android.app.Fragment;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
...@@ -13,12 +14,16 @@ import android.view.LayoutInflater; ...@@ -13,12 +14,16 @@ import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener; import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button; import android.widget.Button;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.Spinner;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.payments.ui.EditorView; import org.chromium.chrome.browser.payments.ui.EditorView;
...@@ -27,7 +32,7 @@ import org.chromium.chrome.browser.widget.DualControlLayout; ...@@ -27,7 +32,7 @@ import org.chromium.chrome.browser.widget.DualControlLayout;
/** Base class for Autofill editors (e.g. credit cards and profiles). */ /** Base class for Autofill editors (e.g. credit cards and profiles). */
public abstract class AutofillEditorBase public abstract class AutofillEditorBase
extends Fragment implements OnItemSelectedListener, TextWatcher { extends Fragment implements OnItemSelectedListener, OnTouchListener, TextWatcher {
/** GUID of the profile we are editing. Empty if creating a new profile. */ /** GUID of the profile we are editing. Empty if creating a new profile. */
protected String mGUID; protected String mGUID;
...@@ -86,6 +91,18 @@ public abstract class AutofillEditorBase ...@@ -86,6 +91,18 @@ public abstract class AutofillEditorBase
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
// Process touch event on spinner views so we can clear the keyboard.
@Override
@SuppressLint("ClickableViewAccessibility")
public boolean onTouch(View v, MotionEvent event) {
if (v instanceof Spinner) {
InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
return false;
}
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear(); menu.clear();
......
...@@ -188,7 +188,11 @@ public class AutofillLocalCardEditor extends AutofillCreditCardEditor { ...@@ -188,7 +188,11 @@ public class AutofillLocalCardEditor extends AutofillCreditCardEditor {
mNumberText.addTextChangedListener(this); mNumberText.addTextChangedListener(this);
mExpirationMonth.setOnItemSelectedListener(this); mExpirationMonth.setOnItemSelectedListener(this);
mExpirationYear.setOnItemSelectedListener(this); mExpirationYear.setOnItemSelectedListener(this);
mBillingAddress.setOnItemSelectedListener(this);
// Listen for touch events for drop down menus. We clear the keyboard when user touches
// any of these fields.
mExpirationMonth.setOnTouchListener(this);
mExpirationYear.setOnTouchListener(this);
} }
private void updateSaveButtonEnabled() { private void updateSaveButtonEnabled() {
......
...@@ -279,6 +279,10 @@ public class AutofillProfileEditor extends AutofillEditorBase { ...@@ -279,6 +279,10 @@ public class AutofillProfileEditor extends AutofillEditorBase {
mEmailText.addTextChangedListener(this); mEmailText.addTextChangedListener(this);
mCountriesDropdown.setOnItemSelectedListener(this); mCountriesDropdown.setOnItemSelectedListener(this);
mNoCountryItemIsSelected = true; mNoCountryItemIsSelected = true;
// Listen for touch events on country field. We clear the keyboard when user touches
// the country field because it is a drop down menu.
mCountriesDropdown.setOnTouchListener(this);
} }
private void setSaveButtonEnabled(boolean enabled) { private void setSaveButtonEnabled(boolean enabled) {
......
...@@ -99,10 +99,4 @@ public class AutofillServerCardEditor extends AutofillCreditCardEditor { ...@@ -99,10 +99,4 @@ public class AutofillServerCardEditor extends AutofillCreditCardEditor {
protected boolean getIsDeletable() { protected boolean getIsDeletable() {
return false; return false;
} }
@Override
protected void initializeButtons(View v) {
super.initializeButtons(v);
mBillingAddress.setOnItemSelectedListener(this);
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment