diff options
16 files changed, 181 insertions, 107 deletions
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index ce3bfc406..f44c1c889 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -56,6 +56,7 @@ android:largeHeap="true" android:networkSecurityConfig="@xml/network_security_configuration" android:theme="@style/ConversationsTheme" + tools:ignore="GoogleAppIndexingWarning" tools:replace="android:label, android:allowBackup" tools:targetApi="o"> diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java index c186732bf..99ba3ddfe 100644 --- a/src/main/java/de/pixart/messenger/services/NotificationService.java +++ b/src/main/java/de/pixart/messenger/services/NotificationService.java @@ -54,8 +54,10 @@ import de.pixart.messenger.entities.Conversational; import de.pixart.messenger.entities.Message; import de.pixart.messenger.persistance.FileBackend; import de.pixart.messenger.ui.ConversationsActivity; +import de.pixart.messenger.ui.EditAccountActivity; import de.pixart.messenger.ui.ManageAccountActivity; import de.pixart.messenger.ui.TimePreference; +import de.pixart.messenger.utils.AccountUtils; import de.pixart.messenger.utils.Compatibility; import de.pixart.messenger.utils.GeoHelper; import de.pixart.messenger.utils.UIHelper; @@ -961,10 +963,14 @@ public class NotificationService { mBuilder.setLocalOnly(true); } mBuilder.setPriority(Notification.PRIORITY_LOW); - mBuilder.setContentIntent(PendingIntent.getActivity(mXmppConnectionService, - 145, - new Intent(mXmppConnectionService, ManageAccountActivity.class), - PendingIntent.FLAG_UPDATE_CURRENT)); + final Intent intent; + if (AccountUtils.MANAGE_ACCOUNT_ACTIVITY != null) { + intent = new Intent(mXmppConnectionService, AccountUtils.MANAGE_ACCOUNT_ACTIVITY); + } else { + intent = new Intent(mXmppConnectionService, EditAccountActivity.class); + intent.putExtra("jid", errors.get(0).getJid().asBareJid().toEscapedString()); + } + mBuilder.setContentIntent(PendingIntent.getActivity(mXmppConnectionService, 145, intent, PendingIntent.FLAG_UPDATE_CURRENT)); if (Compatibility.runsTwentySix()) { mBuilder.setChannelId(ERROR_CHANNEL_ID); } diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 54e86a6ab..bb704c6b6 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -4285,18 +4285,6 @@ public class XmppConnectionService extends Service { return mPushManagementService; } - public Account getPendingAccount() { - Account pending = null; - for (Account account : getAccounts()) { - if (!account.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY)) { - pending = account; - } else { - return null; - } - } - return pending; - } - public void changeStatus(Account account, PresenceTemplate template, String signature) { if (!template.getStatusMessage().isEmpty()) { databaseBackend.insertPresenceTemplate(template); diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java index 787942b8d..a0b91a8c7 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java @@ -89,6 +89,7 @@ import de.pixart.messenger.ui.util.PendingItem; import de.pixart.messenger.utils.EmojiWrapper; import de.pixart.messenger.utils.ExceptionHelper; import de.pixart.messenger.utils.MenuDoubleTabUtil; +import de.pixart.messenger.utils.SignupUtils; import de.pixart.messenger.utils.UIHelper; import de.pixart.messenger.utils.XmppUri; import de.pixart.messenger.xmpp.OnUpdateBlocklist; @@ -235,7 +236,10 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio } boolean isConversationsListEmpty = xmppConnectionService.isConversationsListEmpty(ignore); if (isConversationsListEmpty && mRedirectInProcess.compareAndSet(false, true)) { - final Intent intent = getRedirectionIntent(noAnimation); + final Intent intent = SignupUtils.getRedirectionIntent(this); + if (noAnimation) { + intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); + } runOnUiThread(() -> { startActivity(intent); overridePendingTransition(R.animator.fade_in, R.animator.fade_out); @@ -247,34 +251,6 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio return mRedirectInProcess.get(); } - private Intent getRedirectionIntent(boolean noAnimation) { - Account pendingAccount = xmppConnectionService.getPendingAccount(); - Intent intent; - if (pendingAccount != null) { - intent = new Intent(this, EditAccountActivity.class); - intent.putExtra("jid", pendingAccount.getJid().asBareJid().toString()); - } else { - if (xmppConnectionService.getAccounts().size() == 0) { - if (Config.X509_VERIFICATION) { - intent = new Intent(this, ManageAccountActivity.class); - } else if (Config.MAGIC_CREATE_DOMAIN != null) { - intent = new Intent(this, WelcomeActivity.class); - WelcomeActivity.addInviteUri(intent, getIntent()); - } else { - intent = new Intent(this, EditAccountActivity.class); - } - } else { - intent = new Intent(this, StartConversationActivity.class); - } - } - intent.putExtra("init", true); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); - if (noAnimation) { - intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); - } - return intent; - } - private void showDialogsIfMainIsOverview() { if (xmppConnectionService == null) { return; diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index 3d9c0e63e..426627510 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -66,6 +66,7 @@ import de.pixart.messenger.ui.util.SoftKeyboardUtils; import de.pixart.messenger.utils.CryptoHelper; import de.pixart.messenger.utils.MenuDoubleTabUtil; import de.pixart.messenger.utils.Namespace; +import de.pixart.messenger.utils.SignupUtils; import de.pixart.messenger.utils.UIHelper; import de.pixart.messenger.utils.XmppUri; import de.pixart.messenger.xml.Element; @@ -268,8 +269,9 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat if (mAccount != null && mAccount.getStatus() != Account.State.ONLINE && mFetchingAvatar) { - //TODO: maybe better redirect to StartConversationActivity - startActivity(new Intent(this, ManageAccountActivity.class)); + Intent intent = new Intent(this, StartConversationActivity.class); + StartConversationActivity.addInviteUri(intent, getIntent()); + startActivity(intent); overridePendingTransition(R.animator.fade_in, R.animator.fade_out); finish(); } else if (mInitMode && mAccount != null && mAccount.getStatus() == Account.State.ONLINE) { @@ -301,8 +303,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat xmppConnectionService.deleteAccount(mAccount); } if (xmppConnectionService.getAccounts().size() == 0 && Config.MAGIC_CREATE_DOMAIN != null) { - Intent intent = new Intent(EditAccountActivity.this, WelcomeActivity.class); - WelcomeActivity.addInviteUri(intent, getIntent()); + Intent intent = SignupUtils.getSignUpIntent(this); startActivity(intent); overridePendingTransition(R.animator.fade_in, R.animator.fade_out); } @@ -398,7 +399,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat if (wasFirstAccount) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); } - WelcomeActivity.addInviteUri(intent, getIntent()); + StartConversationActivity.addInviteUri(intent, getIntent()); startActivity(intent); overridePendingTransition(R.animator.fade_in, R.animator.fade_out); finish(); diff --git a/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java b/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java index 10c68cc1d..b5f2c02e7 100644 --- a/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java +++ b/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java @@ -97,7 +97,7 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher, Ad intent.putExtra("init", true); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Toast.makeText(MagicCreateActivity.this, R.string.secure_password_generated, Toast.LENGTH_LONG).show(); - WelcomeActivity.addInviteUri(intent, getIntent()); + StartConversationActivity.addInviteUri(intent, getIntent()); startActivity(intent); overridePendingTransition(R.animator.fade_in, R.animator.fade_out); finish(); diff --git a/src/main/java/de/pixart/messenger/ui/PublishProfilePictureActivity.java b/src/main/java/de/pixart/messenger/ui/PublishProfilePictureActivity.java index 9d6df3980..469ce8021 100644 --- a/src/main/java/de/pixart/messenger/ui/PublishProfilePictureActivity.java +++ b/src/main/java/de/pixart/messenger/ui/PublishProfilePictureActivity.java @@ -50,7 +50,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC runOnUiThread(() -> { if (mInitialAccountSetup) { Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class); - WelcomeActivity.addInviteUri(intent, getIntent()); + StartConversationActivity.addInviteUri(intent, getIntent()); intent.putExtra("init", true); startActivity(intent); } @@ -94,7 +94,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC if (mInitialAccountSetup) { Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class); if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) { - WelcomeActivity.addInviteUri(intent, getIntent()); + StartConversationActivity.addInviteUri(intent, getIntent()); intent.putExtra("init", true); } startActivity(intent); diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 5b337abb6..ade478aa1 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -81,6 +81,8 @@ import static de.pixart.messenger.ui.SettingsActivity.USE_BUNDLED_EMOJIS; public class StartConversationActivity extends XmppActivity implements XmppConnectionService.OnConversationUpdate, OnRosterUpdate, OnUpdateBlocklist, CreateConferenceDialog.CreateConferenceDialogListener, JoinConferenceDialog.JoinConferenceDialogListener { + public static final String EXTRA_INVITE_URI = "eu.siacs.conversations.invite_uri"; + private final int REQUEST_SYNC_CONTACTS = 0x28cf; private final int REQUEST_CREATE_CONFERENCE = 0x39da; private final PendingItem<Intent> pendingViewIntent = new PendingItem<>(); @@ -235,7 +237,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } private static boolean isViewIntent(final Intent i) { - return i != null && (Intent.ACTION_VIEW.equals(i.getAction()) || Intent.ACTION_SENDTO.equals(i.getAction()) || i.hasExtra(WelcomeActivity.EXTRA_INVITE_URI)); + return i != null && (Intent.ACTION_VIEW.equals(i.getAction()) || Intent.ACTION_SENDTO.equals(i.getAction()) || i.hasExtra(EXTRA_INVITE_URI)); } protected void hideToast() { @@ -762,7 +764,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } protected boolean processViewIntent(@NonNull Intent intent) { - final String inviteUri = intent.getStringExtra(WelcomeActivity.EXTRA_INVITE_URI); + final String inviteUri = intent.getStringExtra(EXTRA_INVITE_URI); if (inviteUri != null) { Invite invite = new Invite(inviteUri); if (invite.isJidValid()) { @@ -1183,6 +1185,12 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } } + public static void addInviteUri(Intent to, Intent from) { + if (from != null && from.hasExtra(EXTRA_INVITE_URI)) { + to.putExtra(EXTRA_INVITE_URI, from.getStringExtra(EXTRA_INVITE_URI)); + } + } + private class Invite extends XmppUri { public String account; diff --git a/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java b/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java index 66355f49c..c640e42da 100644 --- a/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java +++ b/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java @@ -5,6 +5,7 @@ import android.app.Activity; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; @@ -18,6 +19,7 @@ import java.util.regex.Pattern; import de.pixart.messenger.Config; import de.pixart.messenger.R; import de.pixart.messenger.persistance.DatabaseBackend; +import de.pixart.messenger.utils.SignupUtils; import de.pixart.messenger.utils.XmppUri; import rocks.xmpp.addr.Jid; @@ -26,17 +28,16 @@ public class UriHandlerActivity extends AppCompatActivity { public static final String ACTION_SCAN_QR_CODE = "scan_qr_code"; private static final int REQUEST_SCAN_QR_CODE = 0x1234; private static final int REQUEST_CAMERA_PERMISSIONS_TO_SCAN = 0x6789; - private boolean handled = false; public static void scan(Activity activity) { - if (ContextCompat.checkSelfPermission(activity, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || ContextCompat.checkSelfPermission(activity, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(activity, UriHandlerActivity.class); intent.setAction(UriHandlerActivity.ACTION_SCAN_QR_CODE); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); activity.startActivity(intent); } else { - ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.CAMERA}, REQUEST_CAMERA_PERMISSIONS_TO_SCAN); + activity.requestPermissions(new String[]{Manifest.permission.CAMERA}, REQUEST_CAMERA_PERMISSIONS_TO_SCAN); } } @@ -86,29 +87,36 @@ public class UriHandlerActivity extends AppCompatActivity { final Intent intent; final XmppUri xmppUri = new XmppUri(uri); final List<Jid> accounts = DatabaseBackend.getInstance(this).getAccountJids(); //TODO only look at enabled accounts - - if (!xmppUri.isJidValid()) { - Toast.makeText(this, R.string.invalid_jid, Toast.LENGTH_SHORT).show(); - return; - } - - if (accounts.size() == 0 && Config.MAGIC_CREATE_DOMAIN != null) { - intent = new Intent(getApplicationContext(), WelcomeActivity.class); - WelcomeActivity.addInviteUri(intent, xmppUri); - startActivity(intent); + if (accounts.size() == 0) { + if (xmppUri.isJidValid()) { + intent = SignupUtils.getSignUpIntent(this); + startActivity(intent); + } else { + Toast.makeText(this, R.string.invalid_jid, Toast.LENGTH_SHORT).show(); + } return; } - if (xmppUri.isAction(XmppUri.ACTION_MESSAGE)) { final Jid jid = xmppUri.getJid(); final String body = xmppUri.getBody(); - if (jid != null) { - intent = new Intent(getApplicationContext(), ShareViaAccountActivity.class); - intent.putExtra(ShareViaAccountActivity.EXTRA_CONTACT, jid.toString()); - intent.putExtra(ShareViaAccountActivity.EXTRA_BODY, body); + Class clazz; + try { + clazz = Class.forName("eu.siacs.conversations.ui.ShareViaAccountActivity"); + } catch (ClassNotFoundException e) { + clazz = null; + } + if (clazz != null) { + intent = new Intent(this, clazz); + intent.putExtra("contact", jid.toEscapedString()); + intent.putExtra("body", body); + } else { + intent = new Intent(this, StartConversationActivity.class); + intent.setData(uri); + intent.putExtra("account", accounts.get(0).toEscapedString()); + } } else { - intent = new Intent(getApplicationContext(), ShareWithActivity.class); + intent = new Intent(this, ShareWithActivity.class); intent.setAction(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, body); @@ -119,14 +127,16 @@ public class UriHandlerActivity extends AppCompatActivity { intent.putExtra("jid", xmppUri.getJid().asBareJid().toString()); intent.setData(uri); intent.putExtra("scanned", scanned); - } else { + } else if (xmppUri.isJidValid()) { intent = new Intent(getApplicationContext(), StartConversationActivity.class); intent.setAction(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); intent.putExtra("scanned", scanned); intent.setData(uri); + } else { + Toast.makeText(this, R.string.invalid_jid, Toast.LENGTH_SHORT).show(); + return; } - startActivity(intent); } @@ -138,9 +148,7 @@ public class UriHandlerActivity extends AppCompatActivity { finish(); return; } - handled = true; - switch (data.getAction()) { case Intent.ACTION_VIEW: case Intent.ACTION_SENDTO: @@ -151,7 +159,6 @@ public class UriHandlerActivity extends AppCompatActivity { startActivityForResult(intent, REQUEST_SCAN_QR_CODE); return; } - finish(); } diff --git a/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java b/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java index cdb6a63a2..60461f1b6 100644 --- a/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java +++ b/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java @@ -43,7 +43,6 @@ import de.pixart.messenger.utils.XmppUri; public class WelcomeActivity extends XmppActivity { - public static final String EXTRA_INVITE_URI = "eu.siacs.conversations.invite_uri"; boolean importSuccessful = false; @Override @@ -329,19 +328,7 @@ public class WelcomeActivity extends XmppActivity { } public void addInviteUri(Intent intent) { - addInviteUri(intent, getIntent()); - } - - public static void addInviteUri(Intent intent, XmppUri uri) { - if (uri.isJidValid()) { - intent.putExtra(EXTRA_INVITE_URI, uri.toString()); - } - } - - public static void addInviteUri(Intent to, Intent from) { - if (from != null && from.hasExtra(EXTRA_INVITE_URI)) { - to.putExtra(EXTRA_INVITE_URI, from.getStringExtra(EXTRA_INVITE_URI)); - } + StartConversationActivity.addInviteUri(intent, getIntent()); } public static void launch(AppCompatActivity activity) { diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index d3e1fce9f..ef8b753d0 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -79,6 +79,7 @@ import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.services.XmppConnectionService.XmppConnectionBinder; import de.pixart.messenger.ui.util.PresenceSelector; import de.pixart.messenger.ui.util.SoftKeyboardUtils; +import de.pixart.messenger.utils.AccountUtils; import de.pixart.messenger.utils.CryptoHelper; import de.pixart.messenger.utils.ExceptionHelper; import de.pixart.messenger.utils.MenuDoubleTabUtil; @@ -365,8 +366,7 @@ public abstract class XmppActivity extends ActionBarActivity { startActivity(intent); overridePendingTransition(R.animator.fade_in, R.animator.fade_out); } else { - final Intent intent = new Intent(getApplicationContext(), ManageAccountActivity.class); - startActivity(intent); + AccountUtils.launchManageAccounts(this); overridePendingTransition(R.animator.fade_in, R.animator.fade_out); } break; diff --git a/src/main/java/de/pixart/messenger/utils/AccountUtils.java b/src/main/java/de/pixart/messenger/utils/AccountUtils.java new file mode 100644 index 000000000..430ebb573 --- /dev/null +++ b/src/main/java/de/pixart/messenger/utils/AccountUtils.java @@ -0,0 +1,59 @@ +package de.pixart.messenger.utils; + +import android.app.Activity; +import android.content.Intent; +import android.widget.Toast; + +import java.util.List; + +import de.pixart.messenger.R; +import de.pixart.messenger.entities.Account; +import de.pixart.messenger.services.XmppConnectionService; + +public class AccountUtils { + + public static final Class MANAGE_ACCOUNT_ACTIVITY; + + static { + MANAGE_ACCOUNT_ACTIVITY = getManageAccountActivityClass(); + } + + + public static Account getFirstEnabled(XmppConnectionService service) { + final List<Account> accounts = service.getAccounts(); + for (Account account : accounts) { + if (!account.isOptionSet(Account.OPTION_DISABLED)) { + return account; + } + } + return null; + } + + public static Account getPendingAccount(XmppConnectionService service) { + Account pending = null; + for (Account account : service.getAccounts()) { + if (!account.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY)) { + pending = account; + } else { + return null; + } + } + return pending; + } + + public static void launchManageAccounts(Activity activity) { + if (MANAGE_ACCOUNT_ACTIVITY != null) { + activity.startActivity(new Intent(activity, MANAGE_ACCOUNT_ACTIVITY)); + } else { + Toast.makeText(activity, R.string.feature_not_implemented, Toast.LENGTH_SHORT).show(); + } + } + + private static Class getManageAccountActivityClass() { + try { + return Class.forName("de.pixart.messenger.ui.ManageAccountActivity"); + } catch (ClassNotFoundException e) { + return null; + } + } +}
\ No newline at end of file diff --git a/src/main/java/de/pixart/messenger/utils/ExceptionHelper.java b/src/main/java/de/pixart/messenger/utils/ExceptionHelper.java index ff2614840..a95278723 100644 --- a/src/main/java/de/pixart/messenger/utils/ExceptionHelper.java +++ b/src/main/java/de/pixart/messenger/utils/ExceptionHelper.java @@ -26,6 +26,7 @@ import de.pixart.messenger.entities.Conversation; import de.pixart.messenger.entities.Message; import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.ui.XmppActivity; +import rocks.xmpp.addr.Jid; public class ExceptionHelper { private static final String FILENAME = "stacktrace.txt"; @@ -49,18 +50,10 @@ public class ExceptionHelper { if (!crashreport || Config.BUG_REPORTS == null) { return false; } - List<Account> accounts = service.getAccounts(); - Account account = null; - for (int i = 0; i < accounts.size(); ++i) { - if (accounts.get(i).isEnabled()) { - account = accounts.get(i); - break; - } - } + final Account account = AccountUtils.getFirstEnabled(service); if (account == null) { return false; } - final Account finalAccount = account; FileInputStream file = activity.openFileInput(FILENAME); InputStreamReader inputStreamReader = new InputStreamReader(file); BufferedReader stacktrace = new BufferedReader(inputStreamReader); @@ -91,8 +84,8 @@ public class ExceptionHelper { builder.setTitle(activity.getString(R.string.crash_report_title)); builder.setMessage(activity.getText(R.string.crash_report_message)); builder.setPositiveButton(activity.getText(R.string.send_now), (dialog, which) -> { - Log.d(Config.LOGTAG, "using account=" + finalAccount.getJid().asBareJid() + " to send in stack trace"); - Conversation conversation = service.findOrCreateConversation(finalAccount, Config.BUG_REPORTS, false, true); + Log.d(Config.LOGTAG, "using account=" + account.getJid().asBareJid() + " to send in stack trace"); + Conversation conversation = service.findOrCreateConversation(account, Config.BUG_REPORTS, false, true); Message message = new Message(conversation, report.toString(), Message.ENCRYPTION_NONE); service.sendMessage(message); }); diff --git a/src/main/java/de/pixart/messenger/utils/SignupUtils.java b/src/main/java/de/pixart/messenger/utils/SignupUtils.java new file mode 100644 index 000000000..81959c929 --- /dev/null +++ b/src/main/java/de/pixart/messenger/utils/SignupUtils.java @@ -0,0 +1,47 @@ +package de.pixart.messenger.utils; + +import android.app.Activity; +import android.content.Intent; + +import de.pixart.messenger.Config; +import de.pixart.messenger.entities.Account; +import de.pixart.messenger.services.XmppConnectionService; +import de.pixart.messenger.ui.ConversationsActivity; +import de.pixart.messenger.ui.EditAccountActivity; +import de.pixart.messenger.ui.ManageAccountActivity; +import de.pixart.messenger.ui.StartConversationActivity; +import de.pixart.messenger.ui.WelcomeActivity; + +public class SignupUtils { + + public static Intent getSignUpIntent(final Activity activity) { + Intent intent = new Intent(activity, WelcomeActivity.class); + StartConversationActivity.addInviteUri(intent, activity.getIntent()); + return intent; + } + + public static Intent getRedirectionIntent(final ConversationsActivity activity) { + final XmppConnectionService service = activity.xmppConnectionService; + Account pendingAccount = AccountUtils.getPendingAccount(service); + Intent intent; + if (pendingAccount != null) { + intent = new Intent(activity, EditAccountActivity.class); + intent.putExtra("jid", pendingAccount.getJid().asBareJid().toString()); + } else { + if (service.getAccounts().size() == 0) { + if (Config.X509_VERIFICATION) { + intent = new Intent(activity, ManageAccountActivity.class); + } else if (Config.MAGIC_CREATE_DOMAIN != null) { + intent = getSignUpIntent(activity); + } else { + intent = new Intent(activity, EditAccountActivity.class); + } + } else { + intent = new Intent(activity, StartConversationActivity.class); + } + } + intent.putExtra("init", true); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + return intent; + } +}
\ No newline at end of file diff --git a/src/main/java/de/pixart/messenger/utils/XmppUri.java b/src/main/java/de/pixart/messenger/utils/XmppUri.java index a44c9a174..9c0b3e666 100644 --- a/src/main/java/de/pixart/messenger/utils/XmppUri.java +++ b/src/main/java/de/pixart/messenger/utils/XmppUri.java @@ -184,7 +184,7 @@ public class XmppUri { public Jid getJid() { try { - return this.jid == null ? null : Jid.of(this.jid.toLowerCase()); + return this.jid == null ? null : Jid.of(this.jid); } catch (IllegalArgumentException e) { return null; } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 369395d30..215483b8b 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -839,5 +839,6 @@ <string name="server_info_available_with">yes, %s</string> <string name="delete_message_dialog">Delete message</string> <string name="delete_message_dialog_msg">Are you sure you want to delete this message?\n\n<b>Warning:</b> This will not delete copies of this message that are stored on other devices or servers.</string> + <string name="feature_not_implemented">Feature not implemented</string> </resources> |