Search in sources :

Example 6 with SignedInUser

use of com.instructure.loginapi.login.model.SignedInUser in project instructure-android by instructure.

the class PreviousUsersUtils method removeByToken.

public static boolean removeByToken(Context context, String token) {
    ArrayList<SignedInUser> signedInUsers = get(context);
    boolean removedUser = false;
    for (SignedInUser user : signedInUsers) {
        if (user.token.equals(token)) {
            remove(context, user);
            removedUser = true;
        }
    }
    return removedUser;
}
Also used : SignedInUser(com.instructure.loginapi.login.model.SignedInUser)

Example 7 with SignedInUser

use of com.instructure.loginapi.login.model.SignedInUser in project instructure-android by instructure.

the class PreviouslySignedInUserAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
    final SignedInUser signedInUser = previouslySignedInUsers.get(position);
    String globalID = OAuthWebLogin.getGlobalUserId(signedInUser.domain, signedInUser.user);
    final ViewHolder viewHolder;
    if (convertView == null) {
        convertView = layoutInflater.inflate(R.layout.previously_signed_in_user, null);
        viewHolder = new ViewHolder();
        viewHolder.name = (TextView) convertView.findViewById(R.id.name);
        viewHolder.domain = (TextView) convertView.findViewById(R.id.domain);
        viewHolder.avatar = (CircleImageView) convertView.findViewById(R.id.avatar);
        viewHolder.progressBar = (ProgressBar) convertView.findViewById(R.id.loading);
        viewHolder.delete = (ImageView) convertView.findViewById(R.id.delete);
        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }
    viewHolder.delete.setImageDrawable(activity.getResources().getDrawable(R.drawable.ic_cv_login_x));
    ProfileUtils.configureAvatarView(activity, signedInUser.user, viewHolder.avatar);
    viewHolder.name.setText(signedInUser.user.getShortName());
    viewHolder.domain.setText(signedInUser.domain);
    if (selectedUserGlobalId == null) {
        viewHolder.delete.setVisibility(View.VISIBLE);
    } else {
        viewHolder.delete.setVisibility(View.GONE);
    }
    // Handle deleting items.
    viewHolder.delete.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // Make sure they actually want to delete that user.
            userToRemove = signedInUser;
            genericDialogStyled = GenericDialogStyled.newInstance(R.string.removeUser, R.string.removedForever, R.string.confirm, R.string.cancel, R.drawable.ic_cv_information_light, PreviouslySignedInUserAdapter.this);
            genericDialogStyled.show(activity.getSupportFragmentManager(), "Delete confirmation");
        }
    });
    if (globalID.equals(selectedUserGlobalId)) {
        viewHolder.progressBar.setVisibility(View.VISIBLE);
    } else {
        viewHolder.progressBar.setVisibility(View.GONE);
    }
    return convertView;
}
Also used : SignedInUser(com.instructure.loginapi.login.model.SignedInUser) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) TextView(android.widget.TextView) View(android.view.View)

Example 8 with SignedInUser

use of com.instructure.loginapi.login.model.SignedInUser in project instructure-android by instructure.

the class ApplicationManager method switchUsers.

/**
 * Switch out the current signed in user. Temporarily remove credentials. Save them elsewhere so we can repopulate it when necessary.
 *
 * @return
 */
public boolean switchUsers() {
    if (!OAuthWebLogin.isMultipleUsersSupported(getApplicationContext(), MULTI_SIGN_IN_PREF_NAME)) {
        return false;
    }
    SignedInUser signedInUser = new SignedInUser();
    signedInUser.user = APIHelpers.getCacheUser(this);
    signedInUser.domain = APIHelpers.getDomain(this);
    signedInUser.protocol = APIHelpers.loadProtocol(this);
    signedInUser.token = APIHelpers.getToken(this);
    signedInUser.lastLogoutDate = new Date();
    // Save Signed In User to sharedPreferences
    OAuthWebLogin.addToPreviouslySignedInUsers(signedInUser, getApplicationContext(), ApplicationManager.OTHER_SIGNED_IN_USERS_PREF_NAME);
    // Clear shared preferences, but keep the important stuff.
    safeClearSharedPreferences();
    // CLear masquerading preferences.
    clearMasqueradingPreferences();
    // Clear all Shared Preferences.
    APIHelpers.clearAllData(this);
    return true;
}
Also used : SignedInUser(com.instructure.loginapi.login.model.SignedInUser) Date(java.util.Date)

Aggregations

SignedInUser (com.instructure.loginapi.login.model.SignedInUser)8 View (android.view.View)3 TextView (android.widget.TextView)3 SharedPreferences (android.content.SharedPreferences)2 ImageView (android.widget.ImageView)2 Gson (com.google.gson.Gson)2 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 Intent (android.content.Intent)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 AdapterView (android.widget.AdapterView)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 ListView (android.widget.ListView)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 PreviousUsersAdapter (com.instructure.loginapi.login.adapter.PreviousUsersAdapter)1 Date (java.util.Date)1