diff --git a/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java b/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java index 29c90825..e715f0d5 100644 --- a/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java @@ -686,16 +686,19 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt viewBinding.issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + EmojiParser.parseToUnicode(issue.getIssue().getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY)); String cleanIssueDescription = issue.getIssue().getBody().trim(); - viewBinding.assigneeAvatar.setOnClickListener(loginId -> { - Intent intent = new Intent(ctx, ProfileActivity.class); - intent.putExtra("username", issue.getIssue().getUser().getLogin()); - ctx.startActivity(intent); - }); + if(!AppUtil.checkGhostUsers(issue.getIssue().getUser().getLogin())) { - viewBinding.assigneeAvatar.setOnLongClickListener(loginId -> { - AppUtil.copyToClipboard(ctx, issue.getIssue().getUser().getLogin(), ctx.getString(R.string.copyLoginIdToClipBoard, issue.getIssue().getUser().getLogin())); - return true; - }); + viewBinding.assigneeAvatar.setOnClickListener(loginId -> { + Intent intent = new Intent(ctx, ProfileActivity.class); + intent.putExtra("username", issue.getIssue().getUser().getLogin()); + ctx.startActivity(intent); + }); + + viewBinding.assigneeAvatar.setOnLongClickListener(loginId -> { + AppUtil.copyToClipboard(ctx, issue.getIssue().getUser().getLogin(), ctx.getString(R.string.copyLoginIdToClipBoard, issue.getIssue().getUser().getLogin())); + return true; + }); + } Markdown.render(ctx, EmojiParser.parseToUnicode(cleanIssueDescription), viewBinding.issueDescription, issue.getRepository()); @@ -720,16 +723,20 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt assigneesView.setLayoutParams(params1); int finalI = i; - assigneesView.setOnClickListener(loginId -> { - Intent intent = new Intent(ctx, ProfileActivity.class); - intent.putExtra("username", issue.getIssue().getAssignees().get(finalI).getLogin()); - ctx.startActivity(intent); - }); - assigneesView.setOnLongClickListener(loginId -> { - AppUtil.copyToClipboard(ctx, issue.getIssue().getAssignees().get(finalI).getLogin(), ctx.getString(R.string.copyLoginIdToClipBoard, issue.getIssue().getAssignees().get(finalI).getLogin())); - return true; - }); + if(!AppUtil.checkGhostUsers(issue.getIssue().getAssignees().get(finalI).getLogin())) { + + assigneesView.setOnClickListener(loginId -> { + Intent intent = new Intent(ctx, ProfileActivity.class); + intent.putExtra("username", issue.getIssue().getAssignees().get(finalI).getLogin()); + ctx.startActivity(intent); + }); + + assigneesView.setOnLongClickListener(loginId -> { + AppUtil.copyToClipboard(ctx, issue.getIssue().getAssignees().get(finalI).getLogin(), ctx.getString(R.string.copyLoginIdToClipBoard, issue.getIssue().getAssignees().get(finalI).getLogin())); + return true; + }); + } /*if(!issue.getIssue().getAssignees().get(i).getFull_name().equals("")) { diff --git a/app/src/main/java/org/mian/gitnex/activities/RepoForksActivity.java b/app/src/main/java/org/mian/gitnex/activities/RepoForksActivity.java index b4afe427..09c56a58 100644 --- a/app/src/main/java/org/mian/gitnex/activities/RepoForksActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/RepoForksActivity.java @@ -117,7 +117,7 @@ public class RepoForksActivity extends BaseActivity { .getApiInterface(ctx) .listForks(repoOwner, repoName, pageSize, resultLimit); - call.enqueue(new Callback>() { + call.enqueue(new Callback<>() { @Override public void onResponse(@NonNull Call> call, @NonNull Response> response) { @@ -131,14 +131,16 @@ public class RepoForksActivity extends BaseActivity { forksList.addAll(response.body()); adapter.notifyDataChanged(); noData.setVisibility(View.GONE); - } else { + } + else { forksList.clear(); adapter.notifyDataChanged(); noData.setVisibility(View.VISIBLE); } progressBar.setVisibility(View.GONE); - } else { + } + else { Log.e(TAG, String.valueOf(response.code())); } } @@ -159,7 +161,7 @@ public class RepoForksActivity extends BaseActivity { .getApiInterface(ctx) .listForks(repoOwner, repoName, page, resultLimit); - call.enqueue(new Callback>() { + call.enqueue(new Callback<>() { @Override public void onResponse(@NonNull Call> call, @NonNull Response> response) { @@ -175,13 +177,15 @@ public class RepoForksActivity extends BaseActivity { if(result.size() > 0) { pageSize = result.size(); forksList.addAll(result); - } else { + } + else { adapter.setMoreDataAvailable(false); } adapter.notifyDataChanged(); progressLoadMore.setVisibility(View.GONE); - } else { + } + else { Log.e(TAG, String.valueOf(response.code())); } } @@ -226,7 +230,7 @@ public class RepoForksActivity extends BaseActivity { List userRepositories = new ArrayList<>(); for(Repository d : forksList) { - if(d.getName().toLowerCase().contains(text) || + if(d.getOwner().getLogin().contains(text) || d.getName().toLowerCase().contains(text) || d.getDescription().toLowerCase().contains(text)) { userRepositories.add(d); diff --git a/app/src/main/java/org/mian/gitnex/adapters/CollaboratorSearchAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/CollaboratorSearchAdapter.java index 658eaaf4..d5cdb636 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/CollaboratorSearchAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/CollaboratorSearchAdapter.java @@ -2,6 +2,7 @@ package org.mian.gitnex.adapters; import android.content.Context; import android.content.Intent; +import android.os.Handler; import android.text.Html; import android.util.Log; import android.view.LayoutInflater; @@ -88,16 +89,21 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter AlertDialogs.collaboratorRemoveDialog(context, userInfo.getLogin(), repository)); - userAvatar.setOnClickListener(loginId -> { - Intent intent = new Intent(context, ProfileActivity.class); - intent.putExtra("username", userInfo.getLogin()); - context.startActivity(intent); - }); + new Handler().postDelayed(() -> { + if(!AppUtil.checkGhostUsers(userInfo.getLogin())) { - userAvatar.setOnLongClickListener(loginId -> { - AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin())); - return true; - }); + userAvatar.setOnClickListener(loginId -> { + Intent intent = new Intent(context, ProfileActivity.class); + intent.putExtra("username", userInfo.getLogin()); + context.startActivity(intent); + }); + + userAvatar.setOnLongClickListener(loginId -> { + AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin())); + return true; + }); + } + }, 500); } } 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 a5b7357f..31b8bc28 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/IssueCommentsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/IssueCommentsAdapter.java @@ -6,6 +6,7 @@ import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.os.Handler; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; @@ -221,16 +222,20 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter { - Intent intent = new Intent(context, ProfileActivity.class); - intent.putExtra("username", userLoginId); - context.startActivity(intent); - }); + new Handler().postDelayed(() -> { + if(!AppUtil.checkGhostUsers(userLoginId)) { + avatar.setOnClickListener(loginId -> { + Intent intent = new Intent(context, ProfileActivity.class); + intent.putExtra("username", userLoginId); + context.startActivity(intent); + }); - avatar.setOnLongClickListener(loginId -> { - AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId)); - return true; - }); + avatar.setOnLongClickListener(loginId -> { + AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId)); + return true; + }); + } + }, 500); } } 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 bbec18fd..a99b1411 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/IssuesAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/IssuesAdapter.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.graphics.Typeface; +import android.os.Handler; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; @@ -112,16 +113,21 @@ public class IssuesAdapter extends RecyclerView.Adapter labelsScrollViewDots = itemView.findViewById(R.id.labelsScrollViewDots); frameLabelsDots = itemView.findViewById(R.id.frameLabelsDots); - issueAssigneeAvatar.setOnLongClickListener(loginId -> { - AppUtil.copyToClipboard(context, issueObject.getUser().getLogin(), context.getString(R.string.copyLoginIdToClipBoard, issueObject.getUser().getLogin())); - return true; - }); + new Handler().postDelayed(() -> { + if(!AppUtil.checkGhostUsers(issueObject.getUser().getLogin())) { - issueAssigneeAvatar.setOnClickListener(v -> { - Intent intent = new Intent(context, ProfileActivity.class); - intent.putExtra("username", issueObject.getUser().getLogin()); - context.startActivity(intent); - }); + issueAssigneeAvatar.setOnLongClickListener(loginId -> { + AppUtil.copyToClipboard(context, issueObject.getUser().getLogin(), context.getString(R.string.copyLoginIdToClipBoard, issueObject.getUser().getLogin())); + return true; + }); + + issueAssigneeAvatar.setOnClickListener(v -> { + Intent intent = new Intent(context, ProfileActivity.class); + intent.putExtra("username", issueObject.getUser().getLogin()); + context.startActivity(intent); + }); + } + }, 500); } @SuppressLint("SetTextI18n") diff --git a/app/src/main/java/org/mian/gitnex/adapters/PullRequestsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/PullRequestsAdapter.java index ab96e2d2..cb2d59d2 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/PullRequestsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/PullRequestsAdapter.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.graphics.Typeface; +import android.os.Handler; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; @@ -113,16 +114,21 @@ public class PullRequestsAdapter extends RecyclerView.Adapter { - Intent intent = new Intent(context, ProfileActivity.class); - intent.putExtra("username", pullRequestObject.getUser().getLogin()); - context.startActivity(intent); - }); + new Handler().postDelayed(() -> { + if(!AppUtil.checkGhostUsers(pullRequestObject.getUser().getLogin())) { - assigneeAvatar.setOnLongClickListener(loginId -> { - AppUtil.copyToClipboard(context, pullRequestObject.getUser().getLogin(), context.getString(R.string.copyLoginIdToClipBoard, pullRequestObject.getUser().getLogin())); - return true; - }); + assigneeAvatar.setOnClickListener(v -> { + Intent intent = new Intent(context, ProfileActivity.class); + intent.putExtra("username", pullRequestObject.getUser().getLogin()); + context.startActivity(intent); + }); + + assigneeAvatar.setOnLongClickListener(loginId -> { + AppUtil.copyToClipboard(context, pullRequestObject.getUser().getLogin(), context.getString(R.string.copyLoginIdToClipBoard, pullRequestObject.getUser().getLogin())); + return true; + }); + } + }, 500); } @SuppressLint("SetTextI18n") 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 e44d5271..fb23ef78 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/ReleasesAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/ReleasesAdapter.java @@ -3,6 +3,7 @@ package org.mian.gitnex.adapters; import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; +import android.os.Handler; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -94,13 +95,18 @@ public class ReleasesAdapter extends RecyclerView.Adapter { - Context context = loginId.getContext(); + new Handler().postDelayed(() -> { + if(!AppUtil.checkGhostUsers(releases.getAuthor().getLogin())) { - Intent intent = new Intent(context, ProfileActivity.class); - intent.putExtra("username", releases.getAuthor().getLogin()); - context.startActivity(intent); - }); + authorAvatar.setOnClickListener(loginId -> { + Context context = loginId.getContext(); + + Intent intent = new Intent(context, ProfileActivity.class); + intent.putExtra("username", releases.getAuthor().getLogin()); + context.startActivity(intent); + }); + } + }, 500); optionsMenu.setOnClickListener(v -> { final Context context = v.getContext(); 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 becee2bc..153ee061 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/UserSearchForTeamMemberAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/UserSearchForTeamMemberAdapter.java @@ -2,6 +2,7 @@ package org.mian.gitnex.adapters; import android.content.Context; import android.content.Intent; +import android.os.Handler; import android.text.Html; import android.view.LayoutInflater; import android.view.View; @@ -65,16 +66,21 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter AlertDialogs.addMemberDialog(context, userInfo.getLogin(), Integer.parseInt(String.valueOf(teamId)))); addMemberButtonRemove.setOnClickListener(v -> AlertDialogs.removeMemberDialog(context, userInfo.getLogin(), Integer.parseInt(String.valueOf(teamId)))); - userAvatar.setOnClickListener(loginId -> { - Intent intent = new Intent(context, ProfileActivity.class); - intent.putExtra("username", userInfo.getLogin()); - context.startActivity(intent); - }); + new Handler().postDelayed(() -> { + if(!AppUtil.checkGhostUsers(userInfo.getLogin())) { - userAvatar.setOnLongClickListener(loginId -> { - AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin())); - return true; - }); + userAvatar.setOnClickListener(loginId -> { + Intent intent = new Intent(context, ProfileActivity.class); + intent.putExtra("username", userInfo.getLogin()); + context.startActivity(intent); + }); + + userAvatar.setOnLongClickListener(loginId -> { + AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin())); + return true; + }); + } + }, 500); } } diff --git a/app/src/main/java/org/mian/gitnex/adapters/UsersAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/UsersAdapter.java index 85078123..200e284a 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/UsersAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/UsersAdapter.java @@ -3,6 +3,7 @@ package org.mian.gitnex.adapters; import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; +import android.os.Handler; import android.text.Html; import android.view.LayoutInflater; import android.view.View; @@ -74,16 +75,21 @@ public class UsersAdapter extends RecyclerView.Adapter userFullName = itemView.findViewById(R.id.userFullName); userName = itemView.findViewById(R.id.userName); - itemView.setOnClickListener(loginId -> { - Intent intent = new Intent(context, ProfileActivity.class); - intent.putExtra("username", userInfo.getLogin()); - context.startActivity(intent); - }); + new Handler().postDelayed(() -> { + if(!AppUtil.checkGhostUsers(userInfo.getLogin())) { - itemView.setOnLongClickListener(loginId -> { - AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin())); - return true; - }); + itemView.setOnClickListener(loginId -> { + Intent intent = new Intent(context, ProfileActivity.class); + intent.putExtra("username", userInfo.getLogin()); + context.startActivity(intent); + }); + + itemView.setOnLongClickListener(loginId -> { + AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin())); + return true; + }); + } + }, 500); } @SuppressLint("SetTextI18n") diff --git a/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java index 3f060fc7..692e92d9 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java @@ -32,12 +32,12 @@ import org.mian.gitnex.helpers.contexts.IssueContext; import org.mian.gitnex.helpers.contexts.RepositoryContext; import java.util.ArrayList; import java.util.Arrays; -import java.util.Date; import java.util.List; +import java.util.Objects; /** * @author opyale - * Modified M M Arif + * @author M M Arif */ public class NotificationsFragment extends Fragment implements NotificationsAdapter.OnNotificationClickedListener, NotificationsAdapter.OnMoreClickedListener { @@ -111,7 +111,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap viewBinding.markAllAsRead.setOnClickListener(v1 -> RetrofitClient.getApiInterface(context) - .notifyReadList(new Date(), "true", Arrays.asList("unread", "pinned"), "read") + .notifyReadList(null, "false", Arrays.asList("unread", "pinned"), "read") .enqueue((SimpleCallback>) (call, voidResponse) -> { if(voidResponse.isPresent() && voidResponse.get().isSuccessful()) { @@ -151,15 +151,16 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap notificationThreads.clear(); } - if(listResponse.get().body().size() > 0) { - notificationThreads.addAll(listResponse.get().body()); + + if(listResponse.get().body() != null) { + notificationThreads.addAll(Objects.requireNonNull(listResponse.get().body())); } else { notificationsAdapter.setMoreDataAvailable(false); } - if(!append || listResponse.get().body().size() > 0) { - notificationsAdapter.notifyDataSetChanged(); + if(!append || Objects.requireNonNull(listResponse.get().body()).size() > 0) { + notificationsAdapter.notifyDataChanged(); } } 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 9b0cbccd..22e76344 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java @@ -17,11 +17,11 @@ import org.gitnex.tea4j.v2.models.Repository; import org.jetbrains.annotations.NotNull; import org.mian.gitnex.R; import org.mian.gitnex.activities.OrganizationDetailActivity; +import org.mian.gitnex.activities.ProfileActivity; 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.activities.ProfileActivity; import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.databinding.FragmentRepoInfoBinding; import org.mian.gitnex.helpers.AlertDialogs; diff --git a/app/src/main/java/org/mian/gitnex/helpers/AppUtil.java b/app/src/main/java/org/mian/gitnex/helpers/AppUtil.java index b9ae5f8c..1da9c358 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/AppUtil.java +++ b/app/src/main/java/org/mian/gitnex/helpers/AppUtil.java @@ -35,6 +35,7 @@ import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; @@ -454,4 +455,13 @@ public class AppUtil { return typeface; } + /** + * check for ghost/restricted users/profiles + */ + public static Boolean checkGhostUsers(String str) { + + ArrayList restrictedUsers = new ArrayList<>(); + restrictedUsers.add("Ghost"); + return restrictedUsers.contains(str); + } } diff --git a/app/src/main/java/org/mian/gitnex/viewmodels/FilesViewModel.java b/app/src/main/java/org/mian/gitnex/viewmodels/FilesViewModel.java index 02e04d9e..3ac0e658 100644 --- a/app/src/main/java/org/mian/gitnex/viewmodels/FilesViewModel.java +++ b/app/src/main/java/org/mian/gitnex/viewmodels/FilesViewModel.java @@ -53,7 +53,6 @@ public class FilesViewModel extends ViewModel { else { progressBar.setVisibility(View.GONE); noDataFiles.setVisibility(View.VISIBLE); - Toasty.error(ctx, ctx.getString(R.string.genericError)); } } @@ -90,7 +89,6 @@ public class FilesViewModel extends ViewModel { else { progressBar.setVisibility(View.GONE); noDataFiles.setVisibility(View.VISIBLE); - Toasty.error(ctx, ctx.getString(R.string.genericError)); } } diff --git a/app/src/main/res/layout/activity_wiki.xml b/app/src/main/res/layout/activity_wiki.xml index 097dce6a..0b36650a 100644 --- a/app/src/main/res/layout/activity_wiki.xml +++ b/app/src/main/res/layout/activity_wiki.xml @@ -158,13 +158,13 @@