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.util.AttributeSet; | 9 import android.util.AttributeSet; |
10 import android.view.Gravity; | 10 import android.view.Gravity; |
11 import android.view.View; | 11 import android.view.View; |
12 import android.view.ViewGroup; | 12 import android.view.ViewGroup; |
13 import android.widget.FrameLayout; | 13 import android.widget.FrameLayout; |
14 import android.widget.ImageView; | 14 import android.widget.ImageView; |
15 import android.widget.TextView; | 15 import android.widget.TextView; |
16 | 16 |
17 import org.chromium.base.ApiCompatibilityUtils; | 17 import org.chromium.base.ApiCompatibilityUtils; |
18 import org.chromium.chrome.R; | 18 import org.chromium.chrome.R; |
19 import org.chromium.chrome.browser.widget.BoundedLinearLayout; | 19 import org.chromium.chrome.browser.widget.BoundedLinearLayout; |
| 20 import org.chromium.chrome.browser.widget.TintedDrawable; |
| 21 import org.chromium.components.url_formatter.UrlFormatter; |
20 | 22 |
21 /** | 23 /** |
22 * Displays the status of a payment request to the user. | 24 * Displays the status of a payment request to the user. |
23 */ | 25 */ |
24 public class PaymentRequestUiErrorView extends BoundedLinearLayout { | 26 public class PaymentRequestUiErrorView extends BoundedLinearLayout { |
25 | 27 |
26 public PaymentRequestUiErrorView(Context context, AttributeSet attrs) { | 28 public PaymentRequestUiErrorView(Context context, AttributeSet attrs) { |
27 super(context, attrs); | 29 super(context, attrs); |
28 } | 30 } |
29 | 31 |
30 /** | 32 /** |
31 * Initializes the view with the correct strings. | 33 * Initializes the view with the correct strings. |
32 * | 34 * |
33 * @param title Title of the webpage. | 35 * @param title Title of the webpage. |
34 * @param origin Origin of the webpage. | 36 * @param origin Origin of the webpage. |
35 */ | 37 */ |
36 public void initialize(String title, String origin) { | 38 public void initialize(String title, String origin) { |
37 ((TextView) findViewById(R.id.page_title)).setText(title); | 39 ((TextView) findViewById(R.id.page_title)).setText(title); |
38 ((TextView) findViewById(R.id.hostname)).setText(origin); | 40 |
| 41 TextView hostName = (TextView) findViewById(R.id.hostname); |
| 42 hostName.setText(UrlFormatter.tintUrlSchemeForSecurityDisplay( |
| 43 origin, ApiCompatibilityUtils.getColor( |
| 44 getContext().getResources(), R.color.google_gree
n_700))); |
| 45 ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(ho
stName, |
| 46 TintedDrawable.constructTintedDrawable(getContext().getResources
(), |
| 47 R.drawable.omnibox_https_valid, R.color.google_green_700
), |
| 48 null, null, null); |
39 | 49 |
40 // Remove the close button, then expand the page information to take up
the space formerly | 50 // Remove the close button, then expand the page information to take up
the space formerly |
41 // occupied by the X. | 51 // occupied by the X. |
42 View toRemove = findViewById(R.id.close_button); | 52 View toRemove = findViewById(R.id.close_button); |
43 ((ViewGroup) toRemove.getParent()).removeView(toRemove); | 53 ((ViewGroup) toRemove.getParent()).removeView(toRemove); |
44 | 54 |
45 int titleEndMargin = getContext().getResources().getDimensionPixelSize( | 55 int titleEndMargin = getContext().getResources().getDimensionPixelSize( |
46 R.dimen.payments_section_large_spacing); | 56 R.dimen.payments_section_large_spacing); |
47 View pageInfoGroup = findViewById(R.id.page_info); | 57 View pageInfoGroup = findViewById(R.id.page_info); |
48 ApiCompatibilityUtils.setMarginEnd( | 58 ApiCompatibilityUtils.setMarginEnd( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 * TODO(dfalcantara): The dialog should listen for configuration changes and
resize accordingly. | 106 * TODO(dfalcantara): The dialog should listen for configuration changes and
resize accordingly. |
97 */ | 107 */ |
98 public static int computeMaxWidth(Context context, int availableWidth, int a
vailableHeight) { | 108 public static int computeMaxWidth(Context context, int availableWidth, int a
vailableHeight) { |
99 int baseUnit = context.getResources().getDimensionPixelSize(R.dimen.dial
og_width_unit); | 109 int baseUnit = context.getResources().getDimensionPixelSize(R.dimen.dial
og_width_unit); |
100 int maxSize = Math.min(availableWidth, availableHeight); | 110 int maxSize = Math.min(availableWidth, availableHeight); |
101 int multiplier = maxSize / baseUnit; | 111 int multiplier = maxSize / baseUnit; |
102 int floatingDialogWidth = multiplier * baseUnit; | 112 int floatingDialogWidth = multiplier * baseUnit; |
103 return floatingDialogWidth; | 113 return floatingDialogWidth; |
104 } | 114 } |
105 } | 115 } |
OLD | NEW |