1
0
mirror of https://codeberg.org/gitnex/GitNex synced 2024-12-23 00:48:57 +01:00

Fix mark all notifications as read (#1170)

Side note: I don't know why but Gitea notifications listing is very random even on the web UI. Olds are in the 1st page and new ones on the last page.

Closes #1164
Closes #1160

Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1170
Reviewed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
M M Arif 2022-08-01 09:24:23 +02:00
parent 9d428f1b11
commit 181f0b5dea
14 changed files with 158 additions and 97 deletions

View File

@ -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("")) {

View File

@ -117,7 +117,7 @@ public class RepoForksActivity extends BaseActivity {
.getApiInterface(ctx)
.listForks(repoOwner, repoName, pageSize, resultLimit);
call.enqueue(new Callback<List<Repository>>() {
call.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> 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<List<Repository>>() {
call.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> 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<Repository> 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);

View File

@ -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<Collaborator
addCollaboratorButtonRemove.setOnClickListener(v -> 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);
}
}

View File

@ -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<IssueCommentsAdap
});
avatar.setOnClickListener(loginId -> {
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);
}
}

View File

@ -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<RecyclerView.ViewHolder>
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")

View File

@ -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<RecyclerView.ViewH
frameLabels.setOnClickListener(openPr);
frameLabelsDots.setOnClickListener(openPr);
assigneeAvatar.setOnClickListener(v -> {
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")

View File

@ -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<ReleasesAdapter.Releas
downloadList.setHasFixedSize(true);
downloadList.setLayoutManager(new LinearLayoutManager(itemView.getContext()));
authorAvatar.setOnClickListener(loginId -> {
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();

View File

@ -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<UserSea
addMemberButtonAdd.setOnClickListener(v -> 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);
}
}

View File

@ -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<RecyclerView.ViewHolder>
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")

View File

@ -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<List<NotificationThread>>) (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();
}
}

View File

@ -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;

View File

@ -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<String> restrictedUsers = new ArrayList<>();
restrictedUsers.add("Ghost");
return restrictedUsers.contains(str);
}
}

View File

@ -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));
}
}

View File

@ -158,13 +158,13 @@
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/wiki_content"
android:layout_width="match_parent"
android:layout_height="480dp"
android:layout_height="wrap_content"
android:minHeight="480dp"
android:textColor="?attr/inputTextColor"
android:textColorHighlight="?attr/hintColor"
android:textColorHint="?attr/hintColor"
android:gravity="top|start"
android:singleLine="false"
android:imeOptions="actionNext"
android:textSize="14sp" />
</com.google.android.material.textfield.TextInputLayout>