#655 Move notes to another account

This commit is contained in:
stefan-niedermann 2020-01-11 09:53:24 +01:00
parent c6104b00e0
commit 9b6d968fe8
2 changed files with 20 additions and 17 deletions

View file

@ -1,17 +1,20 @@
package it.niedermann.owncloud.notes.android.fragment;
import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import java.util.List;
import butterknife.BindView;
@ -25,10 +28,10 @@ public class AccountChooserAdapter extends RecyclerView.Adapter<RecyclerView.Vie
private List<LocalAccount> localAccounts;
@NonNull
private AccountChooserDialogFragment.AccountChooserListener accountChooserListener;
@Nullable
@NonNull
private Context context;
AccountChooserAdapter(@NonNull List<LocalAccount> localAccounts, @NonNull AccountChooserDialogFragment.AccountChooserListener accountChooserListener, @Nullable Context context) {
AccountChooserAdapter(@NonNull List<LocalAccount> localAccounts, @NonNull AccountChooserDialogFragment.AccountChooserListener accountChooserListener, @NonNull Context context) {
super();
this.localAccounts = localAccounts;
this.accountChooserListener = accountChooserListener;
@ -50,15 +53,14 @@ public class AccountChooserAdapter extends RecyclerView.Adapter<RecyclerView.Vie
accountChooserListener.onAccountChosen(localAccount);
});
// if (context != null) {
// try {
//// ViewUtil.addAvatar(context, acHolder.avatar, SingleAccountHelper.getCurrentSingleSignOnAccount(context).url, ac.getUser().getUid(), R.drawable.ic_person_grey600_24dp);
// } catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
// e.printStackTrace();
// }
// }
Glide
.with(context)
.load(localAccount.getUrl() + "/index.php/avatar/" + Uri.encode(localAccount.getUserName()) + "/64")
.error(R.drawable.ic_account_circle_grey_24dp)
.apply(RequestOptions.circleCropTransform())
.into(accountChooserViewHolder.avatar);
accountChooserViewHolder.username.setText(localAccount.getUserName() + localAccount.getUrl());
accountChooserViewHolder.username.setText(localAccount.getAccountName());
}
@Override
@ -68,7 +70,7 @@ public class AccountChooserAdapter extends RecyclerView.Adapter<RecyclerView.Vie
static class AccountChooserViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.accountLayout)
RelativeLayout accountLayout;
LinearLayout accountLayout;
@BindView(R.id.accountItemAvatar)
ImageView avatar;
@BindView(R.id.accountItemLabel)

View file

@ -5,14 +5,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:padding="16dp"
android:padding="24dp"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/accountItemAvatar"
android:layout_width="44dp"
android:layout_height="44dp"
android:padding="10dp"
android:layout_width="32dp"
android:layout_height="32dp"
android:scaleType="center"
android:focusable="false"
app:srcCompat="@drawable/ic_account_circle_grey_24dp"
@ -25,6 +24,8 @@
android:layout_gravity="center"
android:ellipsize="middle"
android:singleLine="true"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:textColor="@color/fg_default"
android:textAppearance="@style/NavigationItem"
tools:hint="Username"/>