Skip to content

Commit

Permalink
v4.10
Browse files Browse the repository at this point in the history
  • Loading branch information
AndraxDev committed May 27, 2024
1 parent 03fb76a commit e643039
Show file tree
Hide file tree
Showing 18 changed files with 519 additions and 44 deletions.
8 changes: 8 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

211 changes: 211 additions & 0 deletions .idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ android {
}

debug {
debuggable true
minifyEnabled false
shrinkResources false
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
multiDexEnabled true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package org.teslasoft.assistant.ui.activities
import android.Manifest
import android.annotation.SuppressLint
import android.app.Activity
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
Expand Down Expand Up @@ -814,7 +816,6 @@ class ChatActivity : FragmentActivity(), ChatAdapter.OnUpdateListener {
btnVisionActionCamera = findViewById(R.id.action_camera)
btnVisionActionGallery = findViewById(R.id.action_gallery)
bulkContainer = findViewById(R.id.bulk_container)

btnSelectAll = findViewById(R.id.btn_select_all)
btnDeselectAll = findViewById(R.id.btn_deselect_all)
btnDeleteSelected = findViewById(R.id.btn_delete_selected)
Expand Down Expand Up @@ -854,6 +855,14 @@ class ChatActivity : FragmentActivity(), ChatAdapter.OnUpdateListener {
deleteSelectedMessages()
}

btnCopySelected?.setOnClickListener {
copySelectedMessages()
}

btnShareSelected?.setOnClickListener {
shareSelectedMessages()
}

btnExport?.background = getDarkAccentDrawable(
AppCompatResources.getDrawable(
this,
Expand Down Expand Up @@ -2895,4 +2904,36 @@ class ChatActivity : FragmentActivity(), ChatAdapter.OnUpdateListener {
.setNegativeButton("Cancel") { _, _ -> }
.show()
}

private fun copySelectedMessages() {
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip = ClipData.newPlainText("Copied messages", conversationToString())
clipboard.setPrimaryClip(clip)
Toast.makeText(this, "Messages copied to clipboard", Toast.LENGTH_SHORT).show()
}

private fun shareSelectedMessages() {
val intent = Intent(Intent.ACTION_SEND)
intent.type = "text/plain"
intent.putExtra(Intent.EXTRA_TEXT, conversationToString())
startActivity(Intent.createChooser(intent, "Share messages"))
}

private fun conversationToString() : String {
val stringBuilder = StringBuilder()

for (m in messagesSelectionProjection) {
if (m["selected"].toString() == "true") {
if (m["isBot"] == true) {
stringBuilder.append("[Bot] >\n")
} else {
stringBuilder.append("[User] >\n")
}
stringBuilder.append(m["message"])
stringBuilder.append("\n\n")
}
}

return stringBuilder.toString()
}
}
Loading

0 comments on commit e643039

Please sign in to comment.