Allow to customize the user agent
This commit is contained in:
parent
dacfa6ea11
commit
6c9ebb3035
|
@ -293,6 +293,10 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null);
|
||||||
|
if( user_agent != null) {
|
||||||
|
webview_video.getSettings().setUserAgentString(user_agent);
|
||||||
|
}
|
||||||
webview_video.getSettings().setAllowFileAccess(true);
|
webview_video.getSettings().setAllowFileAccess(true);
|
||||||
webview_video.setWebChromeClient(mastalabWebChromeClient);
|
webview_video.setWebChromeClient(mastalabWebChromeClient);
|
||||||
webview_video.getSettings().setDomStorageEnabled(true);
|
webview_video.getSettings().setDomStorageEnabled(true);
|
||||||
|
|
|
@ -133,6 +133,10 @@ public class WebviewConnectActivity extends BaseActivity {
|
||||||
webView = findViewById(R.id.webviewConnect);
|
webView = findViewById(R.id.webviewConnect);
|
||||||
clearCookies(getApplicationContext());
|
clearCookies(getApplicationContext());
|
||||||
webView.getSettings().setJavaScriptEnabled(true);
|
webView.getSettings().setJavaScriptEnabled(true);
|
||||||
|
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null);
|
||||||
|
if( user_agent != null) {
|
||||||
|
webView.getSettings().setUserAgentString(user_agent);
|
||||||
|
}
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
||||||
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
|
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -94,6 +94,7 @@ public class HttpsConnection {
|
||||||
private SharedPreferences sharedpreferences;
|
private SharedPreferences sharedpreferences;
|
||||||
private Proxy proxy;
|
private Proxy proxy;
|
||||||
private String instance;
|
private String instance;
|
||||||
|
private String USER_AGENT;
|
||||||
|
|
||||||
public HttpsConnection(Context context, String instance) {
|
public HttpsConnection(Context context, String instance) {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
|
@ -102,6 +103,8 @@ public class HttpsConnection {
|
||||||
boolean proxyEnabled = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false);
|
boolean proxyEnabled = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false);
|
||||||
int type = sharedpreferences.getInt(Helper.SET_PROXY_TYPE, 0);
|
int type = sharedpreferences.getInt(Helper.SET_PROXY_TYPE, 0);
|
||||||
proxy = null;
|
proxy = null;
|
||||||
|
|
||||||
|
USER_AGENT = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT);
|
||||||
if (proxyEnabled) {
|
if (proxyEnabled) {
|
||||||
try {
|
try {
|
||||||
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
|
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
|
||||||
|
@ -211,7 +214,7 @@ public class HttpsConnection {
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
||||||
httpsURLConnection.setConnectTimeout(timeout * 1000);
|
httpsURLConnection.setConnectTimeout(timeout * 1000);
|
||||||
httpsURLConnection.setRequestProperty("http.keepAlive", "false");
|
httpsURLConnection.setRequestProperty("http.keepAlive", "false");
|
||||||
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
|
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
|
||||||
httpsURLConnection.setRequestProperty("Accept", "application/json");
|
httpsURLConnection.setRequestProperty("Accept", "application/json");
|
||||||
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
||||||
|
@ -389,7 +392,7 @@ public class HttpsConnection {
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
||||||
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
httpsURLConnection.setConnectTimeout(timeout * 1000);
|
httpsURLConnection.setConnectTimeout(timeout * 1000);
|
||||||
httpsURLConnection.setDoOutput(true);
|
httpsURLConnection.setDoOutput(true);
|
||||||
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
||||||
|
@ -456,7 +459,7 @@ public class HttpsConnection {
|
||||||
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
|
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpURLConnection = (HttpURLConnection) url.openConnection();
|
httpURLConnection = (HttpURLConnection) url.openConnection();
|
||||||
httpURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
httpURLConnection.setConnectTimeout(timeout * 1000);
|
httpURLConnection.setConnectTimeout(timeout * 1000);
|
||||||
httpURLConnection.setDoOutput(true);
|
httpURLConnection.setDoOutput(true);
|
||||||
httpURLConnection.setRequestMethod("POST");
|
httpURLConnection.setRequestMethod("POST");
|
||||||
|
@ -511,7 +514,7 @@ public class HttpsConnection {
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
||||||
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
httpsURLConnection.setConnectTimeout(timeout * 1000);
|
httpsURLConnection.setConnectTimeout(timeout * 1000);
|
||||||
httpsURLConnection.setDoOutput(true);
|
httpsURLConnection.setDoOutput(true);
|
||||||
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
||||||
|
@ -564,7 +567,7 @@ public class HttpsConnection {
|
||||||
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
|
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpURLConnection = (HttpURLConnection) url.openConnection();
|
httpURLConnection = (HttpURLConnection) url.openConnection();
|
||||||
httpURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
httpURLConnection.setConnectTimeout(timeout * 1000);
|
httpURLConnection.setConnectTimeout(timeout * 1000);
|
||||||
httpURLConnection.setDoOutput(true);
|
httpURLConnection.setDoOutput(true);
|
||||||
httpURLConnection.setRequestMethod("POST");
|
httpURLConnection.setRequestMethod("POST");
|
||||||
|
@ -617,7 +620,7 @@ public class HttpsConnection {
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
||||||
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
httpsURLConnection.setConnectTimeout(timeout * 1000);
|
httpsURLConnection.setConnectTimeout(timeout * 1000);
|
||||||
httpsURLConnection.setDoOutput(true);
|
httpsURLConnection.setDoOutput(true);
|
||||||
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
||||||
|
@ -682,7 +685,7 @@ public class HttpsConnection {
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
||||||
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
int responseCode = httpsURLConnection.getResponseCode();
|
int responseCode = httpsURLConnection.getResponseCode();
|
||||||
|
|
||||||
// always check HTTP response code first
|
// always check HTTP response code first
|
||||||
|
@ -770,7 +773,7 @@ public class HttpsConnection {
|
||||||
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
|
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpURLConnection = (HttpURLConnection) url.openConnection();
|
httpURLConnection = (HttpURLConnection) url.openConnection();
|
||||||
httpURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
int responseCode = httpURLConnection.getResponseCode();
|
int responseCode = httpURLConnection.getResponseCode();
|
||||||
|
|
||||||
// always check HTTP response code first
|
// always check HTTP response code first
|
||||||
|
@ -866,7 +869,7 @@ public class HttpsConnection {
|
||||||
else
|
else
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
||||||
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
||||||
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
int responseCode = httpsURLConnection.getResponseCode();
|
int responseCode = httpsURLConnection.getResponseCode();
|
||||||
// always check HTTP response code first
|
// always check HTTP response code first
|
||||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||||
|
@ -889,7 +892,7 @@ public class HttpsConnection {
|
||||||
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
|
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpURLConnection = (HttpURLConnection) url.openConnection();
|
httpURLConnection = (HttpURLConnection) url.openConnection();
|
||||||
httpURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
int responseCode = httpURLConnection.getResponseCode();
|
int responseCode = httpURLConnection.getResponseCode();
|
||||||
// always check HTTP response code first
|
// always check HTTP response code first
|
||||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||||
|
@ -996,7 +999,7 @@ public class HttpsConnection {
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
||||||
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
httpsURLConnection.setConnectTimeout(timeout * 1000);
|
httpsURLConnection.setConnectTimeout(timeout * 1000);
|
||||||
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
|
||||||
|
@ -1077,7 +1080,7 @@ public class HttpsConnection {
|
||||||
httpURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
httpURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpURLConnection = (HttpsURLConnection) url.openConnection();
|
httpURLConnection = (HttpsURLConnection) url.openConnection();
|
||||||
httpURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
httpURLConnection.setConnectTimeout(timeout * 1000);
|
httpURLConnection.setConnectTimeout(timeout * 1000);
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
|
||||||
httpURLConnection.setRequestMethod("PATCH");
|
httpURLConnection.setRequestMethod("PATCH");
|
||||||
|
@ -1160,7 +1163,7 @@ public class HttpsConnection {
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
||||||
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
httpsURLConnection.setConnectTimeout(timeout * 1000);
|
httpsURLConnection.setConnectTimeout(timeout * 1000);
|
||||||
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
||||||
if (token != null && !token.startsWith("Basic "))
|
if (token != null && !token.startsWith("Basic "))
|
||||||
|
@ -1228,7 +1231,7 @@ public class HttpsConnection {
|
||||||
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
|
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpURLConnection = (HttpURLConnection) url.openConnection();
|
httpURLConnection = (HttpURLConnection) url.openConnection();
|
||||||
httpURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
httpURLConnection.setConnectTimeout(timeout * 1000);
|
httpURLConnection.setConnectTimeout(timeout * 1000);
|
||||||
if (token != null && !token.startsWith("Basic "))
|
if (token != null && !token.startsWith("Basic "))
|
||||||
httpURLConnection.setRequestProperty("Authorization", "Bearer " + token);
|
httpURLConnection.setRequestProperty("Authorization", "Bearer " + token);
|
||||||
|
@ -1300,7 +1303,7 @@ public class HttpsConnection {
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
||||||
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
||||||
if (token != null && !token.startsWith("Basic "))
|
if (token != null && !token.startsWith("Basic "))
|
||||||
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
|
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
|
||||||
|
@ -1363,7 +1366,7 @@ public class HttpsConnection {
|
||||||
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
|
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
|
||||||
else
|
else
|
||||||
httpURLConnection = (HttpURLConnection) url.openConnection();
|
httpURLConnection = (HttpURLConnection) url.openConnection();
|
||||||
httpURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
|
httpURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
if (token != null && !token.startsWith("Basic "))
|
if (token != null && !token.startsWith("Basic "))
|
||||||
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
|
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
|
||||||
else if (token != null && token.startsWith("Basic "))
|
else if (token != null && token.startsWith("Basic "))
|
||||||
|
|
|
@ -2316,6 +2316,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
.into(holder.webview_preview_card);
|
.into(holder.webview_preview_card);
|
||||||
holder.status_cardview.setVisibility(View.GONE);
|
holder.status_cardview.setVisibility(View.GONE);
|
||||||
holder.status_cardview_video.setVisibility(View.VISIBLE);
|
holder.status_cardview_video.setVisibility(View.VISIBLE);
|
||||||
|
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null);
|
||||||
|
if( user_agent != null) {
|
||||||
|
holder.status_cardview_webview.getSettings().setUserAgentString(user_agent);
|
||||||
|
}
|
||||||
holder.status_cardview_webview.getSettings().setJavaScriptEnabled(true);
|
holder.status_cardview_webview.getSettings().setJavaScriptEnabled(true);
|
||||||
String html = card.getHtml();
|
String html = card.getHtml();
|
||||||
String src = card.getUrl();
|
String src = card.getUrl();
|
||||||
|
|
|
@ -919,6 +919,32 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TextView set_user_agent = rootView.findViewById(R.id.set_user_agent);
|
||||||
|
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null);
|
||||||
|
|
||||||
|
if (user_agent != null) {
|
||||||
|
set_user_agent.setText(user_agent);
|
||||||
|
}
|
||||||
|
set_user_agent.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
|
if (s.toString().trim().length() > 0) {
|
||||||
|
editor.putString(Helper.SET_CUSTOM_USER_AGENT, s.toString().toLowerCase().trim());
|
||||||
|
} else {
|
||||||
|
editor.putString(Helper.SET_CUSTOM_USER_AGENT, null);
|
||||||
|
}
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
TextView set_nitter_host = rootView.findViewById(R.id.set_nitter_host);
|
TextView set_nitter_host = rootView.findViewById(R.id.set_nitter_host);
|
||||||
boolean nitter = sharedpreferences.getBoolean(Helper.SET_NITTER, false);
|
boolean nitter = sharedpreferences.getBoolean(Helper.SET_NITTER, false);
|
||||||
final SwitchCompat set_nitter = rootView.findViewById(R.id.set_nitter);
|
final SwitchCompat set_nitter = rootView.findViewById(R.id.set_nitter);
|
||||||
|
|
|
@ -294,6 +294,10 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
||||||
webview_video.setWebChromeClient(mastalabWebChromeClient);
|
webview_video.setWebChromeClient(mastalabWebChromeClient);
|
||||||
webview_video.getSettings().setDomStorageEnabled(true);
|
webview_video.getSettings().setDomStorageEnabled(true);
|
||||||
webview_video.getSettings().setAppCacheEnabled(true);
|
webview_video.getSettings().setAppCacheEnabled(true);
|
||||||
|
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null);
|
||||||
|
if( user_agent != null) {
|
||||||
|
webview_video.getSettings().setUserAgentString(user_agent);
|
||||||
|
}
|
||||||
webview_video.getSettings().setMediaPlaybackRequiresUserGesture(false);
|
webview_video.getSettings().setMediaPlaybackRequiresUserGesture(false);
|
||||||
webview_video.setWebViewClient(new MastalabWebViewClient((Activity) context));
|
webview_video.setWebViewClient(new MastalabWebViewClient((Activity) context));
|
||||||
webview_video.loadUrl(attachment.getUrl());
|
webview_video.loadUrl(attachment.getUrl());
|
||||||
|
|
|
@ -476,6 +476,7 @@ public class Helper {
|
||||||
public static final String SET_ART_WITH_NSFW = "set_art_with_nsfw";
|
public static final String SET_ART_WITH_NSFW = "set_art_with_nsfw";
|
||||||
public static final String SET_SECURITY_PROVIDER = "set_security_provider";
|
public static final String SET_SECURITY_PROVIDER = "set_security_provider";
|
||||||
public static final String SET_ALLOW_STREAM = "set_allow_stream";
|
public static final String SET_ALLOW_STREAM = "set_allow_stream";
|
||||||
|
public static final String SET_CUSTOM_USER_AGENT = "set_custom_user_agent";
|
||||||
//End points
|
//End points
|
||||||
public static final String EP_AUTHORIZE = "/oauth/authorize";
|
public static final String EP_AUTHORIZE = "/oauth/authorize";
|
||||||
|
|
||||||
|
@ -2460,15 +2461,10 @@ public class Helper {
|
||||||
webView.getSettings().setAllowContentAccess(true);
|
webView.getSettings().setAllowContentAccess(true);
|
||||||
webView.getSettings().setLoadsImagesAutomatically(true);
|
webView.getSettings().setLoadsImagesAutomatically(true);
|
||||||
webView.getSettings().setSupportMultipleWindows(false);
|
webView.getSettings().setSupportMultipleWindows(false);
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
|
||||||
//noinspection deprecation
|
|
||||||
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
|
|
||||||
}
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
||||||
webView.getSettings().setMediaPlaybackRequiresUserGesture(true);
|
webView.getSettings().setMediaPlaybackRequiresUserGesture(true);
|
||||||
}
|
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null);
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
if( user_agent != null) {
|
||||||
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
webView.getSettings().setUserAgentString(user_agent);
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
boolean cookies = sharedpreferences.getBoolean(Helper.SET_COOKIES, false);
|
boolean cookies = sharedpreferences.getBoolean(Helper.SET_COOKIES, false);
|
||||||
|
|
|
@ -1818,6 +1818,8 @@
|
||||||
|
|
||||||
<!-- Featured tags -->
|
<!-- Featured tags -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:layout_marginTop="@dimen/settings_option_margin"
|
||||||
|
android:layout_marginBottom="@dimen/settings_option_margin"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
@ -1849,6 +1851,38 @@
|
||||||
android:textColor="@color/mastodonC2" />
|
android:textColor="@color/mastodonC2" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- user agent -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_marginTop="@dimen/settings_option_margin"
|
||||||
|
android:layout_marginBottom="@dimen/settings_option_margin"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:labelFor="@+id/set_user_agent"
|
||||||
|
android:text="@string/set_user_agent"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/set_user_agent"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:hint="@string/set_user_agent_hint"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textMultiLine"
|
||||||
|
android:lines="2"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/set_user_agent_indication"
|
||||||
|
android:textColor="@color/mastodonC2" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- TRUNCATE LONG TOOTS -->
|
<!-- TRUNCATE LONG TOOTS -->
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -1197,4 +1197,7 @@
|
||||||
<string name="check_redirect">Check redirect</string>
|
<string name="check_redirect">Check redirect</string>
|
||||||
<string name="no_redirect">This URL does not redirect</string>
|
<string name="no_redirect">This URL does not redirect</string>
|
||||||
<string name="redirect_detected">%1$s \n\nredirects to\n\n %2$s</string>
|
<string name="redirect_detected">%1$s \n\nredirects to\n\n %2$s</string>
|
||||||
|
<string name="set_user_agent">Change the user agent</string>
|
||||||
|
<string name="set_user_agent_hint">Set a custom user agent or leave blank</string>
|
||||||
|
<string name="set_user_agent_indication">Allows to customize the user agent used for api calls or with the built-in browser.</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue