Skip to content

Commit

Permalink
Add option to hide top bar, fix extension management on ATV.
Browse files Browse the repository at this point in the history
  • Loading branch information
threethan committed Oct 8, 2024
1 parent 8404e9d commit ffc28a2
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 16 deletions.
6 changes: 4 additions & 2 deletions App/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {
minSdkVersion 23
versionCode 1200
versionName "1.2.0"
targetSdk 34

ndk {
//noinspection ChromeOsAbiSupport
abiFilters "arm64-v8a"
Expand Down Expand Up @@ -34,10 +34,12 @@ android {
}
ext {
// https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/
geckoviewVersion = "131.0.20240923135042"
geckoviewVersion = "129.0.20240819150008" // Newer versions have issues :(
}
dependencies {

implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
//noinspection GradleDependency
implementation "org.mozilla.geckoview:geckoview:${geckoviewVersion}"
//noinspection GradleDependency
implementation 'androidx.datastore:datastore-preferences-rxjava3:1.0.0'
Expand Down
1 change: 1 addition & 0 deletions App/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep class androidx.lifecycle.** { *; }
4 changes: 2 additions & 2 deletions App/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
android:documentLaunchMode="intoExisting"
android:theme="@style/ThemeOverlay.Browser">

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class BrowserActivity extends BoundActivity {
protected final BookmarkManager bookmarkManager = new BookmarkManager(this);
private boolean isEphemeral;
private boolean isTab;
private boolean isTopBarHidden;
private final String DEFAULT_URL = "https://www.google.com/";
@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -76,6 +77,10 @@ public void onCreate(Bundle savedInstanceState) {
if (tabId == null) tabId = BrowserService.TAB_PREFIX+"ext::"+currentUrl;
Log.v("Lightning Browser", "... with url " + currentUrl + (isTab ? ", is a tab":", not a tab") + ", assigned id "+tabId);

if (!isTab) {
isTopBarHidden = true;
hideTopBar();
}

// Back/Forward Buttons
back = findViewById(R.id.back);
Expand Down Expand Up @@ -132,6 +137,13 @@ public void onCreate(Bundle savedInstanceState) {
bookmarkManager.removeBookmark(currentUrl);
});

// Hide top bar
View hideBar = findViewById(R.id.hideBar);
hideBar.setOnClickListener(v -> {
isTopBarHidden = true;
hideTopBar();
});

// Edit URL
View urlLayout = findViewById(R.id.urlLayout);
EditText urlEdit = findViewById(R.id.urlEdit);
Expand Down Expand Up @@ -203,6 +215,7 @@ public void stopLoading() {
public void showTopBar() {
findViewById(R.id.topBar).setVisibility(View.VISIBLE);
findViewById(R.id.topBarEdit).setVisibility(View.GONE);
isTopBarHidden = false;
}
public void hideTopBar() {
findViewById(R.id.topBar).setVisibility(View.GONE);
Expand Down Expand Up @@ -238,7 +251,9 @@ private void updateUrl(String url) {

@Override
public void onBackPressed() {
if (findViewById(R.id.topBarEdit).getVisibility() == View.VISIBLE)
if (isTopBarHidden) {
showTopBar();
} else if (findViewById(R.id.topBarEdit).getVisibility() == View.VISIBLE)
findViewById(R.id.cancel).callOnClick();
else {
if (w.canGoBack()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public void onCanGoBack(@NonNull GeckoSession session, boolean canGoBack) {
public void onCanGoForward(@NonNull GeckoSession session, boolean canGoForward) {
this.canGoForward = canGoForward;
}

@Override
public void onLocationChange(@NonNull GeckoSession session, @Nullable String url,
@NonNull List<GeckoSession.PermissionDelegate.ContentPermission> perms) {
GeckoSession.NavigationDelegate.super.onLocationChange(session, url, perms);
public void onLocationChange(@NonNull GeckoSession session, @Nullable String url, @NonNull List<GeckoSession.PermissionDelegate.ContentPermission> perms, @NonNull Boolean hasUserGesture) {
GeckoSession.NavigationDelegate.super.onLocationChange(session, url, perms, hasUserGesture);

if (url != null && !url.isEmpty() && !url.equals("about:blank")) {
currentUrl = url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

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

final AlertDialog dialog = Dialog.build(activity, R.layout.dialog_webextensions);
assert dialog != null;
dialog.hide();

dialog.findViewById(R.id.getMoreButton).setOnClickListener(view -> {
if (activity instanceof BrowserActivity) {
((BrowserActivity) activity).loadUrl(EXTENSIONS_URL);
dialog.dismiss();
}
});

View dismiss = dialog.findViewById(R.id.dismissButton);
dismiss.setOnClickListener(view -> dialog.dismiss());

Expand Down Expand Up @@ -108,15 +109,13 @@ public View getView(final int position, View view, @NonNull final ViewGroup pare
value.removeIf(webExtension -> webExtension.id.equals("[email protected]"));
}
adapter.addAll(value);

dialog.show();

ListView lv = dialog.findViewById(R.id.listView);
lv.setAdapter(adapter);
return null;
});



}
}

5 changes: 5 additions & 0 deletions App/src/main/res/drawable/web_up.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="20dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="20dp" xmlns:android="http://schemas.android.com/apk/res/android">
<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"/>
</vector>
13 changes: 13 additions & 0 deletions App/src/main/res/layout/activity_browser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@
android:visibility="gone"
tools:ignore="UnusedAttribute" />

<ImageButton
android:id="@+id/hideBar"
android:layout_width="39dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/bkg_button_web"
android:src="@drawable/web_up"
android:tooltipText="@string/web_hide_bar"
tools:ignore="UnusedAttribute" />

<ImageButton
android:id="@+id/exit"
android:layout_width="39dp"
Expand Down
7 changes: 4 additions & 3 deletions App/src/main/res/layout/dialog_webextensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bkg_dialog"
android:descendantFocusability="blocksDescendants"
android:focusable="false"
android:orientation="vertical"
android:padding="20dp">

Expand Down Expand Up @@ -35,13 +33,16 @@
</ListView>

<TextView

android:id="@+id/getMoreButton"
style="@style/SettingsText"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="10dp"
android:background="@drawable/bkg_button"
android:gravity="center"
android:text="@string/extension_prompt_hint" />
android:text="@string/extension_prompt_hint">
<requestFocus/>
</TextView>

</com.threethan.browser.browser.CursorLayout>
1 change: 1 addition & 0 deletions App/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<string name="web_forward">前进</string>
<string name="web_reload">刷新页面</string>
<string name="web_exit">退出选项卡</string>
<string name="web_hide_bar">隐藏顶部栏</string>
<string name="web_add_bookmark">将页面添加到芸签</string>
<string name="web_remove_bookmark">从标签中删除芸签</string>
<string name="web_cancel">关闭</string>
Expand Down
1 change: 1 addition & 0 deletions App/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<string name="web_forward">Navigate Forward</string>
<string name="web_reload">Refresh this Page</string>
<string name="web_exit">Minimize Tab</string>
<string name="web_hide_bar">Hide Top Bar</string>
<string name="web_add_bookmark">Add Page to Bookmarks</string>
<string name="web_remove_bookmark">Remove Bookmark</string>
<string name="web_cancel">Cancel</string>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A powerful Gecko-based browser for Android TV and VR.
*(Previously part of [LightningLauncher](https://github.com/threethan/LightningLauncher))*

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

0 comments on commit ffc28a2

Please sign in to comment.