1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-08 07:57:28 +00:00

login update

This commit is contained in:
Austin Huang 2021-04-03 19:30:00 -04:00
parent 067417b12e
commit bcde6ac85a
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F

View File

@ -24,7 +24,7 @@ import awais.instagrabber.utils.Constants;
import awais.instagrabber.utils.CookieUtils; import awais.instagrabber.utils.CookieUtils;
import awais.instagrabber.utils.TextUtils; import awais.instagrabber.utils.TextUtils;
public final class Login extends BaseLanguageActivity implements View.OnClickListener, CompoundButton.OnCheckedChangeListener { public final class Login extends BaseLanguageActivity implements View.OnClickListener {
private final WebViewClient webViewClient = new WebViewClient() { private final WebViewClient webViewClient = new WebViewClient() {
@Override @Override
public void onPageStarted(final WebView view, final String url, final Bitmap favicon) { public void onPageStarted(final WebView view, final String url, final Bitmap favicon) {
@ -53,7 +53,7 @@ public final class Login extends BaseLanguageActivity implements View.OnClickLis
} }
private final WebChromeClient webChromeClient = new WebChromeClient(); private final WebChromeClient webChromeClient = new WebChromeClient();
private String webViewUrl, defaultUserAgent; private String webViewUrl;
private boolean ready = false; private boolean ready = false;
private ActivityLoginBinding loginBinding; private ActivityLoginBinding loginBinding;
@ -65,7 +65,6 @@ public final class Login extends BaseLanguageActivity implements View.OnClickLis
initWebView(); initWebView();
loginBinding.desktopMode.setOnCheckedChangeListener(this);
loginBinding.cookies.setOnClickListener(this); loginBinding.cookies.setOnClickListener(this);
loginBinding.refresh.setOnClickListener(this); loginBinding.refresh.setOnClickListener(this);
} }
@ -86,23 +85,6 @@ public final class Login extends BaseLanguageActivity implements View.OnClickLis
} }
} }
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
final WebSettings webSettings = loginBinding.webView.getSettings();
final String newUserAgent = isChecked
? "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36"
: defaultUserAgent;
webSettings.setUserAgentString(newUserAgent);
webSettings.setUseWideViewPort(isChecked);
webSettings.setLoadWithOverviewMode(isChecked);
webSettings.setSupportZoom(isChecked);
webSettings.setBuiltInZoomControls(isChecked);
loginBinding.webView.loadUrl("https://instagram.com/");
}
@SuppressLint("SetJavaScriptEnabled") @SuppressLint("SetJavaScriptEnabled")
private void initWebView() { private void initWebView() {
if (loginBinding != null) { if (loginBinding != null) {
@ -110,7 +92,7 @@ public final class Login extends BaseLanguageActivity implements View.OnClickLis
loginBinding.webView.setWebViewClient(webViewClient); loginBinding.webView.setWebViewClient(webViewClient);
final WebSettings webSettings = loginBinding.webView.getSettings(); final WebSettings webSettings = loginBinding.webView.getSettings();
if (webSettings != null) { if (webSettings != null) {
if (defaultUserAgent == null) defaultUserAgent = webSettings.getUserAgentString(); webSettings.setUserAgentString("Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.105 Mobile Safari/537.36");
webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true); webSettings.setDomStorageEnabled(true);
webSettings.setSupportZoom(true); webSettings.setSupportZoom(true);