-
Notifications
You must be signed in to change notification settings - Fork 393
Add Login Options to Dev Menu #2801
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8e6f1a5
Add Login Options activity to dev menu.
brandonpage 6ac6282
Fix scrolling issue and cleanup UI.
brandonpage 9a65dac
Review feedback.
brandonpage 789dc91
Update tests.
brandonpage a907632
Fix all tests.
brandonpage 3e11e60
Improve LoginOptionsActivity and the mechanism used to reload on opti…
brandonpage 4e954f5
Add sections and additional info to DevInfoActivity and tests.
brandonpage 37b8dbf
Add DevSupportInfo tests.
brandonpage 45dbec8
Make new DevSupportInfo class backwards compatible.
brandonpage 36509c2
Remove SmartStore string reference in SalesforceSDK library.
brandonpage 64eaeae
Merge branch 'dev' of github.com:forcedotcom/SalesforceMobileSDK-Andr…
brandonpage 88e795f
Merge branch 'dev' of github.com:forcedotcom/SalesforceMobileSDK-Andr…
brandonpage 6d4dd9e
Remove unused code and introduce annotation to exclude UI previews fr…
brandonpage File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
libs/SalesforceSDK/src/com/salesforce/androidsdk/developer/support/DevSupportInfo.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| package com.salesforce.androidsdk.developer.support | ||
|
|
||
| import com.salesforce.androidsdk.accounts.UserAccount | ||
| import com.salesforce.androidsdk.auth.JwtAccessToken | ||
| import com.salesforce.androidsdk.config.BootConfig | ||
| import com.salesforce.androidsdk.config.RuntimeConfig | ||
| import java.text.SimpleDateFormat | ||
| import java.util.Locale | ||
|
|
||
| data class DevSupportInfo( | ||
| val sdkVersion: String, | ||
| val appType: String, | ||
| val userAgent: String, | ||
| val authenticatedUsers: List<UserAccount>, | ||
| val authConfig: List<Pair<String, String>>, | ||
| val bootConfig: BootConfig, | ||
| val currentUser: UserAccount?, | ||
| val runtimeConfig: RuntimeConfig, | ||
| ) { | ||
| val bootConfigValues: List<Pair<String, String>> by lazy { | ||
| with(bootConfig) { | ||
| val values = mutableListOf( | ||
| "Consumer Key" to remoteAccessConsumerKey, | ||
| "Redirect URI" to oauthRedirectURI, | ||
| "Scopes" to oauthScopes.joinToString(separator = " "), | ||
| ) | ||
|
|
||
| if (appType == "Hybrid") { | ||
| values.addAll( | ||
| listOf( | ||
| "Local" to isLocal.toString(), | ||
| "Start Page" to startPage, | ||
| "Unauthenticated Start Page" to unauthenticatedStartPage, | ||
| "Error Page" to errorPage, | ||
| "Should Authenticate" to shouldAuthenticate().toString(), | ||
| "Attempt Offline Load" to attemptOfflineLoad().toString(), | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| return@lazy values | ||
| } | ||
| } | ||
|
|
||
| val authenticatedUsersString: String = authenticatedUsers.joinToString(separator = ",\n") { | ||
| "${it.displayName} (${it.username})" | ||
| } | ||
|
|
||
| val currentUserInfo: List<Pair<String, String>> by lazy { | ||
| if (currentUser != null) { | ||
| with(currentUser) { | ||
| return@lazy mutableListOf( | ||
| "Username" to username, | ||
| "Consumer Key" to clientId, | ||
| "Scopes" to scope, | ||
| "Instance URL" to instanceServer, | ||
| "Token Format" to tokenFormat, | ||
| "Access Token Expiration" to accessTokenExpiration, | ||
| "Beacon Child Consumer Key" to beaconChildConsumerKey, | ||
| ) | ||
| } | ||
| } else { | ||
| emptyList() | ||
| } | ||
| } | ||
|
|
||
| val runtimeConfigValues: List<Pair<String, String>> by lazy { | ||
| with(runtimeConfig) { | ||
| val values = mutableListOf( | ||
| "Managed App" to isManagedApp.toString() | ||
| ) | ||
|
|
||
| if (isManagedApp) { | ||
| values.addAll(listOf( | ||
| "OAuth ID" to (getString(RuntimeConfig.ConfigKey.ManagedAppOAuthID) ?: "N/A"), | ||
| "Callback URL" to (getString(RuntimeConfig.ConfigKey.ManagedAppCallbackURL) ?: "N/A"), | ||
| "Require Cert Auth" to getBoolean(RuntimeConfig.ConfigKey.RequireCertAuth).toString(), | ||
| "Only Show Authorized Hosts" to getBoolean(RuntimeConfig.ConfigKey.OnlyShowAuthorizedHosts).toString(), | ||
| )) | ||
| } | ||
|
|
||
| return@lazy values | ||
| } | ||
| } | ||
|
|
||
| val accessTokenExpiration: String | ||
| get() { | ||
| var expiration = "Unknown" | ||
|
|
||
| if (currentUser?.tokenFormat == "jwt") { | ||
| val jwtAccessToken = JwtAccessToken(currentUser.authToken) | ||
| val expirationDate = jwtAccessToken.expirationDate() | ||
| if (expirationDate != null) { | ||
| val dateFormatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()) | ||
| expiration = dateFormatter.format(expirationDate) | ||
| } | ||
| } | ||
|
|
||
| return expiration | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On iOS I kept the Dev Info "dumb" to be able to support arbitrary grouping of rows - including rows provided by the app or subclasses of SalesforceSDKManager e.g. SmartStoreSDKManager here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I wanted to keep as much of the sorting logic out of the UI as I could... but I forgot about the subclasses. It would be easy to add the subclasses data as additional categories, but if you think I should revert back to the old simple list I can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now the dev infos provided by subclasses of SalesforceSDKManager are no longer shown (e.g. https://github.com/forcedotcom/SalesforceMobileSDK-Android/blob/dev/libs/SmartStore/src/com/salesforce/androidsdk/smartstore/app/SmartStoreSDKManager.java#L470) .
At least we should fix that but we would still be breaking apps that implemented their own SDKManager and overrode getDevSupportInfos.
That's why I ended up going with the list that has "section:xxx" markers. It's a bit low tech ;-) but it keeps everything working.
Maybe the move to a typed dev infos could be done in 14.0??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DevSupportInfo
SmartStoreSDKManger
I was thinking this would be okay? The idea of grouping values based on a string that could change feels fragile but I will take a closer look at the iOS implementation before committing anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe DevSupportInfo could have a field for other infos which would be shown in the UI after everything else.
The DevSupportInfo that you create in SalesforceSDKManager could populate that new field by calling the existing getDevSupportInfos().
The getDevSupportInfos() method in SalesforceSDKManager would return an empty list.
SmartStoreSDKManager and other managers could be left unchanged and their additional infos would keep showing up in the UI.
If we want some grouping in the additional infos, we could do the "section:xxx" hack I did on iOS or do something more structured (but that would mean changing the subclasses to take advantage of it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if SmartStore data is optional it isn't a problem. The UI has to check if SmartStore data exists one way or another, this is just more structured.
Good point. I am going to try to massage the list from the existing API (even if it has been modified by a subclass) into the
DevSupportInfoclass. If I make everything nullable and allow additional sections to be added it should work well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wmathurin I have the approach in my latest commit. The
DevSupportInfoclass now allows for everything to benullon the main constructor, has a secondary constructor similar to the original constructor and features acreateFromLegacyDevInfosfunction to instantiate the class fromList<String>. A unit test insures that given the same input data the objects created by the secondary constructor and thecreateFromLegacyDevInfosfunction are identical.So whatever is in the
devSupportInfos(list of string) will be parsed to the expected categories. Removed values simply will not show up, completely empty sections will now show up and any additional info will be added to the first basic non-collapsable section.SmartStoreSDKManager'soverride ofdevSupportInfosworks as expected, creating a new "Smart Store" section.Code to be used post 14.0 is commented out in place.