「アプリ設定/見た目/常に言語を表示」を追加。

This commit is contained in:
tateisu 2019-12-14 04:49:45 +09:00
parent 867a36c592
commit bf9381c5cd
7 changed files with 78 additions and 27 deletions

View File

@ -122,7 +122,7 @@ class ActLanguageFilter : AppCompatActivity(), View.OnClickListener {
column_index = intent.getIntExtra(EXTRA_COLUMN_INDEX, 0)
column = app_state.column_list[column_index]
load(column.language_filter ?: JSONObject())
load(column.language_filter )
}
private fun initUI() {
@ -144,13 +144,15 @@ class ActLanguageFilter : AppCompatActivity(), View.OnClickListener {
listView.onItemClickListener = adapter
}
private fun load(src : JSONObject) {
private fun load(src : JSONObject?) {
loading_busy = true
try {
languageList.clear()
for(key in src.keys()) {
languageList.add(MyItem(key, src.parseBoolean(key) ?: true))
if(src !=null) {
for(key in src.keys()) {
languageList.add(MyItem(key, src.parseBoolean(key) ?: true))
}
}
if(null == languageList.find { it.code == TootStatus.LANGUAGE_CODE_DEFAULT }) {
languageList.add(MyItem(TootStatus.LANGUAGE_CODE_DEFAULT, true))

View File

@ -1483,13 +1483,7 @@ class Column(
if(column_regex_filter(status.decoded_spoiler_text)) return true
if(column_regex_filter(reblog?.decoded_spoiler_text)) return true
val languageFilter = language_filter
if(languageFilter != null ){
val bShow = languageFilter.parseBoolean(status.language ?: reblog?.language ?:TootStatus.LANGUAGE_CODE_UNKNOWN)
?: languageFilter.parseBoolean(TootStatus.LANGUAGE_CODE_DEFAULT)
?: true
if(!bShow) return true
}
if(checkLanguageFilter(status)) return true
if(access_info.isPseudo) {
var r = UserRelation.loadPseudo(access_info.getFullAcct(status.account))
@ -1503,6 +1497,19 @@ class Column(
return status.checkMuted()
}
// true if the status will be hidden
private fun checkLanguageFilter(status : TootStatus?) : Boolean {
status?:return false
val languageFilter = language_filter ?: return false
val allow = languageFilter.parseBoolean(status.language ?: status.reblog?.language ?:TootStatus.LANGUAGE_CODE_UNKNOWN)
?: languageFilter.parseBoolean(TootStatus.LANGUAGE_CODE_DEFAULT)
?: true
return !allow
}
internal fun isFiltered(item : TootNotification) : Boolean {
if(when(quick_filter) {
@ -1556,15 +1563,7 @@ class Column(
// just update _filtered flag for reversible filter
status.updateKeywordFilteredFlag(access_info, filterTrees)
}
if( status != null){
val languageFilter = language_filter
if(languageFilter != null ){
val bShow = languageFilter.parseBoolean(status.language ?: status.reblog?.language ?:TootStatus.LANGUAGE_CODE_UNKNOWN)
?: languageFilter.parseBoolean(TootStatus.LANGUAGE_CODE_DEFAULT)
?: true
if(!bShow) return true
}
}
if( checkLanguageFilter(status) )return true
if(status?.checkMuted() == true) {
log.d("isFiltered: status muted by in-app muted words.")

View File

@ -1365,17 +1365,41 @@ internal class ItemViewHolder(
makeReactionsView(status)
buttons_for_status?.bind(status, (item as? TootNotification))
var sb :StringBuilder? = null
fun prepareSb() :StringBuilder{
var x = sb
if( x == null){
x = StringBuilder()
sb = x
}else{
x.append(", ")
}
return x
}
val language = status.language
if( language != null &&
(column.type == ColumnType.CONVERSATION || Pref.bpShowLanguage(activity.pref))
){
prepareSb().append(activity.getString(R.string.language_is,language))
}
val application = status.application
if(application != null
&& (column.type == ColumnType.CONVERSATION || Pref.bpShowAppName(activity.pref))
if(application != null &&
(column.type == ColumnType.CONVERSATION || Pref.bpShowAppName(activity.pref))
) {
prepareSb().append(activity.getString(R.string.application_is, application.name ?: ""))
}
if(sb != null) {
tvApplication.visibility = View.VISIBLE
tvApplication.text =
activity.getString(R.string.application_is, application.name ?: "")
} else {
tvApplication.text = sb
}else{
tvApplication.visibility = View.GONE
}
}
private fun showInstanceTicker(who : TootAccount) {

View File

@ -302,7 +302,11 @@ object Pref {
false,
R.id.swShowAppName
)
val bpShowLanguage = BooleanPref(
"ShowLanguage",
false,
R.id.swShowLanguage
)
val bpForceGap = BooleanPref(
"force_gap",
false,

View File

@ -158,6 +158,24 @@
</LinearLayout>
<View style="@style/setting_divider"/>
<TextView
style="@style/setting_row_label"
android:text="@string/always_show_language"
/>
<LinearLayout style="@style/setting_row_form">
<Switch
android:id="@+id/swShowLanguage"
style="@style/setting_horizontal_stretch"
android:gravity="center"
/>
</LinearLayout>
<View style="@style/setting_divider"/>
<TextView

View File

@ -58,7 +58,7 @@
<string name="app_was_muted">アプリはミュートされます</string>
<string name="appearance">見た目</string>
<string name="append_attachment_url_to_content">添付メディアのURLを本文に記載する</string>
<string name="application_is">アプリ: %1$s</string>
<string name="application_is">アプリ: %1$s</string>
<string name="ask_always">毎回尋ねる</string>
<string name="attachment_description">添付メディアの説明文</string>
<string name="attachment_description_cant_edit_while_uploading">添付メディアのアップロード中は説明文を設定できません</string>
@ -994,5 +994,7 @@
<string name="presets">プリセット</string>
<string name="custom">カスタム</string>
<string name="language_code_hint">プリセットを選択または言語コードを入力</string>
<string name="language_is">言語: %1$s</string>
<string name="always_show_language">常に言語を表示する</string>
</resources>

View File

@ -988,4 +988,6 @@
<string name="presets">Presets</string>
<string name="custom">Custom</string>
<string name="language_code_hint">choose preset or input language code</string>
<string name="language_is">lang: %1$s</string>
<string name="always_show_language">Always show language</string>
</resources>