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;
}
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;
}
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;
}
Aggregations