Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/omnibox/SuggestionView.java

Issue 2896883003: Unify toolbar, NTP, and tab switcher text styles (Closed)
Patch Set: Change color for suggestion url Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/omnibox/AnswerTextBuilder.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.omnibox; 5 package org.chromium.chrome.browser.omnibox;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.DialogInterface; 9 import android.content.DialogInterface;
10 import android.content.res.Resources;
10 import android.content.res.TypedArray; 11 import android.content.res.TypedArray;
11 import android.graphics.Bitmap; 12 import android.graphics.Bitmap;
12 import android.graphics.Canvas; 13 import android.graphics.Canvas;
13 import android.graphics.Color; 14 import android.graphics.Color;
14 import android.graphics.PorterDuff; 15 import android.graphics.PorterDuff;
15 import android.graphics.drawable.Drawable; 16 import android.graphics.drawable.Drawable;
16 import android.support.annotation.IntDef; 17 import android.support.annotation.IntDef;
17 import android.support.v4.view.ViewCompat; 18 import android.support.v4.view.ViewCompat;
18 import android.support.v7.app.AlertDialog; 19 import android.support.v7.app.AlertDialog;
19 import android.text.Spannable; 20 import android.text.Spannable;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 63
63 private static final int SUGGESTION_ICON_UNDEFINED = -1; 64 private static final int SUGGESTION_ICON_UNDEFINED = -1;
64 private static final int SUGGESTION_ICON_BOOKMARK = 0; 65 private static final int SUGGESTION_ICON_BOOKMARK = 0;
65 private static final int SUGGESTION_ICON_HISTORY = 1; 66 private static final int SUGGESTION_ICON_HISTORY = 1;
66 private static final int SUGGESTION_ICON_GLOBE = 2; 67 private static final int SUGGESTION_ICON_GLOBE = 2;
67 private static final int SUGGESTION_ICON_MAGNIFIER = 3; 68 private static final int SUGGESTION_ICON_MAGNIFIER = 3;
68 private static final int SUGGESTION_ICON_VOICE = 4; 69 private static final int SUGGESTION_ICON_VOICE = 4;
69 70
70 private static final long RELAYOUT_DELAY_MS = 20; 71 private static final long RELAYOUT_DELAY_MS = 20;
71 72
72 static final int TITLE_COLOR_STANDARD_FONT_DARK = 0xFF333333;
73 private static final int TITLE_COLOR_STANDARD_FONT_LIGHT = 0xFFFFFFFF;
74 private static final int URL_COLOR = 0xFF5595FE;
75
76 private static final float ANSWER_IMAGE_SCALING_FACTOR = 1.15f; 73 private static final float ANSWER_IMAGE_SCALING_FACTOR = 1.15f;
77 74
78 private final LocationBar mLocationBar; 75 private final LocationBar mLocationBar;
79 private UrlBar mUrlBar; 76 private UrlBar mUrlBar;
80 private ImageView mNavigationButton; 77 private ImageView mNavigationButton;
81 78
82 private final int mSuggestionHeight; 79 private final int mSuggestionHeight;
83 private final int mSuggestionAnswerHeight; 80 private final int mSuggestionAnswerHeight;
84 private int mNumAnswerLines = 1; 81 private int mNumAnswerLines = 1;
85 82
83 private final int mDarkTitleColorStandardFont;
84 private final int mLightTitleColorStandardFont;
85 private final int mUrlColor;
86
86 private OmniboxResultItem mSuggestionItem; 87 private OmniboxResultItem mSuggestionItem;
87 private OmniboxSuggestion mSuggestion; 88 private OmniboxSuggestion mSuggestion;
88 private OmniboxSuggestionDelegate mSuggestionDelegate; 89 private OmniboxSuggestionDelegate mSuggestionDelegate;
89 private Boolean mUseDarkColors; 90 private Boolean mUseDarkColors;
90 private int mPosition; 91 private int mPosition;
91 92
92 private final SuggestionContentsContainer mContentsView; 93 private final SuggestionContentsContainer mContentsView;
93 94
94 private final int mRefineWidth; 95 private final int mRefineWidth;
95 private final View mRefineView; 96 private final View mRefineView;
(...skipping 14 matching lines...) Expand all
110 public SuggestionView(Context context, LocationBar locationBar) { 111 public SuggestionView(Context context, LocationBar locationBar) {
111 super(context); 112 super(context);
112 mLocationBar = locationBar; 113 mLocationBar = locationBar;
113 114
114 mSuggestionHeight = 115 mSuggestionHeight =
115 context.getResources().getDimensionPixelOffset(R.dimen.omnibox_s uggestion_height); 116 context.getResources().getDimensionPixelOffset(R.dimen.omnibox_s uggestion_height);
116 mSuggestionAnswerHeight = 117 mSuggestionAnswerHeight =
117 context.getResources().getDimensionPixelOffset( 118 context.getResources().getDimensionPixelOffset(
118 R.dimen.omnibox_suggestion_answer_height); 119 R.dimen.omnibox_suggestion_answer_height);
119 120
121 Resources resources = getResources();
122 mDarkTitleColorStandardFont =
123 ApiCompatibilityUtils.getColor(resources, R.color.url_emphasis_d efault_text);
124 mLightTitleColorStandardFont =
125 ApiCompatibilityUtils.getColor(resources, R.color.url_emphasis_l ight_default_text);
126 mUrlColor = ApiCompatibilityUtils.getColor(resources, R.color.suggestion _url);
127
120 TypedArray a = getContext().obtainStyledAttributes( 128 TypedArray a = getContext().obtainStyledAttributes(
121 new int [] {R.attr.selectableItemBackground}); 129 new int [] {R.attr.selectableItemBackground});
122 Drawable itemBackground = a.getDrawable(0); 130 Drawable itemBackground = a.getDrawable(0);
123 a.recycle(); 131 a.recycle();
124 132
125 mContentsView = new SuggestionContentsContainer(context, itemBackground) ; 133 mContentsView = new SuggestionContentsContainer(context, itemBackground) ;
126 addView(mContentsView); 134 addView(mContentsView);
127 135
128 mRefineView = new View(context) { 136 mRefineView = new View(context) {
129 @Override 137 @Override
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 if (!post(performRefine)) performRefine.run(); 373 if (!post(performRefine)) performRefine.run();
366 } 374 }
367 }); 375 });
368 } else { 376 } else {
369 mRefineView.setOnClickListener(null); 377 mRefineView.setOnClickListener(null);
370 mRefineView.setVisibility(GONE); 378 mRefineView.setVisibility(GONE);
371 } 379 }
372 } 380 }
373 381
374 private int getStandardFontColor() { 382 private int getStandardFontColor() {
375 return (mUseDarkColors == null || mUseDarkColors) 383 return (mUseDarkColors == null || mUseDarkColors) ? mDarkTitleColorStand ardFont
376 ? TITLE_COLOR_STANDARD_FONT_DARK : TITLE_COLOR_STANDARD_FONT_LIG HT; 384 : mLightTitleColorStan dardFont;
377 } 385 }
378 386
379 @Override 387 @Override
380 public void setSelected(boolean selected) { 388 public void setSelected(boolean selected) {
381 super.setSelected(selected); 389 super.setSelected(selected);
382 if (selected && !isInTouchMode()) { 390 if (selected && !isInTouchMode()) {
383 mSuggestionDelegate.onSetUrlToSuggestion(mSuggestion); 391 mSuggestionDelegate.onSetUrlToSuggestion(mSuggestion);
384 } 392 }
385 } 393 }
386 394
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 */ 456 */
449 private void showDescriptionLine(Spannable str, boolean isUrl) { 457 private void showDescriptionLine(Spannable str, boolean isUrl) {
450 TextView textLine = mContentsView.mTextLine2; 458 TextView textLine = mContentsView.mTextLine2;
451 if (textLine.getVisibility() != VISIBLE) { 459 if (textLine.getVisibility() != VISIBLE) {
452 textLine.setVisibility(VISIBLE); 460 textLine.setVisibility(VISIBLE);
453 } 461 }
454 textLine.setText(str, BufferType.SPANNABLE); 462 textLine.setText(str, BufferType.SPANNABLE);
455 463
456 // Force left-to-right rendering for URLs. See UrlBar constructor for de tails. 464 // Force left-to-right rendering for URLs. See UrlBar constructor for de tails.
457 if (isUrl) { 465 if (isUrl) {
458 textLine.setTextColor(URL_COLOR); 466 textLine.setTextColor(mUrlColor);
459 ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_LTR) ; 467 ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_LTR) ;
460 } else { 468 } else {
461 textLine.setTextColor(getStandardFontColor()); 469 textLine.setTextColor(getStandardFontColor());
462 ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_INHE RIT); 470 ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_INHE RIT);
463 } 471 }
464 } 472 }
465 473
466 /** 474 /**
467 * Sets the text of the first line of the omnibox suggestion. 475 * Sets the text of the first line of the omnibox suggestion.
468 * 476 *
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 if (mUrlBar != null) mUrlBar.removeOnLayoutChangeListener(this); 1069 if (mUrlBar != null) mUrlBar.removeOnLayoutChangeListener(this);
1062 if (mLocationBar != null) { 1070 if (mLocationBar != null) {
1063 mLocationBar.getContainerView().removeOnLayoutChangeListener(thi s); 1071 mLocationBar.getContainerView().removeOnLayoutChangeListener(thi s);
1064 } 1072 }
1065 getRootView().removeOnLayoutChangeListener(this); 1073 getRootView().removeOnLayoutChangeListener(this);
1066 1074
1067 super.onDetachedFromWindow(); 1075 super.onDetachedFromWindow();
1068 } 1076 }
1069 } 1077 }
1070 } 1078 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/omnibox/AnswerTextBuilder.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698