aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
authorChristian Schneppe <christian.schneppe@pix-art.de>2019-09-24 20:41:17 +0200
committerChristian Schneppe <christian.schneppe@pix-art.de>2019-09-24 20:41:17 +0200
commit2565da03bb5b09a4f72c8d0a2fe4222667a42a55 (patch)
tree1b5294f7beac42bd35eb50ad0d47f6e2502b922f /src/main/java/de/pixart
parent5aa83a0db42a71f028314acf4b955dd00bb3d9e1 (diff)
channel search result long press to show join dialog
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java14
-rw-r--r--src/main/java/de/pixart/messenger/ui/JoinConferenceDialog.java17
-rw-r--r--src/main/java/de/pixart/messenger/ui/StartConversationActivity.java28
3 files changed, 43 insertions, 16 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java b/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java
index 7e0d97ea2..175dd9bb8 100644
--- a/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java
@@ -2,10 +2,10 @@ package de.pixart.messenger.ui;
import android.app.AlertDialog;
import android.content.Context;
+import android.content.Intent;
import android.content.SharedPreferences;
-import androidx.databinding.DataBindingUtil;
+import android.net.Uri;
import android.os.Bundle;
-import androidx.appcompat.widget.Toolbar;
import android.text.Html;
import android.view.KeyEvent;
import android.view.Menu;
@@ -15,6 +15,9 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
+import androidx.appcompat.widget.Toolbar;
+import androidx.databinding.DataBindingUtil;
+
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
@@ -197,6 +200,13 @@ public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.O
case R.id.share_with:
StartConversationActivity.shareAsChannel(this, room.address);
return true;
+ case R.id.open_join_dialog:
+ final Intent intent = new Intent(this, StartConversationActivity.class);
+ intent.setAction(Intent.ACTION_VIEW);
+ intent.putExtra("force_dialog", true);
+ intent.setData(Uri.parse(String.format("xmpp:%s?join", room.address)));
+ startActivity(intent);
+ return true;
}
}
return false;
diff --git a/src/main/java/de/pixart/messenger/ui/JoinConferenceDialog.java b/src/main/java/de/pixart/messenger/ui/JoinConferenceDialog.java
index 3ed86aba5..d65d8db74 100644
--- a/src/main/java/de/pixart/messenger/ui/JoinConferenceDialog.java
+++ b/src/main/java/de/pixart/messenger/ui/JoinConferenceDialog.java
@@ -4,15 +4,18 @@ import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
-import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.fragment.app.DialogFragment;
-import androidx.appcompat.app.AlertDialog;
import android.view.View;
import android.widget.AutoCompleteTextView;
import android.widget.Spinner;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
+import androidx.databinding.DataBindingUtil;
+import androidx.fragment.app.DialogFragment;
+
+import com.google.android.material.textfield.TextInputLayout;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -74,9 +77,9 @@ public class JoinConferenceDialog extends DialogFragment implements OnBackendCon
builder.setNegativeButton(R.string.cancel, null);
AlertDialog dialog = builder.create();
dialog.show();
- dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(view -> mListener.onJoinDialogPositiveClick(dialog, binding.account, binding.jid, binding.bookmark.isChecked()));
+ dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(view -> mListener.onJoinDialogPositiveClick(dialog, binding.account, binding.accountJidLayout, binding.jid, binding.bookmark.isChecked()));
binding.jid.setOnEditorActionListener((v, actionId, event) -> {
- mListener.onJoinDialogPositiveClick(dialog, binding.account, binding.jid, binding.bookmark.isChecked());
+ mListener.onJoinDialogPositiveClick(dialog, binding.account, binding.accountJidLayout, binding.jid, binding.bookmark.isChecked());
return true;
});
return dialog;
@@ -125,6 +128,6 @@ public class JoinConferenceDialog extends DialogFragment implements OnBackendCon
}
public interface JoinConferenceDialogListener {
- void onJoinDialogPositiveClick(Dialog dialog, Spinner spinner, AutoCompleteTextView jid, boolean isBookmarkChecked);
+ void onJoinDialogPositiveClick(Dialog dialog, Spinner spinner, TextInputLayout jidLayout, AutoCompleteTextView jid, boolean isBookmarkChecked);
}
} \ No newline at end of file
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
index 56d071e68..d94ebfb28 100644
--- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
@@ -48,6 +48,8 @@ import androidx.fragment.app.ListFragment;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
+import com.google.android.material.textfield.TextInputLayout;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -820,6 +822,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
if (uri != null) {
Invite invite = new Invite(intent.getData(), intent.getBooleanExtra("scanned", false));
invite.account = intent.getStringExtra("account");
+ invite.forceDialog = intent.getBooleanExtra("force_dialog", false);
return invite.invite();
} else {
return false;
@@ -832,7 +835,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
List<Contact> contacts = xmppConnectionService.findContacts(invite.getJid(), invite.account);
if (invite.isAction(XmppUri.ACTION_JOIN)) {
Conversation muc = xmppConnectionService.findFirstMuc(invite.getJid());
- if (muc != null) {
+ if (muc != null && !invite.forceDialog) {
switchToConversationDoNotAppend(muc, invite.getBody());
return true;
} else {
@@ -985,7 +988,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
}
@Override
- public void onJoinDialogPositiveClick(Dialog dialog, Spinner spinner, AutoCompleteTextView jid, boolean isBookmarkChecked) {
+ public void onJoinDialogPositiveClick(Dialog dialog, Spinner spinner, TextInputLayout layout, AutoCompleteTextView jid, boolean isBookmarkChecked) {
if (!xmppConnectionServiceBound) {
return;
}
@@ -993,17 +996,26 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
if (account == null) {
return;
}
- final Jid conferenceJid;
+ final String input = jid.getText().toString();
+ Jid conferenceJid;
try {
- conferenceJid = Jid.of(jid.getText().toString());
+ conferenceJid = Jid.of(input);
} catch (final IllegalArgumentException e) {
- jid.setError(getString(R.string.invalid_jid));
- return;
+ final XmppUri xmppUri = new XmppUri(input);
+ if (xmppUri.isJidValid() && xmppUri.isAction(XmppUri.ACTION_JOIN)) {
+ final Editable editable = jid.getEditableText();
+ editable.clear();
+ editable.append(xmppUri.getJid().toEscapedString());
+ conferenceJid = xmppUri.getJid();
+ } else {
+ layout.setError(getString(R.string.invalid_jid));
+ return;
+ }
}
if (isBookmarkChecked) {
if (account.hasBookmarkFor(conferenceJid)) {
- jid.setError(getString(R.string.bookmark_already_exists));
+ layout.setError(getString(R.string.bookmark_already_exists));
} else {
final Bookmark bookmark = new Bookmark(account, conferenceJid.asBareJid());
bookmark.setAutojoin(getBooleanPreference("autojoin", R.bool.autojoin));
@@ -1241,6 +1253,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
public String account;
+ public boolean forceDialog = false;
+
public Invite(final Uri uri) {
super(uri);
}