| Index: chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogContentView.java
|
| 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 01a1bf2b763dfa96fe62c96c1ada5642cbeede94..fcd7ae31c91fab65ddc7d0db784118d2c24b2969 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
|
| @@ -8,7 +8,6 @@ import java.util.ArrayList;
|
| import java.util.List;
|
|
|
| import android.content.Context;
|
| -import android.graphics.BitmapFactory;
|
| import android.text.TextUtils;
|
| import android.util.AttributeSet;
|
| import android.view.View;
|
| @@ -17,7 +16,6 @@ import android.view.animation.Animation;
|
| import android.view.animation.AnimationSet;
|
| import android.view.animation.ScaleAnimation;
|
| import android.view.animation.TranslateAnimation;
|
| -import android.widget.AdapterView;
|
| import android.widget.ArrayAdapter;
|
| import android.widget.ImageView;
|
| import android.widget.LinearLayout;
|
| @@ -42,8 +40,6 @@ import org.chromium.chrome.R;
|
| 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.
|
| - private final AutofillDialogMenuItem[][] mDefaultMenuItems =
|
| - new AutofillDialogMenuItem[NUM_SECTIONS][];
|
| static final int INVALID_LAYOUT = -1;
|
| static final int LAYOUT_EDITING_SHIPPING = 0;
|
| static final int LAYOUT_EDITING_CC = 1;
|
| @@ -65,21 +61,6 @@ public class AutofillDialogContentView extends LinearLayout {
|
|
|
| public AutofillDialogContentView(Context context, AttributeSet attrs) {
|
| super(context, attrs);
|
| - AutofillDialogMenuItem[] billingItems = {
|
| - new AutofillDialogMenuItem(0,
|
| - getResources().getString(R.string.autofill_new_billing)),
|
| - new AutofillDialogMenuItem(0,
|
| - getResources().getString(R.string.autofill_edit_billing))
|
| - };
|
| - AutofillDialogMenuItem[] shippingItems = {
|
| - new AutofillDialogMenuItem(0,
|
| - getResources().getString(R.string.autofill_new_shipping)),
|
| - new AutofillDialogMenuItem(0,
|
| - getResources().getString(R.string.autofill_edit_shipping))
|
| - };
|
| -
|
| - mDefaultMenuItems[SECTION_CC_BILLING] = billingItems;
|
| - mDefaultMenuItems[SECTION_SHIPPING] = shippingItems;
|
| }
|
|
|
| @Override
|
| @@ -98,23 +79,9 @@ public class AutofillDialogContentView extends LinearLayout {
|
| mSpinners[i].setAdapter(adapter);
|
| }
|
|
|
| - createAndAddPlaceHolders();
|
| changeLayoutTo(LAYOUT_FETCHING);
|
| }
|
|
|
| - // TODO(yusufo): Remove this method once glue implements fetching data.
|
| - private void createAndAddPlaceHolders() {
|
| - AutofillDialogMenuItem[] ccItems = new AutofillDialogMenuItem[1];
|
| - ccItems[0] = new AutofillDialogMenuItem(
|
| - 0, "XXXX-XXXX-XXXX-1000", "Additional info required",
|
| - BitmapFactory.decodeResource(getResources(), R.drawable.visa));
|
| - AutofillDialogMenuItem[] addressItems = new AutofillDialogMenuItem[1];
|
| - addressItems[0] = new AutofillDialogMenuItem(
|
| - 0, "Place Holder", "1600 Amphitheatre Pkwy", null);
|
| - updateMenuItemsForSection(SECTION_CC_BILLING, ccItems);
|
| - updateMenuItemsForSection(SECTION_SHIPPING, addressItems);
|
| - }
|
| -
|
| @Override
|
| protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec) {
|
| super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
| @@ -137,35 +104,29 @@ public class AutofillDialogContentView extends LinearLayout {
|
| }
|
|
|
| /**
|
| - * @param spinner The dropdown that was selected by the user.
|
| - * @param section The section that the dropdown corresponds to.
|
| - * @param position The position for the selected item in the dropdown.
|
| - * @return Whether the selection should cause a layout state change.
|
| + * @return Whether the current layout is one of the editing layouts.
|
| */
|
| - public boolean selectionShouldChangeLayout(AdapterView<?> spinner, int section, int position) {
|
| - int numDefaultItems = mDefaultMenuItems[section] != null ?
|
| - mDefaultMenuItems[section].length : 0;
|
| - return position >= spinner.getCount() - numDefaultItems;
|
| + public boolean isInEditingMode() {
|
| + return mCurrentLayout != INVALID_LAYOUT &&
|
| + mCurrentLayout != LAYOUT_STEADY &&
|
| + mCurrentLayout != LAYOUT_FETCHING;
|
| }
|
|
|
| /**
|
| - * @return The current layout the content is showing.
|
| + * @return The current section if we are in editing mode, INVALID_SECTION otherwise.
|
| */
|
| - // TODO(yusufo): Consider restricting this access more to checks rather than the
|
| - // current value.
|
| - public int getCurrentLayout() {
|
| - return mCurrentLayout;
|
| + public int getCurrentSection() {
|
| + return getSectionForLayoutMode(mCurrentLayout);
|
| }
|
|
|
| /**
|
| * Updates a dropdown with the given items and adds default items to the end.
|
| * @param items The {@link AutofillDialogMenuItem} array to update the dropdown with.
|
| */
|
| - public void updateMenuItemsForSection(int section, AutofillDialogMenuItem[] items) {
|
| + public void updateMenuItemsForSection(int section, List<AutofillDialogMenuItem> items) {
|
| AutofillDialogMenuAdapter adapter = mAdapters[section];
|
| adapter.clear();
|
| adapter.addAll(items);
|
| - if (mDefaultMenuItems[section] != null) adapter.addAll(mDefaultMenuItems[section]);
|
| }
|
|
|
| /**
|
|
|