diff options
author | yusufo@chromium.org <yusufo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-01 20:12:36 +0000 |
---|---|---|
committer | yusufo@chromium.org <yusufo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-01 20:12:36 +0000 |
commit | 6ab1d3a16a9949ee4ff28b72d3f4736f1b5e1de9 (patch) | |
tree | 97b8be1185112af616c7394b5783f4e5ce80ed04 /chrome/android/java | |
parent | 05be8cd4ee9129aa4422602c7db88416af2f914d (diff) | |
download | chromium_src-6ab1d3a16a9949ee4ff28b72d3f4736f1b5e1de9.zip chromium_src-6ab1d3a16a9949ee4ff28b72d3f4736f1b5e1de9.tar.gz chromium_src-6ab1d3a16a9949ee4ff28b72d3f4736f1b5e1de9.tar.bz2 |
Glue the label strings for each section and start using all of them
We were just using three labels before with placeholders. This glues the
native strings to java and starts putting labels for each section.
BUG=225057
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/13254006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191647 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/android/java')
6 files changed, 104 insertions, 18 deletions
diff --git a/chrome/android/java/res/layout/autofill_general_layout.xml b/chrome/android/java/res/layout/autofill_general_layout.xml index 6884d48..366f1a5 100644 --- a/chrome/android/java/res/layout/autofill_general_layout.xml +++ b/chrome/android/java/res/layout/autofill_general_layout.xml @@ -11,52 +11,79 @@ android:columnCount="4"> <CheckBox android:id="@+id/top_notification" - android:padding="5dp" - android:textSize="12sp" + android:padding="@dimen/autofill_steady_margin" + android:textSize="@dimen/autofill_notification_text_size" android:visibility="gone" android:layout_columnSpan="4"/> + <TextView + android:id="@+id/email_label" + android:layout_marginLeft="@dimen/autofill_steady_margin" + android:layout_columnSpan="2" + android:textStyle="bold" + android:textSize="@dimen/autofill_steady_text_size"/> + <Space + android:layout_gravity="fill" + android:layout_columnSpan="2"/> <Spinner - android:layout_margin="5dp" + android:layout_margin="@dimen/autofill_steady_margin" android:id="@+id/email_spinner" android:visibility="gone" android:layout_gravity="fill_horizontal" android:layout_columnSpan="4"/> <TextView - android:text="@string/autofill_billing_title" - android:id="@+id/billing_title" - android:layout_marginLeft="5dp" + android:id="@+id/cc_billing_label" + android:layout_marginLeft="@dimen/autofill_steady_margin" android:layout_columnSpan="2" - android:textSize="14sp"/> + android:textStyle="bold" + android:textSize="@dimen/autofill_steady_text_size"/> <Space android:layout_gravity="fill" android:layout_columnSpan="2"/> <Spinner - android:layout_margin="5dp" + android:layout_margin="@dimen/autofill_steady_margin" android:id="@+id/cc_billing_spinner" android:layout_gravity="fill_horizontal" android:layout_columnSpan="4"/> + <TextView + android:id="@+id/cc_label" + android:layout_marginLeft="@dimen/autofill_steady_margin" + android:layout_columnSpan="2" + android:textStyle="bold" + android:textSize="@dimen/autofill_steady_text_size"/> + <Space + android:layout_gravity="fill" + android:layout_columnSpan="2"/> <Spinner - android:layout_margin="5dp" + android:layout_margin="@dimen/autofill_steady_margin" android:id="@+id/cc_spinner" android:layout_gravity="fill_horizontal" android:layout_columnSpan="4"/> + <TextView + android:id="@+id/billing_label" + android:layout_marginLeft="@dimen/autofill_steady_margin" + android:layout_columnSpan="2" + android:textStyle="bold" + android:textSize="@dimen/autofill_steady_text_size"/> + <Space + android:layout_gravity="fill" + android:layout_columnSpan="2"/> <Spinner - android:layout_margin="5dp" + android:layout_margin="@dimen/autofill_steady_margin" android:id="@+id/billing_spinner" android:layout_gravity="fill_horizontal" android:visibility="gone" android:layout_columnSpan="4"/> <TextView - android:text="@string/autofill_shipping_title" - android:id="@+id/shipping_title" - android:layout_marginLeft="5dp" + android:id="@+id/shipping_label" + android:layout_marginLeft="@dimen/autofill_steady_margin" android:layout_columnSpan="2" - android:textSize="14sp"/> + android:textStyle="bold" + android:textSize="@dimen/autofill_steady_text_size"/> <Space android:layout_gravity="fill" android:layout_columnSpan="2"/> <Spinner - android:layout_margin="5dp" + android:layout_margin="@dimen/autofill_steady_margin" android:id="@+id/address_spinner" android:layout_gravity="fill_horizontal" android:layout_columnSpan="4"/> @@ -75,7 +102,7 @@ android:padding="10dp" android:visibility="gone" android:id="@+id/terms_info" - android:textSize="11sp" + android:textSize="@dimen/autofill_notification_text_size" android:background="?android:attr/selectableItemBackground" android:drawableRight="@drawable/arrow" android:layout_columnSpan="4" diff --git a/chrome/android/java/res/values/dimens.xml b/chrome/android/java/res/values/dimens.xml index 54fafca..174729f 100644 --- a/chrome/android/java/res/values/dimens.xml +++ b/chrome/android/java/res/values/dimens.xml @@ -23,10 +23,12 @@ <!-- Autofill Dialog --> <dimen name="autofill_edit_margin">2dp</dimen> + <dimen name="autofill_steady_margin">5dp</dimen> <dimen name="autofill_edit_text_size">18sp</dimen> <dimen name="autofill_edit_height">48dp</dimen> <dimen name="autofill_menu_item_size">44dp</dimen> <dimen name="autofill_notification_padding">5dp</dimen> <dimen name="autofill_notification_text_size">12sp</dimen> + <dimen name="autofill_steady_text_size">14sp</dimen> <dimen name="autofill_translation_anim_distance">300dp</dimen> </resources> 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 5fcbef4e..4248dc7 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 @@ -98,6 +98,13 @@ public class AutofillDialog extends AlertDialog * Informs AutofillDialog controller that the user clicked on the cancel button. */ public void dialogCancel(); + + /** + * Returns the label string to be used for the given section. + * @param section Section for which the label should be returned. + * @return The string that should appear on the label for the given section. + */ + public String getLabelForSection(int section); } protected AutofillDialog(Context context, AutofillDialogDelegate delegate) { @@ -109,6 +116,11 @@ public class AutofillDialog extends AlertDialog ScrollView scroll = new ScrollView(context); mContentView = (AutofillDialogContentView) getLayoutInflater(). inflate(R.layout.autofill_dialog_content, null); + String[] labels = new String[AutofillDialogConstants.NUM_SECTIONS]; + for (int i = 0; i < AutofillDialogConstants.NUM_SECTIONS; i++) { + labels[i] = mDelegate.getLabelForSection(i); + } + mContentView.initializeLabelsForEachSection(labels); scroll.addView(mContentView); setView(scroll); Resources resources = context.getResources(); 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 fcd7ae3..3928f46 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 @@ -47,6 +47,7 @@ public class AutofillDialogContentView extends LinearLayout { static final int LAYOUT_EDITING_CC_BILLING = 3; static final int LAYOUT_FETCHING = 4; static final int LAYOUT_STEADY = 5; + private final Runnable mDismissSteadyLayoutRunnable = new Runnable() { @Override public void run() { @@ -82,6 +83,18 @@ public class AutofillDialogContentView extends LinearLayout { changeLayoutTo(LAYOUT_FETCHING); } + /** + * Initializes the labels for each section. + * @param labels The label strings to be used for each section. + */ + public void initializeLabelsForEachSection(String[] labels) { + TextView labelView; + for (int i = 0; i < labels.length && i < NUM_SECTIONS; i++) { + labelView = (TextView) findViewById(AutofillDialogUtils.getLabelIDForSection(i)); + labelView.setText(labels[i]); + } + } + @Override protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); @@ -182,6 +195,8 @@ public class AutofillDialogContentView extends LinearLayout { public void setVisibilityForSection(int section, boolean visible) { int visibility = visible ? VISIBLE : GONE; mSpinners[section].setVisibility(visibility); + View labelView = findViewById(AutofillDialogUtils.getLabelIDForSection(section)); + if (labelView != null) labelView.setVisibility(visibility); } private void addAppearAnimationForEditLayout(int mode, View layout) { diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java index 4ebca07..d79dc15 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java @@ -154,6 +154,11 @@ public class AutofillDialogGlue implements AutofillDialogDelegate { nativeDialogCancel(mNativeDialogPopup); } + @Override + public String getLabelForSection(int section) { + return nativeGetLabelForSection(mNativeDialogPopup, section); + } + // Helper methods for AutofillDialogField and AutofillDialogItem ------------------------------ @CalledByNative @@ -220,4 +225,6 @@ public class AutofillDialogGlue implements AutofillDialogDelegate { private native void nativeEditingCancel(int nativeAutofillDialogViewAndroid, int section); private native void nativeDialogSubmit(int nativeAutofillDialogViewAndroid); private native void nativeDialogCancel(int nativeAutofillDialogViewAndroid); + private native String nativeGetLabelForSection(int nativeAutofillDialogViewAndroid, + int section); } 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 4a29bb6..5555638 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 @@ -60,8 +60,7 @@ public class AutofillDialogUtils { } /** - * Returns the {@link ViewGroup} ID for the given section in the AutofillDialog - * layout + * Returns the {@link ViewGroup} ID for the given section in the AutofillDialog layout. * @param section The section to return the layout ID for. * @return The Android ID for the edit layout for the given section. */ @@ -84,6 +83,30 @@ public class AutofillDialogUtils { } /** + * Returns the label ID for the given section in the AutofillDialog + * layout + * @param section The section to return the label ID for. + * @return The Android ID for the label text for the given section. + */ + public static int getLabelIDForSection(int section) { + switch (section) { + case AutofillDialogConstants.SECTION_CC : + return R.id.cc_label; + case AutofillDialogConstants.SECTION_CC_BILLING : + return R.id.cc_billing_label; + case AutofillDialogConstants.SECTION_SHIPPING : + return R.id.shipping_label; + case AutofillDialogConstants.SECTION_BILLING : + return R.id.billing_label; + case AutofillDialogConstants.SECTION_EMAIL : + return R.id.email_label; + default: + assert(false); + return INVALID_ID; + } + } + + /** * Returns the {@link EditText} ID for the given field in the given section in the * AutofillDialog layout. * @param section The section that the field belongs to. |