soul-browser/scripts/compile-history-current-tab.sh
KaKi87 6a5016ab8b
Add History "Current tab" filter switch (#144)
* Add History overflow "Current tab" filter switch.

Filters the History list to URLs from the current tab's page stack and back/forward lists, matching the existing detail/single-line toggles.

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

* Fix Current tab filter not refreshing History.

Wire WebViewActivity from MainListView into ListBookHistory so URL collection no longer depends on the dialog theme Context, which never resolved the browser activity.

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

* Filter History current-tab on the in-memory cache path too.

Reloads were serving DataBookHistory's cached full list and skipping the DB cursor filter, so the switch had no effect. Also snapshot the tab's URLs on the UI thread when toggling.

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

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-16 05:06:51 +02:00

116 lines
3.8 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SRC="${ROOT_DIR}/sources/java/com/mycompany/app/list/book/HistoryCurrentTabHelper.java"
OUT_SMALI="${ROOT_DIR}/app/smali_classes3/com/mycompany/app/list/book"
TOOLS="${ROOT_DIR}/tools"
ANDROID_HOME="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-${HOME}/android-sdk}}"
ANDROID_JAR="$(ls -1 "${ANDROID_HOME}/platforms"/android-*/android.jar 2>/dev/null | sort -V | tail -1)"
D8="$(find "${ANDROID_HOME}/build-tools" -name d8 -type f 2>/dev/null | sort -V | tail -1)"
DEX_TOOLS_ZIP="${TOOLS}/dex-tools-v2.4.zip"
DEX_TOOLS_DIR="${TOOLS}/dex-tools-v2.4"
BAKSMALI_JAR="${TOOLS}/baksmali.jar"
mkdir -p "${TOOLS}" "${OUT_SMALI}"
if [[ ! -f "${ANDROID_JAR}" ]]; then
echo "error: android.jar not found" >&2
exit 1
fi
if [[ -z "${D8}" ]]; then
echo "error: d8 not found" >&2
exit 1
fi
if [[ ! -f "${DEX_TOOLS_DIR}/d2j-dex2jar.sh" ]]; then
if [[ ! -f "${DEX_TOOLS_ZIP}" ]]; then
echo "Downloading dex-tools v2.4..."
curl -fsSL -o "${DEX_TOOLS_ZIP}" \
"https://github.com/pxb1988/dex2jar/releases/download/v2.4/dex-tools-v2.4.zip"
fi
unzip -qo "${DEX_TOOLS_ZIP}" -d "${TOOLS}"
fi
chmod +x "${DEX_TOOLS_DIR}/"*.sh "${DEX_TOOLS_DIR}/d2j_invoke.sh" 2>/dev/null || true
if [[ ! -f "${BAKSMALI_JAR}" ]]; then
curl -fsSL -o "${BAKSMALI_JAR}" \
"https://repo1.maven.org/maven2/org/smali/baksmali/2.5.2/baksmali-2.5.2.jar"
fi
STAGE="$(mktemp -d)"
cleanup() { rm -rf "${STAGE}"; }
trap cleanup EXIT
STUBS="${STAGE}/stubs"
mkdir -p \
"${STUBS}/com/mycompany/app/main" \
"${STUBS}/com/mycompany/app/web"
cat > "${STUBS}/com/mycompany/app/main/MainUtil.java" <<'EOF'
package com.mycompany.app.main;
import android.content.Context;
public final class MainUtil {
public static String Z2(Context context, String url) { return url; }
}
EOF
cat > "${STUBS}/com/mycompany/app/web/WebNestView.java" <<'EOF'
package com.mycompany.app.web;
import android.webkit.WebView;
public class WebNestView extends WebView {
public WebNestView(android.content.Context c) { super(c); }
public String getPageUrl() { return null; }
public String getTitle() { return null; }
public String q(String url) { return url; }
}
EOF
cat > "${STUBS}/com/mycompany/app/web/WebNestFrame.java" <<'EOF'
package com.mycompany.app.web;
import java.util.List;
public class WebNestFrame {
public List<PageItem> o;
public static class PageItem {
public String d;
public String e;
public WebNestView i;
}
}
EOF
cat > "${STUBS}/com/mycompany/app/web/WebTabAdapter.java" <<'EOF'
package com.mycompany.app.web;
public class WebTabAdapter {
public static class WebTabItem {
public String j;
public String k;
public WebNestFrame p;
}
}
EOF
cat > "${STUBS}/com/mycompany/app/web/WebViewActivity.java" <<'EOF'
package com.mycompany.app.web;
import android.app.Activity;
public class WebViewActivity extends Activity {
public int P2;
public WebNestFrame H2;
public WebNestView I2;
public WebTabAdapter.WebTabItem n3(int i) { return null; }
}
EOF
echo "Compiling HistoryCurrentTabHelper..."
javac --release 11 -classpath "${ANDROID_JAR}:${STUBS}" -d "${STAGE}/classes" "${SRC}"
mkdir -p "${STAGE}/dex"
mapfile -t CLASS_FILES < <(find "${STAGE}/classes" -name '*.class' -type f)
"${D8}" --min-api 23 --lib "${ANDROID_JAR}" --output "${STAGE}/dex" "${CLASS_FILES[@]}"
if [[ -x "${DEX_TOOLS_DIR}/d2j-baksmali.sh" ]]; then
bash "${DEX_TOOLS_DIR}/d2j-baksmali.sh" -f -o "${STAGE}/out" "${STAGE}/dex/classes.dex"
else
java -cp "${BAKSMALI_JAR}" org.jf.baksmali.Main d "${STAGE}/dex/classes.dex" -o "${STAGE}/out"
fi
rm -f "${OUT_SMALI}"/HistoryCurrentTabHelper*.smali
cp -a "${STAGE}/out/com/mycompany/app/list/book/HistoryCurrentTabHelper"* "${OUT_SMALI}/"
echo "Wrote ${OUT_SMALI}/HistoryCurrentTabHelper*.smali"