use of com.owncloud.android.lib.common.UserInfo in project android by nextcloud.
the class UserInfoActivity method fetchAndSetData.
private void fetchAndSetData() {
Thread t = new Thread(() -> {
NextcloudClient nextcloudClient;
try {
nextcloudClient = OwnCloudClientFactory.createNextcloudClient(user.toPlatformAccount(), this);
} catch (AccountUtils.AccountNotFoundException e) {
Log_OC.e(this, "Error retrieving user info", e);
return;
}
RemoteOperationResult<UserInfo> result = new GetUserInfoRemoteOperation().execute(nextcloudClient);
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
if (result.isSuccess() && result.getResultData() != null) {
userInfo = result.getResultData();
runOnUiThread(() -> populateUserInfoUi(userInfo));
} else {
// show error
runOnUiThread(() -> setErrorMessageForMultiList(getString(R.string.user_information_retrieval_error), result.getLogMessage(), R.drawable.ic_list_empty_error));
Log_OC.d(TAG, result.getLogMessage());
}
}
});
t.start();
}
use of com.owncloud.android.lib.common.UserInfo in project android by nextcloud.
the class UserInfoActivityIT method fullUserInfoDetail.
@Test
@ScreenshotTest
public void fullUserInfoDetail() {
final Intent intent = new Intent(targetContext, UserInfoActivity.class);
intent.putExtra(UserInfoActivity.KEY_ACCOUNT, user);
UserInfo userInfo = new UserInfo("test", true, "Firstname Familyname", "oss@rocks.com", "+49 7613 672 255", "Awesome Place Av.", "https://www.nextcloud.com", "nextclouders", null, null);
intent.putExtra(UserInfoActivity.KEY_USER_DATA, userInfo);
UserInfoActivity sut = activityRule.launchActivity(intent);
shortSleep();
shortSleep();
screenshot(sut);
}
use of com.owncloud.android.lib.common.UserInfo in project android by nextcloud.
the class ManageAccountsActivityIT method userInfoDetail.
@Test
@ScreenshotTest
public void userInfoDetail() {
ManageAccountsActivity sut = activityRule.launchActivity(null);
User user = sut.accountManager.getUser();
UserInfo userInfo = new UserInfo("test", true, "Test User", "test@nextcloud.com", "+49 123 456", "Address 123, Berlin", "https://www.nextcloud.com", "https://twitter.com/Nextclouders", new Quota(), new ArrayList<>());
sut.showUser(user, userInfo);
shortSleep();
shortSleep();
screenshot(getCurrentActivity());
}
use of com.owncloud.android.lib.common.UserInfo in project android by nextcloud.
the class GetUserProfileOperation method run.
/**
* Performs the operation.
*
* Target user account is implicit in 'client'.
*
* Stored account is implicit in {@link #getStorageManager()}.
*
* @return Result of the operation. If successful, includes an instance of
* {@link String} with the display name retrieved from the server.
* Call {@link RemoteOperationResult#getData()}.get(0) to get it.
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
// get display name
GetRemoteUserInfoOperation getDisplayName = new GetRemoteUserInfoOperation();
RemoteOperationResult result = getDisplayName.execute(client);
if (result.isSuccess()) {
// store display name with account data
AccountManager accountManager = AccountManager.get(MainApp.getAppContext());
UserInfo userInfo = (UserInfo) result.getData().get(0);
Account storedAccount = getStorageManager().getAccount();
accountManager.setUserData(storedAccount, AccountUtils.Constants.KEY_DISPLAY_NAME, userInfo.getDisplayName());
accountManager.setUserData(storedAccount, AccountUtils.Constants.KEY_USER_ID, userInfo.getId());
}
return result;
}
use of com.owncloud.android.lib.common.UserInfo in project android by nextcloud.
the class UserAccountManagerImpl method migrateUserId.
public boolean migrateUserId() {
Account[] ocAccounts = accountManager.getAccountsByType(MainApp.getAccountType(context));
String userId;
String displayName;
GetUserInfoRemoteOperation remoteUserNameOperation = new GetUserInfoRemoteOperation();
int failed = 0;
for (Account account : ocAccounts) {
String storedUserId = accountManager.getUserData(account, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
if (!TextUtils.isEmpty(storedUserId)) {
continue;
}
// add userId
try {
OwnCloudAccount ocAccount = new OwnCloudAccount(account, context);
NextcloudClient nextcloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().getNextcloudClientFor(ocAccount, context);
RemoteOperationResult<UserInfo> result = remoteUserNameOperation.execute(nextcloudClient);
if (result.isSuccess()) {
UserInfo userInfo = result.getResultData();
userId = userInfo.getId();
displayName = userInfo.getDisplayName();
} else {
// skip account, try it next time
Log_OC.e(TAG, "Error while getting username for account: " + account.name);
failed++;
continue;
}
} catch (Exception e) {
Log_OC.e(TAG, "Error while getting username: " + e.getMessage());
failed++;
continue;
}
accountManager.setUserData(account, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_DISPLAY_NAME, displayName);
accountManager.setUserData(account, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID, userId);
}
return failed == 0;
}
Aggregations