Skip to content

Commit ffc28a2

Browse files
committed
Add option to hide top bar, fix extension management on ATV.
1 parent 8404e9d commit ffc28a2

File tree

12 files changed

+54
-16
lines changed

12 files changed

+54
-16
lines changed

App/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ android {
66
minSdkVersion 23
77
versionCode 1200
88
versionName "1.2.0"
9-
targetSdk 34
9+
1010
ndk {
1111
//noinspection ChromeOsAbiSupport
1212
abiFilters "arm64-v8a"
@@ -34,10 +34,12 @@ android {
3434
}
3535
ext {
3636
// https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/
37-
geckoviewVersion = "131.0.20240923135042"
37+
geckoviewVersion = "129.0.20240819150008" // Newer versions have issues :(
3838
}
3939
dependencies {
40+
4041
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
42+
//noinspection GradleDependency
4143
implementation "org.mozilla.geckoview:geckoview:${geckoviewVersion}"
4244
//noinspection GradleDependency
4345
implementation 'androidx.datastore:datastore-preferences-rxjava3:1.0.0'

App/proguard-rules.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1616
# public *;
1717
#}
18+
-keep class androidx.lifecycle.** { *; }

App/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
android:documentLaunchMode="intoExisting"
4949
android:theme="@style/ThemeOverlay.Browser">
5050

51-
<layout android:defaultWidth="706dp" android:defaultHeight="442dp" android:gravity="top|end" />
51+
<layout android:defaultWidth="1024dp" android:defaultHeight="640dp" android:gravity="top|end" />
5252

5353
<meta-data android:name="com.oculus.vrshell.supports_free_resizing" android:value="true"/>
5454
<meta-data android:name="com.oculus.vrshell.free_resizing_limits" android:value="300,2000,500,1000"/>
@@ -101,7 +101,7 @@
101101
android:resizeableActivity="true"
102102
android:theme="@style/ThemeOverlay.Browser">
103103

104-
<layout android:defaultWidth="706dp" android:defaultHeight="442dp" android:gravity="top|end" />
104+
<layout android:defaultWidth="1024dp" android:defaultHeight="640dp" android:gravity="top|end" />
105105
<meta-data android:name="com.oculus.vrshell.supports_free_resizing" android:value="true"/>
106106
<meta-data android:name="com.oculus.vrshell.free_resizing_limits" android:value="300,2000,500,1000"/>
107107

App/src/main/java/com/threethan/browser/browser/BrowserActivity.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class BrowserActivity extends BoundActivity {
3636
protected final BookmarkManager bookmarkManager = new BookmarkManager(this);
3737
private boolean isEphemeral;
3838
private boolean isTab;
39+
private boolean isTopBarHidden;
3940
private final String DEFAULT_URL = "https://www.google.com/";
4041
@Override
4142
public void onCreate(Bundle savedInstanceState) {
@@ -76,6 +77,10 @@ public void onCreate(Bundle savedInstanceState) {
7677
if (tabId == null) tabId = BrowserService.TAB_PREFIX+"ext::"+currentUrl;
7778
Log.v("Lightning Browser", "... with url " + currentUrl + (isTab ? ", is a tab":", not a tab") + ", assigned id "+tabId);
7879

80+
if (!isTab) {
81+
isTopBarHidden = true;
82+
hideTopBar();
83+
}
7984

8085
// Back/Forward Buttons
8186
back = findViewById(R.id.back);
@@ -132,6 +137,13 @@ public void onCreate(Bundle savedInstanceState) {
132137
bookmarkManager.removeBookmark(currentUrl);
133138
});
134139

140+
// Hide top bar
141+
View hideBar = findViewById(R.id.hideBar);
142+
hideBar.setOnClickListener(v -> {
143+
isTopBarHidden = true;
144+
hideTopBar();
145+
});
146+
135147
// Edit URL
136148
View urlLayout = findViewById(R.id.urlLayout);
137149
EditText urlEdit = findViewById(R.id.urlEdit);
@@ -203,6 +215,7 @@ public void stopLoading() {
203215
public void showTopBar() {
204216
findViewById(R.id.topBar).setVisibility(View.VISIBLE);
205217
findViewById(R.id.topBarEdit).setVisibility(View.GONE);
218+
isTopBarHidden = false;
206219
}
207220
public void hideTopBar() {
208221
findViewById(R.id.topBar).setVisibility(View.GONE);
@@ -238,7 +251,9 @@ private void updateUrl(String url) {
238251

239252
@Override
240253
public void onBackPressed() {
241-
if (findViewById(R.id.topBarEdit).getVisibility() == View.VISIBLE)
254+
if (isTopBarHidden) {
255+
showTopBar();
256+
} else if (findViewById(R.id.topBarEdit).getVisibility() == View.VISIBLE)
242257
findViewById(R.id.cancel).callOnClick();
243258
else {
244259
if (w.canGoBack()) {

App/src/main/java/com/threethan/browser/browser/GeckoView/Delegate/CustomNavigationDelegate.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ public void onCanGoBack(@NonNull GeckoSession session, boolean canGoBack) {
3030
public void onCanGoForward(@NonNull GeckoSession session, boolean canGoForward) {
3131
this.canGoForward = canGoForward;
3232
}
33+
3334
@Override
34-
public void onLocationChange(@NonNull GeckoSession session, @Nullable String url,
35-
@NonNull List<GeckoSession.PermissionDelegate.ContentPermission> perms) {
36-
GeckoSession.NavigationDelegate.super.onLocationChange(session, url, perms);
35+
public void onLocationChange(@NonNull GeckoSession session, @Nullable String url, @NonNull List<GeckoSession.PermissionDelegate.ContentPermission> perms, @NonNull Boolean hasUserGesture) {
36+
GeckoSession.NavigationDelegate.super.onLocationChange(session, url, perms, hasUserGesture);
3737

3838
if (url != null && !url.isEmpty() && !url.equals("about:blank")) {
3939
currentUrl = url;

App/src/main/java/com/threethan/browser/browser/GeckoView/Delegate/ExtensionPromptDelegate.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
public class ExtensionPromptDelegate implements WebExtensionController.PromptDelegate {
2828
final static String EXTENSIONS_URL = "https://addons.mozilla.org/firefox/extensions/";
29+
/** @noinspection deprecation*/
2930
@Nullable
3031
@Override
3132
public GeckoResult<AllowOrDeny> onInstallPrompt(@NonNull WebExtension extension) {
@@ -39,14 +40,14 @@ public void showList() {
3940

4041
final AlertDialog dialog = Dialog.build(activity, R.layout.dialog_webextensions);
4142
assert dialog != null;
42-
dialog.hide();
4343

4444
dialog.findViewById(R.id.getMoreButton).setOnClickListener(view -> {
4545
if (activity instanceof BrowserActivity) {
4646
((BrowserActivity) activity).loadUrl(EXTENSIONS_URL);
4747
dialog.dismiss();
4848
}
4949
});
50+
5051
View dismiss = dialog.findViewById(R.id.dismissButton);
5152
dismiss.setOnClickListener(view -> dialog.dismiss());
5253

@@ -108,15 +109,13 @@ public View getView(final int position, View view, @NonNull final ViewGroup pare
108109
value.removeIf(webExtension -> webExtension.id.equals("fixes@internal.ext"));
109110
}
110111
adapter.addAll(value);
112+
111113
dialog.show();
112114

113115
ListView lv = dialog.findViewById(R.id.listView);
114116
lv.setAdapter(adapter);
115117
return null;
116118
});
117-
118-
119-
120119
}
121120
}
122121

App/src/main/res/drawable/web_up.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="20dp" android:tint="#FFFFFF"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="20dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M8.12 14.71 12 10.83l3.88 3.88c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41l-4.59-4.59c-.39-.39-1.02-.39-1.41 0L6.7 13.3c-.39.39-.39 1.02 0 1.41.39.38 1.03.39 1.42 0z"/>
5+
</vector>

App/src/main/res/layout/activity_browser.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,19 @@
168168
android:visibility="gone"
169169
tools:ignore="UnusedAttribute" />
170170

171+
<ImageButton
172+
android:id="@+id/hideBar"
173+
android:layout_width="39dp"
174+
android:layout_height="match_parent"
175+
android:layout_gravity="center_vertical"
176+
android:layout_marginStart="8dp"
177+
android:layout_marginTop="8dp"
178+
android:layout_marginBottom="8dp"
179+
android:background="@drawable/bkg_button_web"
180+
android:src="@drawable/web_up"
181+
android:tooltipText="@string/web_hide_bar"
182+
tools:ignore="UnusedAttribute" />
183+
171184
<ImageButton
172185
android:id="@+id/exit"
173186
android:layout_width="39dp"

App/src/main/res/layout/dialog_webextensions.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
android:layout_width="wrap_content"
44
android:layout_height="wrap_content"
55
android:background="@drawable/bkg_dialog"
6-
android:descendantFocusability="blocksDescendants"
7-
android:focusable="false"
86
android:orientation="vertical"
97
android:padding="20dp">
108

@@ -35,13 +33,16 @@
3533
</ListView>
3634

3735
<TextView
36+
3837
android:id="@+id/getMoreButton"
3938
style="@style/SettingsText"
4039
android:layout_width="match_parent"
4140
android:layout_height="40dp"
4241
android:layout_marginTop="10dp"
4342
android:background="@drawable/bkg_button"
4443
android:gravity="center"
45-
android:text="@string/extension_prompt_hint" />
44+
android:text="@string/extension_prompt_hint">
45+
<requestFocus/>
46+
</TextView>
4647

4748
</com.threethan.browser.browser.CursorLayout>

App/src/main/res/values-zh-rCN/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<string name="web_forward">前进</string>
5252
<string name="web_reload">刷新页面</string>
5353
<string name="web_exit">退出选项卡</string>
54+
<string name="web_hide_bar">隐藏顶部栏</string>
5455
<string name="web_add_bookmark">将页面添加到芸签</string>
5556
<string name="web_remove_bookmark">从标签中删除芸签</string>
5657
<string name="web_cancel">关闭</string>

App/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<string name="web_forward">Navigate Forward</string>
6363
<string name="web_reload">Refresh this Page</string>
6464
<string name="web_exit">Minimize Tab</string>
65+
<string name="web_hide_bar">Hide Top Bar</string>
6566
<string name="web_add_bookmark">Add Page to Bookmarks</string>
6667
<string name="web_remove_bookmark">Remove Bookmark</string>
6768
<string name="web_cancel">Cancel</string>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A powerful Gecko-based browser for Android TV and VR.
44
*(Previously part of [LightningLauncher](https://github.com/threethan/LightningLauncher))*
55

66
## Features
7-
- Dynamic cursor that allows for easy nagivation with an Android TV remote control
7+
- Dynamic cursor that allows for easy navigation with an Android TV remote control
88
- Uses GeckoView (Firefox's core) for a modern browser even on outdated devices
99
- Full support for Firefox extensions
1010
- Minimal, dynamic UI for easy navigation on screens big or small

0 commit comments

Comments
 (0)