Skip to content

Commit

Permalink
Make adding the new build field not mandatory
Browse files Browse the repository at this point in the history
Also adds a helper function that reads the property when it exists using reflection
  • Loading branch information
hichamboushaba committed Dec 26, 2024
1 parent f18bfa8 commit 61128a8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import com.woocommerce.android.util.ChromeCustomTabUtils
import com.woocommerce.android.util.ChromeCustomTabUtils.Height.Partial.ThreeQuarters
import com.woocommerce.android.util.UrlUtils
import com.woocommerce.android.util.WooLog
import com.woocommerce.android.util.getBuildConfigValueOrNull
import dagger.android.AndroidInjector
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasAndroidInjector
Expand Down Expand Up @@ -351,7 +352,8 @@ class LoginActivity :
clearCachedSites()

if (authOptions != null) {
val forcePasswordLogin = BuildConfig.DEBUG && BuildConfig.FORCE_PASSWORD_LOGIN
val forcePasswordLogin = BuildConfig.DEBUG &&
getBuildConfigValueOrNull<Boolean>("FORCE_PASSWORD_LOGIN") == true

if (authOptions.isPasswordless && !forcePasswordLogin) {
showMagicLinkRequestScreen(email, verifyEmail, allowPassword = false, forceRequestAtStart = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.woocommerce.android.util

import com.woocommerce.android.BuildConfig

@Suppress("SwallowedException")
inline fun <reified T> getBuildConfigValueOrNull(key: String): T? {
return try {
val field = BuildConfig::class.java.getField(key)
field.get(null) as? T
} catch (e: NoSuchFileException) {
null
}
}

0 comments on commit 61128a8

Please sign in to comment.