Skip to content
Permalink
Browse files

Updated CredentialClient to utilize ProviderResolver methods (#143)

* Updated CredentialClient to utilize ProviderResolver methods

* Fixed import order to pass checkstyle
  • Loading branch information...
nerdyverde authored and iainmcgin committed Nov 4, 2017
1 parent 49e6117 commit ff0de4b8651354673a5e2dc97c1b78cf7c353651
Showing with 6 additions and 21 deletions.
  1. +6 −21 api/java/org/openyolo/api/CredentialClient.java
@@ -31,7 +31,6 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
@@ -44,6 +43,7 @@
import org.openyolo.api.internal.FinishWithResultActivity;
import org.openyolo.api.internal.KnownProviders;
import org.openyolo.api.internal.ProviderPickerActivity;
import org.openyolo.api.internal.ProviderResolver;
import org.openyolo.api.persistence.AppSettings;
import org.openyolo.api.persistence.internal.AppSettingsImpl;
import org.openyolo.protocol.Credential;
@@ -213,7 +213,8 @@ public Intent getCredentialRetrieveIntent(CredentialRetrieveRequest request) {
*/
@NonNull
public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
List<ComponentName> hintProviders =
ProviderResolver.findProviders(mApplicationContext, HINT_CREDENTIAL_ACTION);

if (hintProviders.isEmpty()) {
ActivityResult result = ActivityResult.of(
@@ -282,7 +283,8 @@ public Intent getSaveIntent(final Credential credential) {
*/
@NonNull
public Intent getSaveIntent(final CredentialSaveRequest saveRequest) {
List<ComponentName> saveProviders = findProviders(SAVE_CREDENTIAL_ACTION);
List<ComponentName> saveProviders =
ProviderResolver.findProviders(mApplicationContext, SAVE_CREDENTIAL_ACTION);

if (saveProviders.isEmpty()) {
ActivityResult result = ActivityResult.of(
@@ -360,7 +362,7 @@ public Intent getDeleteIntent(@NonNull CredentialDeleteRequest request) {
require(request, notNullValue());

List<ComponentName> deleteProviders =
findProviders(DELETE_CREDENTIAL_ACTION);
ProviderResolver.findProviders(mApplicationContext, DELETE_CREDENTIAL_ACTION);

if (deleteProviders.isEmpty()) {
ActivityResult result = ActivityResult.of(
@@ -632,23 +634,6 @@ public void disableAutoSignIn() {
mDeviceState.setIsAutoSignInDisabled(true);
}

private List<ComponentName> findProviders(@NonNull String action) {
Intent saveIntent = new Intent(action);
saveIntent.addCategory(OPENYOLO_CATEGORY);

List<ResolveInfo> resolveInfos =
mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);

ArrayList<ComponentName> responders = new ArrayList<>();
for (ResolveInfo info : resolveInfos) {
responders.add(new ComponentName(
info.activityInfo.packageName,
info.activityInfo.name));
}

return responders;
}

@Nullable
private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
// In the future, the user will be able to explicitly set their preferred provider in

0 comments on commit ff0de4b

Please sign in to comment.
You can’t perform that action at this time.