Commit 5457d13c authored by estade's avatar estade Committed by Commit bot

Add CVC icon to card unmasking prompt

(placeholder images inserted, bug 454009 filed)

Also, move CardUnmaskPrompt.java to proper location.

BUG=454009

Review URL: https://codereview.chromium.org/887153003

Cr-Commit-Position: refs/heads/master@{#314393}
parent 5d4e9ddd
...@@ -47,10 +47,17 @@ ...@@ -47,10 +47,17 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:ems="4" android:ems="4"
android:hint="@string/card_unmask_input_hint" /> android:hint="@string/card_unmask_input_hint" />
<ImageView
android:id="@+id/cvc_hint_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp" />
<ProgressBar <ProgressBar
style="@android:style/Widget.ProgressBar.Small" style="@android:style/Widget.ProgressBar.Small"
android:id="@+id/verification_progress_bar" android:id="@+id/verification_progress_bar"
......
...@@ -9,8 +9,8 @@ import android.os.Handler; ...@@ -9,8 +9,8 @@ import android.os.Handler;
import org.chromium.base.CalledByNative; import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace; import org.chromium.base.JNINamespace;
import org.chromium.ui.autofill.CardUnmaskPrompt; import org.chromium.chrome.browser.ResourceId;
import org.chromium.ui.autofill.CardUnmaskPrompt.CardUnmaskPromptDelegate; import org.chromium.chrome.browser.autofill.CardUnmaskPrompt.CardUnmaskPromptDelegate;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
/** /**
...@@ -22,7 +22,8 @@ public class CardUnmaskBridge implements CardUnmaskPromptDelegate { ...@@ -22,7 +22,8 @@ public class CardUnmaskBridge implements CardUnmaskPromptDelegate {
private final CardUnmaskPrompt mCardUnmaskPrompt; private final CardUnmaskPrompt mCardUnmaskPrompt;
public CardUnmaskBridge(long nativeCardUnmaskPromptViewAndroid, String title, public CardUnmaskBridge(long nativeCardUnmaskPromptViewAndroid, String title,
String instructions, boolean shouldRequestExpirationDate, WindowAndroid windowAndroid) { String instructions, int iconId, boolean shouldRequestExpirationDate,
WindowAndroid windowAndroid) {
mNativeCardUnmaskPromptViewAndroid = nativeCardUnmaskPromptViewAndroid; mNativeCardUnmaskPromptViewAndroid = nativeCardUnmaskPromptViewAndroid;
Activity activity = windowAndroid.getActivity().get(); Activity activity = windowAndroid.getActivity().get();
if (activity == null) { if (activity == null) {
...@@ -36,15 +37,16 @@ public class CardUnmaskBridge implements CardUnmaskPromptDelegate { ...@@ -36,15 +37,16 @@ public class CardUnmaskBridge implements CardUnmaskPromptDelegate {
} }
}); });
} else { } else {
mCardUnmaskPrompt = new CardUnmaskPrompt( mCardUnmaskPrompt = new CardUnmaskPrompt(activity, this, title, instructions,
activity, this, title, instructions, shouldRequestExpirationDate); ResourceId.mapToDrawableId(iconId), shouldRequestExpirationDate);
} }
} }
@CalledByNative @CalledByNative
private static CardUnmaskBridge create(long nativeUnmaskPrompt, String title, private static CardUnmaskBridge create(long nativeUnmaskPrompt, String title,
String instructions, boolean shouldRequestExpirationDate, WindowAndroid windowAndroid) { String instructions, int iconId, boolean shouldRequestExpirationDate,
return new CardUnmaskBridge(nativeUnmaskPrompt, title, instructions, WindowAndroid windowAndroid) {
return new CardUnmaskBridge(nativeUnmaskPrompt, title, instructions, iconId,
shouldRequestExpirationDate, windowAndroid); shouldRequestExpirationDate, windowAndroid);
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.ui.autofill; package org.chromium.chrome.browser.autofill;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
...@@ -16,11 +16,12 @@ import android.view.inputmethod.InputMethodManager; ...@@ -16,11 +16,12 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import org.chromium.ui.R; import org.chromium.chrome.R;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.Calendar; import java.util.Calendar;
...@@ -62,7 +63,7 @@ public class CardUnmaskPrompt implements DialogInterface.OnDismissListener, Text ...@@ -62,7 +63,7 @@ public class CardUnmaskPrompt implements DialogInterface.OnDismissListener, Text
} }
public CardUnmaskPrompt(Context context, CardUnmaskPromptDelegate delegate, String title, public CardUnmaskPrompt(Context context, CardUnmaskPromptDelegate delegate, String title,
String instructions, boolean shouldRequestExpirationDate) { String instructions, int drawableId, boolean shouldRequestExpirationDate) {
mDelegate = delegate; mDelegate = delegate;
LayoutInflater inflater = LayoutInflater.from(context); LayoutInflater inflater = LayoutInflater.from(context);
...@@ -74,6 +75,7 @@ public class CardUnmaskPrompt implements DialogInterface.OnDismissListener, Text ...@@ -74,6 +75,7 @@ public class CardUnmaskPrompt implements DialogInterface.OnDismissListener, Text
mYearSpinner = (Spinner) v.findViewById(R.id.expiration_year); mYearSpinner = (Spinner) v.findViewById(R.id.expiration_year);
mVerificationProgressBar = (ProgressBar) v.findViewById(R.id.verification_progress_bar); mVerificationProgressBar = (ProgressBar) v.findViewById(R.id.verification_progress_bar);
mVerificationView = (TextView) v.findViewById(R.id.verification_message); mVerificationView = (TextView) v.findViewById(R.id.verification_message);
((ImageView) v.findViewById(R.id.cvc_hint_image)).setImageResource(drawableId);
mDialog = new AlertDialog.Builder(context) mDialog = new AlertDialog.Builder(context)
.setTitle(title) .setTitle(title)
...@@ -207,7 +209,7 @@ public class CardUnmaskPrompt implements DialogInterface.OnDismissListener, Text ...@@ -207,7 +209,7 @@ public class CardUnmaskPrompt implements DialogInterface.OnDismissListener, Text
private boolean areInputsValid() { private boolean areInputsValid() {
if (mShouldRequestExpirationDate if (mShouldRequestExpirationDate
&& (mMonthSpinner.getSelectedItemPosition() == 0 && (mMonthSpinner.getSelectedItemPosition() == 0
|| mYearSpinner.getSelectedItemPosition() == 0)) { || mYearSpinner.getSelectedItemPosition() == 0)) {
return false; return false;
} }
return mDelegate.checkUserInputValidity(mCardUnmaskInput.getText().toString()); return mDelegate.checkUserInputValidity(mCardUnmaskInput.getText().toString());
......
...@@ -51,5 +51,7 @@ DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_GENERIC, R.drawable.generic_card) ...@@ -51,5 +51,7 @@ DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_GENERIC, R.drawable.generic_card)
DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_MASTERCARD, R.drawable.mc_card) DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_MASTERCARD, R.drawable.mc_card)
DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_VISA, R.drawable.visa_card) DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_VISA, R.drawable.visa_card)
DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_SCAN_NEW, android.R.drawable.ic_menu_camera) DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_SCAN_NEW, android.R.drawable.ic_menu_camera)
DEFINE_RESOURCE_ID(IDR_CREDIT_CARD_CVC_HINT, R.drawable.cvc_icon)
DEFINE_RESOURCE_ID(IDR_CREDIT_CARD_CVC_HINT_AMEX, R.drawable.cvc_icon_amex)
#endif // CHROME_BROWSER_ANDROID_RESOURCE_ID_H_ #endif // CHROME_BROWSER_ANDROID_RESOURCE_ID_H_
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/ui/android/autofill/card_unmask_prompt_view_android.h" #include "chrome/browser/ui/android/autofill/card_unmask_prompt_view_android.h"
#include "chrome/browser/android/resource_mapper.h"
#include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "jni/CardUnmaskBridge_jni.h" #include "jni/CardUnmaskBridge_jni.h"
...@@ -43,7 +44,9 @@ void CardUnmaskPromptViewAndroid::Show() { ...@@ -43,7 +44,9 @@ void CardUnmaskPromptViewAndroid::Show() {
env, controller_->GetInstructionsMessage()); env, controller_->GetInstructionsMessage());
java_object_.Reset(Java_CardUnmaskBridge_create( java_object_.Reset(Java_CardUnmaskBridge_create(
env, reinterpret_cast<intptr_t>(this), dialog_title.obj(), env, reinterpret_cast<intptr_t>(this), dialog_title.obj(),
instructions.obj(), controller_->ShouldRequestExpirationDate(), instructions.obj(),
ResourceMapper::MapFromChromiumId(controller_->GetCvcImageRid()),
controller_->ShouldRequestExpirationDate(),
view_android->GetWindowAndroid()->GetJavaObject().obj())); view_android->GetWindowAndroid()->GetJavaObject().obj()));
Java_CardUnmaskBridge_show(env, java_object_.obj()); Java_CardUnmaskBridge_show(env, java_object_.obj());
......
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