Commit d5acac79 authored by Divyanshu Bhargava's avatar Divyanshu Bhargava

Fix Alert Dialog Button

parent b14a2117
package chat.rocket.android.chatroom.ui package chat.rocket.android.chatroom.ui
import android.app.Activity import android.app.Activity
import android.app.AlertDialog import androidx.appcompat.app.AlertDialog
import android.content.ClipData import android.content.ClipData
import android.content.ClipboardManager import android.content.ClipboardManager
import android.content.Context import android.content.Context
...@@ -200,7 +200,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR ...@@ -200,7 +200,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
private var verticalScrollOffset = AtomicInteger(0) private var verticalScrollOffset = AtomicInteger(0)
private val dialogView by lazy { View.inflate(context, R.layout.file_attachments_dialog, null) } private val dialogView by lazy { View.inflate(context, R.layout.file_attachments_dialog, null) }
internal val alertDialog by lazy { AlertDialog.Builder(activity).setView(dialogView).create() } internal val alertDialog by lazy { activity?.let { AlertDialog.Builder(it).setView(dialogView).create() } }
internal val imagePreview by lazy { dialogView.findViewById<ImageView>(R.id.image_preview) } internal val imagePreview by lazy { dialogView.findViewById<ImageView>(R.id.image_preview) }
internal val sendButton by lazy { dialogView.findViewById<android.widget.Button>(R.id.button_send) } internal val sendButton by lazy { dialogView.findViewById<android.widget.Button>(R.id.button_send) }
internal val cancelButton by lazy { dialogView.findViewById<android.widget.Button>(R.id.button_cancel) } internal val cancelButton by lazy { dialogView.findViewById<android.widget.Button>(R.id.button_cancel) }
......
...@@ -75,10 +75,10 @@ fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) { ...@@ -75,10 +75,10 @@ fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) {
(citation ?: "") + description.text.toString() (citation ?: "") + description.text.toString()
) )
} }
alertDialog.dismiss() alertDialog?.dismiss()
} }
cancelButton.setOnClickListener { alertDialog.dismiss() } cancelButton.setOnClickListener { alertDialog?.dismiss() }
alertDialog.show() alertDialog?.show()
} }
fun ChatRoomFragment.showDrawAttachmentDialog(byteArray: ByteArray) { fun ChatRoomFragment.showDrawAttachmentDialog(byteArray: ByteArray) {
...@@ -92,9 +92,9 @@ fun ChatRoomFragment.showDrawAttachmentDialog(byteArray: ByteArray) { ...@@ -92,9 +92,9 @@ fun ChatRoomFragment.showDrawAttachmentDialog(byteArray: ByteArray) {
byteArray, byteArray,
(citation ?: "") + description.text.toString() (citation ?: "") + description.text.toString()
) )
alertDialog.dismiss() alertDialog?.dismiss()
} }
cancelButton.setOnClickListener { alertDialog.dismiss() } cancelButton.setOnClickListener { alertDialog?.dismiss() }
alertDialog.show() alertDialog?.show()
} }
\ No newline at end of file
package chat.rocket.android.chatrooms.ui package chat.rocket.android.chatrooms.ui
import android.app.AlertDialog import androidx.appcompat.app.AlertDialog
import android.app.ProgressDialog import android.app.ProgressDialog
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
...@@ -236,14 +236,16 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView { ...@@ -236,14 +236,16 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
) )
} }
AlertDialog.Builder(context) context?.let {
.setTitle(R.string.dialog_sort_title) AlertDialog.Builder(it)
.setView(dialogLayout) .setTitle(R.string.dialog_sort_title)
.setPositiveButton(R.string.msg_sort) { dialog, _ -> .setView(dialogLayout)
invalidateQueryOnSearch() .setPositiveButton(R.string.msg_sort) { dialog, _ ->
updateSort() invalidateQueryOnSearch()
dialog.dismiss() updateSort()
}.show() dialog.dismiss()
}.show()
}
} }
} }
return super.onOptionsItemSelected(item) return super.onOptionsItemSelected(item)
......
...@@ -2,7 +2,7 @@ package chat.rocket.android.main.ui ...@@ -2,7 +2,7 @@ package chat.rocket.android.main.ui
import DrawableHelper import DrawableHelper
import android.app.Activity import android.app.Activity
import android.app.AlertDialog import androidx.appcompat.app.AlertDialog
import android.app.ProgressDialog import android.app.ProgressDialog
import android.os.Bundle import android.os.Bundle
import androidx.annotation.IdRes import androidx.annotation.IdRes
......
...@@ -2,7 +2,7 @@ package chat.rocket.android.profile.ui ...@@ -2,7 +2,7 @@ package chat.rocket.android.profile.ui
import DrawableHelper import DrawableHelper
import android.app.Activity import android.app.Activity
import android.app.AlertDialog import androidx.appcompat.app.AlertDialog
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap import android.graphics.Bitmap
import android.os.Build import android.os.Build
...@@ -296,14 +296,16 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback { ...@@ -296,14 +296,16 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
val passwordEditText = EditText(context) val passwordEditText = EditText(context)
passwordEditText.hint = getString(R.string.msg_password) passwordEditText.hint = getString(R.string.msg_password)
val builder = AlertDialog.Builder(context) context?.let {
builder.setTitle(R.string.title_are_you_sure) val builder = AlertDialog.Builder(it)
.setView(passwordEditText) builder.setTitle(R.string.title_are_you_sure)
.setPositiveButton(R.string.action_delete_account) { _, _ -> .setView(passwordEditText)
presenter.deleteAccount(passwordEditText.text.toString()) .setPositiveButton(R.string.action_delete_account) { _, _ ->
} presenter.deleteAccount(passwordEditText.text.toString())
.setNegativeButton(android.R.string.no) { dialog, _ -> dialog.cancel() } }
.create() .setNegativeButton(android.R.string.no) { dialog, _ -> dialog.cancel() }
.show() .create()
.show()
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment