Skip to content

Commit

Permalink
release build: v04.00.03
Browse files Browse the repository at this point in the history
fix: loading URLs that contain a #hash

notes:
* v02.00.02
  - #hash worked
  - didn't include any code to override URL loading
* v03.00.00
  - #hash did not work
  - broken by commit: 8a8eeb3
  - purpose: detect URL navigation originating from JS by History API
  - issue: #hash was (intentionally) removed
  • Loading branch information
warren-bank committed Dec 2, 2023
1 parent bc65dce commit c6cd10f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions android-studio-project/constants.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project.ext {
releaseVersionCode = Integer.parseInt("004000208", 10) //Integer.MAX_VALUE == 2147483647
releaseVersion = '004.00.02-08API'
releaseVersionCode = Integer.parseInt("004000308", 10) //Integer.MAX_VALUE == 2147483647
releaseVersion = '004.00.03-08API'
javaVersion = JavaVersion.VERSION_1_8
minSdkVersion = 8
targetSdkVersion = 33
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class ScriptBrowser {
private String startUrl;
private String currentLoadingUrl;
private String pendingLoadingUrl;
private String pendingLoadingUrlWithHash;
private String currentUrl;

private Handler handler;
Expand Down Expand Up @@ -112,14 +113,16 @@ public void run() {
private void init() {
currentLoadingUrl = null;
pendingLoadingUrl = null;
pendingLoadingUrlWithHash = null;
currentUrl = null;
handler = new Handler();
loadUrlRunnable = new Runnable() {
public void run() {
if ((pendingLoadingUrl != null) && !pendingLoadingUrl.equals(currentLoadingUrl)&& !pendingLoadingUrl.equals(currentUrl)) {
loadUrlOnUiThread(webView, pendingLoadingUrl);
loadUrlOnUiThread(webView, pendingLoadingUrlWithHash);
}
pendingLoadingUrl = null;
pendingLoadingUrlWithHash = null;
}
};
browser = activity.getLayoutInflater().inflate(R.layout.script_browser, null);
Expand Down Expand Up @@ -157,10 +160,12 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
public void changeAddressField(String url) {
if (TextUtils.isEmpty(url)) return;

String urlWithHash = url;

url = UrlUtils.removeHash(url);
if (url.equals(currentUrl)) return;

addressField.setText(url);
addressField.setText(urlWithHash);
}

/**
Expand All @@ -176,6 +181,8 @@ public void loadUrl(String url) {
protected void loadUrl(String url, boolean reloadCurrentUrl) {
if (TextUtils.isEmpty(url)) return;

String urlWithHash = url;

url = UrlUtils.removeHash(url);

if (url.equals(currentUrl) && reloadCurrentUrl) {
Expand All @@ -185,10 +192,11 @@ protected void loadUrl(String url, boolean reloadCurrentUrl) {
if (url.equals(currentUrl) || url.equals(currentLoadingUrl) || url.equals(pendingLoadingUrl)) return;

if ((currentUrl == null) && (currentLoadingUrl == null)) {
changeAddressField(url);
changeAddressField(urlWithHash);
}

pendingLoadingUrl = url;
pendingLoadingUrlWithHash = urlWithHash;
setLoadUrlTimer();
}

Expand Down Expand Up @@ -220,6 +228,7 @@ protected void setCurrentLoadingUrl(String url) {

if (UrlUtils.areEqual(currentLoadingUrl, pendingLoadingUrl)) {
pendingLoadingUrl = null;
pendingLoadingUrlWithHash = null;
}
}

Expand Down Expand Up @@ -435,7 +444,6 @@ private void handlePageNavigation(WebView view, String url, boolean setCurrentUr
url = view.getUrl();
}

url = UrlUtils.removeHash(url);
if (TextUtils.isEmpty(url)) return;

scriptBrowser.loadUrl(url);
Expand Down

0 comments on commit c6cd10f

Please sign in to comment.