Add reports

This commit is contained in:
Thomas 2022-11-12 12:15:16 +01:00
parent 9a79b9dc7d
commit d7f58dab36
8 changed files with 315 additions and 219 deletions

View file

@ -191,6 +191,11 @@
android:name=".activities.AdminAccountActivity" android:name=".activities.AdminAccountActivity"
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/account" /> android:label="@string/account" />
<activity
android:name=".activities.AdminReportActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/report"
android:theme="@style/AppThemeBar" />
<activity <activity
android:name=".activities.ScheduledActivity" android:name=".activities.ScheduledActivity"
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"

View file

@ -16,8 +16,6 @@ package app.fedilab.android.activities;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.os.Bundle; import android.os.Bundle;
@ -25,28 +23,30 @@ import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList; import java.util.ArrayList;
import app.fedilab.android.R; import app.fedilab.android.R;
import app.fedilab.android.client.entities.api.AdminAccount; import app.fedilab.android.client.entities.api.AdminAccount;
import app.fedilab.android.client.entities.api.Report; import app.fedilab.android.client.entities.api.Report;
import app.fedilab.android.client.entities.api.Status;
import app.fedilab.android.databinding.ActivityAdminReportBinding; import app.fedilab.android.databinding.ActivityAdminReportBinding;
import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.ThemeHelper; import app.fedilab.android.helper.ThemeHelper;
import app.fedilab.android.ui.drawer.StatusReportAdapter;
import app.fedilab.android.viewmodel.mastodon.AdminVM;
import es.dmoral.toasty.Toasty; import es.dmoral.toasty.Toasty;
public class AccountReportActivity extends BaseActivity implements OnAdminActionInterface { public class AccountReportActivity extends BaseActivity {
private String account_id; private String account_id;
private Report report; private Report report;
private ActivityAdminReportBinding binding; private ActivityAdminReportBinding binding;
private AdminVM adminVM;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -64,9 +64,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
AdminAccount targeted_account = null; AdminAccount targeted_account = null;
Bundle b = getIntent().getExtras(); Bundle b = getIntent().getExtras();
if (b != null) { if (b != null) {
account_id = b.getString("account_id", null); account_id = b.getString(Helper.ARG_ACCOUNT_ID, null);
targeted_account = b.getParcelable("targeted_account"); targeted_account = (AdminAccount) b.getSerializable(Helper.ARG_ACCOUNT);
report = b.getParcelable("report"); report = (Report) b.getSerializable(Helper.ARG_REPORT);
} }
@ -80,169 +80,99 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
} }
binding.assign.setVisibility(View.GONE); binding.assign.setVisibility(View.GONE);
binding.status.setVisibility(View.GONE); binding.status.setVisibility(View.GONE);
adminVM = new ViewModelProvider(this).get(AdminVM.class);
if (account_id != null) { if (account_id != null) {
new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.GET_ONE_ACCOUNT, account_id, null, AccountReportActivity.this); adminVM.getAccount(MainActivity.currentInstance, MainActivity.currentToken, account_id).observe(this, account -> fillReport(account, null));
return; return;
} }
if (report != null) { if (report != null) {
targeted_account = report.getTarget_account();
RecyclerView lv_statuses = findViewById(R.id.lv_statuses);
ArrayList<String> contents = new ArrayList<>(); ArrayList<String> contents = new ArrayList<>();
for (Status status : report.getStatuses()) { for (Status status : report.statuses) {
contents.add(status.getContent()); contents.add(status.content);
} }
lv_statuses.setLayoutManager(new LinearLayoutManager(this)); binding.lvStatuses.setLayoutManager(new LinearLayoutManager(this));
StatusReportAdapter adapter = new StatusReportAdapter(contents); StatusReportAdapter adapter = new StatusReportAdapter(contents);
lv_statuses.setAdapter(adapter); binding.lvStatuses.setAdapter(adapter);
Group statuses_group = findViewById(R.id.statuses_group); binding.statusesGroup.setVisibility(View.VISIBLE);
statuses_group.setVisibility(View.VISIBLE);
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.GET_ONE_ACCOUNT, report.getTarget_account().getUsername(), null, AccountReportActivity.this);
}
} }
if (targeted_account != null) { if (targeted_account != null) {
account_id = targeted_account.getId(); account_id = targeted_account.id;
fillReport(targeted_account); fillReport(targeted_account, null);
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { account_id = targeted_account.username;
account_id = targeted_account.getUsername();
}
} }
} }
@Override private void fillReport(AdminAccount accountAdmin, actionType type) {
public void onAdminAction(APIResponse apiResponse) {
if (apiResponse.getError() != null) {
if (apiResponse.getError().getStatusCode() == 403) {
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
int style;
if (theme == Helper.THEME_DARK) {
style = R.style.DialogDark;
} else if (theme == Helper.THEME_BLACK) {
style = R.style.DialogBlack;
} else {
style = R.style.Dialog;
}
AlertDialog.Builder builderInner;
builderInner = new AlertDialog.Builder(AccountReportActivity.this, style);
builderInner.setTitle(R.string.reconnect_account);
builderInner.setMessage(R.string.reconnect_account_message);
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
Intent intent = new Intent(AccountReportActivity.this, LoginActivity.class);
intent.putExtra("admin", true);
startActivity(intent);
});
builderInner.show();
} else {
Toasty.error(AccountReportActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
}
return;
}
if (apiResponse.getReports() != null && apiResponse.getReports().size() > 0) {
report = apiResponse.getReports().get(0);
fillReport(report.getTarget_account());
} else if (apiResponse.getAccountAdmins() != null && apiResponse.getAccountAdmins().size() > 0) {
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
account_id = apiResponse.getAccountAdmins().get(0).getUsername();
}
fillReport(apiResponse.getAccountAdmins().get(0));
}
}
private void fillReport(AccountAdmin accountAdmin) {
if (accountAdmin == null) { if (accountAdmin == null) {
Toasty.error(AccountReportActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(AccountReportActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
} }
if (!accountAdmin.isApproved() && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA && (accountAdmin.getDomain() == null || accountAdmin.getDomain().equals("null"))) { if (!accountAdmin.approved && (accountAdmin.domain == null || accountAdmin.domain.equals("null"))) {
allow_reject_group.setVisibility(View.VISIBLE); binding.allowRejectGroup.setVisibility(View.VISIBLE);
} }
reject.setOnClickListener(view -> { if (!accountAdmin.silenced) {
AdminAction adminAction = new AdminAction(); binding.silence.setText(getString(R.string.silence));
adminAction.setType(REJECT);
new PostAdminActionAsyncTask(AccountReportActivity.this, REJECT, account_id, adminAction, AccountReportActivity.this);
});
allow.setOnClickListener(view -> {
AdminAction adminAction = new AdminAction();
adminAction.setType(APPROVE);
new PostAdminActionAsyncTask(AccountReportActivity.this, APPROVE, account_id, adminAction, AccountReportActivity.this);
});
warn.setOnClickListener(view -> {
AdminAction adminAction = new AdminAction();
adminAction.setType(NONE);
adminAction.setSend_email_notification(email_user.isChecked());
adminAction.setText(comment.getText().toString().trim());
new PostAdminActionAsyncTask(AccountReportActivity.this, NONE, account_id, adminAction, AccountReportActivity.this);
});
if (!accountAdmin.isSilenced()) {
silence.setText(getString(R.string.silence));
} else { } else {
silence.setText(getString(R.string.unsilence)); binding.silence.setText(getString(R.string.unsilence));
} }
silence.setOnClickListener(view -> { if (!accountAdmin.disabled) {
if (!accountAdmin.isSilenced()) { binding.disable.setText(getString(R.string.disable));
AdminAction adminAction = new AdminAction();
adminAction.setType(SILENCE);
adminAction.setSend_email_notification(email_user.isChecked());
adminAction.setText(comment.getText().toString().trim());
new PostAdminActionAsyncTask(AccountReportActivity.this, SILENCE, account_id, adminAction, AccountReportActivity.this);
} else { } else {
new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.UNSILENCE, account_id, null, AccountReportActivity.this); binding.disable.setText(getString(R.string.undisable));
}
if (!accountAdmin.suspended) {
binding.suspend.setText(getString(R.string.suspend));
} else {
binding.suspend.setText(getString(R.string.unsuspend));
}
binding.reject.setOnClickListener(view -> adminVM.reject(MainActivity.currentInstance, MainActivity.currentToken, account_id).observe(this, account -> fillReport(account, actionType.REJECT)));
binding.allow.setOnClickListener(view -> adminVM.approve(MainActivity.currentInstance, MainActivity.currentToken, account_id).observe(this, account -> fillReport(account, actionType.APPROVE)));
binding.warn.setOnClickListener(view -> {
adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account_id, "none", null, null, binding.comment.getText().toString().trim(), binding.emailUser.isChecked());
fillReport(accountAdmin, actionType.NONE);
});
binding.silence.setOnClickListener(view -> {
if (!accountAdmin.silenced) {
adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account_id, "silence", null, null, binding.comment.getText().toString().trim(), binding.emailUser.isChecked());
accountAdmin.silenced = true;
fillReport(accountAdmin, actionType.SILENCE);
} else {
adminVM.unsilence(MainActivity.currentInstance, MainActivity.currentToken, account_id).observe(this, account -> fillReport(account, actionType.UNSILENCE));
}
});
binding.disable.setOnClickListener(view -> {
if (!accountAdmin.disabled) {
adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account_id, "disable", null, null, binding.comment.getText().toString().trim(), binding.emailUser.isChecked());
accountAdmin.disabled = true;
fillReport(accountAdmin, actionType.DISABLE);
} else {
adminVM.enable(MainActivity.currentInstance, MainActivity.currentToken, account_id).observe(this, account -> fillReport(account, actionType.ENABLE));
} }
}); });
if (!accountAdmin.isDisabled()) { binding.suspend.setOnClickListener(view -> {
disable.setText(getString(R.string.disable)); if (!accountAdmin.suspended) {
adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account_id, "suspend", null, null, binding.comment.getText().toString().trim(), binding.emailUser.isChecked());
accountAdmin.suspended = true;
fillReport(accountAdmin, actionType.SUSPEND);
} else { } else {
disable.setText(getString(R.string.undisable)); adminVM.unsuspend(MainActivity.currentInstance, MainActivity.currentToken, account_id).observe(this, account -> fillReport(account, actionType.UNSUSPEND));
}
disable.setOnClickListener(view -> {
if (!accountAdmin.isDisabled()) {
AdminAction adminAction = new AdminAction();
adminAction.setType(DISABLE);
adminAction.setSend_email_notification(email_user.isChecked());
adminAction.setText(comment.getText().toString().trim());
new PostAdminActionAsyncTask(AccountReportActivity.this, DISABLE, account_id, adminAction, AccountReportActivity.this);
} else {
new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.ENABLE, account_id, null, AccountReportActivity.this);
}
});
if (!accountAdmin.isSuspended()) {
suspend.setText(getString(R.string.suspend));
} else {
suspend.setText(getString(R.string.unsuspend));
}
suspend.setOnClickListener(view -> {
if (!accountAdmin.isSuspended()) {
AdminAction adminAction = new AdminAction();
adminAction.setType(SUSPEND);
adminAction.setSend_email_notification(email_user.isChecked());
adminAction.setText(comment.getText().toString().trim());
new PostAdminActionAsyncTask(AccountReportActivity.this, SUSPEND, account_id, adminAction, AccountReportActivity.this);
} else {
new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.UNSUSPEND, account_id, null, AccountReportActivity.this);
} }
}); });
if (accountAdmin.getAction() != null) { if (type != null) {
String message = null; String message = null;
switch (accountAdmin.getAction()) { switch (type) {
case SILENCE: case SILENCE:
message = getString(R.string.account_silenced); message = getString(R.string.account_silenced);
break; break;
@ -265,139 +195,158 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
message = getString(R.string.account_warned); message = getString(R.string.account_warned);
break; break;
case APPROVE: case APPROVE:
allow_reject_group.setVisibility(View.GONE); binding.allowRejectGroup.setVisibility(View.GONE);
message = getString(R.string.account_approved); message = getString(R.string.account_approved);
break; break;
case REJECT: case REJECT:
allow_reject_group.setVisibility(View.GONE); binding.allowRejectGroup.setVisibility(View.GONE);
message = getString(R.string.account_rejected); message = getString(R.string.account_rejected);
break; break;
} }
if (message != null) { if (message != null) {
Toasty.success(AccountReportActivity.this, message, Toast.LENGTH_LONG).show(); Toasty.success(AccountReportActivity.this, message, Toast.LENGTH_LONG).show();
} }
comment.setText(""); binding.comment.setText("");
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
assert imm != null; assert imm != null;
imm.hideSoftInputFromWindow(comment.getWindowToken(), 0); imm.hideSoftInputFromWindow(binding.comment.getWindowToken(), 0);
} }
if (accountAdmin.getAccount() != null) { if (accountAdmin.account != null) {
username.setText(String.format("@%s", accountAdmin.getAccount().getAcct())); binding.username.setText(String.format("@%s", accountAdmin.account.acct));
} }
email.setText(accountAdmin.getEmail()); binding.email.setText(accountAdmin.email);
if (accountAdmin.getEmail() == null || accountAdmin.getEmail().trim().equals("")) { if (accountAdmin.email == null || accountAdmin.email.trim().equals("")) {
email.setVisibility(View.GONE); binding.email.setVisibility(View.GONE);
email_label.setVisibility(View.GONE); binding.emailLabel.setVisibility(View.GONE);
} }
if (accountAdmin.getIp() == null || accountAdmin.getIp().trim().equals("")) { if (accountAdmin.ip == null || accountAdmin.ip.ip.trim().equals("")) {
recent_ip.setVisibility(View.GONE); binding.recentIp.setVisibility(View.GONE);
recent_ip_label.setVisibility(View.GONE); binding.recentIpLabel.setVisibility(View.GONE);
} }
if (accountAdmin.getCreated_at() == null) { if (accountAdmin.created_at == null) {
joined.setVisibility(View.GONE); binding.joined.setVisibility(View.GONE);
joined_label.setVisibility(View.GONE); binding.joinedLabel.setVisibility(View.GONE);
} }
if (accountAdmin.isDisabled()) { if (accountAdmin.disabled) {
login_status.setText(getString(R.string.disabled)); binding.loginStatus.setText(getString(R.string.disabled));
} else if (accountAdmin.isSilenced()) { } else if (accountAdmin.silenced) {
login_status.setText(getString(R.string.silenced)); binding.loginStatus.setText(getString(R.string.silenced));
} else if (accountAdmin.isSuspended()) { } else if (accountAdmin.suspended) {
login_status.setText(getString(R.string.suspended)); binding.loginStatus.setText(getString(R.string.suspended));
} else { } else {
login_status.setText(getString(R.string.active)); binding.loginStatus.setText(getString(R.string.active));
} }
if (accountAdmin.getDomain() == null || accountAdmin.getDomain().equals("null")) { if (accountAdmin.domain == null || accountAdmin.domain.equals("null")) {
warn.setVisibility(View.VISIBLE); binding.warn.setVisibility(View.VISIBLE);
email_user.setVisibility(View.VISIBLE); binding.emailUser.setVisibility(View.VISIBLE);
comment_label.setVisibility(View.VISIBLE); binding.commentLabel.setVisibility(View.VISIBLE);
comment.setVisibility(View.VISIBLE); binding.comment.setVisibility(View.VISIBLE);
recent_ip.setText(accountAdmin.getIp()); binding.recentIp.setText(accountAdmin.ip != null ? accountAdmin.ip.ip : "");
disable.setVisibility(View.VISIBLE); binding.disable.setVisibility(View.VISIBLE);
suspend.setVisibility(View.VISIBLE); binding.suspend.setVisibility(View.VISIBLE);
} else { } else {
warn.setVisibility(View.GONE); binding.warn.setVisibility(View.GONE);
email_user.setVisibility(View.GONE); binding.emailUser.setVisibility(View.GONE);
email_user.setChecked(false); binding.emailUser.setChecked(false);
comment.setVisibility(View.GONE); binding.comment.setVisibility(View.GONE);
recent_ip.setText("-"); binding.recentIp.setText("-");
permissions.setText("-"); binding.permissions.setText("-");
email.setText("-"); binding.email.setText("-");
disable.setVisibility(View.GONE); binding.disable.setVisibility(View.GONE);
suspend.setVisibility(View.VISIBLE); binding.suspend.setVisibility(View.VISIBLE);
comment_label.setVisibility(View.GONE); binding.commentLabel.setVisibility(View.GONE);
} }
if (accountAdmin.getRole() != null) { if (accountAdmin.role != null) {
switch (accountAdmin.getRole()) { switch (accountAdmin.role) {
case "user": case "user":
permissions.setText(getString(R.string.user)); binding.permissions.setText(getString(R.string.user));
break; break;
case "moderator": case "moderator":
permissions.setText(getString(R.string.moderator)); binding.permissions.setText(getString(R.string.moderator));
break; break;
case "admin": case "admin":
permissions.setText(getString(R.string.administrator)); binding.permissions.setText(getString(R.string.administrator));
break; break;
} }
if (accountAdmin.getRole().equals("admin") || accountAdmin.getRole().equals("moderator")) { if (accountAdmin.role.equals("admin") || accountAdmin.role.equals("moderator")) {
warn.setVisibility(View.GONE); binding.warn.setVisibility(View.GONE);
suspend.setVisibility(View.GONE); binding.suspend.setVisibility(View.GONE);
silence.setVisibility(View.GONE); binding.silence.setVisibility(View.GONE);
disable.setVisibility(View.GONE); binding.disable.setVisibility(View.GONE);
email_user.setVisibility(View.GONE); binding.emailUser.setVisibility(View.GONE);
email_user.setChecked(false); binding.emailUser.setChecked(false);
comment.setVisibility(View.GONE); binding.comment.setVisibility(View.GONE);
comment_label.setVisibility(View.GONE); binding.commentLabel.setVisibility(View.GONE);
} }
email_status.setText(accountAdmin.isConfirmed() ? getString(R.string.confirmed) : getString(R.string.unconfirmed)); binding.emailStatus.setText(accountAdmin.confirmed ? getString(R.string.confirmed) : getString(R.string.unconfirmed));
} }
joined.setText(Helper.dateToString(accountAdmin.getCreated_at())); binding.joined.setText(Helper.dateToString(accountAdmin.created_at));
if (report != null) { if (report != null) {
assign.setVisibility(View.VISIBLE); binding.assign.setVisibility(View.VISIBLE);
status.setVisibility(View.VISIBLE); binding.status.setVisibility(View.VISIBLE);
if (report.getAssigned_account() == null) { if (report.assigned_account == null) {
assign.setText(getString(R.string.assign_to_me)); binding.assign.setText(getString(R.string.assign_to_me));
} else { } else {
assign.setText(getString(R.string.unassign)); binding.assign.setText(getString(R.string.unassign));
} }
assign.setOnClickListener(view -> { binding.assign.setOnClickListener(view -> {
if (report.getAssigned_account() == null) { if (report.assigned_account == null) {
new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.ASSIGN_TO_SELF, report.getId(), null, AccountReportActivity.this); adminVM.assignToSelf(MainActivity.currentInstance, MainActivity.currentToken, report.id).observe(this, adminReport -> {
});
} else { } else {
new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.UNASSIGN, report.getId(), null, AccountReportActivity.this); adminVM.unassign(MainActivity.currentInstance, MainActivity.currentToken, report.id).observe(this, adminReport -> {
});
} }
}); });
if (report.isAction_taken()) { if (report.action_taken) {
status.setText(getString(R.string.mark_unresolved)); binding.status.setText(getString(R.string.mark_unresolved));
} else { } else {
status.setText(getString(R.string.mark_resolved)); binding.status.setText(getString(R.string.mark_resolved));
} }
status.setOnClickListener(view -> { binding.status.setOnClickListener(view -> {
if (report.isAction_taken()) { if (report.action_taken) {
new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.REOPEN, report.getId(), null, AccountReportActivity.this); adminVM.reopen(MainActivity.currentInstance, MainActivity.currentToken, report.id).observe(this, adminReport -> {
});
} else { } else {
new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.RESOLVE, report.getId(), null, AccountReportActivity.this); adminVM.resolved(MainActivity.currentInstance, MainActivity.currentToken, report.id).observe(this, adminReport -> {
});
} }
}); });
} else { } else {
assign.setVisibility(View.GONE); binding.assign.setVisibility(View.GONE);
status.setVisibility(View.GONE); binding.status.setVisibility(View.GONE);
}
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
email_user.setVisibility(View.GONE);
email_user.setChecked(false);
comment.setVisibility(View.INVISIBLE);
comment_label.setVisibility(View.GONE);
warn.setVisibility(View.GONE);
silence.setVisibility(View.GONE);
assign.setVisibility(View.GONE);
} }
} }
public enum actionType {
ENABLE,
APPROVE,
REJECT,
NONE,
SILENCE,
DISABLE,
UNSILENCE,
SUSPEND,
UNSUSPEND,
ASSIGN_TO_SELF,
UNASSIGN,
REOPEN,
RESOLVE,
GET_ACCOUNTS,
GET_ONE_ACCOUNT,
GET_REPORTS,
GET_ONE_REPORT
}
} }

View file

@ -17,6 +17,7 @@ package app.fedilab.android.client.entities.api;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import java.util.List; import java.util.List;
public class Report implements Serializable { public class Report implements Serializable {
@ -25,6 +26,22 @@ public class Report implements Serializable {
public String id; public String id;
@SerializedName("action_taken") @SerializedName("action_taken")
public boolean action_taken; public boolean action_taken;
@SerializedName("comment")
public String comment;
@SerializedName("created_at")
public Date created_at;
@SerializedName("updated_at")
public Date updated_at;
@SerializedName("account")
public Account account;
@SerializedName("target_account")
public Account target_account;
@SerializedName("assigned_account")
public Account assigned_account;
@SerializedName("action_taken_by_account")
public String action_taken_by_account;
@SerializedName("statuses")
public List<Status> statuses;
public static class ReportParams implements Serializable { public static class ReportParams implements Serializable {
@SerializedName("account_id") @SerializedName("account_id")

View file

@ -231,6 +231,8 @@ public class Helper {
public static final String ARG_MENTION_BOOSTER = "ARG_MENTION_BOOSTER"; public static final String ARG_MENTION_BOOSTER = "ARG_MENTION_BOOSTER";
public static final String ARG_STATUS_REPLY_ID = "ARG_STATUS_REPLY_ID"; public static final String ARG_STATUS_REPLY_ID = "ARG_STATUS_REPLY_ID";
public static final String ARG_ACCOUNT = "ARG_ACCOUNT"; public static final String ARG_ACCOUNT = "ARG_ACCOUNT";
public static final String ARG_ACCOUNT_ID = "ARG_ACCOUNT_ID";
public static final String ARG_REPORT = "ARG_REPORT";
public static final String ARG_ACCOUNT_MENTION = "ARG_ACCOUNT_MENTION"; public static final String ARG_ACCOUNT_MENTION = "ARG_ACCOUNT_MENTION";
public static final String ARG_MINIFIED = "ARG_MINIFIED"; public static final String ARG_MINIFIED = "ARG_MINIFIED";
public static final String ARG_STATUS_REPORT = "ARG_STATUS_REPORT"; public static final String ARG_STATUS_REPORT = "ARG_STATUS_REPORT";

View file

@ -0,0 +1,73 @@
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 <http://www.gnu.org/licenses>. */
import android.os.Build;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import app.fedilab.android.databinding.DrawerAdminStatusReportBinding;
public class StatusReportAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final List<String> mData;
public StatusReportAdapter(List<String> data) {
this.mData = data;
}
@NotNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
DrawerAdminStatusReportBinding itemBinding = DrawerAdminStatusReportBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusReportViewHolder(itemBinding);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
String content;
StatusReportViewHolder holder = (StatusReportViewHolder) viewHolder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
content = Html.fromHtml(mData.get(position), Html.FROM_HTML_MODE_LEGACY).toString();
else
content = Html.fromHtml(mData.get(position)).toString();
holder.binding.reportContent.setText(content);
}
@Override
public int getItemCount() {
return mData.size();
}
public static class StatusReportViewHolder extends RecyclerView.ViewHolder {
DrawerAdminStatusReportBinding binding;
StatusReportViewHolder(DrawerAdminStatusReportBinding itemView) {
super(itemView.getRoot());
binding = itemView;
}
}
}

View file

@ -262,6 +262,7 @@ public class AdminVM extends AndroidViewModel {
return adminAccountMutableLiveData; return adminAccountMutableLiveData;
} }
/** /**
* Re-enable a local account whose login is currently disabled. * Re-enable a local account whose login is currently disabled.
* *

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?><!--
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 <http://www.gnu.org/licenses>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp">
<TextView
android:id="@+id/report_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>

View file

@ -1576,4 +1576,24 @@
<string name="email_user">Notify the user per e-mail</string> <string name="email_user">Notify the user per e-mail</string>
<string name="custom_warning">Custom warning</string> <string name="custom_warning">Custom warning</string>
<string name="list_reported_statuses">Reported statuses</string> <string name="list_reported_statuses">Reported statuses</string>
<string name="silenced">Silenced</string>
<string name="user">User</string>
<string name="moderator">Moderator</string>
<string name="administrator">Administrator</string>
<string name="confirmed">Confirmed</string>
<string name="unconfirmed">Unconfirmed</string>
<string name="assign_to_me">Assign to me</string>
<string name="unassign">Unassign</string>
<string name="mark_unresolved">Mark unresolved</string>
<string name="mark_resolved">Mark resolved</string>
<string name="account_rejected">Account rejected</string>
<string name="account_approved">Account approved</string>
<string name="account_warned">Account warned</string>
<string name="account_unsuspended">Account unsuspended</string>
<string name="account_suspended">Account suspended</string>
<string name="account_undisabled">Account undisabled</string>
<string name="account_disabled">Account disabled</string>
<string name="account_unsilenced">Account unsilenced</string>
<string name="account_silenced">Account silenced</string>
<string name="report">Report</string>
</resources> </resources>