From 6f288acbc9b4ef515c0e30f5a4b552d233c13bb9 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 27 Nov 2022 11:48:14 +0100 Subject: [PATCH] Remove fake user agent --- .../android/activities/WebviewConnectActivity.java | 4 ++-- app/src/main/java/app/fedilab/android/helper/Helper.java | 8 ++++---- .../java/app/fedilab/android/helper/SpannableHelper.java | 5 ++--- .../fedilab/android/ui/fragment/media/FragmentMedia.java | 4 ++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java b/app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java index 23c0e456b..89f0972f0 100644 --- a/app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java @@ -136,8 +136,8 @@ public class WebviewConnectActivity extends BaseActivity { clearCookies(WebviewConnectActivity.this); binding.webviewConnect.getSettings().setJavaScriptEnabled(true); - String user_agent = sharedpreferences.getString(getString(R.string.SET_CUSTOM_USER_AGENT), Helper.USER_AGENT); - binding.webviewConnect.getSettings().setUserAgentString(user_agent); + // String user_agent = sharedpreferences.getString(getString(R.string.SET_CUSTOM_USER_AGENT), Helper.USER_AGENT); + // binding.webviewConnect.getSettings().setUserAgentString(user_agent); binding.webviewConnect.getSettings().setDomStorageEnabled(true); CookieManager.getInstance().setAcceptThirdPartyCookies(binding.webviewConnect, true); diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index 5eebc79d6..fd2ba59aa 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -287,7 +287,7 @@ public class Helper { public static final String VALUE_TRENDS = "VALUE_TRENDS"; - public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0"; + //public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0"; public static final String REDIRECT_CONTENT_WEB = "fedilab://backtofedilab"; public static final String REDIRECT_CONTENT = "urn:ietf:wg:oauth:2.0:oob"; public static final String APP_OAUTH_SCOPES = "read write"; @@ -439,8 +439,8 @@ public class Helper { webView.getSettings().setLoadsImagesAutomatically(true); webView.getSettings().setSupportMultipleWindows(false); webView.getSettings().setMediaPlaybackRequiresUserGesture(true); - String user_agent = sharedpreferences.getString(activity.getString(R.string.SET_CUSTOM_USER_AGENT), USER_AGENT); - webView.getSettings().setUserAgentString(user_agent); + //String user_agent = sharedpreferences.getString(activity.getString(R.string.SET_CUSTOM_USER_AGENT), USER_AGENT); + // webView.getSettings().setUserAgentString(user_agent); boolean cookies = sharedpreferences.getBoolean(activity.getString(R.string.SET_COOKIES), false); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptThirdPartyCookies(webView, cookies); @@ -1761,7 +1761,7 @@ public class Helper { httpURLConnection = (HttpURLConnection) url.openConnection(proxy); else httpURLConnection = (HttpURLConnection) url.openConnection(); - httpURLConnection.setRequestProperty("User-Agent", USER_AGENT); + // httpURLConnection.setRequestProperty("User-Agent", USER_AGENT); int responseCode = httpURLConnection.getResponseCode(); // always check HTTP response code first diff --git a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java index c14b3c662..68dd76536 100644 --- a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java @@ -16,7 +16,6 @@ package app.fedilab.android.helper; import static app.fedilab.android.BaseMainActivity.currentAccount; -import static app.fedilab.android.helper.Helper.USER_AGENT; import static app.fedilab.android.helper.ThemeHelper.linkColor; import android.content.ClipData; @@ -321,7 +320,7 @@ public class SpannableHelper { HttpsURLConnection httpsURLConnection = (HttpsURLConnection) finalUrlCheck.openConnection(); httpsURLConnection.setConnectTimeout(10 * 1000); httpsURLConnection.setRequestProperty("http.keepAlive", "false"); - httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); + // httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); httpsURLConnection.setRequestMethod("HEAD"); httpsURLConnection.setInstanceFollowRedirects(false); if (httpsURLConnection.getResponseCode() == 301 || httpsURLConnection.getResponseCode() == 302) { @@ -550,7 +549,7 @@ public class SpannableHelper { HttpsURLConnection httpsURLConnection = (HttpsURLConnection) finalUrlCheck.openConnection(); httpsURLConnection.setConnectTimeout(10 * 1000); httpsURLConnection.setRequestProperty("http.keepAlive", "false"); - httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); + //httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); httpsURLConnection.setRequestMethod("HEAD"); httpsURLConnection.setInstanceFollowRedirects(false); if (httpsURLConnection.getResponseCode() == 301 || httpsURLConnection.getResponseCode() == 302) { diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/media/FragmentMedia.java b/app/src/main/java/app/fedilab/android/ui/fragment/media/FragmentMedia.java index 277d75cfd..fdf980f1a 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/media/FragmentMedia.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/media/FragmentMedia.java @@ -245,8 +245,8 @@ public class FragmentMedia extends Fragment { webview_video.setWebChromeClient(fedilabWebChromeClient); webview_video.getSettings().setDomStorageEnabled(true); webview_video.getSettings().setAppCacheEnabled(true); - String user_agent = sharedpreferences.getString(getString(R.string.SET_CUSTOM_USER_AGENT), Helper.USER_AGENT); - webview_video.getSettings().setUserAgentString(user_agent); + // String user_agent = sharedpreferences.getString(getString(R.string.SET_CUSTOM_USER_AGENT), Helper.USER_AGENT); + // webview_video.getSettings().setUserAgentString(user_agent); webview_video.getSettings().setMediaPlaybackRequiresUserGesture(false); webview_video.setWebViewClient(new FedilabWebViewClient(requireActivity())); webview_video.loadUrl(attachment.url);