mirror of
https://github.com/ChronosX88/Influence.git
synced 2024-11-23 10:02:18 +00:00
Added ability to copy message to clipboard
This commit is contained in:
parent
4839205cf4
commit
b82c4d0447
@ -103,6 +103,7 @@ interface CoreContracts {
|
|||||||
fun setAdapter(adapter: MessagesListAdapter<GenericMessage>)
|
fun setAdapter(adapter: MessagesListAdapter<GenericMessage>)
|
||||||
fun setUserStatus(status: String)
|
fun setUserStatus(status: String)
|
||||||
fun getActivityObject(): Activity
|
fun getActivityObject(): Activity
|
||||||
|
fun showToast(text: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----SettingsFragment-----
|
// -----SettingsFragment-----
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package io.github.chronosx88.influence.presenters
|
package io.github.chronosx88.influence.presenters
|
||||||
|
|
||||||
|
import android.content.ClipData
|
||||||
|
import android.content.ClipboardManager
|
||||||
|
import android.content.Context
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
@ -38,6 +41,7 @@ import java9.util.stream.StreamSupport
|
|||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
|
import org.jetbrains.anko.toast
|
||||||
import org.jivesoftware.smackx.forward.packet.Forwarded
|
import org.jivesoftware.smackx.forward.packet.Forwarded
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.Comparator
|
import kotlin.Comparator
|
||||||
@ -62,6 +66,12 @@ class ChatPresenter(private val view: CoreContracts.IChatViewContract, private v
|
|||||||
getUserStatus()
|
getUserStatus()
|
||||||
EventBus.getDefault().register(this)
|
EventBus.getDefault().register(this)
|
||||||
AppHelper.setCurrentChatActivity(chatID)
|
AppHelper.setCurrentChatActivity(chatID)
|
||||||
|
chatAdapter.setOnMessageLongClickListener {
|
||||||
|
val clipboard = AppHelper.getContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
val clip = ClipData.newPlainText(it.text, it.text)
|
||||||
|
clipboard.primaryClip = clip
|
||||||
|
view.showToast(AppHelper.getContext().getString(R.string.copied_to_clipboard))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sendMessage(text: String): Boolean {
|
override fun sendMessage(text: String): Boolean {
|
||||||
|
@ -37,6 +37,7 @@ import io.github.chronosx88.influence.contracts.CoreContracts
|
|||||||
import io.github.chronosx88.influence.models.GenericMessage
|
import io.github.chronosx88.influence.models.GenericMessage
|
||||||
import io.github.chronosx88.influence.presenters.ChatPresenter
|
import io.github.chronosx88.influence.presenters.ChatPresenter
|
||||||
import org.jetbrains.anko.find
|
import org.jetbrains.anko.find
|
||||||
|
import org.jetbrains.anko.toast
|
||||||
|
|
||||||
class ChatActivity : AppCompatActivity(), CoreContracts.IChatViewContract {
|
class ChatActivity : AppCompatActivity(), CoreContracts.IChatViewContract {
|
||||||
private var messageList: MessagesList? = null
|
private var messageList: MessagesList? = null
|
||||||
@ -127,4 +128,8 @@ class ChatActivity : AppCompatActivity(), CoreContracts.IChatViewContract {
|
|||||||
override fun getActivityObject(): Activity {
|
override fun getActivityObject(): Activity {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun showToast(text: String) {
|
||||||
|
toast(text)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,4 +29,5 @@
|
|||||||
<string name="clear_chat">Очистить чат</string>
|
<string name="clear_chat">Очистить чат</string>
|
||||||
<string name="notification_channel_name">Уведомления Influence</string>
|
<string name="notification_channel_name">Уведомления Influence</string>
|
||||||
<string name="notification_channel_desc">Уведомления чатов Influence</string>
|
<string name="notification_channel_desc">Уведомления чатов Influence</string>
|
||||||
|
<string name="copied_to_clipboard">Сообщение скопировано в буфер обмена</string>
|
||||||
</resources>
|
</resources>
|
@ -28,4 +28,5 @@
|
|||||||
<string name="clear_chat">Clear chat</string>
|
<string name="clear_chat">Clear chat</string>
|
||||||
<string name="notification_channel_name">Influence Notifications</string>
|
<string name="notification_channel_name">Influence Notifications</string>
|
||||||
<string name="notification_channel_desc">Influence chat notifications</string>
|
<string name="notification_channel_desc">Influence chat notifications</string>
|
||||||
|
<string name="copied_to_clipboard">Message is copied to clipboard</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user