|
15 | 15 | import androidx.lifecycle.MutableLiveData;
|
16 | 16 | import androidx.lifecycle.Observer;
|
17 | 17 |
|
| 18 | +import org.mozilla.geckoview.ContentBlocking; |
18 | 19 | import org.mozilla.vrbrowser.R;
|
19 | 20 | import org.mozilla.vrbrowser.browser.SettingsStore;
|
20 | 21 | import org.mozilla.vrbrowser.ui.widgets.Windows;
|
@@ -67,6 +68,8 @@ public class WindowViewModel extends AndroidViewModel {
|
67 | 68 | private MutableLiveData<ObservableBoolean> isWebXRBlocked;
|
68 | 69 | private MutableLiveData<ObservableBoolean> isTrackingEnabled;
|
69 | 70 | private MutableLiveData<ObservableBoolean> isDrmUsed;
|
| 71 | + private MediatorLiveData<ObservableBoolean> isUrlBarButtonsVisible; |
| 72 | + private MediatorLiveData<ObservableBoolean> isUrlBarIconsVisible; |
70 | 73 |
|
71 | 74 | public WindowViewModel(Application application) {
|
72 | 75 | super(application);
|
@@ -162,6 +165,15 @@ public WindowViewModel(Application application) {
|
162 | 165 |
|
163 | 166 | isTrackingEnabled = new MutableLiveData<>(new ObservableBoolean(true));
|
164 | 167 | isDrmUsed = new MutableLiveData<>(new ObservableBoolean(false));
|
| 168 | + |
| 169 | + isUrlBarButtonsVisible = new MediatorLiveData<>(); |
| 170 | + isUrlBarButtonsVisible.addSource(url, mIsUrlBarButtonsVisibleObserver); |
| 171 | + isUrlBarButtonsVisible.setValue(new ObservableBoolean(false)); |
| 172 | + |
| 173 | + isUrlBarIconsVisible = new MediatorLiveData<>(); |
| 174 | + isUrlBarIconsVisible.addSource(isLoading, mIsUrlBarIconsVisibleObserver); |
| 175 | + isUrlBarIconsVisible.addSource(isInsecureVisible, mIsUrlBarIconsVisibleObserver); |
| 176 | + isUrlBarIconsVisible.setValue(new ObservableBoolean(false)); |
165 | 177 | }
|
166 | 178 |
|
167 | 179 | private Observer<ObservableBoolean> mIsTopBarVisibleObserver = new Observer<ObservableBoolean>() {
|
@@ -297,6 +309,34 @@ public void onChanged(Spannable aUrl) {
|
297 | 309 | }
|
298 | 310 | };
|
299 | 311 |
|
| 312 | + private Observer<Spannable> mIsUrlBarButtonsVisibleObserver = new Observer<Spannable>() { |
| 313 | + @Override |
| 314 | + public void onChanged(Spannable aUrl) { |
| 315 | + isUrlBarButtonsVisible.postValue(new ObservableBoolean( |
| 316 | + !isFocused.getValue().get() && |
| 317 | + !isLibraryVisible.getValue().get() && |
| 318 | + !UrlUtils.isContentFeed(getApplication(), aUrl.toString()) && |
| 319 | + !UrlUtils.isFileUri(aUrl.toString()) && |
| 320 | + ( |
| 321 | + (SettingsStore.getInstance(getApplication()).getTrackingProtectionLevel() != ContentBlocking.EtpLevel.NONE) || |
| 322 | + isPopUpAvailable.getValue().get() || |
| 323 | + isDrmUsed.getValue().get() || |
| 324 | + isWebXRUsed.getValue().get() |
| 325 | + ) |
| 326 | + )); |
| 327 | + } |
| 328 | + }; |
| 329 | + |
| 330 | + private Observer<ObservableBoolean> mIsUrlBarIconsVisibleObserver = new Observer<ObservableBoolean>() { |
| 331 | + @Override |
| 332 | + public void onChanged(ObservableBoolean o) { |
| 333 | + isUrlBarIconsVisible.postValue(new ObservableBoolean( |
| 334 | + isLoading.getValue().get() || |
| 335 | + isInsecureVisible.getValue().get() |
| 336 | + )); |
| 337 | + } |
| 338 | + }; |
| 339 | + |
300 | 340 | public void refresh() {
|
301 | 341 | url.postValue(url.getValue());
|
302 | 342 | hint.postValue(getHintValue());
|
@@ -730,4 +770,14 @@ public MutableLiveData<ObservableBoolean> getIsDrmUsed() {
|
730 | 770 | public void setIsDrmUsed(boolean isEnabled) {
|
731 | 771 | this.isDrmUsed.postValue(new ObservableBoolean(isEnabled));
|
732 | 772 | }
|
| 773 | + |
| 774 | + @NonNull |
| 775 | + public MutableLiveData<ObservableBoolean> getIsUrlBarButtonsVisible() { |
| 776 | + return isUrlBarButtonsVisible; |
| 777 | + } |
| 778 | + |
| 779 | + @NonNull |
| 780 | + public MutableLiveData<ObservableBoolean> getIsUrlBarIconsVisible() { |
| 781 | + return isUrlBarIconsVisible; |
| 782 | + } |
733 | 783 | }
|
0 commit comments