diff options
Diffstat (limited to 'chrome/android')
5 files changed, 53 insertions, 11 deletions
diff --git a/chrome/android/java/res/layout/autofill_dialog_content.xml b/chrome/android/java/res/layout/autofill_dialog_content.xml index 78ac88d..911fd72 100644 --- a/chrome/android/java/res/layout/autofill_dialog_content.xml +++ b/chrome/android/java/res/layout/autofill_dialog_content.xml @@ -9,9 +9,9 @@ android:layout_height="wrap_content"> <!--TODO(yusufo):Add accessibility content description for all actionable items--> <include layout="@layout/autofill_general_layout"/> + <include layout="@layout/autofill_editing_layout_email"/> <include layout="@layout/autofill_editing_layout_credit_card"/> <include layout="@layout/autofill_editing_layout_shipping"/> - <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/chrome/android/java/res/layout/autofill_editing_layout_email.xml b/chrome/android/java/res/layout/autofill_editing_layout_email.xml new file mode 100644 index 0000000..a8fcc7a --- /dev/null +++ b/chrome/android/java/res/layout/autofill_editing_layout_email.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (c) 2013 The Chromium Authors. All rights reserved. + + Use of this source code is governed by a BSD-style license that can be + found in the LICENSE file. +--> +<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/editing_layout_email" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:columnCount="4"> + <EditText + android:layout_height="@dimen/autofill_edit_height" + android:id="@+id/email_address" + android:layout_margin="@dimen/autofill_edit_margin" + android:textSize="@dimen/autofill_edit_text_size" + android:layout_gravity="fill_horizontal" + android:layout_columnSpan="4"/> +</GridLayout>
\ No newline at end of file diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialog.java index 26a227c..aba8753 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialog.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialog.java @@ -16,6 +16,7 @@ import android.util.TypedValue; import android.view.View; import android.view.View.OnFocusChangeListener; import android.view.ViewGroup; +import android.view.WindowManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.CheckBox; @@ -157,6 +158,7 @@ public class AutofillDialog extends AlertDialog protected AutofillDialog(Context context, AutofillDialogDelegate delegate, String useBillingForShippingText, String saveLocallyText) { super(context); + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); mDelegate = delegate; mTitleView = new AutofillDialogTitleView(getContext()); @@ -190,6 +192,12 @@ public class AutofillDialog extends AlertDialog mContentView.setOnItemSelectedListener(this); // TODO(aruslan): remove as part of the native model wrapper http://crbug.com/224162. + final AutofillDialogMenuItem[] emailItems = { + new AutofillDialogMenuItem(ADD_MENU_ITEM_INDEX, + resources.getString(R.string.autofill_new_email)), + new AutofillDialogMenuItem(EDIT_MENU_ITEM_INDEX, + resources.getString(R.string.autofill_edit_email)) + }; final AutofillDialogMenuItem[] ccItems = { new AutofillDialogMenuItem(ADD_MENU_ITEM_INDEX, resources.getString(R.string.autofill_new_credit_card)), @@ -215,7 +223,7 @@ public class AutofillDialog extends AlertDialog resources.getString(R.string.autofill_edit_shipping)) }; - // TODO(yusufo): http://crbug.com/226497 Need an email add/edit layout/something. + mDefaultMenuItems[AutofillDialogConstants.SECTION_EMAIL] = emailItems; mDefaultMenuItems[AutofillDialogConstants.SECTION_CC] = ccItems; mDefaultMenuItems[AutofillDialogConstants.SECTION_BILLING] = billingAddressItems; mDefaultMenuItems[AutofillDialogConstants.SECTION_CC_BILLING] = billingDetailsItems; diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogContentView.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogContentView.java index 7c487fd..83cd1f9 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogContentView.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogContentView.java @@ -26,6 +26,7 @@ import android.widget.TextView; import android.widget.AdapterView.OnItemSelectedListener; import static org.chromium.chrome.browser.autofill.AutofillDialogConstants.NUM_SECTIONS; +import static org.chromium.chrome.browser.autofill.AutofillDialogConstants.SECTION_EMAIL; import static org.chromium.chrome.browser.autofill.AutofillDialogConstants.SECTION_CC; import static org.chromium.chrome.browser.autofill.AutofillDialogConstants.SECTION_CC_BILLING; import static org.chromium.chrome.browser.autofill.AutofillDialogConstants.SECTION_BILLING; @@ -45,14 +46,14 @@ import java.util.List; */ public class AutofillDialogContentView extends LinearLayout { private static final int ANIMATION_DURATION_MS = 1000; - // TODO(yusufo): Remove all placeholders here and also in related layout xml files. static final int INVALID_LAYOUT = -1; - static final int LAYOUT_EDITING_SHIPPING = 0; - static final int LAYOUT_EDITING_CC = 1; - static final int LAYOUT_EDITING_BILLING = 2; - static final int LAYOUT_EDITING_CC_BILLING = 3; - static final int LAYOUT_FETCHING = 4; - static final int LAYOUT_STEADY = 5; + static final int LAYOUT_EDITING_EMAIL = 0; + static final int LAYOUT_EDITING_SHIPPING = 1; + static final int LAYOUT_EDITING_CC = 2; + static final int LAYOUT_EDITING_BILLING = 3; + static final int LAYOUT_EDITING_CC_BILLING = 4; + static final int LAYOUT_FETCHING = 5; + static final int LAYOUT_STEADY = 6; private final Runnable mDismissSteadyLayoutRunnable = new Runnable() { @Override public void run() { @@ -209,9 +210,20 @@ public class AutofillDialogContentView extends LinearLayout { * @param items The {@link AutofillDialogMenuItem} array to update the dropdown with. */ public void updateMenuItemsForSection(int section, List<AutofillDialogMenuItem> items) { + final Spinner spinner = mSpinners[section]; + final OnItemSelectedListener listener = spinner.getOnItemSelectedListener(); + // Set the listener to null and reset it after updating the menu items to avoid getting an + // onItemSelected call when the first item is selected after updating the items. + spinner.setOnItemSelectedListener(null); AutofillDialogMenuAdapter adapter = mAdapters[section]; adapter.clear(); adapter.addAll(items); + spinner.post(new Runnable() { + @Override + public void run() { + spinner.setOnItemSelectedListener(listener); + } + }); } /** @@ -323,6 +335,8 @@ public class AutofillDialogContentView extends LinearLayout { private static int getSectionForLayoutMode(int mode) { switch (mode) { + case LAYOUT_EDITING_EMAIL: + return SECTION_EMAIL; case LAYOUT_EDITING_CC: return SECTION_CC; case LAYOUT_EDITING_BILLING: diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogUtils.java index 1ede216..7c30747 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogUtils.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogUtils.java @@ -86,7 +86,7 @@ public class AutofillDialogUtils { case AutofillDialogConstants.SECTION_BILLING : return R.id.editing_layout_billing; case AutofillDialogConstants.SECTION_EMAIL : - return INVALID_ID; + return R.id.editing_layout_email; default: assert(false); return INVALID_ID; @@ -127,7 +127,8 @@ public class AutofillDialogUtils { public static int getViewIDForField(int section, int field) { switch (section) { case AutofillDialogConstants.SECTION_EMAIL : - return 0; + assert(field == AutofillDialogConstants.EMAIL_ADDRESS); + return R.id.email_address; case AutofillDialogConstants.SECTION_CC : switch (field) { case AutofillDialogConstants.CREDIT_CARD_NUMBER : |