Skip to content

Commit

Permalink
release build: v04.02.01
Browse files Browse the repository at this point in the history
fix:   GM_setUserAgent
issue: the Preference was saved, but not immediately applied.
  • Loading branch information
warren-bank committed Dec 7, 2023
1 parent e02915d commit 873c5f4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,12 @@ public void setUserAgent(String scriptName, String scriptNamespace, String secre
if (!grant(scriptName, scriptNamespace, "GM_setUserAgent")) {
return;
}
SettingsUtils.setUserAgent(/* Context */ WmJsApi.this.activity, value);
SettingsUtils.setUserAgent(/* Context */ WmJsApi.this.activity, value, /* updateWebViewSettings */ false);
activity.runOnUiThread(new Runnable() {
public void run() {
WebViewSettingsMgr.updateUserAgent();
}
});
}

@JavascriptInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ private static String getCustomHomePage(Context context, SharedPreferences prefs
// --------------------

public static void setUserAgent(Context context, String value) {
setUserAgent(context, value, true);
}

public static void setUserAgent(Context context, String value, boolean updateWebViewSettings) {
SharedPreferences.Editor editor = getPrefsEditor(context);
String pref_key = null;
String pref_value = null;
Expand All @@ -116,38 +120,33 @@ public static void setUserAgent(Context context, String value) {
pref_value = context.getString(R.string.pref_useragent_array_values_1);

editor.putString(pref_key, pref_value);

editor.commit();
return;
}

// Chrome desktop
if (value.toLowerCase().equals("chrome")) {
else if (value.toLowerCase().equals("chrome")) {
pref_key = context.getString(R.string.pref_useragent_key);
pref_value = context.getString(R.string.pref_useragent_array_values_2);

editor.putString(pref_key, pref_value);

editor.commit();
return;
}

// Custom URL
{
else {
pref_key = context.getString(R.string.pref_useragent_key);
pref_value = context.getString(R.string.pref_useragent_array_values_3);

editor.putString(pref_key, pref_value);
}
{

pref_key = context.getString(R.string.pref_custom_useragent_key);
pref_value = value;

editor.putString(pref_key, pref_value);

editor.commit();
return;
}

editor.commit();

if (updateWebViewSettings)
WebViewSettingsMgr.updateUserAgent();
}

public static String getUserAgent(Context context) {
Expand Down
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("004020011", 10) //Integer.MAX_VALUE == 2147483647
releaseVersion = '004.02.00-11API'
releaseVersionCode = Integer.parseInt("004020111", 10) //Integer.MAX_VALUE == 2147483647
releaseVersion = '004.02.01-11API'
javaVersion = JavaVersion.VERSION_1_8
minSdkVersion = 11
targetSdkVersion = 33
Expand Down

0 comments on commit 873c5f4

Please sign in to comment.