soul-browser/sources/java/com/mycompany/app/web/TabHomepage.java
KaKi87 ef6d47fc9d
Some checks are pending
Build APK / build (push) Waiting to run
Add per-tab Homepage to tab long-press menu (#21)
* Add per-tab Homepage action to tab long-press menu

Inspired by Zen Browser pinned tabs: first click (or later long-press)
on Homepage confirms setting the current URL; later clicks navigate to
it. Persists via DbBookTab _rsv1 and is toggleable in the cog submenu.

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix tab Homepage menu action and rename label

Correct inverted null/empty checks in TabHomepage that caused click and
long-press to no-op, fix long-press listener wiring in MyPopupMenu, and
use a dedicated tab_homepage string ("Homepage") for the menu item.

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix Homepage menu confirm dialog never showing

The URL empty check before DialogConfirm was inverted, so click and
long-press both returned early whenever a valid page URL was available.

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Polish tab homepage confirm dialog and success toast

- Remove Tip header from confirm dialog
- Show only "Set as homepage?" as the prompt
- Toast reads "Homepage set" instead of "Has been set."
- Dismiss dialog when homepage is saved

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix IllegalAccessError hiding homepage dialog tip header

Add DialogConfirm constructor that sets d0=false during construction
instead of writing the final field from TabHomepage after the fact.

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Show URL in homepage dialog and add Cancel button

Restore URL under the confirm prompt and enable DialogConfirm's
secondary action button with the standard Cancel label.

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix tab homepage persistence across app relaunch

Correct inverted guards in DbBookTab.B() that skipped DB writes for
valid tabs, and fix _rsv1 load in DbBookTab.d() that never restored
the homepage URL from the database.

Co-authored-by: KaKi87 <KaKi87@pm.me>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-08-12 15:13:43 +02:00

77 lines
2.5 KiB
Java

package com.mycompany.app.web;
import android.text.TextUtils;
import com.mycompany.app.db.book.DbBookTab;
import com.mycompany.app.dialog.DialogConfirm;
import com.mycompany.app.main.MainUtil;
import com.mycompany.app.soulbrowser.R;
import com.mycompany.app.web.WebTabAdapter.WebTabItem;
/** Per-tab homepage (Zen-style) helpers kept in a secondary DEX. */
public final class TabHomepage {
private TabHomepage() {
}
public static void a(WebViewActivity webViewActivity, int i, boolean z) {
WebTabItem E;
if (webViewActivity == null || webViewActivity.b3 == null || (E = webViewActivity.b3.E(i)) == null) {
return;
}
String str = E.r;
if (!z && !TextUtils.isEmpty(str)) {
webViewActivity.U4();
if (i != webViewActivity.P2) {
webViewActivity.c7(i, true);
}
webViewActivity.S5(str, null);
return;
}
final String s3;
if (i == webViewActivity.P2) {
s3 = webViewActivity.s3(true);
} else {
s3 = E.j;
if (TextUtils.isEmpty(s3)) {
MainUtil.e8(webViewActivity, R.string.empty);
return;
}
}
if (TextUtils.isEmpty(s3)) {
return;
}
webViewActivity.U4();
final TabHomepage$1 listener = new TabHomepage$1(webViewActivity, E, s3);
String message = webViewActivity.getString(R.string.set_homepage_confirm) + "\n\n" + s3;
DialogConfirm dialogConfirm = new DialogConfirm(webViewActivity, message, listener);
listener.d = dialogConfirm;
}
/* synthetic */ static final class TabHomepage$1 implements DialogConfirm.DialogConfListener {
final WebViewActivity a;
final WebTabItem b;
final String c;
DialogConfirm d;
TabHomepage$1(WebViewActivity webViewActivity, WebTabItem webTabItem, String str) {
this.a = webViewActivity;
this.b = webTabItem;
this.c = str;
}
@Override
public void a(boolean z) {
DialogConfirm dialogConfirm = this.d;
if (dialogConfirm != null) {
dialogConfirm.dismiss();
}
WebTabItem webTabItem = this.b;
String str = this.c;
if (webTabItem == null || str == null) {
return;
}
webTabItem.r = str;
DbBookTab.B(this.a.i1, webTabItem.f19520c, str);
MainUtil.e8(this.a, R.string.tab_homepage_set);
}
}
}