diff --git a/app/src/main/java/org/mian/gitnex/activities/MainActivity.java b/app/src/main/java/org/mian/gitnex/activities/MainActivity.java index e2ddc88e..29e8565f 100644 --- a/app/src/main/java/org/mian/gitnex/activities/MainActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/MainActivity.java @@ -18,6 +18,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.biometric.BiometricPrompt; +import androidx.cardview.widget.CardView; import androidx.core.content.ContextCompat; import androidx.core.content.res.ResourcesCompat; import androidx.core.view.GravityCompat; @@ -71,10 +72,6 @@ import retrofit2.Callback; public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener, BottomSheetDraftsFragment.BottomSheetListener { private DrawerLayout drawer; - private TextView userFullName; - private TextView userEmail; - private ImageView userAvatar; - private ImageView userAvatarBackground; private TextView toolbarTitle; private Typeface myTypeface; @@ -256,6 +253,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig drawer.addDrawerListener(toggle); drawer.addDrawerListener(new DrawerLayout.DrawerListener() { + @Override public void onDrawerOpened(@NonNull View drawerView) { @@ -269,27 +267,26 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig String userFullNameNav = tinyDB.getString("userFullname"); String userAvatarNav = tinyDB.getString("userAvatar"); - userEmail = hView.findViewById(R.id.userEmail); - userFullName = hView.findViewById(R.id.userFullname); - userAvatar = hView.findViewById(R.id.userAvatar); - userAvatarBackground = hView.findViewById(R.id.userAvatarBackground); + TextView userEmail = hView.findViewById(R.id.userEmail); + TextView userFullName = hView.findViewById(R.id.userFullname); + ImageView userAvatar = hView.findViewById(R.id.userAvatar); + ImageView userAvatarBackground = hView.findViewById(R.id.userAvatarBackground); + CardView navRecyclerViewFrame = hView.findViewById(R.id.userAccountsFrame); - List userAccountsList; - userAccountsList = new ArrayList<>(); + List userAccountsList = new ArrayList<>(); UserAccountsApi userAccountsApi; userAccountsApi = new UserAccountsApi(ctx); - RecyclerView navRecyclerViewUserAccounts = hView.findViewById(R.id.navRecyclerViewUserAccounts); + RecyclerView navRecyclerViewUserAccounts = hView.findViewById(R.id.userAccounts); UserAccountsNavAdapter adapterUserAccounts; adapterUserAccounts = new UserAccountsNavAdapter(ctx, userAccountsList, drawer, toolbarTitle); userAccountsApi.getAllAccounts().observe((AppCompatActivity) ctx, userAccounts -> { - if(userAccounts.size() > 0) { - userAccountsList.addAll(userAccounts); navRecyclerViewUserAccounts.setAdapter(adapterUserAccounts); + navRecyclerViewFrame.setVisibility(View.VISIBLE); } }); @@ -308,10 +305,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig if(!userAvatarNav.equals("")) { + int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 3); + PicassoService.getInstance(ctx).get() .load(userAvatarNav) .placeholder(R.drawable.loader_animated) - .transform(new RoundedTransformation(8, 0)) + .transform(new RoundedTransformation(avatarRadius, 0)) .resize(160, 160) .centerCrop().into(userAvatar); diff --git a/app/src/main/java/org/mian/gitnex/adapters/AdminCronTasksAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/AdminCronTasksAdapter.java index 5bce9a2e..cb53bff4 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/AdminCronTasksAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/AdminCronTasksAdapter.java @@ -31,17 +31,13 @@ import retrofit2.Callback; public class AdminCronTasksAdapter extends RecyclerView.Adapter { private final List tasksList; - private final Context mCtx; private static TinyDB tinyDb; static class CronTasksViewHolder extends RecyclerView.ViewHolder { private CronTasks cronTasks; - private final ImageView runTask; private final TextView taskName; - private final LinearLayout cronTasksInfo; - private final LinearLayout cronTasksRun; private CronTasksViewHolder(View itemView) { @@ -51,10 +47,10 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter { @@ -96,10 +92,9 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter tasksListMain) { + public AdminCronTasksAdapter(Context ctx, List tasksListMain) { - tinyDb = TinyDB.getInstance(mCtx); - this.mCtx = mCtx; + tinyDb = TinyDB.getInstance(ctx); this.tasksList = tasksListMain; } diff --git a/app/src/main/java/org/mian/gitnex/adapters/AdminGetUsersAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/AdminGetUsersAdapter.java index 4f7766d8..a01a1d3d 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/AdminGetUsersAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/AdminGetUsersAdapter.java @@ -28,7 +28,7 @@ import java.util.List; public class AdminGetUsersAdapter extends RecyclerView.Adapter implements Filterable { private final List usersList; - private final Context mCtx; + private final Context context; private final List usersListFull; static class UsersViewHolder extends RecyclerView.ViewHolder { @@ -60,9 +60,9 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter usersListMain) { + public AdminGetUsersAdapter(Context ctx, List usersListMain) { - this.mCtx = mCtx; + this.context = ctx; this.usersList = usersListMain; usersListFull = new ArrayList<>(usersList); } @@ -79,17 +79,18 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter { - private final Context mCtx; + private final Context context; private final List assigneesList; private List assigneesStrings = new ArrayList<>(); private List currentAssignees; @@ -36,9 +37,9 @@ public class AssigneesListAdapter extends RecyclerView.Adapter data); } - public AssigneesListAdapter(Context mCtx, List dataMain, AssigneesListAdapterListener assigneesListener, List currentAssignees) { + public AssigneesListAdapter(Context ctx, List dataMain, AssigneesListAdapterListener assigneesListener, List currentAssignees) { - this.mCtx = mCtx; + this.context = ctx; this.assigneesList = dataMain; this.assigneesListener = assigneesListener; this.currentAssignees = currentAssignees; @@ -73,6 +74,7 @@ public class AssigneesListAdapter extends RecyclerView.Adapter collaboratorsList; - private final Context mCtx; + private final Context context; private static class ViewHolder { @@ -46,9 +46,9 @@ public class CollaboratorsAdapter extends BaseAdapter { } } - public CollaboratorsAdapter(Context mCtx, List collaboratorsListMain) { + public CollaboratorsAdapter(Context ctx, List collaboratorsListMain) { - this.mCtx = mCtx; + this.context = ctx; this.collaboratorsList = collaboratorsListMain; } @@ -75,7 +75,7 @@ public class CollaboratorsAdapter extends BaseAdapter { 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); finalView.setTag(viewHolder); } @@ -90,8 +90,10 @@ public class CollaboratorsAdapter extends BaseAdapter { private void initData(ViewHolder viewHolder, int position) { + int imgRadius = AppUtil.getPixelsFromDensity(context, 3); + 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(); diff --git a/app/src/main/java/org/mian/gitnex/adapters/CommitsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/CommitsAdapter.java index 9c67fcde..46e58de1 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/CommitsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/CommitsAdapter.java @@ -26,7 +26,7 @@ import java.util.Locale; public class CommitsAdapter extends RecyclerView.Adapter { - private final Context ctx; + private final Context context; private final int TYPE_LOAD = 0; private List commitsList; private CommitsAdapter.OnLoadMoreListener loadMoreListener; @@ -35,7 +35,7 @@ public class CommitsAdapter extends RecyclerView.Adapter commitsListMain) { - this.ctx = ctx; + this.context = ctx; this.commitsList = commitsListMain; } @@ -44,7 +44,7 @@ public class CommitsAdapter extends RecyclerView.Adapter 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 list) { diff --git a/app/src/main/java/org/mian/gitnex/adapters/CreditsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/CreditsAdapter.java deleted file mode 100644 index 2ec35f66..00000000 --- a/app/src/main/java/org/mian/gitnex/adapters/CreditsAdapter.java +++ /dev/null @@ -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 { - - private List 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 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(); - } - -} diff --git a/app/src/main/java/org/mian/gitnex/adapters/DraftsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/DraftsAdapter.java index a6db98d7..f054c635 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/DraftsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/DraftsAdapter.java @@ -33,7 +33,7 @@ public class DraftsAdapter extends RecyclerView.Adapter draftsList; private final FragmentManager fragmentManager; - private final Context mCtx; + private final Context context; class DraftsViewHolder extends RecyclerView.ViewHolder { @@ -56,9 +56,8 @@ public class DraftsAdapter extends RecyclerView.Adapter { @@ -76,24 +75,23 @@ public class DraftsAdapter extends RecyclerView.Adapter mCtx.startActivity(new Intent(mCtx, IssueDetailActivity.class))); + bottomSheetReplyFragment.setOnInteractedListener(() -> context.startActivity(new Intent(context, IssueDetailActivity.class))); bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet"); - }); } } - public DraftsAdapter(Context mCtx, FragmentManager fragmentManager, List draftsListMain) { - this.mCtx = mCtx; + public DraftsAdapter(Context ctx, FragmentManager fragmentManager, List draftsListMain) { + this.context = ctx; this.fragmentManager = fragmentManager; this.draftsList = draftsListMain; } @@ -103,8 +101,7 @@ public class DraftsAdapter extends RecyclerView.Adapter" + mCtx.getResources().getString(R.string.hash) + currentItem.getIssueId() + ""; + String issueNumber = "" + context.getResources().getString(R.string.hash) + currentItem.getIssueId() + ""; Spanned headTitle = HtmlCompat .fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName(), HtmlCompat.FROM_HTML_MODE_LEGACY); holder.repoInfo.setText(headTitle); holder.draftWithRepository = currentItem; - Markdown.render(mCtx, currentItem.getDraftText(), holder.draftText); + Markdown.render(context, currentItem.getDraftText(), holder.draftText); if(!currentItem.getCommentId().equalsIgnoreCase("new")) { holder.editCommentStatus.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/org/mian/gitnex/adapters/ExploreRepositoriesAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/ExploreRepositoriesAdapter.java index b2af0601..88699632 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/ExploreRepositoriesAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/ExploreRepositoriesAdapter.java @@ -1,8 +1,5 @@ package org.mian.gitnex.adapters; -import android.annotation.SuppressLint; -import android.content.ClipData; -import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; import android.graphics.Typeface; @@ -11,30 +8,30 @@ import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.util.ColorGenerator; -import com.google.android.material.bottomsheet.BottomSheetDialog; import org.gitnex.tea4j.models.UserRepositories; import org.gitnex.tea4j.models.WatchInfo; import org.mian.gitnex.R; -import org.mian.gitnex.activities.OpenRepoInBrowserActivity; 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.RetrofitClient; import org.mian.gitnex.database.api.RepositoriesApi; 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.TimeHelper; import org.mian.gitnex.helpers.TinyDB; 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.Objects; +import java.util.Locale; import retrofit2.Call; import retrofit2.Callback; @@ -44,65 +41,59 @@ import retrofit2.Callback; public class ExploreRepositoriesAdapter extends RecyclerView.Adapter { - private List searchedReposList; - private Context mCtx; + private final List reposList; + private final Context context; - public ExploreRepositoriesAdapter(List dataList, Context mCtx) { + public ExploreRepositoriesAdapter(List dataList, Context ctx) { - this.mCtx = mCtx; - this.searchedReposList = dataList; + this.context = ctx; + this.reposList = dataList; } static class ReposSearchViewHolder extends RecyclerView.ViewHolder { - private ImageView image; - private TextView repoName; - private TextView repoDescription; - private TextView fullName; + private UserRepositories userRepositories; + + private final ImageView image; + private final TextView repoName; + private final TextView orgName; + private final TextView repoDescription; private CheckBox isRepoAdmin; - private ImageView repoPrivatePublic; - private TextView repoStars; - private TextView repoForks; - private TextView repoOpenIssuesCount; - private TextView repoType; - private LinearLayout archiveRepo; - private TextView repoBranch; - private TextView htmlUrl; + private final TextView repoStars; + private final TextView repoLastUpdated; private ReposSearchViewHolder(View itemView) { super(itemView); - repoName = itemView.findViewById(R.id.repoName); + orgName = itemView.findViewById(R.id.orgName); repoDescription = itemView.findViewById(R.id.repoDescription); - image = itemView.findViewById(R.id.imageAvatar); - fullName = itemView.findViewById(R.id.repoFullName); isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin); - repoPrivatePublic = itemView.findViewById(R.id.imageRepoType); + image = itemView.findViewById(R.id.imageAvatar); 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); - archiveRepo = itemView.findViewById(R.id.archiveRepoFrame); - repoBranch = itemView.findViewById(R.id.repoBranch); - htmlUrl = itemView.findViewById(R.id.htmlUrl); + repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated); itemView.setOnClickListener(v -> { Context context = v.getContext(); - TextView repoFullName = v.findViewById(R.id.repoFullName); + TinyDB tinyDb = TinyDB.getInstance(context); 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", repoFullName.getText().toString()); + tinyDb.putString("repoFullName", userRepositories.getFullName()); tinyDb.putBoolean("resumeIssues", true); 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 repoName = parts[1]; @@ -116,13 +107,11 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter { - - 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 originalFiles = new ArrayList<>(); private final List alteredFiles = new ArrayList<>(); - private final Context mCtx; + private final Context context; private final FilesAdapterListener filesListener; @@ -40,8 +40,7 @@ public class FilesAdapter extends RecyclerView.Adapter getOriginalFiles() { @@ -141,7 +139,6 @@ public class FilesAdapter extends RecyclerView.Adapter { if(((DiffTextView) v).getCurrentBackgroundColor() != COLOR_SELECTED) { @@ -197,7 +194,6 @@ public class FilesDiffAdapter extends BaseAdapter { stringBuilder.append(((DiffTextView) view).getText()); stringBuilder.append("\n"); - } stringBuilder.append("```\n\n"); @@ -209,7 +205,6 @@ public class FilesDiffAdapter extends BaseAdapter { bundle.putBoolean("cursorToEnd", true); BottomSheetReplyFragment.newInstance(bundle).show(fragmentManager, "replyBottomSheet"); - } return true; @@ -226,7 +221,6 @@ public class FilesDiffAdapter extends BaseAdapter { else { diffLines.addView(getMessageView(context.getResources().getString(R.string.fileTooLarge))); - } } @@ -248,13 +242,11 @@ public class FilesDiffAdapter extends BaseAdapter { textView.setText(message); return textView; - } private String[] getLines(String content) { return content.split("\\R"); - } } diff --git a/app/src/main/java/org/mian/gitnex/adapters/IssueCommentsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/IssueCommentsAdapter.java index c52111c5..cded93f4 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/IssueCommentsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/IssueCommentsAdapter.java @@ -44,7 +44,7 @@ import retrofit2.Callback; public class IssueCommentsAdapter extends RecyclerView.Adapter { - private final Context ctx; + private final Context context; private final TinyDB tinyDB; private final Bundle bundle; private final List issuesComments; @@ -53,14 +53,13 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter issuesCommentsMain, FragmentManager fragmentManager, BottomSheetReplyFragment.OnInteractedListener onInteractedListener) { - this.ctx = ctx; + this.context = ctx; this.bundle = bundle; this.issuesComments = issuesCommentsMain; this.fragmentManager = fragmentManager; this.onInteractedListener = onInteractedListener; tinyDB = TinyDB.getInstance(ctx); - } class IssueCommentViewHolder extends RecyclerView.ViewHolder { @@ -318,39 +317,40 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreated_at())); } 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(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 { diff --git a/app/src/main/java/org/mian/gitnex/adapters/IssuesAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/IssuesAdapter.java index bb606f65..4a53a42c 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/IssuesAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/IssuesAdapter.java @@ -7,7 +7,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.core.content.res.ResourcesCompat; @@ -41,11 +40,10 @@ public class IssuesAdapter extends RecyclerView.Adapter private OnLoadMoreListener loadMoreListener; private boolean isLoading = false, isMoreDataAvailable = true; - public IssuesAdapter(Context context, List issuesListMain) { + public IssuesAdapter(Context ctx, List issuesListMain) { - this.context = context; + this.context = ctx; this.issuesList = issuesListMain; - } @NonNull @@ -60,7 +58,6 @@ public class IssuesAdapter extends RecyclerView.Adapter else { return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false)); } - } @Override @@ -70,15 +67,12 @@ public class IssuesAdapter extends RecyclerView.Adapter isLoading = true; loadMoreListener.onLoadMore(); - } if(getItemViewType(position) == TYPE_LOAD) { ((IssuesHolder) holder).bindData(issuesList.get(position)); - } - } @Override @@ -90,14 +84,12 @@ public class IssuesAdapter extends RecyclerView.Adapter else { return 1; } - } @Override public int getItemCount() { return issuesList.size(); - } class IssuesHolder extends RecyclerView.ViewHolder { @@ -112,16 +104,14 @@ public class IssuesAdapter extends RecyclerView.Adapter IssuesHolder(View itemView) { super(itemView); - issueAssigneeAvatar = itemView.findViewById(R.id.assigneeAvatar); issueTitle = itemView.findViewById(R.id.issueTitle); issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount); - LinearLayout frameCommentsCount = itemView.findViewById(R.id.frameCommentsCount); 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.putExtra("issueNumber", issue.getNumber()); @@ -130,21 +120,6 @@ public class IssuesAdapter extends RecyclerView.Adapter tinyDb.putString("issueNumber", String.valueOf(issue.getNumber())); tinyDb.putString("issueType", "Issue"); 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 -> { @@ -163,10 +138,12 @@ public class IssuesAdapter extends RecyclerView.Adapter String locale = tinyDb.getString("locale"); String timeFormat = tinyDb.getString("dateFormat"); + int imgRadius = AppUtil.getPixelsFromDensity(context, 3); + PicassoService.getInstance(context).get() .load(issue.getUser().getAvatar_url()) .placeholder(R.drawable.loader_animated) - .transform(new RoundedTransformation(8, 0)) + .transform(new RoundedTransformation(imgRadius, 0)) .resize(120, 120) .centerCrop() .into(issueAssigneeAvatar); @@ -209,32 +186,27 @@ public class IssuesAdapter extends RecyclerView.Adapter super(itemView); } - } public void setMoreDataAvailable(boolean moreDataAvailable) { isMoreDataAvailable = moreDataAvailable; - } public void notifyDataChanged() { notifyDataSetChanged(); isLoading = false; - } public interface OnLoadMoreListener { void onLoadMore(); - } public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) { this.loadMoreListener = loadMoreListener; - } public void updateList(List list) { diff --git a/app/src/main/java/org/mian/gitnex/adapters/LabelsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/LabelsAdapter.java index 2b546330..d584eaf3 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/LabelsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/LabelsAdapter.java @@ -20,7 +20,6 @@ import org.mian.gitnex.R; import org.mian.gitnex.activities.CreateLabelActivity; import org.mian.gitnex.helpers.AlertDialogs; import org.mian.gitnex.helpers.ColorInverter; -import java.util.ArrayList; import java.util.List; /** @@ -29,21 +28,17 @@ import java.util.List; public class LabelsAdapter extends RecyclerView.Adapter { - private List labelsList; - final private Context mCtx; - private ArrayList labelsArray = new ArrayList<>(); + private final List labelsList; private static String type; private static String orgName; static class LabelsViewHolder extends RecyclerView.ViewHolder { - private TextView labelTitle; - private TextView labelId; - private TextView labelColor; + private Labels labels; - private CardView labelView; - private ImageView labelIcon; - private TextView labelName; + private final CardView labelView; + private final ImageView labelIcon; + private final TextView labelName; private LabelsViewHolder(View itemView) { super(itemView); @@ -52,9 +47,6 @@ public class LabelsAdapter extends RecyclerView.Adapter { @@ -67,7 +59,7 @@ public class LabelsAdapter extends RecyclerView.Adapter { Intent intent = new Intent(context, CreateLabelActivity.class); - intent.putExtra("labelId", labelId.getText()); - intent.putExtra("labelTitle", labelTitle.getText()); - intent.putExtra("labelColor", labelColor.getText()); + intent.putExtra("labelId", String.valueOf(labels.getId())); + intent.putExtra("labelTitle", labels.getName()); + intent.putExtra("labelColor", labels.getColor()); intent.putExtra("labelAction", "edit"); intent.putExtra("type", type); intent.putExtra("orgName", orgName); context.startActivity(intent); dialog.dismiss(); - }); 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.labelDeleteMessage), context.getResources().getString(R.string.labelDeleteTitle), context.getResources().getString(R.string.labelDeleteNegativeButton), type, orgName); dialog.dismiss(); - }); }); @@ -103,10 +93,9 @@ public class LabelsAdapter extends RecyclerView.Adapter labelsMain, String type, String orgName) { + public LabelsAdapter(Context ctx, List labelsMain, String type, String orgName) { - this.mCtx = mCtx; - this.labelsList = labelsMain; + this.labelsList = labelsMain; LabelsAdapter.type = type; LabelsAdapter.orgName = orgName; } @@ -122,10 +111,7 @@ public class LabelsAdapter extends RecyclerView.Adapter { private List currentLabelsIds; - private List labels; - private List labelsStrings = new ArrayList<>(); + private final List labels; + private final List labelsStrings = new ArrayList<>(); private List labelsIds = new ArrayList<>(); - private LabelsListAdapterListener labelsListener; + private final LabelsListAdapterListener labelsListener; public interface LabelsListAdapterListener { @@ -43,9 +43,9 @@ public class LabelsListAdapter extends RecyclerView.Adapter membersList; - private final Context mCtx; + private final Context context; private final List membersListFull; private static class ViewHolder { @@ -50,9 +50,9 @@ public class MembersByOrgAdapter extends BaseAdapter implements Filterable { } } - public MembersByOrgAdapter(Context mCtx, List membersListMain) { + public MembersByOrgAdapter(Context ctx, List membersListMain) { - this.mCtx = mCtx; + this.context = ctx; this.membersList = membersListMain; membersListFull = new ArrayList<>(membersList); } @@ -80,7 +80,7 @@ public class MembersByOrgAdapter extends BaseAdapter implements Filterable { 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); finalView.setTag(viewHolder); } @@ -96,7 +96,9 @@ public class MembersByOrgAdapter extends BaseAdapter implements Filterable { private void initData(MembersByOrgAdapter.ViewHolder viewHolder, int 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(); @@ -108,7 +110,6 @@ public class MembersByOrgAdapter extends BaseAdapter implements Filterable { viewHolder.memberName.setText(currentItem.getLogin()); } - } @Override diff --git a/app/src/main/java/org/mian/gitnex/adapters/MilestonesAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/MilestonesAdapter.java index 1439c862..f805e570 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/MilestonesAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/MilestonesAdapter.java @@ -35,19 +35,17 @@ import java.util.Locale; public class MilestonesAdapter extends RecyclerView.Adapter { - private Context context; + private final Context context; private final int TYPE_LOAD = 0; private List dataList; private OnLoadMoreListener loadMoreListener; private boolean isLoading = false; private boolean isMoreDataAvailable = true; - private String TAG = Constants.tagMilestonesAdapter; - public MilestonesAdapter(Context context, List dataListMain) { + public MilestonesAdapter(Context ctx, List dataListMain) { - this.context = context; + this.context = ctx; this.dataList = dataListMain; - } @NonNull @@ -62,7 +60,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter { 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); @@ -122,17 +114,15 @@ public class MilestonesAdapter extends RecyclerView.Adapter { @@ -140,7 +130,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter { @@ -148,7 +137,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter list) { diff --git a/app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java index 64e284f8..a0fe9ab2 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java @@ -1,8 +1,5 @@ package org.mian.gitnex.adapters; -import android.annotation.SuppressLint; -import android.content.ClipData; -import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; import android.graphics.Typeface; @@ -13,31 +10,31 @@ import android.widget.CheckBox; import android.widget.Filter; import android.widget.Filterable; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.util.ColorGenerator; -import com.google.android.material.bottomsheet.BottomSheetDialog; import org.gitnex.tea4j.models.UserRepositories; import org.gitnex.tea4j.models.WatchInfo; import org.mian.gitnex.R; -import org.mian.gitnex.activities.OpenRepoInBrowserActivity; 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.RetrofitClient; import org.mian.gitnex.database.api.RepositoriesApi; 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.TimeHelper; import org.mian.gitnex.helpers.TinyDB; 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.List; -import java.util.Objects; +import java.util.Locale; import retrofit2.Call; import retrofit2.Callback; @@ -47,59 +44,54 @@ import retrofit2.Callback; public class MyReposListAdapter extends RecyclerView.Adapter implements Filterable { - private List reposList; - private Context mCtx; - private List reposListFull; + private final List reposList; + private final Context context; + private final List reposListFull; static class MyReposViewHolder extends RecyclerView.ViewHolder { - private ImageView imageAvatar; - private TextView repoName; - private TextView repoDescription; - private TextView repoFullName; - private ImageView repoPrivatePublic; - private TextView repoStars; - private TextView repoForks; - private TextView repoOpenIssuesCount; - private TextView repoType; + private UserRepositories userRepositories; + + private final ImageView image; + private final TextView repoName; + private final TextView orgName; + private final TextView repoDescription; private CheckBox isRepoAdmin; - private LinearLayout archiveRepo; - private TextView repoBranch; - private TextView htmlUrl; + private final TextView repoStars; + private final TextView repoLastUpdated; private MyReposViewHolder(View itemView) { super(itemView); repoName = itemView.findViewById(R.id.repoName); + orgName = itemView.findViewById(R.id.orgName); 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); - archiveRepo = itemView.findViewById(R.id.archiveRepoFrame); - repoBranch = itemView.findViewById(R.id.repoBranch); - htmlUrl = itemView.findViewById(R.id.htmlUrl); + image = itemView.findViewById(R.id.imageAvatar); + repoStars = itemView.findViewById(R.id.repoStars); + repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated); itemView.setOnClickListener(v -> { Context context = v.getContext(); + TinyDB tinyDb = TinyDB.getInstance(context); 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", repoFullName.getText().toString()); - tinyDb.putString("repoType", repoType.getText().toString()); + tinyDb.putString("repoFullName", userRepositories.getFullName()); //tinyDb.putBoolean("resumeIssues", true); 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 repoName = parts[1]; @@ -113,13 +105,11 @@ public class MyReposListAdapter extends RecyclerView.Adapter { - - 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 reposListMain) { + public MyReposListAdapter(Context ctx, List reposListMain) { - this.mCtx = mCtx; + this.context = ctx; this.reposList = reposListMain; reposListFull = new ArrayList<>(reposList); } @@ -262,10 +184,16 @@ public class MyReposListAdapter extends RecyclerView.Adapter { - private Context context; - private List notificationThreads; - private OnMoreClickedListener onMoreClickedListener; - private OnNotificationClickedListener onNotificationClickedListener; - private TinyDB tinyDb; + private final Context context; + private final List notificationThreads; + private final OnMoreClickedListener onMoreClickedListener; + private final OnNotificationClickedListener onNotificationClickedListener; + private final TinyDB tinyDb; public NotificationsAdapter(Context context, List notificationThreads, OnMoreClickedListener onMoreClickedListener, OnNotificationClickedListener onNotificationClickedListener) { @@ -37,19 +37,18 @@ public class NotificationsAdapter extends RecyclerView.Adapter onMoreClickedListener.onMoreClicked(notificationThread)); - } @Override diff --git a/app/src/main/java/org/mian/gitnex/adapters/OrganizationsListAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/OrganizationsListAdapter.java index 73f79096..38bcc2d7 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/OrganizationsListAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/OrganizationsListAdapter.java @@ -16,6 +16,7 @@ import org.gitnex.tea4j.models.UserOrganizations; import org.mian.gitnex.R; import org.mian.gitnex.activities.OrganizationDetailActivity; import org.mian.gitnex.clients.PicassoService; +import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.TinyDB; import java.util.ArrayList; @@ -27,42 +28,42 @@ import java.util.List; public class OrganizationsListAdapter extends RecyclerView.Adapter implements Filterable { - private List orgList; - private Context mCtx; - private List orgListFull; + private final List orgList; + private final Context context; + private final List orgListFull; static class OrganizationsViewHolder extends RecyclerView.ViewHolder { - private ImageView image; - private TextView mTextView1; - private TextView mTextView2; - private TextView organizationId; + private UserOrganizations userOrganizations; + + private final ImageView image; + private final TextView orgName; + private final TextView orgDescription; private OrganizationsViewHolder(View itemView) { super(itemView); - mTextView1 = itemView.findViewById(R.id.orgUsername); - mTextView2 = itemView.findViewById(R.id.orgDescription); + orgName = itemView.findViewById(R.id.orgName); + orgDescription = itemView.findViewById(R.id.orgDescription); image = itemView.findViewById(R.id.imageAvatar); - organizationId = itemView.findViewById(R.id.organizationId); itemView.setOnClickListener(v -> { Context context = v.getContext(); Intent intent = new Intent(context, OrganizationDetailActivity.class); - intent.putExtra("orgName", mTextView1.getText().toString()); + intent.putExtra("orgName", userOrganizations.getUsername()); TinyDB tinyDb = TinyDB.getInstance(context); - tinyDb.putString("orgName", mTextView1.getText().toString()); - tinyDb.putString("organizationId", organizationId.getText().toString()); + tinyDb.putString("orgName", userOrganizations.getUsername()); + tinyDb.putString("organizationId", String.valueOf(userOrganizations.getId())); tinyDb.putBoolean("organizationAction", true); context.startActivity(intent); }); } } - public OrganizationsListAdapter(Context mCtx, List orgsListMain) { + public OrganizationsListAdapter(Context ctx, List orgsListMain) { - this.mCtx = mCtx; + this.context = ctx; this.orgList = orgsListMain; orgListFull = new ArrayList<>(orgList); } @@ -80,16 +81,16 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter { - private List emailsList; - private Context mCtx; + private final List emailsList; + private final Context context; static class EmailsViewHolder extends RecyclerView.ViewHolder { - private ImageView emailPrimary; - private TextView userEmail; + private final ImageView emailPrimary; + private final TextView userEmail; private EmailsViewHolder(View itemView) { super(itemView); @@ -37,8 +37,8 @@ public class ProfileEmailsAdapter extends RecyclerView.Adapter emailsListMain) { - this.mCtx = mCtx; + public ProfileEmailsAdapter(Context ctx, List emailsListMain) { + this.context = ctx; this.emailsList = emailsListMain; } @@ -59,12 +59,12 @@ public class ProfileEmailsAdapter extends RecyclerView.Adapter { private final List followersList; - private final Context mCtx; + private final Context context; static class FollowersViewHolder extends RecyclerView.ViewHolder { @@ -50,9 +50,9 @@ public class ProfileFollowersAdapter extends RecyclerView.Adapter followersListMain) { + public ProfileFollowersAdapter(Context ctx, List followersListMain) { - this.mCtx = mCtx; + this.context = ctx; this.followersList = followersListMain; } @@ -68,21 +68,20 @@ public class ProfileFollowersAdapter extends RecyclerView.Adapter { private final List followingList; - private final Context mCtx; + private final Context context; static class FollowingViewHolder extends RecyclerView.ViewHolder { @@ -50,9 +50,9 @@ public class ProfileFollowingAdapter extends RecyclerView.Adapter followingListMain) { + public ProfileFollowingAdapter(Context ctx, List followingListMain) { - this.mCtx = mCtx; + this.context = ctx; this.followingList = followingListMain; } @@ -68,21 +68,20 @@ public class ProfileFollowingAdapter extends RecyclerView.Adapter { - - 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 -> { + itemView.setOnClickListener(v -> { Context context = v.getContext(); @@ -184,11 +149,12 @@ public class PullRequestsAdapter extends RecyclerView.Adapter list) { diff --git a/app/src/main/java/org/mian/gitnex/adapters/ReleasesAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/ReleasesAdapter.java index 58287007..03ea3a70 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/ReleasesAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/ReleasesAdapter.java @@ -7,7 +7,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.RelativeLayout; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.core.text.HtmlCompat; @@ -16,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView; import org.gitnex.tea4j.models.Releases; import org.mian.gitnex.R; import org.mian.gitnex.clients.PicassoService; +import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.ClickListener; import org.mian.gitnex.helpers.Markdown; import org.mian.gitnex.helpers.RoundedTransformation; @@ -30,25 +30,24 @@ import java.util.Locale; public class ReleasesAdapter extends RecyclerView.Adapter { - private List releasesList; - private Context mCtx; + private final List releasesList; + private final Context context; static class ReleasesViewHolder extends RecyclerView.ViewHolder { - private TextView releaseType; - private TextView releaseName; - private ImageView authorAvatar; - private TextView authorName; - private TextView releaseTag; - private TextView releaseCommitSha; - private TextView releaseDate; - private TextView releaseBodyContent; - private LinearLayout downloadFrame; - private RelativeLayout downloads; - private TextView releaseZipDownload; - private TextView releaseTarDownload; - private ImageView downloadDropdownIcon; - private RecyclerView downloadList; + private final TextView releaseType; + private final TextView releaseName; + private final ImageView authorAvatar; + private final TextView authorName; + private final TextView releaseTag; + private final TextView releaseDate; + private final TextView releaseBodyContent; + private final LinearLayout downloadFrame; + private final LinearLayout downloads; + private final TextView releaseZipDownload; + private final TextView releaseTarDownload; + private final ImageView downloadDropdownIcon; + private final RecyclerView downloadList; private ReleasesViewHolder(View itemView) { @@ -59,7 +58,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter releasesMain) { - this.mCtx = mCtx; + public ReleasesAdapter(Context ctx, List releasesMain) { + this.context = ctx; this.releasesList = releasesMain; } @@ -90,9 +88,10 @@ public class ReleasesAdapter extends RecyclerView.Adapter" + mCtx.getResources().getString(R.string.zipArchiveDownloadReleasesTab) + " ", HtmlCompat.FROM_HTML_MODE_LEGACY)); + HtmlCompat.fromHtml("" + context.getResources().getString(R.string.zipArchiveDownloadReleasesTab) + " ", HtmlCompat.FROM_HTML_MODE_LEGACY)); holder.releaseZipDownload.setMovementMethod(LinkMovementMethod.getInstance()); holder.releaseTarDownload.setText( - HtmlCompat.fromHtml("" + mCtx.getResources().getString(R.string.tarArchiveDownloadReleasesTab) + " ", HtmlCompat.FROM_HTML_MODE_LEGACY)); + HtmlCompat.fromHtml("" + context.getResources().getString(R.string.tarArchiveDownloadReleasesTab) + " ", HtmlCompat.FROM_HTML_MODE_LEGACY)); holder.releaseTarDownload.setMovementMethod(LinkMovementMethod.getInstance()); ReleasesDownloadsAdapter adapter = new ReleasesDownloadsAdapter(currentItem.getAssets()); holder.downloadList.setAdapter(adapter); - } @Override diff --git a/app/src/main/java/org/mian/gitnex/adapters/ReleasesDownloadsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/ReleasesDownloadsAdapter.java index da4cd67b..77a6e2e7 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/ReleasesDownloadsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/ReleasesDownloadsAdapter.java @@ -18,18 +18,16 @@ import java.util.List; public class ReleasesDownloadsAdapter extends RecyclerView.Adapter { - private List releasesDownloadsList; + private final List releasesDownloadsList; static class ReleasesDownloadsViewHolder extends RecyclerView.ViewHolder { - private TextView downloadName; + private final TextView downloadName; private ReleasesDownloadsViewHolder(View itemView) { super(itemView); - downloadName = itemView.findViewById(R.id.downloadName); - } } @@ -57,7 +55,6 @@ public class ReleasesDownloadsAdapter extends RecyclerView.Adapter { - private Context ctx; + private final Context context; private final int TYPE_LOAD = 0; private List forksList; private OnLoadMoreListener loadMoreListener; @@ -50,16 +51,15 @@ public class RepoForksAdapter extends RecyclerView.Adapter forksListMain) { - this.ctx = ctx; + this.context = ctx; this.forksList = forksListMain; - } @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - LayoutInflater inflater = LayoutInflater.from(ctx); + LayoutInflater inflater = LayoutInflater.from(context); if(viewType == TYPE_LOAD) { return new RepoForksAdapter.ForksHolder(inflater.inflate(R.layout.list_repositories, parent, false)); @@ -67,7 +67,6 @@ public class RepoForksAdapter extends RecyclerView.Adapter { 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.putExtra("repoFullName", repoFullName.getText().toString()); + intent.putExtra("repoFullName", userRepositories.getFullName()); - TinyDB tinyDb = TinyDB.getInstance(context); - tinyDb.putString("repoFullName", repoFullName.getText().toString()); - tinyDb.putString("repoType", repoType_.getText().toString()); + tinyDb.putString("repoFullName", userRepositories.getFullName()); //tinyDb.putBoolean("resumeIssues", true); 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 repoName = parts[1]; @@ -232,13 +229,11 @@ public class RepoForksAdapter extends RecyclerView.Adapter { - - 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 list) { diff --git a/app/src/main/java/org/mian/gitnex/adapters/RepoStargazersAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/RepoStargazersAdapter.java index 02e63c8b..1b3b6973 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/RepoStargazersAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/RepoStargazersAdapter.java @@ -12,6 +12,7 @@ import android.widget.TextView; import org.gitnex.tea4j.models.UserInfo; import org.mian.gitnex.R; import org.mian.gitnex.clients.PicassoService; +import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.TinyDB; import java.util.List; @@ -22,13 +23,13 @@ import java.util.List; public class RepoStargazersAdapter extends BaseAdapter { - private List stargazersList; - private Context mCtx; + private final List stargazersList; + private final Context context; private static class ViewHolder { - private ImageView memberAvatar; - private TextView memberName; + private final ImageView memberAvatar; + private final TextView memberName; ViewHolder(View v) { memberAvatar = v.findViewById(R.id.memberAvatar); @@ -36,8 +37,8 @@ public class RepoStargazersAdapter extends BaseAdapter { } } - public RepoStargazersAdapter(Context mCtx, List membersListMain) { - this.mCtx = mCtx; + public RepoStargazersAdapter(Context ctx, List membersListMain) { + this.context = ctx; this.stargazersList = membersListMain; } @@ -63,7 +64,7 @@ public class RepoStargazersAdapter extends BaseAdapter { RepoStargazersAdapter.ViewHolder viewHolder; 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); finalView.setTag(viewHolder); } @@ -79,23 +80,25 @@ public class RepoStargazersAdapter extends BaseAdapter { private void initData(RepoStargazersAdapter.ViewHolder viewHolder, int 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; switch(tinyDb.getInt("customFontId", -1)) { case 0: - myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf"); + myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/roboto.ttf"); break; case 2: - myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf"); + myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/sourcecodeproregular.ttf"); break; default: - myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf"); + myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/manroperegular.ttf"); break; } diff --git a/app/src/main/java/org/mian/gitnex/adapters/RepoWatchersAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/RepoWatchersAdapter.java index e774b42b..184a43a9 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/RepoWatchersAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/RepoWatchersAdapter.java @@ -12,6 +12,7 @@ import android.widget.TextView; import org.gitnex.tea4j.models.UserInfo; import org.mian.gitnex.R; import org.mian.gitnex.clients.PicassoService; +import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.TinyDB; import java.util.List; @@ -22,13 +23,13 @@ import java.util.List; public class RepoWatchersAdapter extends BaseAdapter { - private List watchersList; - private Context mCtx; + private final List watchersList; + private final Context context; private static class ViewHolder { - private ImageView memberAvatar; - private TextView memberName; + private final ImageView memberAvatar; + private final TextView memberName; ViewHolder(View v) { memberAvatar = v.findViewById(R.id.memberAvatar); @@ -36,8 +37,8 @@ public class RepoWatchersAdapter extends BaseAdapter { } } - public RepoWatchersAdapter(Context mCtx, List membersListMain) { - this.mCtx = mCtx; + public RepoWatchersAdapter(Context ctx, List membersListMain) { + this.context = ctx; this.watchersList = membersListMain; } @@ -63,7 +64,7 @@ public class RepoWatchersAdapter extends BaseAdapter { RepoWatchersAdapter.ViewHolder viewHolder; 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); finalView.setTag(viewHolder); } @@ -79,23 +80,25 @@ public class RepoWatchersAdapter extends BaseAdapter { private void initData(RepoWatchersAdapter.ViewHolder viewHolder, int 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; switch(tinyDb.getInt("customFontId", -1)) { case 0: - myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf"); + myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/roboto.ttf"); break; case 2: - myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf"); + myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/sourcecodeproregular.ttf"); break; default: - myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf"); + myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/manroperegular.ttf"); break; } diff --git a/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java index 0069e224..360061f9 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java @@ -1,8 +1,5 @@ package org.mian.gitnex.adapters; -import android.annotation.SuppressLint; -import android.content.ClipData; -import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; import android.graphics.Typeface; @@ -13,31 +10,31 @@ import android.widget.CheckBox; import android.widget.Filter; import android.widget.Filterable; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.util.ColorGenerator; -import com.google.android.material.bottomsheet.BottomSheetDialog; import org.gitnex.tea4j.models.UserRepositories; import org.gitnex.tea4j.models.WatchInfo; import org.mian.gitnex.R; -import org.mian.gitnex.activities.OpenRepoInBrowserActivity; 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.RetrofitClient; import org.mian.gitnex.database.api.RepositoriesApi; 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.TimeHelper; import org.mian.gitnex.helpers.TinyDB; 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.List; -import java.util.Objects; +import java.util.Locale; import retrofit2.Call; import retrofit2.Callback; @@ -47,61 +44,54 @@ import retrofit2.Callback; public class ReposListAdapter extends RecyclerView.Adapter implements Filterable { - private List reposList; - private Context mCtx; - private List reposListFull; + private final List reposList; + private final Context context; + private final List reposListFull; static class ReposViewHolder extends RecyclerView.ViewHolder { - private ImageView image; - private TextView repoName; - private TextView repoDescription; - private TextView fullName; + private UserRepositories userRepositories; + + private final ImageView image; + private final TextView repoName; + private final TextView orgName; + private final TextView repoDescription; private CheckBox isRepoAdmin; - private ImageView repoPrivatePublic; - private TextView repoStars; - private TextView repoForks; - private TextView repoOpenIssuesCount; - private TextView repoType; - private LinearLayout archiveRepo; - private TextView repoBranch; - private TextView htmlUrl; + private final TextView repoStars; + private final TextView repoLastUpdated; private ReposViewHolder(View itemView) { super(itemView); repoName = itemView.findViewById(R.id.repoName); + orgName = itemView.findViewById(R.id.orgName); repoDescription = itemView.findViewById(R.id.repoDescription); isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin); image = itemView.findViewById(R.id.imageAvatar); - fullName = 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); - archiveRepo = itemView.findViewById(R.id.archiveRepoFrame); - repoBranch = itemView.findViewById(R.id.repoBranch); - htmlUrl = itemView.findViewById(R.id.htmlUrl); + repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated); itemView.setOnClickListener(v -> { Context context = v.getContext(); - TextView repoFullName = v.findViewById(R.id.repoFullName); - TextView repoType_ = v.findViewById(R.id.repoType); + TinyDB tinyDb = TinyDB.getInstance(context); 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", repoFullName.getText().toString()); - tinyDb.putString("repoType", repoType_.getText().toString()); + tinyDb.putString("repoFullName", userRepositories.getFullName()); //tinyDb.putBoolean("resumeIssues", true); 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 repoName = parts[1]; @@ -115,13 +105,11 @@ public class ReposListAdapter extends RecyclerView.Adapter { - - 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 reposListMain) { + public ReposListAdapter(Context ctx, List reposListMain) { - this.mCtx = mCtx; + this.context = ctx; this.reposList = reposListMain; reposListFull = new ArrayList<>(reposList); } @@ -263,20 +183,26 @@ public class ReposListAdapter extends RecyclerView.Adapter implements Filterable { - private List reposList; - private Context mCtx; - private List reposListFull; + private final List reposList; + private final Context context; + private final List reposListFull; static class OrgReposViewHolder extends RecyclerView.ViewHolder { - private ImageView image; - private TextView repoName; - private TextView repoDescription; - private TextView fullName; - private CheckBox isRepoAdmin; - private ImageView repoPrivatePublic; - private TextView repoStars; - private TextView repoForks; - private TextView repoOpenIssuesCount; - private TextView repoType; - private LinearLayout archiveRepo; - private TextView repoBranch; - private TextView htmlUrl; + private UserRepositories userRepositories; + + private final ImageView image; + private final TextView repoName; + private final TextView orgName; + private final TextView repoDescription; + private CheckBox isRepoAdmin; + private final TextView repoStars; + private final TextView repoLastUpdated; private OrgReposViewHolder(View itemView) { - super(itemView); - repoName = itemView.findViewById(R.id.repoName); - repoDescription = itemView.findViewById(R.id.repoDescription); - isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin); - image = itemView.findViewById(R.id.imageAvatar); - fullName = 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); - archiveRepo = itemView.findViewById(R.id.archiveRepoFrame); - repoBranch = itemView.findViewById(R.id.repoBranch); - htmlUrl = itemView.findViewById(R.id.htmlUrl); + + super(itemView); + repoName = itemView.findViewById(R.id.repoName); + orgName = itemView.findViewById(R.id.orgName); + repoDescription = itemView.findViewById(R.id.repoDescription); + isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin); + image = itemView.findViewById(R.id.imageAvatar); + repoStars = itemView.findViewById(R.id.repoStars); + repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated); itemView.setOnClickListener(v -> { Context context = v.getContext(); + TinyDB tinyDb = TinyDB.getInstance(context); 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", fullName.getText().toString()); - tinyDb.putString("repoType", repoType.getText().toString()); + tinyDb.putString("repoFullName", userRepositories.getFullName()); //tinyDb.putBoolean("resumeIssues", true); 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 repoName = parts[1]; @@ -112,13 +105,11 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter { - - 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 reposListMain) { - this.mCtx = mCtx; + public RepositoriesByOrgAdapter(Context ctx, List reposListMain) { + + this.context = ctx; this.reposList = reposListMain; reposListFull = new ArrayList<>(reposList); } @@ -249,6 +172,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter { private final List searchedList; - private final Context mCtx; + private final Context context; private final TinyDB tinyDb; - public SearchIssuesAdapter(List dataList, Context mCtx) { + public SearchIssuesAdapter(List dataList, Context ctx) { - this.mCtx = mCtx; + this.context = ctx; this.searchedList = dataList; - this.tinyDb = TinyDB.getInstance(mCtx); + this.tinyDb = TinyDB.getInstance(context); } class SearchViewHolder extends RecyclerView.ViewHolder { @@ -63,7 +63,7 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter { + itemView.setOnClickListener(v -> { Context context = v.getContext(); @@ -121,19 +121,20 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter" + currentItem.getRepository().getFull_name() + mCtx.getResources().getString(R.string.hash) + currentItem.getNumber() + ""; + String issueNumber_ = "" + currentItem.getRepository().getFull_name() + context.getResources().getString(R.string.hash) + currentItem.getNumber() + ""; holder.issue = currentItem; holder.issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + currentItem.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); @@ -144,17 +145,17 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter { - - private List 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 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(); - } - -} diff --git a/app/src/main/java/org/mian/gitnex/adapters/StarredReposListAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/StarredReposListAdapter.java index 947f3d01..3ebf5bd8 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/StarredReposListAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/StarredReposListAdapter.java @@ -1,8 +1,5 @@ package org.mian.gitnex.adapters; -import android.annotation.SuppressLint; -import android.content.ClipData; -import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; import android.graphics.Typeface; @@ -13,31 +10,31 @@ import android.widget.CheckBox; import android.widget.Filter; import android.widget.Filterable; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.util.ColorGenerator; -import com.google.android.material.bottomsheet.BottomSheetDialog; import org.gitnex.tea4j.models.UserRepositories; import org.gitnex.tea4j.models.WatchInfo; import org.mian.gitnex.R; -import org.mian.gitnex.activities.OpenRepoInBrowserActivity; 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.RetrofitClient; import org.mian.gitnex.database.api.RepositoriesApi; 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.TimeHelper; import org.mian.gitnex.helpers.TinyDB; 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.List; -import java.util.Objects; +import java.util.Locale; import retrofit2.Call; import retrofit2.Callback; @@ -47,58 +44,54 @@ import retrofit2.Callback; public class StarredReposListAdapter extends RecyclerView.Adapter implements Filterable { - private List reposList; - private Context mCtx; - private List reposListFull; + private final List reposList; + private final Context context; + private final List reposListFull; static class StarredReposViewHolder extends RecyclerView.ViewHolder { - private ImageView image; - private TextView repoName; - private TextView repoDescription; - private TextView fullName; - private CheckBox isRepoAdmin; - private ImageView repoPrivatePublic; - private TextView repoStars; - private TextView repoForks; - private TextView repoOpenIssuesCount; - private TextView repoType; - private LinearLayout archiveRepo; - private TextView repoBranch; - private TextView htmlUrl; + private UserRepositories userRepositories; + + private final ImageView image; + private final TextView repoName; + private final TextView orgName; + private final TextView repoDescription; + private CheckBox isRepoAdmin; + private final TextView repoStars; + private final TextView repoLastUpdated; private StarredReposViewHolder(View itemView) { - super(itemView); - repoName = itemView.findViewById(R.id.repoName); - repoDescription = itemView.findViewById(R.id.repoDescription); - isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin); - image = itemView.findViewById(R.id.imageAvatar); - fullName = 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); - archiveRepo = itemView.findViewById(R.id.archiveRepoFrame); - repoBranch = itemView.findViewById(R.id.repoBranch); - htmlUrl = itemView.findViewById(R.id.htmlUrl); + + super(itemView); + repoName = itemView.findViewById(R.id.repoName); + orgName = itemView.findViewById(R.id.orgName); + repoDescription = itemView.findViewById(R.id.repoDescription); + isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin); + image = itemView.findViewById(R.id.imageAvatar); + repoStars = itemView.findViewById(R.id.repoStars); + repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated); itemView.setOnClickListener(v -> { Context context = v.getContext(); + TinyDB tinyDb = TinyDB.getInstance(context); 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", fullName.getText().toString()); - tinyDb.putString("repoType", repoType.getText().toString()); + tinyDb.putString("repoFullName", userRepositories.getFullName()); //tinyDb.putBoolean("resumeIssues", true); 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 repoName = parts[1]; @@ -112,13 +105,11 @@ public class StarredReposListAdapter extends RecyclerView.Adapter { - - 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 reposListMain) { - this.mCtx = mCtx; + public StarredReposListAdapter(Context ctx, List reposListMain) { + this.context = ctx; this.reposList = reposListMain; reposListFull = new ArrayList<>(reposList); } @@ -259,10 +181,16 @@ public class StarredReposListAdapter extends RecyclerView.Adapter filteredList = new ArrayList<>(); diff --git a/app/src/main/java/org/mian/gitnex/adapters/TeamMembersByOrgAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/TeamMembersByOrgAdapter.java index 78627007..b818f515 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/TeamMembersByOrgAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/TeamMembersByOrgAdapter.java @@ -25,7 +25,7 @@ import java.util.List; public class TeamMembersByOrgAdapter extends BaseAdapter { private final List teamMembersList; - private final Context mCtx; + private final Context context; private static class ViewHolder { @@ -48,9 +48,9 @@ public class TeamMembersByOrgAdapter extends BaseAdapter { } } - public TeamMembersByOrgAdapter(Context mCtx, List membersListMain) { + public TeamMembersByOrgAdapter(Context ctx, List membersListMain) { - this.mCtx = mCtx; + this.context = ctx; this.teamMembersList = membersListMain; } @@ -77,7 +77,7 @@ public class TeamMembersByOrgAdapter extends BaseAdapter { 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); finalView.setTag(viewHolder); } @@ -93,25 +93,27 @@ public class TeamMembersByOrgAdapter extends BaseAdapter { private void initData(TeamMembersByOrgAdapter.ViewHolder viewHolder, int 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(); - final TinyDB tinyDb = TinyDB.getInstance(mCtx); + final TinyDB tinyDb = TinyDB.getInstance(context); Typeface myTypeface; switch(tinyDb.getInt("customFontId", -1)) { case 0: - myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf"); + myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/roboto.ttf"); break; case 2: - myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf"); + myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/sourcecodeproregular.ttf"); break; default: - myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf"); + myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/manroperegular.ttf"); break; } diff --git a/app/src/main/java/org/mian/gitnex/adapters/TeamsByOrgAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/TeamsByOrgAdapter.java index 2582535d..25030a8c 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/TeamsByOrgAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/TeamsByOrgAdapter.java @@ -22,44 +22,41 @@ import java.util.List; public class TeamsByOrgAdapter extends RecyclerView.Adapter implements Filterable { - private List teamList; - private Context mCtx; - private List teamListFull; + private final List teamList; + private final Context context; + private final List teamListFull; static class OrgTeamsViewHolder extends RecyclerView.ViewHolder { - private TextView teamTitle; - private TextView teamId; - private TextView teamDescription; - private TextView teamPermission; + private Teams teams; + + private final TextView teamTitle; + private final TextView teamDescription; + private final TextView teamPermission; private OrgTeamsViewHolder(View itemView) { + super(itemView); teamTitle = itemView.findViewById(R.id.teamTitle); - teamId = itemView.findViewById(R.id.teamId); teamDescription = itemView.findViewById(R.id.teamDescription); teamPermission = itemView.findViewById(R.id.teamPermission); - itemView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { + itemView.setOnClickListener(v -> { - Context context = v.getContext(); + Context context = v.getContext(); - Intent intent = new Intent(context, OrganizationTeamMembersActivity.class); - intent.putExtra("teamTitle", teamTitle.getText().toString()); - intent.putExtra("teamId", teamId.getText().toString()); - context.startActivity(intent); - - } + Intent intent = new Intent(context, OrganizationTeamMembersActivity.class); + intent.putExtra("teamTitle", teams.getName()); + intent.putExtra("teamId", String.valueOf(teams.getId())); + context.startActivity(intent); }); } } - public TeamsByOrgAdapter(Context mCtx, List teamListMain) { - this.mCtx = mCtx; + public TeamsByOrgAdapter(Context ctx, List teamListMain) { + this.context = ctx; this.teamList = teamListMain; teamListFull = new ArrayList<>(teamList); } @@ -75,8 +72,10 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter filteredList = new ArrayList<>(); diff --git a/app/src/main/java/org/mian/gitnex/adapters/UserAccountsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/UserAccountsAdapter.java index 6849e929..d698b997 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/UserAccountsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/UserAccountsAdapter.java @@ -16,6 +16,7 @@ import org.mian.gitnex.R; import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.database.api.UserAccountsApi; import org.mian.gitnex.database.models.UserAccount; +import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.Toasty; @@ -29,7 +30,7 @@ import io.mikael.urlbuilder.UrlBuilder; public class UserAccountsAdapter extends RecyclerView.Adapter { private final List userAccountsList; - private final Context mCtx; + private final Context context; private TinyDB tinyDB; class UserAccountsViewHolder extends RecyclerView.ViewHolder { @@ -55,22 +56,22 @@ public class UserAccountsAdapter extends RecyclerView.Adapter { - new AlertDialog.Builder(mCtx) - .setIcon(AppCompatResources.getDrawable(mCtx, R.drawable.ic_delete)) - .setTitle(mCtx.getResources().getString(R.string.removeAccountPopupTitle)) - .setMessage(mCtx.getResources().getString(R.string.removeAccountPopupMessage)) - .setPositiveButton(mCtx.getResources().getString(R.string.removeButton), (dialog, which) -> { + new AlertDialog.Builder(context) + .setIcon(AppCompatResources.getDrawable(context, R.drawable.ic_delete)) + .setTitle(context.getResources().getString(R.string.removeAccountPopupTitle)) + .setMessage(context.getResources().getString(R.string.removeAccountPopupMessage)) + .setPositiveButton(context.getResources().getString(R.string.removeButton), (dialog, which) -> { updateLayoutByPosition(getAdapterPosition()); - UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx); + UserAccountsApi userAccountsApi = new UserAccountsApi(context); userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId))); - }).setNeutralButton(mCtx.getResources().getString(R.string.cancelButton), null) + }).setNeutralButton(context.getResources().getString(R.string.cancelButton), null) .show(); }); itemView.setOnClickListener(switchAccount -> { - UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx); + UserAccountsApi userAccountsApi = new UserAccountsApi(context); UserAccount userAccount = userAccountsApi.getAccountData(accountName); if(tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) { @@ -85,8 +86,8 @@ public class UserAccountsAdapter extends RecyclerView.Adapter userAccountsListMain) { + public UserAccountsAdapter(Context ctx, List userAccountsListMain) { - this.mCtx = mCtx; + this.context = ctx; this.userAccountsList = userAccountsListMain; } @@ -106,7 +107,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter { - private final Context mCtx; + private final Context context; private final TinyDB tinyDB; private final List userAccounts; - public UserAccountsListDialogAdapter(@NonNull Context mCtx, int resource, @NonNull List userAccounts) { + public UserAccountsListDialogAdapter(@NonNull Context ctx, int resource, @NonNull List userAccounts) { - super(mCtx, resource, userAccounts); + super(ctx, resource, userAccounts); - tinyDB = TinyDB.getInstance(mCtx); + tinyDB = TinyDB.getInstance(ctx); this.userAccounts = userAccounts; - this.mCtx = mCtx; - + this.context = ctx; } @NonNull @@ -42,7 +42,7 @@ public class UserAccountsListDialogAdapter extends ArrayAdapter { public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { 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); @@ -51,6 +51,7 @@ public class UserAccountsListDialogAdapter extends ArrayAdapter { ImageView activeAccount = convertView.findViewById(R.id.activeAccount); UserAccount currentItem = userAccounts.get(position); + int imgRadius = AppUtil.getPixelsFromDensity(context, 3); String url = UrlBuilder.fromString(currentItem.getInstanceUrl()) .withPath("/") @@ -67,7 +68,7 @@ public class UserAccountsListDialogAdapter extends ArrayAdapter { } 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; diff --git a/app/src/main/java/org/mian/gitnex/adapters/UserAccountsNavAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/UserAccountsNavAdapter.java index f09f6fa7..7db88c76 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/UserAccountsNavAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/UserAccountsNavAdapter.java @@ -21,6 +21,7 @@ import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.database.api.UserAccountsApi; import org.mian.gitnex.database.models.UserAccount; import org.mian.gitnex.fragments.UserAccountsFragment; +import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.Toasty; @@ -34,13 +35,13 @@ import io.mikael.urlbuilder.UrlBuilder; public class UserAccountsNavAdapter extends RecyclerView.Adapter { private static DrawerLayout drawer; - private List userAccountsList; - private Context mCtx; - private TextView toolbarTitle; + private final List userAccountsList; + private final Context context; + private final TextView toolbarTitle; - public UserAccountsNavAdapter(Context mCtx, List userAccountsListMain, DrawerLayout drawerLayout, TextView toolbarTitle) { + public UserAccountsNavAdapter(Context ctx, List userAccountsListMain, DrawerLayout drawerLayout, TextView toolbarTitle) { - this.mCtx = mCtx; + this.context = ctx; this.userAccountsList = userAccountsListMain; drawer = drawerLayout; this.toolbarTitle = toolbarTitle; @@ -48,7 +49,7 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter { - customDialogUserAccountsList(userAccountsList); drawer.closeDrawers(); }); @@ -84,8 +84,15 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter allAccountsList) { - TinyDB tinyDB = TinyDB.getInstance(mCtx); - Dialog dialog = new Dialog(mCtx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert); + TinyDB tinyDB = TinyDB.getInstance(context); + Dialog dialog = new Dialog(context, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert); dialog.setContentView(R.layout.custom_user_accounts_dialog); ListView listView = dialog.findViewById(R.id.accountsList); @@ -109,19 +116,19 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter { - toolbarTitle.setText(mCtx.getResources().getString(R.string.pageTitleUserAccounts)); - AppCompatActivity activity = (AppCompatActivity) mCtx; + toolbarTitle.setText(context.getResources().getString(R.string.pageTitleUserAccounts)); + AppCompatActivity activity = (AppCompatActivity) context; activity.getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new UserAccountsFragment()).commit(); 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.setOnItemClickListener((adapterView, view, which, l) -> { String accountNameSwitch = allAccountsList.get(which).getAccountName(); - UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx); + UserAccountsApi userAccountsApi = new UserAccountsApi(context); UserAccount userAccount = userAccountsApi.getAccountData(accountNameSwitch); if(tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) { @@ -136,8 +143,8 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter { - private List usersSearchList; - private Context mCtx; + private final List usersSearchList; + private final Context context; - public UserSearchAdapter(List dataList, Context mCtx) { - this.mCtx = mCtx; + public UserSearchAdapter(List dataList, Context ctx) { + this.context = ctx; this.usersSearchList = dataList; } static class UserSearchViewHolder extends RecyclerView.ViewHolder { - private ImageView userAvatar; - private TextView userFullName; - private TextView userName; - private TextView userNameMain; - private ImageView addCollaboratorButtonAdd; - private ImageView addCollaboratorButtonRemove; + private UserInfo userInfo; - 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; private UserSearchViewHolder(View itemView) { + super(itemView); userAvatar = itemView.findViewById(R.id.userAvatar); userFullName = itemView.findViewById(R.id.userFullName); userName = itemView.findViewById(R.id.userName); - userNameMain = itemView.findViewById(R.id.userNameMain); addCollaboratorButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd); addCollaboratorButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove); - addCollaboratorButtonAdd.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { + addCollaboratorButtonAdd.setOnClickListener(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.setSingleChoiceItems(permissionList, permissionSelectedChoice, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { + pBuilder.setTitle(R.string.newTeamPermission); + pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> { - } - }) - .setCancelable(false) - .setNegativeButton(R.string.cancelButton, null) - .setPositiveButton(R.string.addButton, new DialogInterface.OnClickListener() { + }) + .setCancelable(false) + .setNegativeButton(R.string.cancelButton, null) + .setPositiveButton(R.string.addButton, (dialog, which) -> { - @Override - public void onClick(DialogInterface dialog, int which) { + ListView lw = ((AlertDialog)dialog).getListView(); + Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition()); - ListView lw = ((AlertDialog)dialog).getListView(); - Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition()); + CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userInfo.getUsername()); + }); - CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userNameMain.getText().toString()); - - } - }); - - AlertDialog pDialog = pBuilder.create(); - pDialog.show(); - - } + AlertDialog pDialog = pBuilder.create(); + pDialog.show(); }); - addCollaboratorButtonRemove.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { + addCollaboratorButtonRemove.setOnClickListener(v -> { - Context context = v.getContext(); + Context context = v.getContext(); - AlertDialogs.collaboratorRemoveDialog(context, userNameMain.getText().toString(), - context.getResources().getString(R.string.removeCollaboratorTitle), - context.getResources().getString(R.string.removeCollaboratorMessage), - context.getResources().getString(R.string.removeButton), - context.getResources().getString(R.string.cancelButton), "fa"); - - } + AlertDialogs.collaboratorRemoveDialog(context, userInfo.getUsername(), + context.getResources().getString(R.string.removeCollaboratorTitle), + context.getResources().getString(R.string.removeCollaboratorMessage), + context.getResources().getString(R.string.removeButton), + context.getResources().getString(R.string.cancelButton), "fa"); }); } @@ -128,9 +113,9 @@ public class UserSearchAdapter extends RecyclerView.Adapter 0) { - TinyDB tinyDb = TinyDB.getInstance(mCtx); + TinyDB tinyDb = TinyDB.getInstance(context); final String loginUid = tinyDb.getString("loginUid"); String repoFullName = tinyDb.getString("repoFullName"); String[] parts = repoFullName.split("/"); @@ -157,8 +142,8 @@ public class UserSearchAdapter extends RecyclerView.Adapter call = RetrofitClient - .getApiInterface(mCtx) - .checkRepoCollaborator(Authorization.get(mCtx), repoOwner, repoName, currentItem.getUsername()); + .getApiInterface(context) + .checkRepoCollaborator(Authorization.get(context), repoOwner, repoName, currentItem.getUsername()); call.enqueue(new Callback() { diff --git a/app/src/main/java/org/mian/gitnex/adapters/UserSearchForTeamMemberAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/UserSearchForTeamMemberAdapter.java index 0be11de8..ad2ca677 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/UserSearchForTeamMemberAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/UserSearchForTeamMemberAdapter.java @@ -14,6 +14,7 @@ import org.mian.gitnex.R; import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.helpers.AlertDialogs; +import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.TinyDB; @@ -29,25 +30,25 @@ import retrofit2.Response; public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter { - private List usersSearchList; - private Context mCtx; - private int teamId; + private final List usersSearchList; + private final Context context; + private static int teamId; - public UserSearchForTeamMemberAdapter(List dataList, Context mCtx, int teamId) { - this.mCtx = mCtx; + public UserSearchForTeamMemberAdapter(List dataList, Context ctx, int teamId) { + this.context = ctx; this.usersSearchList = dataList; - this.teamId = teamId; + UserSearchForTeamMemberAdapter.teamId = teamId; } static class UserSearchViewHolder extends RecyclerView.ViewHolder { - private ImageView userAvatar; - private TextView userFullName; - private TextView userName; - private TextView userNameMain; - private ImageView addMemberButtonAdd; - private ImageView addMemberButtonRemove; - private TextView teamId_; + private UserInfo userInfo; + + private final ImageView userAvatar; + private final TextView userFullName; + private final TextView userName; + private final ImageView addMemberButtonAdd; + private final ImageView addMemberButtonRemove; private UserSearchViewHolder(View itemView) { @@ -55,35 +56,30 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter { 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.addTeamMemberMessage), 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 -> { 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.removeTeamMemberMessage), 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 0) { - TinyDB tinyDb = TinyDB.getInstance(mCtx); + TinyDB tinyDb = TinyDB.getInstance(context); final String loginUid = tinyDb.getString("loginUid"); String repoFullName = tinyDb.getString("repoFullName"); String[] parts = repoFullName.split("/"); final String repoOwner = parts[0]; - final String instanceToken = "token " + tinyDb.getString(loginUid + "-token"); Call call = RetrofitClient - .getApiInterface(mCtx) - .checkTeamMember(Authorization.get(mCtx), teamId, currentItem.getLogin()); + .getApiInterface(context) + .checkTeamMember(Authorization.get(context), teamId, currentItem.getLogin()); call.enqueue(new Callback() { @@ -167,8 +160,7 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter call, @NonNull Throwable t) { - Toasty.error(mCtx, mCtx.getResources().getString(R.string.genericServerResponseError)); - + Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError)); } }); diff --git a/app/src/main/java/org/mian/gitnex/fragments/BottomSheetReplyFragment.java b/app/src/main/java/org/mian/gitnex/fragments/BottomSheetReplyFragment.java index df04d66e..851075dd 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/BottomSheetReplyFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/BottomSheetReplyFragment.java @@ -19,6 +19,7 @@ import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import com.google.android.material.bottomsheet.BottomSheetBehavior; import com.google.android.material.bottomsheet.BottomSheetDialogFragment; +import com.vdurmont.emoji.EmojiParser; import org.mian.gitnex.R; import org.mian.gitnex.actions.ActionResult; import org.mian.gitnex.actions.IssueActions; @@ -61,7 +62,6 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment { repositoryId = (int) tinyDB.getLong("repositoryId", 0); currentActiveAccountId = tinyDB.getInt("currentActiveAccountId"); issueNumber = Integer.parseInt(tinyDB.getString("issueNumber")); - } @SuppressLint("ClickableViewAccessibility") @@ -87,7 +87,6 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment { send.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_save)); mode = Mode.EDIT; - } if(arguments.getString("draftId") != null) { @@ -97,7 +96,7 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment { if(!tinyDB.getString("issueTitle").isEmpty()) { - toolbarTitle.setText(tinyDB.getString("issueTitle")); + toolbarTitle.setText(EmojiParser.parseToUnicode(tinyDB.getString("issueTitle"))); } else if(arguments.getString("draftTitle") != null) { @@ -134,7 +133,6 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment { } return false; - }); comment.addTextChangedListener(new TextWatcher() { diff --git a/app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java index 29c853dd..88095d88 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java @@ -168,7 +168,6 @@ public class IssuesFragment extends Fragment { loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState")); tinyDb.putBoolean("resumeIssues", false); - } } @@ -191,14 +190,12 @@ public class IssuesFragment extends Fragment { issuesList.addAll(response.body()); adapter.notifyDataChanged(); noDataIssues.setVisibility(View.GONE); - } else { issuesList.clear(); adapter.notifyDataChanged(); noDataIssues.setVisibility(View.VISIBLE); - } mProgressBar.setVisibility(View.GONE); @@ -208,7 +205,6 @@ public class IssuesFragment extends Fragment { noDataIssues.setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.GONE); - } else { Log.e(TAG, String.valueOf(response.code())); @@ -311,7 +307,6 @@ public class IssuesFragment extends Fragment { filter(newText); return false; - } }); diff --git a/app/src/main/java/org/mian/gitnex/fragments/ProfileEmailsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/ProfileEmailsFragment.java index 181573ab..90101c4e 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/ProfileEmailsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/ProfileEmailsFragment.java @@ -74,11 +74,10 @@ public class ProfileEmailsFragment extends Fragment { noDataEmails = fragmentProfileEmailsBinding.noDataEmails; mRecyclerView = fragmentProfileEmailsBinding.recyclerView; + DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL); + mRecyclerView.setHasFixedSize(true); mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), - DividerItemDecoration.VERTICAL); mRecyclerView.addItemDecoration(dividerItemDecoration); mProgressBar = fragmentProfileEmailsBinding.progressBar; diff --git a/app/src/main/java/org/mian/gitnex/fragments/ProfileFollowersFragment.java b/app/src/main/java/org/mian/gitnex/fragments/ProfileFollowersFragment.java index 58d8a066..68d3ebaa 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/ProfileFollowersFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/ProfileFollowersFragment.java @@ -10,20 +10,16 @@ import android.view.ViewGroup; import android.widget.ProgressBar; import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; -import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; -import org.gitnex.tea4j.models.UserInfo; import org.mian.gitnex.adapters.ProfileFollowersAdapter; import org.mian.gitnex.databinding.FragmentProfileFollowersBinding; import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.viewmodels.ProfileFollowersViewModel; -import java.util.List; /** * Author M M Arif @@ -75,11 +71,10 @@ public class ProfileFollowersFragment extends Fragment { noDataFollowers = fragmentProfileFollowersBinding.noDataFollowers; mRecyclerView = fragmentProfileFollowersBinding.recyclerView; - mRecyclerView.setHasFixedSize(true); - mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL); - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), - DividerItemDecoration.VERTICAL); + mRecyclerView.setHasFixedSize(true); + mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); mRecyclerView.addItemDecoration(dividerItemDecoration); mProgressBar = fragmentProfileFollowersBinding.progressBar; @@ -100,21 +95,21 @@ public class ProfileFollowersFragment extends Fragment { ProfileFollowersViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowersViewModel.class); - pfModel.getFollowersList(instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer>() { - @Override - public void onChanged(@Nullable List pfListMain) { - adapter = new ProfileFollowersAdapter(getContext(), pfListMain); - if(adapter.getItemCount() > 0) { - mRecyclerView.setAdapter(adapter); - noDataFollowers.setVisibility(View.GONE); - } - else { - adapter.notifyDataSetChanged(); - mRecyclerView.setAdapter(adapter); - noDataFollowers.setVisibility(View.VISIBLE); - } - mProgressBar.setVisibility(View.GONE); + pfModel.getFollowersList(instanceToken, getContext()).observe(getViewLifecycleOwner(), pfListMain -> { + + adapter = new ProfileFollowersAdapter(getContext(), pfListMain); + + if(adapter.getItemCount() > 0) { + mRecyclerView.setAdapter(adapter); + noDataFollowers.setVisibility(View.GONE); } + else { + adapter.notifyDataSetChanged(); + mRecyclerView.setAdapter(adapter); + noDataFollowers.setVisibility(View.VISIBLE); + } + + mProgressBar.setVisibility(View.GONE); }); } diff --git a/app/src/main/java/org/mian/gitnex/fragments/ProfileFollowingFragment.java b/app/src/main/java/org/mian/gitnex/fragments/ProfileFollowingFragment.java index 8450fb89..7095e096 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/ProfileFollowingFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/ProfileFollowingFragment.java @@ -10,21 +10,17 @@ import android.view.ViewGroup; import android.widget.ProgressBar; import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; -import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; -import org.gitnex.tea4j.models.UserInfo; import org.mian.gitnex.adapters.ProfileFollowingAdapter; import org.mian.gitnex.databinding.FragmentProfileFollowingBinding; import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.viewmodels.ProfileFollowingViewModel; -import java.util.List; /** * Author M M Arif @@ -78,11 +74,10 @@ public class ProfileFollowingFragment extends Fragment { noDataFollowing = fragmentProfileFollowingBinding.noDataFollowing; mRecyclerView = fragmentProfileFollowingBinding.recyclerView; - mRecyclerView.setHasFixedSize(true); - mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL); - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), - DividerItemDecoration.VERTICAL); + mRecyclerView.setHasFixedSize(true); + mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); mRecyclerView.addItemDecoration(dividerItemDecoration); mProgressBar = fragmentProfileFollowingBinding.progressBar; @@ -103,21 +98,21 @@ public class ProfileFollowingFragment extends Fragment { ProfileFollowingViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowingViewModel.class); - pfModel.getFollowingList(instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer>() { - @Override - public void onChanged(@Nullable List pfListMain) { - adapter = new ProfileFollowingAdapter(getContext(), pfListMain); - if(adapter.getItemCount() > 0) { - mRecyclerView.setAdapter(adapter); - noDataFollowing.setVisibility(View.GONE); - } - else { - adapter.notifyDataSetChanged(); - mRecyclerView.setAdapter(adapter); - noDataFollowing.setVisibility(View.VISIBLE); - } - mProgressBar.setVisibility(View.GONE); + pfModel.getFollowingList(instanceToken, getContext()).observe(getViewLifecycleOwner(), pfListMain -> { + + adapter = new ProfileFollowingAdapter(getContext(), pfListMain); + + if(adapter.getItemCount() > 0) { + mRecyclerView.setAdapter(adapter); + noDataFollowing.setVisibility(View.GONE); } + else { + adapter.notifyDataSetChanged(); + mRecyclerView.setAdapter(adapter); + noDataFollowing.setVisibility(View.VISIBLE); + } + + mProgressBar.setVisibility(View.GONE); }); } diff --git a/app/src/main/java/org/mian/gitnex/fragments/ProfileFragment.java b/app/src/main/java/org/mian/gitnex/fragments/ProfileFragment.java index d6c45a00..4df62072 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/ProfileFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/ProfileFragment.java @@ -83,9 +83,11 @@ public class ProfileFragment extends Fragment { userFullName.setText(Html.fromHtml(tinyDb.getString("userFullname"))); userLogin.setText(getString(R.string.usernameWithAt, tinyDb.getString("userLogin"))); + int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 3); + PicassoService.getInstance(ctx).get() .load(tinyDb.getString("userAvatar")) - .transform(new RoundedTransformation(8, 0)) + .transform(new RoundedTransformation(avatarRadius, 0)) .placeholder(R.drawable.loader_animated) .resize(120, 120) .centerCrop().into(userAvatar); diff --git a/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java b/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java index ec0274a1..8d824157 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java @@ -40,8 +40,8 @@ public class RepoInfoFragment extends Fragment { private Context ctx; private LinearLayout pageContent; - private static String repoNameF = "param2"; - private static String repoOwnerF = "param1"; + private static final String repoNameF = "param2"; + private static final String repoOwnerF = "param1"; private FragmentRepoInfoBinding binding; @@ -284,6 +284,13 @@ public class RepoInfoFragment extends Fragment { tinyDb.putBoolean("hasPullRequests", false); } + if(repoInfo.isArchived()) { + binding.repoIsArchived.setVisibility(View.VISIBLE); + } + else { + binding.repoIsArchived.setVisibility(View.GONE); + } + tinyDb.putString("repoHtmlUrl", repoInfo.getHtml_url()); binding.progressBar.setVisibility(View.GONE); diff --git a/app/src/main/java/org/mian/gitnex/helpers/Markdown.java b/app/src/main/java/org/mian/gitnex/helpers/Markdown.java index 067e0b96..986661c7 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/Markdown.java +++ b/app/src/main/java/org/mian/gitnex/helpers/Markdown.java @@ -45,7 +45,7 @@ public class Markdown { private static final int MAX_POOL_SIZE = 45; 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); diff --git a/app/src/main/res/drawable/shape_files_diffs.xml b/app/src/main/res/drawable/shape_files_diffs.xml new file mode 100644 index 00000000..e1b20bb8 --- /dev/null +++ b/app/src/main/res/drawable/shape_files_diffs.xml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/app/src/main/res/layout/activity_issue_detail.xml b/app/src/main/res/layout/activity_issue_detail.xml index 297b5e5b..91defef7 100644 --- a/app/src/main/res/layout/activity_issue_detail.xml +++ b/app/src/main/res/layout/activity_issue_detail.xml @@ -96,9 +96,9 @@ + android:textSize="16sp" /> + android:textSize="14sp" /> + android:textSize="12sp" /> diff --git a/app/src/main/res/layout/bottom_sheet_repository_in_list.xml b/app/src/main/res/layout/bottom_sheet_repository_in_list.xml deleted file mode 100644 index bd3ddd38..00000000 --- a/app/src/main/res/layout/bottom_sheet_repository_in_list.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/credits.xml b/app/src/main/res/layout/credits.xml deleted file mode 100644 index 00f39d97..00000000 --- a/app/src/main/res/layout/credits.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/custom_user_accounts_dialog.xml b/app/src/main/res/layout/custom_user_accounts_dialog.xml index 873444ff..97110672 100644 --- a/app/src/main/res/layout/custom_user_accounts_dialog.xml +++ b/app/src/main/res/layout/custom_user_accounts_dialog.xml @@ -9,13 +9,13 @@ + android:layout_height="wrap_content" + android:padding="16dp" /> diff --git a/app/src/main/res/layout/custom_user_accounts_list.xml b/app/src/main/res/layout/custom_user_accounts_list.xml index 4809bf39..989a37ff 100644 --- a/app/src/main/res/layout/custom_user_accounts_list.xml +++ b/app/src/main/res/layout/custom_user_accounts_list.xml @@ -1,60 +1,62 @@ - + android:gravity="center_vertical" + android:orientation="horizontal" + android:padding="8dp"> + android:layout_width="@dimen/list_avatar_size" + android:layout_height="@dimen/list_avatar_size" + android:layout_marginEnd="10dp" + android:contentDescription="@string/generalImgContentText" + android:visibility="visible" /> + android:orientation="vertical"> + + + + + + + + - - + android:textSize="14sp" /> - - - + diff --git a/app/src/main/res/layout/fragment_drafts.xml b/app/src/main/res/layout/fragment_drafts.xml index c44508c6..4a4cb6fb 100644 --- a/app/src/main/res/layout/fragment_drafts.xml +++ b/app/src/main/res/layout/fragment_drafts.xml @@ -16,7 +16,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="?attr/primaryBackgroundColor" - android:padding="4dp" android:scrollbars="vertical" /> @@ -25,7 +24,7 @@ android:id="@+id/noData" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_margin="15dp" + android:layout_margin="16dp" android:text="@string/draftsListEmpty" android:textColor="?attr/primaryTextColor" android:gravity="center" diff --git a/app/src/main/res/layout/fragment_repo_info.xml b/app/src/main/res/layout/fragment_repo_info.xml index ada90506..d34a5831 100644 --- a/app/src/main/res/layout/fragment_repo_info.xml +++ b/app/src/main/res/layout/fragment_repo_info.xml @@ -57,6 +57,18 @@ android:layout_height="wrap_content" android:orientation="vertical"> + + @@ -43,28 +43,28 @@ android:id="@+id/userFullName" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="5dp" + android:layout_marginBottom="4dp" android:text="@string/userName" android:textColor="?attr/primaryTextColor" - android:textSize="16sp" /> + android:textSize="14sp" + android:textStyle="bold" /> + android:textSize="12sp" /> + android:textSize="12sp" /> diff --git a/app/src/main/res/layout/list_collaborators_search.xml b/app/src/main/res/layout/list_collaborators_search.xml index 574197c0..c6529f32 100644 --- a/app/src/main/res/layout/list_collaborators_search.xml +++ b/app/src/main/res/layout/list_collaborators_search.xml @@ -8,17 +8,11 @@ android:paddingEnd="20dp" android:background="?attr/primaryBackgroundColor" > - - @@ -36,7 +30,8 @@ android:layout_marginBottom="5dp" android:text="@string/userName" android:textColor="?attr/primaryTextColor" - android:textSize="16sp" /> + android:textSize="14sp" + android:textStyle="bold" /> + android:textSize="12sp" /> - - + android:orientation="vertical"> @@ -42,7 +43,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sizeCopy" - android:textColor="?attr/primaryTextColor" + android:textColor="?attr/hintColor" android:textSize="12sp" android:visibility="gone" tools:visibility="visible" /> diff --git a/app/src/main/res/layout/list_files_diffs.xml b/app/src/main/res/layout/list_files_diffs.xml index c18429c9..22e1b3ea 100644 --- a/app/src/main/res/layout/list_files_diffs.xml +++ b/app/src/main/res/layout/list_files_diffs.xml @@ -1,7 +1,6 @@ @@ -10,7 +9,7 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/header" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="?attr/primaryBackgroundColor" + android:background="@drawable/shape_files_diffs" android:orientation="vertical" android:paddingLeft="15dp" android:paddingTop="7dp" @@ -24,7 +23,7 @@ xmlns:tools="http://schemas.android.com/tools" android:ellipsize="start" android:fontFamily="monospace" android:singleLine="true" - android:textColor="?attr/primaryTextColor" + android:textColor="@color/colorWhite" android:textSize="16sp" /> @@ -83,7 +82,8 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_height="wrap_content" android:adjustViewBounds="true" android:scaleType="fitXY" - android:visibility="gone" /> + android:visibility="gone" + android:contentDescription="@string/generalImgContentText" /> @@ -38,7 +38,7 @@ android:ellipsize="middle" android:singleLine="true" android:textColor="?attr/primaryTextColor" - android:textSize="15sp" + android:textSize="14sp" android:textStyle="bold" /> + android:textSize="12sp" /> + android:textSize="14sp" /> diff --git a/app/src/main/res/layout/list_issues.xml b/app/src/main/res/layout/list_issues.xml index 09dfead1..4cc3ceeb 100644 --- a/app/src/main/res/layout/list_issues.xml +++ b/app/src/main/res/layout/list_issues.xml @@ -1,86 +1,95 @@ - - - + android:background="?android:attr/selectableItemBackground" + android:focusable="true"> + android:layout_marginBottom="8dp" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> + + + + + + + + + + + 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"> + + - - - - - - - - - - - - + android:textSize="14sp" + tools:text="50" /> - + diff --git a/app/src/main/res/layout/list_labels.xml b/app/src/main/res/layout/list_labels.xml index 2aeee088..496e342f 100644 --- a/app/src/main/res/layout/list_labels.xml +++ b/app/src/main/res/layout/list_labels.xml @@ -6,28 +6,7 @@ android:layout_height="wrap_content" android:background="?attr/primaryBackgroundColor" android:orientation="horizontal" - android:padding="10dp"> - - - - - - + android:padding="16dp"> @@ -79,7 +58,8 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical|end" android:contentDescription="@string/labelMenuContentDesc" - android:paddingLeft="10dp" + android:paddingStart="10dp" + android:paddingEnd="0dp" android:src="@drawable/ic_dotted_menu_horizontal" /> diff --git a/app/src/main/res/layout/list_milestones.xml b/app/src/main/res/layout/list_milestones.xml index 313e59e3..ec2ff429 100644 --- a/app/src/main/res/layout/list_milestones.xml +++ b/app/src/main/res/layout/list_milestones.xml @@ -7,27 +7,14 @@ android:layout_height="wrap_content" android:id="@+id/milestoneFrame" android:background="?attr/primaryBackgroundColor" + android:padding="16dp" android:orientation="vertical"> - - - - + android:textSize="16sp" /> + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> + android:orientation="horizontal"> - + android:background="?android:attr/selectableItemBackground" + android:focusable="true" + android:orientation="vertical" + android:padding="16dp"> - - - + android:layout_marginBottom="8dp" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> + 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" /> - + android:textColor="?attr/primaryTextColor" + android:textSize="14sp" + tools:text="@string/orgName" /> - + - + - - - - - + diff --git a/app/src/main/res/layout/list_pr.xml b/app/src/main/res/layout/list_pr.xml index a7f49b8d..9c4014c9 100644 --- a/app/src/main/res/layout/list_pr.xml +++ b/app/src/main/res/layout/list_pr.xml @@ -1,81 +1,88 @@ - - - + android:background="?android:attr/selectableItemBackground" + android:focusable="true"> + android:layout_marginBottom="8dp" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> + + + + + + + + + + + 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"> + + - - - - - - - - - - - - @@ -83,4 +90,4 @@ - + diff --git a/app/src/main/res/layout/list_profile_emails.xml b/app/src/main/res/layout/list_profile_emails.xml index cd41d14a..107721df 100644 --- a/app/src/main/res/layout/list_profile_emails.xml +++ b/app/src/main/res/layout/list_profile_emails.xml @@ -1,10 +1,12 @@ - + android:gravity="center_vertical" + android:orientation="horizontal" + android:padding="16dp" + tools:ignore="UseCompoundDrawables"> + tools:src="@drawable/ic_verified_user" /> - + diff --git a/app/src/main/res/layout/list_profile_followers.xml b/app/src/main/res/layout/list_profile_followers.xml index 1ada0008..e00b9c1a 100644 --- a/app/src/main/res/layout/list_profile_followers.xml +++ b/app/src/main/res/layout/list_profile_followers.xml @@ -1,16 +1,15 @@ - + android:gravity="center_vertical" + android:padding="16dp"> @@ -18,7 +17,6 @@ android:id="@+id/userInfoSection" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_toEndOf="@+id/userAvatar" android:orientation="vertical"> + android:textSize="16sp" + android:textStyle="bold" /> - + diff --git a/app/src/main/res/layout/list_profile_following.xml b/app/src/main/res/layout/list_profile_following.xml index 1ada0008..e00b9c1a 100644 --- a/app/src/main/res/layout/list_profile_following.xml +++ b/app/src/main/res/layout/list_profile_following.xml @@ -1,16 +1,15 @@ - + android:gravity="center_vertical" + android:padding="16dp"> @@ -18,7 +17,6 @@ android:id="@+id/userInfoSection" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_toEndOf="@+id/userAvatar" android:orientation="vertical"> + android:textSize="16sp" + android:textStyle="bold" /> - + diff --git a/app/src/main/res/layout/list_releases.xml b/app/src/main/res/layout/list_releases.xml index bd64265e..3c3dd394 100644 --- a/app/src/main/res/layout/list_releases.xml +++ b/app/src/main/res/layout/list_releases.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:padding="15dp"> + android:padding="16dp"> @@ -207,45 +207,71 @@ - - + tools:ignore="UseCompoundDrawables"> - + + + + + + + tools:ignore="UseCompoundDrawables"> + + + + + + - + diff --git a/app/src/main/res/layout/list_releases_downloads.xml b/app/src/main/res/layout/list_releases_downloads.xml index 851e4dc2..0a8a0cc5 100644 --- a/app/src/main/res/layout/list_releases_downloads.xml +++ b/app/src/main/res/layout/list_releases_downloads.xml @@ -10,8 +10,8 @@ tools:ignore="UseCompoundDrawables"> @@ -21,7 +21,7 @@ android:layout_height="wrap_content" android:layout_marginStart="8dp" android:textColor="?attr/primaryTextColor" - android:textSize="14sp" + android:textSize="12sp" tools:text="Source code (ZIP)" /> diff --git a/app/src/main/res/layout/list_repositories.xml b/app/src/main/res/layout/list_repositories.xml index 498c5785..13548e8d 100644 --- a/app/src/main/res/layout/list_repositories.xml +++ b/app/src/main/res/layout/list_repositories.xml @@ -1,194 +1,132 @@ - + android:background="?android:attr/selectableItemBackground" + android:focusable="true" + android:orientation="vertical" + android:padding="16dp"> - - - - - - - + android:buttonTint="#FFFFFF" + android:checked="false" + android:visibility="gone" /> + + - + android:textColor="?attr/primaryTextColor" + android:textSize="14sp" + tools:text="@string/orgName" /> - + - + - + - + - - + - + - + + android:textSize="14sp" + tools:text="@string/repoStars" /> + + - - - - - - - - - - - - - - + android:textSize="14sp" + android:visibility="gone" + tools:text="Java" /> - + - + diff --git a/app/src/main/res/layout/list_teams_by_org.xml b/app/src/main/res/layout/list_teams_by_org.xml index 4228fbe8..b7ee6d62 100644 --- a/app/src/main/res/layout/list_teams_by_org.xml +++ b/app/src/main/res/layout/list_teams_by_org.xml @@ -1,23 +1,11 @@ - - - - - + android:background="?attr/primaryBackgroundColor" + xmlns:android="http://schemas.android.com/apk/res/android"> - - - - + diff --git a/app/src/main/res/layout/list_user_accounts.xml b/app/src/main/res/layout/list_user_accounts.xml index c0d60f4e..4b235af9 100644 --- a/app/src/main/res/layout/list_user_accounts.xml +++ b/app/src/main/res/layout/list_user_accounts.xml @@ -1,68 +1,73 @@ - + android:gravity="center_vertical" + android:orientation="horizontal" + android:background="?android:attr/selectableItemBackground" + android:focusable="true" + android:padding="16dp"> + android:layout_width="@dimen/list_avatar_size" + android:layout_height="@dimen/list_avatar_size" + android:layout_marginEnd="10dp" + android:contentDescription="@string/generalImgContentText" + android:visibility="visible" /> + android:orientation="vertical"> + + + + + + + + + + - - - - + android:textSize="14sp" /> - - - + diff --git a/app/src/main/res/layout/nav_header.xml b/app/src/main/res/layout/nav_header.xml index c607d16a..d132589a 100644 --- a/app/src/main/res/layout/nav_header.xml +++ b/app/src/main/res/layout/nav_header.xml @@ -1,5 +1,5 @@ - + android:padding="20dp"> - + android:orientation="horizontal"> + + + + + + + - - - + diff --git a/app/src/main/res/layout/nav_user_accounts.xml b/app/src/main/res/layout/nav_user_accounts.xml index 92340731..23d6cac6 100644 --- a/app/src/main/res/layout/nav_user_accounts.xml +++ b/app/src/main/res/layout/nav_user_accounts.xml @@ -1,8 +1,8 @@ - - - - - diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index cc52fe7b..ef6bf313 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -2,4 +2,6 @@ 5dp 26dp 15dp + + 24dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0e9ff6e5..7a5401f5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -646,6 +646,7 @@ App version, build, user gitea version Archived + This repo is archived. You can view files, but cannot push or open issues/pull-requests. Account deleted successfully Remove Account @@ -754,4 +755,5 @@ Download manager Indicates the progress of ongoing downloads + Updated %s