New UI for multiple screens (#894)

clean up

Another round of ui improvements and some refactors

Minor improvements.

Hide user accounts frame while list is loading

Remove unnecessary attribute

Minor improvements.

Define avatar size in lists globally.

Improvemnts to some ui elements

Improve layout of organizations and repositories.

Update the UI across most of the screens

Refactor org UI

clean up repo layout

Add archived msg instead of label

Redesign repos UI

Move archived to repo detail screen

Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: opyale <opyale@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/894
Reviewed-by: opyale <opyale@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:
M M Arif 2021-04-13 16:19:42 +02:00
parent 27a4bab73c
commit 9d3cd49d23
84 changed files with 1532 additions and 2389 deletions

View File

@ -18,6 +18,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.biometric.BiometricPrompt; import androidx.biometric.BiometricPrompt;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat; import androidx.core.content.res.ResourcesCompat;
import androidx.core.view.GravityCompat; import androidx.core.view.GravityCompat;
@ -71,10 +72,6 @@ import retrofit2.Callback;
public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener, BottomSheetDraftsFragment.BottomSheetListener { public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener, BottomSheetDraftsFragment.BottomSheetListener {
private DrawerLayout drawer; private DrawerLayout drawer;
private TextView userFullName;
private TextView userEmail;
private ImageView userAvatar;
private ImageView userAvatarBackground;
private TextView toolbarTitle; private TextView toolbarTitle;
private Typeface myTypeface; private Typeface myTypeface;
@ -256,6 +253,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
drawer.addDrawerListener(toggle); drawer.addDrawerListener(toggle);
drawer.addDrawerListener(new DrawerLayout.DrawerListener() { drawer.addDrawerListener(new DrawerLayout.DrawerListener() {
@Override @Override
public void onDrawerOpened(@NonNull View drawerView) { public void onDrawerOpened(@NonNull View drawerView) {
@ -269,27 +267,26 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
String userFullNameNav = tinyDB.getString("userFullname"); String userFullNameNav = tinyDB.getString("userFullname");
String userAvatarNav = tinyDB.getString("userAvatar"); String userAvatarNav = tinyDB.getString("userAvatar");
userEmail = hView.findViewById(R.id.userEmail); TextView userEmail = hView.findViewById(R.id.userEmail);
userFullName = hView.findViewById(R.id.userFullname); TextView userFullName = hView.findViewById(R.id.userFullname);
userAvatar = hView.findViewById(R.id.userAvatar); ImageView userAvatar = hView.findViewById(R.id.userAvatar);
userAvatarBackground = hView.findViewById(R.id.userAvatarBackground); ImageView userAvatarBackground = hView.findViewById(R.id.userAvatarBackground);
CardView navRecyclerViewFrame = hView.findViewById(R.id.userAccountsFrame);
List<UserAccount> userAccountsList; List<UserAccount> userAccountsList = new ArrayList<>();
userAccountsList = new ArrayList<>();
UserAccountsApi userAccountsApi; UserAccountsApi userAccountsApi;
userAccountsApi = new UserAccountsApi(ctx); userAccountsApi = new UserAccountsApi(ctx);
RecyclerView navRecyclerViewUserAccounts = hView.findViewById(R.id.navRecyclerViewUserAccounts); RecyclerView navRecyclerViewUserAccounts = hView.findViewById(R.id.userAccounts);
UserAccountsNavAdapter adapterUserAccounts; UserAccountsNavAdapter adapterUserAccounts;
adapterUserAccounts = new UserAccountsNavAdapter(ctx, userAccountsList, drawer, toolbarTitle); adapterUserAccounts = new UserAccountsNavAdapter(ctx, userAccountsList, drawer, toolbarTitle);
userAccountsApi.getAllAccounts().observe((AppCompatActivity) ctx, userAccounts -> { userAccountsApi.getAllAccounts().observe((AppCompatActivity) ctx, userAccounts -> {
if(userAccounts.size() > 0) { if(userAccounts.size() > 0) {
userAccountsList.addAll(userAccounts); userAccountsList.addAll(userAccounts);
navRecyclerViewUserAccounts.setAdapter(adapterUserAccounts); navRecyclerViewUserAccounts.setAdapter(adapterUserAccounts);
navRecyclerViewFrame.setVisibility(View.VISIBLE);
} }
}); });
@ -308,10 +305,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
if(!userAvatarNav.equals("")) { if(!userAvatarNav.equals("")) {
int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 3);
PicassoService.getInstance(ctx).get() PicassoService.getInstance(ctx).get()
.load(userAvatarNav) .load(userAvatarNav)
.placeholder(R.drawable.loader_animated) .placeholder(R.drawable.loader_animated)
.transform(new RoundedTransformation(8, 0)) .transform(new RoundedTransformation(avatarRadius, 0))
.resize(160, 160) .resize(160, 160)
.centerCrop().into(userAvatar); .centerCrop().into(userAvatar);

View File

@ -31,17 +31,13 @@ import retrofit2.Callback;
public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAdapter.CronTasksViewHolder> { public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAdapter.CronTasksViewHolder> {
private final List<CronTasks> tasksList; private final List<CronTasks> tasksList;
private final Context mCtx;
private static TinyDB tinyDb; private static TinyDB tinyDb;
static class CronTasksViewHolder extends RecyclerView.ViewHolder { static class CronTasksViewHolder extends RecyclerView.ViewHolder {
private CronTasks cronTasks; private CronTasks cronTasks;
private final ImageView runTask;
private final TextView taskName; private final TextView taskName;
private final LinearLayout cronTasksInfo;
private final LinearLayout cronTasksRun;
private CronTasksViewHolder(View itemView) { private CronTasksViewHolder(View itemView) {
@ -51,10 +47,10 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
final String locale = tinyDb.getString("locale"); final String locale = tinyDb.getString("locale");
final String timeFormat = tinyDb.getString("dateFormat"); final String timeFormat = tinyDb.getString("dateFormat");
runTask = itemView.findViewById(R.id.runTask); ImageView runTask = itemView.findViewById(R.id.runTask);
taskName = itemView.findViewById(R.id.taskName); taskName = itemView.findViewById(R.id.taskName);
cronTasksInfo = itemView.findViewById(R.id.cronTasksInfo); LinearLayout cronTasksInfo = itemView.findViewById(R.id.cronTasksInfo);
cronTasksRun = itemView.findViewById(R.id.cronTasksRun); LinearLayout cronTasksRun = itemView.findViewById(R.id.cronTasksRun);
cronTasksInfo.setOnClickListener(taskInfo -> { cronTasksInfo.setOnClickListener(taskInfo -> {
@ -96,10 +92,9 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
} }
} }
public AdminCronTasksAdapter(Context mCtx, List<CronTasks> tasksListMain) { public AdminCronTasksAdapter(Context ctx, List<CronTasks> tasksListMain) {
tinyDb = TinyDB.getInstance(mCtx); tinyDb = TinyDB.getInstance(ctx);
this.mCtx = mCtx;
this.tasksList = tasksListMain; this.tasksList = tasksListMain;
} }

View File

@ -28,7 +28,7 @@ import java.util.List;
public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdapter.UsersViewHolder> implements Filterable { public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdapter.UsersViewHolder> implements Filterable {
private final List<UserInfo> usersList; private final List<UserInfo> usersList;
private final Context mCtx; private final Context context;
private final List<UserInfo> usersListFull; private final List<UserInfo> usersListFull;
static class UsersViewHolder extends RecyclerView.ViewHolder { static class UsersViewHolder extends RecyclerView.ViewHolder {
@ -60,9 +60,9 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdap
} }
} }
public AdminGetUsersAdapter(Context mCtx, List<UserInfo> usersListMain) { public AdminGetUsersAdapter(Context ctx, List<UserInfo> usersListMain) {
this.mCtx = mCtx; this.context = ctx;
this.usersList = usersListMain; this.usersList = usersListMain;
usersListFull = new ArrayList<>(usersList); usersListFull = new ArrayList<>(usersList);
} }
@ -79,17 +79,18 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdap
public void onBindViewHolder(@NonNull AdminGetUsersAdapter.UsersViewHolder holder, int position) { public void onBindViewHolder(@NonNull AdminGetUsersAdapter.UsersViewHolder holder, int position) {
UserInfo currentItem = usersList.get(position); UserInfo currentItem = usersList.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
holder.userLoginId = currentItem.getLogin(); holder.userLoginId = currentItem.getLogin();
if(!currentItem.getFullname().equals("")) { if(!currentItem.getFullname().equals("")) {
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname())); holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername())); holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
} }
else { else {
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername())); holder.userFullName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
holder.userName.setVisibility(View.GONE); holder.userName.setVisibility(View.GONE);
} }
@ -107,12 +108,12 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdap
holder.userRole.setVisibility(View.VISIBLE); holder.userRole.setVisibility(View.VISIBLE);
TextDrawable drawable = TextDrawable.builder() TextDrawable drawable = TextDrawable.builder()
.beginConfig() .beginConfig()
.textColor(ResourcesCompat.getColor(mCtx.getResources(), R.color.colorWhite, null)) .textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null))
.fontSize(44) .fontSize(44)
.width(180) .width(180)
.height(60) .height(60)
.endConfig() .endConfig()
.buildRoundRect(mCtx.getResources().getString(R.string.userRoleAdmin).toLowerCase(), ResourcesCompat.getColor(mCtx.getResources(), R.color.releasePre, null), 8); .buildRoundRect(context.getResources().getString(R.string.userRoleAdmin).toLowerCase(), ResourcesCompat.getColor(context.getResources(), R.color.releasePre, null), 8);
holder.userRole.setImageDrawable(drawable); holder.userRole.setImageDrawable(drawable);
} }
else { else {
@ -120,7 +121,7 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdap
holder.userRole.setVisibility(View.GONE); holder.userRole.setVisibility(View.GONE);
} }
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAvatar); PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
} }
@Override @Override

View File

@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView;
import org.gitnex.tea4j.models.Collaborators; import org.gitnex.tea4j.models.Collaborators;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
@ -24,7 +25,7 @@ import java.util.List;
public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdapter.AssigneesViewHolder> { public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdapter.AssigneesViewHolder> {
private final Context mCtx; private final Context context;
private final List<Collaborators> assigneesList; private final List<Collaborators> assigneesList;
private List<String> assigneesStrings = new ArrayList<>(); private List<String> assigneesStrings = new ArrayList<>();
private List<String> currentAssignees; private List<String> currentAssignees;
@ -36,9 +37,9 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
void assigneesInterface(List<String> data); void assigneesInterface(List<String> data);
} }
public AssigneesListAdapter(Context mCtx, List<Collaborators> dataMain, AssigneesListAdapterListener assigneesListener, List<String> currentAssignees) { public AssigneesListAdapter(Context ctx, List<Collaborators> dataMain, AssigneesListAdapterListener assigneesListener, List<String> currentAssignees) {
this.mCtx = mCtx; this.context = ctx;
this.assigneesList = dataMain; this.assigneesList = dataMain;
this.assigneesListener = assigneesListener; this.assigneesListener = assigneesListener;
this.currentAssignees = currentAssignees; this.currentAssignees = currentAssignees;
@ -73,6 +74,7 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
public void onBindViewHolder(@NonNull AssigneesListAdapter.AssigneesViewHolder holder, int position) { public void onBindViewHolder(@NonNull AssigneesListAdapter.AssigneesViewHolder holder, int position) {
Collaborators currentItem = assigneesList.get(position); Collaborators currentItem = assigneesList.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
if(currentItem.getFull_name().equals("")) { if(currentItem.getFull_name().equals("")) {
@ -83,7 +85,7 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
holder.assigneesName.setText(Html.fromHtml(currentItem.getFull_name())); holder.assigneesName.setText(Html.fromHtml(currentItem.getFull_name()));
} }
PicassoService 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); .getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(holder.assigneesAvatar);
for(int i = 0; i < assigneesList.size(); i++) { for(int i = 0; i < assigneesList.size(); i++) {

View File

@ -23,7 +23,7 @@ import java.util.List;
public class CollaboratorsAdapter extends BaseAdapter { public class CollaboratorsAdapter extends BaseAdapter {
private final List<Collaborators> collaboratorsList; private final List<Collaborators> collaboratorsList;
private final Context mCtx; private final Context context;
private static class ViewHolder { private static class ViewHolder {
@ -46,9 +46,9 @@ public class CollaboratorsAdapter extends BaseAdapter {
} }
} }
public CollaboratorsAdapter(Context mCtx, List<Collaborators> collaboratorsListMain) { public CollaboratorsAdapter(Context ctx, List<Collaborators> collaboratorsListMain) {
this.mCtx = mCtx; this.context = ctx;
this.collaboratorsList = collaboratorsListMain; this.collaboratorsList = collaboratorsListMain;
} }
@ -75,7 +75,7 @@ public class CollaboratorsAdapter extends BaseAdapter {
if (finalView == null) { if (finalView == null) {
finalView = LayoutInflater.from(mCtx).inflate(R.layout.list_collaborators, null); finalView = LayoutInflater.from(context).inflate(R.layout.list_collaborators, null);
viewHolder = new ViewHolder(finalView); viewHolder = new ViewHolder(finalView);
finalView.setTag(viewHolder); finalView.setTag(viewHolder);
} }
@ -90,8 +90,10 @@ public class CollaboratorsAdapter extends BaseAdapter {
private void initData(ViewHolder viewHolder, int position) { private void initData(ViewHolder viewHolder, int position) {
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
Collaborators currentItem = collaboratorsList.get(position); Collaborators currentItem = collaboratorsList.get(position);
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.collaboratorAvatar); PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(viewHolder.collaboratorAvatar);
viewHolder.userLoginId = currentItem.getLogin(); viewHolder.userLoginId = currentItem.getLogin();

View File

@ -26,7 +26,7 @@ import java.util.Locale;
public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final Context ctx; private final Context context;
private final int TYPE_LOAD = 0; private final int TYPE_LOAD = 0;
private List<Commits> commitsList; private List<Commits> commitsList;
private CommitsAdapter.OnLoadMoreListener loadMoreListener; private CommitsAdapter.OnLoadMoreListener loadMoreListener;
@ -35,7 +35,7 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
public CommitsAdapter(Context ctx, List<Commits> commitsListMain) { public CommitsAdapter(Context ctx, List<Commits> commitsListMain) {
this.ctx = ctx; this.context = ctx;
this.commitsList = commitsListMain; this.commitsList = commitsListMain;
} }
@ -44,7 +44,7 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
@Override @Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(ctx); LayoutInflater inflater = LayoutInflater.from(context);
if(viewType == TYPE_LOAD) { if(viewType == TYPE_LOAD) {
return new CommitsHolder(inflater.inflate(R.layout.list_commits, parent, false)); return new CommitsHolder(inflater.inflate(R.layout.list_commits, parent, false));
@ -52,7 +52,6 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
else { else {
return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false)); return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
} }
} }
@Override @Override
@ -62,13 +61,11 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
isLoading = true; isLoading = true;
loadMoreListener.onLoadMore(); loadMoreListener.onLoadMore();
} }
if(getItemViewType(position) == TYPE_LOAD) { if(getItemViewType(position) == TYPE_LOAD) {
((CommitsHolder) holder).bindData(commitsList.get(position)); ((CommitsHolder) holder).bindData(commitsList.get(position));
} }
} }
@ -82,14 +79,12 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
else { else {
return 1; return 1;
} }
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return commitsList.size(); return commitsList.size();
} }
class CommitsHolder extends RecyclerView.ViewHolder { class CommitsHolder extends RecyclerView.ViewHolder {
@ -107,27 +102,25 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
commitCommitter = itemView.findViewById(R.id.commitCommitterVw); commitCommitter = itemView.findViewById(R.id.commitCommitterVw);
commitDate = itemView.findViewById(R.id.commitDateVw); commitDate = itemView.findViewById(R.id.commitDateVw);
commitHtmlUrl = itemView.findViewById(R.id.commitHtmlUrlVw); commitHtmlUrl = itemView.findViewById(R.id.commitHtmlUrlVw);
} }
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
void bindData(Commits commitsModel) { void bindData(Commits commitsModel) {
final TinyDB tinyDb = TinyDB.getInstance(ctx); final TinyDB tinyDb = TinyDB.getInstance(context);
final String locale = tinyDb.getString("locale"); final String locale = tinyDb.getString("locale");
final String timeFormat = tinyDb.getString("dateFormat"); final String timeFormat = tinyDb.getString("dateFormat");
commitTitle.setText(EmojiParser.parseToUnicode(commitsModel.getCommit().getMessage())); commitTitle.setText(EmojiParser.parseToUnicode(commitsModel.getCommit().getMessage()));
commitCommitter.setText(ctx.getString(R.string.commitCommittedBy, commitsModel.getCommit().getCommitter().getName())); commitCommitter.setText(context.getString(R.string.commitCommittedBy, commitsModel.getCommit().getCommitter().getName()));
commitDate.setText(TimeHelper.formatTime(commitsModel.getCommit().getCommitter().getDate(), new Locale(locale), timeFormat, ctx)); commitDate.setText(TimeHelper.formatTime(commitsModel.getCommit().getCommitter().getDate(), new Locale(locale), timeFormat, context));
if(timeFormat.equals("pretty")) { if(timeFormat.equals("pretty")) {
commitDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(commitsModel.getCommit().getCommitter().getDate()), ctx)); commitDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(commitsModel.getCommit().getCommitter().getDate()), context));
} }
commitHtmlUrl.setOnClickListener(v -> ctx.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(commitsModel.getHtml_url())))); commitHtmlUrl.setOnClickListener(v -> context.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(commitsModel.getHtml_url()))));
} }
} }
@ -138,32 +131,27 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
super(itemView); super(itemView);
} }
} }
public void setMoreDataAvailable(boolean moreDataAvailable) { public void setMoreDataAvailable(boolean moreDataAvailable) {
isMoreDataAvailable = moreDataAvailable; isMoreDataAvailable = moreDataAvailable;
} }
public void notifyDataChanged() { public void notifyDataChanged() {
notifyDataSetChanged(); notifyDataSetChanged();
isLoading = false; isLoading = false;
} }
public interface OnLoadMoreListener { public interface OnLoadMoreListener {
void onLoadMore(); void onLoadMore();
} }
public void setLoadMoreListener(CommitsAdapter.OnLoadMoreListener loadMoreListener) { public void setLoadMoreListener(CommitsAdapter.OnLoadMoreListener loadMoreListener) {
this.loadMoreListener = loadMoreListener; this.loadMoreListener = loadMoreListener;
} }
public void updateList(List<Commits> list) { public void updateList(List<Commits> list) {

View File

@ -1,59 +0,0 @@
package org.mian.gitnex.adapters;
import android.text.SpannableStringBuilder;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import org.mian.gitnex.R;
import java.util.List;
/**
* Author M M Arif
*/
public class CreditsAdapter extends RecyclerView.Adapter<CreditsAdapter.CreditsViewHolder> {
private List<CharSequence> creditsList;
static class CreditsViewHolder extends RecyclerView.ViewHolder {
private TextView creditText;
private CreditsViewHolder(View itemView) {
super(itemView);
creditText = itemView.findViewById(R.id.creditText);
}
}
public CreditsAdapter(List<CharSequence> creditsListMain) {
this.creditsList = creditsListMain;
}
@NonNull
@Override
public CreditsAdapter.CreditsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.credits, parent, false);
return new CreditsAdapter.CreditsViewHolder(v);
}
@Override
public void onBindViewHolder(@NonNull CreditsAdapter.CreditsViewHolder holder, int position) {
SpannableStringBuilder strBuilder = new SpannableStringBuilder(creditsList.get(position));
holder.creditText.setText((strBuilder));
holder.creditText.setMovementMethod(LinkMovementMethod.getInstance());
}
@Override
public int getItemCount() {
return creditsList.size();
}
}

View File

@ -33,7 +33,7 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
private List<DraftWithRepository> draftsList; private List<DraftWithRepository> draftsList;
private final FragmentManager fragmentManager; private final FragmentManager fragmentManager;
private final Context mCtx; private final Context context;
class DraftsViewHolder extends RecyclerView.ViewHolder { class DraftsViewHolder extends RecyclerView.ViewHolder {
@ -56,9 +56,8 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
int getDraftId = draftWithRepository.getDraftId(); int getDraftId = draftWithRepository.getDraftId();
deleteDraft(getAdapterPosition()); deleteDraft(getAdapterPosition());
DraftsApi draftsApi = new DraftsApi(mCtx); DraftsApi draftsApi = new DraftsApi(context);
draftsApi.deleteSingleDraft(getDraftId); draftsApi.deleteSingleDraft(getDraftId);
}); });
itemView.setOnClickListener(itemEdit -> { itemView.setOnClickListener(itemEdit -> {
@ -76,24 +75,23 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
bundle.putString("commentAction", "edit"); bundle.putString("commentAction", "edit");
} }
TinyDB tinyDb = TinyDB.getInstance(mCtx); TinyDB tinyDb = TinyDB.getInstance(context);
tinyDb.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId())); tinyDb.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId()));
tinyDb.putLong("repositoryId", draftWithRepository.getRepositoryId()); tinyDb.putLong("repositoryId", draftWithRepository.getRepositoryId());
tinyDb.putString("issueType", draftWithRepository.getIssueType()); tinyDb.putString("issueType", draftWithRepository.getIssueType());
tinyDb.putString("repoFullName", draftWithRepository.getRepositoryOwner() + "/" + draftWithRepository.getRepositoryName()); tinyDb.putString("repoFullName", draftWithRepository.getRepositoryOwner() + "/" + draftWithRepository.getRepositoryName());
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle); BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle);
bottomSheetReplyFragment.setOnInteractedListener(() -> mCtx.startActivity(new Intent(mCtx, IssueDetailActivity.class))); bottomSheetReplyFragment.setOnInteractedListener(() -> context.startActivity(new Intent(context, IssueDetailActivity.class)));
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet"); bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
}); });
} }
} }
public DraftsAdapter(Context mCtx, FragmentManager fragmentManager, List<DraftWithRepository> draftsListMain) { public DraftsAdapter(Context ctx, FragmentManager fragmentManager, List<DraftWithRepository> draftsListMain) {
this.mCtx = mCtx; this.context = ctx;
this.fragmentManager = fragmentManager; this.fragmentManager = fragmentManager;
this.draftsList = draftsListMain; this.draftsList = draftsListMain;
} }
@ -103,8 +101,7 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
draftsList.remove(position); draftsList.remove(position);
notifyItemRemoved(position); notifyItemRemoved(position);
notifyItemRangeChanged(position, draftsList.size()); notifyItemRangeChanged(position, draftsList.size());
Toasty.success(mCtx, mCtx.getResources().getString(R.string.draftsSingleDeleteSuccess)); Toasty.success(context, context.getResources().getString(R.string.draftsSingleDeleteSuccess));
} }
@NonNull @NonNull
@ -120,14 +117,14 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
DraftWithRepository currentItem = draftsList.get(position); DraftWithRepository currentItem = draftsList.get(position);
String issueNumber = "<font color='" + ResourcesCompat.getColor(mCtx.getResources(), R.color.lightGray, null) + "'>" + mCtx.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>"; String issueNumber = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
Spanned headTitle = HtmlCompat Spanned headTitle = HtmlCompat
.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName(), HtmlCompat.FROM_HTML_MODE_LEGACY); .fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName(), HtmlCompat.FROM_HTML_MODE_LEGACY);
holder.repoInfo.setText(headTitle); holder.repoInfo.setText(headTitle);
holder.draftWithRepository = currentItem; holder.draftWithRepository = currentItem;
Markdown.render(mCtx, currentItem.getDraftText(), holder.draftText); Markdown.render(context, currentItem.getDraftText(), holder.draftText);
if(!currentItem.getCommentId().equalsIgnoreCase("new")) { if(!currentItem.getCommentId().equalsIgnoreCase("new")) {
holder.editCommentStatus.setVisibility(View.VISIBLE); holder.editCommentStatus.setVisibility(View.VISIBLE);

View File

@ -1,8 +1,5 @@
package org.mian.gitnex.adapters; package org.mian.gitnex.adapters;
import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
@ -11,30 +8,30 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.TextDrawable;
import com.amulyakhare.textdrawable.util.ColorGenerator; import com.amulyakhare.textdrawable.util.ColorGenerator;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import org.gitnex.tea4j.models.UserRepositories; import org.gitnex.tea4j.models.UserRepositories;
import org.gitnex.tea4j.models.WatchInfo; import org.gitnex.tea4j.models.WatchInfo;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity; import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.database.api.RepositoriesApi; import org.mian.gitnex.database.api.RepositoriesApi;
import org.mian.gitnex.database.models.Repository; import org.mian.gitnex.database.models.Repository;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.ClickListener;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TimeHelper;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.Toasty;
import org.ocpsoft.prettytime.PrettyTime;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Locale;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -44,65 +41,59 @@ import retrofit2.Callback;
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepositoriesAdapter.ReposSearchViewHolder> { public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepositoriesAdapter.ReposSearchViewHolder> {
private List<UserRepositories> searchedReposList; private final List<UserRepositories> reposList;
private Context mCtx; private final Context context;
public ExploreRepositoriesAdapter(List<UserRepositories> dataList, Context mCtx) { public ExploreRepositoriesAdapter(List<UserRepositories> dataList, Context ctx) {
this.mCtx = mCtx; this.context = ctx;
this.searchedReposList = dataList; this.reposList = dataList;
} }
static class ReposSearchViewHolder extends RecyclerView.ViewHolder { static class ReposSearchViewHolder extends RecyclerView.ViewHolder {
private ImageView image; private UserRepositories userRepositories;
private TextView repoName;
private TextView repoDescription; private final ImageView image;
private TextView fullName; private final TextView repoName;
private final TextView orgName;
private final TextView repoDescription;
private CheckBox isRepoAdmin; private CheckBox isRepoAdmin;
private ImageView repoPrivatePublic; private final TextView repoStars;
private TextView repoStars; private final TextView repoLastUpdated;
private TextView repoForks;
private TextView repoOpenIssuesCount;
private TextView repoType;
private LinearLayout archiveRepo;
private TextView repoBranch;
private TextView htmlUrl;
private ReposSearchViewHolder(View itemView) { private ReposSearchViewHolder(View itemView) {
super(itemView); super(itemView);
repoName = itemView.findViewById(R.id.repoName); repoName = itemView.findViewById(R.id.repoName);
orgName = itemView.findViewById(R.id.orgName);
repoDescription = itemView.findViewById(R.id.repoDescription); repoDescription = itemView.findViewById(R.id.repoDescription);
image = itemView.findViewById(R.id.imageAvatar);
fullName = itemView.findViewById(R.id.repoFullName);
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin); isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType); image = itemView.findViewById(R.id.imageAvatar);
repoStars = itemView.findViewById(R.id.repoStars); repoStars = itemView.findViewById(R.id.repoStars);
repoForks = itemView.findViewById(R.id.repoForks); repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
repoType = itemView.findViewById(R.id.repoType);
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
repoBranch = itemView.findViewById(R.id.repoBranch);
htmlUrl = itemView.findViewById(R.id.htmlUrl);
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
Context context = v.getContext(); Context context = v.getContext();
TextView repoFullName = v.findViewById(R.id.repoFullName); TinyDB tinyDb = TinyDB.getInstance(context);
Intent intent = new Intent(context, RepoDetailActivity.class); Intent intent = new Intent(context, RepoDetailActivity.class);
intent.putExtra("repoFullName", repoFullName.getText().toString()); intent.putExtra("repoFullName", userRepositories.getFullName());
TinyDB tinyDb = TinyDB.getInstance(context); tinyDb.putString("repoFullName", userRepositories.getFullName());
tinyDb.putString("repoFullName", repoFullName.getText().toString());
tinyDb.putBoolean("resumeIssues", true); tinyDb.putBoolean("resumeIssues", true);
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked()); tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
tinyDb.putString("repoBranch", repoBranch.getText().toString()); tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
String[] parts = fullName.getText().toString().split("/"); if(userRepositories.getPrivateFlag()) {
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
}
else {
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
}
String[] parts = userRepositories.getFullName().split("/");
final String repoOwner = parts[0]; final String repoOwner = parts[0];
final String repoName = parts[1]; final String repoName = parts[1];
@ -116,13 +107,11 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName); long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", id); tinyDb.putLong("repositoryId", id);
} }
else { else {
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName); Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", data.getRepositoryId()); tinyDb.putLong("repositoryId", data.getRepositoryId());
} }
//store if user is watching this repo //store if user is watching this repo
@ -165,7 +154,6 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
tinyDb.putBoolean("repoWatch", false); tinyDb.putBoolean("repoWatch", false);
Toasty.error(context, context.getString(R.string.genericApiStatusError)); Toasty.error(context, context.getString(R.string.genericApiStatusError));
} }
}); });
@ -174,74 +162,6 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
context.startActivity(intent); context.startActivity(intent);
}); });
reposDropdownMenu.setOnClickListener(v -> {
final Context context = v.getContext();
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
TextView repoForksList = view.findViewById(R.id.repoForksList);
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
BottomSheetDialog dialog = new BottomSheetDialog(context);
dialog.setContentView(view);
dialog.show();
repoCopyUrl.setOnClickListener(openInBrowser -> {
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
dialog.dismiss();
});
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
context.startActivity(intentOpenInBrowser);
dialog.dismiss();
});
repoStargazers.setOnClickListener(stargazers -> {
Intent intent = new Intent(context, RepoStargazersActivity.class);
intent.putExtra("repoFullNameForStars", fullName.getText());
context.startActivity(intent);
dialog.dismiss();
});
repoWatchers.setOnClickListener(watchers -> {
Intent intentW = new Intent(context, RepoWatchersActivity.class);
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
context.startActivity(intentW);
dialog.dismiss();
});
repoForksList.setOnClickListener(forks -> {
Intent intentW = new Intent(context, RepoForksActivity.class);
intentW.putExtra("repoFullNameForForks", fullName.getText());
context.startActivity(intentW);
dialog.dismiss();
});
});
} }
} }
@ -257,10 +177,16 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
@Override @Override
public void onBindViewHolder(@NonNull final ExploreRepositoriesAdapter.ReposSearchViewHolder holder, int position) { public void onBindViewHolder(@NonNull final ExploreRepositoriesAdapter.ReposSearchViewHolder holder, int position) {
UserRepositories currentItem = searchedReposList.get(position); TinyDB tinyDb = TinyDB.getInstance(context);
holder.repoDescription.setVisibility(View.GONE); UserRepositories currentItem = reposList.get(position);
holder.repoBranch.setText(currentItem.getDefault_branch()); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
holder.htmlUrl.setText(currentItem.getHtml_url());
String locale = tinyDb.getString("locale");
String timeFormat = tinyDb.getString("dateFormat");
holder.userRepositories = currentItem;
holder.orgName.setText(currentItem.getFullName().split("/")[0]);
holder.repoName.setText(currentItem.getFullName().split("/")[1]);
holder.repoStars.setText(currentItem.getStars_count());
ColorGenerator generator = ColorGenerator.MATERIAL; ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName()); int color = generator.getColor(currentItem.getName());
@ -270,7 +196,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
if(currentItem.getAvatar_url() != null) { if(currentItem.getAvatar_url() != null) {
if(!currentItem.getAvatar_url().equals("")) { if(!currentItem.getAvatar_url().equals("")) {
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image); PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.image);
} }
else { else {
holder.image.setImageDrawable(drawable); holder.image.setImageDrawable(drawable);
@ -280,41 +206,48 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
holder.image.setImageDrawable(drawable); holder.image.setImageDrawable(drawable);
} }
holder.repoName.setText(currentItem.getName()); if(currentItem.getUpdated_at() != null) {
switch(timeFormat) {
case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
String createdTime = prettyTime.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
break;
}
case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break;
}
case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break;
}
}
}
else {
holder.repoLastUpdated.setVisibility(View.GONE);
}
if(!currentItem.getDescription().equals("")) { if(!currentItem.getDescription().equals("")) {
holder.repoDescription.setVisibility(View.VISIBLE);
holder.repoDescription.setText(currentItem.getDescription()); holder.repoDescription.setText(currentItem.getDescription());
} }
holder.fullName.setText(currentItem.getFullName());
if(currentItem.getPrivateFlag()) {
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock);
holder.repoType.setText(R.string.strPrivate);
}
else {
holder.repoPrivatePublic.setVisibility(View.GONE);
holder.repoType.setText(R.string.strPublic);
}
holder.repoStars.setText(currentItem.getStars_count());
holder.repoForks.setText(currentItem.getForks_count());
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
if(holder.isRepoAdmin == null) { if(holder.isRepoAdmin == null) {
holder.isRepoAdmin = new CheckBox(mCtx); holder.isRepoAdmin = new CheckBox(context);
} }
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin()); holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
if(currentItem.isArchived()) {
holder.archiveRepo.setVisibility(View.VISIBLE);
}
else {
holder.archiveRepo.setVisibility(View.GONE);
}
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return searchedReposList.size(); return reposList.size();
} }
public void notifyDataChanged() { public void notifyDataChanged() {

View File

@ -27,7 +27,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
private final List<Files> originalFiles = new ArrayList<>(); private final List<Files> originalFiles = new ArrayList<>();
private final List<Files> alteredFiles = new ArrayList<>(); private final List<Files> alteredFiles = new ArrayList<>();
private final Context mCtx; private final Context context;
private final FilesAdapterListener filesListener; private final FilesAdapterListener filesListener;
@ -40,7 +40,6 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
private Files file; private Files file;
private final LinearLayout fileFrame;
private final ImageView fileTypeIs; private final ImageView fileTypeIs;
private final TextView fileName; private final TextView fileName;
private final TextView fileInfo; private final TextView fileInfo;
@ -49,7 +48,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
super(itemView); super(itemView);
fileFrame = itemView.findViewById(R.id.fileFrame); LinearLayout fileFrame = itemView.findViewById(R.id.fileFrame);
fileName = itemView.findViewById(R.id.fileName); fileName = itemView.findViewById(R.id.fileName);
fileTypeIs = itemView.findViewById(R.id.fileTypeIs); fileTypeIs = itemView.findViewById(R.id.fileTypeIs);
fileInfo = itemView.findViewById(R.id.fileInfo); fileInfo = itemView.findViewById(R.id.fileInfo);
@ -124,11 +123,10 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
} }
} }
public FilesAdapter(Context mCtx, FilesAdapterListener filesListener) { public FilesAdapter(Context ctx, FilesAdapterListener filesListener) {
this.mCtx = mCtx; this.context = ctx;
this.filesListener = filesListener; this.filesListener = filesListener;
} }
public List<Files> getOriginalFiles() { public List<Files> getOriginalFiles() {
@ -141,7 +139,6 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
alteredFiles.addAll(originalFiles); alteredFiles.addAll(originalFiles);
notifyDataSetChanged(); notifyDataSetChanged();
} }
@NonNull @NonNull
@ -162,28 +159,28 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
switch(currentItem.getType()) { switch(currentItem.getType()) {
case "file": case "file":
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(mCtx, R.drawable.ic_file)); holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_file));
holder.fileInfo.setVisibility(View.VISIBLE); holder.fileInfo.setVisibility(View.VISIBLE);
holder.fileInfo.setText(FileUtils.byteCountToDisplaySize(currentItem.getSize())); holder.fileInfo.setText(FileUtils.byteCountToDisplaySize(currentItem.getSize()));
break; break;
case "dir": case "dir":
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(mCtx, R.drawable.ic_directory)); holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_directory));
holder.fileInfo.setVisibility(View.GONE); holder.fileInfo.setVisibility(View.GONE);
break; break;
case "submodule": case "submodule":
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(mCtx, R.drawable.ic_submodule)); holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_submodule));
holder.fileInfo.setVisibility(View.GONE); holder.fileInfo.setVisibility(View.GONE);
break; break;
case "symlink": case "symlink":
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(mCtx, R.drawable.ic_symlink)); holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_symlink));
holder.fileInfo.setVisibility(View.GONE); holder.fileInfo.setVisibility(View.GONE);
break; break;
default: default:
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(mCtx, R.drawable.ic_question)); holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_question));
} }
} }

View File

@ -54,7 +54,6 @@ public class FilesDiffAdapter extends BaseAdapter {
COLOR_NORMAL = AppUtil.getColorFromAttribute(context, R.attr.primaryBackgroundColor); COLOR_NORMAL = AppUtil.getColorFromAttribute(context, R.attr.primaryBackgroundColor);
COLOR_SELECTED = AppUtil.getColorFromAttribute(context, R.attr.diffSelectedColor); COLOR_SELECTED = AppUtil.getColorFromAttribute(context, R.attr.diffSelectedColor);
COLOR_FONT = AppUtil.getColorFromAttribute(context, R.attr.inputTextColor); COLOR_FONT = AppUtil.getColorFromAttribute(context, R.attr.inputTextColor);
} }
@Override @Override
@ -94,7 +93,6 @@ public class FilesDiffAdapter extends BaseAdapter {
diffStats.setVisibility(View.GONE); diffStats.setVisibility(View.GONE);
diffLines.addView(getMessageView(context.getResources().getString(R.string.binaryFileError))); diffLines.addView(getMessageView(context.getResources().getString(R.string.binaryFileError)));
} }
else { else {
@ -168,7 +166,6 @@ public class FilesDiffAdapter extends BaseAdapter {
} }
diffTextView.setOnClickListener(v -> { diffTextView.setOnClickListener(v -> {
if(((DiffTextView) v).getCurrentBackgroundColor() != COLOR_SELECTED) { if(((DiffTextView) v).getCurrentBackgroundColor() != COLOR_SELECTED) {
@ -197,7 +194,6 @@ public class FilesDiffAdapter extends BaseAdapter {
stringBuilder.append(((DiffTextView) view).getText()); stringBuilder.append(((DiffTextView) view).getText());
stringBuilder.append("\n"); stringBuilder.append("\n");
} }
stringBuilder.append("```\n\n"); stringBuilder.append("```\n\n");
@ -209,7 +205,6 @@ public class FilesDiffAdapter extends BaseAdapter {
bundle.putBoolean("cursorToEnd", true); bundle.putBoolean("cursorToEnd", true);
BottomSheetReplyFragment.newInstance(bundle).show(fragmentManager, "replyBottomSheet"); BottomSheetReplyFragment.newInstance(bundle).show(fragmentManager, "replyBottomSheet");
} }
return true; return true;
@ -226,7 +221,6 @@ public class FilesDiffAdapter extends BaseAdapter {
else { else {
diffLines.addView(getMessageView(context.getResources().getString(R.string.fileTooLarge))); diffLines.addView(getMessageView(context.getResources().getString(R.string.fileTooLarge)));
} }
} }
@ -248,13 +242,11 @@ public class FilesDiffAdapter extends BaseAdapter {
textView.setText(message); textView.setText(message);
return textView; return textView;
} }
private String[] getLines(String content) { private String[] getLines(String content) {
return content.split("\\R"); return content.split("\\R");
} }
} }

View File

@ -44,7 +44,7 @@ import retrofit2.Callback;
public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdapter.IssueCommentViewHolder> { public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdapter.IssueCommentViewHolder> {
private final Context ctx; private final Context context;
private final TinyDB tinyDB; private final TinyDB tinyDB;
private final Bundle bundle; private final Bundle bundle;
private final List<IssueComments> issuesComments; private final List<IssueComments> issuesComments;
@ -53,14 +53,13 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
public IssueCommentsAdapter(Context ctx, Bundle bundle, List<IssueComments> issuesCommentsMain, FragmentManager fragmentManager, BottomSheetReplyFragment.OnInteractedListener onInteractedListener) { public IssueCommentsAdapter(Context ctx, Bundle bundle, List<IssueComments> issuesCommentsMain, FragmentManager fragmentManager, BottomSheetReplyFragment.OnInteractedListener onInteractedListener) {
this.ctx = ctx; this.context = ctx;
this.bundle = bundle; this.bundle = bundle;
this.issuesComments = issuesCommentsMain; this.issuesComments = issuesCommentsMain;
this.fragmentManager = fragmentManager; this.fragmentManager = fragmentManager;
this.onInteractedListener = onInteractedListener; this.onInteractedListener = onInteractedListener;
tinyDB = TinyDB.getInstance(ctx); tinyDB = TinyDB.getInstance(ctx);
} }
class IssueCommentViewHolder extends RecyclerView.ViewHolder { class IssueCommentViewHolder extends RecyclerView.ViewHolder {
@ -318,39 +317,40 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
String timeFormat = tinyDB.getString("dateFormat"); String timeFormat = tinyDB.getString("dateFormat");
IssueComments issueComment = issuesComments.get(position); IssueComments issueComment = issuesComments.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
holder.userLoginId = issueComment.getUser().getLogin(); holder.userLoginId = issueComment.getUser().getLogin();
holder.issueComment = issueComment; holder.issueComment = issueComment;
holder.author.setText(issueComment.getUser().getUsername()); holder.author.setText(issueComment.getUser().getUsername());
PicassoService.getInstance(ctx).get() PicassoService.getInstance(context).get()
.load(issueComment.getUser().getAvatar_url()) .load(issueComment.getUser().getAvatar_url())
.placeholder(R.drawable.loader_animated) .placeholder(R.drawable.loader_animated)
.transform(new RoundedTransformation(4, 0)) .transform(new RoundedTransformation(imgRadius, 0))
.resize(AppUtil.getPixelsFromDensity(ctx, 35), AppUtil.getPixelsFromDensity(ctx, 35)) .resize(AppUtil.getPixelsFromDensity(context, 35), AppUtil.getPixelsFromDensity(context, 35))
.centerCrop() .centerCrop()
.into(holder.avatar); .into(holder.avatar);
Markdown.render(ctx, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment); Markdown.render(context, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment);
StringBuilder informationBuilder = null; StringBuilder informationBuilder = null;
if(issueComment.getCreated_at() != null) { if(issueComment.getCreated_at() != null) {
if(timeFormat.equals("pretty")) { if(timeFormat.equals("pretty")) {
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), Locale.getDefault(), "pretty", ctx)); informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), Locale.getDefault(), "pretty", context));
holder.information.setOnClickListener(v -> TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreated_at())); holder.information.setOnClickListener(v -> TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreated_at()));
} }
else if(timeFormat.equals("normal")) { else if(timeFormat.equals("normal")) {
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), Locale.getDefault(), "normal", ctx)); informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), Locale.getDefault(), "normal", context));
} }
if(!issueComment.getCreated_at().equals(issueComment.getUpdated_at())) { if(!issueComment.getCreated_at().equals(issueComment.getUpdated_at())) {
if(informationBuilder != null) { if(informationBuilder != null) {
informationBuilder.append(ctx.getString(R.string.colorfulBulletSpan)).append(ctx.getString(R.string.modifiedText)); informationBuilder.append(context.getString(R.string.colorfulBulletSpan)).append(context.getString(R.string.modifiedText));
} }
} }
} }
@ -361,7 +361,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
bundle1.putAll(bundle); bundle1.putAll(bundle);
bundle1.putInt("commentId", issueComment.getId()); bundle1.putInt("commentId", issueComment.getId());
ReactionList reactionList = new ReactionList(ctx, bundle1); ReactionList reactionList = new ReactionList(context, bundle1);
holder.commentReactionBadges.addView(reactionList); holder.commentReactionBadges.addView(reactionList);
reactionList.setOnReactionAddedListener(() -> { reactionList.setOnReactionAddedListener(() -> {

View File

@ -7,7 +7,6 @@ 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.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat; import androidx.core.content.res.ResourcesCompat;
@ -41,11 +40,10 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
private OnLoadMoreListener loadMoreListener; private OnLoadMoreListener loadMoreListener;
private boolean isLoading = false, isMoreDataAvailable = true; private boolean isLoading = false, isMoreDataAvailable = true;
public IssuesAdapter(Context context, List<Issues> issuesListMain) { public IssuesAdapter(Context ctx, List<Issues> issuesListMain) {
this.context = context; this.context = ctx;
this.issuesList = issuesListMain; this.issuesList = issuesListMain;
} }
@NonNull @NonNull
@ -60,7 +58,6 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
else { else {
return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false)); return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
} }
} }
@Override @Override
@ -70,15 +67,12 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
isLoading = true; isLoading = true;
loadMoreListener.onLoadMore(); loadMoreListener.onLoadMore();
} }
if(getItemViewType(position) == TYPE_LOAD) { if(getItemViewType(position) == TYPE_LOAD) {
((IssuesHolder) holder).bindData(issuesList.get(position)); ((IssuesHolder) holder).bindData(issuesList.get(position));
} }
} }
@Override @Override
@ -90,14 +84,12 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
else { else {
return 1; return 1;
} }
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return issuesList.size(); return issuesList.size();
} }
class IssuesHolder extends RecyclerView.ViewHolder { class IssuesHolder extends RecyclerView.ViewHolder {
@ -112,16 +104,14 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
IssuesHolder(View itemView) { IssuesHolder(View itemView) {
super(itemView); super(itemView);
issueAssigneeAvatar = itemView.findViewById(R.id.assigneeAvatar); issueAssigneeAvatar = itemView.findViewById(R.id.assigneeAvatar);
issueTitle = itemView.findViewById(R.id.issueTitle); issueTitle = itemView.findViewById(R.id.issueTitle);
issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount); issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount);
LinearLayout frameCommentsCount = itemView.findViewById(R.id.frameCommentsCount);
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime); issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
issueTitle.setOnClickListener(title -> { itemView.setOnClickListener(layoutView -> {
Context context = title.getContext(); Context context = layoutView.getContext();
Intent intent = new Intent(context, IssueDetailActivity.class); Intent intent = new Intent(context, IssueDetailActivity.class);
intent.putExtra("issueNumber", issue.getNumber()); intent.putExtra("issueNumber", issue.getNumber());
@ -130,21 +120,6 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
tinyDb.putString("issueNumber", String.valueOf(issue.getNumber())); tinyDb.putString("issueNumber", String.valueOf(issue.getNumber()));
tinyDb.putString("issueType", "Issue"); tinyDb.putString("issueType", "Issue");
context.startActivity(intent); context.startActivity(intent);
});
frameCommentsCount.setOnClickListener(commentsCount -> {
Context context = commentsCount.getContext();
Intent intent = new Intent(context, IssueDetailActivity.class);
intent.putExtra("issueNumber", issue.getNumber());
TinyDB tinyDb = TinyDB.getInstance(context);
tinyDb.putString("issueNumber", String.valueOf(issue.getNumber()));
tinyDb.putString("issueType", "Issue");
context.startActivity(intent);
}); });
issueAssigneeAvatar.setOnClickListener(v -> { issueAssigneeAvatar.setOnClickListener(v -> {
@ -163,10 +138,12 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
String locale = tinyDb.getString("locale"); String locale = tinyDb.getString("locale");
String timeFormat = tinyDb.getString("dateFormat"); String timeFormat = tinyDb.getString("dateFormat");
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
PicassoService.getInstance(context).get() PicassoService.getInstance(context).get()
.load(issue.getUser().getAvatar_url()) .load(issue.getUser().getAvatar_url())
.placeholder(R.drawable.loader_animated) .placeholder(R.drawable.loader_animated)
.transform(new RoundedTransformation(8, 0)) .transform(new RoundedTransformation(imgRadius, 0))
.resize(120, 120) .resize(120, 120)
.centerCrop() .centerCrop()
.into(issueAssigneeAvatar); .into(issueAssigneeAvatar);
@ -209,32 +186,27 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
super(itemView); super(itemView);
} }
} }
public void setMoreDataAvailable(boolean moreDataAvailable) { public void setMoreDataAvailable(boolean moreDataAvailable) {
isMoreDataAvailable = moreDataAvailable; isMoreDataAvailable = moreDataAvailable;
} }
public void notifyDataChanged() { public void notifyDataChanged() {
notifyDataSetChanged(); notifyDataSetChanged();
isLoading = false; isLoading = false;
} }
public interface OnLoadMoreListener { public interface OnLoadMoreListener {
void onLoadMore(); void onLoadMore();
} }
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) { public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
this.loadMoreListener = loadMoreListener; this.loadMoreListener = loadMoreListener;
} }
public void updateList(List<Issues> list) { public void updateList(List<Issues> list) {

View File

@ -20,7 +20,6 @@ import org.mian.gitnex.R;
import org.mian.gitnex.activities.CreateLabelActivity; import org.mian.gitnex.activities.CreateLabelActivity;
import org.mian.gitnex.helpers.AlertDialogs; import org.mian.gitnex.helpers.AlertDialogs;
import org.mian.gitnex.helpers.ColorInverter; import org.mian.gitnex.helpers.ColorInverter;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -29,21 +28,17 @@ import java.util.List;
public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsViewHolder> { public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsViewHolder> {
private List<Labels> labelsList; private final List<Labels> labelsList;
final private Context mCtx;
private ArrayList<Integer> labelsArray = new ArrayList<>();
private static String type; private static String type;
private static String orgName; private static String orgName;
static class LabelsViewHolder extends RecyclerView.ViewHolder { static class LabelsViewHolder extends RecyclerView.ViewHolder {
private TextView labelTitle; private Labels labels;
private TextView labelId;
private TextView labelColor;
private CardView labelView; private final CardView labelView;
private ImageView labelIcon; private final ImageView labelIcon;
private TextView labelName; private final TextView labelName;
private LabelsViewHolder(View itemView) { private LabelsViewHolder(View itemView) {
super(itemView); super(itemView);
@ -52,9 +47,6 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
labelIcon = itemView.findViewById(R.id.labelIcon); labelIcon = itemView.findViewById(R.id.labelIcon);
labelName = itemView.findViewById(R.id.labelName); labelName = itemView.findViewById(R.id.labelName);
ImageView labelsOptionsMenu = itemView.findViewById(R.id.labelsOptionsMenu); ImageView labelsOptionsMenu = itemView.findViewById(R.id.labelsOptionsMenu);
labelTitle = itemView.findViewById(R.id.labelTitle);
labelId = itemView.findViewById(R.id.labelId);
labelColor = itemView.findViewById(R.id.labelColor);
labelsOptionsMenu.setOnClickListener(v -> { labelsOptionsMenu.setOnClickListener(v -> {
@ -67,7 +59,7 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
TextView labelMenuDelete = view.findViewById(R.id.labelMenuDelete); TextView labelMenuDelete = view.findViewById(R.id.labelMenuDelete);
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader); TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
bottomSheetHeader.setText(labelTitle.getText()); bottomSheetHeader.setText(labels.getName());
BottomSheetDialog dialog = new BottomSheetDialog(context); BottomSheetDialog dialog = new BottomSheetDialog(context);
dialog.setContentView(view); dialog.setContentView(view);
dialog.show(); dialog.show();
@ -75,27 +67,25 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
labelMenuEdit.setOnClickListener(editLabel -> { labelMenuEdit.setOnClickListener(editLabel -> {
Intent intent = new Intent(context, CreateLabelActivity.class); Intent intent = new Intent(context, CreateLabelActivity.class);
intent.putExtra("labelId", labelId.getText()); intent.putExtra("labelId", String.valueOf(labels.getId()));
intent.putExtra("labelTitle", labelTitle.getText()); intent.putExtra("labelTitle", labels.getName());
intent.putExtra("labelColor", labelColor.getText()); intent.putExtra("labelColor", labels.getColor());
intent.putExtra("labelAction", "edit"); intent.putExtra("labelAction", "edit");
intent.putExtra("type", type); intent.putExtra("type", type);
intent.putExtra("orgName", orgName); intent.putExtra("orgName", orgName);
context.startActivity(intent); context.startActivity(intent);
dialog.dismiss(); dialog.dismiss();
}); });
labelMenuDelete.setOnClickListener(deleteLabel -> { labelMenuDelete.setOnClickListener(deleteLabel -> {
AlertDialogs.labelDeleteDialog(context, labelTitle.getText().toString(), labelId.getText().toString(), AlertDialogs.labelDeleteDialog(context, labels.getName(), String.valueOf(labels.getId()),
context.getResources().getString(R.string.labelDeleteTitle), context.getResources().getString(R.string.labelDeleteTitle),
context.getResources().getString(R.string.labelDeleteMessage), context.getResources().getString(R.string.labelDeleteMessage),
context.getResources().getString(R.string.labelDeleteTitle), context.getResources().getString(R.string.labelDeleteTitle),
context.getResources().getString(R.string.labelDeleteNegativeButton), context.getResources().getString(R.string.labelDeleteNegativeButton),
type, orgName); type, orgName);
dialog.dismiss(); dialog.dismiss();
}); });
}); });
@ -103,9 +93,8 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
} }
} }
public LabelsAdapter(Context mCtx, List<Labels> labelsMain, String type, String orgName) { public LabelsAdapter(Context ctx, List<Labels> labelsMain, String type, String orgName) {
this.mCtx = mCtx;
this.labelsList = labelsMain; this.labelsList = labelsMain;
LabelsAdapter.type = type; LabelsAdapter.type = type;
LabelsAdapter.orgName = orgName; LabelsAdapter.orgName = orgName;
@ -122,10 +111,7 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
public void onBindViewHolder(@NonNull LabelsAdapter.LabelsViewHolder holder, int position) { public void onBindViewHolder(@NonNull LabelsAdapter.LabelsViewHolder holder, int position) {
Labels currentItem = labelsList.get(position); Labels currentItem = labelsList.get(position);
holder.labels = currentItem;
holder.labelTitle.setText(currentItem.getName());
holder.labelId.setText(String.valueOf(currentItem.getId()));
holder.labelColor.setText(currentItem.getColor());
String labelColor = currentItem.getColor(); String labelColor = currentItem.getColor();
String labelName = currentItem.getName(); String labelName = currentItem.getName();
@ -138,7 +124,6 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
holder.labelName.setTextColor(contrastColor); holder.labelName.setTextColor(contrastColor);
holder.labelName.setText(labelName); holder.labelName.setText(labelName);
holder.labelView.setCardBackgroundColor(color); holder.labelView.setCardBackgroundColor(color);
} }
@Override @Override

View File

@ -22,11 +22,11 @@ import java.util.List;
public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.LabelsViewHolder> { public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.LabelsViewHolder> {
private List<Integer> currentLabelsIds; private List<Integer> currentLabelsIds;
private List<Labels> labels; private final List<Labels> labels;
private List<String> labelsStrings = new ArrayList<>(); private final List<String> labelsStrings = new ArrayList<>();
private List<Integer> labelsIds = new ArrayList<>(); private List<Integer> labelsIds = new ArrayList<>();
private LabelsListAdapterListener labelsListener; private final LabelsListAdapterListener labelsListener;
public interface LabelsListAdapterListener { public interface LabelsListAdapterListener {
@ -43,9 +43,9 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
static class LabelsViewHolder extends RecyclerView.ViewHolder { static class LabelsViewHolder extends RecyclerView.ViewHolder {
private CheckBox labelSelection; private final CheckBox labelSelection;
private TextView labelText; private final TextView labelText;
private ImageView labelColor; private final ImageView labelColor;
private LabelsViewHolder(View itemView) { private LabelsViewHolder(View itemView) {

View File

@ -26,7 +26,7 @@ import java.util.List;
public class MembersByOrgAdapter extends BaseAdapter implements Filterable { public class MembersByOrgAdapter extends BaseAdapter implements Filterable {
private final List<UserInfo> membersList; private final List<UserInfo> membersList;
private final Context mCtx; private final Context context;
private final List<UserInfo> membersListFull; private final List<UserInfo> membersListFull;
private static class ViewHolder { private static class ViewHolder {
@ -50,9 +50,9 @@ public class MembersByOrgAdapter extends BaseAdapter implements Filterable {
} }
} }
public MembersByOrgAdapter(Context mCtx, List<UserInfo> membersListMain) { public MembersByOrgAdapter(Context ctx, List<UserInfo> membersListMain) {
this.mCtx = mCtx; this.context = ctx;
this.membersList = membersListMain; this.membersList = membersListMain;
membersListFull = new ArrayList<>(membersList); membersListFull = new ArrayList<>(membersList);
} }
@ -80,7 +80,7 @@ public class MembersByOrgAdapter extends BaseAdapter implements Filterable {
if (finalView == null) { if (finalView == null) {
finalView = LayoutInflater.from(mCtx).inflate(R.layout.list_members_by_org, null); finalView = LayoutInflater.from(context).inflate(R.layout.list_members_by_org, null);
viewHolder = new ViewHolder(finalView); viewHolder = new ViewHolder(finalView);
finalView.setTag(viewHolder); finalView.setTag(viewHolder);
} }
@ -96,7 +96,9 @@ public class MembersByOrgAdapter extends BaseAdapter implements Filterable {
private void initData(MembersByOrgAdapter.ViewHolder viewHolder, int position) { private void initData(MembersByOrgAdapter.ViewHolder viewHolder, int position) {
UserInfo currentItem = membersList.get(position); UserInfo currentItem = membersList.get(position);
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(viewHolder.memberAvatar); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(viewHolder.memberAvatar);
viewHolder.userLoginId = currentItem.getLogin(); viewHolder.userLoginId = currentItem.getLogin();
@ -108,7 +110,6 @@ public class MembersByOrgAdapter extends BaseAdapter implements Filterable {
viewHolder.memberName.setText(currentItem.getLogin()); viewHolder.memberName.setText(currentItem.getLogin());
} }
} }
@Override @Override

View File

@ -35,19 +35,17 @@ import java.util.Locale;
public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context; private final Context context;
private final int TYPE_LOAD = 0; private final int TYPE_LOAD = 0;
private List<Milestones> dataList; private List<Milestones> dataList;
private OnLoadMoreListener loadMoreListener; private OnLoadMoreListener loadMoreListener;
private boolean isLoading = false; private boolean isLoading = false;
private boolean isMoreDataAvailable = true; private boolean isMoreDataAvailable = true;
private String TAG = Constants.tagMilestonesAdapter;
public MilestonesAdapter(Context context, List<Milestones> dataListMain) { public MilestonesAdapter(Context ctx, List<Milestones> dataListMain) {
this.context = context; this.context = ctx;
this.dataList = dataListMain; this.dataList = dataListMain;
} }
@NonNull @NonNull
@ -62,7 +60,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
else { else {
return new MilestonesAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false)); return new MilestonesAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
} }
} }
@Override @Override
@ -72,33 +69,29 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
isLoading = true; isLoading = true;
loadMoreListener.onLoadMore(); loadMoreListener.onLoadMore();
} }
if(getItemViewType(position) == TYPE_LOAD) { if(getItemViewType(position) == TYPE_LOAD) {
((MilestonesAdapter.DataHolder) holder).bindData(dataList.get(position)); ((MilestonesAdapter.DataHolder) holder).bindData(dataList.get(position));
} }
} }
class DataHolder extends RecyclerView.ViewHolder { class DataHolder extends RecyclerView.ViewHolder {
private TextView milestoneId; private Milestones milestones;
private TextView msTitle;
private TextView msDescription; private final TextView msTitle;
private TextView msOpenIssues; private final TextView msDescription;
private TextView msClosedIssues; private final TextView msOpenIssues;
private TextView msDueDate; private final TextView msClosedIssues;
private ProgressBar msProgress; private final TextView msDueDate;
private TextView milestoneStatus; private final ProgressBar msProgress;
DataHolder(View itemView) { DataHolder(View itemView) {
super(itemView); super(itemView);
milestoneId = itemView.findViewById(R.id.milestoneId);
msTitle = itemView.findViewById(R.id.milestoneTitle); msTitle = itemView.findViewById(R.id.milestoneTitle);
msDescription = itemView.findViewById(R.id.milestoneDescription); msDescription = itemView.findViewById(R.id.milestoneDescription);
msOpenIssues = itemView.findViewById(R.id.milestoneIssuesOpen); msOpenIssues = itemView.findViewById(R.id.milestoneIssuesOpen);
@ -106,12 +99,11 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
msDueDate = itemView.findViewById(R.id.milestoneDueDate); msDueDate = itemView.findViewById(R.id.milestoneDueDate);
msProgress = itemView.findViewById(R.id.milestoneProgress); msProgress = itemView.findViewById(R.id.milestoneProgress);
ImageView milestonesMenu = itemView.findViewById(R.id.milestonesMenu); ImageView milestonesMenu = itemView.findViewById(R.id.milestonesMenu);
milestoneStatus = itemView.findViewById(R.id.milestoneStatus);
milestonesMenu.setOnClickListener(v -> { milestonesMenu.setOnClickListener(v -> {
Context ctx = v.getContext(); Context ctx = v.getContext();
int milestoneId_ = Integer.parseInt(milestoneId.getText().toString()); int milestoneId_ = Integer.parseInt(String.valueOf(milestones.getId()));
@SuppressLint("InflateParams") View view = LayoutInflater.from(ctx).inflate(R.layout.bottom_sheet_milestones_in_list, null); @SuppressLint("InflateParams") View view = LayoutInflater.from(ctx).inflate(R.layout.bottom_sheet_milestones_in_list, null);
@ -122,17 +114,15 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
dialog.setContentView(view); dialog.setContentView(view);
dialog.show(); dialog.show();
if(milestoneStatus.getText().toString().equals("open")) { if(milestones.getState().equals("open")) {
closeMilestone.setVisibility(View.VISIBLE); closeMilestone.setVisibility(View.VISIBLE);
openMilestone.setVisibility(View.GONE); openMilestone.setVisibility(View.GONE);
} }
else { else {
closeMilestone.setVisibility(View.GONE); closeMilestone.setVisibility(View.GONE);
openMilestone.setVisibility(View.VISIBLE); openMilestone.setVisibility(View.VISIBLE);
} }
closeMilestone.setOnClickListener(v12 -> { closeMilestone.setOnClickListener(v12 -> {
@ -140,7 +130,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
MilestoneActions.closeMilestone(ctx, milestoneId_); MilestoneActions.closeMilestone(ctx, milestoneId_);
dialog.dismiss(); dialog.dismiss();
updateAdapter(getAdapterPosition()); updateAdapter(getAdapterPosition());
}); });
openMilestone.setOnClickListener(v12 -> { openMilestone.setOnClickListener(v12 -> {
@ -148,7 +137,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
MilestoneActions.openMilestone(ctx, milestoneId_); MilestoneActions.openMilestone(ctx, milestoneId_);
dialog.dismiss(); dialog.dismiss();
updateAdapter(getAdapterPosition()); updateAdapter(getAdapterPosition());
}); });
}); });
@ -158,13 +146,11 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
void bindData(Milestones dataModel) { void bindData(Milestones dataModel) {
this.milestones = dataModel;
final TinyDB tinyDb = TinyDB.getInstance(context); final TinyDB tinyDb = TinyDB.getInstance(context);
final String locale = tinyDb.getString("locale"); final String locale = tinyDb.getString("locale");
final String timeFormat = tinyDb.getString("dateFormat"); final String timeFormat = tinyDb.getString("dateFormat");
milestoneId.setText(String.valueOf(dataModel.getId()));
milestoneStatus.setText(dataModel.getState());
Markdown.render(context, dataModel.getTitle(), msTitle); Markdown.render(context, dataModel.getTitle(), msTitle);
if(!dataModel.getDescription().equals("")) { if(!dataModel.getDescription().equals("")) {
@ -185,14 +171,12 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
msProgress.setProgress(100); msProgress.setProgress(100);
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 100), context)); msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 100), context));
} }
else { else {
int msCompletion = 100 * dataModel.getClosed_issues() / (dataModel.getOpen_issues() + dataModel.getClosed_issues()); int msCompletion = 100 * dataModel.getClosed_issues() / (dataModel.getOpen_issues() + dataModel.getClosed_issues());
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, msCompletion), context)); msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, msCompletion), context));
msProgress.setProgress(msCompletion); msProgress.setProgress(msCompletion);
} }
} }
@ -200,11 +184,11 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
msProgress.setProgress(0); msProgress.setProgress(0);
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 0), context)); msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 0), context));
} }
if(dataModel.getDue_on() != null) { if(dataModel.getDue_on() != null) {
String TAG = Constants.tagMilestonesAdapter;
if(timeFormat.equals("normal") || timeFormat.equals("pretty")) { if(timeFormat.equals("normal") || timeFormat.equals("pretty")) {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale));
@ -226,7 +210,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
msDueDate.setText(dueDate); msDueDate.setText(dueDate);
msDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToast(dataModel.getDue_on()), context)); msDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToast(dataModel.getDue_on()), context));
} }
else if(timeFormat.equals("normal1")) { else if(timeFormat.equals("normal1")) {
@ -244,7 +227,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
assert date1 != null; assert date1 != null;
String dueDate = formatter.format(date1); String dueDate = formatter.format(date1);
msDueDate.setText(dueDate); msDueDate.setText(dueDate);
} }
} }
@ -262,7 +244,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
dataList.remove(position); dataList.remove(position);
notifyItemRemoved(position); notifyItemRemoved(position);
notifyItemRangeChanged(position, dataList.size()); notifyItemRangeChanged(position, dataList.size());
} }
@Override @Override
@ -274,14 +255,12 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
else { else {
return 1; return 1;
} }
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return dataList.size(); return dataList.size();
} }
static class LoadHolder extends RecyclerView.ViewHolder { static class LoadHolder extends RecyclerView.ViewHolder {
@ -290,32 +269,27 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
super(itemView); super(itemView);
} }
} }
public void setMoreDataAvailable(boolean moreDataAvailable) { public void setMoreDataAvailable(boolean moreDataAvailable) {
isMoreDataAvailable = moreDataAvailable; isMoreDataAvailable = moreDataAvailable;
} }
public void notifyDataChanged() { public void notifyDataChanged() {
notifyDataSetChanged(); notifyDataSetChanged();
isLoading = false; isLoading = false;
} }
public interface OnLoadMoreListener { public interface OnLoadMoreListener {
void onLoadMore(); void onLoadMore();
} }
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) { public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
this.loadMoreListener = loadMoreListener; this.loadMoreListener = loadMoreListener;
} }
public void updateList(List<Milestones> list) { public void updateList(List<Milestones> list) {

View File

@ -1,8 +1,5 @@
package org.mian.gitnex.adapters; package org.mian.gitnex.adapters;
import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
@ -13,31 +10,31 @@ import android.widget.CheckBox;
import android.widget.Filter; import android.widget.Filter;
import android.widget.Filterable; import android.widget.Filterable;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.TextDrawable;
import com.amulyakhare.textdrawable.util.ColorGenerator; import com.amulyakhare.textdrawable.util.ColorGenerator;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import org.gitnex.tea4j.models.UserRepositories; import org.gitnex.tea4j.models.UserRepositories;
import org.gitnex.tea4j.models.WatchInfo; import org.gitnex.tea4j.models.WatchInfo;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity; import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.database.api.RepositoriesApi; import org.mian.gitnex.database.api.RepositoriesApi;
import org.mian.gitnex.database.models.Repository; import org.mian.gitnex.database.models.Repository;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.ClickListener;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TimeHelper;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.Toasty;
import org.ocpsoft.prettytime.PrettyTime;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Locale;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -47,59 +44,54 @@ import retrofit2.Callback;
public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.MyReposViewHolder> implements Filterable { public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.MyReposViewHolder> implements Filterable {
private List<UserRepositories> reposList; private final List<UserRepositories> reposList;
private Context mCtx; private final Context context;
private List<UserRepositories> reposListFull; private final List<UserRepositories> reposListFull;
static class MyReposViewHolder extends RecyclerView.ViewHolder { static class MyReposViewHolder extends RecyclerView.ViewHolder {
private ImageView imageAvatar; private UserRepositories userRepositories;
private TextView repoName;
private TextView repoDescription; private final ImageView image;
private TextView repoFullName; private final TextView repoName;
private ImageView repoPrivatePublic; private final TextView orgName;
private TextView repoStars; private final TextView repoDescription;
private TextView repoForks;
private TextView repoOpenIssuesCount;
private TextView repoType;
private CheckBox isRepoAdmin; private CheckBox isRepoAdmin;
private LinearLayout archiveRepo; private final TextView repoStars;
private TextView repoBranch; private final TextView repoLastUpdated;
private TextView htmlUrl;
private MyReposViewHolder(View itemView) { private MyReposViewHolder(View itemView) {
super(itemView); super(itemView);
repoName = itemView.findViewById(R.id.repoName); repoName = itemView.findViewById(R.id.repoName);
orgName = itemView.findViewById(R.id.orgName);
repoDescription = itemView.findViewById(R.id.repoDescription); repoDescription = itemView.findViewById(R.id.repoDescription);
imageAvatar = itemView.findViewById(R.id.imageAvatar);
repoFullName = itemView.findViewById(R.id.repoFullName);
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
repoStars = itemView.findViewById(R.id.repoStars);
repoForks = itemView.findViewById(R.id.repoForks);
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
repoType = itemView.findViewById(R.id.repoType);
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin); isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame); image = itemView.findViewById(R.id.imageAvatar);
repoBranch = itemView.findViewById(R.id.repoBranch); repoStars = itemView.findViewById(R.id.repoStars);
htmlUrl = itemView.findViewById(R.id.htmlUrl); repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
Context context = v.getContext(); Context context = v.getContext();
TinyDB tinyDb = TinyDB.getInstance(context);
Intent intent = new Intent(context, RepoDetailActivity.class); Intent intent = new Intent(context, RepoDetailActivity.class);
intent.putExtra("repoFullName", repoFullName.getText().toString()); intent.putExtra("repoFullName", userRepositories.getFullName());
TinyDB tinyDb = TinyDB.getInstance(context); tinyDb.putString("repoFullName", userRepositories.getFullName());
tinyDb.putString("repoFullName", repoFullName.getText().toString());
tinyDb.putString("repoType", repoType.getText().toString());
//tinyDb.putBoolean("resumeIssues", true); //tinyDb.putBoolean("resumeIssues", true);
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked()); tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
tinyDb.putString("repoBranch", repoBranch.getText().toString()); tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
String[] parts = repoFullName.getText().toString().split("/"); if(userRepositories.getPrivateFlag()) {
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
}
else {
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
}
String[] parts = userRepositories.getFullName().split("/");
final String repoOwner = parts[0]; final String repoOwner = parts[0];
final String repoName = parts[1]; final String repoName = parts[1];
@ -113,13 +105,11 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName); long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", id); tinyDb.putLong("repositoryId", id);
} }
else { else {
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName); Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", data.getRepositoryId()); tinyDb.putLong("repositoryId", data.getRepositoryId());
} }
//store if user is watching this repo //store if user is watching this repo
@ -172,81 +162,13 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
context.startActivity(intent); context.startActivity(intent);
}); });
reposDropdownMenu.setOnClickListener(v -> {
final Context context = v.getContext();
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
TextView repoForksList = view.findViewById(R.id.repoForksList);
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
bottomSheetHeader.setText(String.format("%s / %s", repoFullName.getText().toString().split("/")[0], repoFullName.getText().toString().split("/")[1]));
BottomSheetDialog dialog = new BottomSheetDialog(context);
dialog.setContentView(view);
dialog.show();
repoCopyUrl.setOnClickListener(openInBrowser -> {
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
dialog.dismiss();
});
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
intentOpenInBrowser.putExtra("repoFullNameBrowser", repoFullName.getText());
context.startActivity(intentOpenInBrowser);
dialog.dismiss();
});
repoStargazers.setOnClickListener(stargazers -> {
Intent intent = new Intent(context, RepoStargazersActivity.class);
intent.putExtra("repoFullNameForStars", repoFullName.getText());
context.startActivity(intent);
dialog.dismiss();
});
repoWatchers.setOnClickListener(watchers -> {
Intent intentW = new Intent(context, RepoWatchersActivity.class);
intentW.putExtra("repoFullNameForWatchers", repoFullName.getText());
context.startActivity(intentW);
dialog.dismiss();
});
repoForksList.setOnClickListener(forks -> {
Intent intentW = new Intent(context, RepoForksActivity.class);
intentW.putExtra("repoFullNameForForks", repoFullName.getText());
context.startActivity(intentW);
dialog.dismiss();
});
});
} }
} }
public MyReposListAdapter(Context mCtx, List<UserRepositories> reposListMain) { public MyReposListAdapter(Context ctx, List<UserRepositories> reposListMain) {
this.mCtx = mCtx; this.context = ctx;
this.reposList = reposListMain; this.reposList = reposListMain;
reposListFull = new ArrayList<>(reposList); reposListFull = new ArrayList<>(reposList);
} }
@ -262,10 +184,16 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
@Override @Override
public void onBindViewHolder(@NonNull MyReposListAdapter.MyReposViewHolder holder, int position) { public void onBindViewHolder(@NonNull MyReposListAdapter.MyReposViewHolder holder, int position) {
TinyDB tinyDb = TinyDB.getInstance(context);
UserRepositories currentItem = reposList.get(position); UserRepositories currentItem = reposList.get(position);
holder.repoDescription.setVisibility(View.GONE); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
holder.repoBranch.setText(currentItem.getDefault_branch());
holder.htmlUrl.setText(currentItem.getHtml_url()); String locale = tinyDb.getString("locale");
String timeFormat = tinyDb.getString("dateFormat");
holder.userRepositories = currentItem;
holder.orgName.setText(currentItem.getFullName().split("/")[0]);
holder.repoName.setText(currentItem.getFullName().split("/")[1]);
holder.repoStars.setText(currentItem.getStars_count());
ColorGenerator generator = ColorGenerator.MATERIAL; ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName()); int color = generator.getColor(currentItem.getName());
@ -275,46 +203,52 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
if(currentItem.getAvatar_url() != null) { if(currentItem.getAvatar_url() != null) {
if(!currentItem.getAvatar_url().equals("")) { if(!currentItem.getAvatar_url().equals("")) {
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.imageAvatar); PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.image);
} }
else { else {
holder.imageAvatar.setImageDrawable(drawable); holder.image.setImageDrawable(drawable);
} }
} }
else { else {
holder.imageAvatar.setImageDrawable(drawable); holder.image.setImageDrawable(drawable);
}
if(currentItem.getUpdated_at() != null) {
switch(timeFormat) {
case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
String createdTime = prettyTime.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
break;
}
case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break;
}
case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break;
}
}
}
else {
holder.repoLastUpdated.setVisibility(View.GONE);
} }
holder.repoName.setText(currentItem.getName());
if(!currentItem.getDescription().equals("")) { if(!currentItem.getDescription().equals("")) {
holder.repoDescription.setVisibility(View.VISIBLE);
holder.repoDescription.setText(currentItem.getDescription()); holder.repoDescription.setText(currentItem.getDescription());
} }
holder.repoFullName.setText(currentItem.getFullName());
if(currentItem.getPrivateFlag()) {
holder.repoPrivatePublic.setVisibility(View.VISIBLE);
holder.repoType.setText(R.string.strPrivate);
}
else {
holder.repoPrivatePublic.setVisibility(View.GONE);
holder.repoType.setText(R.string.strPublic);
}
holder.repoStars.setText(currentItem.getStars_count());
holder.repoForks.setText(currentItem.getForks_count());
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
if(holder.isRepoAdmin == null) { if(holder.isRepoAdmin == null) {
holder.isRepoAdmin = new CheckBox(mCtx); holder.isRepoAdmin = new CheckBox(context);
} }
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin()); holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
if(currentItem.isArchived()) {
holder.archiveRepo.setVisibility(View.VISIBLE);
}
else {
holder.archiveRepo.setVisibility(View.GONE);
}
} }
@Override @Override
@ -329,7 +263,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
return myReposFilter; return myReposFilter;
} }
private Filter myReposFilter = new Filter() { private final Filter myReposFilter = new Filter() {
@Override @Override
protected FilterResults performFiltering(CharSequence constraint) { protected FilterResults performFiltering(CharSequence constraint) {

View File

@ -24,11 +24,11 @@ import java.util.List;
public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdapter.NotificationsViewHolder> { public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdapter.NotificationsViewHolder> {
private Context context; private final Context context;
private List<NotificationThread> notificationThreads; private final List<NotificationThread> notificationThreads;
private OnMoreClickedListener onMoreClickedListener; private final OnMoreClickedListener onMoreClickedListener;
private OnNotificationClickedListener onNotificationClickedListener; private final OnNotificationClickedListener onNotificationClickedListener;
private TinyDB tinyDb; private final TinyDB tinyDb;
public NotificationsAdapter(Context context, List<NotificationThread> notificationThreads, OnMoreClickedListener onMoreClickedListener, OnNotificationClickedListener onNotificationClickedListener) { public NotificationsAdapter(Context context, List<NotificationThread> notificationThreads, OnMoreClickedListener onMoreClickedListener, OnNotificationClickedListener onNotificationClickedListener) {
@ -37,19 +37,18 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
this.notificationThreads = notificationThreads; this.notificationThreads = notificationThreads;
this.onMoreClickedListener = onMoreClickedListener; this.onMoreClickedListener = onMoreClickedListener;
this.onNotificationClickedListener = onNotificationClickedListener; this.onNotificationClickedListener = onNotificationClickedListener;
} }
static class NotificationsViewHolder extends RecyclerView.ViewHolder { static class NotificationsViewHolder extends RecyclerView.ViewHolder {
private LinearLayout frame; private final LinearLayout frame;
private TextView subject; private final TextView subject;
private TextView repository; private final TextView repository;
private ImageView typePr; private final ImageView typePr;
private ImageView typeIssue; private final ImageView typeIssue;
private ImageView typeUnknown; private final ImageView typeUnknown;
private ImageView pinned; private final ImageView pinned;
private ImageView more; private final ImageView more;
public NotificationsViewHolder(@NonNull View itemView) { public NotificationsViewHolder(@NonNull View itemView) {
@ -63,7 +62,6 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
typeUnknown = itemView.findViewById(R.id.typeUnknown); typeUnknown = itemView.findViewById(R.id.typeUnknown);
pinned = itemView.findViewById(R.id.pinned); pinned = itemView.findViewById(R.id.pinned);
more = itemView.findViewById(R.id.more); more = itemView.findViewById(R.id.more);
} }
} }
@ -73,7 +71,6 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
View v = LayoutInflater.from(context).inflate(R.layout.list_notifications, parent, false); View v = LayoutInflater.from(context).inflate(R.layout.list_notifications, parent, false);
return new NotificationsAdapter.NotificationsViewHolder(v); return new NotificationsAdapter.NotificationsViewHolder(v);
} }
@Override @Override
@ -134,18 +131,15 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName); long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", id); tinyDb.putLong("repositoryId", id);
} }
else { else {
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName); Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", data.getRepositoryId()); tinyDb.putLong("repositoryId", data.getRepositoryId());
} }
}); });
holder.more.setOnClickListener(v -> onMoreClickedListener.onMoreClicked(notificationThread)); holder.more.setOnClickListener(v -> onMoreClickedListener.onMoreClicked(notificationThread));
} }
@Override @Override

View File

@ -16,6 +16,7 @@ import org.gitnex.tea4j.models.UserOrganizations;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.activities.OrganizationDetailActivity; import org.mian.gitnex.activities.OrganizationDetailActivity;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import java.util.ArrayList; import java.util.ArrayList;
@ -27,42 +28,42 @@ import java.util.List;
public class OrganizationsListAdapter extends RecyclerView.Adapter<OrganizationsListAdapter.OrganizationsViewHolder> implements Filterable { public class OrganizationsListAdapter extends RecyclerView.Adapter<OrganizationsListAdapter.OrganizationsViewHolder> implements Filterable {
private List<UserOrganizations> orgList; private final List<UserOrganizations> orgList;
private Context mCtx; private final Context context;
private List<UserOrganizations> orgListFull; private final List<UserOrganizations> orgListFull;
static class OrganizationsViewHolder extends RecyclerView.ViewHolder { static class OrganizationsViewHolder extends RecyclerView.ViewHolder {
private ImageView image; private UserOrganizations userOrganizations;
private TextView mTextView1;
private TextView mTextView2; private final ImageView image;
private TextView organizationId; private final TextView orgName;
private final TextView orgDescription;
private OrganizationsViewHolder(View itemView) { private OrganizationsViewHolder(View itemView) {
super(itemView); super(itemView);
mTextView1 = itemView.findViewById(R.id.orgUsername); orgName = itemView.findViewById(R.id.orgName);
mTextView2 = itemView.findViewById(R.id.orgDescription); orgDescription = itemView.findViewById(R.id.orgDescription);
image = itemView.findViewById(R.id.imageAvatar); image = itemView.findViewById(R.id.imageAvatar);
organizationId = itemView.findViewById(R.id.organizationId);
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
Context context = v.getContext(); Context context = v.getContext();
Intent intent = new Intent(context, OrganizationDetailActivity.class); Intent intent = new Intent(context, OrganizationDetailActivity.class);
intent.putExtra("orgName", mTextView1.getText().toString()); intent.putExtra("orgName", userOrganizations.getUsername());
TinyDB tinyDb = TinyDB.getInstance(context); TinyDB tinyDb = TinyDB.getInstance(context);
tinyDb.putString("orgName", mTextView1.getText().toString()); tinyDb.putString("orgName", userOrganizations.getUsername());
tinyDb.putString("organizationId", organizationId.getText().toString()); tinyDb.putString("organizationId", String.valueOf(userOrganizations.getId()));
tinyDb.putBoolean("organizationAction", true); tinyDb.putBoolean("organizationAction", true);
context.startActivity(intent); context.startActivity(intent);
}); });
} }
} }
public OrganizationsListAdapter(Context mCtx, List<UserOrganizations> orgsListMain) { public OrganizationsListAdapter(Context ctx, List<UserOrganizations> orgsListMain) {
this.mCtx = mCtx; this.context = ctx;
this.orgList = orgsListMain; this.orgList = orgsListMain;
orgListFull = new ArrayList<>(orgList); orgListFull = new ArrayList<>(orgList);
} }
@ -80,16 +81,16 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<Organizations
public void onBindViewHolder(@NonNull OrganizationsViewHolder holder, int position) { public void onBindViewHolder(@NonNull OrganizationsViewHolder holder, int position) {
UserOrganizations currentItem = orgList.get(position); UserOrganizations currentItem = orgList.get(position);
holder.mTextView2.setVisibility(View.GONE); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
holder.organizationId.setText(Integer.toString(currentItem.getId()));
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image); holder.userOrganizations = currentItem;
holder.mTextView1.setText(currentItem.getUsername()); holder.orgName.setText(currentItem.getUsername());
PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.image);
if (!currentItem.getDescription().equals("")) { if (!currentItem.getDescription().equals("")) {
holder.mTextView2.setVisibility(View.VISIBLE); holder.orgDescription.setText(currentItem.getDescription());
holder.mTextView2.setText(currentItem.getDescription());
} }
} }

View File

@ -20,13 +20,13 @@ import java.util.List;
public class ProfileEmailsAdapter extends RecyclerView.Adapter<ProfileEmailsAdapter.EmailsViewHolder> { public class ProfileEmailsAdapter extends RecyclerView.Adapter<ProfileEmailsAdapter.EmailsViewHolder> {
private List<Emails> emailsList; private final List<Emails> emailsList;
private Context mCtx; private final Context context;
static class EmailsViewHolder extends RecyclerView.ViewHolder { static class EmailsViewHolder extends RecyclerView.ViewHolder {
private ImageView emailPrimary; private final ImageView emailPrimary;
private TextView userEmail; private final TextView userEmail;
private EmailsViewHolder(View itemView) { private EmailsViewHolder(View itemView) {
super(itemView); super(itemView);
@ -37,8 +37,8 @@ public class ProfileEmailsAdapter extends RecyclerView.Adapter<ProfileEmailsAdap
} }
} }
public ProfileEmailsAdapter(Context mCtx, List<Emails> emailsListMain) { public ProfileEmailsAdapter(Context ctx, List<Emails> emailsListMain) {
this.mCtx = mCtx; this.context = ctx;
this.emailsList = emailsListMain; this.emailsList = emailsListMain;
} }
@ -59,12 +59,12 @@ public class ProfileEmailsAdapter extends RecyclerView.Adapter<ProfileEmailsAdap
if(currentItem.getPrimary()) { if(currentItem.getPrimary()) {
TextDrawable drawable = TextDrawable.builder() TextDrawable drawable = TextDrawable.builder()
.beginConfig() .beginConfig()
.textColor(ResourcesCompat.getColor(mCtx.getResources(), R.color.colorWhite, null)) .textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null))
.fontSize(36) .fontSize(36)
.width(220) .width(220)
.height(60) .height(60)
.endConfig() .endConfig()
.buildRoundRect(mCtx.getResources().getString(R.string.emailTypeText), ResourcesCompat.getColor(mCtx.getResources(), R.color.tooltipBackground, null), 8); .buildRoundRect(context.getResources().getString(R.string.emailTypeText), ResourcesCompat.getColor(context.getResources(), R.color.tooltipBackground, null), 8);
holder.emailPrimary.setImageDrawable(drawable); holder.emailPrimary.setImageDrawable(drawable);
} }
else { else {

View File

@ -23,7 +23,7 @@ import java.util.List;
public class ProfileFollowersAdapter extends RecyclerView.Adapter<ProfileFollowersAdapter.FollowersViewHolder> { public class ProfileFollowersAdapter extends RecyclerView.Adapter<ProfileFollowersAdapter.FollowersViewHolder> {
private final List<UserInfo> followersList; private final List<UserInfo> followersList;
private final Context mCtx; private final Context context;
static class FollowersViewHolder extends RecyclerView.ViewHolder { static class FollowersViewHolder extends RecyclerView.ViewHolder {
@ -50,9 +50,9 @@ public class ProfileFollowersAdapter extends RecyclerView.Adapter<ProfileFollowe
} }
} }
public ProfileFollowersAdapter(Context mCtx, List<UserInfo> followersListMain) { public ProfileFollowersAdapter(Context ctx, List<UserInfo> followersListMain) {
this.mCtx = mCtx; this.context = ctx;
this.followersList = followersListMain; this.followersList = followersListMain;
} }
@ -68,21 +68,20 @@ public class ProfileFollowersAdapter extends RecyclerView.Adapter<ProfileFollowe
public void onBindViewHolder(@NonNull ProfileFollowersAdapter.FollowersViewHolder holder, int position) { public void onBindViewHolder(@NonNull ProfileFollowersAdapter.FollowersViewHolder holder, int position) {
UserInfo currentItem = followersList.get(position); UserInfo currentItem = followersList.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
holder.userLoginId = currentItem.getLogin(); holder.userLoginId = currentItem.getLogin();
if(!currentItem.getFullname().equals("")) { if(!currentItem.getFullname().equals("")) {
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname())); holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername())); holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
} }
else { else {
holder.userFullName.setText(currentItem.getUsername());
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
holder.userName.setVisibility(View.GONE); holder.userName.setVisibility(View.GONE);
} }
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAvatar); PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
} }
@Override @Override

View File

@ -23,7 +23,7 @@ import java.util.List;
public class ProfileFollowingAdapter extends RecyclerView.Adapter<ProfileFollowingAdapter.FollowingViewHolder> { public class ProfileFollowingAdapter extends RecyclerView.Adapter<ProfileFollowingAdapter.FollowingViewHolder> {
private final List<UserInfo> followingList; private final List<UserInfo> followingList;
private final Context mCtx; private final Context context;
static class FollowingViewHolder extends RecyclerView.ViewHolder { static class FollowingViewHolder extends RecyclerView.ViewHolder {
@ -50,9 +50,9 @@ public class ProfileFollowingAdapter extends RecyclerView.Adapter<ProfileFollowi
} }
} }
public ProfileFollowingAdapter(Context mCtx, List<UserInfo> followingListMain) { public ProfileFollowingAdapter(Context ctx, List<UserInfo> followingListMain) {
this.mCtx = mCtx; this.context = ctx;
this.followingList = followingListMain; this.followingList = followingListMain;
} }
@ -68,21 +68,20 @@ public class ProfileFollowingAdapter extends RecyclerView.Adapter<ProfileFollowi
public void onBindViewHolder(@NonNull ProfileFollowingAdapter.FollowingViewHolder holder, int position) { public void onBindViewHolder(@NonNull ProfileFollowingAdapter.FollowingViewHolder holder, int position) {
UserInfo currentItem = followingList.get(position); UserInfo currentItem = followingList.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
holder.userLoginId = currentItem.getLogin(); holder.userLoginId = currentItem.getLogin();
if(!currentItem.getFullname().equals("")) { if(!currentItem.getFullname().equals("")) {
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname())); holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername())); holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
} }
else { else {
holder.userFullName.setText(currentItem.getUsername());
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
holder.userName.setVisibility(View.GONE); holder.userName.setVisibility(View.GONE);
} }
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAvatar); PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
} }
@Override @Override

View File

@ -7,7 +7,6 @@ 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.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat; import androidx.core.content.res.ResourcesCompat;
@ -42,7 +41,6 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
this.context = context; this.context = context;
this.prList = prListMain; this.prList = prListMain;
} }
@NonNull @NonNull
@ -57,7 +55,6 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
else { else {
return new PullRequestsAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false)); return new PullRequestsAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
} }
} }
@Override @Override
@ -89,7 +86,6 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
public int getItemCount() { public int getItemCount() {
return prList.size(); return prList.size();
} }
class PullRequestsHolder extends RecyclerView.ViewHolder { class PullRequestsHolder extends RecyclerView.ViewHolder {
@ -104,43 +100,12 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
PullRequestsHolder(View itemView) { PullRequestsHolder(View itemView) {
super(itemView); super(itemView);
assigneeAvatar = itemView.findViewById(R.id.assigneeAvatar); assigneeAvatar = itemView.findViewById(R.id.assigneeAvatar);
prTitle = itemView.findViewById(R.id.prTitle); prTitle = itemView.findViewById(R.id.prTitle);
prCommentsCount = itemView.findViewById(R.id.prCommentsCount); prCommentsCount = itemView.findViewById(R.id.prCommentsCount);
LinearLayout frameCommentsCount = itemView.findViewById(R.id.frameCommentsCount);
prCreatedTime = itemView.findViewById(R.id.prCreatedTime); prCreatedTime = itemView.findViewById(R.id.prCreatedTime);
prTitle.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
Context context = v.getContext();
Intent intent = new Intent(context, IssueDetailActivity.class);
intent.putExtra("issueNumber", pullRequest.getNumber());
intent.putExtra("prMergeable", pullRequest.isMergeable());
intent.putExtra("prHeadBranch", pullRequest.getHead().getRef());
TinyDB tinyDb = TinyDB.getInstance(context);
tinyDb.putString("issueNumber", String.valueOf(pullRequest.getNumber()));
tinyDb.putString("prMergeable", String.valueOf(pullRequest.isMergeable()));
tinyDb.putString("prHeadBranch", pullRequest.getHead().getRef());
if(pullRequest.getHead() != null && pullRequest.getHead().getRepo() != null) {
tinyDb.putString("prIsFork", String.valueOf(pullRequest.getHead().getRepo().isFork()));
tinyDb.putString("prForkFullName", pullRequest.getHead().getRepo().getFull_name());
}
else {
// pull was done from a deleted fork
tinyDb.putString("prIsFork", "true");
tinyDb.putString("prForkFullName", context.getString(R.string.prDeletedFork));
}
tinyDb.putString("issueType", "Pull");
context.startActivity(intent);
});
frameCommentsCount.setOnClickListener(v -> {
Context context = v.getContext(); Context context = v.getContext();
@ -184,11 +149,12 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
TinyDB tinyDb = TinyDB.getInstance(context); TinyDB tinyDb = TinyDB.getInstance(context);
String locale = tinyDb.getString("locale"); String locale = tinyDb.getString("locale");
String timeFormat = tinyDb.getString("dateFormat"); String timeFormat = tinyDb.getString("dateFormat");
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
PicassoService.getInstance(context).get() PicassoService.getInstance(context).get()
.load(pullRequest.getUser().getAvatar_url()) .load(pullRequest.getUser().getAvatar_url())
.placeholder(R.drawable.loader_animated) .placeholder(R.drawable.loader_animated)
.transform(new RoundedTransformation(8, 0)) .transform(new RoundedTransformation(imgRadius, 0))
.resize(120, 120) .resize(120, 120)
.centerCrop() .centerCrop()
.into(this.assigneeAvatar); .into(this.assigneeAvatar);
@ -226,19 +192,16 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
notifyDataSetChanged(); notifyDataSetChanged();
isLoading = false; isLoading = false;
} }
public interface OnLoadMoreListener { public interface OnLoadMoreListener {
void onLoadMore(); void onLoadMore();
} }
public void setLoadMoreListener(PullRequestsAdapter.OnLoadMoreListener loadMoreListener) { public void setLoadMoreListener(PullRequestsAdapter.OnLoadMoreListener loadMoreListener) {
this.loadMoreListener = loadMoreListener; this.loadMoreListener = loadMoreListener;
} }
public void updateList(List<PullRequests> list) { public void updateList(List<PullRequests> list) {

View File

@ -7,7 +7,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.text.HtmlCompat; import androidx.core.text.HtmlCompat;
@ -16,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
import org.gitnex.tea4j.models.Releases; import org.gitnex.tea4j.models.Releases;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.ClickListener; import org.mian.gitnex.helpers.ClickListener;
import org.mian.gitnex.helpers.Markdown; import org.mian.gitnex.helpers.Markdown;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
@ -30,25 +30,24 @@ import java.util.Locale;
public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.ReleasesViewHolder> { public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.ReleasesViewHolder> {
private List<Releases> releasesList; private final List<Releases> releasesList;
private Context mCtx; private final Context context;
static class ReleasesViewHolder extends RecyclerView.ViewHolder { static class ReleasesViewHolder extends RecyclerView.ViewHolder {
private TextView releaseType; private final TextView releaseType;
private TextView releaseName; private final TextView releaseName;
private ImageView authorAvatar; private final ImageView authorAvatar;
private TextView authorName; private final TextView authorName;
private TextView releaseTag; private final TextView releaseTag;
private TextView releaseCommitSha; private final TextView releaseDate;
private TextView releaseDate; private final TextView releaseBodyContent;
private TextView releaseBodyContent; private final LinearLayout downloadFrame;
private LinearLayout downloadFrame; private final LinearLayout downloads;
private RelativeLayout downloads; private final TextView releaseZipDownload;
private TextView releaseZipDownload; private final TextView releaseTarDownload;
private TextView releaseTarDownload; private final ImageView downloadDropdownIcon;
private ImageView downloadDropdownIcon; private final RecyclerView downloadList;
private RecyclerView downloadList;
private ReleasesViewHolder(View itemView) { private ReleasesViewHolder(View itemView) {
@ -59,7 +58,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
authorAvatar = itemView.findViewById(R.id.authorAvatar); authorAvatar = itemView.findViewById(R.id.authorAvatar);
authorName = itemView.findViewById(R.id.authorName); authorName = itemView.findViewById(R.id.authorName);
releaseTag = itemView.findViewById(R.id.releaseTag); releaseTag = itemView.findViewById(R.id.releaseTag);
releaseCommitSha = itemView.findViewById(R.id.releaseCommitSha); TextView releaseCommitSha = itemView.findViewById(R.id.releaseCommitSha);
releaseDate = itemView.findViewById(R.id.releaseDate); releaseDate = itemView.findViewById(R.id.releaseDate);
releaseBodyContent = itemView.findViewById(R.id.releaseBodyContent); releaseBodyContent = itemView.findViewById(R.id.releaseBodyContent);
downloadFrame = itemView.findViewById(R.id.downloadFrame); downloadFrame = itemView.findViewById(R.id.downloadFrame);
@ -71,12 +70,11 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
downloadList.setHasFixedSize(true); downloadList.setHasFixedSize(true);
downloadList.setLayoutManager(new LinearLayoutManager(itemView.getContext())); downloadList.setLayoutManager(new LinearLayoutManager(itemView.getContext()));
} }
} }
public ReleasesAdapter(Context mCtx, List<Releases> releasesMain) { public ReleasesAdapter(Context ctx, List<Releases> releasesMain) {
this.mCtx = mCtx; this.context = ctx;
this.releasesList = releasesMain; this.releasesList = releasesMain;
} }
@ -90,9 +88,10 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
@Override @Override
public void onBindViewHolder(@NonNull ReleasesAdapter.ReleasesViewHolder holder, int position) { public void onBindViewHolder(@NonNull ReleasesAdapter.ReleasesViewHolder holder, int position) {
final TinyDB tinyDb = TinyDB.getInstance(mCtx); final TinyDB tinyDb = TinyDB.getInstance(context);
final String locale = tinyDb.getString("locale"); final String locale = tinyDb.getString("locale");
final String timeFormat = tinyDb.getString("dateFormat"); final String timeFormat = tinyDb.getString("dateFormat");
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
Releases currentItem = releasesList.get(position); Releases currentItem = releasesList.get(position);
@ -111,25 +110,25 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
} }
if(currentItem.getAuthor().getAvatar_url() != null) { if(currentItem.getAuthor().getAvatar_url() != null) {
PicassoService.getInstance(mCtx).get().load(currentItem.getAuthor().getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.authorAvatar); PicassoService.getInstance(context).get().load(currentItem.getAuthor().getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.authorAvatar);
} }
holder.authorName.setText(mCtx.getResources().getString(R.string.releasePublishedBy, currentItem.getAuthor().getUsername())); holder.authorName.setText(context.getResources().getString(R.string.releasePublishedBy, currentItem.getAuthor().getUsername()));
if(currentItem.getTag_name() != null) { if(currentItem.getTag_name() != null) {
holder.releaseTag.setText(currentItem.getTag_name()); holder.releaseTag.setText(currentItem.getTag_name());
} }
if(currentItem.getPublished_at() != null) { if(currentItem.getPublished_at() != null) {
holder.releaseDate.setText(TimeHelper.formatTime(currentItem.getPublished_at(), new Locale(locale), timeFormat, mCtx)); holder.releaseDate.setText(TimeHelper.formatTime(currentItem.getPublished_at(), new Locale(locale), timeFormat, context));
} }
if(timeFormat.equals("pretty")) { if(timeFormat.equals("pretty")) {
holder.releaseDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublished_at()), mCtx)); holder.releaseDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublished_at()), context));
} }
if(!currentItem.getBody().equals("")) { if(!currentItem.getBody().equals("")) {
Markdown.render(mCtx, currentItem.getBody(), holder.releaseBodyContent); Markdown.render(context, currentItem.getBody(), holder.releaseBodyContent);
} }
else { else {
holder.releaseBodyContent.setText(R.string.noReleaseBodyContent); holder.releaseBodyContent.setText(R.string.noReleaseBodyContent);
@ -141,28 +140,25 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_down); holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_down);
holder.downloads.setVisibility(View.VISIBLE); holder.downloads.setVisibility(View.VISIBLE);
} }
else { else {
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_right); holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_right);
holder.downloads.setVisibility(View.GONE); holder.downloads.setVisibility(View.GONE);
} }
}); });
holder.releaseZipDownload.setText( holder.releaseZipDownload.setText(
HtmlCompat.fromHtml("<a href='" + currentItem.getZipball_url() + "'>" + mCtx.getResources().getString(R.string.zipArchiveDownloadReleasesTab) + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY)); HtmlCompat.fromHtml("<a href='" + currentItem.getZipball_url() + "'>" + context.getResources().getString(R.string.zipArchiveDownloadReleasesTab) + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY));
holder.releaseZipDownload.setMovementMethod(LinkMovementMethod.getInstance()); holder.releaseZipDownload.setMovementMethod(LinkMovementMethod.getInstance());
holder.releaseTarDownload.setText( holder.releaseTarDownload.setText(
HtmlCompat.fromHtml("<a href='" + currentItem.getTarball_url() + "'>" + mCtx.getResources().getString(R.string.tarArchiveDownloadReleasesTab) + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY)); HtmlCompat.fromHtml("<a href='" + currentItem.getTarball_url() + "'>" + context.getResources().getString(R.string.tarArchiveDownloadReleasesTab) + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY));
holder.releaseTarDownload.setMovementMethod(LinkMovementMethod.getInstance()); holder.releaseTarDownload.setMovementMethod(LinkMovementMethod.getInstance());
ReleasesDownloadsAdapter adapter = new ReleasesDownloadsAdapter(currentItem.getAssets()); ReleasesDownloadsAdapter adapter = new ReleasesDownloadsAdapter(currentItem.getAssets());
holder.downloadList.setAdapter(adapter); holder.downloadList.setAdapter(adapter);
} }
@Override @Override

View File

@ -18,18 +18,16 @@ import java.util.List;
public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownloadsAdapter.ReleasesDownloadsViewHolder> { public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownloadsAdapter.ReleasesDownloadsViewHolder> {
private List<Releases.assetsObject> releasesDownloadsList; private final List<Releases.assetsObject> releasesDownloadsList;
static class ReleasesDownloadsViewHolder extends RecyclerView.ViewHolder { static class ReleasesDownloadsViewHolder extends RecyclerView.ViewHolder {
private TextView downloadName; private final TextView downloadName;
private ReleasesDownloadsViewHolder(View itemView) { private ReleasesDownloadsViewHolder(View itemView) {
super(itemView); super(itemView);
downloadName = itemView.findViewById(R.id.downloadName); downloadName = itemView.findViewById(R.id.downloadName);
} }
} }
@ -57,7 +55,6 @@ public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownl
holder.downloadName.setMovementMethod(LinkMovementMethod.getInstance()); holder.downloadName.setMovementMethod(LinkMovementMethod.getInstance());
} }
} }
@Override @Override

View File

@ -9,29 +9,30 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.TextDrawable;
import com.amulyakhare.textdrawable.util.ColorGenerator; import com.amulyakhare.textdrawable.util.ColorGenerator;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import org.gitnex.tea4j.models.UserRepositories; import org.gitnex.tea4j.models.UserRepositories;
import org.gitnex.tea4j.models.WatchInfo; import org.gitnex.tea4j.models.WatchInfo;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity; import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.database.api.RepositoriesApi; import org.mian.gitnex.database.api.RepositoriesApi;
import org.mian.gitnex.database.models.Repository; import org.mian.gitnex.database.models.Repository;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.ClickListener;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TimeHelper;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.Toasty;
import org.ocpsoft.prettytime.PrettyTime;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List; import java.util.List;
import java.util.Locale;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -41,7 +42,7 @@ import retrofit2.Callback;
public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context ctx; private final Context context;
private final int TYPE_LOAD = 0; private final int TYPE_LOAD = 0;
private List<UserRepositories> forksList; private List<UserRepositories> forksList;
private OnLoadMoreListener loadMoreListener; private OnLoadMoreListener loadMoreListener;
@ -50,16 +51,15 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
public RepoForksAdapter(Context ctx, List<UserRepositories> forksListMain) { public RepoForksAdapter(Context ctx, List<UserRepositories> forksListMain) {
this.ctx = ctx; this.context = ctx;
this.forksList = forksListMain; this.forksList = forksListMain;
} }
@NonNull @NonNull
@Override @Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(ctx); LayoutInflater inflater = LayoutInflater.from(context);
if(viewType == TYPE_LOAD) { if(viewType == TYPE_LOAD) {
return new RepoForksAdapter.ForksHolder(inflater.inflate(R.layout.list_repositories, parent, false)); return new RepoForksAdapter.ForksHolder(inflater.inflate(R.layout.list_repositories, parent, false));
@ -67,7 +67,6 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
else { else {
return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false)); return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
} }
} }
@Override @Override
@ -77,15 +76,12 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
isLoading = true; isLoading = true;
loadMoreListener.onLoadMore(); loadMoreListener.onLoadMore();
} }
if(getItemViewType(position) == TYPE_LOAD) { if(getItemViewType(position) == TYPE_LOAD) {
((RepoForksAdapter.ForksHolder) holder).bindData(forksList.get(position)); ((RepoForksAdapter.ForksHolder) holder).bindData(forksList.get(position));
} }
} }
@Override @Override
@ -97,57 +93,51 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
else { else {
return 1; return 1;
} }
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return forksList.size(); return forksList.size();
} }
class ForksHolder extends RecyclerView.ViewHolder { class ForksHolder extends RecyclerView.ViewHolder {
private ImageView image; private UserRepositories userRepositories;
private TextView repoName;
private TextView repoDescription; private final ImageView image;
private TextView fullName; private final TextView repoName;
private final TextView orgName;
private final TextView repoDescription;
private CheckBox isRepoAdmin; private CheckBox isRepoAdmin;
private ImageView repoPrivatePublic; private final TextView repoStars;
private TextView repoStars; private final TextView repoLastUpdated;
private TextView repoForks;
private TextView repoOpenIssuesCount;
private TextView repoType;
private LinearLayout archiveRepo;
private TextView repoBranch;
private ImageView reposDropdownMenu;
ForksHolder(View itemView) { ForksHolder(View itemView) {
super(itemView); super(itemView);
repoName = itemView.findViewById(R.id.repoName); repoName = itemView.findViewById(R.id.repoName);
orgName = itemView.findViewById(R.id.orgName);
repoDescription = itemView.findViewById(R.id.repoDescription); repoDescription = itemView.findViewById(R.id.repoDescription);
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin); isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
image = itemView.findViewById(R.id.imageAvatar); image = itemView.findViewById(R.id.imageAvatar);
fullName = itemView.findViewById(R.id.repoFullName);
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
repoStars = itemView.findViewById(R.id.repoStars); repoStars = itemView.findViewById(R.id.repoStars);
repoForks = itemView.findViewById(R.id.repoForks); repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
repoType = itemView.findViewById(R.id.repoType);
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
repoBranch = itemView.findViewById(R.id.repoBranch);
} }
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
void bindData(UserRepositories forksModel) { void bindData(UserRepositories forksModel) {
repoDescription.setVisibility(View.GONE); TinyDB tinyDb = TinyDB.getInstance(context);
repoBranch.setText(forksModel.getDefault_branch()); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
String locale = tinyDb.getString("locale");
String timeFormat = tinyDb.getString("dateFormat");
this.userRepositories = forksModel;
orgName.setText(forksModel.getFullName().split("/")[0]);
repoName.setText(forksModel.getFullName().split("/")[1]);
repoStars.setText(forksModel.getStars_count());
ColorGenerator generator = ColorGenerator.MATERIAL; ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(forksModel.getName()); int color = generator.getColor(forksModel.getName());
@ -158,8 +148,8 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
if(forksModel.getAvatar_url() != null) { if(forksModel.getAvatar_url() != null) {
if(!forksModel.getAvatar_url().equals("")) { if(!forksModel.getAvatar_url().equals("")) {
PicassoService.getInstance(ctx).get().load(forksModel.getAvatar_url()).placeholder(R.drawable.loader_animated) PicassoService.getInstance(context).get().load(forksModel.getAvatar_url()).placeholder(R.drawable.loader_animated)
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(image); .transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
} }
else { else {
image.setImageDrawable(drawable); image.setImageDrawable(drawable);
@ -169,56 +159,63 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
image.setImageDrawable(drawable); image.setImageDrawable(drawable);
} }
repoName.setText(forksModel.getName()); if(forksModel.getUpdated_at() != null) {
switch(timeFormat) {
case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
String createdTime = prettyTime.format(forksModel.getUpdated_at());
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(forksModel.getUpdated_at()), context));
break;
}
case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(forksModel.getUpdated_at());
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break;
}
case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(forksModel.getUpdated_at());
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break;
}
}
}
else {
repoLastUpdated.setVisibility(View.GONE);
}
if(!forksModel.getDescription().equals("")) { if(!forksModel.getDescription().equals("")) {
repoDescription.setVisibility(View.VISIBLE);
repoDescription.setText(forksModel.getDescription()); repoDescription.setText(forksModel.getDescription());
} }
fullName.setText(forksModel.getFullName());
if(forksModel.getPrivateFlag()) {
repoPrivatePublic.setImageResource(R.drawable.ic_lock);
repoType.setText(R.string.strPrivate);
}
else {
repoPrivatePublic.setVisibility(View.GONE);
repoType.setText(R.string.strPublic);
}
repoStars.setText(forksModel.getStars_count());
repoForks.setText(forksModel.getForks_count());
repoOpenIssuesCount.setText(forksModel.getOpen_issues_count());
if(isRepoAdmin == null) { if(isRepoAdmin == null) {
isRepoAdmin = new CheckBox(ctx); isRepoAdmin = new CheckBox(context);
} }
isRepoAdmin.setChecked(forksModel.getPermissions().isAdmin()); isRepoAdmin.setChecked(forksModel.getPermissions().isAdmin());
if(forksModel.isArchived()) {
archiveRepo.setVisibility(View.VISIBLE);
}
else {
archiveRepo.setVisibility(View.GONE);
}
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
Context context = v.getContext(); Context context = v.getContext();
TextView repoFullName = v.findViewById(R.id.repoFullName);
TextView repoType_ = v.findViewById(R.id.repoType);
Intent intent = new Intent(context, RepoDetailActivity.class); Intent intent = new Intent(context, RepoDetailActivity.class);
intent.putExtra("repoFullName", repoFullName.getText().toString()); intent.putExtra("repoFullName", userRepositories.getFullName());
TinyDB tinyDb = TinyDB.getInstance(context); tinyDb.putString("repoFullName", userRepositories.getFullName());
tinyDb.putString("repoFullName", repoFullName.getText().toString());
tinyDb.putString("repoType", repoType_.getText().toString());
//tinyDb.putBoolean("resumeIssues", true); //tinyDb.putBoolean("resumeIssues", true);
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked()); tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
tinyDb.putString("repoBranch", repoBranch.getText().toString()); tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
String[] parts = repoFullName.getText().toString().split("/"); if(userRepositories.getPrivateFlag()) {
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
}
else {
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
}
String[] parts = userRepositories.getFullName().split("/");
final String repoOwner = parts[0]; final String repoOwner = parts[0];
final String repoName = parts[1]; final String repoName = parts[1];
@ -232,13 +229,11 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName); long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", id); tinyDb.putLong("repositoryId", id);
} }
else { else {
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName); Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", data.getRepositoryId()); tinyDb.putLong("repositoryId", data.getRepositoryId());
} }
//store if user is watching this repo //store if user is watching this repo
@ -291,63 +286,6 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
context.startActivity(intent); context.startActivity(intent);
}); });
reposDropdownMenu.setOnClickListener(v -> {
final Context context = v.getContext();
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
TextView repoForksList = view.findViewById(R.id.repoForksList);
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
bottomSheetHeader
.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
BottomSheetDialog dialog = new BottomSheetDialog(context);
dialog.setContentView(view);
dialog.show();
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
context.startActivity(intentOpenInBrowser);
dialog.dismiss();
});
repoStargazers.setOnClickListener(stargazers -> {
Intent intent = new Intent(context, RepoStargazersActivity.class);
intent.putExtra("repoFullNameForStars", fullName.getText());
context.startActivity(intent);
dialog.dismiss();
});
repoWatchers.setOnClickListener(watchers -> {
Intent intentW = new Intent(context, RepoWatchersActivity.class);
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
context.startActivity(intentW);
dialog.dismiss();
});
repoForksList.setOnClickListener(watchers -> {
Intent intentW = new Intent(context, RepoForksActivity.class);
intentW.putExtra("repoFullNameForForks", fullName.getText());
context.startActivity(intentW);
dialog.dismiss();
});
});
} }
} }
@ -358,32 +296,27 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
super(itemView); super(itemView);
} }
} }
public void setMoreDataAvailable(boolean moreDataAvailable) { public void setMoreDataAvailable(boolean moreDataAvailable) {
isMoreDataAvailable = moreDataAvailable; isMoreDataAvailable = moreDataAvailable;
} }
public void notifyDataChanged() { public void notifyDataChanged() {
notifyDataSetChanged(); notifyDataSetChanged();
isLoading = false; isLoading = false;
} }
public interface OnLoadMoreListener { public interface OnLoadMoreListener {
void onLoadMore(); void onLoadMore();
} }
public void setLoadMoreListener(RepoForksAdapter.OnLoadMoreListener loadMoreListener) { public void setLoadMoreListener(RepoForksAdapter.OnLoadMoreListener loadMoreListener) {
this.loadMoreListener = loadMoreListener; this.loadMoreListener = loadMoreListener;
} }
public void updateList(List<UserRepositories> list) { public void updateList(List<UserRepositories> list) {

View File

@ -12,6 +12,7 @@ import android.widget.TextView;
import org.gitnex.tea4j.models.UserInfo; import org.gitnex.tea4j.models.UserInfo;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import java.util.List; import java.util.List;
@ -22,13 +23,13 @@ import java.util.List;
public class RepoStargazersAdapter extends BaseAdapter { public class RepoStargazersAdapter extends BaseAdapter {
private List<UserInfo> stargazersList; private final List<UserInfo> stargazersList;
private Context mCtx; private final Context context;
private static class ViewHolder { private static class ViewHolder {
private ImageView memberAvatar; private final ImageView memberAvatar;
private TextView memberName; private final TextView memberName;
ViewHolder(View v) { ViewHolder(View v) {
memberAvatar = v.findViewById(R.id.memberAvatar); memberAvatar = v.findViewById(R.id.memberAvatar);
@ -36,8 +37,8 @@ public class RepoStargazersAdapter extends BaseAdapter {
} }
} }
public RepoStargazersAdapter(Context mCtx, List<UserInfo> membersListMain) { public RepoStargazersAdapter(Context ctx, List<UserInfo> membersListMain) {
this.mCtx = mCtx; this.context = ctx;
this.stargazersList = membersListMain; this.stargazersList = membersListMain;
} }
@ -63,7 +64,7 @@ public class RepoStargazersAdapter extends BaseAdapter {
RepoStargazersAdapter.ViewHolder viewHolder; RepoStargazersAdapter.ViewHolder viewHolder;
if (finalView == null) { if (finalView == null) {
finalView = LayoutInflater.from(mCtx).inflate(R.layout.list_repo_stargazers, null); finalView = LayoutInflater.from(context).inflate(R.layout.list_repo_stargazers, null);
viewHolder = new ViewHolder(finalView); viewHolder = new ViewHolder(finalView);
finalView.setTag(viewHolder); finalView.setTag(viewHolder);
} }
@ -79,23 +80,25 @@ public class RepoStargazersAdapter extends BaseAdapter {
private void initData(RepoStargazersAdapter.ViewHolder viewHolder, int position) { private void initData(RepoStargazersAdapter.ViewHolder viewHolder, int position) {
UserInfo currentItem = stargazersList.get(position); UserInfo currentItem = stargazersList.get(position);
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
final TinyDB tinyDb = TinyDB.getInstance(mCtx); PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
final TinyDB tinyDb = TinyDB.getInstance(context);
Typeface myTypeface; Typeface myTypeface;
switch(tinyDb.getInt("customFontId", -1)) { switch(tinyDb.getInt("customFontId", -1)) {
case 0: case 0:
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf"); myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/roboto.ttf");
break; break;
case 2: case 2:
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf"); myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/sourcecodeproregular.ttf");
break; break;
default: default:
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf"); myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/manroperegular.ttf");
break; break;
} }

View File

@ -12,6 +12,7 @@ import android.widget.TextView;
import org.gitnex.tea4j.models.UserInfo; import org.gitnex.tea4j.models.UserInfo;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import java.util.List; import java.util.List;
@ -22,13 +23,13 @@ import java.util.List;
public class RepoWatchersAdapter extends BaseAdapter { public class RepoWatchersAdapter extends BaseAdapter {
private List<UserInfo> watchersList; private final List<UserInfo> watchersList;
private Context mCtx; private final Context context;
private static class ViewHolder { private static class ViewHolder {
private ImageView memberAvatar; private final ImageView memberAvatar;
private TextView memberName; private final TextView memberName;
ViewHolder(View v) { ViewHolder(View v) {
memberAvatar = v.findViewById(R.id.memberAvatar); memberAvatar = v.findViewById(R.id.memberAvatar);
@ -36,8 +37,8 @@ public class RepoWatchersAdapter extends BaseAdapter {
} }
} }
public RepoWatchersAdapter(Context mCtx, List<UserInfo> membersListMain) { public RepoWatchersAdapter(Context ctx, List<UserInfo> membersListMain) {
this.mCtx = mCtx; this.context = ctx;
this.watchersList = membersListMain; this.watchersList = membersListMain;
} }
@ -63,7 +64,7 @@ public class RepoWatchersAdapter extends BaseAdapter {
RepoWatchersAdapter.ViewHolder viewHolder; RepoWatchersAdapter.ViewHolder viewHolder;
if (finalView == null) { if (finalView == null) {
finalView = LayoutInflater.from(mCtx).inflate(R.layout.list_repo_watchers, null); finalView = LayoutInflater.from(context).inflate(R.layout.list_repo_watchers, null);
viewHolder = new ViewHolder(finalView); viewHolder = new ViewHolder(finalView);
finalView.setTag(viewHolder); finalView.setTag(viewHolder);
} }
@ -79,23 +80,25 @@ public class RepoWatchersAdapter extends BaseAdapter {
private void initData(RepoWatchersAdapter.ViewHolder viewHolder, int position) { private void initData(RepoWatchersAdapter.ViewHolder viewHolder, int position) {
UserInfo currentItem = watchersList.get(position); UserInfo currentItem = watchersList.get(position);
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
final TinyDB tinyDb = TinyDB.getInstance(mCtx); PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
final TinyDB tinyDb = TinyDB.getInstance(context);
Typeface myTypeface; Typeface myTypeface;
switch(tinyDb.getInt("customFontId", -1)) { switch(tinyDb.getInt("customFontId", -1)) {
case 0: case 0:
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf"); myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/roboto.ttf");
break; break;
case 2: case 2:
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf"); myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/sourcecodeproregular.ttf");
break; break;
default: default:
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf"); myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/manroperegular.ttf");
break; break;
} }

View File

@ -1,8 +1,5 @@
package org.mian.gitnex.adapters; package org.mian.gitnex.adapters;
import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
@ -13,31 +10,31 @@ import android.widget.CheckBox;
import android.widget.Filter; import android.widget.Filter;
import android.widget.Filterable; import android.widget.Filterable;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.TextDrawable;
import com.amulyakhare.textdrawable.util.ColorGenerator; import com.amulyakhare.textdrawable.util.ColorGenerator;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import org.gitnex.tea4j.models.UserRepositories; import org.gitnex.tea4j.models.UserRepositories;
import org.gitnex.tea4j.models.WatchInfo; import org.gitnex.tea4j.models.WatchInfo;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity; import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.database.api.RepositoriesApi; import org.mian.gitnex.database.api.RepositoriesApi;
import org.mian.gitnex.database.models.Repository; import org.mian.gitnex.database.models.Repository;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.ClickListener;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TimeHelper;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.Toasty;
import org.ocpsoft.prettytime.PrettyTime;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Locale;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -47,61 +44,54 @@ import retrofit2.Callback;
public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.ReposViewHolder> implements Filterable { public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.ReposViewHolder> implements Filterable {
private List<UserRepositories> reposList; private final List<UserRepositories> reposList;
private Context mCtx; private final Context context;
private List<UserRepositories> reposListFull; private final List<UserRepositories> reposListFull;
static class ReposViewHolder extends RecyclerView.ViewHolder { static class ReposViewHolder extends RecyclerView.ViewHolder {
private ImageView image; private UserRepositories userRepositories;
private TextView repoName;
private TextView repoDescription; private final ImageView image;
private TextView fullName; private final TextView repoName;
private final TextView orgName;
private final TextView repoDescription;
private CheckBox isRepoAdmin; private CheckBox isRepoAdmin;
private ImageView repoPrivatePublic; private final TextView repoStars;
private TextView repoStars; private final TextView repoLastUpdated;
private TextView repoForks;
private TextView repoOpenIssuesCount;
private TextView repoType;
private LinearLayout archiveRepo;
private TextView repoBranch;
private TextView htmlUrl;
private ReposViewHolder(View itemView) { private ReposViewHolder(View itemView) {
super(itemView); super(itemView);
repoName = itemView.findViewById(R.id.repoName); repoName = itemView.findViewById(R.id.repoName);
orgName = itemView.findViewById(R.id.orgName);
repoDescription = itemView.findViewById(R.id.repoDescription); repoDescription = itemView.findViewById(R.id.repoDescription);
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin); isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
image = itemView.findViewById(R.id.imageAvatar); image = itemView.findViewById(R.id.imageAvatar);
fullName = itemView.findViewById(R.id.repoFullName);
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
repoStars = itemView.findViewById(R.id.repoStars); repoStars = itemView.findViewById(R.id.repoStars);
repoForks = itemView.findViewById(R.id.repoForks); repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
repoType = itemView.findViewById(R.id.repoType);
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
repoBranch = itemView.findViewById(R.id.repoBranch);
htmlUrl = itemView.findViewById(R.id.htmlUrl);
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
Context context = v.getContext(); Context context = v.getContext();
TextView repoFullName = v.findViewById(R.id.repoFullName); TinyDB tinyDb = TinyDB.getInstance(context);
TextView repoType_ = v.findViewById(R.id.repoType);
Intent intent = new Intent(context, RepoDetailActivity.class); Intent intent = new Intent(context, RepoDetailActivity.class);
intent.putExtra("repoFullName", repoFullName.getText().toString()); intent.putExtra("repoFullName", userRepositories.getFullName());
TinyDB tinyDb = TinyDB.getInstance(context); tinyDb.putString("repoFullName", userRepositories.getFullName());
tinyDb.putString("repoFullName", repoFullName.getText().toString());
tinyDb.putString("repoType", repoType_.getText().toString());
//tinyDb.putBoolean("resumeIssues", true); //tinyDb.putBoolean("resumeIssues", true);
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked()); tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
tinyDb.putString("repoBranch", repoBranch.getText().toString()); tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
String[] parts = repoFullName.getText().toString().split("/"); if(userRepositories.getPrivateFlag()) {
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
}
else {
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
}
String[] parts = userRepositories.getFullName().split("/");
final String repoOwner = parts[0]; final String repoOwner = parts[0];
final String repoName = parts[1]; final String repoName = parts[1];
@ -115,13 +105,11 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName); long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", id); tinyDb.putLong("repositoryId", id);
} }
else { else {
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName); Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", data.getRepositoryId()); tinyDb.putLong("repositoryId", data.getRepositoryId());
} }
//store if user is watching this repo //store if user is watching this repo
@ -173,81 +161,13 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
context.startActivity(intent); context.startActivity(intent);
}); });
reposDropdownMenu.setOnClickListener(v -> {
final Context context = v.getContext();
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
TextView repoForksList = view.findViewById(R.id.repoForksList);
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
BottomSheetDialog dialog = new BottomSheetDialog(context);
dialog.setContentView(view);
dialog.show();
repoCopyUrl.setOnClickListener(openInBrowser -> {
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
dialog.dismiss();
});
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
context.startActivity(intentOpenInBrowser);
dialog.dismiss();
});
repoStargazers.setOnClickListener(stargazers -> {
Intent intent = new Intent(context, RepoStargazersActivity.class);
intent.putExtra("repoFullNameForStars", fullName.getText());
context.startActivity(intent);
dialog.dismiss();
});
repoWatchers.setOnClickListener(watchers -> {
Intent intentW = new Intent(context, RepoWatchersActivity.class);
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
context.startActivity(intentW);
dialog.dismiss();
});
repoForksList.setOnClickListener(forks -> {
Intent intentW = new Intent(context, RepoForksActivity.class);
intentW.putExtra("repoFullNameForForks", fullName.getText());
context.startActivity(intentW);
dialog.dismiss();
});
});
} }
} }
public ReposListAdapter(Context mCtx, List<UserRepositories> reposListMain) { public ReposListAdapter(Context ctx, List<UserRepositories> reposListMain) {
this.mCtx = mCtx; this.context = ctx;
this.reposList = reposListMain; this.reposList = reposListMain;
reposListFull = new ArrayList<>(reposList); reposListFull = new ArrayList<>(reposList);
} }
@ -263,20 +183,26 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
@Override @Override
public void onBindViewHolder(@NonNull ReposViewHolder holder, int position) { public void onBindViewHolder(@NonNull ReposViewHolder holder, int position) {
TinyDB tinyDb = TinyDB.getInstance(context);
UserRepositories currentItem = reposList.get(position); UserRepositories currentItem = reposList.get(position);
holder.repoDescription.setVisibility(View.GONE); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
holder.repoBranch.setText(currentItem.getDefault_branch());
holder.htmlUrl.setText(currentItem.getHtml_url()); String locale = tinyDb.getString("locale");
String timeFormat = tinyDb.getString("dateFormat");
holder.userRepositories = currentItem;
holder.orgName.setText(currentItem.getFullName().split("/")[0]);
holder.repoName.setText(currentItem.getFullName().split("/")[1]);
holder.repoStars.setText(currentItem.getStars_count());
ColorGenerator generator = ColorGenerator.MATERIAL; ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName()); int color = generator.getColor(currentItem.getName());
String firstCharacter = String.valueOf(currentItem.getName().charAt(0)); String firstCharacter = String.valueOf(currentItem.getFullName().split("/")[0].charAt(0));
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3); TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
if(currentItem.getAvatar_url() != null) { if(currentItem.getAvatar_url() != null) {
if(!currentItem.getAvatar_url().equals("")) { if(!currentItem.getAvatar_url().equals("")) {
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image); PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.image);
} }
else { else {
holder.image.setImageDrawable(drawable); holder.image.setImageDrawable(drawable);
@ -286,35 +212,42 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
holder.image.setImageDrawable(drawable); holder.image.setImageDrawable(drawable);
} }
holder.repoName.setText(currentItem.getName()); if(currentItem.getUpdated_at() != null) {
switch(timeFormat) {
case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
String createdTime = prettyTime.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
break;
}
case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break;
}
case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break;
}
}
}
else {
holder.repoLastUpdated.setVisibility(View.GONE);
}
if(!currentItem.getDescription().equals("")) { if(!currentItem.getDescription().equals("")) {
holder.repoDescription.setVisibility(View.VISIBLE);
holder.repoDescription.setText(currentItem.getDescription()); holder.repoDescription.setText(currentItem.getDescription());
} }
holder.fullName.setText(currentItem.getFullName());
if(currentItem.getPrivateFlag()) {
holder.repoPrivatePublic.setVisibility(View.VISIBLE);
holder.repoType.setText(R.string.strPrivate);
}
else {
holder.repoPrivatePublic.setVisibility(View.GONE);
holder.repoType.setText(R.string.strPublic);
}
holder.repoStars.setText(currentItem.getStars_count());
holder.repoForks.setText(currentItem.getForks_count());
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
if(holder.isRepoAdmin == null) { if(holder.isRepoAdmin == null) {
holder.isRepoAdmin = new CheckBox(mCtx); holder.isRepoAdmin = new CheckBox(context);
} }
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin()); holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
if(currentItem.isArchived()) {
holder.archiveRepo.setVisibility(View.VISIBLE);
}
else {
holder.archiveRepo.setVisibility(View.GONE);
}
} }
@Override @Override
@ -329,7 +262,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
return reposFilter; return reposFilter;
} }
private Filter reposFilter = new Filter() { private final Filter reposFilter = new Filter() {
@Override @Override
protected FilterResults performFiltering(CharSequence constraint) { protected FilterResults performFiltering(CharSequence constraint) {

View File

@ -1,8 +1,5 @@
package org.mian.gitnex.adapters; package org.mian.gitnex.adapters;
import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
@ -13,31 +10,31 @@ import android.widget.CheckBox;
import android.widget.Filter; import android.widget.Filter;
import android.widget.Filterable; import android.widget.Filterable;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.TextDrawable;
import com.amulyakhare.textdrawable.util.ColorGenerator; import com.amulyakhare.textdrawable.util.ColorGenerator;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import org.gitnex.tea4j.models.UserRepositories; import org.gitnex.tea4j.models.UserRepositories;
import org.gitnex.tea4j.models.WatchInfo; import org.gitnex.tea4j.models.WatchInfo;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity; import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.database.api.RepositoriesApi; import org.mian.gitnex.database.api.RepositoriesApi;
import org.mian.gitnex.database.models.Repository; import org.mian.gitnex.database.models.Repository;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.ClickListener;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TimeHelper;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.Toasty;
import org.ocpsoft.prettytime.PrettyTime;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Locale;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -47,58 +44,54 @@ import retrofit2.Callback;
public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesByOrgAdapter.OrgReposViewHolder> implements Filterable { public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesByOrgAdapter.OrgReposViewHolder> implements Filterable {
private List<UserRepositories> reposList; private final List<UserRepositories> reposList;
private Context mCtx; private final Context context;
private List<UserRepositories> reposListFull; private final List<UserRepositories> reposListFull;
static class OrgReposViewHolder extends RecyclerView.ViewHolder { static class OrgReposViewHolder extends RecyclerView.ViewHolder {
private ImageView image; private UserRepositories userRepositories;
private TextView repoName;
private TextView repoDescription; private final ImageView image;
private TextView fullName; private final TextView repoName;
private final TextView orgName;
private final TextView repoDescription;
private CheckBox isRepoAdmin; private CheckBox isRepoAdmin;
private ImageView repoPrivatePublic; private final TextView repoStars;
private TextView repoStars; private final TextView repoLastUpdated;
private TextView repoForks;
private TextView repoOpenIssuesCount;
private TextView repoType;
private LinearLayout archiveRepo;
private TextView repoBranch;
private TextView htmlUrl;
private OrgReposViewHolder(View itemView) { private OrgReposViewHolder(View itemView) {
super(itemView); super(itemView);
repoName = itemView.findViewById(R.id.repoName); repoName = itemView.findViewById(R.id.repoName);
orgName = itemView.findViewById(R.id.orgName);
repoDescription = itemView.findViewById(R.id.repoDescription); repoDescription = itemView.findViewById(R.id.repoDescription);
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin); isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
image = itemView.findViewById(R.id.imageAvatar); image = itemView.findViewById(R.id.imageAvatar);
fullName = itemView.findViewById(R.id.repoFullName);
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
repoStars = itemView.findViewById(R.id.repoStars); repoStars = itemView.findViewById(R.id.repoStars);
repoForks = itemView.findViewById(R.id.repoForks); repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
repoType = itemView.findViewById(R.id.repoType);
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
repoBranch = itemView.findViewById(R.id.repoBranch);
htmlUrl = itemView.findViewById(R.id.htmlUrl);
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
Context context = v.getContext(); Context context = v.getContext();
TinyDB tinyDb = TinyDB.getInstance(context);
Intent intent = new Intent(context, RepoDetailActivity.class); Intent intent = new Intent(context, RepoDetailActivity.class);
intent.putExtra("repoFullName", fullName.getText().toString()); intent.putExtra("repoFullName", userRepositories.getFullName());
TinyDB tinyDb = TinyDB.getInstance(context); tinyDb.putString("repoFullName", userRepositories.getFullName());
tinyDb.putString("repoFullName", fullName.getText().toString());
tinyDb.putString("repoType", repoType.getText().toString());
//tinyDb.putBoolean("resumeIssues", true); //tinyDb.putBoolean("resumeIssues", true);
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked()); tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
tinyDb.putString("repoBranch", repoBranch.getText().toString()); tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
String[] parts = fullName.getText().toString().split("/"); if(userRepositories.getPrivateFlag()) {
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
}
else {
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
}
String[] parts = userRepositories.getFullName().split("/");
final String repoOwner = parts[0]; final String repoOwner = parts[0];
final String repoName = parts[1]; final String repoName = parts[1];
@ -112,13 +105,11 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName); long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", id); tinyDb.putLong("repositoryId", id);
} }
else { else {
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName); Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", data.getRepositoryId()); tinyDb.putLong("repositoryId", data.getRepositoryId());
} }
//store if user is watching this repo //store if user is watching this repo
@ -167,81 +158,13 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
context.startActivity(intent); context.startActivity(intent);
}); });
reposDropdownMenu.setOnClickListener(v -> {
final Context context = v.getContext();
@SuppressLint("InflateParams")
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
TextView repoForksList = view.findViewById(R.id.repoForksList);
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
BottomSheetDialog dialog = new BottomSheetDialog(context);
dialog.setContentView(view);
dialog.show();
repoCopyUrl.setOnClickListener(openInBrowser -> {
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
dialog.dismiss();
});
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
context.startActivity(intentOpenInBrowser);
dialog.dismiss();
});
repoStargazers.setOnClickListener(stargazers -> {
Intent intent = new Intent(context, RepoStargazersActivity.class);
intent.putExtra("repoFullNameForStars", fullName.getText());
context.startActivity(intent);
dialog.dismiss();
});
repoWatchers.setOnClickListener(watchers -> {
Intent intentW = new Intent(context, RepoWatchersActivity.class);
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
context.startActivity(intentW);
dialog.dismiss();
});
repoForksList.setOnClickListener(forks -> {
Intent intentW = new Intent(context, RepoForksActivity.class);
intentW.putExtra("repoFullNameForForks", fullName.getText());
context.startActivity(intentW);
dialog.dismiss();
});
});
} }
} }
public RepositoriesByOrgAdapter(Context mCtx, List<UserRepositories> reposListMain) { public RepositoriesByOrgAdapter(Context ctx, List<UserRepositories> reposListMain) {
this.mCtx = mCtx;
this.context = ctx;
this.reposList = reposListMain; this.reposList = reposListMain;
reposListFull = new ArrayList<>(reposList); reposListFull = new ArrayList<>(reposList);
} }
@ -249,6 +172,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
@NonNull @NonNull
@Override @Override
public RepositoriesByOrgAdapter.OrgReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public RepositoriesByOrgAdapter.OrgReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_repositories, parent, false); View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_repositories, parent, false);
return new RepositoriesByOrgAdapter.OrgReposViewHolder(v); return new RepositoriesByOrgAdapter.OrgReposViewHolder(v);
} }
@ -256,10 +180,16 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
@Override @Override
public void onBindViewHolder(@NonNull RepositoriesByOrgAdapter.OrgReposViewHolder holder, int position) { public void onBindViewHolder(@NonNull RepositoriesByOrgAdapter.OrgReposViewHolder holder, int position) {
TinyDB tinyDb = TinyDB.getInstance(context);
UserRepositories currentItem = reposList.get(position); UserRepositories currentItem = reposList.get(position);
holder.repoDescription.setVisibility(View.GONE); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
holder.repoBranch.setText(currentItem.getDefault_branch());
holder.htmlUrl.setText(currentItem.getHtml_url()); String locale = tinyDb.getString("locale");
String timeFormat = tinyDb.getString("dateFormat");
holder.userRepositories = currentItem;
holder.orgName.setText(currentItem.getFullName().split("/")[0]);
holder.repoName.setText(currentItem.getFullName().split("/")[1]);
holder.repoStars.setText(currentItem.getStars_count());
ColorGenerator generator = ColorGenerator.MATERIAL; ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName()); int color = generator.getColor(currentItem.getName());
@ -277,7 +207,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
if (currentItem.getAvatar_url() != null) { if (currentItem.getAvatar_url() != null) {
if (!currentItem.getAvatar_url().equals("")) { if (!currentItem.getAvatar_url().equals("")) {
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image); PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.image);
} else { } else {
holder.image.setImageDrawable(drawable); holder.image.setImageDrawable(drawable);
} }
@ -286,36 +216,42 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
holder.image.setImageDrawable(drawable); holder.image.setImageDrawable(drawable);
} }
holder.repoName.setText(currentItem.getName()); if(currentItem.getUpdated_at() != null) {
switch(timeFormat) {
case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
String createdTime = prettyTime.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
break;
}
case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break;
}
case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break;
}
}
}
else {
holder.repoLastUpdated.setVisibility(View.GONE);
}
if(!currentItem.getDescription().equals("")) { if(!currentItem.getDescription().equals("")) {
holder.repoDescription.setVisibility(View.VISIBLE);
holder.repoDescription.setText(currentItem.getDescription()); holder.repoDescription.setText(currentItem.getDescription());
} }
holder.fullName.setText(currentItem.getFullName());
if(currentItem.getPrivateFlag()) {
holder.repoPrivatePublic.setVisibility(View.VISIBLE);
holder.repoType.setText(R.string.strPrivate);
}
else {
holder.repoPrivatePublic.setVisibility(View.GONE);
holder.repoType.setText(R.string.strPublic);
}
holder.repoStars.setText(currentItem.getStars_count());
holder.repoForks.setText(currentItem.getForks_count());
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
if(holder.isRepoAdmin == null) { if(holder.isRepoAdmin == null) {
holder.isRepoAdmin = new CheckBox(mCtx); holder.isRepoAdmin = new CheckBox(context);
} }
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin()); holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
if(currentItem.isArchived()) {
holder.archiveRepo.setVisibility(View.VISIBLE);
}
else {
holder.archiveRepo.setVisibility(View.GONE);
}
} }
@Override @Override

View File

@ -35,14 +35,14 @@ import java.util.Locale;
public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapter.SearchViewHolder> { public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapter.SearchViewHolder> {
private final List<Issues> searchedList; private final List<Issues> searchedList;
private final Context mCtx; private final Context context;
private final TinyDB tinyDb; private final TinyDB tinyDb;
public SearchIssuesAdapter(List<Issues> dataList, Context mCtx) { public SearchIssuesAdapter(List<Issues> dataList, Context ctx) {
this.mCtx = mCtx; this.context = ctx;
this.searchedList = dataList; this.searchedList = dataList;
this.tinyDb = TinyDB.getInstance(mCtx); this.tinyDb = TinyDB.getInstance(context);
} }
class SearchViewHolder extends RecyclerView.ViewHolder { class SearchViewHolder extends RecyclerView.ViewHolder {
@ -63,7 +63,7 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount); issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount);
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime); issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
issueTitle.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
Context context = v.getContext(); Context context = v.getContext();
@ -121,19 +121,20 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
public void onBindViewHolder(@NonNull final SearchIssuesAdapter.SearchViewHolder holder, int position) { public void onBindViewHolder(@NonNull final SearchIssuesAdapter.SearchViewHolder holder, int position) {
Issues currentItem = searchedList.get(position); Issues currentItem = searchedList.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
String locale = tinyDb.getString("locale"); String locale = tinyDb.getString("locale");
String timeFormat = tinyDb.getString("dateFormat"); String timeFormat = tinyDb.getString("dateFormat");
PicassoService.getInstance(mCtx).get() PicassoService.getInstance(context).get()
.load(currentItem.getUser().getAvatar_url()) .load(currentItem.getUser().getAvatar_url())
.placeholder(R.drawable.loader_animated) .placeholder(R.drawable.loader_animated)
.transform(new RoundedTransformation(8, 0)) .transform(new RoundedTransformation(imgRadius, 0))
.resize(120, 120) .resize(120, 120)
.centerCrop() .centerCrop()
.into(holder.issueAssigneeAvatar); .into(holder.issueAssigneeAvatar);
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(mCtx.getResources(), R.color.lightGray, null) + "'>" + currentItem.getRepository().getFull_name() + mCtx.getResources().getString(R.string.hash) + currentItem.getNumber() + "</font>"; String issueNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + currentItem.getRepository().getFull_name() + context.getResources().getString(R.string.hash) + currentItem.getNumber() + "</font>";
holder.issue = currentItem; holder.issue = currentItem;
holder.issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + currentItem.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); holder.issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + currentItem.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY));
@ -144,17 +145,17 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
PrettyTime prettyTime = new PrettyTime(new Locale(locale)); PrettyTime prettyTime = new PrettyTime(new Locale(locale));
String createdTime = prettyTime.format(currentItem.getCreated_at()); String createdTime = prettyTime.format(currentItem.getCreated_at());
holder.issueCreatedTime.setText(createdTime); holder.issueCreatedTime.setText(createdTime);
holder.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getCreated_at()), mCtx)); holder.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getCreated_at()), context));
break; break;
} }
case "normal": { case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + mCtx.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getCreated_at()); String createdTime = formatter.format(currentItem.getCreated_at());
holder.issueCreatedTime.setText(createdTime); holder.issueCreatedTime.setText(createdTime);
break; break;
} }
case "normal1": { case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + mCtx.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getCreated_at()); String createdTime = formatter.format(currentItem.getCreated_at());
holder.issueCreatedTime.setText(createdTime); holder.issueCreatedTime.setText(createdTime);
break; break;

View File

@ -1,59 +0,0 @@
package org.mian.gitnex.adapters;
import android.text.SpannableStringBuilder;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import org.mian.gitnex.R;
import java.util.List;
/**
* Author M M Arif
*/
public class SponsorsAdapter extends RecyclerView.Adapter<SponsorsAdapter.SponsorsViewHolder> {
private List<CharSequence> sponsorsList;
static class SponsorsViewHolder extends RecyclerView.ViewHolder {
private TextView sponsorText;
private SponsorsViewHolder(View itemView) {
super(itemView);
sponsorText = itemView.findViewById(R.id.sponsorText);
}
}
public SponsorsAdapter(List<CharSequence> sponsorsListMain) {
this.sponsorsList = sponsorsListMain;
}
@NonNull
@Override
public SponsorsAdapter.SponsorsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.sponsors, parent, false);
return new SponsorsAdapter.SponsorsViewHolder(v);
}
@Override
public void onBindViewHolder(@NonNull SponsorsAdapter.SponsorsViewHolder holder, int position) {
SpannableStringBuilder strBuilder = new SpannableStringBuilder(sponsorsList.get(position));
holder.sponsorText.setText((strBuilder));
holder.sponsorText.setMovementMethod(LinkMovementMethod.getInstance());
}
@Override
public int getItemCount() {
return sponsorsList.size();
}
}

View File

@ -1,8 +1,5 @@
package org.mian.gitnex.adapters; package org.mian.gitnex.adapters;
import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
@ -13,31 +10,31 @@ import android.widget.CheckBox;
import android.widget.Filter; import android.widget.Filter;
import android.widget.Filterable; import android.widget.Filterable;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.TextDrawable;
import com.amulyakhare.textdrawable.util.ColorGenerator; import com.amulyakhare.textdrawable.util.ColorGenerator;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import org.gitnex.tea4j.models.UserRepositories; import org.gitnex.tea4j.models.UserRepositories;
import org.gitnex.tea4j.models.WatchInfo; import org.gitnex.tea4j.models.WatchInfo;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity; import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.database.api.RepositoriesApi; import org.mian.gitnex.database.api.RepositoriesApi;
import org.mian.gitnex.database.models.Repository; import org.mian.gitnex.database.models.Repository;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.ClickListener;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TimeHelper;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.Toasty;
import org.ocpsoft.prettytime.PrettyTime;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Locale;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -47,58 +44,54 @@ import retrofit2.Callback;
public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposListAdapter.StarredReposViewHolder> implements Filterable { public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposListAdapter.StarredReposViewHolder> implements Filterable {
private List<UserRepositories> reposList; private final List<UserRepositories> reposList;
private Context mCtx; private final Context context;
private List<UserRepositories> reposListFull; private final List<UserRepositories> reposListFull;
static class StarredReposViewHolder extends RecyclerView.ViewHolder { static class StarredReposViewHolder extends RecyclerView.ViewHolder {
private ImageView image; private UserRepositories userRepositories;
private TextView repoName;
private TextView repoDescription; private final ImageView image;
private TextView fullName; private final TextView repoName;
private final TextView orgName;
private final TextView repoDescription;
private CheckBox isRepoAdmin; private CheckBox isRepoAdmin;
private ImageView repoPrivatePublic; private final TextView repoStars;
private TextView repoStars; private final TextView repoLastUpdated;
private TextView repoForks;
private TextView repoOpenIssuesCount;
private TextView repoType;
private LinearLayout archiveRepo;
private TextView repoBranch;
private TextView htmlUrl;
private StarredReposViewHolder(View itemView) { private StarredReposViewHolder(View itemView) {
super(itemView); super(itemView);
repoName = itemView.findViewById(R.id.repoName); repoName = itemView.findViewById(R.id.repoName);
orgName = itemView.findViewById(R.id.orgName);
repoDescription = itemView.findViewById(R.id.repoDescription); repoDescription = itemView.findViewById(R.id.repoDescription);
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin); isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
image = itemView.findViewById(R.id.imageAvatar); image = itemView.findViewById(R.id.imageAvatar);
fullName = itemView.findViewById(R.id.repoFullName);
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
repoStars = itemView.findViewById(R.id.repoStars); repoStars = itemView.findViewById(R.id.repoStars);
repoForks = itemView.findViewById(R.id.repoForks); repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
repoType = itemView.findViewById(R.id.repoType);
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
repoBranch = itemView.findViewById(R.id.repoBranch);
htmlUrl = itemView.findViewById(R.id.htmlUrl);
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
Context context = v.getContext(); Context context = v.getContext();
TinyDB tinyDb = TinyDB.getInstance(context);
Intent intent = new Intent(context, RepoDetailActivity.class); Intent intent = new Intent(context, RepoDetailActivity.class);
intent.putExtra("repoFullName", fullName.getText().toString()); intent.putExtra("repoFullName", userRepositories.getFullName());
TinyDB tinyDb = TinyDB.getInstance(context); tinyDb.putString("repoFullName", userRepositories.getFullName());
tinyDb.putString("repoFullName", fullName.getText().toString());
tinyDb.putString("repoType", repoType.getText().toString());
//tinyDb.putBoolean("resumeIssues", true); //tinyDb.putBoolean("resumeIssues", true);
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked()); tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
tinyDb.putString("repoBranch", repoBranch.getText().toString()); tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
String[] parts = fullName.getText().toString().split("/"); if(userRepositories.getPrivateFlag()) {
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
}
else {
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
}
String[] parts = userRepositories.getFullName().split("/");
final String repoOwner = parts[0]; final String repoOwner = parts[0];
final String repoName = parts[1]; final String repoName = parts[1];
@ -112,13 +105,11 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName); long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", id); tinyDb.putLong("repositoryId", id);
} }
else { else {
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName); Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", data.getRepositoryId()); tinyDb.putLong("repositoryId", data.getRepositoryId());
} }
//store if user is watching this repo //store if user is watching this repo
@ -170,81 +161,12 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
context.startActivity(intent); context.startActivity(intent);
}); });
reposDropdownMenu.setOnClickListener(v -> {
final Context context = v.getContext();
@SuppressLint("InflateParams")
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
TextView repoForksList = view.findViewById(R.id.repoForksList);
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
BottomSheetDialog dialog = new BottomSheetDialog(context);
dialog.setContentView(view);
dialog.show();
repoCopyUrl.setOnClickListener(openInBrowser -> {
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
dialog.dismiss();
});
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
context.startActivity(intentOpenInBrowser);
dialog.dismiss();
});
repoStargazers.setOnClickListener(stargazers -> {
Intent intent = new Intent(context, RepoStargazersActivity.class);
intent.putExtra("repoFullNameForStars", fullName.getText());
context.startActivity(intent);
dialog.dismiss();
});
repoWatchers.setOnClickListener(watchers -> {
Intent intentW = new Intent(context, RepoWatchersActivity.class);
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
context.startActivity(intentW);
dialog.dismiss();
});
repoForksList.setOnClickListener(forks -> {
Intent intentW = new Intent(context, RepoForksActivity.class);
intentW.putExtra("repoFullNameForForks", fullName.getText());
context.startActivity(intentW);
dialog.dismiss();
});
});
} }
} }
public StarredReposListAdapter(Context mCtx, List<UserRepositories> reposListMain) { public StarredReposListAdapter(Context ctx, List<UserRepositories> reposListMain) {
this.mCtx = mCtx; this.context = ctx;
this.reposList = reposListMain; this.reposList = reposListMain;
reposListFull = new ArrayList<>(reposList); reposListFull = new ArrayList<>(reposList);
} }
@ -259,10 +181,16 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
@Override @Override
public void onBindViewHolder(@NonNull StarredReposListAdapter.StarredReposViewHolder holder, int position) { public void onBindViewHolder(@NonNull StarredReposListAdapter.StarredReposViewHolder holder, int position) {
TinyDB tinyDb = TinyDB.getInstance(context);
UserRepositories currentItem = reposList.get(position); UserRepositories currentItem = reposList.get(position);
holder.repoDescription.setVisibility(View.GONE); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
holder.repoBranch.setText(currentItem.getDefault_branch());
holder.htmlUrl.setText(currentItem.getHtml_url()); String locale = tinyDb.getString("locale");
String timeFormat = tinyDb.getString("dateFormat");
holder.userRepositories = currentItem;
holder.orgName.setText(currentItem.getFullName().split("/")[0]);
holder.repoName.setText(currentItem.getFullName().split("/")[1]);
holder.repoStars.setText(currentItem.getStars_count());
ColorGenerator generator = ColorGenerator.MATERIAL; ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName()); int color = generator.getColor(currentItem.getName());
@ -280,7 +208,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
if (currentItem.getAvatar_url() != null) { if (currentItem.getAvatar_url() != null) {
if (!currentItem.getAvatar_url().equals("")) { if (!currentItem.getAvatar_url().equals("")) {
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image); PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.image);
} else { } else {
holder.image.setImageDrawable(drawable); holder.image.setImageDrawable(drawable);
} }
@ -289,35 +217,42 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
holder.image.setImageDrawable(drawable); holder.image.setImageDrawable(drawable);
} }
holder.repoName.setText(currentItem.getName()); if(currentItem.getUpdated_at() != null) {
switch(timeFormat) {
case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
String createdTime = prettyTime.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
break;
}
case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break;
}
case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break;
}
}
}
else {
holder.repoLastUpdated.setVisibility(View.GONE);
}
if(!currentItem.getDescription().equals("")) { if(!currentItem.getDescription().equals("")) {
holder.repoDescription.setVisibility(View.VISIBLE);
holder.repoDescription.setText(currentItem.getDescription()); holder.repoDescription.setText(currentItem.getDescription());
} }
holder.fullName.setText(currentItem.getFullName());
if(currentItem.getPrivateFlag()) {
holder.repoPrivatePublic.setVisibility(View.VISIBLE);
holder.repoType.setText(R.string.strPrivate);
}
else {
holder.repoPrivatePublic.setVisibility(View.GONE);
holder.repoType.setText(R.string.strPublic);
}
holder.repoStars.setText(currentItem.getStars_count());
holder.repoForks.setText(currentItem.getForks_count());
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
if(holder.isRepoAdmin == null) { if(holder.isRepoAdmin == null) {
holder.isRepoAdmin = new CheckBox(mCtx); holder.isRepoAdmin = new CheckBox(context);
} }
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin()); holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
if(currentItem.isArchived()) {
holder.archiveRepo.setVisibility(View.VISIBLE);
}
else {
holder.archiveRepo.setVisibility(View.GONE);
}
} }
@Override @Override
@ -330,7 +265,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
return starredReposFilter; return starredReposFilter;
} }
private Filter starredReposFilter = new Filter() { private final Filter starredReposFilter = new Filter() {
@Override @Override
protected FilterResults performFiltering(CharSequence constraint) { protected FilterResults performFiltering(CharSequence constraint) {
List<UserRepositories> filteredList = new ArrayList<>(); List<UserRepositories> filteredList = new ArrayList<>();

View File

@ -25,7 +25,7 @@ import java.util.List;
public class TeamMembersByOrgAdapter extends BaseAdapter { public class TeamMembersByOrgAdapter extends BaseAdapter {
private final List<UserInfo> teamMembersList; private final List<UserInfo> teamMembersList;
private final Context mCtx; private final Context context;
private static class ViewHolder { private static class ViewHolder {
@ -48,9 +48,9 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
} }
} }
public TeamMembersByOrgAdapter(Context mCtx, List<UserInfo> membersListMain) { public TeamMembersByOrgAdapter(Context ctx, List<UserInfo> membersListMain) {
this.mCtx = mCtx; this.context = ctx;
this.teamMembersList = membersListMain; this.teamMembersList = membersListMain;
} }
@ -77,7 +77,7 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
if (finalView == null) { if (finalView == null) {
finalView = LayoutInflater.from(mCtx).inflate(R.layout.list_members_by_team_by_org, null); finalView = LayoutInflater.from(context).inflate(R.layout.list_members_by_team_by_org, null);
viewHolder = new ViewHolder(finalView); viewHolder = new ViewHolder(finalView);
finalView.setTag(viewHolder); finalView.setTag(viewHolder);
} }
@ -93,25 +93,27 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
private void initData(TeamMembersByOrgAdapter.ViewHolder viewHolder, int position) { private void initData(TeamMembersByOrgAdapter.ViewHolder viewHolder, int position) {
UserInfo currentItem = teamMembersList.get(position); UserInfo currentItem = teamMembersList.get(position);
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
viewHolder.userLoginId = currentItem.getLogin(); viewHolder.userLoginId = currentItem.getLogin();
final TinyDB tinyDb = TinyDB.getInstance(mCtx); final TinyDB tinyDb = TinyDB.getInstance(context);
Typeface myTypeface; Typeface myTypeface;
switch(tinyDb.getInt("customFontId", -1)) { switch(tinyDb.getInt("customFontId", -1)) {
case 0: case 0:
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf"); myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/roboto.ttf");
break; break;
case 2: case 2:
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf"); myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/sourcecodeproregular.ttf");
break; break;
default: default:
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf"); myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/manroperegular.ttf");
break; break;
} }

View File

@ -22,44 +22,41 @@ import java.util.List;
public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.OrgTeamsViewHolder> implements Filterable { public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.OrgTeamsViewHolder> implements Filterable {
private List<Teams> teamList; private final List<Teams> teamList;
private Context mCtx; private final Context context;
private List<Teams> teamListFull; private final List<Teams> teamListFull;
static class OrgTeamsViewHolder extends RecyclerView.ViewHolder { static class OrgTeamsViewHolder extends RecyclerView.ViewHolder {
private TextView teamTitle; private Teams teams;
private TextView teamId;
private TextView teamDescription; private final TextView teamTitle;
private TextView teamPermission; private final TextView teamDescription;
private final TextView teamPermission;
private OrgTeamsViewHolder(View itemView) { private OrgTeamsViewHolder(View itemView) {
super(itemView); super(itemView);
teamTitle = itemView.findViewById(R.id.teamTitle); teamTitle = itemView.findViewById(R.id.teamTitle);
teamId = itemView.findViewById(R.id.teamId);
teamDescription = itemView.findViewById(R.id.teamDescription); teamDescription = itemView.findViewById(R.id.teamDescription);
teamPermission = itemView.findViewById(R.id.teamPermission); teamPermission = itemView.findViewById(R.id.teamPermission);
itemView.setOnClickListener(new View.OnClickListener() { itemView.setOnClickListener(v -> {
@Override
public void onClick(View v) {
Context context = v.getContext(); Context context = v.getContext();
Intent intent = new Intent(context, OrganizationTeamMembersActivity.class); Intent intent = new Intent(context, OrganizationTeamMembersActivity.class);
intent.putExtra("teamTitle", teamTitle.getText().toString()); intent.putExtra("teamTitle", teams.getName());
intent.putExtra("teamId", teamId.getText().toString()); intent.putExtra("teamId", String.valueOf(teams.getId()));
context.startActivity(intent); context.startActivity(intent);
}
}); });
} }
} }
public TeamsByOrgAdapter(Context mCtx, List<Teams> teamListMain) { public TeamsByOrgAdapter(Context ctx, List<Teams> teamListMain) {
this.mCtx = mCtx; this.context = ctx;
this.teamList = teamListMain; this.teamList = teamListMain;
teamListFull = new ArrayList<>(teamList); teamListFull = new ArrayList<>(teamList);
} }
@ -75,8 +72,10 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
public void onBindViewHolder(@NonNull TeamsByOrgAdapter.OrgTeamsViewHolder holder, int position) { public void onBindViewHolder(@NonNull TeamsByOrgAdapter.OrgTeamsViewHolder holder, int position) {
Teams currentItem = teamList.get(position); Teams currentItem = teamList.get(position);
holder.teamId.setText(String.valueOf(currentItem.getId()));
holder.teams = currentItem;
holder.teamTitle.setText(currentItem.getName()); holder.teamTitle.setText(currentItem.getName());
if (!currentItem.getDescription().equals("")) { if (!currentItem.getDescription().equals("")) {
holder.teamDescription.setVisibility(View.VISIBLE); holder.teamDescription.setVisibility(View.VISIBLE);
holder.teamDescription.setText(currentItem.getDescription()); holder.teamDescription.setText(currentItem.getDescription());
@ -85,8 +84,7 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
holder.teamDescription.setVisibility(View.GONE); holder.teamDescription.setVisibility(View.GONE);
holder.teamDescription.setText(""); holder.teamDescription.setText("");
} }
holder.teamPermission.setText(mCtx.getResources().getString(R.string.teamPermission, currentItem.getPermission())); holder.teamPermission.setText(context.getResources().getString(R.string.teamPermission, currentItem.getPermission()));
} }
@Override @Override
@ -99,7 +97,7 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
return orgTeamsFilter; return orgTeamsFilter;
} }
private Filter orgTeamsFilter = new Filter() { private final Filter orgTeamsFilter = new Filter() {
@Override @Override
protected FilterResults performFiltering(CharSequence constraint) { protected FilterResults performFiltering(CharSequence constraint) {
List<Teams> filteredList = new ArrayList<>(); List<Teams> filteredList = new ArrayList<>();

View File

@ -16,6 +16,7 @@ import org.mian.gitnex.R;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.database.api.UserAccountsApi; import org.mian.gitnex.database.api.UserAccountsApi;
import org.mian.gitnex.database.models.UserAccount; import org.mian.gitnex.database.models.UserAccount;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.Toasty;
@ -29,7 +30,7 @@ import io.mikael.urlbuilder.UrlBuilder;
public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapter.UserAccountsViewHolder> { public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapter.UserAccountsViewHolder> {
private final List<UserAccount> userAccountsList; private final List<UserAccount> userAccountsList;
private final Context mCtx; private final Context context;
private TinyDB tinyDB; private TinyDB tinyDB;
class UserAccountsViewHolder extends RecyclerView.ViewHolder { class UserAccountsViewHolder extends RecyclerView.ViewHolder {
@ -55,22 +56,22 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
deleteAccount.setOnClickListener(itemDelete -> { deleteAccount.setOnClickListener(itemDelete -> {
new AlertDialog.Builder(mCtx) new AlertDialog.Builder(context)
.setIcon(AppCompatResources.getDrawable(mCtx, R.drawable.ic_delete)) .setIcon(AppCompatResources.getDrawable(context, R.drawable.ic_delete))
.setTitle(mCtx.getResources().getString(R.string.removeAccountPopupTitle)) .setTitle(context.getResources().getString(R.string.removeAccountPopupTitle))
.setMessage(mCtx.getResources().getString(R.string.removeAccountPopupMessage)) .setMessage(context.getResources().getString(R.string.removeAccountPopupMessage))
.setPositiveButton(mCtx.getResources().getString(R.string.removeButton), (dialog, which) -> { .setPositiveButton(context.getResources().getString(R.string.removeButton), (dialog, which) -> {
updateLayoutByPosition(getAdapterPosition()); updateLayoutByPosition(getAdapterPosition());
UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx); UserAccountsApi userAccountsApi = new UserAccountsApi(context);
userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId))); userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId)));
}).setNeutralButton(mCtx.getResources().getString(R.string.cancelButton), null) }).setNeutralButton(context.getResources().getString(R.string.cancelButton), null)
.show(); .show();
}); });
itemView.setOnClickListener(switchAccount -> { itemView.setOnClickListener(switchAccount -> {
UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx); UserAccountsApi userAccountsApi = new UserAccountsApi(context);
UserAccount userAccount = userAccountsApi.getAccountData(accountName); UserAccount userAccount = userAccountsApi.getAccountData(accountName);
if(tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) { if(tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) {
@ -85,8 +86,8 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
tinyDB.putString("instanceUrl", userAccount.getInstanceUrl()); tinyDB.putString("instanceUrl", userAccount.getInstanceUrl());
tinyDB.putInt("currentActiveAccountId", userAccount.getAccountId()); tinyDB.putInt("currentActiveAccountId", userAccount.getAccountId());
Toasty.success(mCtx, mCtx.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url)); Toasty.success(context, context.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
((Activity) mCtx).recreate(); ((Activity) context).recreate();
} }
}); });
@ -95,9 +96,9 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
} }
public UserAccountsAdapter(Context mCtx, List<UserAccount> userAccountsListMain) { public UserAccountsAdapter(Context ctx, List<UserAccount> userAccountsListMain) {
this.mCtx = mCtx; this.context = ctx;
this.userAccountsList = userAccountsListMain; this.userAccountsList = userAccountsListMain;
} }
@ -106,7 +107,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
userAccountsList.remove(position); userAccountsList.remove(position);
notifyItemRemoved(position); notifyItemRemoved(position);
notifyItemRangeChanged(position, userAccountsList.size()); notifyItemRangeChanged(position, userAccountsList.size());
Toasty.success(mCtx, mCtx.getResources().getString(R.string.accountDeletedMessage)); Toasty.success(context, context.getResources().getString(R.string.accountDeletedMessage));
} }
@NonNull @NonNull
@ -122,7 +123,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
public void onBindViewHolder(@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) { public void onBindViewHolder(@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) {
UserAccount currentItem = userAccountsList.get(position); UserAccount currentItem = userAccountsList.get(position);
tinyDB = TinyDB.getInstance(mCtx); tinyDB = TinyDB.getInstance(context);
String url = UrlBuilder.fromString(currentItem.getInstanceUrl()) String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
.withPath("/") .withPath("/")
@ -131,17 +132,23 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
holder.accountId = currentItem.getAccountId(); holder.accountId = currentItem.getAccountId();
holder.accountName = currentItem.getAccountName(); holder.accountName = currentItem.getAccountName();
holder.userId.setText(String.format("@%s", currentItem.getUserName())); holder.userId.setText(currentItem.getUserName());
holder.accountUrl.setText(url); 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); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
PicassoService.getInstance(context).get()
.load(url + "img/favicon.png")
.placeholder(R.drawable.loader_animated)
.transform(new RoundedTransformation(imgRadius, 0))
.resize(120, 120)
.centerCrop()
.into(holder.repoAvatar);
if(tinyDB.getInt("currentActiveAccountId") == currentItem.getAccountId()) { if(tinyDB.getInt("currentActiveAccountId") == currentItem.getAccountId()) {
holder.activeAccount.setVisibility(View.VISIBLE); holder.activeAccount.setVisibility(View.VISIBLE);
} }
else { else {
holder.deleteAccount.setVisibility(View.VISIBLE); holder.deleteAccount.setVisibility(View.VISIBLE);
} }
} }

View File

@ -12,6 +12,7 @@ import androidx.annotation.Nullable;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.database.models.UserAccount; import org.mian.gitnex.database.models.UserAccount;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import java.util.List; import java.util.List;
@ -23,18 +24,17 @@ import io.mikael.urlbuilder.UrlBuilder;
public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> { public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> {
private final Context mCtx; private final Context context;
private final TinyDB tinyDB; private final TinyDB tinyDB;
private final List<UserAccount> userAccounts; private final List<UserAccount> userAccounts;
public UserAccountsListDialogAdapter(@NonNull Context mCtx, int resource, @NonNull List<UserAccount> userAccounts) { public UserAccountsListDialogAdapter(@NonNull Context ctx, int resource, @NonNull List<UserAccount> userAccounts) {
super(mCtx, resource, userAccounts); super(ctx, resource, userAccounts);
tinyDB = TinyDB.getInstance(mCtx); tinyDB = TinyDB.getInstance(ctx);
this.userAccounts = userAccounts; this.userAccounts = userAccounts;
this.mCtx = mCtx; this.context = ctx;
} }
@NonNull @NonNull
@ -42,7 +42,7 @@ public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> {
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
if(convertView == null) { if(convertView == null) {
convertView = LayoutInflater.from(mCtx).inflate(R.layout.custom_user_accounts_list, parent, false); convertView = LayoutInflater.from(context).inflate(R.layout.custom_user_accounts_list, parent, false);
} }
ImageView profileImage = convertView.findViewById(R.id.profileImage); ImageView profileImage = convertView.findViewById(R.id.profileImage);
@ -51,6 +51,7 @@ public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> {
ImageView activeAccount = convertView.findViewById(R.id.activeAccount); ImageView activeAccount = convertView.findViewById(R.id.activeAccount);
UserAccount currentItem = userAccounts.get(position); UserAccount currentItem = userAccounts.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
String url = UrlBuilder.fromString(currentItem.getInstanceUrl()) String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
.withPath("/") .withPath("/")
@ -67,7 +68,7 @@ public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> {
} }
PicassoService PicassoService
.getInstance(mCtx).get().load(url + "img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(profileImage); .getInstance(context).get().load(url + "img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(profileImage);
return convertView; return convertView;

View File

@ -21,6 +21,7 @@ import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.database.api.UserAccountsApi; import org.mian.gitnex.database.api.UserAccountsApi;
import org.mian.gitnex.database.models.UserAccount; import org.mian.gitnex.database.models.UserAccount;
import org.mian.gitnex.fragments.UserAccountsFragment; import org.mian.gitnex.fragments.UserAccountsFragment;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.Toasty;
@ -34,13 +35,13 @@ import io.mikael.urlbuilder.UrlBuilder;
public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNavAdapter.UserAccountsViewHolder> { public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNavAdapter.UserAccountsViewHolder> {
private static DrawerLayout drawer; private static DrawerLayout drawer;
private List<UserAccount> userAccountsList; private final List<UserAccount> userAccountsList;
private Context mCtx; private final Context context;
private TextView toolbarTitle; private final TextView toolbarTitle;
public UserAccountsNavAdapter(Context mCtx, List<UserAccount> userAccountsListMain, DrawerLayout drawerLayout, TextView toolbarTitle) { public UserAccountsNavAdapter(Context ctx, List<UserAccount> userAccountsListMain, DrawerLayout drawerLayout, TextView toolbarTitle) {
this.mCtx = mCtx; this.context = ctx;
this.userAccountsList = userAccountsListMain; this.userAccountsList = userAccountsListMain;
drawer = drawerLayout; drawer = drawerLayout;
this.toolbarTitle = toolbarTitle; this.toolbarTitle = toolbarTitle;
@ -48,7 +49,7 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
class UserAccountsViewHolder extends RecyclerView.ViewHolder { class UserAccountsViewHolder extends RecyclerView.ViewHolder {
private ImageView userAccountAvatar; private final ImageView userAccountAvatar;
private UserAccountsViewHolder(View itemView) { private UserAccountsViewHolder(View itemView) {
@ -57,7 +58,6 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
userAccountAvatar = itemView.findViewById(R.id.userAccountAvatar); userAccountAvatar = itemView.findViewById(R.id.userAccountAvatar);
itemView.setOnClickListener(item -> { itemView.setOnClickListener(item -> {
customDialogUserAccountsList(userAccountsList); customDialogUserAccountsList(userAccountsList);
drawer.closeDrawers(); drawer.closeDrawers();
}); });
@ -84,8 +84,15 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
.withPath("/") .withPath("/")
.toString(); .toString();
PicassoService int imageSize = AppUtil.getPixelsFromDensity(context, 35);
.getInstance(mCtx).get().load(url + "img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAccountAvatar);
PicassoService.getInstance(context).get()
.load(url + "img/favicon.png")
.placeholder(R.drawable.loader_animated)
.transform(new RoundedTransformation(8, 0))
.resize(imageSize, imageSize)
.centerCrop()
.into(holder.userAccountAvatar);
} }
@Override @Override
@ -96,8 +103,8 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
private void customDialogUserAccountsList(List<UserAccount> allAccountsList) { private void customDialogUserAccountsList(List<UserAccount> allAccountsList) {
TinyDB tinyDB = TinyDB.getInstance(mCtx); TinyDB tinyDB = TinyDB.getInstance(context);
Dialog dialog = new Dialog(mCtx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert); Dialog dialog = new Dialog(context, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
dialog.setContentView(R.layout.custom_user_accounts_dialog); dialog.setContentView(R.layout.custom_user_accounts_dialog);
ListView listView = dialog.findViewById(R.id.accountsList); ListView listView = dialog.findViewById(R.id.accountsList);
@ -109,19 +116,19 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
manageAccounts.setOnClickListener(item -> { manageAccounts.setOnClickListener(item -> {
toolbarTitle.setText(mCtx.getResources().getString(R.string.pageTitleUserAccounts)); toolbarTitle.setText(context.getResources().getString(R.string.pageTitleUserAccounts));
AppCompatActivity activity = (AppCompatActivity) mCtx; AppCompatActivity activity = (AppCompatActivity) context;
activity.getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new UserAccountsFragment()).commit(); activity.getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new UserAccountsFragment()).commit();
dialog.dismiss(); dialog.dismiss();
}); });
UserAccountsListDialogAdapter arrayAdapter = new UserAccountsListDialogAdapter(mCtx, R.layout.custom_user_accounts_list, allAccountsList); UserAccountsListDialogAdapter arrayAdapter = new UserAccountsListDialogAdapter(context, R.layout.custom_user_accounts_list, allAccountsList);
listView.setAdapter(arrayAdapter); listView.setAdapter(arrayAdapter);
listView.setOnItemClickListener((adapterView, view, which, l) -> { listView.setOnItemClickListener((adapterView, view, which, l) -> {
String accountNameSwitch = allAccountsList.get(which).getAccountName(); String accountNameSwitch = allAccountsList.get(which).getAccountName();
UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx); UserAccountsApi userAccountsApi = new UserAccountsApi(context);
UserAccount userAccount = userAccountsApi.getAccountData(accountNameSwitch); UserAccount userAccount = userAccountsApi.getAccountData(accountNameSwitch);
if(tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) { if(tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) {
@ -136,8 +143,8 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
tinyDB.putString("instanceUrl", userAccount.getInstanceUrl()); tinyDB.putString("instanceUrl", userAccount.getInstanceUrl());
tinyDB.putInt("currentActiveAccountId", userAccount.getAccountId()); tinyDB.putInt("currentActiveAccountId", userAccount.getAccountId());
Toasty.success(mCtx, mCtx.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url)); Toasty.success(context, context.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
((Activity) mCtx).recreate(); ((Activity) context).recreate();
dialog.dismiss(); dialog.dismiss();
} }
}); });

View File

@ -1,7 +1,6 @@
package org.mian.gitnex.adapters; package org.mian.gitnex.adapters;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.text.Html; import android.text.Html;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -20,6 +19,7 @@ import org.mian.gitnex.actions.CollaboratorActions;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.helpers.AlertDialogs; import org.mian.gitnex.helpers.AlertDialogs;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.helpers.Authorization;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
@ -34,84 +34,69 @@ import retrofit2.Response;
public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.UserSearchViewHolder> { public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.UserSearchViewHolder> {
private List<UserInfo> usersSearchList; private final List<UserInfo> usersSearchList;
private Context mCtx; private final Context context;
public UserSearchAdapter(List<UserInfo> dataList, Context mCtx) { public UserSearchAdapter(List<UserInfo> dataList, Context ctx) {
this.mCtx = mCtx; this.context = ctx;
this.usersSearchList = dataList; this.usersSearchList = dataList;
} }
static class UserSearchViewHolder extends RecyclerView.ViewHolder { static class UserSearchViewHolder extends RecyclerView.ViewHolder {
private ImageView userAvatar; private UserInfo userInfo;
private TextView userFullName;
private TextView userName;
private TextView userNameMain;
private ImageView addCollaboratorButtonAdd;
private ImageView addCollaboratorButtonRemove;
private String[] permissionList = {"Read", "Write", "Admin"}; private final ImageView userAvatar;
private final TextView userFullName;
private final TextView userName;
private final ImageView addCollaboratorButtonAdd;
private final ImageView addCollaboratorButtonRemove;
private final String[] permissionList = {"Read", "Write", "Admin"};
final private int permissionSelectedChoice = 0; final private int permissionSelectedChoice = 0;
private UserSearchViewHolder(View itemView) { private UserSearchViewHolder(View itemView) {
super(itemView); super(itemView);
userAvatar = itemView.findViewById(R.id.userAvatar); userAvatar = itemView.findViewById(R.id.userAvatar);
userFullName = itemView.findViewById(R.id.userFullName); userFullName = itemView.findViewById(R.id.userFullName);
userName = itemView.findViewById(R.id.userName); userName = itemView.findViewById(R.id.userName);
userNameMain = itemView.findViewById(R.id.userNameMain);
addCollaboratorButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd); addCollaboratorButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
addCollaboratorButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove); addCollaboratorButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
addCollaboratorButtonAdd.setOnClickListener(new View.OnClickListener() { addCollaboratorButtonAdd.setOnClickListener(v -> {
@Override
public void onClick(View v) {
final Context context = v.getContext(); final Context context = v.getContext();
AlertDialog.Builder pBuilder = new AlertDialog.Builder(context); AlertDialog.Builder pBuilder = new AlertDialog.Builder(context);
pBuilder.setTitle(R.string.newTeamPermission); pBuilder.setTitle(R.string.newTeamPermission);
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, new DialogInterface.OnClickListener() { pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
}) })
.setCancelable(false) .setCancelable(false)
.setNegativeButton(R.string.cancelButton, null) .setNegativeButton(R.string.cancelButton, null)
.setPositiveButton(R.string.addButton, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.addButton, (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
ListView lw = ((AlertDialog)dialog).getListView(); ListView lw = ((AlertDialog)dialog).getListView();
Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition()); Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition());
CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userNameMain.getText().toString()); CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userInfo.getUsername());
}
}); });
AlertDialog pDialog = pBuilder.create(); AlertDialog pDialog = pBuilder.create();
pDialog.show(); pDialog.show();
}
}); });
addCollaboratorButtonRemove.setOnClickListener(new View.OnClickListener() { addCollaboratorButtonRemove.setOnClickListener(v -> {
@Override
public void onClick(View v) {
Context context = v.getContext(); Context context = v.getContext();
AlertDialogs.collaboratorRemoveDialog(context, userNameMain.getText().toString(), AlertDialogs.collaboratorRemoveDialog(context, userInfo.getUsername(),
context.getResources().getString(R.string.removeCollaboratorTitle), context.getResources().getString(R.string.removeCollaboratorTitle),
context.getResources().getString(R.string.removeCollaboratorMessage), context.getResources().getString(R.string.removeCollaboratorMessage),
context.getResources().getString(R.string.removeButton), context.getResources().getString(R.string.removeButton),
context.getResources().getString(R.string.cancelButton), "fa"); context.getResources().getString(R.string.cancelButton), "fa");
}
}); });
} }
@ -128,9 +113,9 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
@Override @Override
public void onBindViewHolder(@NonNull final UserSearchAdapter.UserSearchViewHolder holder, int position) { public void onBindViewHolder(@NonNull final UserSearchAdapter.UserSearchViewHolder holder, int position) {
final UserInfo currentItem = usersSearchList.get(position); UserInfo currentItem = usersSearchList.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
holder.userNameMain.setText(currentItem.getUsername()); holder.userInfo = currentItem;
if (!currentItem.getFullname().equals("")) { if (!currentItem.getFullname().equals("")) {
@ -138,18 +123,18 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
} }
else { else {
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername())); holder.userFullName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
} }
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername())); holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
if (!currentItem.getAvatar().equals("")) { if (!currentItem.getAvatar().equals("")) {
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAvatar); PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
} }
if(getItemCount() > 0) { if(getItemCount() > 0) {
TinyDB tinyDb = TinyDB.getInstance(mCtx); TinyDB tinyDb = TinyDB.getInstance(context);
final String loginUid = tinyDb.getString("loginUid"); final String loginUid = tinyDb.getString("loginUid");
String repoFullName = tinyDb.getString("repoFullName"); String repoFullName = tinyDb.getString("repoFullName");
String[] parts = repoFullName.split("/"); String[] parts = repoFullName.split("/");
@ -157,8 +142,8 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
final String repoName = parts[1]; final String repoName = parts[1];
Call<Collaborators> call = RetrofitClient Call<Collaborators> call = RetrofitClient
.getApiInterface(mCtx) .getApiInterface(context)
.checkRepoCollaborator(Authorization.get(mCtx), repoOwner, repoName, currentItem.getUsername()); .checkRepoCollaborator(Authorization.get(context), repoOwner, repoName, currentItem.getUsername());
call.enqueue(new Callback<Collaborators>() { call.enqueue(new Callback<Collaborators>() {

View File

@ -14,6 +14,7 @@ import org.mian.gitnex.R;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.helpers.AlertDialogs; import org.mian.gitnex.helpers.AlertDialogs;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.helpers.Authorization;
import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
@ -29,25 +30,25 @@ import retrofit2.Response;
public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSearchForTeamMemberAdapter.UserSearchViewHolder> { public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSearchForTeamMemberAdapter.UserSearchViewHolder> {
private List<UserInfo> usersSearchList; private final List<UserInfo> usersSearchList;
private Context mCtx; private final Context context;
private int teamId; private static int teamId;
public UserSearchForTeamMemberAdapter(List<UserInfo> dataList, Context mCtx, int teamId) { public UserSearchForTeamMemberAdapter(List<UserInfo> dataList, Context ctx, int teamId) {
this.mCtx = mCtx; this.context = ctx;
this.usersSearchList = dataList; this.usersSearchList = dataList;
this.teamId = teamId; UserSearchForTeamMemberAdapter.teamId = teamId;
} }
static class UserSearchViewHolder extends RecyclerView.ViewHolder { static class UserSearchViewHolder extends RecyclerView.ViewHolder {
private ImageView userAvatar; private UserInfo userInfo;
private TextView userFullName;
private TextView userName; private final ImageView userAvatar;
private TextView userNameMain; private final TextView userFullName;
private ImageView addMemberButtonAdd; private final TextView userName;
private ImageView addMemberButtonRemove; private final ImageView addMemberButtonAdd;
private TextView teamId_; private final ImageView addMemberButtonRemove;
private UserSearchViewHolder(View itemView) { private UserSearchViewHolder(View itemView) {
@ -55,35 +56,30 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
userAvatar = itemView.findViewById(R.id.userAvatar); userAvatar = itemView.findViewById(R.id.userAvatar);
userFullName = itemView.findViewById(R.id.userFullName); userFullName = itemView.findViewById(R.id.userFullName);
userName = itemView.findViewById(R.id.userName); userName = itemView.findViewById(R.id.userName);
userNameMain = itemView.findViewById(R.id.userNameMain);
addMemberButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd); addMemberButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
addMemberButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove); addMemberButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
teamId_ = itemView.findViewById(R.id.teamId);
addMemberButtonAdd.setOnClickListener(v -> { addMemberButtonAdd.setOnClickListener(v -> {
Context context = v.getContext(); Context context = v.getContext();
AlertDialogs.addMemberDialog(context, userNameMain.getText().toString(), AlertDialogs.addMemberDialog(context, userInfo.getLogin(),
context.getResources().getString(R.string.addTeamMemberTitle), context.getResources().getString(R.string.addTeamMemberTitle),
context.getResources().getString(R.string.addTeamMemberMessage), context.getResources().getString(R.string.addTeamMemberMessage),
context.getResources().getString(R.string.addButton), context.getResources().getString(R.string.addButton),
context.getResources().getString(R.string.cancelButton), Integer.parseInt(teamId_.getText().toString())); context.getResources().getString(R.string.cancelButton), Integer.parseInt(String.valueOf(teamId)));
}); });
addMemberButtonRemove.setOnClickListener(v -> { addMemberButtonRemove.setOnClickListener(v -> {
Context context = v.getContext(); Context context = v.getContext();
AlertDialogs.removeMemberDialog(context, userNameMain.getText().toString(), AlertDialogs.removeMemberDialog(context, userInfo.getLogin(),
context.getResources().getString(R.string.removeTeamMemberTitle), context.getResources().getString(R.string.removeTeamMemberTitle),
context.getResources().getString(R.string.removeTeamMemberMessage), context.getResources().getString(R.string.removeTeamMemberMessage),
context.getResources().getString(R.string.removeButton), context.getResources().getString(R.string.removeButton),
context.getResources().getString(R.string.cancelButton), Integer.parseInt(teamId_.getText().toString())); context.getResources().getString(R.string.cancelButton), Integer.parseInt(String.valueOf(teamId)));
}); });
} }
} }
@ -98,39 +94,36 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
@Override @Override
public void onBindViewHolder(@NonNull final UserSearchForTeamMemberAdapter.UserSearchViewHolder holder, int position) { public void onBindViewHolder(@NonNull final UserSearchForTeamMemberAdapter.UserSearchViewHolder holder, int position) {
final UserInfo currentItem = usersSearchList.get(position); UserInfo currentItem = usersSearchList.get(position);
holder.userInfo = currentItem;
holder.userNameMain.setText(currentItem.getLogin()); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
holder.teamId_.setText(String.valueOf(teamId));
if (!currentItem.getFullname().equals("")) { if (!currentItem.getFullname().equals("")) {
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname())); holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
} }
else { else {
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getLogin())); holder.userFullName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
} }
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getLogin())); holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
if (!currentItem.getAvatar().equals("")) { if (!currentItem.getAvatar().equals("")) {
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAvatar); PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
} }
if(getItemCount() > 0) { if(getItemCount() > 0) {
TinyDB tinyDb = TinyDB.getInstance(mCtx); TinyDB tinyDb = TinyDB.getInstance(context);
final String loginUid = tinyDb.getString("loginUid"); final String loginUid = tinyDb.getString("loginUid");
String repoFullName = tinyDb.getString("repoFullName"); String repoFullName = tinyDb.getString("repoFullName");
String[] parts = repoFullName.split("/"); String[] parts = repoFullName.split("/");
final String repoOwner = parts[0]; final String repoOwner = parts[0];
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
Call<UserInfo> call = RetrofitClient Call<UserInfo> call = RetrofitClient
.getApiInterface(mCtx) .getApiInterface(context)
.checkTeamMember(Authorization.get(mCtx), teamId, currentItem.getLogin()); .checkTeamMember(Authorization.get(context), teamId, currentItem.getLogin());
call.enqueue(new Callback<UserInfo>() { call.enqueue(new Callback<UserInfo>() {
@ -167,8 +160,7 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
@Override @Override
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) { public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
Toasty.error(mCtx, mCtx.getResources().getString(R.string.genericServerResponseError)); Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
} }
}); });

View File

@ -19,6 +19,7 @@ import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import com.google.android.material.bottomsheet.BottomSheetBehavior; import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.vdurmont.emoji.EmojiParser;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.actions.ActionResult; import org.mian.gitnex.actions.ActionResult;
import org.mian.gitnex.actions.IssueActions; import org.mian.gitnex.actions.IssueActions;
@ -61,7 +62,6 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
repositoryId = (int) tinyDB.getLong("repositoryId", 0); repositoryId = (int) tinyDB.getLong("repositoryId", 0);
currentActiveAccountId = tinyDB.getInt("currentActiveAccountId"); currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
issueNumber = Integer.parseInt(tinyDB.getString("issueNumber")); issueNumber = Integer.parseInt(tinyDB.getString("issueNumber"));
} }
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@ -87,7 +87,6 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
send.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_save)); send.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_save));
mode = Mode.EDIT; mode = Mode.EDIT;
} }
if(arguments.getString("draftId") != null) { if(arguments.getString("draftId") != null) {
@ -97,7 +96,7 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
if(!tinyDB.getString("issueTitle").isEmpty()) { if(!tinyDB.getString("issueTitle").isEmpty()) {
toolbarTitle.setText(tinyDB.getString("issueTitle")); toolbarTitle.setText(EmojiParser.parseToUnicode(tinyDB.getString("issueTitle")));
} }
else if(arguments.getString("draftTitle") != null) { else if(arguments.getString("draftTitle") != null) {
@ -134,7 +133,6 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
} }
return false; return false;
}); });
comment.addTextChangedListener(new TextWatcher() { comment.addTextChangedListener(new TextWatcher() {

View File

@ -168,7 +168,6 @@ public class IssuesFragment extends Fragment {
loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState")); loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"));
tinyDb.putBoolean("resumeIssues", false); tinyDb.putBoolean("resumeIssues", false);
} }
} }
@ -191,14 +190,12 @@ public class IssuesFragment extends Fragment {
issuesList.addAll(response.body()); issuesList.addAll(response.body());
adapter.notifyDataChanged(); adapter.notifyDataChanged();
noDataIssues.setVisibility(View.GONE); noDataIssues.setVisibility(View.GONE);
} }
else { else {
issuesList.clear(); issuesList.clear();
adapter.notifyDataChanged(); adapter.notifyDataChanged();
noDataIssues.setVisibility(View.VISIBLE); noDataIssues.setVisibility(View.VISIBLE);
} }
mProgressBar.setVisibility(View.GONE); mProgressBar.setVisibility(View.GONE);
@ -208,7 +205,6 @@ public class IssuesFragment extends Fragment {
noDataIssues.setVisibility(View.VISIBLE); noDataIssues.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.GONE); mProgressBar.setVisibility(View.GONE);
} }
else { else {
Log.e(TAG, String.valueOf(response.code())); Log.e(TAG, String.valueOf(response.code()));
@ -311,7 +307,6 @@ public class IssuesFragment extends Fragment {
filter(newText); filter(newText);
return false; return false;
} }
}); });

View File

@ -74,11 +74,10 @@ public class ProfileEmailsFragment extends Fragment {
noDataEmails = fragmentProfileEmailsBinding.noDataEmails; noDataEmails = fragmentProfileEmailsBinding.noDataEmails;
mRecyclerView = fragmentProfileEmailsBinding.recyclerView; mRecyclerView = fragmentProfileEmailsBinding.recyclerView;
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
mRecyclerView.setHasFixedSize(true); mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
DividerItemDecoration.VERTICAL);
mRecyclerView.addItemDecoration(dividerItemDecoration); mRecyclerView.addItemDecoration(dividerItemDecoration);
mProgressBar = fragmentProfileEmailsBinding.progressBar; mProgressBar = fragmentProfileEmailsBinding.progressBar;

View File

@ -10,20 +10,16 @@ import android.view.ViewGroup;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import org.gitnex.tea4j.models.UserInfo;
import org.mian.gitnex.adapters.ProfileFollowersAdapter; import org.mian.gitnex.adapters.ProfileFollowersAdapter;
import org.mian.gitnex.databinding.FragmentProfileFollowersBinding; import org.mian.gitnex.databinding.FragmentProfileFollowersBinding;
import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.helpers.Authorization;
import org.mian.gitnex.viewmodels.ProfileFollowersViewModel; import org.mian.gitnex.viewmodels.ProfileFollowersViewModel;
import java.util.List;
/** /**
* Author M M Arif * Author M M Arif
@ -75,11 +71,10 @@ public class ProfileFollowersFragment extends Fragment {
noDataFollowers = fragmentProfileFollowersBinding.noDataFollowers; noDataFollowers = fragmentProfileFollowersBinding.noDataFollowers;
mRecyclerView = fragmentProfileFollowersBinding.recyclerView; mRecyclerView = fragmentProfileFollowersBinding.recyclerView;
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
mRecyclerView.setHasFixedSize(true); mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
DividerItemDecoration.VERTICAL);
mRecyclerView.addItemDecoration(dividerItemDecoration); mRecyclerView.addItemDecoration(dividerItemDecoration);
mProgressBar = fragmentProfileFollowersBinding.progressBar; mProgressBar = fragmentProfileFollowersBinding.progressBar;
@ -100,10 +95,10 @@ public class ProfileFollowersFragment extends Fragment {
ProfileFollowersViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowersViewModel.class); ProfileFollowersViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowersViewModel.class);
pfModel.getFollowersList(instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() { pfModel.getFollowersList(instanceToken, getContext()).observe(getViewLifecycleOwner(), pfListMain -> {
@Override
public void onChanged(@Nullable List<UserInfo> pfListMain) {
adapter = new ProfileFollowersAdapter(getContext(), pfListMain); adapter = new ProfileFollowersAdapter(getContext(), pfListMain);
if(adapter.getItemCount() > 0) { if(adapter.getItemCount() > 0) {
mRecyclerView.setAdapter(adapter); mRecyclerView.setAdapter(adapter);
noDataFollowers.setVisibility(View.GONE); noDataFollowers.setVisibility(View.GONE);
@ -113,8 +108,8 @@ public class ProfileFollowersFragment extends Fragment {
mRecyclerView.setAdapter(adapter); mRecyclerView.setAdapter(adapter);
noDataFollowers.setVisibility(View.VISIBLE); noDataFollowers.setVisibility(View.VISIBLE);
} }
mProgressBar.setVisibility(View.GONE); mProgressBar.setVisibility(View.GONE);
}
}); });
} }

View File

@ -10,21 +10,17 @@ import android.view.ViewGroup;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import org.gitnex.tea4j.models.UserInfo;
import org.mian.gitnex.adapters.ProfileFollowingAdapter; import org.mian.gitnex.adapters.ProfileFollowingAdapter;
import org.mian.gitnex.databinding.FragmentProfileFollowingBinding; import org.mian.gitnex.databinding.FragmentProfileFollowingBinding;
import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.helpers.Authorization;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.viewmodels.ProfileFollowingViewModel; import org.mian.gitnex.viewmodels.ProfileFollowingViewModel;
import java.util.List;
/** /**
* Author M M Arif * Author M M Arif
@ -78,11 +74,10 @@ public class ProfileFollowingFragment extends Fragment {
noDataFollowing = fragmentProfileFollowingBinding.noDataFollowing; noDataFollowing = fragmentProfileFollowingBinding.noDataFollowing;
mRecyclerView = fragmentProfileFollowingBinding.recyclerView; mRecyclerView = fragmentProfileFollowingBinding.recyclerView;
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
mRecyclerView.setHasFixedSize(true); mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
DividerItemDecoration.VERTICAL);
mRecyclerView.addItemDecoration(dividerItemDecoration); mRecyclerView.addItemDecoration(dividerItemDecoration);
mProgressBar = fragmentProfileFollowingBinding.progressBar; mProgressBar = fragmentProfileFollowingBinding.progressBar;
@ -103,10 +98,10 @@ public class ProfileFollowingFragment extends Fragment {
ProfileFollowingViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowingViewModel.class); ProfileFollowingViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowingViewModel.class);
pfModel.getFollowingList(instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() { pfModel.getFollowingList(instanceToken, getContext()).observe(getViewLifecycleOwner(), pfListMain -> {
@Override
public void onChanged(@Nullable List<UserInfo> pfListMain) {
adapter = new ProfileFollowingAdapter(getContext(), pfListMain); adapter = new ProfileFollowingAdapter(getContext(), pfListMain);
if(adapter.getItemCount() > 0) { if(adapter.getItemCount() > 0) {
mRecyclerView.setAdapter(adapter); mRecyclerView.setAdapter(adapter);
noDataFollowing.setVisibility(View.GONE); noDataFollowing.setVisibility(View.GONE);
@ -116,8 +111,8 @@ public class ProfileFollowingFragment extends Fragment {
mRecyclerView.setAdapter(adapter); mRecyclerView.setAdapter(adapter);
noDataFollowing.setVisibility(View.VISIBLE); noDataFollowing.setVisibility(View.VISIBLE);
} }
mProgressBar.setVisibility(View.GONE); mProgressBar.setVisibility(View.GONE);
}
}); });
} }

View File

@ -83,9 +83,11 @@ public class ProfileFragment extends Fragment {
userFullName.setText(Html.fromHtml(tinyDb.getString("userFullname"))); userFullName.setText(Html.fromHtml(tinyDb.getString("userFullname")));
userLogin.setText(getString(R.string.usernameWithAt, tinyDb.getString("userLogin"))); userLogin.setText(getString(R.string.usernameWithAt, tinyDb.getString("userLogin")));
int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 3);
PicassoService.getInstance(ctx).get() PicassoService.getInstance(ctx).get()
.load(tinyDb.getString("userAvatar")) .load(tinyDb.getString("userAvatar"))
.transform(new RoundedTransformation(8, 0)) .transform(new RoundedTransformation(avatarRadius, 0))
.placeholder(R.drawable.loader_animated) .placeholder(R.drawable.loader_animated)
.resize(120, 120) .resize(120, 120)
.centerCrop().into(userAvatar); .centerCrop().into(userAvatar);

View File

@ -40,8 +40,8 @@ public class RepoInfoFragment extends Fragment {
private Context ctx; private Context ctx;
private LinearLayout pageContent; private LinearLayout pageContent;
private static String repoNameF = "param2"; private static final String repoNameF = "param2";
private static String repoOwnerF = "param1"; private static final String repoOwnerF = "param1";
private FragmentRepoInfoBinding binding; private FragmentRepoInfoBinding binding;
@ -284,6 +284,13 @@ public class RepoInfoFragment extends Fragment {
tinyDb.putBoolean("hasPullRequests", false); tinyDb.putBoolean("hasPullRequests", false);
} }
if(repoInfo.isArchived()) {
binding.repoIsArchived.setVisibility(View.VISIBLE);
}
else {
binding.repoIsArchived.setVisibility(View.GONE);
}
tinyDb.putString("repoHtmlUrl", repoInfo.getHtml_url()); tinyDb.putString("repoHtmlUrl", repoInfo.getHtml_url());
binding.progressBar.setVisibility(View.GONE); binding.progressBar.setVisibility(View.GONE);

View File

@ -45,7 +45,7 @@ public class Markdown {
private static final int MAX_POOL_SIZE = 45; private static final int MAX_POOL_SIZE = 45;
private static final int MAX_THREAD_KEEP_ALIVE_SECONDS = 120; private static final int MAX_THREAD_KEEP_ALIVE_SECONDS = 120;
private static final int MAX_CLAIM_TIMEOUT_SECONDS = 5; private static final int MAX_CLAIM_TIMEOUT_SECONDS = 120;
private static final Timeout timeout = new Timeout(MAX_CLAIM_TIMEOUT_SECONDS, TimeUnit.SECONDS); private static final Timeout timeout = new Timeout(MAX_CLAIM_TIMEOUT_SECONDS, TimeUnit.SECONDS);

View File

@ -0,0 +1,14 @@
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="0dp" />
<solid
android:color="?attr/iconsColor"/>
<padding
android:bottom="2dp"
android:left="5dp"
android:right="5dp"
android:top="2dp" />
</shape>

View File

@ -96,9 +96,9 @@
<ImageView <ImageView
android:id="@+id/assigneeAvatar" android:id="@+id/assigneeAvatar"
android:layout_width="48dp" android:layout_width="@dimen/list_avatar_size"
android:layout_height="48dp" android:layout_height="@dimen/list_avatar_size"
android:layout_marginEnd="15dp" android:layout_marginEnd="10dp"
android:contentDescription="@string/generalImgContentText" /> android:contentDescription="@string/generalImgContentText" />
<TextView <TextView
@ -109,7 +109,7 @@
android:gravity="start" android:gravity="start"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textIsSelectable="true" android:textIsSelectable="true"
android:textSize="18sp" /> android:textSize="16sp" />
<RelativeLayout <RelativeLayout
android:id="@+id/msdueFrame" android:id="@+id/msdueFrame"
@ -174,7 +174,7 @@
android:autoLink="web" android:autoLink="web"
android:textColorLink="@color/lightBlue" android:textColorLink="@color/lightBlue"
android:textIsSelectable="true" android:textIsSelectable="true"
android:textSize="16sp" /> android:textSize="14sp" />
<HorizontalScrollView <HorizontalScrollView
android:layout_below="@+id/issueDescription" android:layout_below="@+id/issueDescription"
@ -212,7 +212,7 @@
android:text="@string/createdText" android:text="@string/createdText"
android:visibility="gone" android:visibility="gone"
android:textColor="?attr/hintColor" android:textColor="?attr/hintColor"
android:textSize="14sp" /> android:textSize="12sp" />
<TextView <TextView
android:id="@+id/issueModified" android:id="@+id/issueModified"
@ -220,7 +220,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="?attr/hintColor" android:textColor="?attr/hintColor"
android:layout_toEndOf="@+id/issueCreatedTime" android:layout_toEndOf="@+id/issueCreatedTime"
android:textSize="14sp" android:textSize="12sp"
android:visibility="gone" android:visibility="gone"
android:text="@string/modifiedText" /> android:text="@string/modifiedText" />

View File

@ -1,103 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="6dp"
android:paddingBottom="12dp"
android:background="?attr/primaryBackgroundColor">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<TextView
android:id="@+id/bottomSheetHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/repoName"
android:paddingStart="18dp"
android:paddingEnd="18dp"
android:paddingBottom="18dp"
android:textColor="?attr/primaryTextColor"
android:textSize="18sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/divider"
android:layout_marginBottom="12dp"
android:background="?attr/dividerColor" />
<TextView
android:id="@+id/repoStargazers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/repoStargazersInMenu"
android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="12dp"
app:drawableStartCompat="@drawable/ic_star_unfilled" />
<TextView
android:id="@+id/repoWatchers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/repoWatchersInMenu"
android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="12dp"
app:drawableStartCompat="@drawable/ic_unwatch" />
<TextView
android:id="@+id/repoForksList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/infoTabRepoForksCount"
android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="12dp"
app:drawableStartCompat="@drawable/ic_fork" />
<TextView
android:id="@+id/repoCopyUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/genericCopyUrl"
android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="12dp"
app:drawableStartCompat="@drawable/ic_copy" />
<TextView
android:id="@+id/repoOpenInBrowser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/openWebRepo"
android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="12dp"
app:drawableStartCompat="@drawable/ic_browser" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:background="?attr/primaryBackgroundColor" >
<TextView
android:id="@+id/creditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:textColor="?attr/primaryTextColor"
android:textColorLink="@color/lightBlue"
android:textSize="16sp" />
</RelativeLayout>

View File

@ -9,13 +9,13 @@
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp"
android:orientation="vertical"> android:orientation="vertical">
<ListView <ListView
android:id="@+id/accountsList" android:id="@+id/accountsList"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
android:padding="16dp" />
</LinearLayout> </LinearLayout>

View File

@ -1,48 +1,51 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layoutFrame" android:id="@+id/layoutFrame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center_vertical"
android:padding="8dp" android:orientation="horizontal"
android:orientation="vertical"> android:padding="8dp">
<ImageView <ImageView
android:id="@+id/profileImage" android:id="@+id/profileImage"
android:visibility="visible" android:layout_width="@dimen/list_avatar_size"
android:layout_width="36dp" android:layout_height="@dimen/list_avatar_size"
android:layout_height="36dp" android:layout_marginEnd="10dp"
android:layout_marginEnd="15dp" android:contentDescription="@string/generalImgContentText"
android:contentDescription="@string/generalImgContentText" /> android:visibility="visible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/frameAccountsInfo" android:id="@+id/frameAccountsInfo"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:gravity="center_vertical"
android:layout_toEndOf="@+id/profileImage" android:orientation="horizontal">
android:layout_marginBottom="2dp">
<TextView <TextView
android:id="@+id/userName" android:id="@+id/userName"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight=".95" android:layout_weight="1"
android:layout_gravity="start"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold" /> android:textStyle="bold" />
<ImageView <ImageView
android:id="@+id/activeAccount" android:id="@+id/activeAccount"
android:layout_weight=".05" android:layout_width="20dp"
android:layout_width="10dp" android:layout_height="wrap_content"
android:layout_height="20dp" android:layout_weight="0"
android:layout_gravity="end" android:contentDescription="@string/generalImgContentText"
android:src="@drawable/ic_check" android:src="@drawable/ic_check"
android:visibility="gone" android:visibility="gone"
android:contentDescription="@string/generalImgContentText" /> tools:visibility="visible" />
</LinearLayout> </LinearLayout>
@ -50,11 +53,10 @@
android:id="@+id/accountUrl" android:id="@+id/accountUrl"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_toEndOf="@+id/profileImage"
android:layout_below="@+id/frameAccountsInfo"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="16sp" /> android:textSize="14sp" />
</RelativeLayout> </LinearLayout>
</LinearLayout>

View File

@ -16,7 +16,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/primaryBackgroundColor" android:background="?attr/primaryBackgroundColor"
android:padding="4dp"
android:scrollbars="vertical" /> android:scrollbars="vertical" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
@ -25,7 +24,7 @@
android:id="@+id/noData" android:id="@+id/noData"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="15dp" android:layout_margin="16dp"
android:text="@string/draftsListEmpty" android:text="@string/draftsListEmpty"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:gravity="center" android:gravity="center"

View File

@ -57,6 +57,18 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<TextView
android:id="@+id/repoIsArchived"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_gravity="center"
android:text="@string/archivedRepositoryMessage"
android:background="@drawable/shape_archived"
android:padding="5dp"
android:layout_marginBottom="8dp"
android:textColor="@color/colorWhite" />
<TextView <TextView
android:id="@+id/repoMetaName" android:id="@+id/repoMetaName"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="15dp" android:padding="16dp"
android:background="?attr/primaryBackgroundColor" > android:background="?attr/primaryBackgroundColor" >
<LinearLayout <LinearLayout

View File

@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="15dp" android:padding="16dp"
android:background="?attr/primaryBackgroundColor" > android:background="?attr/primaryBackgroundColor" >
<LinearLayout <LinearLayout
@ -15,8 +15,8 @@
<ImageView <ImageView
android:id="@+id/userAvatar" android:id="@+id/userAvatar"
android:layout_width="wrap_content" android:layout_width="@dimen/list_avatar_size"
android:layout_height="wrap_content" android:layout_height="@dimen/list_avatar_size"
android:layout_gravity="center" android:layout_gravity="center"
android:contentDescription="@string/generalImgContentText" android:contentDescription="@string/generalImgContentText"
android:src="@drawable/ic_android" /> android:src="@drawable/ic_android" />
@ -43,28 +43,28 @@
android:id="@+id/userFullName" android:id="@+id/userFullName"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="5dp" android:layout_marginBottom="4dp"
android:text="@string/userName" android:text="@string/userName"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="16sp" /> android:textSize="14sp"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/userName" android:id="@+id/userName"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="5dp" android:layout_marginBottom="4dp"
android:text="@string/userName" android:text="@string/userName"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="16sp" /> android:textSize="12sp" />
<TextView <TextView
android:id="@+id/userEmail" android:id="@+id/userEmail"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/userEmail" android:text="@string/userEmail"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="16sp" /> android:textSize="12sp" />
</LinearLayout> </LinearLayout>

View File

@ -8,17 +8,11 @@
android:paddingEnd="20dp" android:paddingEnd="20dp"
android:background="?attr/primaryBackgroundColor" > android:background="?attr/primaryBackgroundColor" >
<TextView
android:id="@+id/teamId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<ImageView <ImageView
android:id="@+id/userAvatar" android:id="@+id/userAvatar"
android:layout_width="40dp" android:layout_width="@dimen/list_avatar_size"
android:layout_height="40dp" android:layout_height="@dimen/list_avatar_size"
android:layout_marginEnd="15dp" android:layout_marginEnd="10dp"
android:contentDescription="@string/generalImgContentText" android:contentDescription="@string/generalImgContentText"
android:src="@drawable/ic_android" /> android:src="@drawable/ic_android" />
@ -36,7 +30,8 @@
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:text="@string/userName" android:text="@string/userName"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="16sp" /> android:textSize="14sp"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/userName" android:id="@+id/userName"
@ -45,16 +40,10 @@
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:text="@string/addCollaboratorViewUserDesc" android:text="@string/addCollaboratorViewUserDesc"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="14sp" /> android:textSize="12sp" />
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/userNameMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<LinearLayout <LinearLayout
android:id="@+id/frameAddCollaborator" android:id="@+id/frameAddCollaborator"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -69,8 +58,8 @@
<ImageView <ImageView
android:id="@+id/addCollaboratorButtonAdd" android:id="@+id/addCollaboratorButtonAdd"
android:layout_width="40dp" android:layout_width="28dp"
android:layout_height="40dp" android:layout_height="28dp"
android:layout_gravity="end" android:layout_gravity="end"
android:contentDescription="@string/addNewContent" android:contentDescription="@string/addNewContent"
android:background="@drawable/shape_circle" android:background="@drawable/shape_circle"
@ -80,8 +69,8 @@
<ImageView <ImageView
android:id="@+id/addCollaboratorButtonRemove" android:id="@+id/addCollaboratorButtonRemove"
android:layout_width="40dp" android:layout_width="28dp"
android:layout_height="40dp" android:layout_height="28dp"
android:layout_gravity="end" android:layout_gravity="end"
android:contentDescription="@string/removeContent" android:contentDescription="@string/removeContent"
android:background="@drawable/shape_circle_red" android:background="@drawable/shape_circle_red"

View File

@ -4,6 +4,7 @@
android:id="@+id/commitList" android:id="@+id/commitList"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp"
android:background="?attr/primaryBackgroundColor"> android:background="?attr/primaryBackgroundColor">
<LinearLayout <LinearLayout
@ -11,8 +12,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:orientation="vertical" android:orientation="vertical">
android:layout_margin="15dp">
<TextView <TextView
android:id="@+id/commitTitleVw" android:id="@+id/commitTitleVw"

View File

@ -5,11 +5,10 @@
android:id="@+id/layoutDraftsFrame" android:id="@+id/layoutDraftsFrame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:fitsSystemWindows="true"
android:orientation="vertical" android:orientation="vertical"
android:layout_margin="10dp" android:padding="16dp"
android:background="?attr/primaryBackgroundColor" android:background="?android:attr/selectableItemBackground"
android:focusable="true"
tools:context=".activities.MainActivity"> tools:context=".activities.MainActivity">
<LinearLayout <LinearLayout

View File

@ -4,15 +4,16 @@
android:id="@+id/fileFrame" android:id="@+id/fileFrame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="12dp" android:padding="16dp"
android:background="?attr/primaryBackgroundColor" android:background="?android:attr/selectableItemBackground"
android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/fileTypeIs" android:id="@+id/fileTypeIs"
android:layout_width="28dp" android:layout_width="wrap_content"
android:layout_height="28dp" android:layout_height="wrap_content"
android:layout_marginEnd="15dp" android:layout_marginEnd="15dp"
android:contentDescription="@string/generalImgContentText" android:contentDescription="@string/generalImgContentText"
android:src="@drawable/ic_file" /> android:src="@drawable/ic_file" />
@ -42,7 +43,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/sizeCopy" android:text="@string/sizeCopy"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/hintColor"
android:textSize="12sp" android:textSize="12sp"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible" /> tools:visibility="visible" />

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -10,7 +9,7 @@ xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/header" android:id="@+id/header"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/primaryBackgroundColor" android:background="@drawable/shape_files_diffs"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="15dp" android:paddingLeft="15dp"
android:paddingTop="7dp" android:paddingTop="7dp"
@ -24,7 +23,7 @@ xmlns:tools="http://schemas.android.com/tools"
android:ellipsize="start" android:ellipsize="start"
android:fontFamily="monospace" android:fontFamily="monospace"
android:singleLine="true" android:singleLine="true"
android:textColor="?attr/primaryTextColor" android:textColor="@color/colorWhite"
android:textSize="16sp" /> android:textSize="16sp" />
<LinearLayout <LinearLayout
@ -37,8 +36,8 @@ xmlns:tools="http://schemas.android.com/tools"
<LinearLayout <LinearLayout
android:layout_width="16dp" android:layout_width="16dp"
android:layout_height="5dp" android:layout_height="5dp"
android:layout_marginRight="10dp" android:layout_marginEnd="10dp"
android:background="@color/darkGreen" android:background="@color/colorLightGreen"
android:orientation="horizontal"> android:orientation="horizontal">
<Space <Space
@ -59,7 +58,7 @@ xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="monospace" android:fontFamily="monospace"
android:textColor="?attr/primaryTextColor" android:textColor="@color/colorWhite"
android:textSize="12sp" /> android:textSize="12sp" />
</LinearLayout> </LinearLayout>
@ -83,7 +82,8 @@ xmlns:tools="http://schemas.android.com/tools"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:scaleType="fitXY" android:scaleType="fitXY"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="@string/generalImgContentText" />
<HorizontalScrollView <HorizontalScrollView
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -16,8 +16,8 @@
<ImageView <ImageView
android:id="@+id/avatar" android:id="@+id/avatar"
android:layout_width="35dp" android:layout_width="@dimen/list_avatar_size"
android:layout_height="35dp" android:layout_height="@dimen/list_avatar_size"
android:layout_weight="0" android:layout_weight="0"
android:contentDescription="@string/generalImgContentText" android:contentDescription="@string/generalImgContentText"
tools:srcCompat="@tools:sample/avatars" /> tools:srcCompat="@tools:sample/avatars" />
@ -38,7 +38,7 @@
android:ellipsize="middle" android:ellipsize="middle"
android:singleLine="true" android:singleLine="true"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="15sp" android:textSize="14sp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
@ -48,7 +48,7 @@
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true" android:singleLine="true"
android:textColor="?attr/hintColor" android:textColor="?attr/hintColor"
android:textSize="14sp" /> android:textSize="12sp" />
</LinearLayout> </LinearLayout>
<ImageView <ImageView
@ -71,14 +71,14 @@
android:textIsSelectable="true" android:textIsSelectable="true"
android:autoLink="web" android:autoLink="web"
android:textColorLink="@color/lightBlue" android:textColorLink="@color/lightBlue"
android:textSize="16sp" /> android:textSize="14sp" />
<LinearLayout <LinearLayout
android:id="@+id/commentReactionBadges" android:id="@+id/commentReactionBadges"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" android:visibility="gone"
android:layout_marginTop="15dp" android:layout_marginTop="16dp"
android:orientation="horizontal" /> android:orientation="horizontal" />
</LinearLayout> </LinearLayout>

View File

@ -1,86 +1,95 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relativeLayoutFrameIssuesList" android:id="@+id/relativeLayoutFrameIssuesList"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:padding="16dp"
android:layout_margin="15dp"
android:orientation="vertical" android:orientation="vertical"
android:background="?attr/primaryBackgroundColor"> android:background="?android:attr/selectableItemBackground"
android:focusable="true">
<ImageView
android:id="@+id/assigneeAvatar"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginEnd="15dp"
android:contentDescription="@string/generalImgContentText"
android:src="@drawable/ic_android" />
<LinearLayout <LinearLayout
android:id="@+id/infoSection" android:id="@+id/infoSection"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toEndOf="@+id/assigneeAvatar" android:layout_marginBottom="8dp"
android:orientation="vertical"> android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<LinearLayout <ImageView
android:id="@+id/frameIssueNameStatus" android:id="@+id/assigneeAvatar"
android:layout_width="match_parent" android:layout_width="@dimen/list_avatar_size"
android:layout_height="wrap_content" android:layout_height="@dimen/list_avatar_size"
android:layout_marginBottom="10dp" android:layout_marginEnd="10dp"
android:orientation="horizontal"> android:contentDescription="@string/generalImgContentText"
tools:src="@tools:sample/avatars" />
<TextView <TextView
android:id="@+id/issueTitle" android:id="@+id/issueTitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="top|center_vertical" android:gravity="top|center_vertical"
android:textAlignment="gravity"
android:text="@string/strFilter" android:text="@string/strFilter"
android:textAlignment="gravity"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="18sp" /> android:textSize="16sp"
tools:text="Id illum odio repellat omnis fuga deserunt aut. Ut est aut similique qui incidunt quia et." />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/frameCreatedDate" android:id="@+id/issueInfoFrame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView
android:id="@+id/issueCreatedTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start"
android:textColor="?attr/hintColor"
android:textSize="12sp"
tools:text="10.01.2020" />
<LinearLayout <LinearLayout
android:id="@+id/frameCommentsCount" android:id="@+id/frameCommentsCount"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight=".25"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:layout_gravity="end"
android:layout_marginStart="10dp"
android:layout_marginEnd="6dp"
android:layout_weight="1"
android:gravity="end"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_marginStart="3dp"
android:layout_marginEnd="5dp"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_comment"
app:tint="?attr/iconsColor" />
<TextView <TextView
android:id="@+id/issueCommentsCount" android:id="@+id/issueCommentsCount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="start" android:gravity="center_vertical"
android:drawablePadding="5dp" android:text="@string/repoStars"
app:drawableStartCompat="@drawable/ic_comment"
android:layout_gravity="center_horizontal"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="14sp" /> android:textSize="14sp"
tools:text="50" />
</LinearLayout>
<TextView
android:id="@+id/issueCreatedTime"
android:layout_width="0dp"
android:layout_weight=".25"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</RelativeLayout> </LinearLayout>

View File

@ -6,28 +6,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/primaryBackgroundColor" android:background="?attr/primaryBackgroundColor"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="10dp"> android:padding="16dp">
<TextView
android:id="@+id/labelTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="gone" />
<TextView
android:id="@+id/labelId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="gone" />
<TextView
android:id="@+id/labelColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="gone" />
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:id="@+id/labelView" android:id="@+id/labelView"
@ -52,17 +31,17 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
android:contentDescription="@string/generalImgContentText" android:contentDescription="@string/generalImgContentText"
android:tint="@color/colorWhite" app:tint="@color/colorWhite"
app:srcCompat="@drawable/ic_label" /> app:srcCompat="@drawable/ic_label" />
<TextView <TextView
android:id="@+id/labelName" android:id="@+id/labelName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginStart="10dp"
android:layout_weight="1" android:layout_weight="1"
android:textColor="@color/colorWhite" android:textColor="@color/colorWhite"
android:textSize="16sp" android:textSize="14sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -79,7 +58,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end" android:layout_gravity="center_vertical|end"
android:contentDescription="@string/labelMenuContentDesc" android:contentDescription="@string/labelMenuContentDesc"
android:paddingLeft="10dp" android:paddingStart="10dp"
android:paddingEnd="0dp"
android:src="@drawable/ic_dotted_menu_horizontal" /> android:src="@drawable/ic_dotted_menu_horizontal" />
</LinearLayout> </LinearLayout>

View File

@ -7,27 +7,14 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/milestoneFrame" android:id="@+id/milestoneFrame"
android:background="?attr/primaryBackgroundColor" android:background="?attr/primaryBackgroundColor"
android:padding="16dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:id="@+id/milestoneId" />
<TextView
android:id="@+id/milestoneStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
tools:visibility="visible" />
<LinearLayout <LinearLayout
android:id="@+id/mainFrame" android:id="@+id/mainFrame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_margin="15dp"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
@ -44,7 +31,7 @@
android:layout_weight="0" android:layout_weight="0"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textIsSelectable="true" android:textIsSelectable="true"
android:textSize="18sp" /> android:textSize="16sp" />
<ProgressBar <ProgressBar
android:id="@+id/milestoneProgress" android:id="@+id/milestoneProgress"
@ -72,7 +59,8 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginEnd="15dp" android:layout_marginEnd="15dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<ImageView <ImageView
android:layout_width="18dp" android:layout_width="18dp"
@ -95,7 +83,8 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginEnd="15dp" android:layout_marginEnd="15dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<ImageView <ImageView
android:layout_width="18dp" android:layout_width="18dp"
@ -117,7 +106,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<ImageView <ImageView
android:layout_width="18dp" android:layout_width="18dp"

View File

@ -5,13 +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/primaryBackgroundColor" android:background="?attr/primaryBackgroundColor"
android:padding="16dp"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal">
android:padding="16dp">
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -1,59 +1,48 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/primaryBackgroundColor">
<RelativeLayout
android:id="@+id/linearLayoutFrame" android:id="@+id/linearLayoutFrame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:background="?android:attr/selectableItemBackground"
android:focusable="true"
android:orientation="vertical" android:orientation="vertical"
android:padding="15dp"> android:padding="16dp">
<TextView <LinearLayout
android:id="@+id/organizationId" android:id="@+id/orgInfoFrame"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="invisible"/> android:layout_marginBottom="8dp"
android:gravity="center_vertical"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<ImageView <ImageView
android:id="@+id/imageAvatar" android:id="@+id/imageAvatar"
android:layout_width="40dp" android:layout_width="@dimen/list_avatar_size"
android:layout_height="40dp" android:layout_height="@dimen/list_avatar_size"
android:layout_marginEnd="15dp" android:layout_marginStart="0dp"
android:src="@drawable/ic_android" android:layout_marginEnd="10dp"
android:contentDescription="@string/orgContentAvatar"/> android:contentDescription="@string/repoContentAvatar"
android:src="@drawable/ic_android" />
<LinearLayout
android:id="@+id/infoSection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/imageAvatar"
android:orientation="vertical">
<TextView <TextView
android:id="@+id/orgUsername" android:id="@+id/orgName"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/orgName"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="18sp" /> android:textSize="14sp"
tools:text="@string/orgName" />
</LinearLayout>
<TextView <TextView
android:id="@+id/orgDescription" android:id="@+id/orgDescription"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/orgDescription" android:text="@string/noDataDescription"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="16sp" android:textSize="15sp" />
android:visibility="gone" />
</LinearLayout> </LinearLayout>
</RelativeLayout>
</RelativeLayout>

View File

@ -1,36 +1,31 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relativeLayoutFrame" android:id="@+id/relativeLayoutFrame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:padding="16dp"
android:layout_margin="15dp"
android:orientation="vertical" android:orientation="vertical"
android:background="?attr/primaryBackgroundColor"> android:background="?android:attr/selectableItemBackground"
android:focusable="true">
<ImageView
android:id="@+id/assigneeAvatar"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginEnd="15dp"
android:contentDescription="@string/generalImgContentText"
android:src="@drawable/ic_android" />
<LinearLayout
android:id="@+id/infoSection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/assigneeAvatar"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/framePrNameStatus" android:id="@+id/framePrNameStatus"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="10dp" android:layout_marginBottom="8dp"
android:orientation="horizontal"> android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<ImageView
android:id="@+id/assigneeAvatar"
android:layout_width="@dimen/list_avatar_size"
android:layout_height="@dimen/list_avatar_size"
android:layout_marginEnd="10dp"
android:contentDescription="@string/generalImgContentText"
android:src="@drawable/ic_android" />
<TextView <TextView
android:id="@+id/prTitle" android:id="@+id/prTitle"
@ -38,44 +33,56 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="top|center_vertical" android:gravity="top|center_vertical"
android:textAlignment="gravity" android:textAlignment="gravity"
android:text="@string/strFilter"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="18sp" /> android:textSize="16sp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/frameCreatedDate" android:id="@+id/issueInfoFrame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView
android:id="@+id/prCreatedTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start"
android:textColor="?attr/hintColor"
android:textSize="12sp" />
<LinearLayout <LinearLayout
android:id="@+id/frameCommentsCount" android:id="@+id/frameCommentsCount"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight=".25"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:layout_gravity="end"
android:layout_marginStart="10dp"
android:layout_marginEnd="6dp"
android:layout_weight="1"
android:gravity="end"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_marginStart="3dp"
android:layout_marginEnd="5dp"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_comment"
app:tint="?attr/iconsColor" />
<TextView <TextView
android:id="@+id/prCommentsCount" android:id="@+id/prCommentsCount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="start" android:gravity="center_vertical"
android:drawablePadding="5dp" android:text="@string/repoStars"
android:layout_gravity="center_horizontal"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp"
app:drawableStartCompat="@drawable/ic_comment" />
</LinearLayout>
<TextView
android:id="@+id/prCreatedTime"
android:layout_width="0dp"
android:layout_weight=".25"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="14sp" /> android:textSize="14sp" />
@ -83,4 +90,4 @@
</LinearLayout> </LinearLayout>
</RelativeLayout> </LinearLayout>

View File

@ -1,10 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="15dp" android:gravity="center_vertical"
android:background="?attr/primaryBackgroundColor" > android:orientation="horizontal"
android:padding="16dp"
tools:ignore="UseCompoundDrawables">
<TextView <TextView
android:id="@+id/userEmail" android:id="@+id/userEmail"
@ -18,12 +20,11 @@
android:id="@+id/emailPrimary" android:id="@+id/emailPrimary"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toEndOf="@+id/userEmail"
android:layout_gravity="start" android:layout_gravity="start"
android:layout_marginTop="0dp" android:layout_marginTop="2dp"
android:contentDescription="@string/emailTypeText"
android:paddingStart="20dp" android:paddingStart="20dp"
android:paddingEnd="2dp" android:paddingEnd="2dp"
android:contentDescription="@string/emailTypeText" tools:src="@drawable/ic_verified_user" />
android:src="@drawable/ic_verified_user" />
</RelativeLayout> </LinearLayout>

View File

@ -1,16 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="15dp" android:gravity="center_vertical"
android:background="?attr/primaryBackgroundColor" > android:padding="16dp">
<ImageView <ImageView
android:id="@+id/userAvatar" android:id="@+id/userAvatar"
android:layout_width="wrap_content" android:layout_width="@dimen/list_avatar_size"
android:layout_height="wrap_content" android:layout_height="@dimen/list_avatar_size"
android:layout_marginEnd="15dp" android:layout_marginEnd="10dp"
android:contentDescription="@string/generalImgContentText" android:contentDescription="@string/generalImgContentText"
android:src="@drawable/ic_android" /> android:src="@drawable/ic_android" />
@ -18,7 +17,6 @@
android:id="@+id/userInfoSection" android:id="@+id/userInfoSection"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toEndOf="@+id/userAvatar"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
@ -27,7 +25,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/userName" android:text="@string/userName"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="16sp" /> android:textSize="16sp"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/userName" android:id="@+id/userName"
@ -39,4 +38,4 @@
</LinearLayout> </LinearLayout>
</RelativeLayout> </LinearLayout>

View File

@ -1,16 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="15dp" android:gravity="center_vertical"
android:background="?attr/primaryBackgroundColor" > android:padding="16dp">
<ImageView <ImageView
android:id="@+id/userAvatar" android:id="@+id/userAvatar"
android:layout_width="wrap_content" android:layout_width="@dimen/list_avatar_size"
android:layout_height="wrap_content" android:layout_height="@dimen/list_avatar_size"
android:layout_marginEnd="15dp" android:layout_marginEnd="10dp"
android:contentDescription="@string/generalImgContentText" android:contentDescription="@string/generalImgContentText"
android:src="@drawable/ic_android" /> android:src="@drawable/ic_android" />
@ -18,7 +17,6 @@
android:id="@+id/userInfoSection" android:id="@+id/userInfoSection"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toEndOf="@+id/userAvatar"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
@ -27,7 +25,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/userName" android:text="@string/userName"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="16sp" /> android:textSize="16sp"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/userName" android:id="@+id/userName"
@ -39,4 +38,4 @@
</LinearLayout> </LinearLayout>
</RelativeLayout> </LinearLayout>

View File

@ -5,7 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:padding="15dp"> android:padding="16dp">
<LinearLayout <LinearLayout
android:id="@+id/headerFrame" android:id="@+id/headerFrame"
@ -26,7 +26,7 @@
android:layout_weight="1" android:layout_weight="1"
android:singleLine="true" android:singleLine="true"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="18sp" android:textSize="16sp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
@ -193,7 +193,7 @@
android:layout_width="15dp" android:layout_width="15dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/generalImgContentText" android:contentDescription="@string/generalImgContentText"
android:tint="?attr/primaryTextColor" app:tint="?attr/primaryTextColor"
android:src="@drawable/ic_chevron_right" android:src="@drawable/ic_chevron_right"
app:srcCompat="@drawable/ic_chevron_right" /> app:srcCompat="@drawable/ic_chevron_right" />
@ -207,45 +207,71 @@
</LinearLayout> </LinearLayout>
<RelativeLayout <LinearLayout
android:id="@+id/downloads" android:id="@+id/downloads"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="vertical"
android:visibility="gone" android:visibility="gone"
android:paddingTop="8dp"> android:paddingTop="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_marginStart="8dp"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
app:srcCompat="@drawable/ic_download"
android:contentDescription="@string/generalImgContentText" />
<TextView <TextView
android:id="@+id/releaseZipDownload" android:id="@+id/releaseZipDownload"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:drawableStart="@drawable/ic_download"
android:drawablePadding="8dp"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="14sp" /> android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_marginStart="8dp"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
app:srcCompat="@drawable/ic_download"
android:contentDescription="@string/generalImgContentText" />
<TextView <TextView
android:id="@+id/releaseTarDownload" android:id="@+id/releaseTarDownload"
android:layout_below="@+id/releaseZipDownload"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:drawableStart="@drawable/ic_download"
android:drawablePadding="8dp"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="14sp" /> android:textSize="12sp" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/downloadList" android:id="@+id/downloadList"
android:layout_below="@+id/releaseTarDownload"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/primaryBackgroundColor" android:background="?attr/primaryBackgroundColor"
android:scrollbars="vertical" /> android:scrollbars="vertical" />
</RelativeLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -10,8 +10,8 @@
tools:ignore="UseCompoundDrawables"> tools:ignore="UseCompoundDrawables">
<ImageView <ImageView
android:layout_width="wrap_content" android:layout_width="18dp"
android:layout_height="wrap_content" android:layout_height="18dp"
app:srcCompat="@drawable/ic_download" app:srcCompat="@drawable/ic_download"
android:contentDescription="@string/generalImgContentText" /> android:contentDescription="@string/generalImgContentText" />
@ -21,7 +21,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="14sp" android:textSize="12sp"
tools:text="Source code (ZIP)" /> tools:text="Source code (ZIP)" />
</LinearLayout> </LinearLayout>

View File

@ -1,126 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/primaryBackgroundColor"> android:background="?android:attr/selectableItemBackground"
android:focusable="true"
<TextView android:orientation="vertical"
android:id="@+id/repoType" android:padding="16dp">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible" />
<TextView
android:id="@+id/repoBranch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible" />
<TextView
android:id="@+id/htmlUrl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible" />
<RelativeLayout
android:id="@+id/linearLayoutFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:orientation="vertical">
<ImageView
android:id="@+id/imageAvatar"
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/infoSection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/imageAvatar"
android:orientation="vertical">
<LinearLayout
android:id="@+id/frameRepoName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/repoName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".95"
android:text="@string/repoName"
android:textColor="?attr/primaryTextColor"
android:textSize="18sp" />
<LinearLayout
android:id="@+id/archiveRepoFrame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="6dp"
android:background="@drawable/shape_archived"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:visibility="gone"
tools:visibility="visible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_vertical"
android:text="@string/archivedRepository"
android:textColor="@color/colorWhite" />
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_marginStart="3dp"
android:layout_weight="0"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_archive"
app:tint="@color/colorWhite" />
</LinearLayout>
<ImageView
android:id="@+id/imageRepoType"
android:layout_width="10dp"
android:layout_height="20dp"
android:layout_weight=".05"
android:contentDescription="@string/privateAvatar"
android:src="@drawable/ic_lock" />
</LinearLayout>
<TextView
android:id="@+id/repoFullName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/repoFullName"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/repoDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="@string/repoDescription"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:visibility="gone" />
<CheckBox <CheckBox
android:id="@+id/repoIsAdmin" android:id="@+id/repoIsAdmin"
@ -131,64 +18,115 @@
android:visibility="gone" /> android:visibility="gone" />
<LinearLayout <LinearLayout
android:id="@+id/orgInfoFrame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginBottom="8dp"
android:gravity="center_vertical"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<ImageView
android:id="@+id/imageAvatar"
android:layout_width="@dimen/list_avatar_size"
android:layout_height="@dimen/list_avatar_size"
android:layout_marginStart="0dp"
android:layout_marginEnd="10dp"
android:contentDescription="@string/repoContentAvatar"
android:src="@drawable/ic_android" />
<TextView
android:id="@+id/orgName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp"
tools:text="@string/orgName" />
</LinearLayout>
<TextView
android:id="@+id/repoName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/repoName"
android:textColor="?attr/primaryTextColor"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/repoDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:textColor="?attr/primaryTextColor"
android:textSize="15sp"
android:text="@string/noDataDescription" />
<LinearLayout
android:id="@+id/repoInfoFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/repoOpenIssuesCount" android:id="@+id/repoLastUpdated"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="24dp" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:textColor="?attr/hintColor"
android:layout_weight=".25" android:textSize="13sp"
app:drawableStartCompat="@drawable/ic_issue" tools:text="@string/lastUpdatedAt" />
android:drawablePadding="6dp"
android:gravity="center_vertical" <LinearLayout
android:text="@string/repoWatchers" android:id="@+id/repoInfoStarsFrame"
android:textColor="?attr/primaryTextColor" android:layout_width="match_parent"
android:textSize="14sp" /> android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:gravity="center_vertical|end"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_marginStart="3dp"
android:layout_marginEnd="5dp"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_star"
app:tint="?attr/iconsColor" />
<TextView <TextView
android:id="@+id/repoStars" android:id="@+id/repoStars"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="24dp" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".25"
app:drawableStartCompat="@drawable/ic_star_unfilled"
android:drawablePadding="6dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text="@string/repoStars"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="14sp" /> android:textSize="14sp"
tools:text="@string/repoStars" />
<TextView
android:id="@+id/repoForks"
android:layout_width="0dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_weight=".25"
app:drawableStartCompat="@drawable/ic_fork"
android:drawablePadding="6dp"
android:gravity="center_vertical"
android:text="@string/repoWatchers"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp" />
<ImageView <ImageView
android:id="@+id/reposDropdownMenu" android:layout_width="18dp"
android:layout_width="0dp" android:layout_height="18dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="5dp"
android:contentDescription="@string/generalImgContentText"
android:visibility="gone"
app:srcCompat="@drawable/ic_star"
app:tint="?attr/iconsColor" />
<TextView
android:id="@+id/repoStars2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end" android:gravity="center_vertical"
android:layout_weight=".10" android:textColor="?attr/primaryTextColor"
android:contentDescription="@string/menuContentDesc" android:textSize="14sp"
android:scaleType="fitEnd" android:visibility="gone"
android:src="@drawable/ic_dotted_menu_horizontal" /> tools:text="Java" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</RelativeLayout> </LinearLayout>
</RelativeLayout>

View File

@ -1,23 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout android:layout_width="match_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/orgTeamsFrame"
android:padding="16dp"
android:orientation="vertical" android:orientation="vertical"
android:id="@+id/relativeLayoutMainFrame" android:background="?attr/primaryBackgroundColor"
android:background="?attr/primaryBackgroundColor"> xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15dp"
android:id="@+id/milestoneFrame"
android:orientation="vertical">
<TextView
android:id="@+id/teamId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
<TextView <TextView
android:id="@+id/teamTitle" android:id="@+id/teamTitle"
@ -46,6 +34,3 @@
android:textSize="14sp" /> android:textSize="14sp" />
</LinearLayout> </LinearLayout>
</RelativeLayout>

View File

@ -1,57 +1,63 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/layoutFrame" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layoutFrame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:gravity="center_vertical"
android:layout_margin="15dp" android:orientation="horizontal"
android:background="?attr/primaryBackgroundColor" android:background="?android:attr/selectableItemBackground"
xmlns:android="http://schemas.android.com/apk/res/android"> android:focusable="true"
android:padding="16dp">
<ImageView <ImageView
android:id="@+id/repoAvatar" android:id="@+id/repoAvatar"
android:layout_width="40dp" android:layout_width="@dimen/list_avatar_size"
android:layout_height="40dp" android:layout_height="@dimen/list_avatar_size"
android:layout_marginEnd="15dp" android:layout_marginEnd="10dp"
android:contentDescription="@string/repoContentAvatar" android:contentDescription="@string/generalImgContentText"
android:src="@drawable/ic_android" /> android:visibility="visible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/frameAccountsInfo" android:id="@+id/frameAccountsInfo"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:gravity="center_vertical"
android:layout_toEndOf="@+id/repoAvatar" android:orientation="horizontal">
android:layout_marginBottom="10dp">
<TextView <TextView
android:id="@+id/userId" android:id="@+id/userId"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight=".95" android:layout_weight="1"
android:layout_gravity="start"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold" /> android:textStyle="bold" />
<ImageView <ImageView
android:id="@+id/activeAccount" android:id="@+id/activeAccount"
android:layout_weight=".05" android:layout_width="20dp"
android:layout_width="10dp" android:layout_height="wrap_content"
android:layout_height="20dp" android:layout_weight="0"
android:layout_gravity="end" android:contentDescription="@string/menuContentDesc"
android:src="@drawable/ic_check" android:src="@drawable/ic_check"
android:visibility="gone" android:visibility="gone"
android:contentDescription="@string/menuContentDesc" /> tools:visibility="visible" />
<ImageView <ImageView
android:id="@+id/deleteAccount" android:id="@+id/deleteAccount"
android:layout_weight=".05" android:layout_width="20dp"
android:layout_width="10dp" android:layout_height="wrap_content"
android:layout_height="20dp" android:layout_weight="0"
android:layout_gravity="end" android:contentDescription="@string/menuDeleteText"
android:src="@drawable/ic_delete" android:src="@drawable/ic_delete"
android:visibility="gone" android:visibility="gone"
android:contentDescription="@string/menuDeleteText" /> tools:visibility="visible" />
</LinearLayout> </LinearLayout>
@ -59,10 +65,9 @@
android:id="@+id/accountUrl" android:id="@+id/accountUrl"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_toEndOf="@+id/repoAvatar"
android:layout_below="@+id/frameAccountsInfo"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="14sp" /> android:textSize="14sp" />
</RelativeLayout> </LinearLayout>
</LinearLayout>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/navHeaderFrame" android:id="@+id/navHeaderFrame"
@ -19,10 +19,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="bottom" android:gravity="bottom"
android:orientation="vertical" android:orientation="vertical"
android:paddingStart="20dp" android:padding="20dp">
android:paddingTop="20dp"
android:paddingEnd="20dp"
android:paddingBottom="20dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -36,23 +33,43 @@
android:contentDescription="@string/generalImgContentText" android:contentDescription="@string/generalImgContentText"
tools:srcCompat="@tools:sample/avatars" /> tools:srcCompat="@tools:sample/avatars" />
<androidx.recyclerview.widget.RecyclerView <FrameLayout
android:id="@+id/navRecyclerViewUserAccounts"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:id="@+id/userAccountsFrame"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="end"
android:visibility="gone"
app:cardBackgroundColor="?attr/primaryBackgroundColor"
app:cardCornerRadius="20dp"
app:cardElevation="0dp"
app:contentPaddingLeft="5dp"
app:contentPaddingRight="5dp"
tools:visibility="visible">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/userAccounts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
app:reverseLayout="true" />
</androidx.cardview.widget.CardView>
</FrameLayout>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:baselineAligned="false"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
@ -79,11 +96,4 @@
</LinearLayout> </LinearLayout>
<View </FrameLayout>
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_marginTop="16dp"
android:background="?attr/dividerColor" />
</RelativeLayout>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ImageView <ImageView
android:id="@+id/userAccountAvatar" android:id="@+id/userAccountAvatar"
android:layout_width="36dp" android:layout_width="32dp"
android:layout_height="36dp" android:layout_height="32dp"
android:paddingStart="4dp" android:paddingStart="4dp"
android:paddingEnd="4dp" android:paddingEnd="4dp"
android:contentDescription="@string/generalImgContentText" android:contentDescription="@string/generalImgContentText"

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:background="?attr/primaryBackgroundColor" >
<TextView
android:id="@+id/sponsorText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:textColor="?attr/primaryTextColor"
android:textColorLink="@color/lightBlue"
android:textSize="16sp" />
</RelativeLayout>

View File

@ -2,4 +2,6 @@
<dimen name="tooltipCornor">5dp</dimen> <dimen name="tooltipCornor">5dp</dimen>
<dimen name="close_button_size">26dp</dimen> <dimen name="close_button_size">26dp</dimen>
<dimen name="fab_padding">15dp</dimen> <dimen name="fab_padding">15dp</dimen>
<dimen name="list_avatar_size">24dp</dimen>
</resources> </resources>

View File

@ -646,6 +646,7 @@
<string name="aboutAppHintText">App version, build, user gitea version</string> <string name="aboutAppHintText">App version, build, user gitea version</string>
<string name="archivedRepository">Archived</string> <string name="archivedRepository">Archived</string>
<string name="archivedRepositoryMessage">This repo is archived. You can view files, but cannot push or open issues/pull-requests.</string>
<string name="accountDeletedMessage">Account deleted successfully</string> <string name="accountDeletedMessage">Account deleted successfully</string>
<string name="removeAccountPopupTitle">Remove Account</string> <string name="removeAccountPopupTitle">Remove Account</string>
@ -754,4 +755,5 @@
<string name="fileViewerNotificationChannelName">Download manager</string> <string name="fileViewerNotificationChannelName">Download manager</string>
<string name="fileViewerNotificationChannelDescription">Indicates the progress of ongoing downloads</string> <string name="fileViewerNotificationChannelDescription">Indicates the progress of ongoing downloads</string>
<string name="lastUpdatedAt">Updated %s</string>
</resources> </resources>