Add statuses

This commit is contained in:
tom79 2019-06-21 19:10:45 +02:00
parent 36fac88338
commit 6b7f045892
5 changed files with 329 additions and 162 deletions

View File

@ -25,10 +25,15 @@ import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import app.fedilab.android.R;
import app.fedilab.android.asynctasks.PostAdminActionAsyncTask;
@ -36,6 +41,8 @@ import app.fedilab.android.client.API;
import app.fedilab.android.client.APIResponse;
import app.fedilab.android.client.Entities.AccountAdmin;
import app.fedilab.android.client.Entities.Report;
import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.drawers.StatusReportAdapter;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.interfaces.OnAdminActionInterface;
import es.dmoral.toasty.Toasty;
@ -107,6 +114,18 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
}
if( report != null) {
targeted_account = report.getAccount();
RecyclerView lv_statuses = findViewById(R.id.lv_statuses);
ArrayList<String> contents = new ArrayList<>();
for(Status status: report.getStatuses()){
contents.add(status.getContent());
}
lv_statuses.setLayoutManager(new LinearLayoutManager(this));
StatusReportAdapter adapter = new StatusReportAdapter(this, contents);
lv_statuses.setAdapter(adapter);
LinearLayout statuses_container = findViewById(R.id.statuses_container);
statuses_container.setVisibility(View.VISIBLE);
}
fillReport(targeted_account);

View File

@ -0,0 +1,99 @@
package app.fedilab.android.drawers;
/* Copyright 2019 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.content.Context;
import android.os.Build;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import app.fedilab.android.R;
public class StatusReportAdapter extends RecyclerView.Adapter<StatusReportAdapter.ViewHolder> {
private List<String> mData;
private LayoutInflater mInflater;
private ItemClickListener mClickListener;
public StatusReportAdapter(Context context, List<String> data) {
this.mInflater = LayoutInflater.from(context);
this.mData = data;
}
@NotNull
@Override
public ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.drawer_status_report, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NotNull ViewHolder holder, int position) {
String content;
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.report_content.setText(content);
}
// total number of rows
@Override
public int getItemCount() {
return mData.size();
}
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView report_content;
ViewHolder(View itemView) {
super(itemView);
report_content = itemView.findViewById(R.id.report_content);
itemView.setOnClickListener(this);
}
@Override
public void onClick(View view) {
if (mClickListener != null) mClickListener.onItemClick(view, getAdapterPosition());
}
}
String getItem(int id) {
return mData.get(id);
}
void setClickListener(ItemClickListener itemClickListener) {
this.mClickListener = itemClickListener;
}
public interface ItemClickListener {
void onItemClick(View view, int position);
}
}

View File

@ -32,190 +32,206 @@
android:theme="@style/AppTheme.AppBarOverlay">
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/permissions"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/permissions"
android:layout_width="wrap_content"
android:layout_weight="3"
android:layout_height="wrap_content" />
</LinearLayout>
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/email"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_weight="3"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/permissions"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/permissions"
android:layout_width="wrap_content"
android:layout_weight="3"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/email"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_weight="3"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/email_status"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/email_status"
android:layout_width="wrap_content"
android:layout_weight="3"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/email_status"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/email_status"
android:layout_width="wrap_content"
android:layout_weight="3"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/login_status"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/login_status"
android:layout_width="wrap_content"
android:layout_weight="3"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/login_status"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/login_status"
android:layout_width="wrap_content"
android:layout_weight="3"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/joined"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/joined"
android:layout_width="wrap_content"
android:layout_weight="3"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/joined"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/joined"
android:layout_width="wrap_content"
android:layout_weight="3"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/recent_ip"
android:layout_width="wrap_content"
android:layout_weight="1"
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/recent_ip"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/recent_ip"
android:layout_width="wrap_content"
android:layout_weight="3"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<Button
android:id="@+id/warn"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/warn"
android:textSize="16sp" />
<Button
android:id="@+id/disable"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/disable"
android:textSize="16sp" />
<Button
android:id="@+id/silence"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/silence"
android:textSize="16sp" />
</LinearLayout>
<CheckBox
android:layout_marginTop="20dp"
android:checked="true"
android:id="@+id/email_user"
android:text="@string/email_user"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/recent_ip"
android:layout_width="wrap_content"
android:layout_weight="3"
android:labelFor="@+id/comment"
android:text="@string/custom_warning"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<EditText
android:minLines="3"
android:id="@+id/comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<!--
<Button
android:id="@+id/warn"
android:id="@+id/action"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/warn"
android:textSize="16sp" />
android:text="@string/perform_action"
android:textSize="18sp" />
-->
<LinearLayout
android:layout_width="match_parent"
android:visibility="gone"
android:layout_marginTop="20dp"
android:layout_height="wrap_content" android:orientation="vertical"
android:id="@+id/statuses_container">
<TextView
android:text="@string/list_reported_statuses"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/lv_statuses"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:divider="@null"
/>
</LinearLayout>
<Button
android:id="@+id/disable"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/disable"
android:textSize="16sp" />
<Button
android:id="@+id/silence"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/silence"
android:textSize="16sp" />
</LinearLayout>
<CheckBox
android:layout_marginTop="20dp"
android:checked="true"
android:id="@+id/email_user"
android:text="@string/email_user"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:labelFor="@+id/comment"
android:text="@string/custom_warning"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:minLines="3"
android:id="@+id/comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</ScrollView>
<!--
<Button
android:id="@+id/action"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/perform_action"
android:textSize="18sp" />
-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/lv_statuses"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:divider="@null"
/>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019 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

@ -1057,6 +1057,7 @@
<string name="administrator">Administrator</string>
<string name="confirmed">Confirmed</string>
<string name="unconfirmed">Not confirmed</string>
<string name="list_reported_statuses">Reported statuses</string>
<plurals name="number_of_vote">
<item quantity="one">%d vote</item>
<item quantity="other">%d votes</item>