checkpoint: active transaction on home screen is feature complete

Now, just need to cleanup the overall animation
This commit is contained in:
Kevin Gorham 2019-02-02 10:07:25 -05:00 committed by Kevin Gorham
parent 3404082869
commit 969af030db
9 changed files with 127 additions and 39 deletions

View File

@ -15,9 +15,11 @@ import androidx.annotation.StringRes
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.transition.ChangeBounds import androidx.transition.ChangeBounds
import androidx.transition.Transition
import androidx.transition.TransitionInflater import androidx.transition.TransitionInflater
import androidx.transition.TransitionSet import androidx.transition.TransitionSet
import cash.z.android.wallet.R import cash.z.android.wallet.R
import cash.z.android.wallet.extention.Toaster
import cash.z.android.wallet.extention.toAppColor import cash.z.android.wallet.extention.toAppColor
import cash.z.android.wallet.extention.toAppString import cash.z.android.wallet.extention.toAppString
import cash.z.android.wallet.extention.tryIgnore import cash.z.android.wallet.extention.tryIgnore
@ -54,8 +56,26 @@ class HomeFragment : BaseFragment(), HomePresenter.HomeView {
): View? { ): View? {
viewsInitialized = false viewsInitialized = false
val enterTransitionSet = TransitionInflater.from(mainActivity).inflateTransition(R.transition.transition_zec_sent).apply { val enterTransitionSet = TransitionInflater.from(mainActivity).inflateTransition(R.transition.transition_zec_sent).apply {
duration = 3500L duration = 350L
} }.addListener(object : Transition.TransitionListener {
override fun onTransitionEnd(transition: Transition) {
// fixes a bug where the translation gets lost, during animation. As a nice side effect, visually, it makes the view appear to settle in to position
header_active_transaction.translationZ = 10.0f
}
override fun onTransitionResume(transition: Transition) {
}
override fun onTransitionPause(transition: Transition) {
}
override fun onTransitionCancel(transition: Transition) {
}
override fun onTransitionStart(transition: Transition) {
}
})
this.sharedElementEnterTransition = enterTransitionSet this.sharedElementEnterTransition = enterTransitionSet
this.sharedElementReturnTransition = enterTransitionSet this.sharedElementReturnTransition = enterTransitionSet
@ -70,7 +90,7 @@ class HomeFragment : BaseFragment(), HomePresenter.HomeView {
mainActivity.setupNavigation() mainActivity.setupNavigation()
mainActivity.supportActionBar?.setTitle(R.string.destination_title_home) mainActivity.supportActionBar?.setTitle(R.string.destination_title_home)
} }
// background_active_transaction.isActivated = true header_active_transaction.isActivated = true
headerFullViews = arrayOf(text_balance_usd, text_balance_includes_info, text_balance_zec, image_zec_symbol_balance_shadow, image_zec_symbol_balance) headerFullViews = arrayOf(text_balance_usd, text_balance_includes_info, text_balance_zec, image_zec_symbol_balance_shadow, image_zec_symbol_balance)
headerEmptyViews = arrayOf(text_balance_zec_info, text_balance_zec_empty, image_zec_symbol_balance_shadow_empty, image_zec_symbol_balance_empty) headerEmptyViews = arrayOf(text_balance_zec_info, text_balance_zec_empty, image_zec_symbol_balance_shadow_empty, image_zec_symbol_balance_empty)
@ -83,7 +103,11 @@ class HomeFragment : BaseFragment(), HomePresenter.HomeView {
image_logo.setOnClickListener { image_logo.setOnClickListener {
// forceRedraw() // forceRedraw()
// toggleViews(false) // toggleViews(false)
background_active_transaction.isActivated = !background_active_transaction.isActivated header_active_transaction.isActivated = !header_active_transaction.isActivated
}
button_active_transaction_cancel.setOnClickListener {
onCancelActiveTransaction()
} }
} }
@ -161,8 +185,9 @@ class HomeFragment : BaseFragment(), HomePresenter.HomeView {
} }
} }
// //
// Private API // Private View API
// //
/** /**
@ -230,6 +255,13 @@ class HomeFragment : BaseFragment(), HomePresenter.HomeView {
} }
} }
private fun onCancelActiveTransaction() {
button_active_transaction_cancel.isEnabled = false
button_active_transaction_cancel.text = "canceled"
header_active_transaction.isActivated = false
homePresenter.onCancelActiveTransaction()
}
/** /**
* Defines the basic properties of each FAB button for use while initializing the FAB * Defines the basic properties of each FAB button for use while initializing the FAB
*/ */

View File

@ -116,7 +116,9 @@ class SendFragment : BaseFragment(), SendPresenter.SendView {
override fun submit(){ override fun submit(){
val extras = FragmentNavigatorExtras( val extras = FragmentNavigatorExtras(
binding.dialogSendContents to getString(R.string.transition_active_transaction) binding.dialogSendContents to getString(R.string.transition_active_transaction_background),
binding.dialogTextTitle to getString(R.string.transition_active_transaction_title),
binding.dialogTextAddress to getString(R.string.transition_active_transaction_address)
) )
mainActivity.navController.navigate(R.id.nav_home_fragment, mainActivity.navController.navigate(R.id.nav_home_fragment,

View File

@ -1,6 +1,7 @@
package cash.z.android.wallet.ui.presenter package cash.z.android.wallet.ui.presenter
import android.util.Log import android.util.Log
import cash.z.android.wallet.extention.Toaster
import cash.z.android.wallet.ui.presenter.Presenter.PresenterView import cash.z.android.wallet.ui.presenter.Presenter.PresenterView
import cash.z.android.wallet.vo.WalletTransaction import cash.z.android.wallet.vo.WalletTransaction
import cash.z.android.wallet.vo.WalletTransactionStatus import cash.z.android.wallet.vo.WalletTransactionStatus
@ -102,11 +103,17 @@ class HomePresenter(
} }
} }
fun onCancelActiveTransaction() {
// TODO: hold a reference to the job and cancel it
Toaster.short("Cancelled transaction!")
}
private fun NoteQuery.toWalletTransaction(timeOverride: Long? = null): WalletTransaction { private fun NoteQuery.toWalletTransaction(timeOverride: Long? = null): WalletTransaction {
// convert time from seconds to milliseconds // convert time from seconds to milliseconds
val timestamp = if (timeOverride == null) time * 1000 else timeOverride * 1000 val timestamp = if (timeOverride == null) time * 1000 else timeOverride * 1000
Log.e("@TWIG-u", "setting timestamp to $timestamp for value $value") Log.e("@TWIG-u", "setting timestamp to $timestamp for value $value")
return WalletTransaction(height, if (sent) SENT else RECEIVED, timestamp, BigDecimal(value / 1e8)) return WalletTransaction(height, if (sent) SENT else RECEIVED, timestamp, BigDecimal(value / 1e8))
} }
} }

View File

@ -7,14 +7,14 @@
<objectAnimator <objectAnimator
android:propertyName="backgroundColor" android:propertyName="backgroundColor"
android:valueFrom="@color/zcashGray_light" android:valueFrom="@color/fragment_home_background"
android:valueTo="@color/zcashBlue" android:valueTo="@color/zcashWhite"
android:duration="@android:integer/config_shortAnimTime" android:duration="@android:integer/config_shortAnimTime"
android:valueType="colorType" /> android:valueType="colorType" />
<objectAnimator <objectAnimator
android:propertyName="translationZ" android:propertyName="translationZ"
android:valueTo="8dp" android:valueTo="4dp"
android:startOffset="300" android:startOffset="300"
android:duration="@android:integer/config_shortAnimTime" android:duration="@android:integer/config_shortAnimTime"
android:interpolator="@android:interpolator/fast_out_slow_in" /> android:interpolator="@android:interpolator/fast_out_slow_in" />
@ -29,8 +29,8 @@
<objectAnimator <objectAnimator
android:propertyName="backgroundColor" android:propertyName="backgroundColor"
android:valueFrom="@color/zcashBlue" android:valueFrom="@color/zcashWhite"
android:valueTo="@color/zcashGray_light" android:valueTo="@color/fragment_home_background"
android:duration="@android:integer/config_shortAnimTime" android:duration="@android:integer/config_shortAnimTime"
android:valueType="colorType" /> android:valueType="colorType" />

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/text_dark_dimmed"/>
<item android:state_enabled="true" android:color="@color/zcashRed" />
</selector>

View File

@ -291,7 +291,7 @@
android:backgroundTint="@color/zcashWhite" android:backgroundTint="@color/zcashWhite"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:transitionName="@string/transition_active_transaction" android:transitionName="@string/transition_active_transaction_background"
android:visibility="gone" android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
@ -309,6 +309,7 @@
android:text="Send 1.73 ZEC ($200.23)?" android:text="Send 1.73 ZEC ($200.23)?"
android:textSize="@dimen/text_size_h6" android:textSize="@dimen/text_size_h6"
android:textStyle="bold" android:textStyle="bold"
android:transitionName="@string/transition_active_transaction_title"
app:layout_constraintBottom_toTopOf="@id/dialog_text_address" app:layout_constraintBottom_toTopOf="@id/dialog_text_address"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -341,6 +342,7 @@
android:text="ztestsapling1snmqdnfqnc407pvqw7sld8w5zxx6nd0523kvlj4jf39uvxvh7vn0hs3q38n07806dwwecqwke3t" android:text="ztestsapling1snmqdnfqnc407pvqw7sld8w5zxx6nd0523kvlj4jf39uvxvh7vn0hs3q38n07806dwwecqwke3t"
android:textColor="@color/colorPrimary" android:textColor="@color/colorPrimary"
android:textSize="@dimen/text_size_body_1" android:textSize="@dimen/text_size_body_1"
android:transitionName="@string/transition_active_transaction_address"
app:layout_constraintBottom_toTopOf="@+id/dialog_text_memo_included" app:layout_constraintBottom_toTopOf="@+id/dialog_text_memo_included"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/dialog_text_to" app:layout_constraintStart_toEndOf="@id/dialog_text_to"

View File

@ -5,41 +5,76 @@
android:id="@+id/scrollable" android:id="@+id/scrollable"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/fragment_home_background"
android:fillViewport="true" android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"> app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingTop="30dp"
android:paddingBottom="16dp"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp"> android:paddingTop="30dp"
android:paddingEnd="16dp"
android:paddingBottom="16dp">
<View <!-- Active Transaction - primary -->
android:id="@+id/background_active_transaction" <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/header_active_transaction"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="60dp" android:layout_height="70dp"
android:background="@drawable/background_rounded_corners" android:background="@drawable/background_rounded_corners"
android:transitionName="@string/transition_active_transaction" android:clipToPadding="false"
app:layout_constraintTop_toTopOf="parent" android:padding="16dp"
app:layout_constraintStart_toStartOf="parent"
android:stateListAnimator="@animator/selector_active_raise" android:stateListAnimator="@animator/selector_active_raise"
android:clickable="true" android:transitionName="@string/transition_active_transaction_background"
android:focusableInTouchMode="true" app:layout_constraintStart_toStartOf="parent"
/> app:layout_constraintTop_toTopOf="parent">
<com.airbnb.lottie.LottieAnimationView <com.airbnb.lottie.LottieAnimationView
android:id="@+id/animation_view" android:id="@+id/lottie_active_transaction"
android:layout_width="36dp" android:layout_width="36dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginLeft="16dp" app:layout_constraintBottom_toBottomOf="parent"
app:lottie_autoPlay="true" app:layout_constraintStart_toStartOf="parent"
app:lottie_loop="false" app:layout_constraintTop_toTopOf="parent"
app:lottie_rawRes="@raw/lottie_active_transaction_fail" app:lottie_autoPlay="true"
app:layout_constraintTop_toTopOf="@id/background_active_transaction" app:lottie_loop="false"
app:layout_constraintBottom_toBottomOf="@id/background_active_transaction" app:lottie_rawRes="@raw/lottie_active_transaction_fail" />
app:layout_constraintStart_toStartOf="@id/background_active_transaction"/>
<TextView
android:id="@+id/text_active_transaction_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:text="Preparing 1.01 ZEC"
android:textSize="@dimen/text_size_body_1"
android:textStyle="bold"
android:transitionName="@string/transition_active_transaction_title"
app:layout_constraintStart_toEndOf="@id/lottie_active_transaction"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/text_active_transaction_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="to zsapling...123456789"
android:textSize="@dimen/text_size_caption"
android:transitionName="@string/transition_active_transaction_address"
app:layout_constraintStart_toStartOf="@id/text_active_transaction_title"
app:layout_constraintTop_toBottomOf="@id/text_active_transaction_title" />
<Button
android:id="@+id/button_active_transaction_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:text="cancel"
android:textColor="@color/selector_red_button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- Label: Past Activity --> <!-- Label: Past Activity -->
<TextView <TextView
@ -47,13 +82,13 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:paddingBottom="16dp"
android:text="Past Activity" android:text="Past Activity"
android:textColor="@color/text_dark" android:textColor="@color/text_dark"
android:textSize="@dimen/text_size_body_2" android:textSize="@dimen/text_size_body_2"
android:textStyle="bold" android:textStyle="bold"
android:paddingBottom="16dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/background_active_transaction" /> app:layout_constraintTop_toBottomOf="@id/header_active_transaction" />
<!-- Transactions --> <!-- Transactions -->
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
@ -90,8 +125,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:padding="16dp"
android:gravity="center" android:gravity="center"
android:padding="16dp"
android:text="@string/home_empty_wallet" android:text="@string/home_empty_wallet"
android:textColor="#AAAAAA" android:textColor="#AAAAAA"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"

View File

@ -32,6 +32,7 @@
<color name="zcashBlack_87">#DD000000</color> <color name="zcashBlack_87">#DD000000</color>
<color name="zcashBlack">#00000000</color> <color name="zcashBlack">#00000000</color>
<color name="zcashPrimaryMedium">#136E6E</color> <color name="zcashPrimaryMedium">#136E6E</color>
<color name="zcashRed">#B00016</color>
<!-- --> <!-- -->
<!-- named colors --> <!-- named colors -->
@ -58,6 +59,7 @@
<color name="fragment_receive_background">@color/zcashBlack_light</color> <color name="fragment_receive_background">@color/zcashBlack_light</color>
<color name="fragment_request_background">@color/colorPrimary</color> <color name="fragment_request_background">@color/colorPrimary</color>
<color name="fragment_send_background">@color/zcashWhite_light</color> <color name="fragment_send_background">@color/zcashWhite_light</color>
<color name="fragment_home_background">@color/zcashWhite_light</color>
<color name="launcher_icon_background">@color/zcashPrimaryMedium</color> <color name="launcher_icon_background">@color/zcashPrimaryMedium</color>
<color name="receive_title_background">@color/zcashBlack_12</color> <color name="receive_title_background">@color/zcashBlack_12</color>
<color name="home_transaction_item_background">@color/zcashBlueGray</color> <color name="home_transaction_item_background">@color/zcashBlueGray</color>

View File

@ -27,7 +27,9 @@
<string name="destination_menu_label_settings">Settings</string> <string name="destination_menu_label_settings">Settings</string>
<!-- Transitions --> <!-- Transitions -->
<string name="transition_active_transaction">transition_active_transaction</string> <string name="transition_active_transaction_background">transition_active_transaction_background</string>
<string name="transition_active_transaction_title">transition_active_transaction_title</string>
<string name="transition_active_transaction_address">transition_active_transaction_address</string>
<!-- Screen copy --> <!-- Screen copy -->
<string name="receive_address_title">Your Zcash shielded address</string> <string name="receive_address_title">Your Zcash shielded address</string>