Add server avatar to user accounts (#594)

Add server avatar to user accounts

Co-authored-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/594
Reviewed-by: 6543 <6543@noreply.codeberg.org>
This commit is contained in:
M M Arif 2020-07-19 12:13:37 +02:00 committed by 6543
parent 26f54280a1
commit 060c86c090
2 changed files with 65 additions and 39 deletions

View File

@ -10,7 +10,9 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import org.mian.gitnex.R;
import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.database.models.UserAccount;
import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty;
import java.util.List;
@ -32,6 +34,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
private TextView userId;
private ImageView activeAccount;
private ImageView deleteAccount;
private ImageView repoAvatar;
private UserAccountsViewHolder(View itemView) {
@ -41,6 +44,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
userId = itemView.findViewById(R.id.userId);
activeAccount = itemView.findViewById(R.id.activeAccount);
deleteAccount = itemView.findViewById(R.id.deleteAccount);
repoAvatar = itemView.findViewById(R.id.repoAvatar);
deleteAccount.setOnClickListener(itemDelete -> {
// use later to delete an account
@ -93,6 +97,8 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
holder.userId.setText(String.format("@%s", currentItem.getUserName()));
holder.accountUrl.setText(url);
PicassoService.getInstance(mCtx).get().load(url + "img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.repoAvatar);
if(tinyDB.getInt("currentActiveAccountId") == currentItem.getAccountId()) {
holder.activeAccount.setVisibility(View.VISIBLE);
}

View File

@ -7,54 +7,74 @@
android:layout_alignParentTop="true"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:layout_margin="10dp"
android:layout_margin="15dp"
android:background="?attr/primaryBackgroundColor">
<LinearLayout
android:id="@+id/frameAccountsInfo"
<RelativeLayout
android:id="@+id/layoutFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
android:orientation="vertical">
<ImageView
android:id="@+id/repoAvatar"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="15dp"
android:contentDescription="@string/repoContentAvatar"
android:src="@drawable/ic_android" />
<LinearLayout
android:id="@+id/frameAccountsInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_toEndOf="@+id/repoAvatar"
android:layout_marginBottom="10dp">
<TextView
android:id="@+id/userId"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".95"
android:layout_gravity="start"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/activeAccount"
android:layout_weight=".05"
android:layout_width="10dp"
android:layout_height="20dp"
android:layout_gravity="end"
android:src="@drawable/ic_check"
android:visibility="gone"
android:contentDescription="@string/menuContentDesc" />
<ImageView
android:id="@+id/deleteAccount"
android:layout_weight=".05"
android:layout_width="10dp"
android:layout_height="20dp"
android:layout_gravity="end"
android:src="@drawable/ic_delete"
android:visibility="gone"
android:contentDescription="@string/menuDeleteText" />
</LinearLayout>
<TextView
android:id="@+id/userId"
android:layout_width="0dp"
android:id="@+id/accountUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".95"
android:layout_gravity="start"
android:layout_marginBottom="0dp"
android:layout_toEndOf="@+id/repoAvatar"
android:layout_below="@+id/frameAccountsInfo"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp" />
android:textSize="14sp" />
<ImageView
android:id="@+id/activeAccount"
android:layout_weight=".05"
android:layout_width="10dp"
android:layout_height="20dp"
android:layout_gravity="end"
android:src="@drawable/ic_check"
android:visibility="gone"
android:contentDescription="@string/menuContentDesc" />
<ImageView
android:id="@+id/deleteAccount"
android:layout_weight=".05"
android:layout_width="10dp"
android:layout_height="20dp"
android:layout_gravity="end"
android:src="@drawable/ic_delete"
android:visibility="gone"
android:contentDescription="@string/menuDeleteText" />
</LinearLayout>
<TextView
android:id="@+id/accountUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>