mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2024-12-16 15:48:13 +08:00
Switch to proper account for popular instances and other ui improvements (#836)
* improve navigation via keyboard * switch to proper account for popular instances * ui improvements Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/836 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-Authored-By: M M Arif <mmarif@noreply.codeberg.org> Co-Committed-By: M M Arif <mmarif@noreply.codeberg.org>
This commit is contained in:
parent
47d6c68410
commit
afffb7c15a
@ -78,6 +78,13 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
if(hostUri.toLowerCase().contains(Objects.requireNonNull(data.getHost().toLowerCase()))) {
|
||||
|
||||
accountFound = true;
|
||||
|
||||
tinyDB.putString("loginUid", userAccount.getUserName());
|
||||
tinyDB.putString("userLogin", userAccount.getUserName());
|
||||
tinyDB.putString(userAccount.getUserName() + "-token", userAccount.getToken());
|
||||
tinyDB.putString("instanceUrl", userAccount.getInstanceUrl());
|
||||
tinyDB.putInt("currentActiveAccountId", userAccount.getAccountId());
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -23,12 +24,12 @@ import java.util.List;
|
||||
|
||||
public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdapter.AssigneesViewHolder> {
|
||||
|
||||
private Context mCtx;
|
||||
private List<Collaborators> assigneesList;
|
||||
private final Context mCtx;
|
||||
private final List<Collaborators> assigneesList;
|
||||
private List<String> assigneesStrings = new ArrayList<>();
|
||||
private List<String> currentAssignees;
|
||||
|
||||
private AssigneesListAdapterListener assigneesListener;
|
||||
private final AssigneesListAdapterListener assigneesListener;
|
||||
|
||||
public interface AssigneesListAdapterListener {
|
||||
|
||||
@ -45,9 +46,9 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
||||
|
||||
static class AssigneesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private CheckBox assigneesSelection;
|
||||
private TextView assigneesName;
|
||||
private ImageView assigneesAvatar;
|
||||
private final CheckBox assigneesSelection;
|
||||
private final TextView assigneesName;
|
||||
private final ImageView assigneesAvatar;
|
||||
|
||||
private AssigneesViewHolder(View itemView) {
|
||||
|
||||
@ -79,7 +80,7 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
||||
}
|
||||
else {
|
||||
|
||||
holder.assigneesName.setText(currentItem.getFull_name());
|
||||
holder.assigneesName.setText(Html.fromHtml(currentItem.getFull_name()));
|
||||
}
|
||||
PicassoService
|
||||
.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(holder.assigneesAvatar);
|
||||
|
@ -32,6 +32,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
||||
private final FilesAdapterListener filesListener;
|
||||
|
||||
public interface FilesAdapterListener {
|
||||
|
||||
void onClickDir(String str);
|
||||
void onClickFile(String str);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -27,19 +28,20 @@ import io.mikael.urlbuilder.UrlBuilder;
|
||||
|
||||
public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapter.UserAccountsViewHolder> {
|
||||
|
||||
private List<UserAccount> userAccountsList;
|
||||
private Context mCtx;
|
||||
private final List<UserAccount> userAccountsList;
|
||||
private final Context mCtx;
|
||||
private TinyDB tinyDB;
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView accountUrl;
|
||||
private TextView userId;
|
||||
private ImageView activeAccount;
|
||||
private ImageView deleteAccount;
|
||||
private ImageView repoAvatar;
|
||||
private TextView accountId;
|
||||
private TextView accountName;
|
||||
private int accountId;
|
||||
private String accountName;
|
||||
|
||||
private final TextView accountUrl;
|
||||
private final TextView userId;
|
||||
private final ImageView activeAccount;
|
||||
private final ImageView deleteAccount;
|
||||
private final ImageView repoAvatar;
|
||||
|
||||
private UserAccountsViewHolder(View itemView) {
|
||||
|
||||
@ -50,30 +52,26 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
activeAccount = itemView.findViewById(R.id.activeAccount);
|
||||
deleteAccount = itemView.findViewById(R.id.deleteAccount);
|
||||
repoAvatar = itemView.findViewById(R.id.repoAvatar);
|
||||
accountId = itemView.findViewById(R.id.accountId);
|
||||
accountName = itemView.findViewById(R.id.accountName);
|
||||
|
||||
deleteAccount.setOnClickListener(itemDelete -> {
|
||||
|
||||
new AlertDialog.Builder(mCtx)
|
||||
.setIcon(mCtx.getDrawable(R.drawable.ic_delete))
|
||||
.setIcon(AppCompatResources.getDrawable(mCtx, R.drawable.ic_delete))
|
||||
.setTitle(mCtx.getResources().getString(R.string.removeAccountPopupTitle))
|
||||
.setMessage(mCtx.getResources().getString(R.string.removeAccountPopupMessage))
|
||||
.setPositiveButton(mCtx.getResources().getString(R.string.removeButton), (dialog, which) -> {
|
||||
|
||||
updateLayoutByPosition(getAdapterPosition());
|
||||
UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx);
|
||||
userAccountsApi.deleteAccount(Integer.parseInt(accountId.getText().toString()));
|
||||
userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId)));
|
||||
}).setNeutralButton(mCtx.getResources().getString(R.string.cancelButton), null)
|
||||
.show();
|
||||
|
||||
});
|
||||
|
||||
itemView.setOnClickListener(itemEdit -> {
|
||||
itemView.setOnClickListener(switchAccount -> {
|
||||
|
||||
String accountNameSwitch = accountName.getText().toString();
|
||||
UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx);
|
||||
UserAccount userAccount = userAccountsApi.getAccountData(accountNameSwitch);
|
||||
UserAccount userAccount = userAccountsApi.getAccountData(accountName);
|
||||
|
||||
if(tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) {
|
||||
|
||||
@ -109,7 +107,6 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, userAccountsList.size());
|
||||
Toasty.success(mCtx, mCtx.getResources().getString(R.string.accountDeletedMessage));
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -131,20 +128,22 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
.withPath("/")
|
||||
.toString();
|
||||
|
||||
holder.accountId.setText(String.valueOf(currentItem.getAccountId()));
|
||||
holder.accountName.setText(currentItem.getAccountName());
|
||||
holder.accountId = currentItem.getAccountId();
|
||||
holder.accountName = currentItem.getAccountName();
|
||||
|
||||
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);
|
||||
}
|
||||
else {
|
||||
|
||||
holder.deleteAccount.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,6 +81,7 @@
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionSend"
|
||||
android:inputType="text"
|
||||
android:textSize="16sp" />
|
||||
|
@ -75,6 +75,7 @@
|
||||
android:inputType="none"
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:labelFor="@+id/protocolSpinner"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@ -102,7 +103,8 @@
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@ -130,7 +132,8 @@
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -81,6 +81,7 @@
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:singleLine="true"
|
||||
android:inputType="text"
|
||||
android:textSize="16sp" />
|
||||
|
||||
|
@ -78,6 +78,8 @@
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="textCapSentences"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@ -134,6 +136,7 @@
|
||||
android:inputType="textCapSentences"
|
||||
android:labelFor="@id/new_file_branches"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
@ -164,6 +167,7 @@
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:singleLine="true"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -78,6 +78,8 @@
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="textCapSentences"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -75,6 +75,8 @@
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="textCapSentences"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -75,6 +75,8 @@
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="textCapSentences"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@ -100,6 +102,8 @@
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@ -125,6 +129,8 @@
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@ -150,6 +156,7 @@
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:singleLine="true"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -75,6 +75,8 @@
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="textCapSentences"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -78,6 +78,8 @@
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="textCapSentences"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -74,7 +74,9 @@
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:inputType="textCapSentences"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@ -101,6 +103,8 @@
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="textCapSentences"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -75,6 +75,8 @@
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="textCapSentences"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@ -103,6 +105,8 @@
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -75,6 +75,8 @@
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="textCapSentences"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -107,6 +107,7 @@
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="textUri"
|
||||
android:singleLine="true"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@ -134,6 +135,7 @@
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:singleLine="true"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@ -162,6 +164,7 @@
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@ -193,6 +196,7 @@
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="number"
|
||||
android:singleLine="true"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@ -220,6 +224,7 @@
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:singleLine="true"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -89,6 +89,8 @@
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:inputType="textCapSentences"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
@ -1,32 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/layoutUserAccountsFrame"
|
||||
<RelativeLayout android:id="@+id/layoutFrame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical"
|
||||
android:layout_margin="15dp"
|
||||
android:background="?attr/primaryBackgroundColor">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/accountId"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/accountName"
|
||||
android:visibility="gone" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/layoutFrame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/repoAvatar"
|
||||
@ -86,7 +65,4 @@
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user