///** // * Copyright 2010-present Facebook. // * // * Licensed under the Apache License, Version 2.0 (the "License"); // * you may not use this file except in compliance with the License. // * You may obtain a copy of the License at // * // * http://www.apache.org/licenses/LICENSE-2.0 // * // * Unless required by applicable law or agreed to in writing, software // * distributed under the License is distributed on an "AS IS" BASIS, // * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // * See the License for the specific language governing permissions and // * limitations under the License. // */ // //package com.ved.musicmapapp; // //import java.util.ArrayList; //import java.util.Arrays; //import java.util.List; // //import org.json.JSONArray; //import org.json.JSONException; //import org.json.JSONObject; // //import android.app.Activity; //import android.app.ProgressDialog; //import android.content.Intent; //import android.content.SharedPreferences; //import android.content.SharedPreferences.Editor; //import android.graphics.Typeface; //import android.os.Bundle; //import android.util.Log; //import android.view.View; //import android.view.View.OnClickListener; //import android.widget.Button; //import android.widget.TextView; // //import com.facebook.HttpMethod; //import com.facebook.LoggingBehavior; //import com.facebook.Request; //import com.facebook.Response; //import com.facebook.Session; //import com.facebook.SessionState; //import com.facebook.Settings; //import com.facebook.model.GraphObject; //import com.facebook.model.GraphUser; ////import com.restfb.DefaultFacebookClient; ////import com.restfb.FacebookClient; ////import com.restfb.json.JsonObject; //import com.ved.musicmapapp.Objects.Friend; //import com.ved.musicmapapp.fragments.YouFollowFragment; //import com.ved.musicmapapp.utils.Statics; // //public class Test extends Activity implements OnClickListener{ // // private static final String PERMISSION = "publish_actions"; // private View btnLogin; // // private Session.StatusCallback statusCallback; // private ProgressDialog pd; // private Button tab_join, tab_about; // private TextView txt_hello, txt_welcome; // private SharedPreferences prefs; // private Editor edt; // //// FacebookClient userFBClient; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.layout_login_facebook); // // prefs = getSharedPreferences("MUSIC_MAP", MODE_PRIVATE); // edt = prefs.edit(); // // String str = "10. My+love+will+go+on"; // Statics.showToast(getBaseContext(), str.replaceAll("[^a-zA-Z 0-9],_", " ")); // // // findViewById(R.id.imv_three_line).setVisibility(View.INVISIBLE); // findViewById(R.id.imv_search).setVisibility(View.INVISIBLE); // // btnLogin = findViewById(R.id.btn_login); // tab_join = (Button)findViewById(R.id.tab_join); // tab_about = (Button)findViewById(R.id.tab_about); // // btnLogin.setOnClickListener(this); // tab_join.setOnClickListener(this); // tab_about.setOnClickListener(this); // // tab_join.setBackgroundResource(R.drawable.bg_tab_press); // // // Typeface tf = Typeface.createFromAsset(getAssets(), "font.otf"); // tab_join.setTypeface(tf); // tab_about.setTypeface(tf); // // Typeface tf1 = Typeface.createFromAsset(getAssets(), "font1.otf"); // Typeface tf2 = Typeface.createFromAsset(getAssets(), "HATTEN.TTF"); // txt_hello = (TextView)findViewById(R.id.txt_hello); // txt_welcome = (TextView)findViewById(R.id.txt_welcome); // txt_hello.setTypeface(tf1); // txt_welcome.setTypeface(tf2); // // pd = new ProgressDialog(this); // pd.setMessage("Logging..."); // pd.setCancelable(false); // // if(getIntent().getBooleanExtra("LOGOUT", false)){ // onClickLogout(); // } // // initFacebook(savedInstanceState); //// //// if(Session.getActiveSession() != null && prefs.getString("USER_ID", "").length() > 0){ //// finish(); //// startActivity(new Intent(this, MainActivity.class)); //// return; //// } // // updateView(); // } // private void initFacebook(Bundle savedInstanceState){ // statusCallback= new SessionStatusCallback(); // Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS); // Session session = Session.getActiveSession(); // if (session == null) { // if (savedInstanceState != null) { // session = Session.restoreSession(this, null, statusCallback, savedInstanceState); // } // if (session == null) { // session = new Session(this); // } // Session.setActiveSession(session); // } // } // private void performFacebookPermisson(){ // List<String> readPermissions = Arrays.asList("email","user_education_history", "user_interests", // "user_friends","user_work_history","user_birthday","user_hometown", // "user_location", "user_religion_politics"); // // Session session = Session.getActiveSession(); // if(session!=null && session.isOpened() && !session.getPermissions().contains(readPermissions)){ // session.requestNewPublishPermissions(new Session.NewPermissionsRequest(this, readPermissions)); // } // } // @Override // public void onStart() { // super.onStart(); // Session.getActiveSession().addCallback(statusCallback); // } // // @Override // public void onStop() { // super.onStop(); // Session.getActiveSession().removeCallback(statusCallback); // } // // @Override // public void onActivityResult(int requestCode, int resultCode, Intent data) { // super.onActivityResult(requestCode, resultCode, data); // Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data); // } // // @Override // protected void onSaveInstanceState(Bundle outState) { // super.onSaveInstanceState(outState); // Session session = Session.getActiveSession(); // Session.saveSession(session, outState); // } // // private void updateView() { // final Session session = Session.getActiveSession(); // if (session.isOpened()) { // //// tv_login.setText("Logout"); //// btnLogin.setOnClickListener(new OnClickListener() { //// public void onClick(View view) { onClickLogout(); } //// }); // performFacebookPermisson(); // if (session != null && session.isOpened()) { // // If the session is open, make an API call to get user data // // and define a new callback to handle the response // // if(prefs.getString("USER_ID", "").length() > 0){ // Log.i("=====","2"); // analyeJSON(); //// finish(); //// startActivity(new Intent(this, MainActivity.class)); // return; // } // pd.show(); // // Request request = Request.newMeRequest(session, new Request.GraphUserCallback() { // @Override // public void onCompleted(GraphUser user, Response response) { // // If the response is successful // if (user != null) { // edt.putString("USER_ID", user.getId()); // edt.putString("USER_NAME", user.getName()); // edt.commit(); // Log.i("=====","1"); // //================= // getFaceAccInfo(user); // //================ // // pd.dismiss(); // //// finish(); //// startActivity(new Intent(LoginAcitivity.this, MainActivity.class)); // } // } // }); // // Request.executeBatchAsync(request); // } // } // } // // // private void onClickLogin() { // Session session = Session.getActiveSession(); // performFacebookPermisson(); // if (!session.isOpened() && !session.isClosed()) { // session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback)); // } else { // Session.openActiveSession(this, true, statusCallback); // } // } // // private void onClickLogout() { // edt.putString("USER_ID", ""); // edt.putString("USER_NAME", ""); // edt.commit(); // // Session session = Session.getActiveSession(); // if (!session.isClosed()) { // session.closeAndClearTokenInformation(); // } // } // // private class SessionStatusCallback implements Session.StatusCallback { // @Override // public void call(Session session, SessionState state, Exception exception) { // updateView(); // } // } // // // @Override // public void onClick(View v) { // if(v.getId() == R.id.btn_login){ // onClickLogin(); // }else if(v.getId() == R.id.tab_join){ // tab_join.setBackgroundResource(R.drawable.bg_tab_press); // tab_about.setBackgroundResource(R.drawable.bg_btn_tab); // }else if(v.getId() == R.id.tab_about){ // tab_join.setBackgroundResource(R.drawable.bg_btn_tab); // tab_about.setBackgroundResource(R.drawable.bg_tab_press); // } // } // // private void getFaceAccInfo(GraphUser graph_user){ // if(!pd.isShowing()) pd.show(); // String fqlQuery = "SELECT uid, first_name, last_name, name, email, birthday_date," + // "about_me, sex, religion, languages, locale, " + // "music, movies, books, games, favorite_athletes," + // "inspirational_people, favorite_teams, work, education " + // "FROM user WHERE uid="+graph_user.getId(); // Bundle params = new Bundle(); // params.putString("q", fqlQuery); // Session session = Session.getActiveSession(); // Request request = new Request(session,"/fql", params,HttpMethod.GET, new Request.Callback(){ // public void onCompleted(Response response) { // GraphObject graphObject = response.getGraphObject(); // JSONObject jsonObject = graphObject.getInnerJSONObject(); // // // SharedPreferences.Editor prefsEditor = prefs.edit(); // prefsEditor.putString("facebook_json",jsonObject.toString()); // prefsEditor.commit(); // // // analyeJSON(); // } // }); // Request.executeBatchAsync(request); // } // // private void analyeJSON(){ // String json=prefs.getString("facebook_json", ""); // Log.i("=====================facebook_json===========================", "= "+json); // } // // public void click1(View v) { // onClickLogout(); // } //}