aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui
diff options
context:
space:
mode:
authorChristian Schneppe <christian.schneppe@pix-art.de>2019-11-15 21:53:21 +0100
committerChristian Schneppe <christian.schneppe@pix-art.de>2019-11-15 21:53:21 +0100
commit449f09c9754a0a29c52db2c7c7fa46f4c1392427 (patch)
treedc7a0f6878954d21c38d31c6be3b2598c153ab38 /src/main/java/de/pixart/messenger/ui
parent78c85da03cb0c8336db9b910fae3c499ebae5f0a (diff)
fix duplicate accounts in EnterJidDialog
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r--src/main/java/de/pixart/messenger/ui/EnterJidDialog.java66
-rw-r--r--src/main/java/de/pixart/messenger/ui/StartConversationActivity.java14
2 files changed, 35 insertions, 45 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/EnterJidDialog.java b/src/main/java/de/pixart/messenger/ui/EnterJidDialog.java
index 2b9a6b8e3..6a7b1e98b 100644
--- a/src/main/java/de/pixart/messenger/ui/EnterJidDialog.java
+++ b/src/main/java/de/pixart/messenger/ui/EnterJidDialog.java
@@ -2,16 +2,17 @@ package de.pixart.messenger.ui;
import android.app.Activity;
import android.app.Dialog;
-import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.fragment.app.DialogFragment;
-import androidx.appcompat.app.AlertDialog;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.ArrayAdapter;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
+import androidx.databinding.DataBindingUtil;
+import androidx.fragment.app.DialogFragment;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -28,7 +29,11 @@ import rocks.xmpp.addr.Jid;
public class EnterJidDialog extends DialogFragment implements OnBackendConnected, TextWatcher {
+
private static final List<String> SUSPICIOUS_DOMAINS = Arrays.asList("conference", "muc", "room", "rooms", "chat");
+
+ private OnEnterJidDialogPositiveListener mListener = null;
+
private static final String TITLE_KEY = "title";
private static final String POSITIVE_BUTTON_KEY = "positive_button";
private static final String PREFILLED_JID_KEY = "prefilled_jid";
@@ -38,12 +43,9 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected
private static final String ACCOUNTS_LIST_KEY = "activated_accounts_list";
private static final String SANITY_CHECK_JID = "sanity_check_jid";
- private OnEnterJidDialogPositiveListener mListener = null;
-
private KnownHostsAdapter knownHostsAdapter;
private Collection<String> whitelistedDomains = Collections.emptyList();
-
private EnterJidDialogBinding binding;
private AlertDialog dialog;
private boolean sanityCheckJid = false;
@@ -101,7 +103,6 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected
binding.jid.setCursorVisible(false);
}
}
-
sanityCheckJid = getArguments().getBoolean(SANITY_CHECK_JID, false);
DelayedHintHelper.setHint(R.string.account_settings_example_jabber_id, binding.jid);
@@ -135,6 +136,7 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected
View.OnClickListener dialogOnClick = v -> {
handleEnter(binding, account);
};
+
binding.jid.setOnEditorActionListener((v, actionId, event) -> {
handleEnter(binding, account);
return true;
@@ -195,25 +197,6 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected
}
}
- @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) {
- if (issuedWarning) {
- dialog.getButton(AlertDialog.BUTTON_POSITIVE).setText(R.string.add);
- binding.jidLayout.setError(null);
- issuedWarning = false;
- }
- }
-
public void setOnEnterJidDialogPositiveListener(OnEnterJidDialogPositiveListener listener) {
this.mListener = listener;
}
@@ -233,12 +216,22 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected
}
@Override
- public void onDestroyView() {
- Dialog dialog = getDialog();
- if (dialog != null && getRetainInstance()) {
- dialog.setDismissMessage(null);
+ 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) {
+ if (issuedWarning) {
+ dialog.getButton(AlertDialog.BUTTON_POSITIVE).setText(R.string.add);
+ binding.jidLayout.setError(null);
+ issuedWarning = false;
}
- super.onDestroyView();
}
public interface OnEnterJidDialogPositiveListener {
@@ -257,6 +250,15 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected
}
}
+ @Override
+ public void onDestroyView() {
+ Dialog dialog = getDialog();
+ if (dialog != null && getRetainInstance()) {
+ dialog.setDismissMessage(null);
+ }
+ super.onDestroyView();
+ }
+
private boolean suspiciousSubDomain(String domain) {
if (this.whitelistedDomains.contains(domain)) {
return false;
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
index 4cfd752b6..cabdfc8fa 100644
--- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
@@ -51,7 +51,6 @@ import androidx.viewpager.widget.ViewPager;
import com.google.android.material.textfield.TextInputLayout;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -215,9 +214,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
spinner.setAdapter(adapter);
spinner.setEnabled(true);
} else {
- ArrayAdapter<String> adapter = new ArrayAdapter<>(context,
- R.layout.simple_list_item,
- Arrays.asList(context.getString(R.string.no_accounts)));
+ ArrayAdapter<String> adapter = new ArrayAdapter<>(context, R.layout.simple_list_item, Collections.singletonList(context.getString(R.string.no_accounts)));
adapter.setDropDownViewResource(R.layout.simple_list_item);
spinner.setAdapter(adapter);
spinner.setEnabled(false);
@@ -776,15 +773,6 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
this.mPostponedActivityResult = null;
}
this.mActivatedAccounts.addAll(AccountUtils.getEnabledAccounts(xmppConnectionService));
- for (Account account : xmppConnectionService.getAccounts()) {
- if (account.getStatus() != Account.State.DISABLED) {
- if (Config.DOMAIN_LOCK != null) {
- this.mActivatedAccounts.add(account.getJid().getLocal());
- } else {
- this.mActivatedAccounts.add(account.getJid().asBareJid().toString());
- }
- }
- }
configureHomeButton();
Intent intent = pendingViewIntent.pop();
if (intent != null && processViewIntent(intent)) {