mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Merge pull request #657 from hjubb/prevent_notifications_on_home
Don't Show Notifications Banners on Home Screen
This commit is contained in:
commit
9c60c2133c
@ -159,6 +159,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
ApplicationContext.getInstance(this).messageNotifier.setHomeScreenVisible(true)
|
||||
if (TextSecurePreferences.getLocalNumber(this) == null) { return; } // This can be the case after a secondary device is auto-cleared
|
||||
IdentityKeyUtil.checkUpdate(this)
|
||||
profileButton.recycle() // clear cached image before update tje profilePictureView
|
||||
@ -174,6 +175,11 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
ApplicationContext.getInstance(this).messageNotifier.setHomeScreenVisible(false)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == CreateClosedGroupActivity.closedGroupCreatedResultCode) {
|
||||
|
@ -96,6 +96,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
private static final long DESKTOP_ACTIVITY_PERIOD = TimeUnit.MINUTES.toMillis(1);
|
||||
|
||||
private volatile static long visibleThread = -1;
|
||||
private volatile static boolean homeScreenVisible = false;
|
||||
private volatile static long lastDesktopActivityTimestamp = -1;
|
||||
private volatile static long lastAudibleNotification = -1;
|
||||
private static final CancelableExecutor executor = new CancelableExecutor();
|
||||
@ -105,6 +106,11 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
visibleThread = threadId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHomeScreenVisible(boolean isVisible) {
|
||||
homeScreenVisible = isVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastDesktopActivityTimestamp(long timestamp) {
|
||||
lastDesktopActivityTimestamp = timestamp;
|
||||
@ -234,7 +240,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
|
||||
if (isVisible) {
|
||||
sendInThreadNotification(context, threads.getRecipientForThreadId(threadId));
|
||||
} else {
|
||||
} else if (!homeScreenVisible) {
|
||||
updateNotification(context, signal, 0);
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,11 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
@Override
|
||||
public void setVisibleThread(long threadId) { wrapped.setVisibleThread(threadId); }
|
||||
|
||||
@Override
|
||||
public void setHomeScreenVisible(boolean isVisible) {
|
||||
wrapped.setHomeScreenVisible(isVisible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastDesktopActivityTimestamp(long timestamp) { wrapped.setLastDesktopActivityTimestamp(timestamp);}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
|
||||
interface MessageNotifier {
|
||||
fun setHomeScreenVisible(isVisible: Boolean)
|
||||
fun setVisibleThread(threadId: Long)
|
||||
fun setLastDesktopActivityTimestamp(timestamp: Long)
|
||||
fun notifyMessageDeliveryFailed(context: Context?, recipient: Recipient?, threadId: Long)
|
||||
|
Loading…
x
Reference in New Issue
Block a user