@Override public void onSuccess(com.facebook.login.LoginResult loginResult) { Profile facebookProfile = Profile.getCurrentProfile(); if (facebookProfile == null) { String errorMsg = InfoFromFacebookActivity.this.getResources().getString(R.string.facebook_error); errorMsg = errorMsg + "."; Snackbar.make(textViewFacebookName, errorMsg, Snackbar.LENGTH_LONG).show(); textViewFacebookName.setText(errorMsg); } else { facebookProfilePhoto.setProfileId(facebookProfile.getId()); textViewFacebookName.setText(facebookProfile.getName()); buttonAck.setEnabled(true); buttonSwitch.setVisibility(Button.VISIBLE); } // TODO: Do not store access token - it is a security issue storing this // TODO and appears to be of no benefit. // AccessToken token = loginResult.getAccessToken(); // DataHolder data = DataHolder.getInstance(InfoFromFacebookActivity.this.getApplicationContext()); // data.setFacebookToken(token.getToken()); // data.persist(); }
private void initFBSdk() { if (!FacebookSdk.isInitialized()) { FacebookSdk.setApplicationId(ApiObjects.facebook.get("app_id")); FacebookSdk.sdkInitialize(getActivity().getApplicationContext()); } callbackManager = CallbackManager.Factory.create(); profileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { if (eventHandler != null) { if (currentProfile != null) eventHandler.onFacebookLoggedIn(); } } }; }
@Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getActivity().getApplicationContext()); callbackManager = CallbackManager.Factory.create(); accessTokenTracker = new AccessTokenTracker() { @Override protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) { } }; profileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { //Toast.makeText(getActivity(), "newProfile", Toast.LENGTH_SHORT).show(); //displayMessage(currentProfile); } }; accessTokenTracker.startTracking(); profileTracker.startTracking(); }
private void setFacebookRule() { callbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { EventBus.getDefault().post(MessageEvent.UPDATE_FACEBOOK_PROFILE); } @Override public void onCancel() { Log.d("Teste", "deu errp"); } @Override public void onError(FacebookException exception) { Log.d("ErrorF", exception.toString()); } } ); Profile profile = Profile.getCurrentProfile(); if (profile != null) { this.sidebar.showHideLogoff(true); } else { this.sidebar.showHideLogoff(false); } }
private String getImageStringFile() { try { URL image = new URL(Profile.getCurrentProfile() .getProfilePictureUri(140, 140).toString()); Resources res = getResources(); Bitmap src = BitmapFactory.decodeStream(image.openConnection().getInputStream()); ByteArrayOutputStream bYtE = new ByteArrayOutputStream(); src.compress(Bitmap.CompressFormat.PNG, 100, bYtE); src.recycle(); byte[] byteArray = bYtE.toByteArray(); return Base64.encodeToString(byteArray, Base64.DEFAULT); } catch (Exception e) { e.printStackTrace(); } return null; }
private void addTemplateTasks() { for (String task : NewEventActivity.TEMPLATE_TASKS[fromTemplateNumber]) { JSONObject json = new JSONObject(); String eventId = String.valueOf(newEventId); try { json.put("name", task); json.put("cost", 0); } catch (JSONException e) { e.printStackTrace(); } ServerHandler.executePost(eventId, ServerHandler.EVENT_TASKS, Profile.getCurrentProfile().getId(), "", json, j -> { if (j != null) SplitAppLogger.writeLog(1, "Post new Task on event Creation (RESULT): " + j.toString()); }); } }
private void updateUserData(String email) { Profile profile = Profile.getCurrentProfile(); mName.setText(profile.getName()); int photoDimention = getResources().getDimensionPixelSize(R.dimen.avatar_dimention); Picasso.with(this) .load(profile.getProfilePictureUri(photoDimention, photoDimention)) .transform(PicassoTransformations.getRoundedTransformation()) .error(R.drawable.ic_signup) .placeholder(R.drawable.ic_signup) .into(mPhotoProfile); if (!TextUtils.isEmpty(email)) { mEmail.setText(email); } }
/** * Start tracking profile. */ public void startProfileTracking() { //Track profile profileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged( Profile oldProfile, Profile currentProfile) { // App code comes here. if (currentProfile != null && Config.IS_DEBUG_MODE) Log.d(TAG, currentProfile.getName()); } }; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getActivity().getApplicationContext()); mCallbackManager = CallbackManager.Factory.create(); profileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { final Profile profile = currentProfile; if (profile != null) { final Thread thread = new Thread() { public void run() { createUserFromFacebook(profile); openListsOverview(); } }; thread.start(); } } }; printKeyHash(getActivity()); }
private void updateUI() { boolean loggedIn = AccessToken.getCurrentAccessToken() != null; Profile profile = Profile.getCurrentProfile(); if (loggedIn && (profile != null)) { profilePicture.setProfileId(profile.getId()); userName.setText(profile.getName()); name = profile.getName(); id = profile.getId(); // postLinkButton.setEnabled(true); // postPictureButton.setEnabled(true); } else { profilePicture.setProfileId(null); userName.setText(null); // postLinkButton.setEnabled(false); // postPictureButton.setEnabled(false); } }
/** * Metodo para obtener el nombre de usuario y la fotografia de Facebook */ private void ObtenerDatosFacebook() { //Para obtener datos del perfil tenemos que hacer un GraphRequest GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback() { @Override public void onCompleted(final JSONObject object, GraphResponse response) { //Obtenemos los datos del perfil Profile perfil = Profile.getCurrentProfile(); //Lo mostramos en pantalla y lo guardamos foto.setProfileId(perfil.getId()); nombre.setText(object.optString("name")); } }); //Añadimos los parametros que hemos requerido y ejecutamos la peticion Bundle parameters = new Bundle(); parameters.putString("fields", "name"); request.setParameters(parameters); request.executeAsync(); }
private void setFacebookAvatar() { Profile fbProfile = Profile.getCurrentProfile(); String profileImageUri = fbProfile.getProfilePictureUri(250, 250).toString(); GetSocial.User.setAvatarUrl(profileImageUri, new CompletionCallback() { @Override public void onSuccess() { _activityListener.invalidateUi(); } @Override public void onFailure(GetSocialException e) { // failed to set avatar url } }); }
private void finishLogin( AccessToken newToken, LoginClient.Request origRequest, FacebookException exception, boolean isCanceled, FacebookCallback<LoginResult> callback) { if (newToken != null) { AccessToken.setCurrentAccessToken(newToken); Profile.fetchProfileForCurrentAccessToken(); } if (callback != null) { LoginResult loginResult = newToken != null ? computeLoginResult(origRequest, newToken) : null; // If there are no granted permissions, the operation is treated as cancel. if (isCanceled || (loginResult != null && loginResult.getRecentlyGrantedPermissions().size() == 0)) { callback.onCancel(); } else if (exception != null) { callback.onError(exception); } else if (newToken != null) { callback.onSuccess(loginResult); } } }
private void successLogin() { loggedIn = true; accessToken = AccessToken.getCurrentAccessToken(); profile = Profile.getCurrentProfile(); if (profile != null) { Utils.d("Name: " + profile.getName()); } Utils.callScriptFunc("login", "true"); fetchUserInformationAndLogin(); }
public String dump() { StringBuffer buf = new StringBuffer(); buf.append("FacebookSDK is initialized: " + FacebookSdk.isInitialized() + "\n"); buf.append("FacebookSDK app id: " + FacebookSdk.getApplicationId() + "\n"); buf.append("FacebookSDK app name: " + FacebookSdk.getApplicationName() + "\n"); buf.append("FacebookSDK app signature: " + FacebookSdk.getApplicationSignature(this) + "\n"); buf.append("FacebookSDK client token: " + FacebookSdk.getClientToken() + "\n"); buf.append("FacebookSDK facebook domain: " + FacebookSdk.getFacebookDomain() + "\n"); buf.append("FacebookSDK version: " + FacebookSdk.getSdkVersion() + "\n"); buf.append("FacebookSDK debug enabled: " + FacebookSdk.isDebugEnabled() + "\n"); Profile profile = Profile.getCurrentProfile(); if (profile == null) { buf.append("Profile is null\n"); } else { buf.append("Profile: First Name: " + profile.getFirstName() + "\n"); buf.append("Profile: Last Name: " + profile.getLastName() + "\n"); buf.append("Profile: Name: " + profile.getName() + "\n"); buf.append("Profile: Id: " + profile.getId() + "\n"); buf.append("Profile: LinkURI: " + profile.getLinkUri() + "\n"); buf.append("Profile: Pic URI: " + profile.getProfilePictureUri(100, 100) + "\n"); } AccessToken currentToken = AccessToken.getCurrentAccessToken(); if (currentToken == null) { buf.append("Current Access Token is null\n"); } else { buf.append("CurToken: tok: " + currentToken.getToken() + "\n"); buf.append("CurToken: appid: " + currentToken.getApplicationId() + "\n"); buf.append("CurToken: expires: " + currentToken.getExpires().toString() + "\n"); } return buf.toString(); }
private void initProfileTracker() { mProfileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { // Toast.makeText(mActivity, "Facebook current profile changed", Toast.LENGTH_SHORT) // .show(); } }; }
@Override public void getFacebookLink(LoginResult loginResult) { Log.d("123", "loginResult " + loginResult.getAccessToken().getToken() + " " + loginResult.getAccessToken().getUserId() + "\n"); Log.d("123", "Profile " + Profile.getCurrentProfile().getId() + " "); FacebookLinkInform inform = new FacebookLinkInform(); inform.setToken(AccessToken.getCurrentAccessToken().getToken()); inform.setUserId(Long.parseLong(AccessToken.getCurrentAccessToken().getUserId())); inform.setFullName(Profile.getCurrentProfile().getName()); if (inform.getToken() != null && inform.getUserId() != null) { presenter.refreshLinkedInfInView(inform); } }
/** * This method disabled the play button when a user has already played that game. Otherwise, the button is enabled. * * @param dataModel a given OnlineMatch * @param viewHolder the gui * @return true if the button should be enabled. */ private boolean disablePlayButton(OnlineMatch dataModel,ViewHolder viewHolder) { String playerID = Profile.getCurrentProfile().getId(); if(dataModel.getFirstplayer().getId().equals(playerID)){ if(viewHolder.scoreP1.getText().equals("")) return false; } if(dataModel.getSecondplayer().getId().equals(playerID)) { if (viewHolder.scoreP2.getText().equals("")) return false; } return true; }
@Override public void saveNewMeal() { Meal meal = new Meal(Profile.getCurrentProfile().getId(), appetizer, entree, dessert, beverage); MealsFirebaseIO mealsFirebaseIO = new MealsFirebaseIO(); mealsFirebaseIO.saveMeal(meal, new MealsFirebaseIO.OnMealSavedResult() { @Override public void onMealSaved() { if (appetizer!=null){ mvpView.onMealSaved(); } } }); }
@Override public void onSuccess(LoginResult loginResult) { AccessToken accessToken = loginResult.getAccessToken(); Profile profile = Profile.getCurrentProfile(); //displayMessage(profile); //Toast.makeText(getActivity(), "profile", Toast.LENGTH_SHORT).show(); }
private void notifySignInSuccess(Profile profile) { SocialNetworkAccount socialNetworkAccount = new SocialNetworkAccount( IdentityProvider.FACEBOOK, profile.getId(), AccessToken.getCurrentAccessToken().getToken(), profile.getFirstName(), profile.getLastName() ); if (authMode.canStoreToken()) { SocialNetworkTokens.facebook().storeToken(AccessToken.getCurrentAccessToken()); } onAuthenticationSuccess(socialNetworkAccount); }
@Override public void onSuccess(LoginResult loginResult) { DebugLog.i("Facebook login success"); if (Profile.getCurrentProfile() == null) { DebugLog.i("Can't get access to FB profile"); facebookProfileTracker.startTracking(); } else { notifySignInSuccess(Profile.getCurrentProfile()); } }
@Override protected void onCurrentProfileChanged(Profile profile, Profile profile2) { if (profile2 != null) { notifySignInSuccess(profile2); if (facebookProfileTracker.isTracking()) { facebookProfileTracker.stopTracking(); } } }
/** * Initialises both player objects and sets the reference objects. */ private void initDBComponents() { opponent = null; opponentId = null; myself = new Player(Profile.getCurrentProfile().getId(), Profile.getCurrentProfile().getFirstName(), sudoku); availableUsersReference = FirebaseDatabase.getInstance().getReference().child("available"); playersReference = FirebaseDatabase.getInstance().getReference().child("players"); }
/** * Initialises buttons on this xml with their respective elements. Updates facebook profile if * changed because the Profile is loaded asynchronously so it returns null right after log in. */ private void initComponents() { playButton = (Button) findViewById(R.id.playButton); solveButton = (Button) findViewById(R.id.solveButton); logOutButton = (Button) findViewById(R.id.log_out_button); welcomeView = (TextView) findViewById(R.id.user_name); profilePictureView = (ProfilePictureView) findViewById(R.id.profile_picture); // Checks if the profile is changed and hence current profile is null. If so updates the profile if (Profile.getCurrentProfile() != null) { welcomeView.setText(WELCOME_TAG + Profile.getCurrentProfile().getName()); profilePictureView.setProfileId(Profile.getCurrentProfile().getId()); } else { ProfileTracker profileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { this.stopTracking(); Profile.setCurrentProfile(currentProfile); profilePictureView.setProfileId(currentProfile.getId()); welcomeView.setText(WELCOME_TAG + currentProfile.getName()); } }; profileTracker.startTracking(); } intentPlay = new Intent(this, PlayActivity.class); intentSolve = new Intent(this, SolveActivity.class); intentLogIn = new Intent(this, LogInActivity.class); }
public static void sendGroupMessage(String message, String groupName, String[] friendList) { if (mRoom == null) { return; } mRoom.addResponse(message, Profile.getCurrentProfile().getId()); AddGroupResponseTask task = new AddGroupResponseTask(groupName, friendList); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
public static void sendFriendMessage(String message, String friendId, String friendName) { if (mSession == null) { return; } mSession.addResponse(message, Profile.getCurrentProfile().getId()); AddResponseTask task = new AddResponseTask(friendId, friendName); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
/** * Adds an user response to the chat log * * @param message Message to add * @param userId Sender id */ public void addResponse(String message, String userId) { if (userId.equals(mFriendId)) { addFriendResponse(message); return; } if (userId.equals(Profile.getCurrentProfile().getId())) { addPersonalResponse(message); return; } SplitAppLogger.writeLog(SplitAppLogger.WARN, "Response from unknown id:" + userId + " - " + message); }
private void addNavHeader(NavigationView navigationView) { View header = navigationView.getHeaderView(0); CircularImageView userPic = (CircularImageView) header.findViewById(R.id.user_pic); Profile profile = Profile.getCurrentProfile(); FacebookManager.fillWithUserPic(profile.getId(), userPic, getApplicationContext()); TextView username = (TextView) header.findViewById(R.id.user_id); username.setText(profile.getName()); ImageView background = (ImageView) header.findViewById(R.id.nav_background); FacebookManager.fillWithUserCover(profile.getId(), background, getApplicationContext()); }
private void setAttendeesList(JSONArray attendees) throws JSONException { SplitAppLogger.writeLog(SplitAppLogger.DEBG, attendees.toString()); ArrayList<String> attendes = new ArrayList<>(); for (int i = 0; i < attendees.length(); i++) { String id = attendees.getJSONObject(i).getString("facebook_id"); SplitAppLogger.writeLog(SplitAppLogger.DEBG, id); if (!id.equals(Profile.getCurrentProfile().getId())) { attendes.add(id); } } mAttendees = attendes.toArray(new String[attendes.size()]); }
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_chat) { Intent intent = new Intent(this, ChatRoomActivity.class); intent.putExtra(ChatRoomActivity.EXTRA_FRIENDS_IDS, mAttendees); intent.putExtra(ChatRoomActivity.EXTRA_FRIENDS_NAMES, Profile.getCurrentProfile().getFirstName()); intent.putExtra(ChatRoomActivity.EXTRA_GROUP_NAME, mEventName); startActivity(intent); } if (id == R.id.action_add_task) { newTaskFragment = new NewTaskDialogFragment(); newTaskFragment.event_id = Integer.parseInt(id_event); FragmentManager fragmentManager = getSupportFragmentManager(); newTaskFragment.show(fragmentManager, "newTask"); return true; } if (id == R.id.action_add_people) { Intent friendChooser = new Intent(this, FriendChooserActivity.class); friendChooser.putExtra(FriendChooserActivity.FROM_CURRENT_EVENT, true); friendChooser.putStringArrayListExtra(FriendChooserActivity.ALREADY_INVITED, inviteesID); startActivityForResult(friendChooser, FRIEND_CHOOSER_REQUEST); return true; } return super.onOptionsItemSelected(item); }
/** * Adds an user response to the chat log * * @param message Message to add * @param userId Sender id */ public void addResponse(String message, String userId) { if (userId.equals(Profile.getCurrentProfile().getId())) { addPersonalResponse(message); return; } addFriendResponse(message, "", userId); }
private void setupProfileTracker() { mProfileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { Log.d("scion", "" + currentProfile); } }; }
@Override protected void onStart() { super.onStart(); // Bypass LoginActivity if the user is already logged in: if (Profile.getCurrentProfile() != null) { startActivity(new Intent(this, MainActivity.class)); } }
public static boolean setFacebookDetails() { Profile.fetchProfileForCurrentAccessToken(); // try to get from Profile if (Profile.getCurrentProfile() != null) { username = Profile.getCurrentProfile().getFirstName(); picture = Profile.getCurrentProfile().getProfilePictureUri(200, 200); } else { //if Profile has not yet been updated, then //manually send a request to Graph API to get the name GraphRequest request = GraphRequest.newMeRequest( AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback() { @Override public void onCompleted( JSONObject object, GraphResponse response) { username = object.optString("name"); picture = (Uri) object.opt("picture"); } }); Bundle parameters = new Bundle(); parameters.putString("fields", "id,name,link,picture"); request.setParameters(parameters); request.executeAsync(); } return true; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scar); // Intent i = getIntent(); // latit = i.getStringExtra("lati"); // longtit = i.getStringExtra("longti"); // System.out.println(latit + longtit); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); View nav_header = LayoutInflater.from(this).inflate(R.layout.nav_header_main, null); profile = Profile.getCurrentProfile(); ((TextView)nav_header.findViewById(R.id.data_ffffffname)).setText(profile.getName()); ((ProfilePictureView)nav_header.findViewById(R.id.profile_picture)).setProfileId(profile.getId()); navigationView.addHeaderView(nav_header); mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.container); mViewPager.setAdapter(mSectionsPagerAdapter); tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); new SimpleTask().execute("http://203.151.92.179:8080/getuserprofile?id=" + MemberStatic.getFbID()); }