diff --git a/CHANGELOG.md b/CHANGELOG.md index 90216f2..9fb4000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/src/main/java/com/myetherwallet/mewconnect/MewApplication.kt b/app/src/main/java/com/myetherwallet/mewconnect/MewApplication.kt index 47197bb..8edf1c1 100644 --- a/app/src/main/java/com/myetherwallet/mewconnect/MewApplication.kt +++ b/app/src/main/java/com/myetherwallet/mewconnect/MewApplication.kt @@ -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 @@ -28,6 +29,7 @@ class MewApplication : Application() { super.onCreate() injectMembers() + DisplaySizeHelper.init() preferences.applicationPreferences.setInstallTime() } diff --git a/app/src/main/java/com/myetherwallet/mewconnect/core/ui/fragment/BaseFragment.kt b/app/src/main/java/com/myetherwallet/mewconnect/core/ui/fragment/BaseFragment.kt index 84d098d..79653fb 100644 --- a/app/src/main/java/com/myetherwallet/mewconnect/core/ui/fragment/BaseFragment.kt +++ b/app/src/main/java/com/myetherwallet/mewconnect/core/ui/fragment/BaseFragment.kt @@ -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 diff --git a/app/src/main/java/com/myetherwallet/mewconnect/core/ui/fragment/BaseMnemonicListFragment.kt b/app/src/main/java/com/myetherwallet/mewconnect/core/ui/fragment/BaseMnemonicListFragment.kt index e27fcff..b932db1 100644 --- a/app/src/main/java/com/myetherwallet/mewconnect/core/ui/fragment/BaseMnemonicListFragment.kt +++ b/app/src/main/java/com/myetherwallet/mewconnect/core/ui/fragment/BaseMnemonicListFragment.kt @@ -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() { diff --git a/app/src/main/java/com/myetherwallet/mewconnect/core/utils/DisplaySizeHelper.kt b/app/src/main/java/com/myetherwallet/mewconnect/core/utils/DisplaySizeHelper.kt index 6288910..d9867bc 100644 --- a/app/src/main/java/com/myetherwallet/mewconnect/core/utils/DisplaySizeHelper.kt +++ b/app/src/main/java/com/myetherwallet/mewconnect/core/utils/DisplaySizeHelper.kt @@ -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 @@ -48,4 +48,6 @@ object DisplaySizeHelper { } return 0 } + + fun init() {} } \ No newline at end of file diff --git a/app/src/main/java/com/myetherwallet/mewconnect/feature/auth/fragment/AuthFragment.kt b/app/src/main/java/com/myetherwallet/mewconnect/feature/auth/fragment/AuthFragment.kt index 0c6ae77..48c1675 100644 --- a/app/src/main/java/com/myetherwallet/mewconnect/feature/auth/fragment/AuthFragment.kt +++ b/app/src/main/java/com/myetherwallet/mewconnect/feature/auth/fragment/AuthFragment.kt @@ -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) + } } }) @@ -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) + } } } } @@ -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) + } } } diff --git a/app/src/main/java/com/myetherwallet/mewconnect/feature/backup/fragment/DoubleCheckFragment.kt b/app/src/main/java/com/myetherwallet/mewconnect/feature/backup/fragment/DoubleCheckFragment.kt index 23699c9..2b8280a 100644 --- a/app/src/main/java/com/myetherwallet/mewconnect/feature/backup/fragment/DoubleCheckFragment.kt +++ b/app/src/main/java/com/myetherwallet/mewconnect/feature/backup/fragment/DoubleCheckFragment.kt @@ -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 @@ -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 { diff --git a/app/src/main/java/com/myetherwallet/mewconnect/feature/main/activity/MainActivity.kt b/app/src/main/java/com/myetherwallet/mewconnect/feature/main/activity/MainActivity.kt index 998c97a..f6c9de3 100644 --- a/app/src/main/java/com/myetherwallet/mewconnect/feature/main/activity/MainActivity.kt +++ b/app/src/main/java/com/myetherwallet/mewconnect/feature/main/activity/MainActivity.kt @@ -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 @@ -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) @@ -45,7 +47,9 @@ class MainActivity : BaseDiActivity() { setStatusBarColor() if (preferences.applicationPreferences.shouldShowWhatsNewDialog()) { - addFragment(WhatsNewFragment()) + handler.postDelayed({ + addFragment(WhatsNewFragment.newInstance()) + }, 1000) } } diff --git a/app/src/main/java/com/myetherwallet/mewconnect/feature/main/activity/SplashActivity.kt b/app/src/main/java/com/myetherwallet/mewconnect/feature/main/activity/SplashActivity.kt index 9d6baf7..a3e7bde 100644 --- a/app/src/main/java/com/myetherwallet/mewconnect/feature/main/activity/SplashActivity.kt +++ b/app/src/main/java/com/myetherwallet/mewconnect/feature/main/activity/SplashActivity.kt @@ -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 /** @@ -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() { diff --git a/app/src/main/java/com/myetherwallet/mewconnect/feature/main/fragment/WalletFragment.kt b/app/src/main/java/com/myetherwallet/mewconnect/feature/main/fragment/WalletFragment.kt index 134fcdf..2c6b154 100644 --- a/app/src/main/java/com/myetherwallet/mewconnect/feature/main/fragment/WalletFragment.kt +++ b/app/src/main/java/com/myetherwallet/mewconnect/feature/main/fragment/WalletFragment.kt @@ -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 + } } } } diff --git a/app/src/main/java/com/myetherwallet/mewconnect/feature/scan/fragment/ScanFragment.kt b/app/src/main/java/com/myetherwallet/mewconnect/feature/scan/fragment/ScanFragment.kt index 9de40df..d8fe716 100644 --- a/app/src/main/java/com/myetherwallet/mewconnect/feature/scan/fragment/ScanFragment.kt +++ b/app/src/main/java/com/myetherwallet/mewconnect/feature/scan/fragment/ScanFragment.kt @@ -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 } }