OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.app.Dialog; | 7 import android.app.Dialog; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.graphics.Typeface; | 9 import android.graphics.Typeface; |
10 import android.net.http.SslCertificate; | 10 import android.net.http.SslCertificate; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 // Show information about an array of DER-encoded data representing a X509 c
ertificate chain. | 65 // Show information about an array of DER-encoded data representing a X509 c
ertificate chain. |
66 // A spinner will be displayed allowing the user to select which certificate
to display. | 66 // A spinner will be displayed allowing the user to select which certificate
to display. |
67 private void showCertificateChain(byte[][] derData) { | 67 private void showCertificateChain(byte[][] derData) { |
68 for (int i = 0; i < derData.length; i++) { | 68 for (int i = 0; i < derData.length; i++) { |
69 addCertificate(derData[i]); | 69 addCertificate(derData[i]); |
70 } | 70 } |
71 ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(mContext, | 71 ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(mContext, |
72 android.R.layout.simple_spinner_item, | 72 android.R.layout.simple_spinner_item, |
73 mTitles); | 73 mTitles) { |
| 74 @Override |
| 75 public View getView(int position, View convertView, ViewGroup parent
) { |
| 76 TextView view = (TextView) super.getView(position, convertView,
parent); |
| 77 // Add extra padding on the end side to avoid overlapping the dr
opdown arrow. |
| 78 ApiCompatibilityUtils.setPaddingRelative(view, mPadding, mPaddin
g, mPadding * 2, |
| 79 mPadding); |
| 80 return view; |
| 81 } |
| 82 }; |
74 arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dro
pdown_item); | 83 arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dro
pdown_item); |
75 | 84 |
76 LinearLayout dialogContainer = new LinearLayout(mContext); | 85 LinearLayout dialogContainer = new LinearLayout(mContext); |
77 dialogContainer.setOrientation(LinearLayout.VERTICAL); | 86 dialogContainer.setOrientation(LinearLayout.VERTICAL); |
78 | 87 |
79 TextView title = new TextView(mContext); | 88 TextView title = new TextView(mContext); |
80 title.setText(R.string.certtitle); | 89 title.setText(R.string.certtitle); |
| 90 ApiCompatibilityUtils.setTextAlignment(title, View.TEXT_ALIGNMENT_VIEW_S
TART); |
81 ApiCompatibilityUtils.setTextAppearance(title, android.R.style.TextAppea
rance_Large); | 91 ApiCompatibilityUtils.setTextAppearance(title, android.R.style.TextAppea
rance_Large); |
82 title.setTypeface(title.getTypeface(), Typeface.BOLD); | 92 title.setTypeface(title.getTypeface(), Typeface.BOLD); |
83 title.setPadding(mPadding, mPadding, mPadding, mPadding / 2); | 93 title.setPadding(mPadding, mPadding, mPadding, mPadding / 2); |
84 dialogContainer.addView(title); | 94 dialogContainer.addView(title); |
85 | 95 |
86 Spinner spinner = new Spinner(mContext); | 96 Spinner spinner = new Spinner(mContext); |
| 97 ApiCompatibilityUtils.setTextAlignment(spinner, View.TEXT_ALIGNMENT_VIEW
_START); |
87 spinner.setAdapter(arrayAdapter); | 98 spinner.setAdapter(arrayAdapter); |
88 spinner.setOnItemSelectedListener(this); | 99 spinner.setOnItemSelectedListener(this); |
89 spinner.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT); | 100 spinner.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT); |
90 spinner.setPadding(0, 0, 0, mPadding); | 101 // Remove padding so that dropdown has same width as the spinner. |
| 102 spinner.setPadding(0, 0, 0, 0); |
91 dialogContainer.addView(spinner); | 103 dialogContainer.addView(spinner); |
92 | 104 |
93 LinearLayout certContainer = new LinearLayout(mContext); | 105 LinearLayout certContainer = new LinearLayout(mContext); |
94 certContainer.setOrientation(LinearLayout.VERTICAL); | 106 certContainer.setOrientation(LinearLayout.VERTICAL); |
95 for (int i = 0; i < mViews.size(); ++i) { | 107 for (int i = 0; i < mViews.size(); ++i) { |
96 LinearLayout certificateView = mViews.get(i); | 108 LinearLayout certificateView = mViews.get(i); |
97 if (i != 0) { | 109 if (i != 0) { |
98 certificateView.setVisibility(LinearLayout.GONE); | 110 certificateView.setVisibility(LinearLayout.GONE); |
99 } | 111 } |
100 certContainer.addView(certificateView); | 112 certContainer.addView(certificateView); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 190 |
179 private void addItem(LinearLayout certificateView, String label, String valu
e) { | 191 private void addItem(LinearLayout certificateView, String label, String valu
e) { |
180 if (value.isEmpty()) return; | 192 if (value.isEmpty()) return; |
181 | 193 |
182 addLabel(certificateView, label); | 194 addLabel(certificateView, label); |
183 addValue(certificateView, value); | 195 addValue(certificateView, value); |
184 } | 196 } |
185 | 197 |
186 private TextView addLabel(LinearLayout certificateView, String label) { | 198 private TextView addLabel(LinearLayout certificateView, String label) { |
187 TextView t = new TextView(mContext); | 199 TextView t = new TextView(mContext); |
| 200 ApiCompatibilityUtils.setTextAlignment(t, View.TEXT_ALIGNMENT_VIEW_START
); |
188 t.setPadding(mPadding, mPadding / 2, mPadding, 0); | 201 t.setPadding(mPadding, mPadding / 2, mPadding, 0); |
189 t.setText(label); | 202 t.setText(label); |
190 t.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); | 203 t.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); |
191 t.setTextColor(ApiCompatibilityUtils.getColor(mContext.getResources(), | 204 t.setTextColor(ApiCompatibilityUtils.getColor(mContext.getResources(), |
192 R.color.connection_info_popup_text)); | 205 R.color.connection_info_popup_text)); |
193 certificateView.addView(t); | 206 certificateView.addView(t); |
194 return t; | 207 return t; |
195 } | 208 } |
196 | 209 |
197 private void addValue(LinearLayout certificateView, String value) { | 210 private void addValue(LinearLayout certificateView, String value) { |
198 TextView t = new TextView(mContext); | 211 TextView t = new TextView(mContext); |
| 212 ApiCompatibilityUtils.setTextAlignment(t, View.TEXT_ALIGNMENT_VIEW_START
); |
199 t.setText(value); | 213 t.setText(value); |
200 t.setPadding(mPadding, 0, mPadding, mPadding / 2); | 214 t.setPadding(mPadding, 0, mPadding, mPadding / 2); |
201 t.setTextColor(ApiCompatibilityUtils.getColor(mContext.getResources(), | 215 t.setTextColor(ApiCompatibilityUtils.getColor(mContext.getResources(), |
202 R.color.connection_info_popup_text)); | 216 R.color.connection_info_popup_text)); |
203 certificateView.addView(t); | 217 certificateView.addView(t); |
204 } | 218 } |
205 | 219 |
206 private static String formatBytes(byte[] bytes, char separator) { | 220 private static String formatBytes(byte[] bytes, char separator) { |
207 StringBuilder sb = new StringBuilder(); | 221 StringBuilder sb = new StringBuilder(); |
208 for (int i = 0; i < bytes.length; i++) { | 222 for (int i = 0; i < bytes.length; i++) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 private static native String nativeGetCertInfoSerialNumberText(); | 256 private static native String nativeGetCertInfoSerialNumberText(); |
243 private static native String nativeGetCertInfoOrganizationUnitText(); | 257 private static native String nativeGetCertInfoOrganizationUnitText(); |
244 private static native String nativeGetCertIssuedByText(); | 258 private static native String nativeGetCertIssuedByText(); |
245 private static native String nativeGetCertValidityText(); | 259 private static native String nativeGetCertValidityText(); |
246 private static native String nativeGetCertIssuedOnText(); | 260 private static native String nativeGetCertIssuedOnText(); |
247 private static native String nativeGetCertExpiresOnText(); | 261 private static native String nativeGetCertExpiresOnText(); |
248 private static native String nativeGetCertFingerprintsText(); | 262 private static native String nativeGetCertFingerprintsText(); |
249 private static native String nativeGetCertSHA256FingerprintText(); | 263 private static native String nativeGetCertSHA256FingerprintText(); |
250 private static native String nativeGetCertSHA1FingerprintText(); | 264 private static native String nativeGetCertSHA1FingerprintText(); |
251 } | 265 } |
OLD | NEW |