@ -492,17 +492,15 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
sessionDialog {
title ( R . string . RecipientPreferenceActivity _block _this _contact _question )
text ( R . string . RecipientPreferenceActivity _you _will _no _longer _receive _messages _and _calls _from _this _contact )
buttons {
button ( R . string . RecipientPreferenceActivity _block ) {
lifecycleScope . launch ( Dispatchers . IO ) {
recipientDatabase . setBlocked ( thread . recipient , true )
withContext ( Dispatchers . Main ) {
binding . recyclerView . adapter ?. notifyDataSetChanged ( )
}
button ( R . string . RecipientPreferenceActivity _block ) {
lifecycleScope . launch ( Dispatchers . IO ) {
recipientDatabase . setBlocked ( thread . recipient , true )
withContext ( Dispatchers . Main ) {
binding . recyclerView . adapter ?. notifyDataSetChanged ( )
}
}
cancelButton ( )
}
cancelButton ( )
}
}
@ -510,17 +508,15 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
sessionDialog {
title ( R . string . RecipientPreferenceActivity _unblock _this _contact _question )
text ( R . string . RecipientPreferenceActivity _you _will _once _again _be _able _to _receive _messages _and _calls _from _this _contact )
buttons {
button ( R . string . RecipientPreferenceActivity _unblock ) {
lifecycleScope . launch ( Dispatchers . IO ) {
recipientDatabase . setBlocked ( thread . recipient , false )
withContext ( Dispatchers . Main ) {
binding . recyclerView . adapter ?. notifyDataSetChanged ( )
}
button ( R . string . RecipientPreferenceActivity _unblock ) {
lifecycleScope . launch ( Dispatchers . IO ) {
recipientDatabase . setBlocked ( thread . recipient , false )
withContext ( Dispatchers . Main ) {
binding . recyclerView . adapter ?. notifyDataSetChanged ( )
}
}
cancelButton ( )
}
cancelButton ( )
}
}
@ -582,60 +578,58 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
sessionDialog {
text ( message )
buttons {
button ( R . string . yes ) {
lifecycleScope . launch ( Dispatchers . Main ) {
val context = this @HomeActivity as Context
// Cancel any outstanding jobs
DatabaseComponent . get ( context ) . sessionJobDatabase ( )
. cancelPendingMessageSendJobs ( threadID )
// Send a leave group message if this is an active closed group
if ( recipient . address . isClosedGroup && DatabaseComponent . get ( context )
. groupDatabase ( ) . isActive ( recipient . address . toGroupString ( ) )
) {
var isClosedGroup : Boolean
var groupPublicKey : String ?
try {
groupPublicKey =
GroupUtil . doubleDecodeGroupID ( recipient . address . toString ( ) )
. toHexString ( )
isClosedGroup = DatabaseComponent . get ( context ) . lokiAPIDatabase ( )
. isClosedGroup ( groupPublicKey )
} catch ( e : IOException ) {
groupPublicKey = null
isClosedGroup = false
}
if ( isClosedGroup ) {
MessageSender . explicitLeave ( groupPublicKey !! , false )
}
button ( R . string . yes ) {
lifecycleScope . launch ( Dispatchers . Main ) {
val context = this @HomeActivity as Context
// Cancel any outstanding jobs
DatabaseComponent . get ( context ) . sessionJobDatabase ( )
. cancelPendingMessageSendJobs ( threadID )
// Send a leave group message if this is an active closed group
if ( recipient . address . isClosedGroup && DatabaseComponent . get ( context )
. groupDatabase ( ) . isActive ( recipient . address . toGroupString ( ) )
) {
var isClosedGroup : Boolean
var groupPublicKey : String ?
try {
groupPublicKey =
GroupUtil . doubleDecodeGroupID ( recipient . address . toString ( ) )
. toHexString ( )
isClosedGroup = DatabaseComponent . get ( context ) . lokiAPIDatabase ( )
. isClosedGroup ( groupPublicKey )
} catch ( e : IOException ) {
groupPublicKey = null
isClosedGroup = false
}
// Delete the conversation
val v2OpenGroup =
DatabaseComponent . get ( this @HomeActivity ) . lokiThreadDatabase ( )
. getOpenGroupChat ( threadID )
if ( v2OpenGroup != null ) {
OpenGroupManager . delete (
v2OpenGroup . server ,
v2OpenGroup . room ,
this @HomeActivity
)
} else {
lifecycleScope . launch ( Dispatchers . IO ) {
threadDb . deleteConversation ( threadID )
}
if ( isClosedGroup ) {
MessageSender . explicitLeave ( groupPublicKey !! , false )
}
// Update the badge count
ApplicationContext . getInstance ( context ) . messageNotifier . updateNotification (
context
}
// Delete the conversation
val v2OpenGroup =
DatabaseComponent . get ( this @HomeActivity ) . lokiThreadDatabase ( )
. getOpenGroupChat ( threadID )
if ( v2OpenGroup != null ) {
OpenGroupManager . delete (
v2OpenGroup . server ,
v2OpenGroup . room ,
this @HomeActivity
)
// Notify the user
val toastMessage =
if ( recipient . isGroupRecipient ) R . string . MessageRecord _left _group else R . string . activity _home _conversation _deleted _message
Toast . makeText ( context , toastMessage , Toast . LENGTH _LONG ) . show ( )
} else {
lifecycleScope . launch ( Dispatchers . IO ) {
threadDb . deleteConversation ( threadID )
}
}
// Update the badge count
ApplicationContext . getInstance ( context ) . messageNotifier . updateNotification (
context
)
// Notify the user
val toastMessage =
if ( recipient . isGroupRecipient ) R . string . MessageRecord _left _group else R . string . activity _home _conversation _deleted _message
Toast . makeText ( context , toastMessage , Toast . LENGTH _LONG ) . show ( )
}
button ( R . string . no )
}
button ( R . string . no )
}
}
@ -651,14 +645,12 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
private fun hideMessageRequests ( ) {
sessionDialog {
text ( " Hide message requests? " )
buttons {
button ( R . string . yes ) {
textSecurePreferences . setHasHiddenMessageRequests ( )
setupMessageRequestsBanner ( )
homeViewModel . tryUpdateChannel ( )
}
button ( R . string . no )
button ( R . string . yes ) {
textSecurePreferences . setHasHiddenMessageRequests ( )
setupMessageRequestsBanner ( )
homeViewModel . tryUpdateChannel ( )
}
button ( R . string . no )
}
}