mirror of
https://github.com/gitnex-org/gitnex.git
synced 2026-07-19 23:49:49 -05:00
Fix user accounts popup layout, disable activation for the same account, limit nav accounts to 3, other UI fixes
This commit is contained in:
@@ -27,34 +27,6 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
||||
private final List<User> collaboratorsList;
|
||||
private final Context context;
|
||||
|
||||
private class ViewHolder {
|
||||
|
||||
private String userLoginId;
|
||||
|
||||
private final ImageView collaboratorAvatar;
|
||||
private final TextView collaboratorName;
|
||||
private final TextView userName;
|
||||
|
||||
ViewHolder(View v) {
|
||||
|
||||
collaboratorAvatar = v.findViewById(R.id.collaboratorAvatar);
|
||||
collaboratorName = v.findViewById(R.id.collaboratorName);
|
||||
userName = v.findViewById(R.id.userName);
|
||||
|
||||
collaboratorAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
collaboratorAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CollaboratorsAdapter(Context ctx, List<User> collaboratorsListMain) {
|
||||
|
||||
this.context = ctx;
|
||||
@@ -120,4 +92,31 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
||||
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
|
||||
private final ImageView collaboratorAvatar;
|
||||
private final TextView collaboratorName;
|
||||
private final TextView userName;
|
||||
private String userLoginId;
|
||||
|
||||
ViewHolder(View v) {
|
||||
|
||||
collaboratorAvatar = v.findViewById(R.id.collaboratorAvatar);
|
||||
collaboratorName = v.findViewById(R.id.collaboratorName);
|
||||
userName = v.findViewById(R.id.userName);
|
||||
|
||||
v.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
v.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,11 +41,13 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
private final List<UserAccount> userAccountsList;
|
||||
private final Context context;
|
||||
private final Dialog dialog;
|
||||
private final TinyDB tinyDB;
|
||||
|
||||
public UserAccountsAdapter(Context ctx, Dialog dialog) {
|
||||
this.dialog = dialog;
|
||||
this.context = ctx;
|
||||
this.userAccountsList = Objects.requireNonNull(BaseApi.getInstance(context, UserAccountsApi.class)).usersAccounts();
|
||||
this.tinyDB = TinyDB.getInstance(context);
|
||||
}
|
||||
|
||||
private void updateLayoutByPosition(int position) {
|
||||
@@ -96,7 +98,6 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
public void onBindViewHolder(@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) {
|
||||
|
||||
UserAccount currentItem = userAccountsList.get(position);
|
||||
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl()).withPath("/").toString();
|
||||
|
||||
@@ -202,18 +203,18 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
return;
|
||||
}
|
||||
|
||||
if(AppUtil.switchToAccount(context, userAccount)) {
|
||||
if(tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) {
|
||||
if(AppUtil.switchToAccount(context, userAccount)) {
|
||||
|
||||
String url = UrlBuilder.fromString(userAccount.getInstanceUrl()).withPath("/").toString();
|
||||
|
||||
Toasty.success(context, context.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
|
||||
getNotificationsCount();
|
||||
((Activity) context).recreate();
|
||||
dialog.dismiss();
|
||||
String url = UrlBuilder.fromString(userAccount.getInstanceUrl()).withPath("/").toString();
|
||||
|
||||
Toasty.success(context, context.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
|
||||
getNotificationsCount();
|
||||
((Activity) context).recreate();
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,16 +57,16 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
||||
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl()).withPath("/").toString();
|
||||
|
||||
int imageSize = AppUtil.getPixelsFromDensity(context, 35);
|
||||
int imageSize = AppUtil.getPixelsFromDensity(context, 36);
|
||||
|
||||
PicassoService.getInstance(context).get().load(url + "assets/img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(imageSize, imageSize).centerCrop()
|
||||
PicassoService.getInstance(context).get().load(url + "assets/img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(18, 0)).resize(imageSize, imageSize).centerCrop()
|
||||
.into(holder.userAccountAvatar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
return userAccountsList.size();
|
||||
return Math.min(userAccountsList.size(), 3);
|
||||
}
|
||||
|
||||
private void customDialogUserAccountsList() {
|
||||
|
||||
@@ -4,9 +4,6 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
@@ -22,12 +19,8 @@ import org.mian.gitnex.viewmodels.CollaboratorsViewModel;
|
||||
public class CollaboratorsFragment extends Fragment {
|
||||
|
||||
public static boolean refreshCollaborators = false;
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private FragmentCollaboratorsBinding fragmentCollaboratorsBinding;
|
||||
private CollaboratorsAdapter adapter;
|
||||
private GridView mGridView;
|
||||
private TextView noDataCollaborators;
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
public CollaboratorsFragment() {
|
||||
@@ -48,11 +41,7 @@ public class CollaboratorsFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
FragmentCollaboratorsBinding fragmentCollaboratorsBinding = FragmentCollaboratorsBinding.inflate(inflater, container, false);
|
||||
|
||||
noDataCollaborators = fragmentCollaboratorsBinding.noDataCollaborators;
|
||||
mProgressBar = fragmentCollaboratorsBinding.progressBar;
|
||||
mGridView = fragmentCollaboratorsBinding.gridView;
|
||||
fragmentCollaboratorsBinding = FragmentCollaboratorsBinding.inflate(inflater, container, false);
|
||||
|
||||
fetchDataAsync(repository.getOwner(), repository.getName());
|
||||
return fragmentCollaboratorsBinding.getRoot();
|
||||
@@ -66,15 +55,15 @@ public class CollaboratorsFragment extends Fragment {
|
||||
collaboratorsModel.getCollaboratorsList(owner, repo, getContext()).observe(getViewLifecycleOwner(), collaboratorsListMain -> {
|
||||
adapter = new CollaboratorsAdapter(getContext(), collaboratorsListMain);
|
||||
if(adapter.getCount() > 0) {
|
||||
mGridView.setAdapter(adapter);
|
||||
noDataCollaborators.setVisibility(View.GONE);
|
||||
fragmentCollaboratorsBinding.gridView.setAdapter(adapter);
|
||||
fragmentCollaboratorsBinding.noDataCollaborators.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
adapter.notifyDataSetChanged();
|
||||
mGridView.setAdapter(adapter);
|
||||
noDataCollaborators.setVisibility(View.VISIBLE);
|
||||
fragmentCollaboratorsBinding.gridView.setAdapter(adapter);
|
||||
fragmentCollaboratorsBinding.noDataCollaborators.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
fragmentCollaboratorsBinding.progressBar.setVisibility(View.GONE);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/dimen48dp"
|
||||
android:layout_marginBottom="@dimen/dimen48dp"
|
||||
android:background="@drawable/shape_round_corners"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/dimen16dp">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/accountsList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:id="@+id/divider"
|
||||
android:background="?attr/dividerColor"/>
|
||||
android:background="?attr/dividerColor" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/newAccount"
|
||||
@@ -32,10 +34,9 @@
|
||||
android:layout_margin="16dp"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/addNewAccount"
|
||||
android:textColor="@color/colorWhite"
|
||||
android:textSize="16sp"/>
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user