mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 02:55:23 +00:00
fix: fix the notifications and request at appropriate time
This commit is contained in:
parent
461669b7c2
commit
64fa5e297c
@ -29,6 +29,7 @@
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false" />
|
||||
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
@ -1,5 +1,7 @@
|
||||
package org.thoughtcrime.securesms.home
|
||||
|
||||
import android.Manifest
|
||||
import android.app.NotificationManager
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
@ -69,6 +71,7 @@ import org.thoughtcrime.securesms.mms.GlideApp
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
import org.thoughtcrime.securesms.onboarding.SeedActivity
|
||||
import org.thoughtcrime.securesms.onboarding.SeedReminderViewDelegate
|
||||
import org.thoughtcrime.securesms.permissions.Permissions
|
||||
import org.thoughtcrime.securesms.preferences.SettingsActivity
|
||||
import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities
|
||||
import org.thoughtcrime.securesms.util.DateUtils
|
||||
@ -87,6 +90,11 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
SeedReminderViewDelegate,
|
||||
GlobalSearchInputLayout.GlobalSearchInputLayoutListener {
|
||||
|
||||
companion object {
|
||||
const val FROM_ONBOARDING = "HomeActivity_FROM_ONBOARDING"
|
||||
}
|
||||
|
||||
|
||||
private lateinit var binding: ActivityHomeBinding
|
||||
private lateinit var glide: GlideRequests
|
||||
private var broadcastReceiver: BroadcastReceiver? = null
|
||||
@ -242,23 +250,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
.onEach(globalSearchViewModel::postQuery)
|
||||
.collect()
|
||||
}
|
||||
// launch(IO) {
|
||||
// val publicKey = TextSecurePreferences.getLocalNumber(this@HomeActivity) ?: return@launch
|
||||
// // do a expire
|
||||
// try {
|
||||
// val promise = SnodeAPI.alterTtl(
|
||||
// listOf(
|
||||
// "message hashes"
|
||||
// ),
|
||||
// some long in the future,
|
||||
// publicKey
|
||||
// )
|
||||
// val result = promise.get()
|
||||
// Log.d("TTL", "ttl result: $result")
|
||||
// } catch (e: Exception) {
|
||||
// Log.e("TTL", "Expiry didn't work", e)
|
||||
// }
|
||||
// }
|
||||
// Get group results and display them
|
||||
launch {
|
||||
globalSearchViewModel.result.collect { result ->
|
||||
@ -305,6 +296,14 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
}
|
||||
}
|
||||
EventBus.getDefault().register(this@HomeActivity)
|
||||
if (intent.hasExtra(FROM_ONBOARDING)
|
||||
&& intent.getBooleanExtra(FROM_ONBOARDING, false)
|
||||
&& !(getSystemService(NOTIFICATION_SERVICE) as NotificationManager).areNotificationsEnabled()
|
||||
) {
|
||||
Permissions.with(this)
|
||||
.request(Manifest.permission.POST_NOTIFICATIONS)
|
||||
.execute()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInputFocusChanged(hasFocus: Boolean) {
|
||||
|
@ -60,7 +60,6 @@ import org.thoughtcrime.securesms.conversation.v2.utilities.MentionManagerUtilit
|
||||
import org.thoughtcrime.securesms.conversation.v2.utilities.MentionUtilities;
|
||||
import org.thoughtcrime.securesms.crypto.KeyPairUtilities;
|
||||
import org.thoughtcrime.securesms.database.LokiThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||
import org.thoughtcrime.securesms.database.MmsSmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
@ -240,10 +239,6 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
!(recipient.isApproved() || threads.getLastSeenAndHasSent(threadId).second())) {
|
||||
TextSecurePreferences.removeHasHiddenMessageRequests(context);
|
||||
}
|
||||
// if (isVisible && recipient != null && threads.getMessageCount(threadId) > 0) {
|
||||
// List<MarkedMessageInfo> messageIds = threads.setRead(threadId, false);
|
||||
// if (SessionMetaProtocol.shouldSendReadReceipt(recipient)) { MarkReadReceiver.process(context, messageIds); }
|
||||
// }
|
||||
|
||||
if (!TextSecurePreferences.isNotificationsEnabled(context) ||
|
||||
(recipient != null && recipient.isMuted()))
|
||||
|
@ -163,6 +163,7 @@ class PNModeActivity : BaseActionBarActivity() {
|
||||
application.registerForFCMIfNeeded(true)
|
||||
val intent = Intent(this, HomeActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
intent.putExtra(HomeActivity.FROM_ONBOARDING, true)
|
||||
show(intent)
|
||||
}
|
||||
// endregion
|
||||
|
@ -1,12 +1,10 @@
|
||||
package org.thoughtcrime.securesms.util
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
import android.os.Build
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.app.NotificationCompat
|
||||
@ -32,15 +30,7 @@ class CallNotificationBuilder {
|
||||
@JvmStatic
|
||||
fun areNotificationsEnabled(context: Context): Boolean {
|
||||
val notificationManager = NotificationManagerCompat.from(context)
|
||||
return when {
|
||||
!notificationManager.areNotificationsEnabled() -> false
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O -> {
|
||||
notificationManager.notificationChannels.firstOrNull { channel ->
|
||||
channel.importance == NotificationManager.IMPORTANCE_NONE
|
||||
} == null
|
||||
}
|
||||
else -> true
|
||||
}
|
||||
return notificationManager.areNotificationsEnabled()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
@ -212,6 +212,7 @@ class BatchMessageReceiveJob(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (threadId == NO_THREAD_MAPPING) return@async
|
||||
// increment unreads, notify, and update thread
|
||||
// last seen will be the current last seen if not changed (re-computes the read counts for thread record)
|
||||
// might have been updated from a different thread at this point
|
||||
|
@ -2,7 +2,6 @@ package org.session.libsession.messaging.jobs
|
||||
|
||||
import network.loki.messenger.libsession_util.ConfigBase
|
||||
import network.loki.messenger.libsession_util.ConfigBase.Companion.protoKindFor
|
||||
import network.loki.messenger.libsession_util.UserGroupsConfig
|
||||
import nl.komponents.kovenant.functional.bind
|
||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||
import org.session.libsession.messaging.messages.Destination
|
||||
@ -109,7 +108,7 @@ data class ConfigurationSyncJob(val destination: Destination): Job {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val responseList = (rawResponses["results"] as List<RawResponse>)
|
||||
// we are always adding in deletions at the end
|
||||
val deletionResponse = if (toDeleteRequest != null) responseList.last() else null
|
||||
val deletionResponse = if (toDeleteRequest != null && responseList.isNotEmpty()) responseList.last() else null
|
||||
val deletedHashes = deletionResponse?.let {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
// get the sub-request body
|
||||
|
Loading…
Reference in New Issue
Block a user