Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Fixes #3291 Update URL bar icons visibility based on permissions state #3292

Merged
merged 2 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ public WindowViewModel(Application application) {
isDrmUsed = new MutableLiveData<>(new ObservableBoolean(false));

isUrlBarButtonsVisible = new MediatorLiveData<>();
isUrlBarButtonsVisible.addSource(url, mIsUrlBarButtonsVisibleObserver);
isUrlBarButtonsVisible.addSource(isTrackingEnabled, mIsUrlBarButtonsVisibleObserver);
isUrlBarButtonsVisible.addSource(isDrmUsed, mIsUrlBarButtonsVisibleObserver);
isUrlBarButtonsVisible.addSource(isPopUpAvailable, mIsUrlBarButtonsVisibleObserver);
isUrlBarButtonsVisible.addSource(isWebXRUsed, mIsUrlBarButtonsVisibleObserver);
isUrlBarButtonsVisible.setValue(new ObservableBoolean(false));

isUrlBarIconsVisible = new MediatorLiveData<>();
Expand Down Expand Up @@ -310,15 +313,16 @@ public void onChanged(Spannable aUrl) {
}
};

private Observer<Spannable> mIsUrlBarButtonsVisibleObserver = new Observer<Spannable>() {
private Observer<ObservableBoolean> mIsUrlBarButtonsVisibleObserver = new Observer<ObservableBoolean>() {
@Override
public void onChanged(Spannable aUrl) {
public void onChanged(ObservableBoolean o) {
String aUrl = url.getValue().toString();
isUrlBarButtonsVisible.postValue(new ObservableBoolean(
!isFocused.getValue().get() &&
!isLibraryVisible.getValue().get() &&
!UrlUtils.isContentFeed(getApplication(), aUrl.toString()) &&
!UrlUtils.isPrivateAboutPage(getApplication(), aUrl.toString()) &&
(URLUtil.isHttpUrl(aUrl.toString()) || URLUtil.isHttpsUrl(aUrl.toString())) &&
!UrlUtils.isContentFeed(getApplication(), aUrl) &&
!UrlUtils.isPrivateAboutPage(getApplication(), aUrl) &&
(URLUtil.isHttpUrl(aUrl) || URLUtil.isHttpsUrl(aUrl)) &&
(
(SettingsStore.getInstance(getApplication()).getTrackingProtectionLevel() != ContentBlocking.EtpLevel.NONE) ||
isPopUpAvailable.getValue().get() ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ public void handleURLEdit(String text) {
GleanMetricsService.urlBarEvent(false);
}

mViewModel.setUrl(url);

mSession.loadUri(url);

if (mDelegate != null) {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/layout/navigation_url.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:src="@{viewmodel.isTrackingEnabled ? @drawable/ic_icon_tracking_enabled : @drawable/ic_icon_tracking_disabled}"
tools:src="@drawable/ic_icon_tracking_enabled"
app:privateMode="@{viewmodel.isPrivateSession}"
android:tint="@color/fog"
app:visibleGone="@{!UrlUtils.isPrivateAboutPage(context, viewmodel.url.toString()) &amp;&amp; settingsViewmodel.isTrackingProtectionEnabled &amp;&amp; !UrlUtils.isContentFeed(context, viewmodel.url.toString())}"
Expand Down Expand Up @@ -79,6 +80,7 @@
android:paddingStart="@{settingsViewmodel.isTrackingProtectionEnabled ? @dimen/navigation_bar_icon_padding_small : @dimen/navigation_bar_icon_padding_big}"
android:paddingEnd="2dp"
android:src="@{settingsViewmodel.isDrmEnabled ? @drawable/ic_icon_drm_allowed : @drawable/ic_icon_drm_blocked}"
tools:src="@drawable/ic_icon_drm_allowed"
android:tint="@color/fog"
android:tooltipText="@{settingsViewmodel.isDrmEnabled ? @string/drm_enabled_tooltip : @string/drm_disabled_tooltip}"
app:privateMode="@{viewmodel.isPrivateSession}" />
Expand Down Expand Up @@ -107,6 +109,7 @@
android:paddingStart="@{settingsViewmodel.isTrackingProtectionEnabled || (settingsViewmodel.isDrmEnabled &amp;&amp; viewmodel.isDrmUsed) ? @dimen/navigation_bar_icon_padding_small : @dimen/navigation_bar_icon_padding_big}"
android:paddingEnd="2dp"
android:src="@{viewmodel.isPopUpBlocked ? @drawable/ic_icon_popup_blocked : @drawable/ic_icon_popup}"
tools:src="@drawable/ic_icon_popup_blocked"
android:tint="@color/fog"
android:tooltipText="@string/popup_tooltip"
app:privateMode="@{viewmodel.isPrivateSession}" />
Expand Down Expand Up @@ -135,6 +138,7 @@
android:paddingStart="@{settingsViewmodel.isTrackingProtectionEnabled || (settingsViewmodel.isPopUpBlockingEnabled &amp;&amp; viewmodel.isPopUpBlocked) || (settingsViewmodel.isDrmEnabled &amp;&amp; viewmodel.isDrmUsed) ? @dimen/navigation_bar_icon_padding_small : @dimen/navigation_bar_icon_padding_big}"
android:paddingEnd="2dp"
android:src="@{viewmodel.isWebXRBlocked ? @drawable/ic_icon_webxr_blocked : @drawable/ic_icon_webxr_allowed}"
tools:src="@drawable/ic_icon_webxr_blocked"
app:privateMode="@{viewmodel.isPrivateSession}"
android:tint="@color/fog"
android:tooltipText="@{viewmodel.isWebXRBlocked ? @string/webxr_blocked_tooltip : @string/webxr_allowed_tooltip}" />
Expand Down