Skip to content

Commit

Permalink
Merge branch 'hotfix/1.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Foboz committed Jul 12, 2019
2 parents 72d0be0 + ddaea00 commit dc27c4d
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 61 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### Release 1.0.6 (19070301)
### Release 1.0.6 (19071201)

- Added biometric authentication (i.e. Fingerprint unlock and alike)
- Updates to ‘What's new’ screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.myetherwallet.mewconnect.core.di.DaggerApplicationComponent
import com.myetherwallet.mewconnect.core.persist.database.DatabaseModule
import com.myetherwallet.mewconnect.core.persist.prefenreces.PreferencesManager
import com.myetherwallet.mewconnect.core.persist.prefenreces.PreferencesModule
import com.myetherwallet.mewconnect.core.utils.DisplaySizeHelper
import javax.inject.Inject


Expand All @@ -28,6 +29,7 @@ class MewApplication : Application() {
super.onCreate()
injectMembers()

DisplaySizeHelper.init()
preferences.applicationPreferences.setInstallTime()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ abstract class BaseFragment : Fragment() {
}

fun addOnResumeListener(listener: () -> Unit) {
onResumeListeners.add(listener)
if (isResumed) {
listener.invoke()
} else {
onResumeListeners.add(listener)
}
}

open fun onBackPressed() = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ abstract class BaseMnemonicListFragment : BaseDiFragment(), View.OnClickListener
MewLog.d(TAG, "Auth success")
mnemonic = helper.decrypt(preferences.applicationPreferences.getWalletMnemonic(keyStore))

requireActivity().runOnUiThread {
if (TextUtils.isEmpty(mnemonic)) {
Toast.makeText(context, R.string.words_loading_error, Toast.LENGTH_LONG).show()
} else {
adapter.setItems(mnemonic!!.split(" "))
addOnResumeListener {
requireActivity().runOnUiThread {
if (TextUtils.isEmpty(mnemonic)) {
Toast.makeText(context, R.string.words_loading_error, Toast.LENGTH_LONG).show()
} else {
adapter.setItems(mnemonic!!.split(" "))
}
}
close()
}
close()
}

override fun onAuthCancel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object DisplaySizeHelper {
private set
private val handler = Handler()

fun init(view: View) {
fun setup(view: View) {
val displayMetrics = DisplayMetrics()
(view.context.getSystemService(Context.WINDOW_SERVICE) as WindowManager)
.defaultDisplay
Expand All @@ -48,4 +48,6 @@ object DisplaySizeHelper {
}
return 0
}

fun init() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ class AuthFragment : BaseDiFragment() {

auth_password_text.addTextChangedListener(object : EmptyTextWatcher {
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
auth_password_input_layout.isErrorEnabled = false
setEnterButtonEnabled(auth_password_text.length() > 0)
addOnResumeListener {
auth_password_input_layout.isErrorEnabled = false
setEnterButtonEnabled(auth_password_text.length() > 0)
}
}
})

Expand Down Expand Up @@ -110,10 +112,12 @@ class AuthFragment : BaseDiFragment() {
}

private fun showBiometricPrompt() {
BiometricUtils.authenticate(requireActivity(), preferences) { cipher ->
cipher?.let {
requireActivity().runOnUiThread {
handleResult(BiometricKeystoreHelper(requireContext(), cipher), KeyStore.BIOMETRIC)
addOnResumeListener {
BiometricUtils.authenticate(requireActivity(), preferences) { cipher ->
cipher?.let {
requireActivity().runOnUiThread {
handleResult(BiometricKeystoreHelper(requireContext(), cipher), KeyStore.BIOMETRIC)
}
}
}
}
Expand All @@ -129,9 +133,11 @@ class AuthFragment : BaseDiFragment() {
}

private fun doAuth() {
if (auth_password_input_layout.isEnabled) {
val password = auth_password_text.text.toString()
handleResult(PasswordKeystoreHelper(password), KeyStore.PASSWORD)
addOnResumeListener {
if (auth_password_input_layout.isEnabled) {
val password = auth_password_text.text.toString()
handleResult(PasswordKeystoreHelper(password), KeyStore.PASSWORD)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.myetherwallet.mewconnect.R
import com.myetherwallet.mewconnect.core.di.ApplicationComponent
import com.myetherwallet.mewconnect.core.extenstion.getString
import com.myetherwallet.mewconnect.core.persist.prefenreces.KeyStore
import com.myetherwallet.mewconnect.core.persist.prefenreces.PreferencesManager
import com.myetherwallet.mewconnect.core.ui.fragment.BaseDiFragment
import com.myetherwallet.mewconnect.core.utils.crypto.keystore.encrypt.PasswordKeystoreHelper
import com.myetherwallet.mewconnect.feature.backup.adapter.DoubleCheckAdapter
import kotlinx.android.synthetic.main.fragment_double_check.*
import javax.inject.Inject
Expand Down Expand Up @@ -55,15 +53,17 @@ class DoubleCheckFragment : BaseDiFragment(), View.OnClickListener, Toolbar.OnMe
double_check_list.isNestedScrollingEnabled = false
double_check_list.setHasFixedSize(false)

getString(EXTRA_MNEMONIC)?.let {mnemonic ->
getString(EXTRA_MNEMONIC)?.let { mnemonic ->
adapter.setItems(mnemonic.split(" "))
} ?: Toast.makeText(context, R.string.words_loading_error, Toast.LENGTH_LONG).show()
}

private fun setDoneButtonEnabled(isEnabled: Boolean) {
double_check_toolbar.getMenu().findItem(R.id.done).isEnabled = isEnabled
val icon = if (isEnabled) R.drawable.ic_action_done_enabled else R.drawable.ic_action_done_disabled
double_check_toolbar.getMenu().findItem(R.id.done).setIcon(icon)
addOnResumeListener {
double_check_toolbar.getMenu().findItem(R.id.done).isEnabled = isEnabled
val icon = if (isEnabled) R.drawable.ic_action_done_enabled else R.drawable.ic_action_done_disabled
double_check_toolbar.getMenu().findItem(R.id.done).setIcon(icon)
}
}

override fun onMenuItemClick(menuItem: MenuItem): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.myetherwallet.mewconnect.feature.main.activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import androidx.fragment.app.Fragment
import com.myetherwallet.mewconnect.R
import com.myetherwallet.mewconnect.core.di.ApplicationComponent
Expand All @@ -29,6 +30,7 @@ class MainActivity : BaseDiActivity() {
@Inject
lateinit var preferences: PreferencesManager
private lateinit var fragmentTransactor: FragmentTransactor
private val handler = Handler()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -45,7 +47,9 @@ class MainActivity : BaseDiActivity() {
setStatusBarColor()

if (preferences.applicationPreferences.shouldShowWhatsNewDialog()) {
addFragment(WhatsNewFragment())
handler.postDelayed({
addFragment(WhatsNewFragment.newInstance())
}, 1000)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import com.myetherwallet.mewconnect.R
import com.myetherwallet.mewconnect.core.ui.activity.BaseActivity
import com.myetherwallet.mewconnect.core.utils.DisplaySizeHelper
import kotlinx.android.synthetic.main.activity_splash.*
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin


/**
Expand All @@ -25,7 +22,7 @@ class SplashActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
DisplaySizeHelper.init(window.decorView)
DisplaySizeHelper.setup(window.decorView)
}

override fun onResume() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,26 +261,28 @@ class WalletFragment : BaseViewModelFragment() {
}

private fun setConnectedStatus() {
when {
networkHandler.isConnected != true -> {
wallet_status_container.visibility = GONE
wallet_offline_container.visibility = VISIBLE
wallet_scan_to_connect.setBackgroundResource(R.drawable.wallet_scan_to_connect_background_grey)
wallet_scan_to_connect.visibility = VISIBLE
}
viewModel.checkConnected() -> {
viewModel.setOnTransactionListener { activity?.runOnUiThread { openConfirmFragment(it) } }
viewModel.setOnMessageListener { activity?.runOnUiThread { openSignMessageFragment(it) } }
wallet_status_container.visibility = VISIBLE
wallet_offline_container.visibility = GONE
wallet_scan_to_connect.visibility = GONE
}
else -> {
viewModel.bindService()
wallet_status_container.visibility = GONE
wallet_offline_container.visibility = GONE
wallet_scan_to_connect.setBackgroundResource(R.drawable.wallet_scan_to_connect_background_blue)
wallet_scan_to_connect.visibility = VISIBLE
addOnResumeListener {
when {
networkHandler.isConnected != true -> {
wallet_status_container.visibility = GONE
wallet_offline_container.visibility = VISIBLE
wallet_scan_to_connect.setBackgroundResource(R.drawable.wallet_scan_to_connect_background_grey)
wallet_scan_to_connect.visibility = VISIBLE
}
viewModel.checkConnected() -> {
viewModel.setOnTransactionListener { activity?.runOnUiThread { openConfirmFragment(it) } }
viewModel.setOnMessageListener { activity?.runOnUiThread { openSignMessageFragment(it) } }
wallet_status_container.visibility = VISIBLE
wallet_offline_container.visibility = GONE
wallet_scan_to_connect.visibility = GONE
}
else -> {
viewModel.bindService()
wallet_status_container.visibility = GONE
wallet_offline_container.visibility = GONE
wallet_scan_to_connect.setBackgroundResource(R.drawable.wallet_scan_to_connect_background_blue)
wallet_scan_to_connect.visibility = VISIBLE
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,23 @@ class ScanFragment : BaseViewModelFragment() {
}

private fun showPermissionRationale(shouldOpenDialog: Boolean?) {
if (shouldOpenDialog == null) {
scan_camera_permission_rationale.visibility = GONE
} else {
if (shouldOpenDialog) {
setRationaleText(R.string.scan_camera_permission_rationale_dialog, 7, 20) {
permissionHelper.requestPermissions(this)
}
addOnResumeListener {
if (shouldOpenDialog == null) {
scan_camera_permission_rationale.visibility = GONE
} else {
setRationaleText(R.string.scan_camera_permission_rationale_settings, 46, 54) {
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
intent.data = Uri.fromParts("package", requireContext().packageName, null)
startActivityForResult(intent, REQUEST_CODE_PERMISSIONS)
if (shouldOpenDialog) {
setRationaleText(R.string.scan_camera_permission_rationale_dialog, 7, 20) {
permissionHelper.requestPermissions(this)
}
} else {
setRationaleText(R.string.scan_camera_permission_rationale_settings, 46, 54) {
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
intent.data = Uri.fromParts("package", requireContext().packageName, null)
startActivityForResult(intent, REQUEST_CODE_PERMISSIONS)
}
}
scan_camera_permission_rationale.visibility = VISIBLE
}
scan_camera_permission_rationale.visibility = VISIBLE
}
}

Expand Down

0 comments on commit dc27c4d

Please sign in to comment.