Commit 78a878f4 authored by Marcin Wiacek's avatar Marcin Wiacek Committed by Commit Bot

Replace enum with @IntDef inside LocationBarLayout

Change-Id: Ibca3a219a21281cf573a963732a1ef7220be1ffd
Reviewed-on: https://chromium-review.googlesource.com/1142410Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Marcin Wiącek <marcin@mwiacek.com>
Cr-Commit-Position: refs/heads/master@{#576238}
parent df3a31b2
...@@ -128,7 +128,7 @@ public class LocationBarLayout extends FrameLayout ...@@ -128,7 +128,7 @@ public class LocationBarLayout extends FrameLayout
private final List<Runnable> mDeferredNativeRunnables = new ArrayList<Runnable>(); private final List<Runnable> mDeferredNativeRunnables = new ArrayList<Runnable>();
// The type of the navigation button currently showing. // The type of the navigation button currently showing.
private NavigationButtonType mNavigationButtonType; private @NavigationButtonType int mNavigationButtonType;
// The type of the security icon currently active. // The type of the security icon currently active.
@DrawableRes @DrawableRes
...@@ -356,10 +356,12 @@ public class LocationBarLayout extends FrameLayout ...@@ -356,10 +356,12 @@ public class LocationBarLayout extends FrameLayout
/** /**
* Specifies the types of buttons shown to signify different types of navigation elements. * Specifies the types of buttons shown to signify different types of navigation elements.
*/ */
protected enum NavigationButtonType { @IntDef({NavigationButtonType.PAGE, NavigationButtonType.MAGNIFIER, NavigationButtonType.EMPTY})
PAGE, @Retention(RetentionPolicy.SOURCE)
MAGNIFIER, public @interface NavigationButtonType {
EMPTY, int PAGE = 0;
int MAGNIFIER = 1;
int EMPTY = 2;
} }
/** Specifies which button should be shown in location bar, if any. */ /** Specifies which button should be shown in location bar, if any. */
...@@ -997,7 +999,7 @@ public class LocationBarLayout extends FrameLayout ...@@ -997,7 +999,7 @@ public class LocationBarLayout extends FrameLayout
return mToolbarDataProvider; return mToolbarDataProvider;
} }
private static NavigationButtonType suggestionTypeToNavigationButtonType( private static @NavigationButtonType int suggestionTypeToNavigationButtonType(
OmniboxSuggestion suggestion) { OmniboxSuggestion suggestion) {
if (suggestion.isUrlSuggestion()) { if (suggestion.isUrlSuggestion()) {
return NavigationButtonType.PAGE; return NavigationButtonType.PAGE;
...@@ -1008,7 +1010,8 @@ public class LocationBarLayout extends FrameLayout ...@@ -1008,7 +1010,8 @@ public class LocationBarLayout extends FrameLayout
// Updates the navigation button based on the URL string // Updates the navigation button based on the URL string
private void updateNavigationButton() { private void updateNavigationButton() {
NavigationButtonType type = NavigationButtonType.EMPTY; @NavigationButtonType
int type = NavigationButtonType.EMPTY;
if (mIsTablet && !mSuggestionItems.isEmpty()) { if (mIsTablet && !mSuggestionItems.isEmpty()) {
// If there are suggestions showing, show the icon for the default suggestion. // If there are suggestions showing, show the icon for the default suggestion.
type = suggestionTypeToNavigationButtonType( type = suggestionTypeToNavigationButtonType(
...@@ -1090,19 +1093,19 @@ public class LocationBarLayout extends FrameLayout ...@@ -1090,19 +1093,19 @@ public class LocationBarLayout extends FrameLayout
* Sets the type of the current navigation type and updates the UI to match it. * Sets the type of the current navigation type and updates the UI to match it.
* @param buttonType The type of navigation button to be shown. * @param buttonType The type of navigation button to be shown.
*/ */
private void setNavigationButtonType(NavigationButtonType buttonType) { private void setNavigationButtonType(@NavigationButtonType int buttonType) {
if (!mIsTablet) return; if (!mIsTablet) return;
switch (buttonType) { switch (buttonType) {
case PAGE: case NavigationButtonType.PAGE:
Drawable page = TintedDrawable.constructTintedDrawable(getContext(), Drawable page = TintedDrawable.constructTintedDrawable(getContext(),
R.drawable.ic_omnibox_page, R.drawable.ic_omnibox_page,
mUseDarkColors ? R.color.dark_mode_tint : R.color.light_mode_tint); mUseDarkColors ? R.color.dark_mode_tint : R.color.light_mode_tint);
mNavigationButton.setImageDrawable(page); mNavigationButton.setImageDrawable(page);
break; break;
case MAGNIFIER: case NavigationButtonType.MAGNIFIER:
mNavigationButton.setImageResource(R.drawable.ic_omnibox_magnifier); mNavigationButton.setImageResource(R.drawable.ic_omnibox_magnifier);
break; break;
case EMPTY: case NavigationButtonType.EMPTY:
mNavigationButton.setImageDrawable(null); mNavigationButton.setImageDrawable(null);
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment