Small fix

This commit is contained in:
Thomas 2021-01-03 10:02:11 +01:00
parent 8178cff72c
commit d446081331
3 changed files with 44 additions and 4 deletions

View File

@ -78,7 +78,6 @@ public class LoginActivity extends AppCompatActivity {
SpannableString content_create; SpannableString content_create;
//noinspection ConstantConditions
if (BuildConfig.FLAVOR.compareTo("queermotion") == 0) { if (BuildConfig.FLAVOR.compareTo("queermotion") == 0) {
content_create = new SpannableString(getString(R.string.register_account)); content_create = new SpannableString(getString(R.string.register_account));
} else { } else {
@ -101,7 +100,6 @@ public class LoginActivity extends AppCompatActivity {
if (BuildConfig.full_instances && BuildConfig.instance_switcher) { if (BuildConfig.full_instances && BuildConfig.instance_switcher) {
binding.loginInstanceContainer.setVisibility(View.VISIBLE); binding.loginInstanceContainer.setVisibility(View.VISIBLE);
} }
//noinspection ConstantConditions
if (BuildConfig.FLAVOR.compareTo("queermotion") == 0) { if (BuildConfig.FLAVOR.compareTo("queermotion") == 0) {
binding.loginInstance.setText("queermotion.org"); binding.loginInstance.setText("queermotion.org");
} }
@ -121,7 +119,6 @@ public class LoginActivity extends AppCompatActivity {
binding.loginPasswdContainer.setLayoutParams(layoutParamsP); binding.loginPasswdContainer.setLayoutParams(layoutParamsP);
} }
if (!BuildConfig.full_instances) { if (!BuildConfig.full_instances) {
binding.loginUid.setOnFocusChangeListener((v, hasFocus) -> { binding.loginUid.setOnFocusChangeListener((v, hasFocus) -> {
if (!hasFocus) { if (!hasFocus) {
@ -173,7 +170,27 @@ public class LoginActivity extends AppCompatActivity {
} }
}); });
} }
if (BuildConfig.allow_remote_connections) {
binding.loginInstance.setOnFocusChangeListener((v, hasFocus) -> {
if (!hasFocus) {
if (binding.loginInstance.getText() != null) {
new Thread(() -> {
String testInstance = binding.loginInstance.getText().toString();
WellKnownNodeinfo.NodeInfo instanceNodeInfo = null;
if (BuildConfig.allow_remote_connections) {
instanceNodeInfo = new RetrofitPeertubeAPI(LoginActivity.this, testInstance, null).getNodeInfo();
}
if (instanceNodeInfo != null &&
(instanceNodeInfo.getSoftware().getName().toUpperCase().trim().compareTo("MASTODON") == 0 ||
instanceNodeInfo.getSoftware().getName().toUpperCase().trim().compareTo("PLEROMA") == 0)
) {
connectToFediverse(testInstance, instanceNodeInfo);
}
}).start();
}
}
});
}
binding.loginButton.setOnClickListener(v -> { binding.loginButton.setOnClickListener(v -> {
if (!BuildConfig.full_instances) { if (!BuildConfig.full_instances) {

View File

@ -23,6 +23,7 @@ import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.MenuItem;
import android.webkit.CookieManager; import android.webkit.CookieManager;
import android.webkit.CookieSyncManager; import android.webkit.CookieSyncManager;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
@ -160,6 +161,16 @@ public class MastodonWebviewConnectActivity extends AppCompatActivity {
webView.loadUrl(redirectUserToAuthorizeAndLogin(clientId, instance)); webView.loadUrl(redirectUserToAuthorizeAndLogin(clientId, instance));
} }
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (webView != null && webView.canGoBack()) { if (webView != null && webView.canGoBack()) {

View File

@ -19,6 +19,7 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.MenuItem;
import android.webkit.CookieManager; import android.webkit.CookieManager;
import android.webkit.CookieSyncManager; import android.webkit.CookieSyncManager;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
@ -158,6 +159,17 @@ public class WebviewConnectActivity extends AppCompatActivity {
} }
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (webView != null && webView.canGoBack()) { if (webView != null && webView.canGoBack()) {