Fix up report activity/layout
This commit is contained in:
parent
1015f27554
commit
c1fc6959e7
|
@ -17,6 +17,7 @@ package com.keylesspalace.tusky;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
|
@ -25,6 +26,8 @@ import android.support.v7.widget.DividerItemDecoration;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
@ -45,6 +48,11 @@ public class ReportActivity extends BaseActivity {
|
||||||
private View anyView; // what Snackbar will use to find the root view
|
private View anyView; // what Snackbar will use to find the root view
|
||||||
private ReportAdapter adapter;
|
private ReportAdapter adapter;
|
||||||
private boolean reportAlreadyInFlight;
|
private boolean reportAlreadyInFlight;
|
||||||
|
private String accountId;
|
||||||
|
private String accountUsername;
|
||||||
|
private String statusId;
|
||||||
|
private String statusContent;
|
||||||
|
private EditText comment;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
@ -52,10 +60,10 @@ public class ReportActivity extends BaseActivity {
|
||||||
setContentView(R.layout.activity_report);
|
setContentView(R.layout.activity_report);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
final String accountId = intent.getStringExtra("account_id");
|
accountId = intent.getStringExtra("account_id");
|
||||||
String accountUsername = intent.getStringExtra("account_username");
|
accountUsername = intent.getStringExtra("account_username");
|
||||||
String statusId = intent.getStringExtra("status_id");
|
statusId = intent.getStringExtra("status_id");
|
||||||
String statusContent = intent.getStringExtra("status_content");
|
statusContent = intent.getStringExtra("status_content");
|
||||||
|
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
@ -64,6 +72,8 @@ public class ReportActivity extends BaseActivity {
|
||||||
String title = String.format(getString(R.string.report_username_format),
|
String title = String.format(getString(R.string.report_username_format),
|
||||||
accountUsername);
|
accountUsername);
|
||||||
bar.setTitle(title);
|
bar.setTitle(title);
|
||||||
|
bar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
bar.setDisplayShowHomeEnabled(true);
|
||||||
}
|
}
|
||||||
anyView = toolbar;
|
anyView = toolbar;
|
||||||
|
|
||||||
|
@ -85,28 +95,28 @@ public class ReportActivity extends BaseActivity {
|
||||||
HtmlUtils.fromHtml(statusContent), true);
|
HtmlUtils.fromHtml(statusContent), true);
|
||||||
adapter.addItem(reportStatus);
|
adapter.addItem(reportStatus);
|
||||||
|
|
||||||
final EditText comment = (EditText) findViewById(R.id.report_comment);
|
comment = (EditText) findViewById(R.id.report_comment);
|
||||||
Button send = (Button) findViewById(R.id.report_send);
|
|
||||||
reportAlreadyInFlight = false;
|
reportAlreadyInFlight = false;
|
||||||
send.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (reportAlreadyInFlight) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String[] statusIds = adapter.getCheckedStatusIds();
|
|
||||||
if (statusIds.length > 0) {
|
|
||||||
reportAlreadyInFlight = true;
|
|
||||||
sendReport(accountId, statusIds, comment.getText().toString());
|
|
||||||
} else {
|
|
||||||
comment.setError(getString(R.string.error_report_too_few_statuses));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
fetchRecentStatuses(accountId);
|
fetchRecentStatuses(accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onClickSend() {
|
||||||
|
if (reportAlreadyInFlight) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] statusIds = adapter.getCheckedStatusIds();
|
||||||
|
|
||||||
|
if (statusIds.length > 0) {
|
||||||
|
reportAlreadyInFlight = true;
|
||||||
|
sendReport(accountId, statusIds, comment.getText().toString());
|
||||||
|
} else {
|
||||||
|
comment.setError(getString(R.string.error_report_too_few_statuses));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void sendReport(final String accountId, final String[] statusIds,
|
private void sendReport(final String accountId, final String[] statusIds,
|
||||||
final String comment) {
|
final String comment) {
|
||||||
mastodonAPI.report(accountId, Arrays.asList(statusIds), comment).enqueue(new Callback<ResponseBody>() {
|
mastodonAPI.report(accountId, Arrays.asList(statusIds), comment).enqueue(new Callback<ResponseBody>() {
|
||||||
|
@ -167,4 +177,25 @@ public class ReportActivity extends BaseActivity {
|
||||||
private void onFetchStatusesFailure(Exception exception) {
|
private void onFetchStatusesFailure(Exception exception) {
|
||||||
Log.e(TAG, "Failed to fetch recent statuses to report. " + exception.getMessage());
|
Log.e(TAG, "Failed to fetch recent statuses to report. " + exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.report_toolbar, menu);
|
||||||
|
return super.onCreateOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case android.R.id.home: {
|
||||||
|
onBackPressed();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case R.id.action_report: {
|
||||||
|
onClickSend();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,51 +1,43 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
<LinearLayout
|
||||||
<android.support.v7.widget.Toolbar
|
|
||||||
android:id="@+id/toolbar"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="match_parent"
|
||||||
android:elevation="4dp"
|
android:orientation="vertical">
|
||||||
android:theme="@style/AppTheme.Account.AppBarLayout"
|
<android.support.v7.widget.Toolbar
|
||||||
app:popupTheme="@style/AppTheme.Account.ToolbarPopupTheme.Dark"
|
android:id="@+id/toolbar"
|
||||||
android:background="?attr/toolbar_background_color" />
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:elevation="4dp"
|
||||||
|
android:theme="@style/AppTheme.Account.AppBarLayout"
|
||||||
|
app:popupTheme="@style/AppTheme.Account.ToolbarPopupTheme.Dark"
|
||||||
|
android:background="?attr/toolbar_background_color" />
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:id="@+id/report_recycler_view"
|
android:id="@+id/report_recycler_view"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
android:fadeScrollbars="false"
|
android:fadeScrollbars="false"
|
||||||
android:background="?attr/report_status_background_color" />
|
android:background="?attr/report_status_background_color" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:id="@+id/report_comment"
|
android:id="@+id/report_comment"
|
||||||
android:inputType="textMultiLine"
|
android:inputType="textMultiLine"
|
||||||
android:gravity="top|start"
|
android:gravity="top|start"
|
||||||
android:ems="10"
|
android:background="@android:color/transparent"
|
||||||
android:layout_marginLeft="8dp"
|
android:ems="10"
|
||||||
android:layout_marginRight="8dp"
|
android:paddingLeft="16dp"
|
||||||
android:hint="@string/report_comment_hint" />
|
android:paddingRight="16dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
<RelativeLayout
|
android:paddingBottom="8dp"
|
||||||
android:layout_width="match_parent"
|
android:hint="@string/report_comment_hint" />
|
||||||
android:layout_height="wrap_content">
|
</LinearLayout>
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
<Button
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:id="@+id/report_send"
|
|
||||||
android:text="@string/action_report" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_report"
|
||||||
|
android:title="@string/action_report"
|
||||||
|
android:icon="@drawable/ic_send_24dp"
|
||||||
|
app:showAsAction="always"/>
|
||||||
|
</menu>
|
|
@ -54,7 +54,7 @@
|
||||||
<string name="notification_favourite_format">%s favourited your status</string>
|
<string name="notification_favourite_format">%s favourited your status</string>
|
||||||
<string name="notification_follow_format">%s followed you</string>
|
<string name="notification_follow_format">%s followed you</string>
|
||||||
|
|
||||||
<string name="report_username_format">Reporting @%s</string>
|
<string name="report_username_format">Report @%s</string>
|
||||||
<string name="report_comment_hint">Additional comments?</string>
|
<string name="report_comment_hint">Additional comments?</string>
|
||||||
|
|
||||||
<string name="action_compose">Compose</string>
|
<string name="action_compose">Compose</string>
|
||||||
|
|
|
@ -53,8 +53,8 @@
|
||||||
<item name="compose_content_warning_bar_background">@drawable/border_background_dark</item>
|
<item name="compose_content_warning_bar_background">@drawable/border_background_dark</item>
|
||||||
<item name="notification_content">@color/notification_content_faded_dark</item>
|
<item name="notification_content">@color/notification_content_faded_dark</item>
|
||||||
<item name="notification_icon_tint">@color/notification_icon_tint_dark</item>
|
<item name="notification_icon_tint">@color/notification_icon_tint_dark</item>
|
||||||
<item name="report_status_background_color">@color/report_status_background_dark</item>
|
<item name="report_status_background_color">@color/color_background_dark</item>
|
||||||
<item name="report_status_divider_drawable">@drawable/report_status_divider_dark</item>
|
<item name="report_status_divider_drawable">@drawable/status_divider_dark</item>
|
||||||
|
|
||||||
<item name="material_drawer_background">@color/window_background_dark</item>
|
<item name="material_drawer_background">@color/window_background_dark</item>
|
||||||
<item name="material_drawer_primary_text">@color/text_color_primary_dark</item>
|
<item name="material_drawer_primary_text">@color/text_color_primary_dark</item>
|
||||||
|
|
Loading…
Reference in New Issue