use of com.nextcloud.client.account.User in project android by nextcloud.
the class ManageAccountsActivity method hasAccountListChanged.
/**
* checks the set of actual accounts against the set of original accounts when the activity has been started.
*
* @return true if account list has changed, false if not
*/
private boolean hasAccountListChanged() {
List<User> users = accountManager.getAllUsers();
List<User> newList = new ArrayList<>();
for (User user : users) {
boolean pendingForRemoval = arbitraryDataProvider.getBooleanValue(user, PENDING_FOR_REMOVAL);
if (!pendingForRemoval) {
newList.add(user);
}
}
Set<String> actualAccounts = toAccountNames(newList);
return !originalUsers.equals(actualAccounts);
}
use of com.nextcloud.client.account.User in project android by nextcloud.
the class ManageAccountsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.accounts_layout);
recyclerView = findViewById(R.id.account_list);
setupToolbar();
// set the back button from action bar
ActionBar actionBar = getSupportActionBar();
// check if is not null
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
// set title Action bar
updateActionBarTitleAndHomeButtonByString(getResources().getString(R.string.prefs_manage_accounts));
ThemeToolbarUtils.tintBackButton(actionBar, this);
List<User> users = accountManager.getAllUsers();
originalUsers = toAccountNames(users);
Optional<User> currentUser = getUser();
if (currentUser.isPresent()) {
originalCurrentUser = currentUser.get().getAccountName();
}
arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
multipleAccountsSupported = getResources().getBoolean(R.bool.multiaccount_support);
userListAdapter = new UserListAdapter(this, accountManager, getUserListItems(), this, multipleAccountsSupported, true);
recyclerView.setAdapter(userListAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
initializeComponentGetters();
}
use of com.nextcloud.client.account.User in project android by nextcloud.
the class ManageAccountsActivity method getUserListItems.
private List<UserListItem> getUserListItems() {
List<User> users = accountManager.getAllUsers();
List<UserListItem> userListItems = new ArrayList<>(users.size());
for (User user : users) {
boolean pendingForRemoval = arbitraryDataProvider.getBooleanValue(user, PENDING_FOR_REMOVAL);
userListItems.add(new UserListItem(user, !pendingForRemoval));
}
if (getResources().getBoolean(R.bool.multiaccount_support)) {
userListItems.add(new UserListItem());
}
return userListItems;
}
use of com.nextcloud.client.account.User in project android by nextcloud.
the class NotificationsActivity method initializeClient.
private void initializeClient() {
if (client == null && optionalUser.isPresent()) {
try {
User user = optionalUser.get();
client = clientFactory.create(user);
} catch (ClientFactory.CreationException e) {
Log_OC.e(TAG, "Error initializing client", e);
}
}
}
use of com.nextcloud.client.account.User in project android by nextcloud.
the class NotificationsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
Log_OC.v(TAG, "onCreate() start");
super.onCreate(savedInstanceState);
binding = NotificationsLayoutBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
optionalUser = getUser();
// use account from intent (opened via android notification can have a different account than current one)
if (getIntent() != null && getIntent().getExtras() != null) {
String accountName = getIntent().getExtras().getString(NotificationWork.KEY_NOTIFICATION_ACCOUNT);
if (accountName != null && optionalUser.isPresent()) {
User user = optionalUser.get();
if (user.getAccountName().equalsIgnoreCase(accountName)) {
accountManager.setCurrentOwnCloudAccount(accountName);
setUser(getUserAccountManager().getUser());
optionalUser = getUser();
}
}
}
// setup toolbar
setupToolbar();
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_notifications));
ThemeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingList);
ThemeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingEmpty);
// setup drawer
setupDrawer(R.id.nav_notifications);
if (!optionalUser.isPresent()) {
// show error
runOnUiThread(() -> setEmptyContent(getString(R.string.notifications_no_results_headline), getString(R.string.account_not_found)));
return;
}
binding.swipeContainingList.setOnRefreshListener(() -> {
setLoadingMessage();
binding.swipeContainingList.setRefreshing(true);
fetchAndSetData();
});
binding.swipeContainingEmpty.setOnRefreshListener(() -> {
setLoadingMessageEmpty();
fetchAndSetData();
});
setupPushWarning();
setupContent();
}
Aggregations