Search in sources :

Example 1 with UserListAdapter

use of com.owncloud.android.ui.adapter.UserListAdapter in project android by nextcloud.

the class ManageAccountsActivity method startAccountCreation.

@Override
public void startAccountCreation() {
    AccountManager am = AccountManager.get(getApplicationContext());
    am.addAccount(MainApp.getAccountType(this), null, null, null, this, future -> {
        if (future != null) {
            try {
                Bundle result = future.getResult();
                String name = result.getString(AccountManager.KEY_ACCOUNT_NAME);
                accountManager.setCurrentOwnCloudAccount(name);
                userListAdapter = new UserListAdapter(this, accountManager, getUserListItems(), this, multipleAccountsSupported, false);
                recyclerView.setAdapter(userListAdapter);
                runOnUiThread(() -> userListAdapter.notifyDataSetChanged());
            } catch (OperationCanceledException e) {
                Log_OC.d(TAG, "Account creation canceled");
            } catch (Exception e) {
                Log_OC.e(TAG, "Account creation finished in exception: ", e);
            }
        }
    }, handler);
}
Also used : Bundle(android.os.Bundle) OperationCanceledException(android.accounts.OperationCanceledException) UserAccountManager(com.nextcloud.client.account.UserAccountManager) AccountManager(android.accounts.AccountManager) UserListAdapter(com.owncloud.android.ui.adapter.UserListAdapter) OperationCanceledException(android.accounts.OperationCanceledException)

Example 2 with UserListAdapter

use of com.owncloud.android.ui.adapter.UserListAdapter in project android by nextcloud.

the class ManageAccountsActivity method run.

@Override
public void run(AccountManagerFuture<Boolean> future) {
    if (future.isDone()) {
        // after remove account
        Account account = new Account(accountName, MainApp.getAccountType(this));
        if (!accountManager.exists(account)) {
            // Cancel transfers of the removed account
            if (mUploaderBinder != null) {
                mUploaderBinder.cancel(account);
            }
            if (mDownloaderBinder != null) {
                mDownloaderBinder.cancel(account);
            }
        }
        User user = getUserAccountManager().getUser();
        if (user.isAnonymous()) {
            String accountName = "";
            Account[] accounts = AccountManager.get(this).getAccountsByType(MainApp.getAccountType(this));
            if (accounts.length != 0) {
                accountName = accounts[0].name;
            }
            accountManager.setCurrentOwnCloudAccount(accountName);
        }
        List<UserListItem> userListItemArray = getUserListItems();
        if (userListItemArray.size() > SINGLE_ACCOUNT) {
            userListAdapter = new UserListAdapter(this, accountManager, userListItemArray, this, multipleAccountsSupported, false);
            recyclerView.setAdapter(userListAdapter);
        } else {
            onBackPressed();
        }
    }
}
Also used : Account(android.accounts.Account) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) User(com.nextcloud.client.account.User) UserListItem(com.owncloud.android.ui.adapter.UserListItem) UserListAdapter(com.owncloud.android.ui.adapter.UserListAdapter)

Example 3 with UserListAdapter

use of com.owncloud.android.ui.adapter.UserListAdapter in project android by nextcloud.

the class FileDetailFragment method updateListOfUserGroups.

private void updateListOfUserGroups() {
    // Update list of users/groups
    // TODO Refactoring: create a new {@link ShareUserListAdapter} instance with every call should not be needed
    UserListAdapter mUserGroupsAdapter = new UserListAdapter(getActivity().getApplicationContext(), R.layout.share_user_item, mShares);
    // Show data
    ListView usersList = getView().findViewById(R.id.fdshareUsersList);
    // No data
    TextView noList = getView().findViewById(R.id.fdShareNoUsers);
    if (mShares.size() > 0) {
        usersList.setVisibility(View.VISIBLE);
        usersList.setAdapter(mUserGroupsAdapter);
        noList.setVisibility(View.GONE);
        setListViewHeightBasedOnChildren(usersList);
    } else {
        usersList.setVisibility(View.GONE);
        noList.setVisibility(View.VISIBLE);
    }
}
Also used : ListView(android.widget.ListView) TextView(android.widget.TextView) UserListAdapter(com.owncloud.android.ui.adapter.UserListAdapter)

Example 4 with UserListAdapter

use of com.owncloud.android.ui.adapter.UserListAdapter 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 5 with UserListAdapter

use of com.owncloud.android.ui.adapter.UserListAdapter in project android by nextcloud.

the class MultipleAccountsDialog method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity activity = getActivity();
    if (activity == null) {
        throw new IllegalArgumentException("Activity may not be null");
    }
    // Inflate the layout for the dialog
    LayoutInflater inflater = activity.getLayoutInflater();
    MultipleAccountsBinding binding = MultipleAccountsBinding.inflate(inflater, null, false);
    final ReceiveExternalFilesActivity parent = (ReceiveExternalFilesActivity) getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(parent);
    UserListAdapter adapter = new UserListAdapter(parent, accountManager, getAccountListItems(), this, false, false);
    binding.list.setHasFixedSize(true);
    binding.list.setLayoutManager(new LinearLayoutManager(activity));
    binding.list.setAdapter(adapter);
    builder.setView(binding.getRoot()).setTitle(R.string.common_choose_account);
    Dialog dialog = builder.create();
    Window window = dialog.getWindow();
    if (window != null) {
        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    }
    return dialog;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Window(android.view.Window) AlertDialog(androidx.appcompat.app.AlertDialog) Dialog(android.app.Dialog) LayoutInflater(android.view.LayoutInflater) ReceiveExternalFilesActivity(com.owncloud.android.ui.activity.ReceiveExternalFilesActivity) Activity(android.app.Activity) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ReceiveExternalFilesActivity(com.owncloud.android.ui.activity.ReceiveExternalFilesActivity) MultipleAccountsBinding(com.owncloud.android.databinding.MultipleAccountsBinding) UserListAdapter(com.owncloud.android.ui.adapter.UserListAdapter) NonNull(androidx.annotation.NonNull)

Aggregations

UserListAdapter (com.owncloud.android.ui.adapter.UserListAdapter)5 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 User (com.nextcloud.client.account.User)2 Account (android.accounts.Account)1 AccountManager (android.accounts.AccountManager)1 OperationCanceledException (android.accounts.OperationCanceledException)1 Activity (android.app.Activity)1 Dialog (android.app.Dialog)1 Bundle (android.os.Bundle)1 LayoutInflater (android.view.LayoutInflater)1 Window (android.view.Window)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 ActionBar (androidx.appcompat.app.ActionBar)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 UserAccountManager (com.nextcloud.client.account.UserAccountManager)1 MultipleAccountsBinding (com.owncloud.android.databinding.MultipleAccountsBinding)1 ArbitraryDataProvider (com.owncloud.android.datamodel.ArbitraryDataProvider)1 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)1