Cleanup and Attributions

This commit is contained in:
Kevin Gorham 2019-04-05 06:23:58 -04:00
parent aeeb1b0a1f
commit 14db38c2c4
15 changed files with 51 additions and 172 deletions

View File

@ -1,6 +1,6 @@
package cash.z.android.wallet.sample
import android.preference.PreferenceManager
import android.content.Context
import android.util.Log
import cash.z.android.wallet.ZcashWalletApplication
import okio.ByteString
@ -8,10 +8,6 @@ import java.nio.charset.Charset
import kotlin.properties.ReadOnlyProperty
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
import android.R.id.edit
import android.content.Context
import android.content.SharedPreferences
import java.lang.IllegalStateException
@Deprecated(message = InsecureWarning.message)
class SampleImportedSeedProvider(private val seedHex: String) : ReadOnlyProperty<Any?, ByteArray> {

View File

@ -1,26 +1,17 @@
package cash.z.android.wallet.ui.activity
import android.animation.ObjectAnimator
import android.animation.ValueAnimator
import android.annotation.SuppressLint
import android.os.Bundle
import android.util.Log
import android.view.Gravity
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.view.inputmethod.InputMethodManager.HIDE_NOT_ALWAYS
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.graphics.drawable.DrawerArrowDrawable
import androidx.core.app.ActivityCompat
import androidx.core.content.getSystemService
import androidx.core.view.GravityCompat
import androidx.core.view.doOnLayout
import androidx.databinding.DataBindingUtil
import androidx.drawerlayout.widget.DrawerLayout
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.Navigation
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.navigateUp
@ -28,23 +19,12 @@ import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import cash.z.android.wallet.BuildConfig
import cash.z.android.wallet.R
import cash.z.android.wallet.ZcashWalletApplication
import cash.z.android.wallet.databinding.ActivityMainBinding
import cash.z.android.wallet.sample.WalletConfig
import cash.z.wallet.sdk.data.Synchronizer
import dagger.Module
import dagger.android.ContributesAndroidInjector
import dagger.android.support.DaggerAppCompatActivity
import cash.z.wallet.sdk.data.Synchronizer
import com.google.android.material.snackbar.Snackbar
import dagger.android.AndroidInjection
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import javax.inject.Inject
import kotlin.random.Random
import kotlin.random.nextInt
class MainActivity : BaseActivity() {
@ -57,17 +37,12 @@ class MainActivity : BaseActivity() {
lateinit var binding: ActivityMainBinding
lateinit var loadMessages: List<String>
// used to manage the drawer and drawerToggle interactions
private lateinit var appBarConfiguration: AppBarConfiguration
lateinit var navController: NavController
// private val multiStartNavigationUi = MultiStartNavigationUI(listOf(
// R.id.nav_home_fragment,
// R.id.nav_welcome_fragment
// ))
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main)
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
initAppBar()
loadMessages = generateFunLoadMessages().shuffled()
synchronizer.start(this)
@ -75,7 +50,6 @@ class MainActivity : BaseActivity() {
private fun initAppBar() {
setSupportActionBar(findViewById(R.id.main_toolbar))
// supportActionBar?.setDisplayHomeAsUpEnabled(false)
setupNavigation()
}
@ -155,6 +129,7 @@ class MainActivity : BaseActivity() {
"Validating your balance"
)
}
fun generateFunLoadMessages(): List<String> {
return listOf(
"Reticulating splines",
@ -173,81 +148,3 @@ abstract class MainActivityModule {
@ContributesAndroidInjector
abstract fun contributeMainActivity(): MainActivity
}
//
//class MultiStartNavigationUI(private val startDestinations: List<Int>) {
// fun setupActionBarWithNavController(activity: AppCompatActivity, navController: NavController,
// drawerLayout: DrawerLayout?) {
//
// navController.addOnNavigatedListener(ActionBarOnNavigatedListener(
// activity, startDestinations, drawerLayout))
// }
//
// fun navigateUp(drawerLayout: DrawerLayout?, navController: NavController): Boolean {
// if (drawerLayout != null && startDestinations.contains(navController.currentDestination?.id)) {
// drawerLayout.openDrawer(GravityCompat.START)
// return true
// } else {
// return navController.navigateUp()
// }
// }
//
// fun onBackPressed(activity: AppCompatActivity,
// navController: NavController): Boolean {
// if (startDestinations.contains(navController.currentDestination?.id)) {
// ActivityCompat.finishAfterTransition(activity)
// return true
// }
//
// return false
// }
//
// private class ActionBarOnNavigatedListener(
// private val mActivity: AppCompatActivity,
// private val startDestinations: List<Int>,
// private val mDrawerLayout: DrawerLayout?
// ) : NavController.OnNavigatedListener {
// private var mArrowDrawable: DrawerArrowDrawable? = null
// private var mAnimator: ValueAnimator? = null
//
// override fun onNavigated(controller: NavController, destination: NavDestination) {
// val actionBar = mActivity.supportActionBar
//
// val title = destination.label
// if (!title.isNullOrEmpty()) {
// actionBar?.title = title
// }
//
// val isStartDestination = startDestinations.contains(destination.id)
// actionBar?.setDisplayHomeAsUpEnabled(this.mDrawerLayout != null || !isStartDestination)
// setActionBarUpIndicator(mDrawerLayout != null && isStartDestination)
// }
//
//
// private fun setActionBarUpIndicator(showAsDrawerIndicator: Boolean) {
// val delegate = mActivity.drawerToggleDelegate
// var animate = true
// if (mArrowDrawable == null) {
// mArrowDrawable = DrawerArrowDrawable(delegate!!.actionBarThemedContext)
// delegate.setActionBarUpIndicator(mArrowDrawable, 0)
// animate = false
// }
//
// mArrowDrawable?.let {
// val endValue = if (showAsDrawerIndicator) 0.0f else 1.0f
//
// if (animate) {
// val startValue = it.progress
// mAnimator?.cancel()
//
// @SuppressLint("ObjectAnimatorBinding")
// mAnimator = ObjectAnimator.ofFloat(it, "progress", startValue, endValue)
// mAnimator?.start()
// } else {
// it.progress = endValue
// }
// }
//
// }
// }
//}

View File

@ -45,8 +45,6 @@ class FirstrunFragment : ProgressFragment(R.id.progress_firstrun), Transition.Tr
null
)
}
// binding.buttonNext.alpha = 0f
// binding.textProgressFirstrun.alpha = 0f
}
override fun onActivityCreated(savedInstanceState: Bundle?) {

View File

@ -518,13 +518,6 @@ class HomeFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, HomeP
@IdRes val destination:Int
) {
/* ordered by when they need to be added to the speed dial (i.e. reverse display order) */
// REQUEST(
// R.id.fab_request,
// R.drawable.ic_receipt_24dp,
// R.color.icon_request,
// R.string.destination_menu_label_request,
// R.id.nav_request_fragment
// ),
HISTORY(
R.id.fab_history,
R.drawable.ic_history_24dp,
@ -551,14 +544,12 @@ class HomeFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, HomeP
fun fromId(id: Int): HomeFab? = values().firstOrNull { it.id == id }
}
}
//
//
//
//// ---------------------------------------------------------------------------------------------------------------------
//// TODO: Delete these test functions
//// ---------------------------------------------------------------------------------------------------------------------
//
var empty = false
val delay = 50L
lateinit var headerEmptyViews: Array<View>
lateinit var headerFullViews: Array<View>
@ -569,9 +560,6 @@ class HomeFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, HomeP
binding.includeHeader.containerHomeHeader.progress = binding.includeHeader.containerHomeHeader.progress - 0.1f
}, delay * 2)
}
// internal fun toggle(isEmpty: Boolean) {
// toggleValues(isEmpty)
// }
internal fun toggleViews(isEmpty: Boolean) {
twig("toggling views to isEmpty == $isEmpty")
@ -608,49 +596,6 @@ class HomeFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, HomeP
view?.postDelayed(::forceRedraw, delay * 2)
}
// TODO: get rid of all of this and consider two different fragments for the header, instead
internal fun toggleViews2(isEmpty: Boolean) {
var action: () -> Unit
if (isEmpty) {
action = {
// group_empty_view_items.visibility = View.VISIBLE
// group_full_view_items.visibility = View.GONE
headerFullViews.forEach { binding.includeHeader.containerHomeHeader.removeView(it) }
headerEmptyViews.forEach {
tryIgnore {
binding.includeHeader.containerHomeHeader.addView(it)
}
}
}
} else {
action = {
// group_empty_view_items.visibility = View.GONE
// group_full_view_items.visibility = View.VISIBLE
headerEmptyViews.forEach { binding.includeHeader.containerHomeHeader.removeView(it) }
headerFullViews.forEach {
tryIgnore {
binding.includeHeader.containerHomeHeader.addView(it)
}
}
}
}
view?.postDelayed({
action()
viewsInitialized = true
}, delay)
// TODO: the motion layout does not begin in the right state for some reason. Debug this later.
view?.postDelayed(::forceRedraw, delay * 2)
}
// internal fun toggleValues(isEmpty: Boolean) {
// empty = isEmpty
// if(empty) {
// reduceValue()
// } else {
// increaseValue(Random.nextDouble(20.0, 100.0))
// }
// }
inner class HomeTransitionListener : Transition.TransitionListener {
override fun onTransitionStart(transition: Transition) {

View File

@ -1,4 +1,6 @@
/*
* Copyright (C) 2019 Electric Coin Company
*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -7,13 +9,14 @@
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* This file has been modified by Electric Coin Company to translate it into Kotlin and add support for Firebase vision.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cash.z.android.cameraview
import android.app.Activity

View File

@ -1,4 +1,6 @@
/*
* Copyright (C) 2019 Electric Coin Company
*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -7,6 +9,8 @@
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* This file has been modified by Electric Coin Company to translate it into Kotlin and add support for Firebase vision.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -1,4 +1,6 @@
/*
* Copyright (C) 2019 Electric Coin Company
*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -7,6 +9,8 @@
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* This file has been modified by Electric Coin Company to translate it into Kotlin and add support for Firebase vision.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -1,4 +1,6 @@
/*
* Copyright (C) 2019 Electric Coin Company
*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -7,6 +9,8 @@
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* This file has been modified by Electric Coin Company to translate it into Kotlin and add support for Firebase vision.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -1,4 +1,6 @@
/*
* Copyright (C) 2019 Electric Coin Company
*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -7,6 +9,8 @@
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* This file has been modified by Electric Coin Company to translate it into Kotlin and add support for Firebase vision.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -1,4 +1,6 @@
/*
* Copyright (C) 2019 Electric Coin Company
*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -7,6 +9,8 @@
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* This file has been modified by Electric Coin Company to translate it into Kotlin and add support for Firebase vision.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -1,4 +1,6 @@
/*
* Copyright (C) 2019 Electric Coin Company
*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -7,6 +9,8 @@
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* This file has been modified by Electric Coin Company to translate it into Kotlin and add support for Firebase vision.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -1,4 +1,6 @@
/*
* Copyright (C) 2019 Electric Coin Company
*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -7,6 +9,8 @@
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* This file has been modified by Electric Coin Company to translate it into Kotlin and add support for Firebase vision.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -1,4 +1,6 @@
/*
* Copyright (C) 2019 Electric Coin Company
*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -7,6 +9,8 @@
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* This file has been modified by Electric Coin Company to translate it into Kotlin and add support for Firebase vision.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -1,4 +1,6 @@
/*
* Copyright (C) 2019 Electric Coin Company
*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -7,6 +9,8 @@
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* This file has been modified by Electric Coin Company to translate it into Kotlin and add support for Firebase vision.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -1,4 +1,6 @@
/*
* Copyright (C) 2019 Electric Coin Company
*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -7,6 +9,8 @@
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* This file has been modified by Electric Coin Company to translate it into Kotlin and add support for Firebase vision.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.