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

View file

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