-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of browser tabs
The Tabs Bar is a small window that sits next to the current window and which lists the open tabs. There are two implementations: - HorizontalTabsBar on the top of the window - VerticalTabsBar on the side of the window The Tabs Bar is managed by VRBrowserActivity. SessionStore now keeps a list of session change listeners. TabDelegate is moved to a separate interface. The current tabs style can be changed in Settings -> Display. WindowViewModel is updated to hide the Tabs Bar ass needed. Note that we don't (yet) link windows and tabs, so the interface gets a bit confusing when we have more than one window open.
- Loading branch information
1 parent
22da6fa
commit af15e21
Showing
29 changed files
with
1,081 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
app/src/common/shared/com/igalia/wolvic/ui/adapters/TabsBarAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.igalia.wolvic.ui.adapters; | ||
|
||
import android.view.LayoutInflater; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.LayoutRes; | ||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import com.igalia.wolvic.R; | ||
import com.igalia.wolvic.browser.engine.Session; | ||
import com.igalia.wolvic.ui.views.TabsBarItem; | ||
import com.igalia.wolvic.ui.widgets.TabDelegate; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class TabsBarAdapter extends RecyclerView.Adapter<TabsBarAdapter.ViewHolder> { | ||
|
||
public enum Orientation {HORIZONTAL, VERTICAL} | ||
|
||
private final TabDelegate mTabDelegate; | ||
private final Orientation mOrientation; | ||
private final List<Session> mTabs = new ArrayList<>(); | ||
|
||
static class ViewHolder extends RecyclerView.ViewHolder { | ||
TabsBarItem mTabBarItem; | ||
|
||
ViewHolder(TabsBarItem v) { | ||
super(v); | ||
mTabBarItem = v; | ||
} | ||
} | ||
|
||
public TabsBarAdapter(@NonNull TabDelegate tabDelegate, Orientation orientation) { | ||
mTabDelegate = tabDelegate; | ||
mOrientation = orientation; | ||
} | ||
|
||
@Override | ||
public long getItemId(int position) { | ||
if (position == 0) { | ||
return 0; | ||
} else { | ||
return mTabs.get(position - 1).getId().hashCode(); | ||
} | ||
} | ||
|
||
public void updateTabs(List<Session> aTabs) { | ||
mTabs.clear(); | ||
mTabs.addAll(aTabs); | ||
|
||
notifyDataSetChanged(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
@LayoutRes int layout; | ||
if (mOrientation == Orientation.HORIZONTAL) { | ||
layout = R.layout.tabs_bar_item_horizontal; | ||
} else { | ||
layout = R.layout.tabs_bar_item_vertical; | ||
} | ||
TabsBarItem view = (TabsBarItem) LayoutInflater.from(parent.getContext()).inflate(layout, parent, false); | ||
return new ViewHolder(view); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) { | ||
holder.mTabBarItem.setDelegate(mItemDelegate); | ||
|
||
Session session = mTabs.get(position); | ||
holder.mTabBarItem.attachToSession(session); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return mTabs.size(); | ||
} | ||
|
||
private final TabsBarItem.Delegate mItemDelegate = new TabsBarItem.Delegate() { | ||
@Override | ||
public void onClick(TabsBarItem item) { | ||
mTabDelegate.onTabSelect(item.getSession()); | ||
} | ||
|
||
@Override | ||
public void onClose(TabsBarItem item) { | ||
mTabDelegate.onTabsClose(Collections.singletonList(item.getSession())); | ||
} | ||
}; | ||
} |
Oops, something went wrong.