ホームカラムに「通常トゥートを表示しない」設定を追加

This commit is contained in:
tateisu 2018-02-10 09:36:27 +09:00
parent f0ed7631e8
commit 117c18f54d
8 changed files with 56 additions and 5 deletions

View File

@ -1624,6 +1624,16 @@ class ActMain : AppCompatActivity()
}
override fun handleResult(result : TootApiResult?) {
val host = this.host
val ta = this.ta
var sa = this.sa
if( ta != null && host != null && sa == null ){
val user = ta.username + "@" + host
// アカウント追加時に、アプリ内に既にあるアカウントと同じものを登録していたかもしれない
sa = SavedAccount.loadAccountByAcct( this@ActMain,user )
}
afterAccountVerify(result, ta, sa, host)
}
@ -1687,6 +1697,7 @@ class ActMain : AppCompatActivity()
} else if(host != null) {
// アカウント追加時
val user = ta.username + "@" + host
val row_id = SavedAccount.insert(host, user, jsonObject, token_info)
val account = SavedAccount.loadAccount(this@ActMain, row_id)
if(account != null) {

View File

@ -94,6 +94,7 @@ class Column(
private const val KEY_DONT_SHOW_FAVOURITE = "dont_show_favourite"
private const val KEY_DONT_SHOW_FOLLOW = "dont_show_follow"
private const val KEY_DONT_SHOW_REPLY = "dont_show_reply"
private const val KEY_DONT_SHOW_NORMAL_TOOT = "dont_show_normal_toot"
private const val KEY_DONT_STREAMING = "dont_streaming"
private const val KEY_DONT_AUTO_REFRESH = "dont_auto_refresh"
private const val KEY_HIDE_MEDIA_DEFAULT = "hide_media_default"
@ -266,6 +267,7 @@ class Column(
internal var with_highlight : Boolean = false
internal var dont_show_boost : Boolean = false
internal var dont_show_reply : Boolean = false
internal var dont_show_normal_toot : Boolean = false
internal var dont_show_favourite : Boolean = false // 通知カラムのみ
internal var dont_show_follow : Boolean = false // 通知カラムのみ
internal var dont_streaming : Boolean = false
@ -350,6 +352,7 @@ class Column(
|| dont_show_favourite
|| dont_show_follow
|| dont_show_reply
|| dont_show_normal_toot
|| regex_text.isNotEmpty()
)
@ -443,6 +446,7 @@ class Column(
dont_show_follow = src.optBoolean(KEY_DONT_SHOW_FOLLOW)
dont_show_favourite = src.optBoolean(KEY_DONT_SHOW_FAVOURITE)
dont_show_reply = src.optBoolean(KEY_DONT_SHOW_REPLY)
dont_show_normal_toot = src.optBoolean(KEY_DONT_SHOW_NORMAL_TOOT)
dont_streaming = src.optBoolean(KEY_DONT_STREAMING)
dont_auto_refresh = src.optBoolean(KEY_DONT_AUTO_REFRESH)
hide_media_default = src.optBoolean(KEY_HIDE_MEDIA_DEFAULT)
@ -496,6 +500,7 @@ class Column(
dst.put(KEY_DONT_SHOW_FOLLOW, dont_show_follow)
dst.put(KEY_DONT_SHOW_FAVOURITE, dont_show_favourite)
dst.put(KEY_DONT_SHOW_REPLY, dont_show_reply)
dst.put(KEY_DONT_SHOW_NORMAL_TOOT, dont_show_normal_toot)
dst.put(KEY_DONT_STREAMING, dont_streaming)
dst.put(KEY_DONT_AUTO_REFRESH, dont_auto_refresh)
dst.put(KEY_HIDE_MEDIA_DEFAULT, hide_media_default)
@ -1074,6 +1079,12 @@ class Column(
if(status.reblog?.in_reply_to_id?.isNotEmpty() == true) return true
}
if(dont_show_normal_toot) {
if( status.in_reply_to_id?.isEmpty() != false
&& status.reblog == null
) return true
}
if(column_regex_filter(status.decoded_content)) return true
if(column_regex_filter(status.reblog?.decoded_content)) return true
@ -3317,6 +3328,13 @@ class Column(
}
}
fun canFilterNormalToot() : Boolean {
return when(column_type) {
TYPE_HOME -> true
else -> false
}
}
internal fun canAutoRefresh() : Boolean {
return streamPath != null
}
@ -3566,4 +3584,5 @@ class Column(
}
}
}

View File

@ -100,6 +100,7 @@ class ColumnViewHolder(
private val cbDontShowFollow : CheckBox
private val cbDontShowFavourite : CheckBox
private val cbDontShowReply : CheckBox
private val cbDontShowNormalToot : CheckBox
private val cbDontStreaming : CheckBox
private val cbDontAutoRefresh : CheckBox
private val cbHideMediaDefault : CheckBox
@ -230,6 +231,7 @@ class ColumnViewHolder(
cbDontShowFollow = viewRoot.findViewById(R.id.cbDontShowFollow)
cbDontShowFavourite = viewRoot.findViewById(R.id.cbDontShowFavourite)
cbDontShowReply = viewRoot.findViewById(R.id.cbDontShowReply)
cbDontShowNormalToot = viewRoot.findViewById(R.id.cbDontShowNormalToot)
cbDontStreaming = viewRoot.findViewById(R.id.cbDontStreaming)
cbDontAutoRefresh = viewRoot.findViewById(R.id.cbDontAutoRefresh)
cbHideMediaDefault = viewRoot.findViewById(R.id.cbHideMediaDefault)
@ -260,6 +262,7 @@ class ColumnViewHolder(
cbDontShowFollow.setOnCheckedChangeListener(this)
cbDontShowFavourite.setOnCheckedChangeListener(this)
cbDontShowReply.setOnCheckedChangeListener(this)
cbDontShowNormalToot.setOnCheckedChangeListener(this)
cbDontStreaming.setOnCheckedChangeListener(this)
cbDontAutoRefresh.setOnCheckedChangeListener(this)
cbHideMediaDefault.setOnCheckedChangeListener(this)
@ -428,6 +431,7 @@ class ColumnViewHolder(
cbDontShowFollow.isChecked = column.dont_show_follow
cbDontShowFavourite.isChecked = column.dont_show_favourite
cbDontShowReply.isChecked = column.dont_show_reply
cbDontShowNormalToot.isChecked = column.dont_show_normal_toot
cbDontStreaming.isChecked = column.dont_streaming
cbDontAutoRefresh.isChecked = column.dont_auto_refresh
cbHideMediaDefault.isChecked = column.hide_media_default
@ -445,6 +449,7 @@ class ColumnViewHolder(
vg(cbDontShowBoost, column.canFilterBoost())
vg(cbDontShowReply, column.canFilterReply())
vg(cbDontShowNormalToot, column.canFilterNormalToot())
vg(cbDontShowFavourite, isNotificationColumn)
vg(cbDontShowFollow, isNotificationColumn)
@ -717,6 +722,12 @@ class ColumnViewHolder(
column.startLoading()
}
R.id.cbDontShowNormalToot -> {
column.dont_show_normal_toot = isChecked
activity.app_state.saveColumnList()
column.startLoading()
}
R.id.cbDontShowFavourite -> {
column.dont_show_favourite = isChecked
activity.app_state.saveColumnList()

View File

@ -6,7 +6,6 @@ import android.view.View
import android.widget.TextView
import jp.juggler.subwaytooter.api.entity.TootInstance
import jp.juggler.subwaytooter.util.CharacterGroup
import jp.juggler.subwaytooter.util.DecodeOptions
import jp.juggler.subwaytooter.util.LogCategory
import jp.juggler.subwaytooter.util.showToast
@ -23,6 +22,8 @@ internal class ViewHolderHeaderInstance(
companion object {
private val log = LogCategory("ViewHolderHeaderInstance")
val reWhitespaceBeforeLineFeed = Pattern.compile("[ \t\r]+\n")
}
private val btnInstance : TextView
@ -97,7 +98,6 @@ internal class ViewHolderHeaderInstance(
.decodeHTML( "<p>" + (instance.description ?: "") + "</p>")
// 行末の空白を除去
val reWhitespaceBeforeLineFeed = Pattern.compile("[ \t\r]+\n")
val m = reWhitespaceBeforeLineFeed.matcher(sb)
val matchList = LinkedList<Pair<Int,Int>>()
while(m.find()){
@ -105,8 +105,9 @@ internal class ViewHolderHeaderInstance(
matchList.addFirst( Pair(m.start(),m.end()))
}
for( pair in matchList ){
sb.replace( pair.first,pair.second,"\n")
sb.delete( pair.first,pair.second-1)
}
// 連続する改行をまとめる
var previous_br_count = 0
var i = 0
@ -122,6 +123,7 @@ internal class ViewHolderHeaderInstance(
}
++ i
}
tvDescription.text = sb
val stats = instance.stats

View File

@ -184,7 +184,12 @@
android:layout_height="wrap_content"
android:text="@string/dont_show_reply"
/>
<CheckBox
android:id="@+id/cbDontShowNormalToot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dont_show_normal_toot"
/>
<CheckBox
android:id="@+id/cbDontStreaming"
android:layout_width="match_parent"

View File

@ -613,8 +613,9 @@
<string name="notification_type_follow">follow</string>
<string name="notification_type_boost">boost</string>
<string name="notification_type_favourite">fav.</string>
<string name="dont_show_normal_toot">Don\'t show normal toot</string>
<!--<string name="abc_action_bar_home_description">Revenir à l\'accueil</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>-->
<!--<string name="abc_action_bar_home_subtitle_description_format">%1$s, %2$s, %3$s</string>-->
<!--<string name="abc_action_bar_up_description">Revenir en haut de la page</string>-->

View File

@ -896,5 +896,6 @@
<string name="notification_type_follow">フォロー</string>
<string name="notification_type_boost">ブースト</string>
<string name="notification_type_favourite">お気に入り</string>
<string name="dont_show_normal_toot">通常トゥートを表示しない</string>
</resources>

View File

@ -602,4 +602,5 @@
<string name="notification_type_follow">follow</string>
<string name="notification_type_boost">boost</string>
<string name="notification_type_favourite">fav.</string>
<string name="dont_show_normal_toot">Don\'t show normal toot</string>
</resources>