From c0744d4280d9730b4a09fa7eeb351e961776bc87 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Mon, 8 Jul 2019 15:51:50 +0200 Subject: [PATCH] remove quick reply fallback #983 --- AndroidManifest.xml | 8 -- .../securesms/ConversationPopupActivity.java | 118 ------------------ .../notifications/MessageNotifier.java | 1 - .../notifications/NotificationState.java | 12 -- .../SingleRecipientNotificationBuilder.java | 12 +- 5 files changed, 3 insertions(+), 148 deletions(-) delete mode 100644 src/org/thoughtcrime/securesms/ConversationPopupActivity.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 42c7e8cfd..4c61dae1e 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -141,14 +141,6 @@ android:value="org.thoughtcrime.securesms.ConversationListActivity" /> - - diff --git a/src/org/thoughtcrime/securesms/ConversationPopupActivity.java b/src/org/thoughtcrime/securesms/ConversationPopupActivity.java deleted file mode 100644 index 7f1dca070..000000000 --- a/src/org/thoughtcrime/securesms/ConversationPopupActivity.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.thoughtcrime.securesms; - -import android.content.Intent; -import android.os.Build.VERSION; -import android.os.Build.VERSION_CODES; -import android.os.Bundle; -import android.support.v4.app.ActivityOptionsCompat; -import android.util.Log; -import android.view.Display; -import android.view.Gravity; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.WindowManager; - -import org.thoughtcrime.securesms.util.concurrent.ListenableFuture; - -import java.util.concurrent.ExecutionException; - -public class ConversationPopupActivity extends ConversationActivity { - - private static final String TAG = ConversationPopupActivity.class.getSimpleName(); - - @Override - protected void onPreCreate() { - super.onPreCreate(); - overridePendingTransition(R.anim.slide_from_top, R.anim.slide_to_top); - } - - @Override - protected void onCreate(Bundle bundle, boolean ready) { - getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, - WindowManager.LayoutParams.FLAG_DIM_BEHIND); - - WindowManager.LayoutParams params = getWindow().getAttributes(); - params.alpha = 1.0f; - params.dimAmount = 0.1f; - params.gravity = Gravity.TOP; - getWindow().setAttributes(params); - - Display display = getWindowManager().getDefaultDisplay(); - int width = display.getWidth(); - int height = display.getHeight(); - - if (height > width) getWindow().setLayout((int) (width * .85), (int) (height * .5)); - else getWindow().setLayout((int) (width * .7), (int) (height * .75)); - - super.onCreate(bundle, ready); - - titleView.setOnClickListener(null); - } - - @Override - protected void onResume() { - super.onResume(); - composeText.requestFocus(); - quickAttachmentToggle.disable(); - } - - @Override - protected void onPause() { - super.onPause(); - if (isFinishing()) overridePendingTransition(R.anim.slide_from_top, R.anim.slide_to_top); - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - MenuInflater inflater = this.getMenuInflater(); - menu.clear(); - - inflater.inflate(R.menu.conversation_popup, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_expand: - processComposeControls(ACTION_SAVE_DRAFT).addListener(new ListenableFuture.Listener() { - @Override - public void onSuccess(Integer result) { - ActivityOptionsCompat transition = ActivityOptionsCompat.makeScaleUpAnimation(getWindow().getDecorView(), 0, 0, getWindow().getAttributes().width, getWindow().getAttributes().height); - Intent intent = new Intent(ConversationPopupActivity.this, ConversationActivity.class); - intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, result); - - if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { - startActivity(intent, transition.toBundle()); - } else { - startActivity(intent); - overridePendingTransition(R.anim.fade_scale_in, R.anim.slide_to_right); - } - - finish(); - } - - @Override - public void onFailure(ExecutionException e) { - Log.w(TAG, e); - } - }); - return true; - } - - return false; - } - - @Override - protected void initializeActionBar() { - super.initializeActionBar(); - getSupportActionBar().setDisplayHomeAsUpEnabled(false); - } - - @Override - protected void sendComplete(int chatId) { - super.sendComplete(chatId); - finish(); - } -} diff --git a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java index c5acc1ad8..598077491 100644 --- a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java +++ b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java @@ -253,7 +253,6 @@ abstract class MessageNotifier { if (timestamp != 0) builder.setWhen(timestamp); builder.addActions(notificationState.getMarkAsReadIntent(context, chatId, notificationId), - notificationState.getQuickReplyIntent(context, recipient), notificationState.getRemoteReplyIntent(context, recipient)); ListIterator iterator = notifications.listIterator(notifications.size()); diff --git a/src/org/thoughtcrime/securesms/notifications/NotificationState.java b/src/org/thoughtcrime/securesms/notifications/NotificationState.java index be227219f..e49c350e6 100644 --- a/src/org/thoughtcrime/securesms/notifications/NotificationState.java +++ b/src/org/thoughtcrime/securesms/notifications/NotificationState.java @@ -8,8 +8,6 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.Log; -import org.thoughtcrime.securesms.ConversationActivity; -import org.thoughtcrime.securesms.ConversationPopupActivity; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.util.Prefs; import org.thoughtcrime.securesms.util.Prefs.VibrateState; @@ -154,15 +152,5 @@ public class NotificationState { return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); } - PendingIntent getQuickReplyIntent(Context context, Recipient recipient) { - if (chats.size() != 1) throw new AssertionError("We only support replies to single chat notifications! " + chats.size()); - - Intent intent = new Intent(context, ConversationPopupActivity.class); - intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, (chats.toArray(new Integer[chats.size()]))[0]); - intent.setData((Uri.parse("custom://"+System.currentTimeMillis()))); - - return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); - } - } diff --git a/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java b/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java index 05e7125b5..767dbd588 100644 --- a/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java +++ b/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java @@ -115,25 +115,20 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil } void addActions(@NonNull PendingIntent markReadIntent, - @NonNull PendingIntent compatInNotificationReplyIntent, @NonNull PendingIntent inNotificationReplyIntent) { Action markAsReadAction = new Action(R.drawable.check, context.getString(R.string.notify_mark_read), markReadIntent); - Action replyAction; - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { - replyAction = new Action(R.drawable.ic_reply_white_36dp, - context.getString(R.string.notify_reply_button), - compatInNotificationReplyIntent); - } else { - replyAction = new Action.Builder(R.drawable.ic_reply_white_36dp, + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + Action replyAction = new Action.Builder(R.drawable.ic_reply_white_36dp, context.getString(R.string.notify_reply_button), inNotificationReplyIntent) .addRemoteInput(new RemoteInput.Builder(MessageNotifierCompat.EXTRA_REMOTE_REPLY) .setLabel(context.getString(R.string.notify_reply_button)).build()) .build(); + addAction(replyAction); } Action wearableReplyAction = new Action.Builder(R.drawable.ic_reply, @@ -144,7 +139,6 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil .build(); addAction(markAsReadAction); - addAction(replyAction); extend(new NotificationCompat.WearableExtender().addAction(markAsReadAction) .addAction(wearableReplyAction));