Checkpoint prior to build cleanup

This commit is contained in:
Kevin Gorham 2019-02-04 13:42:28 -05:00 committed by Kevin Gorham
parent 6a8cc9bc6c
commit c7712f58eb
7 changed files with 79 additions and 47 deletions

View File

@ -85,10 +85,16 @@ internal object SynchronizerModule {
// TODO: load most of these properties in later, perhaps from settings
object Properties {
// const val COMPACT_BLOCK_SERVER = "10.0.0.26"
const val COMPACT_BLOCK_SERVER = "lightwalletd.z.cash"
val COMPACT_BLOCK_SERVER = Servers.ZCASH_TESTNET.host
const val COMPACT_BLOCK_PORT = 9067
const val CACHE_DB_NAME = "wallet_cache9.db"
const val DATA_DB_NAME = "wallet_data9.db"
const val CACHE_DB_NAME = "wallet_cache19.db"
const val DATA_DB_NAME = "wallet_data19.db"
val SEED_PROVIDER = SampleSeedProvider("dummyseed")
}
}
enum class Servers(val host: String) {
EMULATOR("10.0.2.2"),
WLAN("10.0.0.26"),
BOLT_TESTNET("ec2-34-228-10-162.compute-1.amazonaws.com"),
ZCASH_TESTNET("lightwalletd.z.cash")
}

View File

@ -9,6 +9,7 @@ import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.getSystemService
import androidx.core.view.GravityCompat
import androidx.core.view.doOnLayout
import androidx.drawerlayout.widget.DrawerLayout
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.Navigation
@ -77,6 +78,10 @@ class MainActivity : BaseActivity() {
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
}
fun setDrawerLocked(isLocked: Boolean) {
drawer_layout.setDrawerLockMode(if (isLocked) DrawerLayout.LOCK_MODE_LOCKED_CLOSED else DrawerLayout.LOCK_MODE_UNLOCKED)
}
fun setupNavigation() {
// create and setup the navController and appbarConfiguration
navController = Navigation.findNavController(this, R.id.nav_host_fragment).also { n ->

View File

@ -29,8 +29,10 @@ import cash.z.android.wallet.ui.presenter.HomePresenter
import cash.z.android.wallet.ui.util.AlternatingRowColorDecoration
import cash.z.android.wallet.ui.util.TopAlignedSpan
import cash.z.android.wallet.vo.WalletTransaction
import cash.z.wallet.sdk.data.ActiveSendTransaction
import cash.z.wallet.sdk.data.ActiveTransaction
import cash.z.wallet.sdk.data.TransactionState
import cash.z.wallet.sdk.ext.toZec
import com.leinardi.android.speeddial.SpeedDialActionItem
import dagger.Module
import dagger.android.ContributesAndroidInjector
@ -68,7 +70,7 @@ class HomeFragment : BaseFragment(), HomePresenter.HomeView {
private fun setupSharedElementTransitions() {
val enterTransitionSet =
TransitionInflater.from(mainActivity).inflateTransition(R.transition.transition_zec_sent).apply {
duration = 300L
duration = 3000L
}.addListener(HomeTransitionListener())
this.sharedElementEnterTransition = enterTransitionSet
@ -106,22 +108,24 @@ class HomeFragment : BaseFragment(), HomePresenter.HomeView {
onCancelActiveTransaction()
}
refresh_layout.setOnRefreshListener {
val fauxRefresh = Random.nextLong(750L..3000L)
refresh_layout.postDelayed({
refresh_layout.isRefreshing = false
}, fauxRefresh)
// refresh_layout.setOnRefreshListener {
// val fauxRefresh = Random.nextLong(750L..3000L)
// refresh_layout.postDelayed({
// refresh_layout.isRefreshing = false
// }, fauxRefresh)
// }
launch {
setFirstRunShown(mainActivity.synchronizer.isFirstRun())
}
if (mainActivity.synchronizer.processor.dataDbExists) {
container_first_run.visibility = View.GONE
mainActivity.findViewById<DrawerLayout>(R.id.drawer_layout).setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
sd_fab.visibility = View.VISIBLE
} else {
container_first_run.visibility = View.VISIBLE
mainActivity.findViewById<DrawerLayout>(R.id.drawer_layout).setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
sd_fab.visibility = View.GONE
}
// refresh_layout.setProgressViewEndTarget(false, (86f * resources.displayMetrics.density).toInt())
}
private fun setFirstRunShown(isShown: Boolean) {
container_first_run?.visibility = if (isShown) View.VISIBLE else View.GONE
mainActivity.setDrawerLocked(isShown)
sd_fab?.visibility = if (!isShown) View.VISIBLE else View.GONE
}
override fun onResume() {
@ -180,6 +184,7 @@ class HomeFragment : BaseFragment(), HomePresenter.HomeView {
Log.e("TWIG-t", "submitList called with ${transactions.size} transactions")
transactionAdapter.submitList(transactions)
recycler_transactions.smoothScrollToPosition(0)
if (transactions.isNotEmpty()) setFirstRunShown(false)
}
var snackbar: Snackbar? = null
@ -202,12 +207,6 @@ class HomeFragment : BaseFragment(), HomePresenter.HomeView {
snackbar?.setText(message)
if(progress == 100 && snackbar?.isShownOrQueued != true) snackbar?.show()
}
if (progress >= 100) {
container_first_run.visibility = View.GONE
mainActivity.findViewById<DrawerLayout>(R.id.drawer_layout).setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
sd_fab.visibility = View.VISIBLE
}
}
override fun setActiveTransactions(activeTransactionMap: Map<ActiveTransaction, TransactionState>) {
@ -229,13 +228,13 @@ class HomeFragment : BaseFragment(), HomePresenter.HomeView {
var subtitle = "Processing..."
when (transactionState) {
TransactionState.Creating -> {
title = "Preparing ${transaction.value} ZEC"
subtitle = "to ********"
title = "Preparing ${transaction.value.toZec(2)} ZEC"
subtitle = "to ${(transaction as ActiveSendTransaction).toAddress}"
button_active_transaction_cancel.text = "cancel"
}
TransactionState.SendingToNetwork -> {
title = "Sending Transaction"
subtitle = "to ********"
subtitle = "to ${(transaction as ActiveSendTransaction).toAddress}"
button_active_transaction_cancel.text = "${transaction.value/1000L}"
}
is TransactionState.Failure -> {
@ -336,11 +335,12 @@ class HomeFragment : BaseFragment(), HomePresenter.HomeView {
if (situationHasChanged) {
Log.e("TWIG-t", "The situation has changed! toggling views!")
toggleViews(isEmpty)
if (!isEmpty) setFirstRunShown(false)
}
}
private fun onActiveTransactionTransitionStart() {
button_active_transaction_cancel.visibility = View.INVISIBLE
}
private fun onActiveTransactionTransitionEnd() {
@ -348,6 +348,7 @@ class HomeFragment : BaseFragment(), HomePresenter.HomeView {
header_active_transaction.translationZ = 10.0f
button_active_transaction_cancel.apply {
postDelayed({text = "cancel"}, 50L)
visibility = View.VISIBLE
}
}

View File

@ -102,13 +102,6 @@ class HomePresenter(
private fun bind(progress: Int) = onMain {
view.showProgress(progress)
if (progress == 100) {
launch {
// TODO: remove this behavior and pull it down into the synchronizer
Log.e("@TWIG-t", "triggering manual scan!")
synchronizer.processor.scanBlocks()
}
}
}
private fun bind(activeTransactionMap: Map<ActiveTransaction, TransactionState>) = onMain {

View File

@ -18,17 +18,20 @@
android:id="@+id/container_first_run"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:background="#81CAFF">
android:background="#81CAFF"
android:clickable="true"
android:focusableInTouchMode="true"
android:visibility="gone">
<cash.z.android.wallet.ui.util.ViewpagerHeader
android:id="@+id/scenic_view"
android:layout_width="match_parent"
android:layout_height="230dp"
android:layout_height="260dp"
app:layoutDescription="@xml/scene_15"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/mountains"
@ -62,4 +65,28 @@
tools:layout_editor_absoluteY="194dp" />
</cash.z.android.wallet.ui.util.ViewpagerHeader>
<TextView
android:id="@+id/first_run_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
android:text="Initializing first run!"
android:textColor="@color/zcashBlack_40"
android:textSize="@dimen/text_size_h6"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/scenic_view" />
<TextView
android:id="@+id/first_run_submessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enjoy the view because this may take a while..."
android:textColor="@color/zcashBlack_40"
android:textSize="@dimen/text_size_subtitle_1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/first_run_message" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -9,10 +9,10 @@
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/refresh_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!--<androidx.swiperefreshlayout.widget.SwipeRefreshLayout-->
<!--android:id="@+id/refresh_layout"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content">-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/content_home"
@ -156,5 +156,5 @@
android:layout_height="wrap_content"
app:constraint_referenced_ids="image_empty_wallet,text_wallet_message" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<!--</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>-->
</androidx.core.widget.NestedScrollView>