Remove VerificationOnSendReceiver and related calls as not used anymore
With commit 9ea6e3de79bd7e14 we simplified the flow used to show "Verification Required" during the sending process, not using broadcasts anymore. This is not unused. MAILAND-914
This commit is contained in:
parent
cba04197fa
commit
37722077a1
|
@ -129,11 +129,6 @@
|
|||
<action android:name="protonmail_notif_action_trash" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".receivers.VerificationOnSendReceiver">
|
||||
<intent-filter android:priority="1">
|
||||
<action android:name="protonmail_notif_action_verify" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".receivers.TimeChangedReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.TIME_SET" />
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package ch.protonmail.android.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
|
@ -28,7 +27,6 @@ import android.graphics.Color;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -52,7 +50,6 @@ import javax.inject.Inject;
|
|||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.protonmail.android.R;
|
||||
import ch.protonmail.android.activities.composeMessage.ComposeMessageActivity;
|
||||
import ch.protonmail.android.activities.messageDetails.MessageDetailsActivity;
|
||||
import ch.protonmail.android.adapters.swipe.SwipeProcessor;
|
||||
import ch.protonmail.android.api.NetworkConfigurator;
|
||||
|
@ -65,7 +62,6 @@ import ch.protonmail.android.bl.HtmlDivHandler;
|
|||
import ch.protonmail.android.bl.HtmlProcessor;
|
||||
import ch.protonmail.android.bl.XHtmlHandler;
|
||||
import ch.protonmail.android.core.BigContentHolder;
|
||||
import ch.protonmail.android.core.Constants;
|
||||
import ch.protonmail.android.core.NetworkResults;
|
||||
import ch.protonmail.android.core.ProtonMailApplication;
|
||||
import ch.protonmail.android.core.QueueNetworkUtil;
|
||||
|
@ -86,9 +82,6 @@ import ch.protonmail.android.worker.FetchUserInfoWorker;
|
|||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static ch.protonmail.android.receivers.VerificationOnSendReceiver.EXTRA_MESSAGE_ADDRESS_ID;
|
||||
import static ch.protonmail.android.receivers.VerificationOnSendReceiver.EXTRA_MESSAGE_ID;
|
||||
import static ch.protonmail.android.receivers.VerificationOnSendReceiver.EXTRA_MESSAGE_INLINE;
|
||||
import static ch.protonmail.android.settings.pin.ValidatePinActivityKt.EXTRA_FRAGMENT_TITLE;
|
||||
import static ch.protonmail.android.settings.pin.ValidatePinActivityKt.EXTRA_LOGOUT;
|
||||
import static ch.protonmail.android.settings.pin.ValidatePinActivityKt.EXTRA_PIN_VALID;
|
||||
|
@ -455,46 +448,6 @@ public abstract class BaseActivity extends AppCompatActivity implements INetwork
|
|||
}
|
||||
}
|
||||
|
||||
protected final BroadcastReceiver humanVerificationBroadcastReceiver = new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, Intent intent) {
|
||||
Bundle extras = intent.getExtras();
|
||||
String errorText = getString(R.string.message_drafted);
|
||||
if (intent.hasExtra(Constants.ERROR)) {
|
||||
String extraText = intent.getStringExtra(Constants.ERROR);
|
||||
if (!TextUtils.isEmpty(extraText)) {
|
||||
errorText = extraText;
|
||||
}
|
||||
}
|
||||
final String messageId = extras.getString(EXTRA_MESSAGE_ID);
|
||||
final boolean messageInline = extras.getBoolean(EXTRA_MESSAGE_INLINE);
|
||||
final String messageAddressId = extras.getString(EXTRA_MESSAGE_ADDRESS_ID);
|
||||
|
||||
if (mConnectivitySnackLayout == null) {
|
||||
return;
|
||||
}
|
||||
mDraftedMessageSnack = Snackbar.make(mConnectivitySnackLayout, errorText, Snackbar.LENGTH_INDEFINITE);
|
||||
View view = mDraftedMessageSnack.getView();
|
||||
TextView tv = view.findViewById(com.google.android.material.R.id.snackbar_text);
|
||||
tv.setTextColor(Color.WHITE);
|
||||
mDraftedMessageSnack.setAction(getString(R.string.verify), v -> {
|
||||
mDraftedMessageSnack.dismiss();
|
||||
final Intent composeIntent = new Intent(BaseActivity.this, ComposeMessageActivity.class);
|
||||
composeIntent.putExtra(ComposeMessageActivity.EXTRA_MESSAGE_ID, messageId);
|
||||
composeIntent.putExtra(ComposeMessageActivity.EXTRA_MESSAGE_RESPONSE_INLINE, messageInline);
|
||||
composeIntent.putExtra(ComposeMessageActivity.EXTRA_MESSAGE_ADDRESS_ID, messageAddressId);
|
||||
composeIntent.putExtra(ComposeMessageActivity.EXTRA_VERIFY, true);
|
||||
startActivity(composeIntent);
|
||||
});
|
||||
mDraftedMessageSnack.setActionTextColor(getResources().getColor(R.color.icon_purple));
|
||||
mDraftedMessageSnack.show();
|
||||
|
||||
setResultCode(Activity.RESULT_OK);
|
||||
abortBroadcast();
|
||||
}
|
||||
};
|
||||
|
||||
@Subscribe
|
||||
public void onMessageSentEvent(MessageSentEvent event){
|
||||
switch (event.getStatus()) {
|
||||
|
|
|
@ -703,12 +703,6 @@ class MailboxActivity :
|
|||
LocalBroadcastManager.getInstance(this).registerReceiver(fcmBroadcastReceiver, filter)
|
||||
}
|
||||
|
||||
private fun registerHumanVerificationReceiver() {
|
||||
val filter = IntentFilter(getString(R.string.notification_action_verify))
|
||||
filter.priority = 10
|
||||
registerReceiver(humanVerificationBroadcastReceiver, filter)
|
||||
}
|
||||
|
||||
private fun onConnectivityCheckRetry() {
|
||||
mConnectivitySnackLayout?.let {
|
||||
networkSnackBarUtil.getCheckingConnectionSnackBar(it).show()
|
||||
|
@ -835,7 +829,6 @@ class MailboxActivity :
|
|||
}
|
||||
reloadMessageCounts()
|
||||
registerFcmReceiver()
|
||||
registerHumanVerificationReceiver()
|
||||
checkDelinquency()
|
||||
no_messages_layout.visibility = View.GONE
|
||||
mailboxViewModel.checkConnectivity()
|
||||
|
@ -859,7 +852,6 @@ class MailboxActivity :
|
|||
runCatching {
|
||||
LocalBroadcastManager.getInstance(this).unregisterReceiver(fcmBroadcastReceiver)
|
||||
unregisterReceiver(showDraftedSnackBroadcastReceiver)
|
||||
unregisterReceiver(humanVerificationBroadcastReceiver)
|
||||
}
|
||||
networkSnackBarUtil.hideAllSnackBars()
|
||||
super.onPause()
|
||||
|
|
|
@ -82,7 +82,6 @@ import ch.protonmail.android.events.MessageSentEvent;
|
|||
import ch.protonmail.android.events.ParentEvent;
|
||||
import ch.protonmail.android.jobs.Priority;
|
||||
import ch.protonmail.android.jobs.ProtonMailBaseJob;
|
||||
import ch.protonmail.android.receivers.VerificationOnSendReceiver;
|
||||
import ch.protonmail.android.utils.AppUtil;
|
||||
import ch.protonmail.android.utils.HTMLToMDConverter;
|
||||
import ch.protonmail.android.utils.Logger;
|
||||
|
@ -404,9 +403,9 @@ public class PostMessageJob extends ProtonMailBaseJob {
|
|||
builder.append("response SUCCESS response error ERROR_VERIFICATION_NEEDED \n");
|
||||
Intent verifyIntent = new Intent(getApplicationContext().getString(R.string.notification_action_verify));
|
||||
verifyIntent.putExtra(Constants.ERROR, getApplicationContext().getString(R.string.message_drafted_verification_needed));
|
||||
verifyIntent.putExtra(VerificationOnSendReceiver.EXTRA_MESSAGE_ID, message.getMessageId());
|
||||
verifyIntent.putExtra(VerificationOnSendReceiver.EXTRA_MESSAGE_INLINE, message.isInline());
|
||||
verifyIntent.putExtra(VerificationOnSendReceiver.EXTRA_MESSAGE_ADDRESS_ID, message.getAddressID());
|
||||
// verifyIntent.putExtra(VerificationOnSendReceiver.EXTRA_MESSAGE_ID, message.getMessageId());
|
||||
// verifyIntent.putExtra(VerificationOnSendReceiver.EXTRA_MESSAGE_INLINE, message.isInline());
|
||||
// verifyIntent.putExtra(VerificationOnSendReceiver.EXTRA_MESSAGE_ADDRESS_ID, message.getAddressID());
|
||||
ProtonMailApplication.getApplication().sendOrderedBroadcast(verifyIntent, null);
|
||||
} else {
|
||||
if (!BuildConfig.DEBUG) {
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* ProtonMail is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ProtonMail is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
package ch.protonmail.android.receivers;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import ch.protonmail.android.core.UserManager;
|
||||
import ch.protonmail.android.servers.notification.INotificationServer;
|
||||
import ch.protonmail.android.servers.notification.NotificationServer;
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
|
||||
/*
|
||||
* Created by dino on 12/25/16.
|
||||
*/
|
||||
|
||||
@AndroidEntryPoint
|
||||
public class VerificationOnSendReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String EXTRA_NOTIFICATION_MESSAGE_TITLE = "notification_message_title";
|
||||
public static final String EXTRA_MESSAGE_ID = "message_id";
|
||||
public static final String EXTRA_MESSAGE_INLINE = "message_inline";
|
||||
public static final String EXTRA_MESSAGE_ADDRESS_ID = "message_address_id";
|
||||
|
||||
@Inject
|
||||
UserManager mUserManager;
|
||||
|
||||
public VerificationOnSendReceiver() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras != null) {
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(
|
||||
Context.NOTIFICATION_SERVICE);
|
||||
INotificationServer notificationServer = new NotificationServer(context, notificationManager);
|
||||
String messageTitle = extras.getString(EXTRA_NOTIFICATION_MESSAGE_TITLE);
|
||||
String messageId = extras.getString(EXTRA_MESSAGE_ID);
|
||||
boolean messageInline = extras.getBoolean(EXTRA_MESSAGE_INLINE);
|
||||
String messageAddressId = extras.getString(EXTRA_MESSAGE_ADDRESS_ID);
|
||||
notificationServer.notifyVerificationNeeded( mUserManager.getUser(), messageTitle, messageId, messageInline, messageAddressId);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue