Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -16,15 +17,18 @@
import org.mozilla.vrbrowser.audio.AudioEngine;
import org.mozilla.vrbrowser.browser.SessionChangeListener;
import org.mozilla.vrbrowser.ui.views.UIButton;
import org.mozilla.vrbrowser.ui.views.UITextButton;

public class TopBarWidget extends UIWidget implements SessionChangeListener, WidgetManagerDelegate.UpdateListener {

private UIButton mCloseButton;
private UIButton mMoveLeftButton;
private UIButton mMoveRightButton;
private UITextButton mClearButton;
private AudioEngine mAudio;
private WindowWidget mAttachedWindow;
private TopBarWidget.Delegate mDelegate;
private LinearLayout mMultiWindowControlsContainer;
private boolean mVisible;

public TopBarWidget(Context aContext) {
Expand All @@ -51,6 +55,8 @@ public interface Delegate {
private void initialize(Context aContext) {
inflate(aContext, R.layout.top_bar, this);

mMultiWindowControlsContainer = findViewById(R.id.multiWindowControlsContainer);

mCloseButton = findViewById(R.id.closeWindowButton);
mCloseButton.setOnClickListener(view -> {
view.requestFocusFromTouch();
Expand Down Expand Up @@ -84,7 +90,16 @@ private void initialize(Context aContext) {
}
});


mClearButton = findViewById(R.id.clearButton);
mClearButton.setOnClickListener(view -> {
view.requestFocusFromTouch();
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}
if (mDelegate != null) {
mDelegate.onCloseClicked(TopBarWidget.this);
}
});

mAudio = AudioEngine.fromContext(aContext);

Expand Down Expand Up @@ -164,6 +179,11 @@ public void setVisible(boolean aIsVisible) {
}
}

public void setClearMode(boolean showClear) {
mMultiWindowControlsContainer.setVisibility(showClear ? GONE : VISIBLE);
mClearButton.setVisibility(showClear ? VISIBLE : GONE);
}

public void setDelegate(TopBarWidget.Delegate aDelegate) {
mDelegate = aDelegate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ private void updateTopBars() {
boolean visible = mFullscreenWindow == null && (windows.size() > 1 || isInPrivateMode());
for (WindowWidget window: windows) {
window.getTopBar().setVisible(visible);
window.getTopBar().setClearMode((windows.size() == 1 && isInPrivateMode()));
if (visible) {
window.getTopBar().setMoveLeftButtonEnabled(window != leftWindow);
window.getTopBar().setMoveRightButtonEnabled(window != rightWindow);
Expand Down
31 changes: 31 additions & 0 deletions app/src/main/res/drawable/text_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false">
<shape android:shape="rectangle">
<solid android:color="@color/asphalt" />
<corners
android:radius="20dp" />
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/void_color" />
<corners
android:radius="20dp" />
</shape>
</item>
<item android:state_hovered="true" android:state_pressed="false">
<shape android:shape="rectangle">
<solid android:color="@color/fog" />
<corners
android:radius="20dp" />
</shape>
</item>
<item android:state_hovered="false" android:state_pressed="false">
<shape android:shape="rectangle">
<solid android:color="@color/asphalt" />
<corners
android:radius="20dp" />
</shape>
</item>
</selector>
31 changes: 31 additions & 0 deletions app/src/main/res/drawable/text_button_private.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false">
<shape android:shape="rectangle">
<solid android:color="@color/eggplant" />
<corners
android:radius="20dp" />
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/blackberry" />
<corners
android:radius="20dp" />
</shape>
</item>
<item android:state_hovered="true" android:state_pressed="false">
<shape android:shape="rectangle">
<solid android:color="@color/fog" />
<corners
android:radius="20dp" />
</shape>
</item>
<item android:state_hovered="false" android:state_pressed="false">
<shape android:shape="rectangle">
<solid android:color="@color/eggplant" />
<corners
android:radius="20dp" />
</shape>
</item>
</selector>
62 changes: 41 additions & 21 deletions app/src/main/res/layout/top_bar.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
style="?attr/navigationBarStyle"
android:id="@+id/fullScreenModeContainer"

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:padding="0dp"
android:orientation="horizontal">
<org.mozilla.vrbrowser.ui.views.UIButton
android:id="@+id/moveWindowLeftButton"
style="?attr/fullScreenButtonStyle"
android:background="@drawable/fullscreen_button_first"
android:src="@drawable/ic_icon_window_left" />
<org.mozilla.vrbrowser.ui.views.UIButton
android:id="@+id/closeWindowButton"
style="?attr/fullScreenButtonStyle"
android:src="@drawable/ic_icon_window_exit" />
<org.mozilla.vrbrowser.ui.views.UIButton
android:id="@+id/moveWindowRightButton"
android:background="@drawable/fullscreen_button_last"
style="?attr/fullScreenButtonStyle"
android:src="@drawable/ic_icon_window_right" />
</LinearLayout>
android:layout_gravity="center"
android:gravity="center_horizontal">

<LinearLayout
android:id="@+id/multiWindowControlsContainer"
style="?attr/navigationBarStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:padding="0dp">

<org.mozilla.vrbrowser.ui.views.UIButton
android:id="@+id/moveWindowLeftButton"
style="?attr/fullScreenButtonStyle"
android:background="@drawable/fullscreen_button_first"
android:src="@drawable/ic_icon_window_left" />

<org.mozilla.vrbrowser.ui.views.UIButton
android:id="@+id/closeWindowButton"
style="?attr/fullScreenButtonStyle"
android:src="@drawable/ic_icon_window_exit" />

<org.mozilla.vrbrowser.ui.views.UIButton
android:id="@+id/moveWindowRightButton"
style="?attr/fullScreenButtonStyle"
android:background="@drawable/fullscreen_button_last"
android:src="@drawable/ic_icon_window_right" />
</LinearLayout>

<org.mozilla.vrbrowser.ui.views.UITextButton
android:id="@+id/clearButton"
style="@style/textButtonTheme"
android:background="@drawable/text_button_private"
android:text="@string/private_clear_button"
android:textAllCaps="true"
android:textSize="@dimen/text_medium_big_size"
android:visibility="gone" />
</FrameLayout>
</merge>
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -901,4 +901,8 @@

<!-- This string is displayed in the URL bar when the user is in the history panel -->
<string name="url_history_title">History</string>

<!-- This string is displayed in the Clear button on top of the window when in private mode. It only appears
when there is one window left. When clicked, it closes the private session -->
<string name="private_clear_button">Clear</string>
</resources>
15 changes: 15 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@
<item name="privateModeTintColorList">@drawable/main_button_icon_color_private</item>
</style>

<style name="textButtonTheme">
<item name="android:background">@drawable/text_button_private</item>
<item name="android:padding">10dp</item>
<item name="android:paddingStart">20dp</item>
<item name="android:paddingEnd">20dp</item>
<item name="android:layout_gravity">center</item>
<item name="android:gravity">center</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">40dp</item>
<item name="android:textAlignment">center</item>
<item name="tintColorList">@drawable/main_button_icon_color</item>
<item name="privateModeTintColorList">@drawable/main_button_icon_color_private</item>
<item name="privateModeBackground">@drawable/text_button</item>
</style>

<style name="navigationBarTextButtonStartTheme" parent="navigationBarTextButtonTheme">
<item name="android:background">@drawable/fullscreen_button_first</item>
<item name="privateModeBackground">@drawable/fullscreen_button_private_first</item>
Expand Down