フォロー推奨ユーザのカラムでユーザを長押しして「フォロー推奨から削除…」を選べる
This commit is contained in:
parent
136bc487ac
commit
881a9fda46
|
@ -815,9 +815,8 @@ class Column(
|
|||
}
|
||||
}
|
||||
|
||||
// ミュート解除が成功した時に呼ばれる
|
||||
fun removeFromMuteList(target_account : SavedAccount, who_id : Long) {
|
||||
if(column_type == TYPE_MUTES && target_account.acct == access_info.acct) {
|
||||
fun removeUser(targetAccount : SavedAccount,columnType:Int,who_id:Long){
|
||||
if(column_type == columnType && targetAccount.acct == access_info.acct) {
|
||||
val tmp_list = ArrayList<TimelineItem>(list_data.size)
|
||||
for(o in list_data) {
|
||||
if(o is TootAccountRef) {
|
||||
|
@ -828,52 +827,11 @@ class Column(
|
|||
if(tmp_list.size != list_data.size) {
|
||||
list_data.clear()
|
||||
list_data.addAll(tmp_list)
|
||||
fireShowContent(reason = "removeFromMuteList")
|
||||
fireShowContent(reason = "removeUser")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ブロック解除が成功したので、ブロックリストから削除する
|
||||
fun removeFromBlockList(target_account : SavedAccount, who_id : Long) {
|
||||
if(column_type == TYPE_BLOCKS && target_account.acct == access_info.acct) {
|
||||
val tmp_list = ArrayList<TimelineItem>(list_data.size)
|
||||
for(o in list_data) {
|
||||
if(o is TootAccountRef) {
|
||||
if(o.get().id == who_id) continue
|
||||
}
|
||||
tmp_list.add(o)
|
||||
}
|
||||
if(tmp_list.size != list_data.size) {
|
||||
list_data.clear()
|
||||
list_data.addAll(tmp_list)
|
||||
fireShowContent(reason = "removeFromBlockList")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun removeFollowRequest(target_account : SavedAccount, who_id : Long) {
|
||||
if(target_account.acct != access_info.acct) return
|
||||
|
||||
if(column_type == TYPE_FOLLOW_REQUESTS) {
|
||||
val tmp_list = ArrayList<TimelineItem>(list_data.size)
|
||||
for(o in list_data) {
|
||||
if(o is TootAccountRef) {
|
||||
if(o.get().id == who_id) continue
|
||||
}
|
||||
tmp_list.add(o)
|
||||
}
|
||||
if(tmp_list.size != list_data.size) {
|
||||
list_data.clear()
|
||||
list_data.addAll(tmp_list)
|
||||
fireShowContent(reason = "removeFollowRequest 1")
|
||||
}
|
||||
} else {
|
||||
// 他のカラムでもフォロー状態の表示更新が必要
|
||||
fireRebindAdapterItems()
|
||||
}
|
||||
}
|
||||
|
||||
// ステータスが削除された時に呼ばれる
|
||||
fun onStatusRemoved(tl_host : String, status_id : Long) {
|
||||
|
||||
|
@ -4062,4 +4020,6 @@ class Column(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ internal class DlgContextMenu(
|
|||
val btnAccountWebPage = viewRoot.findViewById<View>(R.id.btnAccountWebPage)
|
||||
val btnFollowRequestOK = viewRoot.findViewById<View>(R.id.btnFollowRequestOK)
|
||||
val btnFollowRequestNG = viewRoot.findViewById<View>(R.id.btnFollowRequestNG)
|
||||
val btnDeleteSuggestion = viewRoot.findViewById<View>(R.id.btnDeleteSuggestion)
|
||||
val btnFollowFromAnotherAccount =
|
||||
viewRoot.findViewById<View>(R.id.btnFollowFromAnotherAccount)
|
||||
val btnSendMessageFromAnotherAccount =
|
||||
|
@ -130,6 +131,7 @@ internal class DlgContextMenu(
|
|||
btnAccountWebPage.setOnClickListener(this)
|
||||
btnFollowRequestOK.setOnClickListener(this)
|
||||
btnFollowRequestNG.setOnClickListener(this)
|
||||
btnDeleteSuggestion.setOnClickListener(this)
|
||||
btnFollowFromAnotherAccount.setOnClickListener(this)
|
||||
btnSendMessageFromAnotherAccount.setOnClickListener(this)
|
||||
btnOpenProfileFromAnotherAccount.setOnClickListener(this)
|
||||
|
@ -299,6 +301,10 @@ internal class DlgContextMenu(
|
|||
btnFollowRequestNG.visibility = View.GONE
|
||||
}
|
||||
|
||||
if( column_type != Column.TYPE_FOLLOW_SUGGESTION) {
|
||||
btnDeleteSuggestion.visibility = View.GONE
|
||||
}
|
||||
|
||||
if(account_list_non_pseudo.isEmpty()) {
|
||||
btnFollowFromAnotherAccount.visibility = View.GONE
|
||||
btnSendMessageFromAnotherAccount.visibility = View.GONE
|
||||
|
@ -462,6 +468,9 @@ internal class DlgContextMenu(
|
|||
R.id.btnFollowRequestOK ->
|
||||
Action_Follow.authorizeFollowRequest(activity, access_info, whoRef, true)
|
||||
|
||||
R.id.btnDeleteSuggestion ->
|
||||
Action_User.deleteSuggestion(activity, access_info, who)
|
||||
|
||||
R.id.btnFollowRequestNG ->
|
||||
Action_Follow.authorizeFollowRequest(activity, access_info, whoRef, false)
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.support.v7.app.AlertDialog
|
|||
|
||||
import jp.juggler.subwaytooter.ActMain
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.Column
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.api.*
|
||||
import jp.juggler.subwaytooter.api.entity.TootAccount
|
||||
|
@ -457,7 +458,14 @@ object Action_Follow {
|
|||
val jsonObject = result.jsonObject
|
||||
if(jsonObject != null) {
|
||||
for(column in App1.getAppState(activity).column_list) {
|
||||
column.removeFollowRequest(access_info, who.id)
|
||||
column.removeUser(access_info, Column.TYPE_FOLLOW_REQUESTS,who.id)
|
||||
|
||||
// 他のカラムでもフォロー状態の表示更新が必要
|
||||
if(column.access_info.acct == access_info.acct
|
||||
&& column.column_type != Column.TYPE_FOLLOW_REQUESTS
|
||||
){
|
||||
column.fireRebindAdapterItems()
|
||||
}
|
||||
}
|
||||
|
||||
showToast(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package jp.juggler.subwaytooter.action
|
||||
|
||||
import android.app.AlertDialog
|
||||
import org.json.JSONObject
|
||||
|
||||
import java.util.Locale
|
||||
|
@ -45,7 +46,7 @@ object Action_User {
|
|||
|
||||
TootTaskRunner(activity).run(access_info, object : TootTask {
|
||||
|
||||
internal var relation : UserRelation? = null
|
||||
var relation : UserRelation? = null
|
||||
override fun background(client : TootApiClient) : TootApiResult? {
|
||||
|
||||
val request_builder = Request.Builder().post(
|
||||
|
@ -96,7 +97,7 @@ object Action_User {
|
|||
}
|
||||
} else {
|
||||
// 「ミュートしたユーザ」カラムからユーザを除去
|
||||
column.removeFromMuteList(access_info, who.id)
|
||||
column.removeUser(access_info, Column.TYPE_MUTES, who.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +126,7 @@ object Action_User {
|
|||
|
||||
TootTaskRunner(activity).run(access_info, object : TootTask {
|
||||
|
||||
internal var relation : UserRelation? = null
|
||||
var relation : UserRelation? = null
|
||||
override fun background(client : TootApiClient) : TootApiResult? {
|
||||
|
||||
val request_builder = Request.Builder().post(
|
||||
|
@ -170,7 +171,7 @@ object Action_User {
|
|||
}
|
||||
} else {
|
||||
//「ブロックしたユーザ」カラムのリストから消える
|
||||
column.removeFromBlockList(access_info, who.id)
|
||||
column.removeUser(access_info, Column.TYPE_BLOCKS, who.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,7 +213,7 @@ object Action_User {
|
|||
) {
|
||||
TootTaskRunner(activity).run(access_info, object : TootTask {
|
||||
|
||||
internal var who_local : TootAccount? = null
|
||||
var who_local : TootAccount? = null
|
||||
override fun background(client : TootApiClient) : TootApiResult? {
|
||||
|
||||
val path = String.format(
|
||||
|
@ -325,7 +326,7 @@ object Action_User {
|
|||
bAuto = false,
|
||||
message = activity.getString(
|
||||
R.string.account_picker_open_user_who,
|
||||
AcctColor.getNickname(user + "@" + host)
|
||||
AcctColor.getNickname("$user@$host")
|
||||
),
|
||||
accountListArg = makeAccountListNonPseudo(activity, host)
|
||||
) { ai ->
|
||||
|
@ -413,7 +414,7 @@ object Action_User {
|
|||
|
||||
TootTaskRunner(activity).run(access_info, object : TootTask {
|
||||
|
||||
internal var relation : TootRelationShip? = null
|
||||
var relation : TootRelationShip? = null
|
||||
override fun background(client : TootApiClient) : TootApiResult? {
|
||||
|
||||
val content = JSONObject()
|
||||
|
@ -486,4 +487,49 @@ object Action_User {
|
|||
mention(activity, ai, initial_text)
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteSuggestion(
|
||||
activity : ActMain,
|
||||
access_info : SavedAccount,
|
||||
who : TootAccount,
|
||||
bConfirmed :Boolean = false
|
||||
) {
|
||||
if(!bConfirmed){
|
||||
|
||||
val name = who.decodeDisplayName(activity)
|
||||
AlertDialog.Builder(activity)
|
||||
.setMessage( name.intoStringResource(activity,R.string.delete_succeeded_confirm))
|
||||
.setNegativeButton(R.string.cancel,null)
|
||||
.setPositiveButton(R.string.ok){ _ , _ ->
|
||||
deleteSuggestion(activity,access_info,who,bConfirmed=true)
|
||||
}
|
||||
.show()
|
||||
return
|
||||
}
|
||||
TootTaskRunner(activity).run(access_info, object : TootTask {
|
||||
override fun background(client : TootApiClient) : TootApiResult? {
|
||||
val result = client.request("/api/v1/suggestions/${who.id}",Request.Builder().delete())
|
||||
return result
|
||||
}
|
||||
|
||||
override fun handleResult(result : TootApiResult?) {
|
||||
// cancelled
|
||||
result ?: return
|
||||
|
||||
// error
|
||||
val error = result.error
|
||||
if( error != null ){
|
||||
showToast(activity,true,result.error)
|
||||
return
|
||||
}
|
||||
|
||||
showToast(activity,false,R.string.delete_succeeded)
|
||||
|
||||
// update suggestion column
|
||||
for( column in activity.app_state.column_list){
|
||||
column.removeUser(access_info,Column.TYPE_FOLLOW_SUGGESTION,who.id)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -499,6 +499,22 @@
|
|||
android:textAllCaps="false"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDeleteSuggestion"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/btn_bg_transparent"
|
||||
android:drawablePadding="4dp"
|
||||
android:gravity="start|center_vertical"
|
||||
android:minHeight="32dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="4dp"
|
||||
android:text="@string/delete_suggestion"
|
||||
android:textAllCaps="false"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnFollowRequestNG"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -726,6 +726,8 @@
|
|||
<string name="filter_expire_1day">1 day after save</string>
|
||||
<string name="filter_expire_1week">1 week after save</string>
|
||||
<string name="scroll_top_from_column_strip">Scroll to top when tapping visible column in column strip</string>
|
||||
<string name="delete_suggestion">Delete from follow suggestion…</string>
|
||||
<string name="delete_succeeded_confirm">The user \"%1$s\" will be removed from follow suggestion. Are you sure?</string>
|
||||
|
||||
<!--<string name="abc_action_bar_home_description">Revenir à l\'accueil</string>-->
|
||||
<!--<string name="abc_action_bar_home_description_format">%1$s, %2$s</string>-->
|
||||
|
|
|
@ -1005,5 +1005,7 @@
|
|||
<string name="filter_expire_1week">1週間後</string>
|
||||
|
||||
<string name="scroll_top_from_column_strip">カラムストリップのタップで上端にスクロール</string>
|
||||
<string name="delete_suggestion">フォロー推奨から削除…</string>
|
||||
<string name="delete_succeeded_confirm">ユーザ \"%1$s\" はフォロー推奨から削除されます。よろしいですか?</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -712,4 +712,6 @@
|
|||
<string name="filter_expire_1day">1 day after save</string>
|
||||
<string name="filter_expire_1week">1 week after save</string>
|
||||
<string name="scroll_top_from_column_strip">Scroll to top when tapping visible column in column strip</string>
|
||||
<string name="delete_suggestion">Delete from follow suggestion…</string>
|
||||
<string name="delete_succeeded_confirm">The user \"%1$s\" will be removed from follow suggestion. Are you sure?</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue