optionally forward report

closes #205
This commit is contained in:
sk
2022-12-28 14:45:20 +01:00
parent a3c3fec9b4
commit 6107698a76
4 changed files with 69 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ import android.view.ViewGroup;
import android.view.WindowInsets;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.TextView;
import com.squareup.otto.Subscribe;
@@ -28,15 +29,17 @@ import java.util.ArrayList;
import me.grishka.appkit.Nav;
import me.grishka.appkit.api.Callback;
import me.grishka.appkit.api.ErrorResponse;
import me.grishka.appkit.fragments.ToolbarFragment;
import me.grishka.appkit.utils.V;
public class ReportCommentFragment extends MastodonToolbarFragment{
private String accountID;
private Account reportAccount;
private Button btn;
private View buttonBar;
private View buttonBar, forwardReportItem;
private TextView forwardReportText;
private Switch forwardReportSwitch;
private EditText commentEdit;
private boolean forwardReport;
@Override
public void onCreate(Bundle savedInstanceState){
@@ -77,7 +80,17 @@ public class ReportCommentFragment extends MastodonToolbarFragment{
view.findViewById(R.id.btn_back).setOnClickListener(this::onButtonClick);
buttonBar=view.findViewById(R.id.button_bar);
commentEdit=view.findViewById(R.id.text);
forwardReportSwitch = view.findViewById(R.id.forward_report_switch);
forwardReportItem = view.findViewById(R.id.forward_report);
forwardReportText = view.findViewById(R.id.forward_report_text);
String domain = reportAccount.getDomain();
if (domain == null) {
forwardReportItem.setVisibility(View.GONE);
} else {
forwardReportItem.setOnClickListener(this::onForwardReportClick);
forwardReportText.setText(getActivity().getString(R.string.sk_forward_report_to, domain));
forwardReportSwitch.setChecked(forwardReport = true);
}
return view;
}
@@ -102,7 +115,7 @@ public class ReportCommentFragment extends MastodonToolbarFragment{
ReportReason reason=ReportReason.valueOf(getArguments().getString("reason"));
ArrayList<String> statusIDs=getArguments().getStringArrayList("statusIDs");
ArrayList<String> ruleIDs=getArguments().getStringArrayList("ruleIDs");
new SendReport(reportAccount.id, reason, statusIDs, ruleIDs, v.getId()==R.id.btn_back ? null : commentEdit.getText().toString(), true)
new SendReport(reportAccount.id, reason, statusIDs, ruleIDs, v.getId()==R.id.btn_back ? null : commentEdit.getText().toString(), forwardReport)
.setCallback(new Callback<>(){
@Override
public void onSuccess(Object result){
@@ -123,6 +136,11 @@ public class ReportCommentFragment extends MastodonToolbarFragment{
.exec(accountID);
}
private void onForwardReportClick(View v) {
forwardReport = !forwardReport;
forwardReportSwitch.setChecked(forwardReport);
}
@Subscribe
public void onFinishReportFragments(FinishReportFragmentsEvent ev){
if(ev.reportAccountID.equals(reportAccount.id))

View File

@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:pathData="M14.723 16.221c-0.293 0.293-0.293 0.768 0 1.06 0.293 0.294 0.768 0.293 1.061 0l4.997-5.003c0.292-0.293 0.292-0.768 0-1.06L15.783 6.22c-0.293-0.293-0.768-0.293-1.06 0-0.294 0.293-0.294 0.767-0.001 1.06l3.72 3.72H10.6c-1.595 0-2.81 0.242-3.889 0.764L6.466 11.89c-1.109 0.593-1.983 1.467-2.576 2.576C3.28 15.606 3 16.884 3 18.6c0 0.414 0.336 0.75 0.75 0.75S4.5 19.014 4.5 18.6c0-1.484 0.228-2.52 0.713-3.428 0.453-0.847 1.113-1.507 1.96-1.96 0.838-0.448 1.786-0.676 3.094-0.709L10.6 12.5h7.837l-3.715 3.721z" android:fillColor="@color/fluent_default_icon_tint"/>
</vector>

View File

@@ -26,6 +26,49 @@
android:gravity="top|start"
android:minHeight="212dp"/>
<LinearLayout
android:id="@+id/forward_report"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="8dp"
android:paddingVertical="8dp"
android:gravity="center_vertical"
android:layoutDirection="locale"
android:background="?android:selectableItemBackground">
<ImageView
android:id="@+id/icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="32dp"
android:importantForAccessibility="no"
android:tint="?android:textColorPrimary"
android:src="@drawable/ic_fluent_arrow_forward_24_regular"/>
<TextView
android:id="@+id/forward_report_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingVertical="8dp"
android:textSize="16sp"
android:text="@string/sk_forward_report_to"
android:textColor="?android:textColorPrimary" />
<Switch
android:id="@+id/forward_report_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:duplicateParentState="true"
android:layout_marginStart="16dp"
android:layout_marginEnd="12dp"
android:focusable="false"
android:clickable="false"/>
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@@ -102,4 +102,5 @@
<string name="sk_already_reblogged">Already reblogged</string>
<string name="sk_reply_as">Reply with other account</string>
<string name="sk_settings_uniform_icon_for_notifications">Uniform icon for all notifications</string>
<string name="sk_forward_report_to">Forward to %s</string>
</resources>