public void updateUI(boolean isSignedIn) { if (isSignedIn) { getActionBar().setTitle("My Profile"); logo.setVisibility(View.GONE); header.setVisibility(View.GONE); title.setVisibility(View.GONE); // loginTwitter.setVisibility(View.GONE); btnLoginTwitter.setVisibility(View.GONE); btnSignIn.setVisibility(View.GONE); loginNormal.setVisibility(View.GONE); authButton.setVisibility(View.GONE); btnSignOut.setVisibility(View.GONE); btnRevokeAccess.setVisibility(View.VISIBLE); btnProceed.setVisibility(View.VISIBLE); llProfileLayout.setVisibility(View.VISIBLE); } else { logo.setVisibility(View.VISIBLE); header.setVisibility(View.VISIBLE); title.setVisibility(View.VISIBLE); // loginTwitter.setVisibility(View.VISIBLE); btnLoginTwitter.setVisibility(View.VISIBLE); btnSignIn.setVisibility(View.VISIBLE); loginNormal.setVisibility(View.VISIBLE); authButton.setVisibility(View.VISIBLE); btnSignOut.setVisibility(View.GONE); btnRevokeAccess.setVisibility(View.GONE); btnProceed.setVisibility(View.GONE); llProfileLayout.setVisibility(View.GONE); } }
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); if (savedInstanceState != null) { String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY); pendingAction = PendingAction.valueOf(name); } loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setReadPermissions( Arrays.asList("public_profile", "email", "user_likes", "user_status")); loginButton.setUserInfoChangedCallback( new LoginButton.UserInfoChangedCallback() { @Override public void onUserInfoFetched(GraphUser user) { LoginActivity.this.user = user; updateUI(); // It's possible that we were waiting for this.user to // be populated in order to post a // status update. handlePendingAction(); } }); init(); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate( AirFacebookExtension.context.getResourceId("layout.com_facebook_usersettingsfragment"), container, false); loginButton = (LoginButton) view.findViewById( AirFacebookExtension.context.getResourceId( "id.com_facebook_usersettingsfragment_login_button")); loginButton.setProperties(loginButtonProperties); loginButton.setFragment(this); Session session = getSession(); if (session != null && !session.equals(Session.getActiveSession())) { loginButton.setSession(session); } connectedStateLabel = (TextView) view.findViewById( AirFacebookExtension.context.getResourceId( "id.com_facebook_usersettingsfragment_profile_name")); // if no background is set for some reason, then default to Facebook blue if (view.getBackground() == null) { view.setBackgroundColor( getResources() .getColor(AirFacebookExtension.context.getResourceId("color.com_facebook_blue"))); } else { view.getBackground().setDither(true); } return view; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); Globals.settings = getSharedPreferences(Globals.PREFERNCES, 0); Globals.USER_PROF_ID = Globals.settings.getString(Globals.USER_PROF_ID_KEY, ""); Globals.USER_NAME = Globals.settings.getString(Globals.USER_NAME_KEY, ""); Globals.bProfileLoaded = Globals.settings.getBoolean(Globals.LOGGED_IN_KEY, false); Globals.UNIQ_ID = Globals.settings.getLong(Globals.PROPERTY_UNIQ_ID, 0); Globals.DEVICE_REG_ID = Globals.settings.getString(Globals.PROPERTY_REG_ID, ""); LoginButton button = (LoginButton) findViewById(R.id.authButton); button.setReadPermissions(Arrays.asList("user_friends")); callback = new Session.StatusCallback() { @Override public void call(Session session, SessionState state, Exception exception) { onSessionStateChange(state); } }; uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); Log.i("LoginActivity", "onCreate"); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.splash, container, false); LoginButton loginButton = (LoginButton) view.findViewById(R.id.login_button); loginButton.setFragment(this); loginButton.setReadPermissions(Arrays.asList("read_friendlists")); return view; }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Set up the layout View view = inflater.inflate(R.layout.activity_main, container, false); // To allow the fragment to receive the onActivityResult() call rather than the activity LoginButton authButton = (LoginButton) view.findViewById(R.id.authButton); authButton.setFragment(this); // Ask for permissions other than the basic permissions authButton.setReadPermissions(Arrays.asList("user_likes", "user_status")); return view; }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_login, container, false); ButterKnife.inject(this, view); mLoginButton.setFragment(this); return view; }
/** * Set the Session object to use instead of the active Session. Since a Session cannot be reused, * if the user logs out from this Session, and tries to log in again, a new Active Session will be * used instead. * * <p>If the passed in session is currently opened, this method will also attempt to load some * user information for display (if needed). * * @param newSession the Session object to use * @throws com.facebook.FacebookException if errors occur during the loading of user information */ @Override public void setSession(Session newSession) { super.setSession(newSession); if (loginButton != null) { loginButton.setSession(newSession); } fetchUserInfo(); updateUI(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); // Font path String fontPath = "font/sigward.ttf"; // text view label TextView txtGhost = (TextView) findViewById(R.id.textView8); // Loading Font Face Typeface tf = Typeface.createFromAsset(getAssets(), fontPath); // Applying font txtGhost.setTypeface(tf); txtGhost.setTextSize(30); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); // Remove divider under actionbar getActionBar().setBackgroundDrawable(null); loginNormal = (Button) findViewById(R.id.loginNormal); loginNormal.setBackgroundColor(Color.TRANSPARENT); loginNormal.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(LoginActivity.this, NavigationActivity.class); startActivity(i); finish(); } }); btnSignIn = (ImageButton) findViewById(R.id.loginGPlus); btnSignOut = (Button) findViewById(R.id.btn_sign_out); btnRevokeAccess = (Button) findViewById(R.id.btn_revoke_access); imgProfilePic = (ImageView) findViewById(R.id.imgProfilePic); profileName = (TextView) findViewById(R.id.profileName); profileEmail = (TextView) findViewById(R.id.profileEmail); llProfileLayout = (LinearLayout) findViewById(R.id.llProfileLayout); btnProceed = (Button) findViewById(R.id.btn_proceed); logo = (ImageView) findViewById(R.id.loginLogo); header = (TextView) findViewById(R.id.textView8); title = (TextView) findViewById(R.id.loginTitle); // Button click listeners btnSignIn.setOnClickListener(this); btnSignOut.setOnClickListener(this); btnRevokeAccess.setOnClickListener(this); btnProceed.setOnClickListener(this); // Initializing google plus api client mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(Plus.API) .addScope(Plus.SCOPE_PLUS_LOGIN) .build(); // TWITTER if (TWITTER_CONSUMER_KEY.trim().length() == 0 || TWITTER_CONSUMER_SECRET.trim().length() == 0) { // Internet Connection is not present alert.showAlertDialog( LoginActivity.this, "Twitter oAuth tokens", "Please set your twitter oauth tokens first!", false); // stop executing code by return return; } // All UI elements btnLoginTwitter = (ImageButton) findViewById(R.id.btnLoginTwitter); btnLoginTwitter.setBackgroundResource(R.drawable.ic_twitter); mSharedPreferences = getApplicationContext().getSharedPreferences("MyPref", 0); /** Twitter login button click event will call loginToTwitter() function */ btnLoginTwitter.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { // Call login twitter function new TwitterLoginTask().execute(); } }); if (!isTwitterLoggedInAlready()) { Uri uri = getIntent().getData(); if (uri != null && uri.toString().startsWith(TWITTER_CALLBACK_URL)) { // oAuth verifier String verifier = uri.getQueryParameter(URL_TWITTER_OAUTH_VERIFIER); new TwitterGetAccessTokenTask().execute(verifier); } } else { String userName = mSharedPreferences.getString(PREF_KEY_USER_NAME, ""); // // enableTwitterStatus(userName); } // For Twitter Login /* loginTwitter = (TwitterLoginButton) findViewById(R.id.loginTwitter); loginTwitter.setText(null); loginTwitter.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); loginTwitter.setBackgroundResource(R.drawable.ic_twitter); loginTwitter.setCallback(new Callback<TwitterSession>() { // TwitterSession session = // Twitter.getSessionManager().getActiveSession(); // TwitterAuthToken authToken = session.getAuthToken(); // String token = authToken.token; // String secret = authToken.secret; @Override public void success(Result<TwitterSession> result) { TwitterSession session = Twitter.getSessionManager().getActiveSession(); TwitterAuthToken authToken = session.getAuthToken(); String token = authToken.token; String secret = authToken.secret; long userid = session.getUserId(); // Do something with result, which provides a TwitterSession for making API calls // Do something with the result, which provides // the email address //loginTwitter.setReadPermissions(Arrays.asList("user_likes", "user_status", "email", "user_about_me", "user_location")); Toast.makeText(getApplicationContext(),"Welcome! "+session.getUserName() ,Toast.LENGTH_LONG).show(); Intent i = new Intent(LoginActivity.this, NavigationActivity.class); startActivity(i); } @Override public void failure(TwitterException exception) { // Do something on failure Toast.makeText(getApplicationContext(),"Login Failed",Toast.LENGTH_LONG).show(); } }); */ // For facebook Login authButton = (LoginButton) findViewById(R.id.loginFacebook); authButton.setBackgroundResource(R.drawable.ic_facebook); authButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); authButton.setReadPermissions( Arrays.asList("user_likes", "user_status", "email", "user_about_me", "user_location")); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); if (savedInstanceState != null) { String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY); pendingAction = PendingAction.valueOf(name); } setContentView(R.layout.new_login); loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setUserInfoChangedCallback( new LoginButton.UserInfoChangedCallback() { public void onUserInfoFetched(GraphUser user) { NewLogin.this.user = user; updateUI(); // It's possible that we were waiting for this.user to be populated in order to post a // status update. handlePendingAction(); } }); profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture); greeting = (TextView) findViewById(R.id.greeting); postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton); postStatusUpdateButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { onClickPostStatusUpdate(); } }); postPhotoButton = (Button) findViewById(R.id.postPhotoButton); postPhotoButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { onClickPostPhoto(); } }); pickFriendsButton = (Button) findViewById(R.id.pickFriendsButton); pickFriendsButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { onClickPickFriends(); } }); pickPlaceButton = (Button) findViewById(R.id.pickPlaceButton); pickPlaceButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { onClickPickPlace(); } }); controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container); final FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide the main UI controls and // b) hook up its listeners again. controlsContainer.setVisibility(View.GONE); } // Listen for changes in the back stack so we know if a fragment got popped off because the user // clicked the back button. fm.addOnBackStackChangedListener( new FragmentManager.OnBackStackChangedListener() { public void onBackStackChanged() { if (fm.getBackStackEntryCount() == 0) { // We need to re-show our UI. controlsContainer.setVisibility(View.VISIBLE); } } }); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mRoot = (DisableTouchFrameLayout) inflater.inflate(R.layout.start_fragment, null); mProgressBar = (ProgressBar) mRoot.findViewById(R.id.start_fragment_pb); mLoginBtn = (LoginButton) mRoot.findViewById(android.R.id.empty); mLoginBtn.setFragment(this); mAdapter = new SimpleCursorAdapter(getActivity(), R.layout.layout_item_friend, null, from, to, 0); mAdapter.setViewBinder( new ViewBinder() { @Override public boolean setViewValue(View view, Cursor cursor, int index) { int viewId = view.getId(); if (viewId == R.id.item_friend_image) { ImageView avatar = (ImageView) view; String photoUrl = cursor.getString(cursor.getColumnIndex(DBHelper.KEY_COLUMN_PICTURE)); if (mImageLoader != null && mOptions != null && photoUrl != null && !TextUtils.isEmpty(photoUrl)) mImageLoader.displayImage( photoUrl, avatar, mOptions, new ImageLoadingListener() { @Override public void onLoadingStarted(String arg0, View arg1) { activeDownloaders++; if (!UtilHelper.isImageDownloaded()) {} } @Override public void onLoadingFailed(String arg0, View arg1, FailReason arg2) { activeDownloaders--; if (!UtilHelper.isImageDownloaded() && !mCheckDisableTouch) { checkDisableTouch(); } } @Override public void onLoadingComplete(String arg0, View arg1, Bitmap arg2) { activeDownloaders--; if (!UtilHelper.isImageDownloaded() && !mCheckDisableTouch) { checkDisableTouch(); } } @Override public void onLoadingCancelled(String arg0, View arg1) { activeDownloaders--; if (!UtilHelper.isImageDownloaded() && !mCheckDisableTouch) { checkDisableTouch(); } } }); return true; } return false; } }); setListAdapter(mAdapter); getLoaderManager().restartLoader(FRIENDS_LOADER_ID, null, this); return mRoot; }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Get the layout inflater LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.register_dialog, null); mFirstNameReg = (EditText) view.findViewById(R.id.firstNameReg); mFirstNameReg.requestFocus(); mFirstNameReg.setOnFocusChangeListener( new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { getActivity() .getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); } } }); mLastNameReg = (EditText) view.findViewById(R.id.lastNameReg); mEmailReg = (EditText) view.findViewById(R.id.emailReg); mPasswordReg = (EditText) view.findViewById(R.id.passwordReg); mRePasswordReg = (EditText) view.findViewById(R.id.rePasswordReg); mFacebookLoginButton = (LoginButton) view.findViewById(R.id.facebookLoginButton); mFacebookLoginButton.setReadPermissions("email", "public_profile"); mFacebookLoginButton.setApplicationId(getActivity().getResources().getString(R.string.app_id)); mFacebookLoginButton.setUserInfoChangedCallback( new LoginButton.UserInfoChangedCallback() { @Override public void onUserInfoFetched(GraphUser user) { if (user != null) { mFacebookUser = user; mListener.onRegisterDialogFacebookClick(RegisterDialog.this); } } }); mUiHelper = new UiLifecycleHelper(getActivity(), null); mUiHelper.onCreate(savedInstanceState); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout builder .setView(view) // Add action buttons .setPositiveButton( R.string.register, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) {} }) .setNegativeButton( R.string.go_to_login, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { mListener.onRegisterDialogNegativeClick(RegisterDialog.this); } }) .setCancelable(false); Dialog d = builder.create(); d.setCancelable(false); d.setCanceledOnTouchOutside(false); setCancelable(false); return d; }