diff --git a/app/src/common/shared/com/igalia/wolvic/ui/viewmodel/WindowViewModel.java b/app/src/common/shared/com/igalia/wolvic/ui/viewmodel/WindowViewModel.java index b0380f59129..627ef164e29 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/viewmodel/WindowViewModel.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/viewmodel/WindowViewModel.java @@ -53,6 +53,7 @@ public class WindowViewModel extends AndroidViewModel { private MutableLiveData isActiveWindow; private MediatorLiveData isTitleBarVisible; private MutableLiveData currentContentType; + public MutableLiveData lastContentType; private MediatorLiveData isNativeContentVisible; private MutableLiveData backToNewTabEnabled; private MutableLiveData isLoading; @@ -135,6 +136,7 @@ public WindowViewModel(Application application) { isTitleBarVisible.setValue(new ObservableBoolean(true)); currentContentType = new MutableLiveData<>(Windows.ContentType.WEB_CONTENT); + lastContentType = new MutableLiveData<>(Windows.ContentType.WEB_CONTENT); isNativeContentVisible = new MediatorLiveData<>(); isNativeContentVisible.addSource(currentContentType, contentType -> isNativeContentVisible.setValue(new ObservableBoolean(contentType != Windows.ContentType.WEB_CONTENT)) @@ -579,6 +581,9 @@ public void setIsActiveWindow(boolean isActiveWindow) { } public void setCurrentContentType(Windows.ContentType contentType) { + if (!currentContentType.getValue().isLibraryContent() || !contentType.isLibraryContent()) { + lastContentType.postValue(currentContentType.getValue()); + } currentContentType.postValue(contentType); } diff --git a/app/src/common/shared/com/igalia/wolvic/ui/widgets/WindowWidget.java b/app/src/common/shared/com/igalia/wolvic/ui/widgets/WindowWidget.java index 9eed435ead8..8d913706976 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/widgets/WindowWidget.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/widgets/WindowWidget.java @@ -510,7 +510,7 @@ public Windows.ContentType getSelectedPanel() { } private void hideLibraryPanel() { - if (mViewModel.getIsNativeContentVisible().getValue().get() && mViewModel.getCurrentContentType().getValue() != Windows.ContentType.NEW_TAB) { + if (mViewModel.getCurrentContentType().getValue().isLibraryContent()) { hidePanel(true); } } @@ -589,12 +589,12 @@ private void hidePanel(boolean switchSurface) { mRestoreFirstPaint.run(); mRestoreFirstPaint = null; } - if (mViewModel.getBackToNewTabEnabled().getValue().get()) { + //if (mViewModel.getBackToNewTabEnabled().getValue().get()) { + if (mViewModel.lastContentType.getValue() == Windows.ContentType.NEW_TAB) { showNewTab(); } else { mViewModel.setCurrentContentType(Windows.ContentType.WEB_CONTENT); } - mViewModel.enableBackToNewTab(false); } public void hideNewTab() { @@ -2053,23 +2053,23 @@ WResult onLoadRequest(WSession aSession, @NonNull LoadRequest aReq Uri uri = Uri.parse(aRequest.uri); if (UrlUtils.isAboutPage(uri.toString())) { if(UrlUtils.isBookmarksUrl(uri.toString())) { - hideNewTab(); + //hideNewTab(); showPanel(Windows.ContentType.BOOKMARKS); } else if (UrlUtils.isHistoryUrl(uri.toString())) { - hideNewTab(); + //hideNewTab(); showPanel(Windows.ContentType.HISTORY); } else if (UrlUtils.isDownloadsUrl(uri.toString())) { - hideNewTab(); + //hideNewTab(); showPanel(Windows.ContentType.DOWNLOADS); } else if (UrlUtils.isAddonsUrl(uri.toString())) { - hideNewTab(); + //hideNewTab(); showPanel(Windows.ContentType.ADDONS); } else if (UrlUtils.isNewTabUrl(uri.toString())) { - hideLibraryPanel(); + //hideLibraryPanel(); showNewTab(); } else { diff --git a/app/src/common/shared/com/igalia/wolvic/ui/widgets/Windows.java b/app/src/common/shared/com/igalia/wolvic/ui/widgets/Windows.java index 015e05cfe93..58b662b2fca 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/widgets/Windows.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/widgets/Windows.java @@ -180,9 +180,18 @@ public enum ContentType { @NonNull public final String URL; + ContentType(@NonNull String url) { this.URL = url; } + + public boolean isLibraryContent() { + return (this.URL == UrlUtils.ABOUT_BOOKMARKS || + this.URL == UrlUtils.ABOUT_WEBAPPS || + this.URL == UrlUtils.ABOUT_HISTORY || + this.URL == UrlUtils.ABOUT_DOWNLOADS || + this.URL == UrlUtils.ABOUT_ADDONS); + }; } public enum WindowPlacement{