diff --git a/app/src/main/java/com/nextcloud/talk/translate/TranslateActivity.kt b/app/src/main/java/com/nextcloud/talk/translate/TranslateActivity.kt index 8d9e8717a..f08e1697b 100644 --- a/app/src/main/java/com/nextcloud/talk/translate/TranslateActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/translate/TranslateActivity.kt @@ -21,6 +21,9 @@ */ package com.nextcloud.talk.translate +import android.content.ClipData +import android.content.ClipboardManager +import android.content.Context import android.graphics.drawable.ColorDrawable import android.os.Bundle import android.text.method.ScrollingMovementMethod @@ -73,6 +76,7 @@ class TranslateActivity : BaseActivity() { setupSystemColors() setupTextViews() setupSpinners() + setupCopyButton() getLanguageOptions() if (savedInstanceState == null) { @@ -94,6 +98,19 @@ class TranslateActivity : BaseActivity() { 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() { setSupportActionBar(binding.translationToolbar) binding.translationToolbar.setNavigationOnClickListener { @@ -107,14 +124,19 @@ class TranslateActivity : BaseActivity() { } private fun setupTextViews() { - val original = binding.originalMessageTextview - val translation = binding.translatedMessageTextview + viewThemeUtils.talk.themeIncomingMessageBubble( + binding.originalMessageTextview, + grouped = true, + deleted = false + ) + viewThemeUtils.talk.themeIncomingMessageBubble( + binding.translatedMessageTextview, + grouped = true, + deleted = false + ) - viewThemeUtils.talk.themeIncomingMessageBubble(original, grouped = true, deleted = false) - viewThemeUtils.talk.themeIncomingMessageBubble(translation, grouped = true, deleted = false) - - original.movementMethod = ScrollingMovementMethod() - translation.movementMethod = ScrollingMovementMethod() + binding.originalMessageTextview.movementMethod = ScrollingMovementMethod() + binding.translatedMessageTextview.movementMethod = ScrollingMovementMethod() val bundle = intent.extras binding.originalMessageTextview.text = bundle?.getString(BundleKeys.KEY_TRANSLATE_MESSAGE) @@ -163,13 +185,13 @@ class TranslateActivity : BaseActivity() { ?.subscribe(object : Observer { override fun onSubscribe(d: Disposable) { enableSpinners(false) - binding.translatedMessageTextview.visibility = View.GONE + binding.translatedMessageContainer.visibility = View.GONE binding.progressBar.visibility = View.VISIBLE } override fun onNext(translationOverall: TranslationsOverall) { binding.progressBar.visibility = View.GONE - binding.translatedMessageTextview.visibility = View.VISIBLE + binding.translatedMessageContainer.visibility = View.VISIBLE binding.translatedMessageTextview.text = translationOverall.ocs?.data?.text } diff --git a/app/src/main/res/layout-land/activity_translate.xml b/app/src/main/res/layout-land/activity_translate.xml index 144fd2010..ac1c7e682 100644 --- a/app/src/main/res/layout-land/activity_translate.xml +++ b/app/src/main/res/layout-land/activity_translate.xml @@ -3,7 +3,9 @@ ~ Nextcloud Talk application ~ ~ @author Julius Linus + ~ @author Andy Scherzinger ~ Copyright (C) 2023 Julius Linus + ~ Copyright (C) 2023 Andy Scherzinger ~ ~ 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 @@ -99,44 +101,69 @@ + android:orientation="vertical"> - + android:orientation="horizontal" + android:paddingBottom="@dimen/standard_padding"> - + + + + + + + + + + + + android:visibility="gone" + tools:visibility="visible" /> diff --git a/app/src/main/res/layout/activity_translate.xml b/app/src/main/res/layout/activity_translate.xml index 8dbdd7977..ad097c7f0 100644 --- a/app/src/main/res/layout/activity_translate.xml +++ b/app/src/main/res/layout/activity_translate.xml @@ -3,7 +3,9 @@ ~ Nextcloud Talk application ~ ~ @author Julius Linus + ~ @author Andy Scherzinger ~ Copyright (C) 2023 Julius Linus + ~ Copyright (C) 2023 Andy Scherzinger ~ ~ 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 @@ -110,36 +112,51 @@ android:layout_marginStart="@dimen/standard_margin" android:layout_marginEnd="@dimen/standard_margin" android:layout_marginBottom="@dimen/standard_margin" - android:layout_weight="1" android:background="@drawable/shape_grouped_incoming_message" android:padding="@dimen/dialog_padding" 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:textSize="@dimen/message_text_size" /> - + android:orientation="vertical" + android:visibility="visible"> + + + + + + + android:visibility="gone" + tools:visibility="visible" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f612264ae..bd7218b52 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -664,5 +664,6 @@ How to translate with transifex: Device settings Translation failed Could not detect language + Copy translated text