diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java index 34ef4d733..4479dda0f 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java @@ -17,6 +17,7 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; +import android.view.ViewGroup; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.inputmethod.EditorInfo; @@ -71,6 +72,7 @@ public class NavigationURLBar extends FrameLayout { private BookmarkViewModel mBookmarkModel; private AudioEngine mAudio; private boolean mIsBookmarkMode; + private boolean mBookmarkEnabled = true; private Unit domainAutocompleteFilter(String text, InlineAutocompleteEditText view) { if (view != null) { @@ -187,10 +189,33 @@ public void setDelegate(NavigationURLBarDelegate delegate) { } public void setIsBookmarkMode(boolean isBookmarkMode) { + if (mIsBookmarkMode == isBookmarkMode) { + return; + } mIsBookmarkMode = isBookmarkMode; + if (isBookmarkMode) { + mMicrophoneButton.setVisibility(GONE); + mBookmarkButton.setVisibility(GONE); + } else { + mMicrophoneButton.setVisibility(VISIBLE); + if (mBookmarkEnabled) { + mBookmarkButton.setVisibility(VISIBLE); + } + } syncViews(); } + private void setBookmarkEnabled(boolean aEnabled) { + if (mBookmarkEnabled != aEnabled) { + mBookmarkEnabled = aEnabled; + mBookmarkButton.setVisibility(aEnabled ? View.VISIBLE : View.GONE); + ViewGroup.LayoutParams params = mMicrophoneButton.getLayoutParams(); + params.width = (int) getResources().getDimension(aEnabled ? R.dimen.url_bar_item_width : R.dimen.url_bar_last_item_width); + mMicrophoneButton.setLayoutParams(params); + mMicrophoneButton.setBackgroundResource(aEnabled ? R.drawable.url_button : R.drawable.url_button_end); + } + } + private final NavigationBarCallback mNavigationBarCallback = new NavigationBarCallback() { @Override public void onBookmarkClick(Bookmark bookmark) { @@ -266,6 +291,7 @@ else if (aURL.startsWith("data:") && SessionStore.get().isCurrentSessionPrivate( mURL.setText(aURL); } } + setBookmarkEnabled(aURL.length() > 0 && !aURL.startsWith("about://")); } mURL.addTextChangedListener(mURLTextWatcher); @@ -303,28 +329,18 @@ public void setIsLoading(boolean aIsLoading) { } } - public void setBookmarks(boolean enabled) { - if (enabled) { - mMicrophoneButton.setVisibility(GONE); - mBookmarkButton.setVisibility(GONE); - - } else { - mMicrophoneButton.setVisibility(VISIBLE); - mBookmarkButton.setVisibility(VISIBLE); - } - } - public void showVoiceSearch(boolean enabled) { if (enabled) { + if (mBookmarkEnabled) { + mMicrophoneButton.setBackgroundResource(R.drawable.url_button); + mMicrophoneButton.getLayoutParams().width = (int)getContext().getResources().getDimension(R.dimen.url_bar_item_width); + } mMicrophoneButton.setImageResource(R.drawable.ic_icon_microphone); - mMicrophoneButton.setBackgroundResource(R.drawable.url_button); - mMicrophoneButton.getLayoutParams().width = (int)getContext().getResources().getDimension(R.dimen.url_bar_item_width); mMicrophoneButton.setOnClickListener(mMicrophoneListener); if (mIsBookmarkMode) { mMicrophoneButton.setVisibility(GONE); - - } else { + } else if (mBookmarkEnabled) { mBookmarkButton.setVisibility(VISIBLE); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java index 9702d7a47..48e6e26bc 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java @@ -964,7 +964,6 @@ public void OnItemDeleted(SuggestionsWidget.SuggestionItem item) { @Override public void onBookmarksShown() { - mURLBar.setBookmarks(true); mURLBar.setURL(""); mURLBar.setHint(R.string.about_bookmarks); mURLBar.setIsBookmarkMode(true); @@ -973,7 +972,6 @@ public void onBookmarksShown() { @Override public void onBookmarksHidden() { mURLBar.setIsBookmarkMode(false); - mURLBar.setBookmarks(false); mURLBar.setURL(SessionStore.get().getCurrentUri()); mURLBar.setHint(R.string.search_placeholder); }