Skip to content

Commit

Permalink
Suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeerias authored and haanhvu committed Nov 21, 2024
1 parent e1daefe commit 5574b0c
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 439 deletions.
29 changes: 0 additions & 29 deletions app/src/common/shared/com/igalia/wolvic/ui/adapters/Bookmark.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.igalia.wolvic.ui.adapters;

import android.util.Log;

import androidx.annotation.NonNull;

import java.util.ArrayList;
Expand All @@ -27,11 +25,6 @@ public enum Type {
private Type mType;
private boolean mHasChildren;

public Bookmark(String title, String url) {
mTitle = title;
mURL = url;
}

public Bookmark(@NonNull BookmarkNode node, int level, boolean isExpanded) {
mIsExpanded = isExpanded;
mLevel = level;
Expand Down Expand Up @@ -138,28 +131,6 @@ private static List<Bookmark> getDisplayListTree(@NonNull List<BookmarkNode> boo
return children;
}

/*public static List<Bookmark> getBookmarkItems(@NonNull List<BookmarkNode> bookmarkNodes) {
Log.e("New Tab", "Bookmark nodes size: " + bookmarkNodes.size());
ArrayList<Bookmark> bookmarkItems = new ArrayList<>();
for (BookmarkNode node : bookmarkNodes) {
if (node.getType() == BookmarkNodeType.ITEM) {
//if (node.getTitle() != null) {
//if (node.getType() != BookmarkNodeType.FOLDER && node.getTitle() != null) {
Log.e("New Tab", "Bookmark node's item type recognized");
Bookmark bookmark = new Bookmark(node, 0, false);
bookmarkItems.add(bookmark);
} else {
Log.e("New Tab", "Not item type. Real type: " + node.getType());
}
}
Log.e("New Tab", "Bookmark items size: " + bookmarkItems.size());
return bookmarkItems;
}*/

/**
* Traverses the current display list looking for opened folders
* @param displayList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ static class BookmarkViewHolder extends RecyclerView.ViewHolder {
}

static class BookmarkFolderViewHolder extends RecyclerView.ViewHolder {

final BookmarkItemFolderBinding binding;

BookmarkFolderViewHolder(@NonNull BookmarkItemFolderBinding binding) {
Expand Down
186 changes: 0 additions & 186 deletions app/src/common/shared/com/igalia/wolvic/ui/adapters/NewTabAdapter.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class WindowViewModel extends AndroidViewModel {
private MutableLiveData<ObservableBoolean> isActiveWindow;
private MediatorLiveData<ObservableBoolean> isTitleBarVisible;
private MutableLiveData<ObservableBoolean> isLibraryVisible;
private MutableLiveData<ObservableBoolean> isNewTabVisible;
private MutableLiveData<ObservableBoolean> isLoading;
private MutableLiveData<ObservableBoolean> isMicrophoneEnabled;
private MutableLiveData<ObservableBoolean> isBookmarked;
Expand Down Expand Up @@ -129,6 +130,7 @@ public WindowViewModel(Application application) {
isTitleBarVisible.setValue(new ObservableBoolean(true));

isLibraryVisible = new MutableLiveData<>(new ObservableBoolean(false));
isNewTabVisible = new MutableLiveData<>(new ObservableBoolean(false));

isLoading = new MutableLiveData<>(new ObservableBoolean(false));
isMicrophoneEnabled = new MutableLiveData<>(new ObservableBoolean(true));
Expand All @@ -152,6 +154,7 @@ public WindowViewModel(Application application) {
isInsecureVisible.addSource(isInsecure, mIsInsecureVisibleObserver);
isInsecureVisible.addSource(isPrivateSession, mIsInsecureVisibleObserver);
isInsecureVisible.addSource(isLibraryVisible, mIsInsecureVisibleObserver);
isInsecureVisible.addSource(isNewTabVisible, mIsInsecureVisibleObserver);
isInsecureVisible.setValue(new ObservableBoolean(false));

isMediaAvailable = new MutableLiveData<>(new ObservableBoolean(false));
Expand All @@ -173,6 +176,7 @@ public WindowViewModel(Application application) {
isUrlBarButtonsVisible.addSource(isPopUpAvailable, mIsUrlBarButtonsVisibleObserver);
isUrlBarButtonsVisible.addSource(isWebXRUsed, mIsUrlBarButtonsVisibleObserver);
isUrlBarButtonsVisible.addSource(isLibraryVisible, mIsUrlBarButtonsVisibleObserver);
isUrlBarButtonsVisible.addSource(isNewTabVisible, mIsUrlBarButtonsVisibleObserver);
isUrlBarButtonsVisible.addSource(isFocused, mIsUrlBarButtonsVisibleObserver);
isUrlBarButtonsVisible.setValue(new ObservableBoolean(false));

Expand Down Expand Up @@ -231,6 +235,9 @@ public void onChanged(Spannable aUrl) {
if (isLibraryVisible.getValue().get()) {
url = getApplication().getString(R.string.url_library_title);

} else if (isNewTabVisible.getValue().get()) {
url = getApplication().getString(R.string.url_new_tab_title);

} else {
if (UrlUtils.isPrivateAboutPage(getApplication(), url) ||
(UrlUtils.isDataUri(url) && isPrivateSession.getValue().get())) {
Expand Down Expand Up @@ -261,6 +268,7 @@ public void onChanged(ObservableBoolean o) {
UrlUtils.isFileUri(aUrl) ||
UrlUtils.isHomeUri(getApplication(), aUrl) ||
isLibraryVisible.getValue().get() ||
isNewTabVisible.getValue().get() ||
UrlUtils.isBlankUri(getApplication(), aUrl)) {
isInsecureVisible.postValue(new ObservableBoolean(false));

Expand All @@ -282,6 +290,7 @@ public void onChanged(Spannable aUrl) {
(UrlUtils.isDataUri(url) && isPrivateSession.getValue().get()) ||
UrlUtils.isHomeUri(getApplication(), aUrl.toString()) ||
isLibraryVisible.getValue().get() ||
isNewTabVisible.getValue().get() ||
UrlUtils.isBlankUri(getApplication(), aUrl.toString())) {
navigationBarUrl.postValue("");

Expand All @@ -298,6 +307,7 @@ public void onChanged(ObservableBoolean o) {
isUrlBarButtonsVisible.postValue(new ObservableBoolean(
!isFocused.getValue().get() &&
!isLibraryVisible.getValue().get() &&
!isNewTabVisible.getValue().get() &&
!UrlUtils.isContentFeed(getApplication(), aUrl) &&
!UrlUtils.isPrivateAboutPage(getApplication(), aUrl) &&
(URLUtil.isHttpUrl(aUrl) || URLUtil.isHttpsUrl(aUrl)) &&
Expand All @@ -317,6 +327,7 @@ public void onChanged(ObservableBoolean o) {
public void onChanged(ObservableBoolean o) {
isUrlBarIconsVisible.postValue(new ObservableBoolean(
!isLibraryVisible.getValue().get() &&
!isNewTabVisible.getValue().get() &&
(isLoading.getValue().get() ||
isInsecureVisible.getValue().get())
));
Expand Down Expand Up @@ -430,6 +441,9 @@ private String getHintValue() {
if (isLibraryVisible.getValue().get()) {
return getApplication().getString(R.string.url_library_title);

} else if (isNewTabVisible.getValue().get()) {
return getApplication().getString(R.string.url_new_tab_title);

} else {
return getApplication().getString(R.string.search_placeholder);
}
Expand Down Expand Up @@ -577,6 +591,16 @@ public MutableLiveData<ObservableBoolean> getIsLibraryVisible() {
return isLibraryVisible;
}

public void setIsNewTabVisible(boolean isNewTabVisible) {
this.isNewTabVisible.postValue(new ObservableBoolean(isNewTabVisible));
this.url.postValue(this.getUrl().getValue());
}

@NonNull
public MutableLiveData<ObservableBoolean> getIsNewTabVisible() {
return isNewTabVisible;
}

@NonNull
public MutableLiveData<ObservableBoolean> getIsLoading() {
return isLoading;
Expand Down
Loading

0 comments on commit 5574b0c

Please sign in to comment.