mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
Merge pull request #3033 from nextcloud/enhancement/2931/CopyToClipboard
Add copy to clipboard action for translations
This commit is contained in:
commit
9eebdcc172
@ -21,6 +21,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.nextcloud.talk.translate
|
package com.nextcloud.talk.translate
|
||||||
|
|
||||||
|
import android.content.ClipData
|
||||||
|
import android.content.ClipboardManager
|
||||||
|
import android.content.Context
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.method.ScrollingMovementMethod
|
import android.text.method.ScrollingMovementMethod
|
||||||
@ -73,6 +76,7 @@ class TranslateActivity : BaseActivity() {
|
|||||||
setupSystemColors()
|
setupSystemColors()
|
||||||
setupTextViews()
|
setupTextViews()
|
||||||
setupSpinners()
|
setupSpinners()
|
||||||
|
setupCopyButton()
|
||||||
getLanguageOptions()
|
getLanguageOptions()
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
@ -94,6 +98,19 @@ class TranslateActivity : BaseActivity() {
|
|||||||
super.onSaveInstanceState(outState)
|
super.onSaveInstanceState(outState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupCopyButton() {
|
||||||
|
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.copyTranslatedMessage)
|
||||||
|
binding.copyTranslatedMessage.setOnClickListener {
|
||||||
|
val clipboardManager =
|
||||||
|
getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
val clipData = ClipData.newPlainText(
|
||||||
|
resources?.getString(R.string.nc_app_product_name),
|
||||||
|
binding.translatedMessageTextview.text?.toString()
|
||||||
|
)
|
||||||
|
clipboardManager.setPrimaryClip(clipData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupActionBar() {
|
private fun setupActionBar() {
|
||||||
setSupportActionBar(binding.translationToolbar)
|
setSupportActionBar(binding.translationToolbar)
|
||||||
binding.translationToolbar.setNavigationOnClickListener {
|
binding.translationToolbar.setNavigationOnClickListener {
|
||||||
@ -107,14 +124,19 @@ class TranslateActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupTextViews() {
|
private fun setupTextViews() {
|
||||||
val original = binding.originalMessageTextview
|
viewThemeUtils.talk.themeIncomingMessageBubble(
|
||||||
val translation = binding.translatedMessageTextview
|
binding.originalMessageTextview,
|
||||||
|
grouped = true,
|
||||||
|
deleted = false
|
||||||
|
)
|
||||||
|
viewThemeUtils.talk.themeIncomingMessageBubble(
|
||||||
|
binding.translatedMessageTextview,
|
||||||
|
grouped = true,
|
||||||
|
deleted = false
|
||||||
|
)
|
||||||
|
|
||||||
viewThemeUtils.talk.themeIncomingMessageBubble(original, grouped = true, deleted = false)
|
binding.originalMessageTextview.movementMethod = ScrollingMovementMethod()
|
||||||
viewThemeUtils.talk.themeIncomingMessageBubble(translation, grouped = true, deleted = false)
|
binding.translatedMessageTextview.movementMethod = ScrollingMovementMethod()
|
||||||
|
|
||||||
original.movementMethod = ScrollingMovementMethod()
|
|
||||||
translation.movementMethod = ScrollingMovementMethod()
|
|
||||||
|
|
||||||
val bundle = intent.extras
|
val bundle = intent.extras
|
||||||
binding.originalMessageTextview.text = bundle?.getString(BundleKeys.KEY_TRANSLATE_MESSAGE)
|
binding.originalMessageTextview.text = bundle?.getString(BundleKeys.KEY_TRANSLATE_MESSAGE)
|
||||||
@ -163,13 +185,13 @@ class TranslateActivity : BaseActivity() {
|
|||||||
?.subscribe(object : Observer<TranslationsOverall> {
|
?.subscribe(object : Observer<TranslationsOverall> {
|
||||||
override fun onSubscribe(d: Disposable) {
|
override fun onSubscribe(d: Disposable) {
|
||||||
enableSpinners(false)
|
enableSpinners(false)
|
||||||
binding.translatedMessageTextview.visibility = View.GONE
|
binding.translatedMessageContainer.visibility = View.GONE
|
||||||
binding.progressBar.visibility = View.VISIBLE
|
binding.progressBar.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNext(translationOverall: TranslationsOverall) {
|
override fun onNext(translationOverall: TranslationsOverall) {
|
||||||
binding.progressBar.visibility = View.GONE
|
binding.progressBar.visibility = View.GONE
|
||||||
binding.translatedMessageTextview.visibility = View.VISIBLE
|
binding.translatedMessageContainer.visibility = View.VISIBLE
|
||||||
binding.translatedMessageTextview.text = translationOverall.ocs?.data?.text
|
binding.translatedMessageTextview.text = translationOverall.ocs?.data?.text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
~ Nextcloud Talk application
|
~ Nextcloud Talk application
|
||||||
~
|
~
|
||||||
~ @author Julius Linus
|
~ @author Julius Linus
|
||||||
|
~ @author Andy Scherzinger
|
||||||
~ Copyright (C) 2023 Julius Linus <julius.linus@nextcloud.com>
|
~ Copyright (C) 2023 Julius Linus <julius.linus@nextcloud.com>
|
||||||
|
~ Copyright (C) 2023 Andy Scherzinger <info@andy-scherzinger.de>
|
||||||
~
|
~
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
~ This program is free software: you can redistribute it and/or modify
|
||||||
~ it under the terms of the GNU General Public License as published by
|
~ it under the terms of the GNU General Public License as published by
|
||||||
@ -99,44 +101,69 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="vertical">
|
||||||
android:paddingBottom="@dimen/standard_padding">
|
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/original_message_textview"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/standard_margin"
|
android:orientation="horizontal"
|
||||||
android:layout_marginEnd="@dimen/standard_margin"
|
android:paddingBottom="@dimen/standard_padding">
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="@drawable/shape_grouped_incoming_message"
|
|
||||||
android:padding="@dimen/dialog_padding"
|
|
||||||
android:scrollbars="vertical"
|
|
||||||
android:text=""
|
|
||||||
android:textColor="@color/nc_incoming_text_default"
|
|
||||||
android:textSize="@dimen/message_text_size" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/translated_message_textview"
|
android:id="@+id/original_message_textview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/standard_margin"
|
android:layout_marginStart="@dimen/standard_margin"
|
||||||
android:layout_marginEnd="@dimen/standard_margin"
|
android:layout_marginEnd="@dimen/standard_margin"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="@drawable/shape_grouped_incoming_message"
|
android:background="@drawable/shape_grouped_incoming_message"
|
||||||
android:padding="@dimen/dialog_padding"
|
android:padding="@dimen/dialog_padding"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
android:text=""
|
android:textColor="@color/nc_incoming_text_default"
|
||||||
android:textColor="@color/nc_incoming_text_default"
|
android:textSize="@dimen/message_text_size"
|
||||||
android:textSize="@dimen/message_text_size"
|
tools:text="This is the last message\nof an incredibly long two line conversation text" />
|
||||||
android:visibility="visible" />
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/translated_message_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/standard_margin"
|
||||||
|
android:layout_marginEnd="@dimen/standard_margin"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="visible">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/translated_message_textview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/shape_grouped_incoming_message"
|
||||||
|
android:padding="@dimen/dialog_padding"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:textColor="@color/nc_incoming_text_default"
|
||||||
|
android:textSize="@dimen/message_text_size"
|
||||||
|
tools:text="This is the last message\nof an incredibly long two line conversation text" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/copy_translated_message"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:layout_marginTop="@dimen/standard_half_margin"
|
||||||
|
android:text="@string/translation_copy_translated_text"
|
||||||
|
app:icon="@drawable/ic_content_copy" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
style="?android:attr/progressBarStyle"
|
style="?android:attr/progressBarStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone" />
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
~ Nextcloud Talk application
|
~ Nextcloud Talk application
|
||||||
~
|
~
|
||||||
~ @author Julius Linus
|
~ @author Julius Linus
|
||||||
|
~ @author Andy Scherzinger
|
||||||
~ Copyright (C) 2023 Julius Linus <julius.linus@nextcloud.com>
|
~ Copyright (C) 2023 Julius Linus <julius.linus@nextcloud.com>
|
||||||
|
~ Copyright (C) 2023 Andy Scherzinger <info@andy-scherzinger.de>
|
||||||
~
|
~
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
~ This program is free software: you can redistribute it and/or modify
|
||||||
~ it under the terms of the GNU General Public License as published by
|
~ it under the terms of the GNU General Public License as published by
|
||||||
@ -110,36 +112,51 @@
|
|||||||
android:layout_marginStart="@dimen/standard_margin"
|
android:layout_marginStart="@dimen/standard_margin"
|
||||||
android:layout_marginEnd="@dimen/standard_margin"
|
android:layout_marginEnd="@dimen/standard_margin"
|
||||||
android:layout_marginBottom="@dimen/standard_margin"
|
android:layout_marginBottom="@dimen/standard_margin"
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="@drawable/shape_grouped_incoming_message"
|
android:background="@drawable/shape_grouped_incoming_message"
|
||||||
android:padding="@dimen/dialog_padding"
|
android:padding="@dimen/dialog_padding"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
android:text=""
|
tools:text="This is the last message\nof an incredibly long two line conversation text"
|
||||||
android:textColor="@color/nc_incoming_text_default"
|
android:textColor="@color/nc_incoming_text_default"
|
||||||
android:textSize="@dimen/message_text_size" />
|
android:textSize="@dimen/message_text_size" />
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/translated_message_textview"
|
android:id="@+id/translated_message_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/standard_margin"
|
android:layout_marginStart="@dimen/standard_margin"
|
||||||
android:layout_marginEnd="@dimen/standard_margin"
|
android:layout_marginEnd="@dimen/standard_margin"
|
||||||
android:layout_marginBottom="@dimen/standard_margin"
|
android:orientation="vertical"
|
||||||
android:layout_weight="1"
|
android:visibility="visible">
|
||||||
android:background="@drawable/shape_grouped_incoming_message"
|
|
||||||
android:padding="@dimen/dialog_padding"
|
<TextView
|
||||||
android:scrollbars="vertical"
|
android:id="@+id/translated_message_textview"
|
||||||
android:text=""
|
android:layout_width="match_parent"
|
||||||
android:textColor="@color/nc_incoming_text_default"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/message_text_size"
|
android:layout_marginBottom="@dimen/standard_half_margin"
|
||||||
android:visibility="visible" />
|
android:background="@drawable/shape_grouped_incoming_message"
|
||||||
|
android:padding="@dimen/dialog_padding"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
tools:text="This is the last message\nof an incredibly long two line conversation text"
|
||||||
|
android:textColor="@color/nc_incoming_text_default"
|
||||||
|
android:textSize="@dimen/message_text_size" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/copy_translated_message"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:text="@string/translation_copy_translated_text"
|
||||||
|
app:icon="@drawable/ic_content_copy" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
style="?android:attr/progressBarStyle"
|
style="?android:attr/progressBarStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone" />
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -664,5 +664,6 @@ How to translate with transifex:
|
|||||||
<string name="translation_device_settings">Device settings</string>
|
<string name="translation_device_settings">Device settings</string>
|
||||||
<string name="translation_error_title">Translation failed</string>
|
<string name="translation_error_title">Translation failed</string>
|
||||||
<string name="translation_error_message">Could not detect language</string>
|
<string name="translation_error_message">Could not detect language</string>
|
||||||
|
<string name="translation_copy_translated_text">Copy translated text</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user