OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.payments.ui; | 5 package org.chromium.chrome.browser.payments.ui; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
9 import android.view.LayoutInflater; | 9 import android.view.LayoutInflater; |
10 import android.view.View; | 10 import android.view.View; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 (MarginLayoutParams) pageInfoGroup.getLayoutParams(), titleEndMa
rgin); | 56 (MarginLayoutParams) pageInfoGroup.getLayoutParams(), titleEndMa
rgin); |
57 | 57 |
58 // Indicate that we're processing the data. | 58 // Indicate that we're processing the data. |
59 TextView messageView = (TextView) mResultLayout.findViewById(R.id.messag
e); | 59 TextView messageView = (TextView) mResultLayout.findViewById(R.id.messag
e); |
60 messageView.setText(R.string.payments_processing_message); | 60 messageView.setText(R.string.payments_processing_message); |
61 } | 61 } |
62 | 62 |
63 /** | 63 /** |
64 * Updates the UI to display whether or not the payment request was successf
ul. | 64 * Updates the UI to display whether or not the payment request was successf
ul. |
65 * | 65 * |
66 * @param paymentSuccess Whether or not the payment request was successful. | 66 * @param shouldCloseImmediately If true, this function will immediately dis
miss the dialog |
67 * @param callback Callback to run upon dismissal. | 67 * without describing the error. |
| 68 * @param callback Callback to run upon dismissal. |
68 */ | 69 */ |
69 public void update(boolean paymentSuccess, final Runnable callback) { | 70 public void update(boolean shouldCloseImmediately, final Runnable callback)
{ |
70 if (mResultLayout.getParent() == null || paymentSuccess) { | 71 if (mResultLayout.getParent() == null || shouldCloseImmediately) { |
71 // Dismiss the dialog immediately. | 72 // The shouldCloseImmediately boolean is true when the merchant call
s |
| 73 // instrumentResponse.complete("success") or instrumentResponse.comp
lete("") |
| 74 // in JavaScript. |
72 callback.run(); | 75 callback.run(); |
73 } else { | 76 } else { |
74 // Describe the error. | 77 // Describe the error. |
75 Context context = mResultLayout.getContext(); | 78 Context context = mResultLayout.getContext(); |
76 TextView resultMessage = (TextView) mResultLayout.findViewById(R.id.
message); | 79 TextView resultMessage = (TextView) mResultLayout.findViewById(R.id.
message); |
77 resultMessage.setText(context.getString(R.string.payments_error_mess
age)); | 80 resultMessage.setText(context.getString(R.string.payments_error_mess
age)); |
78 resultMessage.setTextColor(ApiCompatibilityUtils.getColor( | 81 resultMessage.setTextColor(ApiCompatibilityUtils.getColor( |
79 context.getResources(), R.color.error_text_color)); | 82 context.getResources(), R.color.error_text_color)); |
80 ApiCompatibilityUtils.setTextAlignment(resultMessage, View.TEXT_ALIG
NMENT_VIEW_START); | 83 ApiCompatibilityUtils.setTextAlignment(resultMessage, View.TEXT_ALIG
NMENT_VIEW_START); |
81 | 84 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 * TODO(dfalcantara): The dialog should listen for configuration changes and
resize accordingly. | 126 * TODO(dfalcantara): The dialog should listen for configuration changes and
resize accordingly. |
124 */ | 127 */ |
125 public static int computeMaxWidth(Context context, int availableWidth, int a
vailableHeight) { | 128 public static int computeMaxWidth(Context context, int availableWidth, int a
vailableHeight) { |
126 int baseUnit = context.getResources().getDimensionPixelSize(R.dimen.dial
og_width_unit); | 129 int baseUnit = context.getResources().getDimensionPixelSize(R.dimen.dial
og_width_unit); |
127 int maxSize = Math.min(availableWidth, availableHeight); | 130 int maxSize = Math.min(availableWidth, availableHeight); |
128 int multiplier = maxSize / baseUnit; | 131 int multiplier = maxSize / baseUnit; |
129 int floatingDialogWidth = multiplier * baseUnit; | 132 int floatingDialogWidth = multiplier * baseUnit; |
130 return floatingDialogWidth; | 133 return floatingDialogWidth; |
131 } | 134 } |
132 } | 135 } |
OLD | NEW |