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

Now easier to apply MaterialDesign. #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.udinic.accounts_authenticator_example.authentication;

import android.accounts.Account;
import android.accounts.AccountAuthenticatorActivity;
import android.accounts.AccountManager;
import android.accounts.AccountAuthenticatorResponse;
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
Expand All @@ -21,7 +22,7 @@
*
* It sends back to the Authenticator the result.
*/
public class AuthenticatorActivity extends AccountAuthenticatorActivity {
public class AuthenticatorActivity extends Activity {

public final static String ARG_ACCOUNT_TYPE = "ACCOUNT_TYPE";
public final static String ARG_AUTH_TYPE = "AUTH_TYPE";
Expand All @@ -36,15 +37,21 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity {

private final String TAG = this.getClass().getSimpleName();

private AccountAuthenticatorResponse mAccountAuthenticatorResponse = null;
private AccountManager mAccountManager;
private String mAuthTokenType;
private Bundle mResultBundle = null;

/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAccountAuthenticatorResponse = getIntent().getParcelableExtra( AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE );
if( mAccountAuthenticatorResponse != null ) {
mAccountAuthenticatorResponse.onRequestContinued();
}
setContentView(R.layout.act_login);
mAccountManager = AccountManager.get(getBaseContext());

Expand Down Expand Up @@ -155,4 +162,21 @@ private void finishLogin(Intent intent) {
finish();
}

public final void setAccountAuthenticatorResult( Bundle result ) {
mResultBundle = result;
}

public void finish() {
if( mAccountAuthenticatorResponse != null ) {
// send the result bundle back if set, otherwise send an error.
if( mResultBundle != null ) {
mAccountAuthenticatorResponse.onResult( mResultBundle );
} else {
mAccountAuthenticatorResponse.onError( AccountManager.ERROR_CODE_CANCELED, "canceled" );
}
mAccountAuthenticatorResponse = null;
}
super.finish();
}

}