package it.asg.hustle;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;

public class FacebookActivity extends AppCompatActivity {
    String logtag = "ActivityFacebook";
    LoginButton loginButton;
    CallbackManager callbackManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FacebookSdk.sdkInitialize(getApplicationContext());
        setContentView(R.layout.activity_facebook);

        callbackManager = new CallbackManager.Factory().create();

        loginButton = (LoginButton) findViewById(R.id.login_button);
        loginButton.setReadPermissions("user_friends");

        // Other app specific specialization

        // Callback registration
        loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                // App code
                Log.d(logtag, "onSuccess Facebook");
            }

            @Override
            public void onCancel() {
                // App code
                Log.d(logtag, "onCancel Facebook");
            }

            @Override
            public void onError(FacebookException exception) {
                // App code
                Log.d(logtag, "onError Facebook");
            }
        });

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        callbackManager.onActivityResult(requestCode, resultCode, data);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_facebook, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

@@ -48,16 +48,134 @@
 Intent;%0A
+import android.content.pm.PackageInfo;%0Aimport android.content.pm.PackageManager;%0Aimport android.content.pm.Signature;%0A
 import a
@@ -241,16 +241,44 @@
 Bundle;%0A
+import android.util.Base64;%0A
 import a
@@ -407,16 +407,49 @@
 utton;%0A%0A
+import com.facebook.AccessToken;%0A
 import c
@@ -587,16 +587,117 @@
 ookSdk;%0A
+import com.facebook.GraphRequest;%0Aimport com.facebook.GraphResponse;%0Aimport com.facebook.HttpMethod;%0A
 import c
@@ -774,16 +774,100 @@
 utton;%0A%0A
+import java.security.MessageDigest;%0Aimport java.security.NoSuchAlgorithmException;%0A%0A
 public c
@@ -1198,16 +1198,17 @@
 ext());%0A
+%0A
         
@@ -1248,24 +1248,56 @@
 facebook);%0A%0A
+        //facebook login button%0A
         call
@@ -1346,25 +1346,24 @@
 ).create();%0A
-%0A
         logi
@@ -1475,17 +1475,16 @@
 ends%22);%0A
-%0A
         
@@ -1520,17 +1520,16 @@
 ization%0A
-%0A
         
@@ -1801,32 +1801,632 @@
 ess Facebook%22);%0A
+                       /* make the API call */%0A                new GraphRequest(%0A                        AccessToken.getCurrentAccessToken(),%0A                        %22/me/friends%22,%0A                        null,%0A                        HttpMethod.GET,%0A                        new GraphRequest.Callback() %7B%0A                            public void onCompleted(GraphResponse response) %7B%0A                                 /* handle the result */%0A%0A                                Log.d(logtag,response.toString());%0A%0A                            %7D%0A                        %7D%0A                ).executeAsync();%0A%0A
             %7D%0A%0A 
@@ -2768,24 +2768,59 @@
     %7D);%0A
+        //end facebook login button
 %0A    %7D%0A%0A
     @Ove
@@ -2803,32 +2803,33 @@
 n button%0A    %7D%0A%0A
+%0A
     @Override%0A  

fix facebook activity