OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.infobar; | 5 package org.chromium.chrome.browser.infobar; |
6 | 6 |
7 import android.util.TypedValue; | 7 import android.util.TypedValue; |
8 import android.view.Gravity; | 8 import android.view.Gravity; |
9 import android.view.View; | 9 import android.view.View; |
10 import android.widget.TextView; | 10 import android.widget.TextView; |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 @Override | 42 @Override |
43 protected boolean usesCompactLayout() { | 43 protected boolean usesCompactLayout() { |
44 return true; | 44 return true; |
45 } | 45 } |
46 | 46 |
47 @Override | 47 @Override |
48 protected void createCompactLayoutContent(InfoBarCompactLayout layout) { | 48 protected void createCompactLayoutContent(InfoBarCompactLayout layout) { |
49 TextView prompt = new TextView(getContext()); | 49 TextView prompt = new TextView(getContext()); |
50 prompt.setText(R.string.reader_view_text); | 50 prompt.setText(R.string.reader_view_text); |
51 prompt.setSingleLine(); | |
52 prompt.setTextSize(TypedValue.COMPLEX_UNIT_PX, | 51 prompt.setTextSize(TypedValue.COMPLEX_UNIT_PX, |
53 getContext().getResources().getDimension(R.dimen.infobar_text_si
ze)); | 52 getContext().getResources().getDimension(R.dimen.infobar_text_si
ze)); |
54 prompt.setTextColor( | 53 prompt.setTextColor( |
55 ApiCompatibilityUtils.getColor(layout.getResources(), R.color.de
fault_text_color)); | 54 ApiCompatibilityUtils.getColor(layout.getResources(), R.color.de
fault_text_color)); |
56 prompt.setGravity(Gravity.CENTER_VERTICAL); | 55 prompt.setGravity(Gravity.CENTER_VERTICAL); |
57 prompt.setOnClickListener(mNavigateListener); | 56 prompt.setOnClickListener(mNavigateListener); |
58 | 57 |
59 layout.findViewById(R.id.infobar_icon).setOnClickListener(mNavigateListe
ner); | 58 layout.findViewById(R.id.infobar_icon).setOnClickListener(mNavigateListe
ner); |
| 59 final int messagePadding = getContext().getResources().getDimensionPixel
Offset( |
| 60 R.dimen.reader_mode_infobar_text_padding); |
| 61 prompt.setPadding(0, messagePadding, 0, messagePadding); |
60 layout.addContent(prompt, 1f); | 62 layout.addContent(prompt, 1f); |
61 } | 63 } |
62 | 64 |
63 @Override | 65 @Override |
64 public void onCloseButtonClicked() { | 66 public void onCloseButtonClicked() { |
65 if (getReaderModeManager() != null) { | 67 if (getReaderModeManager() != null) { |
66 getReaderModeManager().onClosed(StateChangeReason.CLOSE_BUTTON); | 68 getReaderModeManager().onClosed(StateChangeReason.CLOSE_BUTTON); |
67 } | 69 } |
68 super.onCloseButtonClicked(); | 70 super.onCloseButtonClicked(); |
69 } | 71 } |
(...skipping 21 matching lines...) Expand all Loading... |
91 * @return An instance of the {@link ReaderModeInfoBar}. | 93 * @return An instance of the {@link ReaderModeInfoBar}. |
92 */ | 94 */ |
93 @CalledByNative | 95 @CalledByNative |
94 private static ReaderModeInfoBar create() { | 96 private static ReaderModeInfoBar create() { |
95 return new ReaderModeInfoBar(); | 97 return new ReaderModeInfoBar(); |
96 } | 98 } |
97 | 99 |
98 private static native void nativeCreate(Tab tab); | 100 private static native void nativeCreate(Tab tab); |
99 private native Tab nativeGetTab(long nativeReaderModeInfoBar); | 101 private native Tab nativeGetTab(long nativeReaderModeInfoBar); |
100 } | 102 } |
OLD | NEW |