Improve API
This commit is contained in:
parent
b636e54ec5
commit
e3180c1956
|
@ -19,7 +19,6 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
|
@ -235,7 +234,6 @@ public class API {
|
|||
}
|
||||
try {
|
||||
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl(endpoint), 60, params, prefKeyOauthTokenT);
|
||||
Log.v(Helper.TAG,response);
|
||||
switch (action){
|
||||
case GET_ACCOUNTS:
|
||||
List<AccountAdmin> accountAdmins = parseAccountAdminResponse(new JSONArray(response));
|
||||
|
@ -5056,9 +5054,15 @@ public class API {
|
|||
report.setComment(resobj.getString("comment"));
|
||||
report.setCreated_at(Helper.mstStringToDate(context, resobj.getString("created_at")));
|
||||
report.setUpdated_at(Helper.mstStringToDate(context, resobj.getString("updated_at")));
|
||||
report.setAccount_id(resobj.getString("account_id"));
|
||||
report.setTarget_account_id(resobj.getString("target_account_id"));
|
||||
report.setAssigned_account_id(resobj.getString("assigned_account_id"));
|
||||
if( !resobj.isNull("account")) {
|
||||
report.setAccount(parseAccountResponse(context, resobj.getJSONObject("account")));
|
||||
}
|
||||
if( !resobj.isNull("target_account")) {
|
||||
report.setTarget_account(parseAccountResponse(context, resobj.getJSONObject("target_account")));
|
||||
}
|
||||
if( !resobj.isNull("assigned_account")) {
|
||||
report.setAssigned_account(parseAccountResponse(context, resobj.getJSONObject("assigned_account")));
|
||||
}
|
||||
report.setAction_taken_by_account_id(resobj.getString("action_taken_by_account_id"));
|
||||
report.setStatuses(parseStatuses(context, resobj.getJSONArray("statuses")));
|
||||
}catch (Exception ignored){}
|
||||
|
|
|
@ -28,9 +28,9 @@ public class Report implements Parcelable {
|
|||
private String comment;
|
||||
private Date created_at;
|
||||
private Date updated_at;
|
||||
private String account_id;
|
||||
private String target_account_id;
|
||||
private String assigned_account_id;
|
||||
private Account account;
|
||||
private Account target_account;
|
||||
private Account assigned_account;
|
||||
private String action_taken_by_account_id;
|
||||
private List<Status> statuses;
|
||||
|
||||
|
@ -75,29 +75,6 @@ public class Report implements Parcelable {
|
|||
this.updated_at = updated_at;
|
||||
}
|
||||
|
||||
public String getAccount_id() {
|
||||
return account_id;
|
||||
}
|
||||
|
||||
public void setAccount_id(String account_id) {
|
||||
this.account_id = account_id;
|
||||
}
|
||||
|
||||
public String getTarget_account_id() {
|
||||
return target_account_id;
|
||||
}
|
||||
|
||||
public void setTarget_account_id(String target_account_id) {
|
||||
this.target_account_id = target_account_id;
|
||||
}
|
||||
|
||||
public String getAssigned_account_id() {
|
||||
return assigned_account_id;
|
||||
}
|
||||
|
||||
public void setAssigned_account_id(String assigned_account_id) {
|
||||
this.assigned_account_id = assigned_account_id;
|
||||
}
|
||||
|
||||
public String getAction_taken_by_account_id() {
|
||||
return action_taken_by_account_id;
|
||||
|
@ -116,6 +93,33 @@ public class Report implements Parcelable {
|
|||
}
|
||||
|
||||
|
||||
public Report() {
|
||||
}
|
||||
|
||||
public Account getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(Account account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public Account getTarget_account() {
|
||||
return target_account;
|
||||
}
|
||||
|
||||
public void setTarget_account(Account target_account) {
|
||||
this.target_account = target_account;
|
||||
}
|
||||
|
||||
public Account getAssigned_account() {
|
||||
return assigned_account;
|
||||
}
|
||||
|
||||
public void setAssigned_account(Account assigned_account) {
|
||||
this.assigned_account = assigned_account;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
|
@ -128,16 +132,13 @@ public class Report implements Parcelable {
|
|||
dest.writeString(this.comment);
|
||||
dest.writeLong(this.created_at != null ? this.created_at.getTime() : -1);
|
||||
dest.writeLong(this.updated_at != null ? this.updated_at.getTime() : -1);
|
||||
dest.writeString(this.account_id);
|
||||
dest.writeString(this.target_account_id);
|
||||
dest.writeString(this.assigned_account_id);
|
||||
dest.writeParcelable(this.account, flags);
|
||||
dest.writeParcelable(this.target_account, flags);
|
||||
dest.writeParcelable(this.assigned_account, flags);
|
||||
dest.writeString(this.action_taken_by_account_id);
|
||||
dest.writeTypedList(this.statuses);
|
||||
}
|
||||
|
||||
public Report() {
|
||||
}
|
||||
|
||||
protected Report(Parcel in) {
|
||||
this.id = in.readString();
|
||||
this.action_taken = in.readString();
|
||||
|
@ -146,14 +147,14 @@ public class Report implements Parcelable {
|
|||
this.created_at = tmpCreated_at == -1 ? null : new Date(tmpCreated_at);
|
||||
long tmpUpdated_at = in.readLong();
|
||||
this.updated_at = tmpUpdated_at == -1 ? null : new Date(tmpUpdated_at);
|
||||
this.account_id = in.readString();
|
||||
this.target_account_id = in.readString();
|
||||
this.assigned_account_id = in.readString();
|
||||
this.account = in.readParcelable(Account.class.getClassLoader());
|
||||
this.target_account = in.readParcelable(Account.class.getClassLoader());
|
||||
this.assigned_account = in.readParcelable(Account.class.getClassLoader());
|
||||
this.action_taken_by_account_id = in.readString();
|
||||
this.statuses = in.createTypedArrayList(Status.CREATOR);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<Report> CREATOR = new Parcelable.Creator<Report>() {
|
||||
public static final Creator<Report> CREATOR = new Creator<Report>() {
|
||||
@Override
|
||||
public Report createFromParcel(Parcel source) {
|
||||
return new Report(source);
|
||||
|
|
|
@ -179,12 +179,12 @@ public class AccountsListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
if( account.getDisplay_name() != null && !account.getDisplay_name().trim().equals(""))
|
||||
holder.account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
|
||||
else
|
||||
holder.account_dn.setText(account.getDisplay_name().replace("@",""));
|
||||
holder.account_dn.setText(account.getUsername().replace("@",""));
|
||||
}else
|
||||
holder.account_dn.setText( account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.account_un.setText(String.format("@%s",account.getUsername()));
|
||||
holder.account_ac.setText(account.getAcct());
|
||||
if( account.getDisplay_name().equals(account.getAcct()))
|
||||
if( account.getUsername().equals(account.getAcct()))
|
||||
holder.account_ac.setVisibility(View.GONE);
|
||||
else
|
||||
holder.account_ac.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -72,28 +72,34 @@ public class ReportsListAdapter extends RecyclerView.Adapter implements OnRetrie
|
|||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||
final ReportsListAdapter.ViewHolder holder = (ReportsListAdapter.ViewHolder) viewHolder;
|
||||
Report report = reports.get(position);
|
||||
Account account = report.getStatuses().get(0).getAccount();
|
||||
Account account = report.getAccount();
|
||||
Account target_account = report.getTarget_account();
|
||||
|
||||
|
||||
account.makeAccountNameEmoji(context, ReportsListAdapter.this, account);
|
||||
target_account.makeAccountNameEmoji(context, ReportsListAdapter.this, target_account);
|
||||
if( account.getdisplayNameSpan() == null || account.getdisplayNameSpan().toString().trim().equals("")) {
|
||||
if( account.getDisplay_name() != null && !account.getDisplay_name().trim().equals(""))
|
||||
holder.account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
|
||||
holder.account_dn_reporter.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
|
||||
else
|
||||
holder.account_dn.setText(account.getDisplay_name().replace("@",""));
|
||||
holder.account_dn_reporter.setText(account.getUsername().replace("@",""));
|
||||
}else
|
||||
holder.account_dn.setText( account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.account_dn_reporter.setText( account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
|
||||
if( account.getdisplayNameSpan() == null || account.getdisplayNameSpan().toString().trim().equals("")) {
|
||||
if( account.getDisplay_name() != null && !account.getDisplay_name().trim().equals(""))
|
||||
holder.account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
|
||||
if( target_account.getdisplayNameSpan() == null || target_account.getdisplayNameSpan().toString().trim().equals("")) {
|
||||
if( target_account.getDisplay_name() != null && !target_account.getDisplay_name().trim().equals(""))
|
||||
holder.account_dn.setText(Helper.shortnameToUnicode(target_account.getDisplay_name(), true));
|
||||
else
|
||||
holder.account_dn.setText(account.getDisplay_name().replace("@",""));
|
||||
holder.account_dn.setText(target_account.getUsername().replace("@",""));
|
||||
}else
|
||||
holder.account_dn.setText( account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.account_dn.setText( target_account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
|
||||
|
||||
Helper.loadGiF(context, account.getAvatar(), holder.account_pp);
|
||||
Helper.loadGiF(context, account.getAvatar(), holder.account_pp_reporter);
|
||||
holder.account_un.setText(String.format("@%s",account.getUsername()));
|
||||
holder.account_ac.setText(account.getAcct());
|
||||
if( account.getDisplay_name().equals(account.getAcct()))
|
||||
if( account.getUsername().equals(account.getAcct()))
|
||||
holder.account_ac.setVisibility(View.GONE);
|
||||
else
|
||||
holder.account_ac.setVisibility(View.VISIBLE);
|
||||
|
@ -138,9 +144,9 @@ public class ReportsListAdapter extends RecyclerView.Adapter implements OnRetrie
|
|||
|
||||
|
||||
private class ViewHolder extends RecyclerView.ViewHolder{
|
||||
ImageView account_pp;
|
||||
ImageView account_pp, account_pp_reporter;
|
||||
TextView account_ac;
|
||||
TextView account_dn;
|
||||
TextView account_dn, account_dn_reporter;
|
||||
TextView account_un;
|
||||
TextView report_action_taken;
|
||||
|
||||
|
@ -149,7 +155,9 @@ public class ReportsListAdapter extends RecyclerView.Adapter implements OnRetrie
|
|||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
account_pp = itemView.findViewById(R.id.account_pp);
|
||||
account_pp_reporter = itemView.findViewById(R.id.account_pp_reporter);
|
||||
account_dn = itemView.findViewById(R.id.account_dn);
|
||||
account_dn_reporter = itemView.findViewById(R.id.account_dn_reporter);
|
||||
account_ac = itemView.findViewById(R.id.account_ac);
|
||||
account_un = itemView.findViewById(R.id.account_un);
|
||||
report_action_taken = itemView.findViewById(R.id.report_action_taken);
|
||||
|
|
|
@ -22,60 +22,75 @@
|
|||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:id="@+id/main_container"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/account_pp"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:contentDescription="@string/profile_picture"/>
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/account_container"
|
||||
android:orientation="vertical">
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/account_pp"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:contentDescription="@string/profile_picture"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/account_dn"
|
||||
android:maxLines="1"
|
||||
android:id="@+id/account_container"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/account_dn"
|
||||
android:maxLines="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
||||
<TextView
|
||||
android:id="@+id/account_un"
|
||||
android:maxLines="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/account_un"
|
||||
android:layout_marginTop="10dp"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/account_ac"
|
||||
android:textSize="16sp"
|
||||
android:maxLines="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageView
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/account_pp_reporter"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:contentDescription="@string/profile_picture"/>
|
||||
<TextView
|
||||
android:id="@+id/account_dn_reporter"
|
||||
android:maxLines="1"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
||||
<TextView
|
||||
android:layout_marginTop="10dp"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/account_ac"
|
||||
android:textSize="16sp"
|
||||
android:maxLines="1"
|
||||
android:id="@+id/report_action_taken"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/report_action_taken"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:text="@string/request_sent"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue