Updated on 2026-08-14
This commit is contained in:
parent
635f38bb86
commit
c72faf1c35
9 changed files with 97 additions and 23 deletions
|
|
@ -0,0 +1,22 @@
|
|||
package com.tangem.tangemtest.extensions
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
fun Fragment.shareText(text: String) {
|
||||
requireActivity().shareText(text)
|
||||
}
|
||||
|
||||
fun ComponentActivity.shareText(text: String) {
|
||||
val sendIntent: Intent = Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(Intent.EXTRA_TEXT, text)
|
||||
type = "text/plain"
|
||||
}
|
||||
val shareIntent = Intent.createChooser(sendIntent, null)
|
||||
startActivity(shareIntent)
|
||||
}
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
package com.tangem.tangemtest.ucase.variants.responses.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.*
|
||||
import android.widget.LinearLayout
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.Observer
|
||||
import com.google.gson.Gson
|
||||
import com.tangem.tangemtest.R
|
||||
import com.tangem.tangemtest._arch.widget.WidgetBuilder
|
||||
import com.tangem.tangemtest._main.MainViewModel
|
||||
import com.tangem.tangemtest.extensions.shareText
|
||||
import com.tangem.tangemtest.ucase.ui.BaseFragment
|
||||
import com.tangem.tangemtest.ucase.variants.responses.ResponseViewModel
|
||||
import com.tangem.tangemtest.ucase.variants.responses.ui.widget.ResponseItemBuilder
|
||||
|
|
@ -27,9 +27,9 @@ open class ResponseFragment : BaseFragment() {
|
|||
|
||||
override fun getLayoutId(): Int = R.layout.fg_card_response
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setTittle()
|
||||
return super.onCreateView(inflater, container, savedInstanceState)
|
||||
}
|
||||
|
||||
private fun setTittle() {
|
||||
|
|
@ -40,6 +40,7 @@ open class ResponseFragment : BaseFragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
setHasOptionsMenu(true)
|
||||
buildWidgets()
|
||||
listenDescriptionSwitchChanges()
|
||||
}
|
||||
|
|
@ -55,4 +56,18 @@ open class ResponseFragment : BaseFragment() {
|
|||
selfVM.toggleDescriptionVisibility(it)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
|
||||
val menuItem = menu.findItem(R.id.action_share)
|
||||
menuItem.isVisible = true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_share -> shareText(Gson().toJson(mainActivityVM.responseEvent))
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ import android.view.ViewGroup
|
|||
import com.google.android.material.checkbox.MaterialCheckBox
|
||||
import com.tangem.tangemtest.R
|
||||
import com.tangem.tangemtest._arch.structure.impl.BoolItem
|
||||
import com.tangem.tangemtest.ucase.variants.personalize.ui.widgets.DescriptionWidget
|
||||
import ru.dev.gbixahue.eu4d.lib.android._android.views.colorFrom
|
||||
|
||||
/**
|
||||
|
|
@ -13,7 +12,7 @@ import ru.dev.gbixahue.eu4d.lib.android._android.views.colorFrom
|
|||
class CheckBoxWidget(
|
||||
parent: ViewGroup,
|
||||
private val typedItem: BoolItem
|
||||
) : DescriptionWidget(parent, typedItem) {
|
||||
) : ResponseWidget(parent, typedItem) {
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.w_response_item_checkbox
|
||||
|
||||
|
|
@ -22,7 +21,7 @@ class CheckBoxWidget(
|
|||
init {
|
||||
switchItem.text = getName()
|
||||
switchItem.isChecked = typedItem.getData() ?: false
|
||||
switchItem.isEnabled = false
|
||||
switchItem.isClickable = false
|
||||
switchItem.setTextColor(switchItem.colorFrom(R.color.action_name))
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,9 @@
|
|||
package com.tangem.tangemtest.ucase.variants.responses.ui.widget
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.tangem.tangemtest.R
|
||||
import com.tangem.tangemtest._arch.structure.impl.TextItem
|
||||
import com.tangem.tangemtest.ucase.variants.personalize.ui.widgets.DescriptionWidget
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
|
|
@ -15,7 +11,7 @@ import com.tangem.tangemtest.ucase.variants.personalize.ui.widgets.DescriptionWi
|
|||
class ResponseTextWidget(
|
||||
parent: ViewGroup,
|
||||
private val typedItem: TextItem
|
||||
) : DescriptionWidget(parent, typedItem) {
|
||||
) : ResponseWidget(parent, typedItem) {
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.w_response_item
|
||||
|
||||
|
|
@ -30,13 +26,5 @@ class ResponseTextWidget(
|
|||
val data = typedItem.getData() as? String
|
||||
tvName.text = getName()
|
||||
tvValue.text = data
|
||||
|
||||
view.setOnClickListener {
|
||||
val clipboard = view.context.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
||||
?: return@setOnClickListener
|
||||
|
||||
val clip: ClipData = ClipData.newPlainText("FieldValue", "$data")
|
||||
clipboard.setPrimaryClip(clip)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.tangem.tangemtest.ucase.variants.responses.ui.widget
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.view.ViewGroup
|
||||
import com.tangem.tangemtest.R
|
||||
import com.tangem.tangemtest._arch.structure.abstraction.Item
|
||||
import com.tangem.tangemtest.ucase.variants.personalize.ui.widgets.DescriptionWidget
|
||||
import ru.dev.gbixahue.eu4d.lib.android._android.views.stringFrom
|
||||
import ru.dev.gbixahue.eu4d.lib.android._android.views.toast
|
||||
import ru.dev.gbixahue.eu4d.lib.kotlin.stringOf
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
abstract class ResponseWidget(parent: ViewGroup, item: Item): DescriptionWidget(parent, item) {
|
||||
|
||||
init {
|
||||
view.setOnClickListener {
|
||||
val data = stringOf(item.getData<Any?>())
|
||||
val clipboard = view.context.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
||||
?: return@setOnClickListener
|
||||
|
||||
val clip: ClipData = ClipData.newPlainText("FieldValue", "$data")
|
||||
clipboard.setPrimaryClip(clip)
|
||||
|
||||
val copyMessage = view.stringFrom(R.string.copy_to_clipboard)
|
||||
view.toast("$copyMessage: ${getName()} - $data")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="18dp"
|
||||
android:height="18dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"
|
||||
android:fillColor="#ffffff"/>
|
||||
</vector>
|
||||
|
|
@ -2,9 +2,17 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_share"
|
||||
android:icon="@drawable/ic_share_white_18dp"
|
||||
android:title="Share"
|
||||
android:visible="false"
|
||||
app:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_favorite"
|
||||
android:title=""
|
||||
app:actionLayout="@layout/menu_item_switch"
|
||||
app:showAsAction="always" />
|
||||
|
||||
</menu>
|
||||
|
|
@ -128,7 +128,7 @@
|
|||
<fragment
|
||||
android:id="@+id/nav_card_response"
|
||||
android:name="com.tangem.tangemtest.ucase.variants.responses.ui.ResponseFragment"
|
||||
android:label="@string/unknown"
|
||||
android:label=""
|
||||
tools:layout="@layout/fg_card_response" />
|
||||
|
||||
</navigation>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
<string name="fg_name_response_depersonalization">Depersonalization response</string>
|
||||
|
||||
<string name="unknown">unknown</string>
|
||||
<string name="copy_to_clipboard">Copy to clipboard</string>
|
||||
<string name="switch_description">Docs</string>
|
||||
|
||||
<string name="card_error_not_personalized">Your card hasn\'t been personalized yet. You need to run personalize command first.</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue