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

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

haanhvu
Copy link
Collaborator

@haanhvu haanhvu commented Oct 15, 2024

fix #1318

@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.

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 the changes in this file are not needed for now. I would rather focus this PR on just getting the basic functionality. Let's implement the New Tab content in subsequent PRs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a good idea but let's move it to a separate PR once we land this one.

@@ -111,6 +111,7 @@ public void updateUI() {
mBinding.setBookmarksViewModel(mViewModel);
mBinding.setCallback(mBookmarksCallback);
mBookmarkAdapter = new BookmarkAdapter(mBookmarkItemCallback, getContext());
mBookmarkAdapter = new BookmarkAdapter(mBookmarkItemCallback, getContext());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Duplicated line.

SettingsStore.getInstance(getContext()).setHomepage(mDefaultHomepageUrl);
} else if (checkedId == 1) {
mBinding.homepageEdit.setVisibility(View.GONE);
SettingsStore.getInstance(getContext()).setHomepage("about://newtab");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use UrlUtils.isNewTabUrl()

private int getHomepageId(String homepage) {
if (homepage == getContext().getString(R.string.HOMEPAGE_URL)) {
return 0;
} else if (homepage == "about://newtab") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use UrlUtils.isNewTabUrl()

if (mNewTab != null) {
setView(mNewTab, true);
mViewModel.setIsFindInPage(false);
final Runnable firstDrawCallback = mFirstDrawCallback;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure, but I think that we need to have the same check as in showPanel() below.

if (mRestoreFirstPaint == null && !isFirstPaintReady() && (mFirstDrawCallback != null) && (mSurface != null)) {
...

if(UrlUtils.isBookmarksUrl(uri.toString())) {
showPanel(Windows.BOOKMARKS);
if(UrlUtils.isBookmarksUrl(uri.toString())) {
hideNewTab(true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can make showPanel(…) hide the New Tab view?

SettingsStore.getInstance(getContext()).setHomepage(mDefaultHomepageUrl);
} else if (checkedId == 1) {
mBinding.homepageEdit.setVisibility(View.GONE);
SettingsStore.getInstance(getContext()).setHomepage("about://newtab");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use UrlUtils.ABOUT_NEWTAB.

}

private int getHomepageId(String homepage) {
if (homepage == getContext().getString(R.string.HOMEPAGE_URL)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to use equals() in Java to compare strings.

private int getHomepageId(String homepage) {
if (homepage == getContext().getString(R.string.HOMEPAGE_URL)) {
return 0;
} else if (homepage == "about://newtab") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use equals() and UrlUtils.ABOUT_NEWTAB.

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.

Speed Dial on New Tab
3 participants