diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 84e92d74..a34f97d5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -191,6 +191,11 @@ android:name=".activities.AdminAccountActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:label="@string/account" /> + statuses; @SerializedName("rules") diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/ReportAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/ReportAdapter.java new file mode 100644 index 00000000..394a9bc1 --- /dev/null +++ b/app/src/main/java/app/fedilab/android/ui/drawer/ReportAdapter.java @@ -0,0 +1,123 @@ +package app.fedilab.android.ui.drawer; +/* Copyright 2022 Thomas Schneider + * + * This file is a part of Fedilab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Fedilab; if not, + * see . */ + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import org.jetbrains.annotations.NotNull; + +import java.lang.ref.WeakReference; +import java.util.List; + +import app.fedilab.android.activities.AccountReportActivity; +import app.fedilab.android.client.entities.api.Account; +import app.fedilab.android.client.entities.api.AdminReport; +import app.fedilab.android.databinding.DrawerReportBinding; +import app.fedilab.android.helper.Helper; +import app.fedilab.android.helper.MastodonHelper; + + +public class ReportAdapter extends RecyclerView.Adapter { + + private final List reports; + private Context context; + + + public ReportAdapter(List reports) { + this.reports = reports; + } + + @NotNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) { + context = parent.getContext(); + DrawerReportBinding itemBinding = DrawerReportBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); + return new ReportViewHolder(itemBinding); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) { + ReportViewHolder holder = (ReportViewHolder) viewHolder; + AdminReport report = reports.get(position); + Account account = report.account.account; + Account target_account = report.target_account.account; + if (account.display_name == null || account.display_name.trim().equals("")) { + if (account.display_name != null && !account.display_name.trim().equals("")) + holder.binding.accountDnReporter.setText(account.display_name); + else + holder.binding.accountDnReporter.setText(account.username.replace("@", "")); + } else + holder.binding.accountDnReporter.setText(account.display_name, TextView.BufferType.SPANNABLE); + + + holder.binding.accountDn.setText( + report.account.account.getSpanDisplayName(context, + new WeakReference<>(holder.binding.accountDn)), + TextView.BufferType.SPANNABLE); + + MastodonHelper.loadPPMastodon(holder.binding.accountPp, target_account); + MastodonHelper.loadPPMastodon(holder.binding.accountPpReporter, account); + if (target_account.acct != null) { + holder.binding.accountAc.setText(target_account.acct); + } + + holder.binding.reportComment.setText(report.comment); + + if (report.statuses != null) { + holder.binding.reportNumberStatus.setText(String.valueOf(report.statuses.size())); + } else { + holder.binding.reportNumberStatus.setText("0"); + } + + holder.binding.mainContainer.setOnClickListener(view -> { + Intent intent = new Intent(context, AccountReportActivity.class); + Bundle b = new Bundle(); + b.putSerializable(Helper.ARG_REPORT, report); + intent.putExtras(b); + context.startActivity(intent); + }); + + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public int getItemCount() { + return reports.size(); + } + + + public static class ReportViewHolder extends RecyclerView.ViewHolder { + DrawerReportBinding binding; + + ReportViewHolder(DrawerReportBinding itemView) { + super(itemView.getRoot()); + binding = itemView; + } + } + + +} \ No newline at end of file diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/admin/FragmentAdminAccount.java b/app/src/main/java/app/fedilab/android/ui/fragment/admin/FragmentAdminAccount.java index 3eecc610..ba3e9b3b 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/admin/FragmentAdminAccount.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/admin/FragmentAdminAccount.java @@ -24,6 +24,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; +import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -137,6 +138,9 @@ public class FragmentAdminAccount extends Fragment { adminAccountAdapter = new AdminAccountAdapter(this.adminAccounts); flagLoading = adminAccounts.pagination.max_id == null; LinearLayoutManager mLayoutManager = new LinearLayoutManager(requireActivity()); + DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(binding.recyclerView.getContext(), + mLayoutManager.getOrientation()); + binding.recyclerView.addItemDecoration(dividerItemDecoration); binding.recyclerView.setLayoutManager(mLayoutManager); binding.recyclerView.setAdapter(adminAccountAdapter); //Fetch the relationship diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/admin/FragmentAdminReport.java b/app/src/main/java/app/fedilab/android/ui/fragment/admin/FragmentAdminReport.java index 2481f8c5..0f5a5ec1 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/admin/FragmentAdminReport.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/admin/FragmentAdminReport.java @@ -24,6 +24,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; +import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -38,7 +39,7 @@ import app.fedilab.android.client.entities.api.AdminReports; import app.fedilab.android.databinding.FragmentPaginationBinding; import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.ThemeHelper; -import app.fedilab.android.ui.drawer.StatusAdapter; +import app.fedilab.android.ui.drawer.ReportAdapter; import app.fedilab.android.viewmodel.mastodon.AdminVM; @@ -50,7 +51,7 @@ public class FragmentAdminReport extends Fragment { private boolean flagLoading; private List adminReports; private String max_id, min_id; - private StatusAdapter statusAdapter; + private ReportAdapter reportAdapter; private LinearLayoutManager mLayoutManager; private String viewModelKey; @@ -119,16 +120,15 @@ public class FragmentAdminReport extends Fragment { } flagLoading = adminReports.pagination.max_id == null; binding.recyclerView.setVisibility(View.VISIBLE); - if (statusAdapter != null && this.adminReports != null) { + if (reportAdapter != null && this.adminReports != null) { int size = this.adminReports.size(); this.adminReports.clear(); this.adminReports = new ArrayList<>(); - statusAdapter.notifyItemRangeRemoved(0, size); + reportAdapter.notifyItemRangeRemoved(0, size); } if (this.adminReports == null) { this.adminReports = new ArrayList<>(); } - this.adminReports.addAll(adminReports.adminReports); if (max_id == null || (adminReports.pagination.max_id != null && Helper.compareTo(adminReports.pagination.max_id, max_id) < 0)) { @@ -138,12 +138,14 @@ public class FragmentAdminReport extends Fragment { min_id = adminReports.pagination.min_id; } - // statusAdapter = new StatusAdapter(this.statuses, timelineType, minified); + reportAdapter = new ReportAdapter(adminReports.adminReports); mLayoutManager = new LinearLayoutManager(requireActivity()); binding.recyclerView.setLayoutManager(mLayoutManager); - binding.recyclerView.setAdapter(statusAdapter); - + binding.recyclerView.setAdapter(reportAdapter); + DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(binding.recyclerView.getContext(), + mLayoutManager.getOrientation()); + binding.recyclerView.addItemDecoration(dividerItemDecoration); binding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { @@ -189,7 +191,7 @@ public class FragmentAdminReport extends Fragment { //There are some adminReports present in the timeline int startId = adminReports.size(); adminReports.addAll(admReports.adminReports); - statusAdapter.notifyItemRangeInserted(startId, admReports.adminReports.size()); + reportAdapter.notifyItemRangeInserted(startId, admReports.adminReports.size()); if (max_id == null || (admReports.pagination.max_id != null && Helper.compareTo(admReports.pagination.max_id, max_id) < 0)) { max_id = admReports.pagination.max_id; } @@ -199,19 +201,6 @@ public class FragmentAdminReport extends Fragment { } } - @Override - public void onPause() { - super.onPause(); - } - - /** - * Refresh status in list - */ - public void refreshAllAdapters() { - if (statusAdapter != null && adminReports != null) { - statusAdapter.notifyItemRangeChanged(0, adminReports.size()); - } - } } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_baseline_mode_comment_24.xml b/app/src/main/res/drawable/ic_baseline_mode_comment_24.xml new file mode 100644 index 00000000..ee6babce --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_mode_comment_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/drawer_report.xml b/app/src/main/res/layout/drawer_report.xml new file mode 100644 index 00000000..3419ac3d --- /dev/null +++ b/app/src/main/res/layout/drawer_report.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/popup_admin_filter_accounts.xml b/app/src/main/res/layout/popup_admin_filter_accounts.xml index b11ae67f..69c77705 100644 --- a/app/src/main/res/layout/popup_admin_filter_accounts.xml +++ b/app/src/main/res/layout/popup_admin_filter_accounts.xml @@ -16,7 +16,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" - android:orientation="horizontal"> + android:orientation="vertical"> + android:orientation="vertical"> Account unsilenced Account silenced Report + State