Allow to report a single account
This commit is contained in:
parent
a23cd0358f
commit
4b314edbcd
|
@ -41,6 +41,8 @@ import androidx.viewpager.widget.PagerAdapter;
|
|||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
|
@ -50,6 +52,7 @@ import android.text.style.UnderlineSpan;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -1026,6 +1029,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
|
||||
}if( isOwner) {
|
||||
popup.getMenu().findItem(R.id.action_block).setVisible(false);
|
||||
popup.getMenu().findItem(R.id.action_report).setVisible(false);
|
||||
popup.getMenu().findItem(R.id.action_mute).setVisible(false);
|
||||
popup.getMenu().findItem(R.id.action_mention).setVisible(false);
|
||||
popup.getMenu().findItem(R.id.action_follow_instance).setVisible(false);
|
||||
|
@ -1223,6 +1227,36 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
doActionAccount = API.StatusAction.MUTE;
|
||||
}
|
||||
break;
|
||||
case R.id.action_report:
|
||||
builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
|
||||
builderInner.setTitle(R.string.report_account);
|
||||
//Text for report
|
||||
EditText input = new EditText(ShowAccountActivity.this);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
input.setLayoutParams(lp);
|
||||
builderInner.setView(input);
|
||||
doActionAccount = API.StatusAction.REPORT;
|
||||
builderInner.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog,int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderInner.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog,int which) {
|
||||
String targetedId;
|
||||
String comment = null;
|
||||
if (input.getText() != null)
|
||||
comment = input.getText().toString();
|
||||
new PostActionAsyncTask(getApplicationContext(), doActionAccount, account.getId(), null, comment, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderInner.show();
|
||||
return true;
|
||||
case R.id.action_block:
|
||||
builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
|
||||
builderInner.setTitle(stringArrayConf[1]);
|
||||
|
|
|
@ -161,8 +161,13 @@ public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (apiAction == API.StatusAction.REPORT)
|
||||
statusCode = api.reportAction(status, comment);
|
||||
if (apiAction == API.StatusAction.REPORT) {
|
||||
if( status != null ) {
|
||||
statusCode = api.reportAction(status, comment);
|
||||
}else{
|
||||
statusCode = api.reportAction(targetedId, comment);
|
||||
}
|
||||
}
|
||||
else if (apiAction == API.StatusAction.CREATESTATUS)
|
||||
statusCode = api.statusAction(status);
|
||||
else if(apiAction == API.StatusAction.UPDATESERVERSCHEDULE) {
|
||||
|
|
|
@ -2623,6 +2623,16 @@ public class API {
|
|||
return postAction(API.StatusAction.REPORT, null, status, comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the post action
|
||||
* @param targetedId targeted account
|
||||
* @param comment String comment for the report
|
||||
* @return in status code - Should be equal to 200 when action is done
|
||||
*/
|
||||
public int reportAction(String targetedId, String comment){
|
||||
return postAction(API.StatusAction.REPORT, targetedId, null, comment);
|
||||
}
|
||||
|
||||
public int statusAction(Status status){
|
||||
return postAction(StatusAction.CREATESTATUS, null, status, null);
|
||||
}
|
||||
|
@ -2720,9 +2730,14 @@ public class API {
|
|||
case REPORT:
|
||||
action = "/reports";
|
||||
params = new HashMap<>();
|
||||
params.put("account_id", status.getAccount().getId());
|
||||
if( status != null )
|
||||
params.put("account_id", status.getAccount().getId());
|
||||
else
|
||||
params.put("account_id", targetedId);
|
||||
params.put("comment", comment);
|
||||
params.put("status_ids[]", status.getId());
|
||||
if( status != null) {
|
||||
params.put("status_ids[]", status.getId());
|
||||
}
|
||||
break;
|
||||
case CREATESTATUS:
|
||||
params = new HashMap<>();
|
||||
|
|
|
@ -51,6 +51,11 @@
|
|||
android:title="@string/follow_instance"
|
||||
android:icon="@drawable/ic_public_world"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_report"
|
||||
android:title="@string/more_action_3"
|
||||
android:icon="@drawable/ic_block"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_block_instance"
|
||||
android:title="@string/block_domain"
|
||||
|
|
|
@ -1146,6 +1146,7 @@
|
|||
<string name="set_backup">Backup</string>
|
||||
<string name="set_auto_backup">Auto backup statuses</string>
|
||||
<string name="set_auto_backup_indication">This option is per account. It will launch a service that will automatically store your statuses locally in the database. That allows to get statistics and charts</string>
|
||||
<string name="report_account">Report account</string>
|
||||
<plurals name="number_of_vote">
|
||||
<item quantity="one">%d vote</item>
|
||||
<item quantity="other">%d votes</item>
|
||||
|
|
Loading…
Reference in New Issue