Skip to content

Commit

Permalink
KAA-379: update according to review
Browse files Browse the repository at this point in the history
  • Loading branch information
batytskyy committed Mar 12, 2015
1 parent 1e2c88b commit c4f248e
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 55 deletions.
2 changes: 1 addition & 1 deletion examples/verifiersdemo/assembly/src.xml
Expand Up @@ -31,7 +31,7 @@
<fileSet>
<directory>${project.basedir}/../thirdparty/android/appcompat_v7</directory>
<useDefaultExcludes>true</useDefaultExcludes>
<outputDirectory>smarthouse_demo/appcompat_v7</outputDirectory>
<outputDirectory>verifiers_demo/appcompat_v7</outputDirectory>
</fileSet>
</fileSets>
<files>
Expand Down
59 changes: 36 additions & 23 deletions examples/verifiersdemo/resources/config_schema.avsc
@@ -1,24 +1,37 @@
{
"type" : "record",
"name" : "KaaVerifiersTokens",
"namespace" : "org.kaaproject.kaa.demo.verifiersdemo",
"fields" : [ {
"name" : "twitterKaaVerifierToken",
"type" : [ {
"type" : "string",
"avro.java.string" : "String"
}, "null" ]
}, {
"name" : "facebookKaaVerifierToken",
"type" : [ {
"type" : "string",
"avro.java.string" : "String"
}, "null" ]
}, {
"name" : "googleKaaVerifierToken",
"type" : [ {
"type" : "string",
"avro.java.string" : "String"
}, "null" ]
} ]
}
"type":"record",
"name":"KaaVerifiersTokens",
"namespace":"org.kaaproject.kaa.demo.verifiersdemo",
"fields":[
{
"name":"twitterKaaVerifierToken",
"type":[
{
"type":"string",
"avro.java.string":"String"
},
"null"
]
},
{
"name":"facebookKaaVerifierToken",
"type":[
{
"type":"string",
"avro.java.string":"String"
},
"null"
]
},
{
"name":"googleKaaVerifierToken",
"type":[
{
"type":"string",
"avro.java.string":"String"
},
"null"
]
}
]
}
Expand Up @@ -23,12 +23,12 @@
import com.facebook.model.GraphUser;
import com.facebook.widget.LoginButton;

public class FacebookSigninListeners implements LoginButton.UserInfoChangedCallback, Session.StatusCallback {
private LoginsActivity parentActivity;
public class FacebookSigninListener implements LoginButton.UserInfoChangedCallback, Session.StatusCallback {
private LoginActivity parentActivity;
private static final String TAG = "Example-Facebook";
private boolean isClicked;

public FacebookSigninListeners(LoginsActivity parentActivity) {
public FacebookSigninListener(LoginActivity parentActivity) {
this.parentActivity = parentActivity;
}

Expand All @@ -45,7 +45,7 @@ public void onUserInfoFetched(GraphUser user) {
Log.i(TAG, "User id: " + userId);
Log.i(TAG, "User name: " + user.getFirstName());

parentActivity.updateUI(userName, userId, accessToken, LoginsActivity.AccountType.FACEBOOK);
parentActivity.updateUI(userName, userId, accessToken, LoginActivity.AccountType.FACEBOOK);

// Disconnect user from Facebook (to make Log out button disappear)
Session.getActiveSession().closeAndClearTokenInformation();
Expand Down
Expand Up @@ -32,19 +32,19 @@

import java.io.IOException;

public class GplusSigninListeners implements GoogleApiClient.ConnectionCallbacks,
public class GplusSigninListener implements GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener, View.OnClickListener {
private static final int RC_SIGN_IN = 0;
private static final String SCOPE = "oauth2:https://www.googleapis.com/auth/plus.login";
private static final String TAG = "Example-G+";

private GoogleApiClient client;
private LoginsActivity parentActivity;
private LoginActivity parentActivity;
private boolean mSignInClicked;
private boolean mIntentInProgress;
private ConnectionResult mConnectionResult;

public GplusSigninListeners(LoginsActivity parentActivity) {
public GplusSigninListener(LoginActivity parentActivity) {
this.parentActivity = parentActivity;
}

Expand Down Expand Up @@ -141,9 +141,9 @@ private void getTokenInBackground() {
}

private class GetTokenInBackground extends AsyncTask<Void, Void, Void> {
private LoginsActivity activity;
private LoginActivity activity;

public GetTokenInBackground(LoginsActivity activity) {
public GetTokenInBackground(LoginActivity activity) {
this.activity = activity;
}

Expand All @@ -164,7 +164,7 @@ protected Void doInBackground(Void... params) {
Log.i(TAG, "User id: " + userId);
Log.i(TAG, "User name: " + userName);

parentActivity.updateUI(userName, userId, accessToken, LoginsActivity.AccountType.GOOGLE);
parentActivity.updateUI(userName, userId, accessToken, LoginActivity.AccountType.GOOGLE);

return null;
} catch (IOException e) {
Expand Down
Expand Up @@ -58,7 +58,7 @@

import io.fabric.sdk.android.Fabric;

public class LoginsActivity extends FragmentActivity {
public class LoginActivity extends FragmentActivity {
// Note: Your consumer key and secret should be obfuscated in your source code before shipping.
private static final String TWITTER_KEY = "01Y9gbsMeGPetye1w9kkNvNMi";
private static final String TWITTER_SECRET = "g4Pwh51o7SQlhd3RL6inNF3VxixBURAJDZc494uSISF7yOyJjc";
Expand Down Expand Up @@ -97,9 +97,9 @@ public enum EventStatus {RCVD, SENT};
private boolean buttonEnabled;

// classes, handling each button's specific actions
private GplusSigninListeners gplusSigninListeners;
private FacebookSigninListeners facebookSigninListeners;
private TwitterSigninListeners twitterSigninListeners;
private GplusSigninListener gplusSigninListener;
private FacebookSigninListener facebookSigninListener;
private TwitterSigninListener twitterSigninListener;

// Google API client, which is used to establish connection with Google
// and access its API
Expand Down Expand Up @@ -160,35 +160,35 @@ protected void onCreate(Bundle savedInstanceState) {

// Enable button, even if a user is signed-in
twitterButton.setEnabled(true);
twitterSigninListeners = new TwitterSigninListeners(this);
twitterSigninListener = new TwitterSigninListener(this);

// Attach listeners needed to keep track of connection
twitterButton.setCallback(twitterSigninListeners);
twitterButton.setOnClickListener(twitterSigninListeners);
twitterButton.setCallback(twitterSigninListener);
twitterButton.setOnClickListener(twitterSigninListener);

// create listeners class for Google+
gplusSigninListeners = new GplusSigninListeners(this);
gplusSigninListener = new GplusSigninListener(this);

googleButton = (SignInButton) findViewById(R.id.gplus_sign_in_button);
googleButton.setSize(SignInButton.SIZE_WIDE);
googleButton.setOnClickListener(gplusSigninListeners);
googleButton.setOnClickListener(gplusSigninListener);

// Google API client, which is capable of making requests for tokens, user info etc.
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(gplusSigninListeners)
.addOnConnectionFailedListener(gplusSigninListeners)
.addConnectionCallbacks(gplusSigninListener)
.addOnConnectionFailedListener(gplusSigninListener)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.build();
gplusSigninListeners.setClient(mGoogleApiClient);
gplusSigninListener.setClient(mGoogleApiClient);

// create listeners class for Facebook
facebookSigninListeners = new FacebookSigninListeners(this);
facebookSigninListener = new FacebookSigninListener(this);
facebookButton = (LoginButton) findViewById(R.id.facebook_sign_in_button);

facebookButton.setUserInfoChangedCallback(facebookSigninListeners);
facebookButton.setUserInfoChangedCallback(facebookSigninListener);
// UI helper is used for managing Facebook's log in UI
uiHelper = new UiLifecycleHelper(this, facebookSigninListeners);
uiHelper = new UiLifecycleHelper(this, facebookSigninListener);
uiHelper.onCreate(savedInstanceState);

sendEventButton.setOnClickListener(new SendEventButtonClickListener());
Expand All @@ -210,7 +210,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// respectively
uiHelper.onActivityResult(requestCode, resultCode, data);
twitterButton.onActivityResult(requestCode, resultCode, data);
gplusSigninListeners.onActivityResult(requestCode, resultCode, data);
gplusSigninListener.onActivityResult(requestCode, resultCode, data);
}

@Override
Expand Down Expand Up @@ -253,7 +253,7 @@ protected void onStart() {
@Override
protected void onStop() {
super.onStop();
gplusSigninListeners.onStop();
gplusSigninListener.onStop();
}

public void updateUI(String userName, String userId, String token, AccountType type) {
Expand Down
Expand Up @@ -24,12 +24,12 @@
import com.twitter.sdk.android.core.TwitterException;
import com.twitter.sdk.android.core.TwitterSession;

public class TwitterSigninListeners extends Callback<TwitterSession> implements View.OnClickListener {
private LoginsActivity parentActivity;
public class TwitterSigninListener extends Callback<TwitterSession> implements View.OnClickListener {
private LoginActivity parentActivity;
private static String TAG = "Example-Twitter";
private boolean isClicked;

public TwitterSigninListeners(LoginsActivity parentActivity) {
public TwitterSigninListener(LoginActivity parentActivity) {
this.parentActivity = parentActivity;
}

Expand All @@ -47,7 +47,7 @@ public void success(Result<TwitterSession> twitterSessionResult) {
Log.i(TAG, "User id: " + userId);
Log.i(TAG, "User name: " + userName);

parentActivity.updateUI(userName, userId, accessToken, LoginsActivity.AccountType.TWITTER);
parentActivity.updateUI(userName, userId, accessToken, LoginActivity.AccountType.TWITTER);
}
}

Expand Down

0 comments on commit c4f248e

Please sign in to comment.