soul-browser/sources/java/com/mycompany/app/setting/SettingInfoUrlSpan.java
KaKi87 b5af18831f
Rebrand as Soul2 Browser (#34)
* Update README.md

* Rebrand as Soul2 Browser with branch-specific package IDs.

Use net.kaki87.soul2 on main and .testing elsewhere, slim Settings → Information to source/bug links plus README-extracted about text, and drop rate/share/feedback entries.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Use Soul2⁺ Browser as the display name for non-main builds.

Keep Soul2 Browser on main so stable and testing installs are easy to tell apart in the launcher.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Run the APK CI workflow on pushes to every branch.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Open Information links in the in-app web dialog.

MainUtil.I4 is for external-browser handoff and no-ops when Soul itself handles https, so App version / Source code / Bug tracker appeared dead.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Open Information paragraph hyperlinks in the in-app web dialog.

Replace Html URLSpans so README INFO links use SettingInfo.P0 like App version / Source code / Bug tracker.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Add a back chevron to the in-app Information web dialog.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 06:01:36 +02:00

52 lines
1.8 KiB
Java

package com.mycompany.app.setting;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.URLSpan;
import android.view.View;
import com.mycompany.app.soulbrowser.R;
/** URLSpan that opens https links via SettingInfo.P0 (in-app web dialog). */
public final class SettingInfoUrlSpan extends URLSpan {
public SettingInfoUrlSpan(String url) {
super(url);
}
public static CharSequence a(CharSequence text) {
if (text == null || !(text instanceof Spanned)) {
return text;
}
SpannableStringBuilder ssb = new SpannableStringBuilder(text);
URLSpan[] spans = ssb.getSpans(0, ssb.length(), URLSpan.class);
if (spans != null) {
for (URLSpan span : spans) {
if (span instanceof SettingInfoUrlSpan || span == null) {
continue;
}
int start = ssb.getSpanStart(span);
int end = ssb.getSpanEnd(span);
int flags = ssb.getSpanFlags(span);
String url = span.getURL();
ssb.removeSpan(span);
ssb.setSpan(new SettingInfoUrlSpan(url), start, end, flags);
}
}
return ssb;
}
@Override
public void onClick(View widget) {
Context context = widget.getContext();
while (context instanceof ContextWrapper && !(context instanceof Activity)) {
context = ((ContextWrapper) context).getBaseContext();
}
if (context instanceof SettingInfo) {
((SettingInfo) context).P0(getURL(), R.string.info, true);
return;
}
super.onClick(widget);
}
}