mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
fix: fixing the message dismissal of notifications for threads upon activity resume. using media send activity's camera intent for consistency
This commit is contained in:
parent
18c177971a
commit
dbec5ad53c
@ -241,7 +241,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
searchBottomBar.setEventListener(this)
|
searchBottomBar.setEventListener(this)
|
||||||
setUpSearchResultObserver()
|
setUpSearchResultObserver()
|
||||||
scrollToFirstUnreadMessageIfNeeded()
|
scrollToFirstUnreadMessageIfNeeded()
|
||||||
markAllAsRead()
|
|
||||||
showOrHideInputIfNeeded()
|
showOrHideInputIfNeeded()
|
||||||
if (this.thread.isOpenGroupRecipient) {
|
if (this.thread.isOpenGroupRecipient) {
|
||||||
val openGroup = DatabaseFactory.getLokiThreadDatabase(this).getOpenGroupChat(threadID)
|
val openGroup = DatabaseFactory.getLokiThreadDatabase(this).getOpenGroupChat(threadID)
|
||||||
@ -255,6 +254,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
ApplicationContext.getInstance(this).messageNotifier.setVisibleThread(threadID)
|
ApplicationContext.getInstance(this).messageNotifier.setVisibleThread(threadID)
|
||||||
|
markAllAsRead()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
@ -498,7 +498,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
} else {
|
} else {
|
||||||
MarkReadReceiver.process(this, messages)
|
MarkReadReceiver.process(this, messages)
|
||||||
}
|
}
|
||||||
ApplicationContext.getInstance(this).messageNotifier.updateNotification(this, threadID)
|
ApplicationContext.getInstance(this).messageNotifier.updateNotification(this, false, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun inputBarHeightChanged(newValue: Int) {
|
override fun inputBarHeightChanged(newValue: Int) {
|
||||||
@ -977,7 +977,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun showCamera() {
|
private fun showCamera() {
|
||||||
attachmentManager.capturePhoto(this, ConversationActivityV2.TAKE_PHOTO)
|
attachmentManager.capturePhoto(this, ConversationActivityV2.TAKE_PHOTO, thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttachmentChanged() {
|
override fun onAttachmentChanged() {
|
||||||
@ -1006,11 +1006,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
val uri = intent?.data ?: return
|
val uri = intent?.data ?: return
|
||||||
prepMediaForSending(uri, AttachmentManager.MediaType.DOCUMENT).addListener(mediaPreppedListener)
|
prepMediaForSending(uri, AttachmentManager.MediaType.DOCUMENT).addListener(mediaPreppedListener)
|
||||||
}
|
}
|
||||||
TAKE_PHOTO -> {
|
|
||||||
if (resultCode != RESULT_OK) { return }
|
|
||||||
val uri = attachmentManager.captureUri ?: return
|
|
||||||
prepMediaForSending(uri, AttachmentManager.MediaType.IMAGE).addListener(mediaPreppedListener)
|
|
||||||
}
|
|
||||||
PICK_GIF -> {
|
PICK_GIF -> {
|
||||||
intent ?: return
|
intent ?: return
|
||||||
val uri = intent.data ?: return
|
val uri = intent.data ?: return
|
||||||
@ -1019,7 +1014,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
val height = intent.getIntExtra(GiphyActivity.EXTRA_HEIGHT, 0)
|
val height = intent.getIntExtra(GiphyActivity.EXTRA_HEIGHT, 0)
|
||||||
prepMediaForSending(uri, type, width, height).addListener(mediaPreppedListener)
|
prepMediaForSending(uri, type, width, height).addListener(mediaPreppedListener)
|
||||||
}
|
}
|
||||||
PICK_FROM_LIBRARY -> {
|
PICK_FROM_LIBRARY,
|
||||||
|
TAKE_PHOTO -> {
|
||||||
intent ?: return
|
intent ?: return
|
||||||
val body = intent.getStringExtra(MediaSendActivity.EXTRA_MESSAGE)
|
val body = intent.getStringExtra(MediaSendActivity.EXTRA_MESSAGE)
|
||||||
val media = intent.getParcelableArrayListExtra<Media>(MediaSendActivity.EXTRA_MEDIA) ?: return
|
val media = intent.getParcelableArrayListExtra<Media>(MediaSendActivity.EXTRA_MEDIA) ?: return
|
||||||
|
@ -25,7 +25,6 @@ import android.content.Intent;
|
|||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.provider.OpenableColumns;
|
import android.provider.OpenableColumns;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
@ -34,9 +33,12 @@ import android.widget.Toast;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.session.libsignal.utilities.NoExternalStorageException;
|
import org.session.libsession.utilities.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.giph.ui.GiphyActivity;
|
import org.session.libsignal.utilities.ListenableFuture;
|
||||||
import org.session.libsignal.utilities.Log;
|
import org.session.libsignal.utilities.Log;
|
||||||
|
import org.session.libsignal.utilities.SettableFuture;
|
||||||
|
import org.session.libsignal.utilities.guava.Optional;
|
||||||
|
import org.thoughtcrime.securesms.giph.ui.GiphyActivity;
|
||||||
import org.thoughtcrime.securesms.mediasend.MediaSendActivity;
|
import org.thoughtcrime.securesms.mediasend.MediaSendActivity;
|
||||||
import org.thoughtcrime.securesms.mms.AudioSlide;
|
import org.thoughtcrime.securesms.mms.AudioSlide;
|
||||||
import org.thoughtcrime.securesms.mms.DocumentSlide;
|
import org.thoughtcrime.securesms.mms.DocumentSlide;
|
||||||
@ -50,16 +52,8 @@ import org.thoughtcrime.securesms.mms.SlideDeck;
|
|||||||
import org.thoughtcrime.securesms.mms.VideoSlide;
|
import org.thoughtcrime.securesms.mms.VideoSlide;
|
||||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||||
import org.session.libsignal.utilities.ExternalStorageUtil;
|
|
||||||
import org.thoughtcrime.securesms.util.FileProviderUtil;
|
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
import org.session.libsignal.utilities.guava.Optional;
|
|
||||||
|
|
||||||
import org.session.libsession.utilities.recipients.Recipient;
|
|
||||||
import org.session.libsignal.utilities.ListenableFuture;
|
|
||||||
import org.session.libsignal.utilities.SettableFuture;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -67,8 +61,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import network.loki.messenger.R;
|
import network.loki.messenger.R;
|
||||||
|
|
||||||
import static android.provider.MediaStore.EXTRA_OUTPUT;
|
|
||||||
|
|
||||||
public class AttachmentManager {
|
public class AttachmentManager {
|
||||||
|
|
||||||
private final static String TAG = AttachmentManager.class.getSimpleName();
|
private final static String TAG = AttachmentManager.class.getSimpleName();
|
||||||
@ -278,25 +270,15 @@ public class AttachmentManager {
|
|||||||
return captureUri;
|
return captureUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void capturePhoto(Activity activity, int requestCode) {
|
public void capturePhoto(Activity activity, int requestCode, Recipient recipient) {
|
||||||
Permissions.with(activity)
|
Permissions.with(activity)
|
||||||
.request(Manifest.permission.CAMERA)
|
.request(Manifest.permission.CAMERA)
|
||||||
.withPermanentDenialDialog(activity.getString(R.string.AttachmentManager_signal_requires_the_camera_permission_in_order_to_take_photos_but_it_has_been_permanently_denied))
|
.withPermanentDenialDialog(activity.getString(R.string.AttachmentManager_signal_requires_the_camera_permission_in_order_to_take_photos_but_it_has_been_permanently_denied))
|
||||||
.withRationaleDialog(activity.getString(R.string.ConversationActivity_to_capture_photos_and_video_allow_signal_access_to_the_camera),R.drawable.ic_baseline_photo_camera_24)
|
.withRationaleDialog(activity.getString(R.string.ConversationActivity_to_capture_photos_and_video_allow_signal_access_to_the_camera),R.drawable.ic_baseline_photo_camera_24)
|
||||||
.onAllGranted(() -> {
|
.onAllGranted(() -> {
|
||||||
try {
|
Intent captureIntent = MediaSendActivity.buildCameraIntent(activity, recipient);
|
||||||
File captureFile = File.createTempFile("conversation-capture", ".jpg", ExternalStorageUtil.getImageDir(activity));
|
if (captureIntent.resolveActivity(activity.getPackageManager()) != null) {
|
||||||
Uri captureUri = FileProviderUtil.getUriFor(context, captureFile);
|
activity.startActivityForResult(captureIntent, requestCode);
|
||||||
Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
|
||||||
captureIntent.putExtra(EXTRA_OUTPUT, captureUri);
|
|
||||||
captureIntent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
|
||||||
if (captureIntent.resolveActivity(activity.getPackageManager()) != null) {
|
|
||||||
Log.d(TAG, "captureUri path is " + captureUri.getPath());
|
|
||||||
this.captureUri = captureUri;
|
|
||||||
activity.startActivityForResult(captureIntent, requestCode);
|
|
||||||
}
|
|
||||||
} catch (IOException | NoExternalStorageException e) {
|
|
||||||
throw new RuntimeException("Error creating image capture intent.", e);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.execute();
|
.execute();
|
||||||
|
@ -20,19 +20,18 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
import org.session.libsession.utilities.Address;
|
||||||
import org.session.libsession.utilities.MediaTypes;
|
import org.session.libsession.utilities.MediaTypes;
|
||||||
|
import org.session.libsession.utilities.Util;
|
||||||
|
import org.session.libsession.utilities.concurrent.SimpleTask;
|
||||||
|
import org.session.libsession.utilities.recipients.Recipient;
|
||||||
|
import org.session.libsignal.utilities.Log;
|
||||||
import org.session.libsignal.utilities.guava.Optional;
|
import org.session.libsignal.utilities.guava.Optional;
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
|
||||||
import org.session.libsignal.utilities.Log;
|
|
||||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||||
import org.thoughtcrime.securesms.scribbles.ImageEditorFragment;
|
import org.thoughtcrime.securesms.scribbles.ImageEditorFragment;
|
||||||
|
|
||||||
import org.session.libsession.utilities.Address;
|
|
||||||
import org.session.libsession.utilities.recipients.Recipient;
|
|
||||||
import org.session.libsession.utilities.concurrent.SimpleTask;
|
|
||||||
import org.session.libsession.utilities.Util;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -87,7 +86,7 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an intent to launch the media send flow starting with the picker.
|
* Get an intent to launch the media send flow starting with the camera.
|
||||||
*/
|
*/
|
||||||
public static Intent buildCameraIntent(@NonNull Context context, @NonNull Recipient recipient) {
|
public static Intent buildCameraIntent(@NonNull Context context, @NonNull Recipient recipient) {
|
||||||
Intent intent = buildGalleryIntent(context, recipient, "");
|
Intent intent = buildGalleryIntent(context, recipient, "");
|
||||||
|
@ -90,8 +90,9 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
|||||||
|
|
||||||
private static final String TAG = DefaultMessageNotifier.class.getSimpleName();
|
private static final String TAG = DefaultMessageNotifier.class.getSimpleName();
|
||||||
|
|
||||||
public static final String EXTRA_REMOTE_REPLY = "extra_remote_reply";
|
public static final String EXTRA_REMOTE_REPLY = "extra_remote_reply";
|
||||||
public static final String LATEST_MESSAGE_ID_TAG = "extra_latest_message_id";
|
public static final String LATEST_MESSAGE_ID_TAG = "extra_latest_message_id";
|
||||||
|
public static final String EXTRA_THREAD_ID = "extra_thread_id";
|
||||||
|
|
||||||
private static final int FOREGROUND_ID = 313399;
|
private static final int FOREGROUND_ID = 313399;
|
||||||
private static final int SUMMARY_NOTIFICATION_ID = 1338;
|
private static final int SUMMARY_NOTIFICATION_ID = 1338;
|
||||||
|
@ -380,7 +380,7 @@ object TextSecurePreferences {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun isInThreadNotifications(context: Context): Boolean {
|
fun isInThreadNotifications(context: Context): Boolean {
|
||||||
return getBooleanPreference(context, IN_THREAD_NOTIFICATION_PREF, true)
|
return getBooleanPreference(context, IN_THREAD_NOTIFICATION_PREF, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
Loading…
x
Reference in New Issue
Block a user