アプリ設定に「見た目/ヘッダ部アイコンの大きさ」と「見た目/ヘッダ部テキストの大きさ」を追加。自動CWの行幅計算がフォントサイズ指定時におかしかったバグの修正。

This commit is contained in:
tateisu 2019-01-11 18:47:30 +09:00
parent 826084b86f
commit 158d7bd423
10 changed files with 172 additions and 40 deletions

View File

@ -73,7 +73,6 @@ class ActAppSettingChild : AppCompatActivity()
internal const val REQUEST_CODE_TIMELINE_FONT = 1
internal const val REQUEST_CODE_TIMELINE_FONT_BOLD = 2
private val reLinefeed = Regex("[\\x0d\\x0a]+")
}
@ -132,7 +131,6 @@ class ActAppSettingChild : AppCompatActivity()
private var etRoundRatio : EditText? = null
private var etBoostAlpha : EditText? = null
private var etMediaReadTimeout : EditText? = null
private var tvTimelineFontUrl : TextView? = null
private var timeline_font : String? = null
@ -143,6 +141,10 @@ class ActAppSettingChild : AppCompatActivity()
private var etAcctFontSize : EditText? = null
private var tvTimelineFontSize : TextView? = null
private var tvAcctFontSize : TextView? = null
private var etHeaderTextSize : EditText? = null
private var tvHeaderTextSize : TextView? = null
private var etAvatarIconSize : EditText? = null
private var etPullNotificationCheckInterval : EditText? = null
@ -153,6 +155,7 @@ class ActAppSettingChild : AppCompatActivity()
private var etBoostButtonSize : EditText? = null
private var etReplyIconSize : EditText? = null
private var etHeaderIconSize : EditText? = null
private var tvUserAgentError : TextView? = null
@ -188,19 +191,19 @@ class ActAppSettingChild : AppCompatActivity()
override fun onCreate(savedInstanceState : Bundle?) {
super.onCreate(savedInstanceState)
App1.setActivityTheme(this, false)
pref = Pref.pref(this)
val intent = this.intent
val layoutId = intent.getIntExtra(EXTRA_LAYOUT_ID,0)
val titleId = intent.getIntExtra(EXTRA_TITLE_ID,0)
val layoutId = intent.getIntExtra(EXTRA_LAYOUT_ID, 0)
val titleId = intent.getIntExtra(EXTRA_TITLE_ID, 0)
this.title = getString(titleId)
setContentView(layoutId)
initUI()
loadUIFromData()
@ -323,7 +326,7 @@ class ActAppSettingChild : AppCompatActivity()
, R.id.btnCcdContentAcctReset
, R.id.btnCcdContentTextEdit
, R.id.btnCcdContentTextReset
,R.id.btnInstanceTickerCopyright
, R.id.btnInstanceTickerCopyright
).forEach {
findViewById<View>(it)?.setOnClickListener(this)
}
@ -400,6 +403,17 @@ class ActAppSettingChild : AppCompatActivity()
)
)
tvHeaderTextSize = findViewById(R.id.tvHeaderTextSize)
etHeaderTextSize = findViewById(R.id.etHeaderTextSize)
etHeaderTextSize?.addTextChangedListener(
SizeCheckTextWatcher(
tvHeaderTextSize !!,
etHeaderTextSize !!,
Pref.default_header_font_size
)
)
etNotificationTlFontSize = findViewById(R.id.etNotificationTlFontSize)
etNotificationTlFontSize?.addTextChangedListener(
SizeCheckTextWatcher(
@ -414,7 +428,9 @@ class ActAppSettingChild : AppCompatActivity()
etPullNotificationCheckInterval = findViewById(R.id.etPullNotificationCheckInterval)
etBoostButtonSize = findViewById(R.id.etBoostButtonSize)
etReplyIconSize= findViewById(R.id.etReplyIconSize)
etReplyIconSize = findViewById(R.id.etReplyIconSize)
etHeaderIconSize = findViewById(R.id.etHeaderIconSize)
tvTimelineFontUrl = findViewById(R.id.tvTimelineFontUrl)
tvTimelineFontBoldUrl = findViewById(R.id.tvTimelineFontBoldUrl)
@ -431,12 +447,12 @@ class ActAppSettingChild : AppCompatActivity()
}
private fun initSpinner(@IdRes viewId : Int, vararg captions : String) : Spinner? =
findViewById<Spinner>(viewId)?.apply{
findViewById<Spinner>(viewId)?.apply {
adapter = ArrayAdapter(
this@ActAppSettingChild,
android.R.layout.simple_spinner_item,
arrayOf(*captions)
).apply{
).apply {
setDropDownViewResource(R.layout.lv_spinner_dropdown)
}
onItemSelectedListener = this@ActAppSettingChild
@ -493,6 +509,7 @@ class ActAppSettingChild : AppCompatActivity()
etNotificationTlIconSize?.setText(Pref.spNotificationTlIconSize(pref))
etBoostButtonSize?.setText(Pref.spBoostButtonSize(pref))
etReplyIconSize?.setText(Pref.spReplyIconSize(pref))
etHeaderIconSize?.setText(Pref.spHeaderIconSize(pref))
etPullNotificationCheckInterval?.setText(Pref.spPullNotificationCheckInterval(pref))
etMediaSizeMax?.setText(Pref.spMediaSizeMax(pref))
@ -508,6 +525,7 @@ class ActAppSettingChild : AppCompatActivity()
etTimelineFontSize?.setText(formatFontSize(Pref.fpTimelineFontSize(pref)))
etAcctFontSize?.setText(formatFontSize(Pref.fpAcctFontSize(pref)))
etNotificationTlFontSize?.setText(formatFontSize(Pref.fpNotificationTlFontSize(pref)))
etHeaderTextSize?.setText(formatFontSize(Pref.fpHeaderTextSize(pref)))
etUserAgent?.hint = App1.userAgentDefault
@ -524,6 +542,7 @@ class ActAppSettingChild : AppCompatActivity()
etNotificationTlFontSize,
Pref.default_notification_tl_font_size
)
showFontSize(tvHeaderTextSize, etHeaderTextSize, Pref.default_header_font_size)
showUserAgentError()
showColumnSample()
@ -554,6 +573,7 @@ class ActAppSettingChild : AppCompatActivity()
putFontSize(Pref.fpAcctFontSize, etAcctFontSize)
putFontSize(Pref.fpNotificationTlFontSize, etNotificationTlFontSize)
putFontSize(Pref.fpNotificationTlFontSize, etNotificationTlFontSize)
putFontSize(Pref.fpHeaderTextSize, etHeaderTextSize)
fun putText(sp : StringPref, et : EditText?, filter : (String) -> String = { it.trim() }) {
et ?: return
@ -570,6 +590,7 @@ class ActAppSettingChild : AppCompatActivity()
putText(Pref.spNotificationTlIconSize, etNotificationTlIconSize)
putText(Pref.spBoostButtonSize, etBoostButtonSize)
putText(Pref.spReplyIconSize, etReplyIconSize)
putText(Pref.spHeaderIconSize, etHeaderIconSize)
putText(Pref.spPullNotificationCheckInterval, etPullNotificationCheckInterval)
putText(Pref.spMediaSizeMax, etMediaSizeMax)
putText(Pref.spMovieSizeMax, etMovieSizeMax)
@ -913,7 +934,10 @@ class ActAppSettingChild : AppCompatActivity()
showToast(this, ex, "could not open picker for font")
}
R.id.btnInstanceTickerCopyright -> App1.openBrowser(this@ActAppSettingChild,"https://wee.jp/mastodon/")
R.id.btnInstanceTickerCopyright -> App1.openBrowser(
this@ActAppSettingChild,
"https://wee.jp/mastodon/"
)
}
}

View File

@ -90,6 +90,7 @@ class ActMain : AppCompatActivity()
var boostButtonSize = 1
var replyIconSize = 1
var headerIconSize = 1
var timeline_font : Typeface = Typeface.DEFAULT
var timeline_font_bold : Typeface = Typeface.DEFAULT_BOLD
}
@ -116,6 +117,7 @@ class ActMain : AppCompatActivity()
var timeline_font_size_sp = Float.NaN
var acct_font_size_sp = Float.NaN
var notification_tl_font_size_sp = Float.NaN
var header_text_size_sp = Float.NaN
internal var bStart : Boolean = false
@ -397,6 +399,7 @@ class ActMain : AppCompatActivity()
timeline_font_size_sp = validateFloat(Pref.fpTimelineFontSize(pref))
acct_font_size_sp = validateFloat(Pref.fpAcctFontSize(pref))
notification_tl_font_size_sp = validateFloat(Pref.fpNotificationTlFontSize(pref))
header_text_size_sp = validateFloat(Pref.fpHeaderTextSize(pref))
initUI()
@ -1246,6 +1249,7 @@ class ActMain : AppCompatActivity()
notificationTlIconSize = parseIconSize(Pref.spNotificationTlIconSize)
boostButtonSize = parseIconSize(Pref.spBoostButtonSize)
replyIconSize = parseIconSize(Pref.spReplyIconSize)
headerIconSize = parseIconSize(Pref.spHeaderIconSize)
run {
var round_ratio = 33f
@ -2820,7 +2824,7 @@ class ActMain : AppCompatActivity()
val lp = LinearLayout.LayoutParams(nAutoCwCellWidth, LinearLayout.LayoutParams.WRAP_CONTENT)
val tv = TextView(this)
tv.layoutParams = lp
if(timeline_font_size_sp.isNaN()) {
if(!timeline_font_size_sp.isNaN()) {
tv.textSize = timeline_font_size_sp
}
tv.typeface = timeline_font

View File

@ -392,24 +392,51 @@ class ColumnViewHolder(
cbEnableSpeech.setOnCheckedChangeListener(this)
cbOldApi.setOnCheckedChangeListener(this)
if(Pref.bpMoveNotificationsQuickFilter(activity.pref)){
if(Pref.bpMoveNotificationsQuickFilter(activity.pref)) {
(svQuickFilter.parent as? ViewGroup)?.removeView(svQuickFilter)
llColumnSettingInside.addView(svQuickFilter,0)
llColumnSettingInside.addView(svQuickFilter, 0)
svQuickFilter.setOnTouchListener { v, event ->
svQuickFilter.setOnTouchListener { v, event ->
val action = event.action
if(action == MotionEvent.ACTION_DOWN){
val sv = v as? HorizontalScrollView
if(sv != null && sv.getChildAt(0).width > sv.width ){
sv.requestDisallowInterceptTouchEvent(true)
}
}
v.onTouchEvent(event)
if(action == MotionEvent.ACTION_DOWN) {
val sv = v as? HorizontalScrollView
if(sv != null && sv.getChildAt(0).width > sv.width) {
sv.requestDisallowInterceptTouchEvent(true)
}
}
v.onTouchEvent(event)
}
}
if(! activity.header_text_size_sp.isNaN()) {
tvColumnName.textSize = activity.header_text_size_sp
val acctSize = activity.header_text_size_sp * 0.857f
tvColumnContext.textSize = acctSize
tvColumnStatus.textSize = acctSize
tvColumnIndex.textSize = acctSize
}
initLoadingTextView()
var pad = 0
var wh = ActMain.headerIconSize + pad * 2
ivColumnIcon.layoutParams.width = wh
ivColumnIcon.layoutParams.height = wh
ivColumnIcon.setPaddingRelative(pad, pad, pad, pad)
pad = (ActMain.headerIconSize * 0.125f + 0.5f).toInt()
wh = ActMain.headerIconSize + pad * 2
btnColumnSetting.layoutParams.width = wh
btnColumnSetting.layoutParams.height = wh
btnColumnSetting.setPaddingRelative(pad, pad, pad, pad)
btnColumnReload.layoutParams.width = wh
btnColumnReload.layoutParams.height = wh
btnColumnReload.setPaddingRelative(pad, pad, pad, pad)
btnColumnClose.layoutParams.width = wh
btnColumnClose.layoutParams.height = wh
btnColumnClose.setPaddingRelative(pad, pad, pad, pad)
// 入力の追跡
etRegexFilter.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(
@ -1471,20 +1498,20 @@ class ColumnViewHolder(
vg(btnQuickFilterReaction, column.isMisskey)
vg(btnQuickFilterVote, column.isMisskey)
vg(btnQuickFilterFavourite, !column.isMisskey)
vg(btnQuickFilterFavourite, ! column.isMisskey)
val insideColumnSetting = Pref.bpMoveNotificationsQuickFilter(activity.pref)
val showQuickFilterButton:(btn : View, iconId : Int, selected : Boolean)->Unit
if(insideColumnSetting){
val showQuickFilterButton : (btn : View, iconId : Int, selected : Boolean) -> Unit
if(insideColumnSetting) {
svQuickFilter.setBackgroundColor(0)
val colorFg = getAttributeColor(activity,R.attr.colorContentText)
val colorFg = getAttributeColor(activity, R.attr.colorContentText)
val colorBgSelected = colorFg.applyAlphaMultiplier(0.25f)
showQuickFilterButton = { btn , iconId , selected ->
showQuickFilterButton = { btn, iconId, selected ->
ViewCompat.setBackground(
btn,
if(selected) {
@ -1492,8 +1519,8 @@ class ColumnViewHolder(
colorBgSelected,
colorFg
)
}else {
ContextCompat.getDrawable(activity,R.drawable.btn_bg_transparent)
} else {
ContextCompat.getDrawable(activity, R.drawable.btn_bg_transparent)
}
)
when(btn) {
@ -1501,7 +1528,7 @@ class ColumnViewHolder(
is TextView -> btn.textColor = colorFg
}
}
}else {
} else {
val colorBg = column.getHeaderBackgroundColor()
val colorFg = column.getHeaderNameColor()
val colorBgSelected = Color.rgb(
@ -1511,7 +1538,7 @@ class ColumnViewHolder(
)
svQuickFilter.setBackgroundColor(colorBg)
showQuickFilterButton = { btn , iconId , selected ->
showQuickFilterButton = { btn, iconId, selected ->
ViewCompat.setBackground(
btn,

View File

@ -118,6 +118,8 @@ internal class DlgContextMenu(
val btnAroundFTL : View = viewRoot.findViewById(R.id.btnAroundFTL)
val btnCopyAccountId : Button = viewRoot.findViewById(R.id.btnCopyAccountId)
val btnOpenAccountInAdminWebUi :Button = viewRoot.findViewById(R.id.btnOpenAccountInAdminWebUi)
val btnOpenInstanceInAdminWebUi :Button = viewRoot.findViewById(R.id.btnOpenInstanceInAdminWebUi)
val llLinks : LinearLayout = viewRoot.findViewById(R.id.llLinks)
btnAroundAccountTL.setOnClickListener(this)
@ -163,6 +165,7 @@ internal class DlgContextMenu(
btnEndorse.setOnClickListener(this)
btnCopyAccountId.setOnClickListener(this)
btnOpenAccountInAdminWebUi.setOnClickListener(this)
btnOpenInstanceInAdminWebUi.setOnClickListener(this)
viewRoot.findViewById<View>(R.id.btnQuoteUrlStatus).setOnClickListener(this)
viewRoot.findViewById<View>(R.id.btnQuoteUrlAccount).setOnClickListener(this)
@ -357,6 +360,7 @@ internal class DlgContextMenu(
btnDomainBlock.visibility = View.GONE
btnCopyAccountId.visibility = View.GONE
btnOpenAccountInAdminWebUi.visibility = View.GONE
btnOpenInstanceInAdminWebUi.visibility = View.GONE
} else {
val who_host = who.host
btnInstanceInformation.visibility = View.VISIBLE
@ -375,7 +379,7 @@ internal class DlgContextMenu(
btnCopyAccountId.text = activity.getString(R.string.copy_account_id, who.id.toString() )
vg( btnOpenAccountInAdminWebUi , ! access_info.isPseudo)
vg( btnOpenInstanceInAdminWebUi , ! access_info.isPseudo)
}
viewRoot.findViewById<View>(R.id.btnAccountText).setOnClickListener(this)
@ -761,7 +765,11 @@ internal class DlgContextMenu(
R.id.btnCopyAccountId -> who.id.toString().copyToClipboard(activity)
R.id.btnOpenAccountInAdminWebUi -> App1.openBrowser(activity,"https://${access_info.host}/admin/accounts/${who.id}")
R.id.btnOpenAccountInAdminWebUi ->
App1.openBrowser(activity,"https://${access_info.host}/admin/accounts/${who.id}")
R.id.btnOpenInstanceInAdminWebUi ->
App1.openBrowser(activity,"https://${access_info.host}/admin/instances/${who.host}")
}
}

View File

@ -424,6 +424,7 @@ object Pref {
val spNotificationTlIconSize = StringPref("notification_tl_icon_size", "32")
val spBoostButtonSize = StringPref("BoostButtonSize", "35")
val spReplyIconSize = StringPref("ReplyIconSize", "24")
val spHeaderIconSize = StringPref("HeaderIconSize", "32")
val spMediaSizeMax = StringPref("max_media_size", "8")
val spMovieSizeMax = StringPref("max_movie_size", "40")
val spTimelineFont = StringPref("timeline_font", "", skipImport = true)
@ -447,8 +448,10 @@ object Pref {
val fpTimelineFontSize = FloatPref("timeline_font_size", Float.NaN)
val fpAcctFontSize = FloatPref("acct_font_size", Float.NaN)
val fpNotificationTlFontSize = FloatPref("notification_tl_font_size", Float.NaN)
val fpHeaderTextSize = FloatPref("HeaderTextSize", Float.NaN)
internal const val default_timeline_font_size = 14f
internal const val default_acct_font_size = 12f
internal const val default_notification_tl_font_size = 14f
internal const val default_header_font_size = 14f
}

View File

@ -476,6 +476,45 @@
<View style="@style/setting_divider"/>
<TextView
style="@style/setting_row_label"
android:labelFor="@+id/etHeaderIconSize"
android:text="@string/header_icon_size"
/>
<LinearLayout style="@style/setting_row_form">
<EditText
android:id="@+id/etHeaderIconSize"
style="@style/setting_horizontal_stretch"
android:gravity="center"
android:inputType="numberDecimal"
/>
</LinearLayout>
<View style="@style/setting_divider"/>
<TextView
style="@style/setting_row_label"
android:labelFor="@+id/etHeaderTextSize"
android:text="@string/header_text_size"
android:id="@+id/tvHeaderTextSize"
/>
<LinearLayout style="@style/setting_row_form">
<EditText
android:id="@+id/etHeaderTextSize"
style="@style/setting_horizontal_stretch"
android:gravity="center"
android:inputType="numberDecimal"
/>
</LinearLayout>
<View style="@style/setting_divider"/>
<TextView
style="@style/setting_row_label"
android:text="@string/show_instance_ticker"

View File

@ -945,6 +945,21 @@
android:paddingTop="4dp"
android:textAllCaps="false"
/>
<Button
android:id="@+id/btnOpenInstanceInAdminWebUi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_bg_transparent"
android:gravity="start|center_vertical"
android:minHeight="32dp"
android:paddingBottom="4dp"
android:paddingEnd="8dp"
android:paddingStart="8dp"
android:paddingTop="4dp"
android:text="@string/open_in_admin_ui"
android:textAllCaps="false"
/>
</LinearLayout>
</LinearLayout>

View File

@ -78,6 +78,8 @@
android:layout_height="32dp"
android:layout_marginEnd="4dp"
android:importantForAccessibility="no"
android:padding="4dp"
android:scaleType="fitCenter"
/>
<TextView
@ -97,6 +99,8 @@
android:background="@drawable/btn_bg_transparent"
android:contentDescription="@string/setting"
android:src="?attr/ic_tune"
android:padding="8dp"
android:scaleType="fitCenter"
/>
<ImageButton
@ -108,6 +112,8 @@
android:background="@drawable/btn_bg_transparent"
android:contentDescription="@string/reload"
android:src="?attr/btn_refresh"
android:padding="8dp"
android:scaleType="fitCenter"
/>
<ImageButton
@ -119,6 +125,8 @@
android:background="@drawable/btn_bg_transparent"
android:contentDescription="@string/close_column"
android:src="?attr/btn_close"
android:padding="8dp"
android:scaleType="fitCenter"
/>
</LinearLayout>

View File

@ -842,6 +842,8 @@
<string name="cant_change_account_when_editing_scheduled_status">予約した投稿の再編集ではアカウントを変更できません</string>
<string name="delete_scheduled_status_before_update">投稿する前に編集前の古い予約投稿を削除します。よろしいですか?</string>
<string name="reply_icon_size">返信アイコンの大きさ(単位:dp。デフォルト:24。アプリ再起動が必要)</string>
<string name="header_icon_size">ヘッダ部アイコンの大きさ(単位:dp。デフォルト:32。アプリ再起動が必要)</string>
<string name="header_text_size">ヘッダ部テキストの大きさ(単位:sp。デフォルト:14。アプリ再起動が必要)</string>
<string name="all">All</string>
<string name="show_links_in_context_menu">本文中のリンクをコンテキストメニューに表示する</string>
<string name="scheduled_status_requires_mastodon_2_7_0">予約投稿はマストドン2.7.0以降で使えます</string>

View File

@ -863,6 +863,8 @@
<string name="cant_change_account_when_editing_scheduled_status">Can\'t change account when editing scheduled status.</string>
<string name="delete_scheduled_status_before_update">Delete scheduled status before posting. Are you sure?</string>
<string name="reply_icon_size">Reply icon size(Unit:dp. default:24. app restart required)</string>
<string name="header_icon_size">Header icon size(Unit:dp. default:32. app restart required)</string>
<string name="header_text_size">Header text size(Unit:sp. default:14. app restart required)</string>
<string name="all">All</string>
<string name="show_links_in_context_menu">Show links in context menu</string>
<string name="scheduled_status_requires_mastodon_2_7_0">Scheduled status requires Mastodon 2.7.0 or later.</string>