Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@W-17411362: LoginActivity Fit and Finish #2668

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/SalesforceSDK/res/values/sf__colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
<color name="sf__error">#BA0517</color>
<color name="sf__disabled_text">#747474</color>
<color name="sf__disabled_text_dark">#AEAEAE</color>
</resources>
</resources>
163 changes: 82 additions & 81 deletions libs/SalesforceSDK/res/values/sf__strings.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!-- Errors -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The leading indentation for this source was pretty mixed, so since we're adding a significant number of lines I thought a gentle reformat to Android Studio's defaults would be helpful.

<string name="sf__generic_authentication_error_title">Error</string>
<string name="sf__generic_authentication_error">Authentication error. Please try again.</string>
<string name="sf__generic_error">An error has occurred %s\nPlease try again</string>
<string name="sf__invalid_server_name">Please type in a valid Name</string>
<string name="sf__invalid_server_url">Please type in a valid URL</string>
<string name="sf__access_token_revoked">Your access token has been revoked by the administrator. You will now be logged out.</string>
<!-- Errors -->
<string name="sf__generic_authentication_error_title">Error</string>
<string name="sf__generic_authentication_error">Authentication error. Please try again.</string>
<string name="sf__generic_error">An error has occurred %s\nPlease try again</string>
<string name="sf__invalid_server_name">Please type in a valid Name</string>
<string name="sf__invalid_server_url">Please type in a valid URL</string>
<string name="sf__access_token_revoked">Your access token has been revoked by the administrator. You will now be logged out.</string>
<string name="sf__managed_app_error">Authentication only allowed from managed device.</string>
<string name="sf__jwt_authentication_error">JWT authentication error. Please try again.</string>
<string name="sf__jwt_authentication_error">JWT authentication error. Please try again.</string>

<!-- SSL errors -->
<string name="sf__ssl_error">SSL error: %s.</string>
Expand All @@ -19,59 +19,60 @@
<string name="sf__ssl_untrusted">Untrusted certificate authority</string>
<string name="sf__ssl_unknown_error">Unknown error</string>

<!-- Login -->
<string name="sf__login_title">Login</string>
<string name="sf__pick_server">Change Server</string>
<string name="sf__clear_cookies">Clear Cookies</string>
<string name="sf__reload">Reload</string>
<string name="sf__launch_idp">Log In with IDP App</string>
<string name="sf__login_with_biometric">Log In with Biometric</string>
<string name="sf__setup_biometric_unlock">Setup Biometric Unlock</string>
<string name="sf__back_button_content_description">Back</string>
<!-- Login -->
<string name="sf__login_title">Login</string>
<string name="sf__more_options">More Options</string>
<string name="sf__pick_server">Change Server</string>
<string name="sf__clear_cookies">Clear Cookies</string>
<string name="sf__reload">Reload</string>
<string name="sf__launch_idp">Log In with IDP App</string>
<string name="sf__login_with_biometric">Log In with Biometric</string>
<string name="sf__setup_biometric_unlock">Setup Biometric Unlock</string>
<string name="sf__back_button_content_description">Back</string>

<!-- Server picker -->
<string name="sf__auth_login_production">Production</string>
<string name="sf__auth_login_sandbox">Sandbox</string>
<string name="sf__custom_url_button">Add New Connection</string>
<string name="sf__server_url_add_title">Add Connection</string>
<string name="sf__server_url_default_custom_label">Name</string>
<string name="sf__server_url_default_custom_url">URL</string>
<string name="sf__server_url_save">Save</string>
<string name="sf__server_url_delete">Delete</string>
<string name="sf__server_picker_content_description">Login Server Picker</string>
<string name="sf__server_close_button_content_description">Close</string>
<string name="sf__server_remove_content_description">Remove Server</string>
<string name="sf__server_delete_content_description">Confirm Delete</string>
<string name="sf__server_picker_click_label">Select login server</string>
<!-- Server picker -->
<string name="sf__auth_login_production">Production</string>
<string name="sf__auth_login_sandbox">Sandbox</string>
<string name="sf__custom_url_button">Add New Connection</string>
<string name="sf__server_url_add_title">Add Connection</string>
<string name="sf__server_url_default_custom_label">Name</string>
<string name="sf__server_url_default_custom_url">URL</string>
<string name="sf__server_url_save">Save</string>
<string name="sf__server_url_delete">Delete</string>
<string name="sf__server_picker_content_description">Login Server Picker</string>
<string name="sf__server_close_button_content_description">Close</string>
<string name="sf__server_remove_content_description">Remove Server</string>
<string name="sf__server_delete_content_description">Confirm Delete</string>
<string name="sf__server_picker_click_label">Select login server</string>

<!-- Manage space activity -->
<string name="sf__manage_space_title">Clear User Data?</string>
<string name="sf__manage_space_confirmation">Clearing user data will log the current user out. Are you sure you want to perform this action?</string>
<string name="sf__manage_space_logout_yes">Yes</string>
<string name="sf__manage_space_logout_no">No</string>
<!-- Manage space activity -->
<string name="sf__manage_space_title">Clear User Data?</string>
<string name="sf__manage_space_confirmation">Clearing user data will log the current user out. Are you sure you want to perform this action?</string>
<string name="sf__manage_space_logout_yes">Yes</string>
<string name="sf__manage_space_logout_no">No</string>

<!-- Account picker -->
<string name="sf__account_selector_text">Organizations</string>
<string name="sf__add_new_account">Add New Account</string>
<string name="sf__account_picker_content_description">User Account Picker</string>
<string name="sf__account_selector_click_label">Select user account</string>
<string name="sf__profile_photo_content_description">Profile Photo</string>
<!-- Account picker -->
<string name="sf__account_selector_text">Organizations</string>
<string name="sf__add_new_account">Add New Account</string>
<string name="sf__account_picker_content_description">User Account Picker</string>
<string name="sf__account_selector_click_label">Select user account</string>
<string name="sf__profile_photo_content_description">Profile Photo</string>

<!-- SP status updates -->
<string name="sf__failed_to_send_request_to_idp">Failed to send request to IDP app</string>
<string name="sf__login_request_sent_to_idp">Login request sent to IDP app</string>
<string name="sf__auth_code_received_from_idp">IDP app successfully obtained authorization code</string>
<string name="sf__error_received_from_idp">IDP app failed to obtain authorization code</string>
<string name="sf__failed_to_exchange_authorization_code">Failed to exchange authorization code</string>
<string name="sf__login_complete">Log in complete</string>
<!-- SP status updates -->
<string name="sf__failed_to_send_request_to_idp">Failed to send request to IDP app</string>
<string name="sf__login_request_sent_to_idp">Login request sent to IDP app</string>
<string name="sf__auth_code_received_from_idp">IDP app successfully obtained authorization code</string>
<string name="sf__error_received_from_idp">IDP app failed to obtain authorization code</string>
<string name="sf__failed_to_exchange_authorization_code">Failed to exchange authorization code</string>
<string name="sf__login_complete">Log in complete</string>

<!-- IDP status updates -->
<string name="sf__login_request_sent_to_sp">Login request sent to SP app</string>
<string name="sf__getting_auth_code_from_server">Getting authorization code for SP app</string>
<string name="sf__failed_to_get_authorization_code">Failed to get authorization code for SP app</string>
<string name="sf__auth_code_sent_to_sp">Authorization code sent to SP app</string>
<string name="sf__error_received_from_sp">SP app failed to exchange authorization code</string>
<string name="sf__sp_login_complete">SP app log in complete</string>
<!-- IDP status updates -->
<string name="sf__login_request_sent_to_sp">Login request sent to SP app</string>
<string name="sf__getting_auth_code_from_server">Getting authorization code for SP app</string>
<string name="sf__failed_to_get_authorization_code">Failed to get authorization code for SP app</string>
<string name="sf__auth_code_sent_to_sp">Authorization code sent to SP app</string>
<string name="sf__error_received_from_sp">SP app failed to exchange authorization code</string>
<string name="sf__sp_login_complete">SP app log in complete</string>

<!-- Managed app restrictions -->
<string name="sf__app_service_hosts_description">Used to specify login hosts for the application.</string>
Expand All @@ -80,33 +81,33 @@
<string name="sf__managed_app_callback_url_description">Used to specify OAuth callback URL for the application.</string>
<string name="sf__require_cert_auth_description">Used to specify if certificate based authentication is required for the application.</string>
<string name="sf__managed_app_cert_alias_description">Used to specify the certificate alias required for the application.</string>
<string name="sf__only_show_authorized_hosts_description">Used to specify that only authorized hosts can be shown.</string>
<string name="sf__only_show_authorized_hosts_description">Used to specify that only authorized hosts can be shown.</string>
<string name="sf__idp_app_url_scheme_description">Used to specify IDP app\'s URL scheme to be used.</string>

<!-- ScreenLock -->
<string name="sf__logout">Logout</string>
<string name="sf__application_icon">Application Icon</string>
<string name="sf__screen_lock_auth_failed">Authentication Failed.</string>
<string name="sf__screen_lock_auth_error">Authentication error.</string>
<string name="sf__screen_lock_auth_success">Authentication Success.</string>
<string name="sf__screen_lock_title">%s Lock</string>
<string name="sf__screen_lock_subtitle">Unlock to access your %s account.</string>
<string name="sf__screen_lock_error_hw_unavailable">Hardware unavailable. Try again later.</string>
<string name="sf__screen_lock_error">An unknown error has occurred.</string>
<string name="sf__screen_lock_setup_required">%s requires a device lock screen.</string>
<string name="sf__screen_lock_setup_button">Setup Lock Screen</string>
<string name="sf__screen_lock_retry_button">Retry Unlock</string>
<!-- ScreenLock -->
<string name="sf__logout">Logout</string>
<string name="sf__application_icon">Application Icon</string>
<string name="sf__screen_lock_auth_failed">Authentication Failed.</string>
<string name="sf__screen_lock_auth_error">Authentication error.</string>
<string name="sf__screen_lock_auth_success">Authentication Success.</string>
<string name="sf__screen_lock_title">%s Lock</string>
<string name="sf__screen_lock_subtitle">Unlock to access your %s account.</string>
<string name="sf__screen_lock_error_hw_unavailable">Hardware unavailable. Try again later.</string>
<string name="sf__screen_lock_error">An unknown error has occurred.</string>
<string name="sf__screen_lock_setup_required">%s requires a device lock screen.</string>
<string name="sf__screen_lock_setup_button">Setup Lock Screen</string>
<string name="sf__screen_lock_retry_button">Retry Unlock</string>

<!-- Biometric Authentication Opt In Dialog -->
<string name="sf__biometric_opt_in_title">Biometric Login</string>
<string name="sf__biometric_opt_in_message">Use your fingerprint to quickly log in. Biometric information is never stored.</string>
<string name="sf__biometric_opt_in_approve">Enable</string>
<string name="sf__biometric_opt_in_deny">Use Password</string>
<string name="sf__biometric_signout_user">Signing out %s.</string>
<!-- Biometric Authentication Opt In Dialog -->
<string name="sf__biometric_opt_in_title">Biometric Login</string>
<string name="sf__biometric_opt_in_message">Use your fingerprint to quickly log in. Biometric information is never stored.</string>
<string name="sf__biometric_opt_in_approve">Enable</string>
<string name="sf__biometric_opt_in_deny">Use Password</string>
<string name="sf__biometric_signout_user">Signing out %s.</string>

<!-- Developer Support -->
<string name="sf__dev_support_title">Mobile SDK Developer Support</string>
<string name="sf__notifications_local_show_dev_support_content">Show Salesforce Mobile SDK developer support</string>
<string name="sf__notifications_local_show_dev_support_text">Tap to display Salesforce Mobile SDK developer support in the active app.</string>
<string name="sf__notifications_local_show_dev_support_title">Salesforce Mobile Developer Support</string>
<!-- Developer Support -->
<string name="sf__dev_support_title">Mobile SDK Developer Support</string>
<string name="sf__notifications_local_show_dev_support_content">Show Salesforce Mobile SDK developer support</string>
<string name="sf__notifications_local_show_dev_support_text">Tap to display Salesforce Mobile SDK developer support in the active app.</string>
<string name="sf__notifications_local_show_dev_support_title">Salesforce Mobile Developer Support</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ import android.content.res.Configuration.UI_MODE_NIGHT_MASK
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import android.os.Build.MODEL
import android.os.Build.VERSION.RELEASE
import android.os.Build.VERSION.SDK_INT
import android.os.Build.VERSION.SECURITY_PATCH
import android.os.Build.VERSION_CODES.R
import android.os.Bundle
import android.os.Handler
import android.os.Looper.getMainLooper
Expand All @@ -52,6 +54,7 @@ import android.text.TextUtils.isEmpty
import android.text.TextUtils.join
import android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
import android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
import android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS
import android.webkit.CookieManager
import android.webkit.URLUtil.isHttpsUrl
import androidx.compose.material3.ColorScheme
Expand Down Expand Up @@ -1498,18 +1501,29 @@ open class SalesforceSDKManager protected constructor(
}

/**
* Sets the system status and navigation bars as visible regardless of style
* and OS dark theme states.
* Sets the system status and navigation bars to the light theme without
* regard to the system theme. This is useful when the background is light
* even when dark theme is enabled.
*
* @param activity The activity used to set style attributes
* @param activity The activity
*/
open fun setViewNavigationVisibility(activity: Activity) {
if (!isDarkTheme || activity.javaClass.name == loginActivityClass.name) {
/*
* This covers the case where OS dark theme is true, but app has
* disabled.
*/
activity.window.decorView.systemUiVisibility = SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR or SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
if (SDK_INT > R) {
JohnsonEricAtSalesforce marked this conversation as resolved.
Show resolved Hide resolved
runCatching {
activity.window?.insetsController?.setSystemBarsAppearance(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brandonpage - Here's a modern way to accomplish what this once did with a dandy to-do so we can clean up once API 30 is our minimum. I did some reading, and though the names have changed the overall approach is almost identical.

APPEARANCE_LIGHT_STATUS_BARS,
APPEARANCE_LIGHT_STATUS_BARS
)
}
} else {
// TODO: Remove with minimum API >= 30
activity.window?.decorView?.systemUiVisibility = SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR or SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ import com.salesforce.androidsdk.R

interface IDPManager {

enum class Status(val resIdForDescription:Int) {
enum class Status(val resIdForDescription: Int) {
LOGIN_REQUEST_SENT_TO_SP(R.string.sf__login_request_sent_to_sp),
GETTING_AUTH_CODE_FROM_SERVER(R.string.sf__getting_auth_code_from_server),
ERROR_RECEIVED_FROM_SERVER(R.string.sf__failed_to_get_authorization_code),
AUTH_CODE_SENT_TO_SP(R.string.sf__auth_code_sent_to_sp),
ERROR_RECEIVED_FROM_SP(R.string.sf__error_received_from_sp),
SP_LOGIN_COMPLETE(R.string.sf__sp_login_complete)
}

interface StatusUpdateCallback {
fun onStatusUpdate(status: Status)
}


/**
* Process received intent
*/
Expand All @@ -54,4 +54,4 @@ interface IDPManager {
* Kick off IDP initiated login flow for given SP app
*/
fun kickOffIDPInitiatedLoginFlow(context: Context, spAppPackageName: String, callback: StatusUpdateCallback)
}
}
Loading