Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create New Tab page and add an option to set New Tab page as homepage #1574

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

haanhvu
Copy link
Collaborator

@haanhvu haanhvu commented Oct 15, 2024

First step for #1318: Create initial New Tab page that has Wolvic logo and add an option in Display Settings to set New Tab page as homepage

This should be released when all the steps have been done and #1318 is closed.

@haanhvu
Copy link
Collaborator Author

haanhvu commented Oct 15, 2024

@felipeerias @svillar (and other maintainers) This is a very draft initial implementation. Currently I just added a Homepage option that shows Bookmarks panel like this: https://drive.google.com/file/d/1feSPqru-LJJOmQ3kwPKKuEXal9dirkbr/view?usp=sharing

I'm thinking of creating a specific New Tab page that shows bookmarks (and maybe other things too?). Do you have any ideas on how that New Tab page should look like? Is there any existing layout that I can use for this page?

@haanhvu haanhvu changed the title Add an option that shows bookmarks in Homepage/New tab Add an option that shows bookmarks as Homepage/New tab Oct 15, 2024
@svillar
Copy link
Member

svillar commented Oct 15, 2024

@felipeerias @svillar (and other maintainers) This is a very draft initial implementation. Currently I just added a Homepage option that shows Bookmarks panel like this: https://drive.google.com/file/d/1feSPqru-LJJOmQ3kwPKKuEXal9dirkbr/view?usp=sharing

I'm thinking of creating a specific New Tab page that shows bookmarks (and maybe other things too?). Do you have any ideas on how that New Tab page should look like? Is there any existing layout that I can use for this page?

I think we should be consistent with what others do. See Desktop Firefox, Chrome, or Edge for inspiration

@haanhvu haanhvu force-pushed the issue1318 branch 2 times, most recently from 64fb0d9 to 218b7b8 Compare October 22, 2024 17:51
@haanhvu haanhvu changed the title Add an option that shows bookmarks as Homepage/New tab Create New Tab page and add an option to set New Tab page as homepage Nov 4, 2024
@haanhvu haanhvu force-pushed the issue1318 branch 5 times, most recently from bf3f824 to 8ffd64b Compare November 12, 2024 08:13
@haanhvu haanhvu force-pushed the issue1318 branch 2 times, most recently from 01ac05b to 96768a2 Compare November 18, 2024 06:38
@haanhvu
Copy link
Collaborator Author

haanhvu commented Nov 18, 2024

@felipeerias @svillar (and other maintainers) There's bug in the New Tab page that I'm not having any clues to debug. Basically, the hovering point is not exactly as it's showing.

For example:
Screenshot from 2024-11-18 16-27-08
As you can see, the hovering point is outside of the page item, however, somehow the New Tab page sees the point as being inside the page item, and shows the trash icon.

The reverse is true too: when I actually hover in the item, the page doesn't recognize that and doesn't show the trash icon:
Screenshot from 2024-11-18 16-42-22

Could you help me to debug this? Thanks!

Copy link
Collaborator

@felipeerias felipeerias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is great work 🙂

In addition to these suggestions, we also need to add the New Page to the WindowViewModel so other elements in the UI are updated correctly.

See WindowViewModel.setIsLibraryVisible() and WindowViewModel.getIsLibraryVisible() for reference.

@haanhvu
Copy link
Collaborator Author

haanhvu commented Nov 26, 2024

@felipeerias I have simplified the initial UI of the New Tab page like you suggested (the more complete UI is stored here as references for next PRs: https://github.com/haanhvu/wolvic/tree/issue1318-skeleton)

I have also enabled going back to New Tab from another page or library panel.

I'll wait for #1644 to be merged first to continue on it. Basically if #1644 works for library panel it would work for New Tab too

@haanhvu haanhvu force-pushed the issue1318 branch 3 times, most recently from b5206ba to 4d02e46 Compare December 5, 2024 05:51
Copy link
Collaborator Author

@haanhvu haanhvu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felipeerias I have applied your suggestions and fixed the remaining bugs. Think we can undraft this now. Please review and see whether there are any other bugs. Thanks!

I'll add notes for some changes that don't seem very apparent:

isNativeContentVisible = new MediatorLiveData<>();
isNativeContentVisible.addSource(currentContentType, contentType ->
isNativeContentVisible.setValue(new ObservableBoolean(contentType != Windows.ContentType.WEB_CONTENT))
isNativeContentVisible.setValue(new ObservableBoolean(contentType != Windows.ContentType.WEB_CONTENT && contentType != Windows.ContentType.NEW_TAB))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I excluded New Tab here. Because as I see there're many places we're dealing with library content only, but there're no places where we deal with library and new tab content together. Do you agree? If yes should we change the name to isLibraryContentVisible?

Copy link
Collaborator

@felipeerias felipeerias Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isNativeContentVisible indicates that Android UI is being shown, so it should also include New Tab.

This property is mainly used to address the different requirements of Web content and Android UI.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this to the review. Simply restore the previous lines:

isNativeContentVisible.setValue(new ObservableBoolean(contentType != Windows.ContentType.WEB_CONTENT))

@@ -239,9 +249,12 @@ public void onChanged(ObservableBoolean o) {
@Override
public void onChanged(Spannable aUrl) {
String url = aUrl.toString();
if (isNativeContentVisible.getValue().get()) {
if (isNativeContentVisible.getValue().get() && currentContentType.getValue() != Windows.ContentType.NEW_TAB) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though isNativeContentVisible does not include New Tab now, there are currently still some lines like this, because I want to remember these are where we check for library content only. Once we agree what isNativeContentVisible include I'll clean up these lines.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned above, isNativeContentVisible should include New Tab so this line can stay as is.

Comment on lines +591 to +594
if (switchSurface && mRestoreFirstPaint != null) {
mRestoreFirstPaint.run();
mRestoreFirstPaint = null;
}
Copy link
Collaborator Author

@haanhvu haanhvu Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L591-594 already existed in hidePanel(boolean switchSurface). I actually added these lines to hideNewTab(boolean switchSurface). But somehow Github shows that I added to hidePanel().

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. Thank you for the clarification.

Comment on lines +186 to +192
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);
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we agree isNativeContenVisible does not include New Tab, then this function is probably not needed. I'll clean up later once we agree what isNativeContenVisible includes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this method is a good idea.

However. it is using == to compare Strings, which might lead to trouble in Java. This is one possible way to rewrite it:

    public boolean isLibraryContent() {
        switch (this) {
            case BOOKMARKS:
            case WEB_APPS:
            case HISTORY:
            case DOWNLOADS:
            case ADDONS:
                return true;
            default:
                return false;
        }

@@ -188,7 +188,7 @@
android:id="@+id/bookmarksButton"
style="@style/trayButtonMiddleTheme"
android:src="@drawable/ic_icon_bookmark"
android:tooltipText="@{viewmodel.currentContentType == ContentType.BOOKMARKS ? @string/close_library_tooltip : @string/open_library_tooltip}"
android:tooltipText="@{viewmodel.currentContentType == ContentType.BOOKMARKS ? @string/close_library_tooltip : @string/open_bookmarks_tooltip}"
Copy link
Collaborator Author

@haanhvu haanhvu Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and L204 are not in the scope of this PR. But I think these are correct fixes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, these were fixed in #1655

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. These were fixed, no need to include this particular change in this PR.

@haanhvu haanhvu marked this pull request as ready for review December 6, 2024 06:33
Copy link
Collaborator

@felipeerias felipeerias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much, this is a great job. I have a few comments pointing some things that need to be changed.

Additionally:

In TrayWidget.java mCurrentContentTypeObserver (line 608) we need to change this line:

if (contentType == Windows.ContentType.WEB_CONTENT) {

into this one:

if (contentType == Windows.ContentType.WEB_CONTENT || contentType == Windows.ContentType.NEW_TAB) {

otherwise there is a small glitch in the Bookmarks icon in the tray.

Comment on lines +186 to +192
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);
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this method is a good idea.

However. it is using == to compare Strings, which might lead to trouble in Java. This is one possible way to rewrite it:

    public boolean isLibraryContent() {
        switch (this) {
            case BOOKMARKS:
            case WEB_APPS:
            case HISTORY:
            case DOWNLOADS:
            case ADDONS:
                return true;
            default:
                return false;
        }

isNativeContentVisible = new MediatorLiveData<>();
isNativeContentVisible.addSource(currentContentType, contentType ->
isNativeContentVisible.setValue(new ObservableBoolean(contentType != Windows.ContentType.WEB_CONTENT))
isNativeContentVisible.setValue(new ObservableBoolean(contentType != Windows.ContentType.WEB_CONTENT && contentType != Windows.ContentType.NEW_TAB))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this to the review. Simply restore the previous lines:

isNativeContentVisible.setValue(new ObservableBoolean(contentType != Windows.ContentType.WEB_CONTENT))

@@ -188,7 +188,7 @@
android:id="@+id/bookmarksButton"
style="@style/trayButtonMiddleTheme"
android:src="@drawable/ic_icon_bookmark"
android:tooltipText="@{viewmodel.currentContentType == ContentType.BOOKMARKS ? @string/close_library_tooltip : @string/open_library_tooltip}"
android:tooltipText="@{viewmodel.currentContentType == ContentType.BOOKMARKS ? @string/close_library_tooltip : @string/open_bookmarks_tooltip}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. These were fixed, no need to include this particular change in this PR.

@@ -201,7 +201,7 @@
<com.igalia.wolvic.ui.views.UIButton
android:id="@+id/downloadsButton"
style="@style/trayButtonMiddleTheme"
android:tooltipText="@{viewmodel.currentContentType == ContentType.DOWNLOADS ? @string/close_library_tooltip : @string/open_library_tooltip}"
android:tooltipText="@{viewmodel.currentContentType == ContentType.DOWNLOADS ? @string/close_library_tooltip : @string/open_downloads_tooltip}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, already fixed.

private MediatorLiveData<ObservableBoolean> isNativeContentVisible;
private MutableLiveData<ObservableBoolean> backToNewTabEnabled;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you had to add new attributes in the WindowViewModel to keep track of the current state, specially when the user browses back and forward, shows and hides the library, etc. Perhaps not all of these are needed and we can use the current URL to select the appropriate UI and content type (but maybe that is just wishful thinking on my part :-) ).

One question that comes to mind is whether these need to be part of the WindowViewModel instead of being internal properties of WindowWidget, for example. The view model is specially useful to listen to changes in particular values and to update XML layouts automatically.

Another observation is that this code tries to manipulate how the Back and Forward navigation works, and the result can be a bit confusing sometimes. This happens specially when we combine back/forward with the Home button.

In this case, I think it is better to leave that behaviour as something internal to the Web engine (Gecko or Chromium). Personally, I often use desktop Firefox as the reference when trying to understand how this navigation should work,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants