From 5c7bbc9e79f87cf2fb207789de4a3e5861f83ec6 Mon Sep 17 00:00:00 2001 From: Hicham Boushaba Date: Thu, 16 Jan 2025 16:38:03 +0100 Subject: [PATCH] Remove unused code and simplify logic --- .../android/ui/login/LoginActivity.kt | 9 +--- .../WooLoginEmailPasswordFragment.kt | 43 ++----------------- 2 files changed, 5 insertions(+), 47 deletions(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/LoginActivity.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/LoginActivity.kt index 998519fa922..702e15189a9 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/LoginActivity.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/LoginActivity.kt @@ -364,15 +364,10 @@ class LoginActivity : } } - private fun showEmailPasswordScreen( - email: String?, - verifyEmail: Boolean, - password: String? = null - ) { + private fun showEmailPasswordScreen(email: String?, verifyEmail: Boolean) { val wooLoginEmailPasswordFragment = WooLoginEmailPasswordFragment .newInstance( emailAddress = email, - password = password, verifyMagicLinkEmail = verifyEmail ) changeFragment(wooLoginEmailPasswordFragment, true, LoginEmailPasswordFragment.TAG) @@ -969,7 +964,7 @@ class LoginActivity : stat = AnalyticsEvent.LOGIN_APP_LOGIN_LINK_SUCCESS, properties = mapOf(KEY_FLOW to VALUE_WP_COM) ) - showEmailPasswordScreen(email = wpComEmail, verifyEmail = false, password = null) + showEmailPasswordScreen(email = wpComEmail, verifyEmail = false) } siteUrl.isNotEmpty() && username.isNotEmpty() -> { diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/overrides/WooLoginEmailPasswordFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/overrides/WooLoginEmailPasswordFragment.kt index b4ea48c5500..8665ade99ad 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/overrides/WooLoginEmailPasswordFragment.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/overrides/WooLoginEmailPasswordFragment.kt @@ -1,25 +1,18 @@ package com.woocommerce.android.ui.login.overrides -import android.content.Context import android.os.Bundle import android.view.ViewGroup import android.widget.Button import androidx.annotation.LayoutRes import androidx.core.view.isVisible -import com.bumptech.glide.Registry.MissingComponentException import com.woocommerce.android.R -import com.woocommerce.android.extensions.isNotNullOrEmpty -import dagger.android.support.AndroidSupportInjection import org.wordpress.android.login.LoginEmailPasswordFragment -import org.wordpress.android.login.LoginListener -import org.wordpress.android.login.widgets.WPLoginInputRow class WooLoginEmailPasswordFragment : LoginEmailPasswordFragment() { companion object { @Suppress("LongParameterList") fun newInstance( emailAddress: String?, - password: String? = null, idToken: String? = null, service: String? = null, isSocialLogin: Boolean = false, @@ -28,7 +21,6 @@ class WooLoginEmailPasswordFragment : LoginEmailPasswordFragment() { val fragment = WooLoginEmailPasswordFragment() val args = Bundle() args.putString(ARG_EMAIL_ADDRESS, emailAddress) - args.putString(ARG_PASSWORD, password) args.putString(ARG_SOCIAL_ID_TOKEN, idToken) args.putString(ARG_SOCIAL_SERVICE, service) args.putBoolean(ARG_SOCIAL_LOGIN, isSocialLogin) @@ -39,48 +31,19 @@ class WooLoginEmailPasswordFragment : LoginEmailPasswordFragment() { } } - private var loginListener: LoginListener? = null - private var email: String? = null - private var isSocialLogin: Boolean = false - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - email = requireArguments().getString(ARG_EMAIL_ADDRESS) - isSocialLogin = requireArguments().getBoolean(ARG_SOCIAL_LOGIN) - } - - override fun onAttach(context: Context) { - AndroidSupportInjection.inject(this) - super.onAttach(context) - loginListener = if (context is LoginListener) { - context - } else { - throw MissingComponentException("$context must implement LoginListener") - } - } - - override fun onDetach() { - super.onDetach() - loginListener = null - } - @LayoutRes override fun getContentLayout(): Int = R.layout.fragment_login_email_password override fun setupContent(rootView: ViewGroup) { super.setupContent(rootView) + // Replace the original magic link button with the new one in bottom section + val originalMagicLinkButton = rootView.findViewById