aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationsActivity.java3
-rw-r--r--src/main/java/de/pixart/messenger/ui/XmppActivity.java60
-rw-r--r--src/main/res/layout/choose_account_dialog.xml22
-rw-r--r--src/main/res/menu/activity_conversations.xml13
-rw-r--r--src/main/res/menu/fragment_conversation.xml5
-rw-r--r--src/main/res/values/strings.xml1
6 files changed, 81 insertions, 23 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java
index 2eef85029..89e003e9f 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java
@@ -535,6 +535,9 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
Toast.makeText(this, R.string.account_status_no_internet, Toast.LENGTH_LONG).show();
}
break;
+ case R.id.action_invite_user:
+ inviteUser();
+ break;
}
return super.onOptionsItemSelected(item);
}
diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
index a3ddb8a95..c51e2ffe6 100644
--- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
@@ -50,6 +50,7 @@ import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
+import android.widget.Spinner;
import android.widget.Toast;
import net.java.otr4j.session.SessionID;
@@ -378,9 +379,6 @@ public abstract class XmppActivity extends AppCompatActivity {
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
- case R.id.action_invite_user:
- inviteUser();
- break;
case R.id.action_create_issue:
createIssue();
break;
@@ -962,17 +960,51 @@ public abstract class XmppActivity extends AppCompatActivity {
return null;
}
- private void inviteUser() {
- Account mAccount = xmppConnectionService.getAccounts().get(0);
- String user = mAccount.getJid().getLocal().toString();
- String domain = mAccount.getJid().getDomain().toString();
- String inviteURL = Config.inviteUserURL + user + "/" + domain;
- String inviteText = getString(R.string.InviteText, user);
- Intent intent = new Intent(android.content.Intent.ACTION_SEND);
- intent.setType("text/plain");
- intent.putExtra(Intent.EXTRA_SUBJECT, user + " " + getString(R.string.inviteUser_Subject) + " " + getString(R.string.app_name));
- intent.putExtra(Intent.EXTRA_TEXT, inviteText + "\n\n" + inviteURL);
- startActivity(Intent.createChooser(intent, getString(R.string.invite_contact)));
+ public void inviteUser() {
+ if (xmppConnectionServiceBound && !xmppConnectionService.multipleAccounts()) {
+ Account mAccount = xmppConnectionService.getAccounts().get(0);
+ String user = Jid.of(mAccount.getJid()).getLocal();
+ String domain = Jid.of(mAccount.getJid()).getDomain();
+ String inviteURL = Config.inviteUserURL + user + "/" + domain;
+ String inviteText = getString(R.string.InviteText, user);
+ Intent intent = new Intent(android.content.Intent.ACTION_SEND);
+ intent.setType("text/plain");
+ intent.putExtra(Intent.EXTRA_SUBJECT, user + " " + getString(R.string.inviteUser_Subject) + " " + getString(R.string.app_name));
+ intent.putExtra(Intent.EXTRA_TEXT, inviteText + "\n\n" + inviteURL);
+ startActivity(Intent.createChooser(intent, getString(R.string.invite_contact)));
+ } else {
+ final AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.chooce_account);
+ final View dialogView = this.getLayoutInflater().inflate(R.layout.choose_account_dialog, null);
+ final Spinner spinner = dialogView.findViewById(R.id.account);
+ builder.setView(dialogView);
+ List<String> mActivatedAccounts = new ArrayList<>();
+ for (Account account : xmppConnectionService.getAccounts()) {
+ if (account.getStatus() != Account.State.DISABLED) {
+ if (Config.DOMAIN_LOCK != null) {
+ mActivatedAccounts.add(account.getJid().getLocal());
+ } else {
+ mActivatedAccounts.add(account.getJid().asBareJid().toString());
+ }
+ }
+ }
+ StartConversationActivity.populateAccountSpinner(this, mActivatedAccounts, spinner);
+ builder.setPositiveButton(R.string.ok,
+ (dialog, id) -> {
+ String selection = spinner.getSelectedItem().toString();
+ String user = Jid.of(selection).getLocal();
+ String domain = Jid.of(selection).getDomain();
+ String inviteURL = Config.inviteUserURL + user + "/" + domain;
+ String inviteText = getString(R.string.InviteText, user);
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType("text/plain");
+ intent.putExtra(Intent.EXTRA_SUBJECT, user + " " + getString(R.string.inviteUser_Subject) + " " + getString(R.string.app_name));
+ intent.putExtra(Intent.EXTRA_TEXT, inviteText + "\n\n" + inviteURL);
+ startActivity(Intent.createChooser(intent, getString(R.string.invite_contact)));
+ });
+ builder.setNegativeButton(R.string.cancel, null);
+ builder.create().show();
+ }
}
private void createIssue() {
diff --git a/src/main/res/layout/choose_account_dialog.xml b/src/main/res/layout/choose_account_dialog.xml
new file mode 100644
index 000000000..da747fbf4
--- /dev/null
+++ b/src/main/res/layout/choose_account_dialog.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:paddingBottom="?attr/dialog_vertical_padding"
+ android:paddingLeft="?attr/dialog_horizontal_padding"
+ android:paddingRight="?attr/dialog_horizontal_padding"
+ android:paddingTop="?attr/dialog_vertical_padding">
+
+ <Spinner
+ android:id="@+id/account"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
+</LinearLayout> \ No newline at end of file
diff --git a/src/main/res/menu/activity_conversations.xml b/src/main/res/menu/activity_conversations.xml
index aa2d54919..a396194c6 100644
--- a/src/main/res/menu/activity_conversations.xml
+++ b/src/main/res/menu/activity_conversations.xml
@@ -8,10 +8,6 @@
android:visible="@bool/show_qr_code_scan"
app:showAsAction="always" />
<item
- android:id="@+id/action_check_updates"
- app:showAsAction="never"
- android:title="@string/action_check_update" />
- <item
android:id="@+id/action_accounts"
android:orderInCategory="90"
android:title="@string/action_accounts"
@@ -21,5 +17,14 @@
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
+ <item
+ android:id="@+id/action_check_updates"
+ app:showAsAction="never"
+ android:title="@string/action_check_update" />
+ <item
+ android:id="@+id/action_invite_user"
+ android:orderInCategory="100"
+ app:showAsAction="never"
+ android:title="@string/invite_user" />
</menu> \ No newline at end of file
diff --git a/src/main/res/menu/fragment_conversation.xml b/src/main/res/menu/fragment_conversation.xml
index 78edffeca..1fb3f1391 100644
--- a/src/main/res/menu/fragment_conversation.xml
+++ b/src/main/res/menu/fragment_conversation.xml
@@ -73,11 +73,6 @@
app:showAsAction="never"
android:title="@string/action_end_conversation" />
<item
- android:id="@+id/action_invite_user"
- android:orderInCategory="100"
- app:showAsAction="never"
- android:title="@string/invite_user" />
- <item
android:id="@+id/action_create_issue"
android:orderInCategory="100"
app:showAsAction="never"
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 6b72fa1a7..809b77dba 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -781,4 +781,5 @@
<string name="pref_theme_dark">Dark theme</string>
<string name="pref_theme_options_summary">Select the color palette</string>
<string name="pref_theme_options">Theme</string>
+ <string name="chooce_account">Choose account</string>
</resources>