enable reporting users without statuses (#1445)
This commit is contained in:
parent
8353ed7214
commit
d13a341a35
40 changed files with 38 additions and 79 deletions
|
@ -43,6 +43,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton
|
|||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.keylesspalace.tusky.adapter.AccountFieldAdapter
|
||||
import com.keylesspalace.tusky.components.report.ReportActivity
|
||||
import com.keylesspalace.tusky.di.ViewModelFactory
|
||||
import com.keylesspalace.tusky.entity.Account
|
||||
import com.keylesspalace.tusky.entity.Relationship
|
||||
|
@ -628,12 +629,13 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
|||
}
|
||||
|
||||
} else {
|
||||
// It shouldn't be possible to block or follow yourself.
|
||||
// It shouldn't be possible to block, follow, mute or report yourself.
|
||||
menu.removeItem(R.id.action_follow)
|
||||
menu.removeItem(R.id.action_block)
|
||||
menu.removeItem(R.id.action_mute)
|
||||
menu.removeItem(R.id.action_mute_domain)
|
||||
menu.removeItem(R.id.action_show_reblogs)
|
||||
menu.removeItem(R.id.action_report)
|
||||
}
|
||||
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
|
@ -725,6 +727,12 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
|||
viewModel.changeShowReblogsState()
|
||||
return true
|
||||
}
|
||||
R.id.action_report -> {
|
||||
if(loadedAccount != null) {
|
||||
startActivity(ReportActivity.getIntent(this, viewModel.accountId, loadedAccount!!.username))
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package com.keylesspalace.tusky.components.report
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.Spanned
|
||||
import android.view.MenuItem
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.lifecycle.Observer
|
||||
|
@ -27,7 +26,6 @@ import com.keylesspalace.tusky.BottomSheetActivity
|
|||
import com.keylesspalace.tusky.R
|
||||
import com.keylesspalace.tusky.components.report.adapter.ReportPagerAdapter
|
||||
import com.keylesspalace.tusky.di.ViewModelFactory
|
||||
import com.keylesspalace.tusky.util.HtmlUtils
|
||||
import com.keylesspalace.tusky.util.ThemeUtils
|
||||
import dagger.android.DispatchingAndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
|
@ -55,8 +53,7 @@ class ReportActivity : BottomSheetActivity(), HasAndroidInjector {
|
|||
throw IllegalStateException("accountId ($accountId) or accountUserName ($accountUserName) is null")
|
||||
}
|
||||
|
||||
viewModel.init(accountId, accountUserName,
|
||||
intent?.getStringExtra(STATUS_ID), intent?.getStringExtra(STATUS_CONTENT))
|
||||
viewModel.init(accountId, accountUserName, intent?.getStringExtra(STATUS_ID))
|
||||
|
||||
|
||||
setContentView(R.layout.activity_report)
|
||||
|
@ -143,16 +140,14 @@ class ReportActivity : BottomSheetActivity(), HasAndroidInjector {
|
|||
private const val ACCOUNT_ID = "account_id"
|
||||
private const val ACCOUNT_USERNAME = "account_username"
|
||||
private const val STATUS_ID = "status_id"
|
||||
private const val STATUS_CONTENT = "status_content"
|
||||
|
||||
@JvmStatic
|
||||
fun getIntent(context: Context, accountId: String, userName: String, statusId: String, statusContent: Spanned) =
|
||||
fun getIntent(context: Context, accountId: String, userName: String, statusId: String? = null) =
|
||||
Intent(context, ReportActivity::class.java)
|
||||
.apply {
|
||||
putExtra(ACCOUNT_ID, accountId)
|
||||
putExtra(ACCOUNT_USERNAME, userName)
|
||||
putExtra(STATUS_ID, statusId)
|
||||
putExtra(STATUS_CONTENT, HtmlUtils.toHtml(statusContent))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,21 +64,20 @@ class ReportViewModel @Inject constructor(
|
|||
var reportNote: String? = null
|
||||
var isRemoteNotify = false
|
||||
|
||||
private var statusContent: String? = null
|
||||
private var statusId: String? = null
|
||||
lateinit var accountUserName: String
|
||||
lateinit var accountId: String
|
||||
var isRemoteAccount: Boolean = false
|
||||
var remoteServer: String? = null
|
||||
|
||||
fun init(accountId: String, userName: String, statusId: String?, statusContent: String?) {
|
||||
fun init(accountId: String, userName: String, statusId: String?) {
|
||||
this.accountId = accountId
|
||||
this.accountUserName = userName
|
||||
this.statusId = statusId
|
||||
statusId?.let {
|
||||
selectedIds.add(it)
|
||||
}
|
||||
this.statusContent = statusContent
|
||||
|
||||
isRemoteAccount = userName.contains('@')
|
||||
if (isRemoteAccount) {
|
||||
remoteServer = userName.substring(userName.indexOf('@') + 1)
|
||||
|
@ -208,17 +207,15 @@ class ReportViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
fun setStatusChecked(status: Status, checked: Boolean) {
|
||||
if (checked)
|
||||
if (checked) {
|
||||
selectedIds.add(status.id)
|
||||
else
|
||||
} else {
|
||||
selectedIds.remove(status.id)
|
||||
}
|
||||
}
|
||||
|
||||
fun isStatusChecked(id: String): Boolean {
|
||||
return selectedIds.contains(id)
|
||||
}
|
||||
|
||||
fun isStatusesSelected(): Boolean {
|
||||
return selectedIds.isNotEmpty()
|
||||
}
|
||||
}
|
|
@ -72,14 +72,18 @@ class StatusesDataSource(private val accountId: String,
|
|||
retryBefore = null
|
||||
retryInitial = null
|
||||
initialLoad.postValue(NetworkState.LOADING)
|
||||
mastodonApi.statusObservable(params.requestedInitialKey).zipWith(
|
||||
mastodonApi.accountStatusesObservable(accountId, params.requestedInitialKey, null, params.requestedLoadSize - 1, true),
|
||||
BiFunction { status: Status, list: List<Status> ->
|
||||
val ret = ArrayList<Status>()
|
||||
ret.add(status)
|
||||
ret.addAll(list)
|
||||
return@BiFunction ret
|
||||
})
|
||||
if (params.requestedInitialKey == null) {
|
||||
mastodonApi.accountStatusesObservable(accountId, null, null, params.requestedLoadSize, true)
|
||||
} else {
|
||||
mastodonApi.statusObservable(params.requestedInitialKey).zipWith(
|
||||
mastodonApi.accountStatusesObservable(accountId, params.requestedInitialKey, null, params.requestedLoadSize - 1, true),
|
||||
BiFunction { status: Status, list: List<Status> ->
|
||||
val ret = ArrayList<Status>()
|
||||
ret.add(status)
|
||||
ret.addAll(list)
|
||||
return@BiFunction ret
|
||||
})
|
||||
}
|
||||
.doOnSubscribe {
|
||||
disposables.add(it)
|
||||
}
|
||||
|
|
|
@ -188,11 +188,7 @@ class ReportStatusesFragment : Fragment(), Injectable, AdapterHandler {
|
|||
}
|
||||
|
||||
buttonContinue.setOnClickListener {
|
||||
if (viewModel.isStatusesSelected()) {
|
||||
viewModel.navigateTo(Screen.Note)
|
||||
} else {
|
||||
Snackbar.make(swipeRefreshLayout, R.string.error_report_too_few_statuses, Snackbar.LENGTH_LONG).show()
|
||||
}
|
||||
viewModel.navigateTo(Screen.Note)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -202,7 +202,6 @@ class SearchStatusesFragment : SearchFragment<Pair<Status, StatusViewData.Concre
|
|||
val id = status.actionableId
|
||||
val accountId = status.actionableStatus.account.id
|
||||
val accountUsername = status.actionableStatus.account.username
|
||||
val content = status.actionableStatus.content
|
||||
val statusUrl = status.actionableStatus.url
|
||||
val accounts = viewModel.getAllAccountsOrderedByActive()
|
||||
var openAsTitle: String? = null
|
||||
|
@ -297,7 +296,7 @@ class SearchStatusesFragment : SearchFragment<Pair<Status, StatusViewData.Concre
|
|||
return@setOnMenuItemClickListener true
|
||||
}
|
||||
R.id.status_report -> {
|
||||
openReportPage(accountId, accountUsername, id, content)
|
||||
openReportPage(accountId, accountUsername, id)
|
||||
return@setOnMenuItemClickListener true
|
||||
}
|
||||
R.id.status_unreblog_private -> {
|
||||
|
@ -367,9 +366,8 @@ class SearchStatusesFragment : SearchFragment<Pair<Status, StatusViewData.Concre
|
|||
}
|
||||
}
|
||||
|
||||
private fun openReportPage(accountId: String, accountUsername: String, statusId: String,
|
||||
statusContent: Spanned) {
|
||||
startActivity(ReportActivity.getIntent(requireContext(), accountId, accountUsername, statusId, statusContent))
|
||||
private fun openReportPage(accountId: String, accountUsername: String, statusId: String) {
|
||||
startActivity(ReportActivity.getIntent(requireContext(), accountId, accountUsername, statusId))
|
||||
}
|
||||
|
||||
private fun showConfirmDeleteDialog(id: String, position: Int) {
|
||||
|
|
|
@ -165,7 +165,6 @@ public abstract class SFragment extends BaseFragment implements Injectable {
|
|||
final String id = status.getActionableId();
|
||||
final String accountId = status.getActionableStatus().getAccount().getId();
|
||||
final String accountUsername = status.getActionableStatus().getAccount().getUsername();
|
||||
final Spanned content = status.getActionableStatus().getContent();
|
||||
final String statusUrl = status.getActionableStatus().getUrl();
|
||||
List<AccountEntity> accounts = accountManager.getAllAccountsOrderedByActive();
|
||||
String openAsTitle = null;
|
||||
|
@ -273,7 +272,7 @@ public abstract class SFragment extends BaseFragment implements Injectable {
|
|||
return true;
|
||||
}
|
||||
case R.id.status_report: {
|
||||
openReportPage(accountId, accountUsername, id, content);
|
||||
openReportPage(accountId, accountUsername, id);
|
||||
return true;
|
||||
}
|
||||
case R.id.status_unreblog_private: {
|
||||
|
@ -340,9 +339,8 @@ public abstract class SFragment extends BaseFragment implements Injectable {
|
|||
startActivity(intent);
|
||||
}
|
||||
|
||||
protected void openReportPage(String accountId, String accountUsername, String statusId,
|
||||
Spanned statusContent) {
|
||||
startActivity(ReportActivity.getIntent(requireContext(),accountId,accountUsername,statusId,statusContent));
|
||||
protected void openReportPage(String accountId, String accountUsername, String statusId) {
|
||||
startActivity(ReportActivity.getIntent(requireContext(), accountId, accountUsername, statusId));
|
||||
}
|
||||
|
||||
protected void showConfirmDeleteDialog(final String id, final int position) {
|
||||
|
|
|
@ -19,7 +19,6 @@ import com.keylesspalace.tusky.entity.AccessToken;
|
|||
import com.keylesspalace.tusky.entity.Account;
|
||||
import com.keylesspalace.tusky.entity.AppCredentials;
|
||||
import com.keylesspalace.tusky.entity.Attachment;
|
||||
import com.keylesspalace.tusky.entity.Card;
|
||||
import com.keylesspalace.tusky.entity.Conversation;
|
||||
import com.keylesspalace.tusky.entity.Emoji;
|
||||
import com.keylesspalace.tusky.entity.Filter;
|
||||
|
@ -299,13 +298,6 @@ public interface MastodonApi {
|
|||
@POST("api/v1/follow_requests/{id}/reject")
|
||||
Call<Relationship> rejectFollowRequest(@Path("id") String accountId);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("api/v1/reports")
|
||||
Call<ResponseBody> report(
|
||||
@Field("account_id") String accountId,
|
||||
@Field("status_ids[]") List<String> statusIds,
|
||||
@Field("comment") String comment);
|
||||
|
||||
@GET("api/v1/search")
|
||||
Call<SearchResults> search(@Query("q") String q, @Query("resolve") Boolean resolve);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue