-
-
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 gets three new fields: - isTabsBarVisible - usesHorizontalTabsBar - usesVerticalTabsBar TopBarWidget uses two of these fields to update its placement so as to not overlap with the tabs bar. 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. WidgetPlacement gets two new fields: horizontalOffset, verticalOffset. These define a translation offset (in world dimensions), which is applied after the anchors have been calculated. The goal is to be able to move widgets from their initial position in a predictable way, to make space for the tabs bar when necessary.
- Loading branch information
1 parent
15e6cff
commit d4a54d9
Showing
35 changed files
with
1,198 additions
and
24 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
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
90 changes: 90 additions & 0 deletions
90
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,90 @@ | ||
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) { | ||
return (position == 0) ? 0 : 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())); | ||
} | ||
}; | ||
} |
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
Oops, something went wrong.