Search in sources :

Example 76 with User

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);
}
Also used : User(com.nextcloud.client.account.User) ArrayList(java.util.ArrayList)

Example 77 with User

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();
}
Also used : User(com.nextcloud.client.account.User) ArbitraryDataProvider(com.owncloud.android.datamodel.ArbitraryDataProvider) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ActionBar(androidx.appcompat.app.ActionBar) UserListAdapter(com.owncloud.android.ui.adapter.UserListAdapter)

Example 78 with User

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;
}
Also used : User(com.nextcloud.client.account.User) ArrayList(java.util.ArrayList) UserListItem(com.owncloud.android.ui.adapter.UserListItem)

Example 79 with User

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);
        }
    }
}
Also used : User(com.nextcloud.client.account.User) ClientFactory(com.nextcloud.client.network.ClientFactory)

Example 80 with User

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();
}
Also used : User(com.nextcloud.client.account.User)

Aggregations

User (com.nextcloud.client.account.User)84 OCFile (com.owncloud.android.datamodel.OCFile)21 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)19 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)19 Intent (android.content.Intent)14 Account (android.accounts.Account)12 ArrayList (java.util.ArrayList)12 Context (android.content.Context)9 Fragment (androidx.fragment.app.Fragment)9 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)9 File (java.io.File)9 ArbitraryDataProvider (com.owncloud.android.datamodel.ArbitraryDataProvider)7 Uri (android.net.Uri)6 Bundle (android.os.Bundle)6 OCCapability (com.owncloud.android.lib.resources.status.OCCapability)6 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)6 PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)6 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)6 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)6 View (android.view.View)5