アプリ設定に「通知TLのフォントサイズ、アイコンサイズ」を追加

This commit is contained in:
tateisu 2018-06-24 10:12:45 +09:00
parent f9f2d7c793
commit 3b5882c1bb
8 changed files with 90 additions and 348 deletions

View File

@ -62,6 +62,7 @@ class ActAppSetting : AppCompatActivity()
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 COLOR_DIALOG_ID_FOOTER_BUTTON_BG = 1
internal const val COLOR_DIALOG_ID_FOOTER_BUTTON_FG = 2
@ -136,6 +137,10 @@ class ActAppSetting : AppCompatActivity()
private lateinit var etAvatarIconSize : EditText
private lateinit var etPullNotificationCheckInterval : EditText
private lateinit var etNotificationTlFontSize : EditText
private lateinit var tvNotificationTlFontSize : TextView
private lateinit var etNotificationTlIconSize : EditText
private lateinit var tvUserAgentError : TextView
private var load_busy : Boolean = false
@ -300,6 +305,7 @@ class ActAppSetting : AppCompatActivity()
tvTimelineFontSize = findViewById(R.id.tvTimelineFontSize)
tvAcctFontSize = findViewById(R.id.tvAcctFontSize)
tvNotificationTlFontSize = findViewById(R.id.tvNotificationTlFontSize)
etTimelineFontSize = findViewById(R.id.etTimelineFontSize)
etTimelineFontSize.addTextChangedListener(
@ -319,7 +325,17 @@ class ActAppSetting : AppCompatActivity()
)
)
etNotificationTlFontSize = findViewById(R.id.etNotificationTlFontSize)
etNotificationTlFontSize.addTextChangedListener(
SizeCheckTextWatcher(
tvNotificationTlFontSize,
etNotificationTlFontSize,
default_notification_tl_font_size
)
)
etAvatarIconSize = findViewById(R.id.etAvatarIconSize)
etNotificationTlIconSize = findViewById(R.id.etNotificationTlIconSize)
etPullNotificationCheckInterval = findViewById(R.id.etPullNotificationCheckInterval)
tvTimelineFontUrl = findViewById(R.id.tvTimelineFontUrl)
@ -362,6 +378,7 @@ class ActAppSetting : AppCompatActivity()
etQuoteNameFormat.setText(Pref.spQuoteNameFormat(pref))
etAutoCWLines.setText(Pref.spAutoCWLines(pref))
etAvatarIconSize.setText(Pref.spAvatarIconSize(pref))
etNotificationTlIconSize.setText(Pref.spNotificationTlIconSize(pref))
etPullNotificationCheckInterval.setText(Pref.spPullNotificationCheckInterval(pref))
etMediaSizeMax.setText(Pref.spMediaSizeMax(pref))
@ -372,7 +389,8 @@ class ActAppSetting : AppCompatActivity()
etTimelineFontSize.setText(formatFontSize(Pref.fpTimelineFontSize(pref)))
etAcctFontSize.setText(formatFontSize(Pref.fpAcctFontSize(pref)))
etNotificationTlFontSize.setText(formatFontSize(Pref.fpNotificationTlFontSize(pref)))
etUserAgent.hint = App1.userAgentDefault
load_busy = false
@ -383,6 +401,7 @@ class ActAppSetting : AppCompatActivity()
showFontSize(tvTimelineFontSize, etTimelineFontSize, default_timeline_font_size)
showFontSize(tvAcctFontSize, etAcctFontSize, default_acct_font_size)
showFontSize(tvNotificationTlFontSize, etNotificationTlFontSize, default_notification_tl_font_size)
showUserAgentError()
}
@ -411,6 +430,10 @@ class ActAppSetting : AppCompatActivity()
Pref.fpAcctFontSize,
parseFontSize(etAcctFontSize.text.toString().trim { it <= ' ' })
)
.put(
Pref.fpNotificationTlFontSize,
parseFontSize(etNotificationTlFontSize.text.toString().trim { it <= ' ' })
)
.put(Pref.spColumnWidth, etColumnWidth.text.toString().trim { it <= ' ' })
.put(Pref.spMediaThumbHeight, etMediaThumbHeight.text.toString().trim { it <= ' ' })
@ -421,6 +444,7 @@ class ActAppSetting : AppCompatActivity()
.put(Pref.spQuoteNameFormat, etQuoteNameFormat.text.toString()) // not trimmed
.put(Pref.spAutoCWLines, etAutoCWLines.text.toString().trim { it <= ' ' })
.put(Pref.spAvatarIconSize, etAvatarIconSize.text.toString().trim { it <= ' ' })
.put(Pref.spNotificationTlIconSize, etNotificationTlIconSize.text.toString().trim { it <= ' ' })
.put(
Pref.spPullNotificationCheckInterval,
etPullNotificationCheckInterval.text.toString().trim { it <= ' ' })

View File

@ -129,6 +129,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
internal var bStart : Boolean = false
@ -151,6 +152,7 @@ class ActMain : AppCompatActivity()
var timeline_font : Typeface? = null
var timeline_font_bold : Typeface? = null
var avatarIconSize : Int = 0
var notificationTlIconSize : Int = 0
private lateinit var llQuickTootBar : View
private lateinit var etQuickToot : MyEditText
@ -372,6 +374,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))
initUI()
@ -1092,11 +1095,10 @@ class ActMain : AppCompatActivity()
}
run {
var icon_size_dp = 48f
fun parseIconSize(stringPref: Pref.StringPref) : Int {
var icon_size_dp = stringPref.defVal.toFloat()
try {
sv = Pref.spAvatarIconSize(pref)
sv = stringPref(pref)
val fv = if(sv.isEmpty()) Float.NaN else sv.toFloat()
if(fv.isFinite() && fv >= 1f) {
icon_size_dp = fv
@ -1104,10 +1106,12 @@ class ActMain : AppCompatActivity()
} catch(ex : Throwable) {
log.trace(ex)
}
avatarIconSize = (0.5f + icon_size_dp * density).toInt()
return (0.5f + icon_size_dp * density).toInt()
}
avatarIconSize = parseIconSize(Pref.spAvatarIconSize)
notificationTlIconSize = parseIconSize(Pref.spNotificationTlIconSize)
run {
var round_ratio = 33f
try {

View File

@ -193,7 +193,6 @@ internal class ItemViewHolder(
this.content_color_default = tvContent.textColors.defaultColor
if(! activity.timeline_font_size_sp.isNaN()) {
tvBoosted.textSize = activity.timeline_font_size_sp
tvFollowerName.textSize = activity.timeline_font_size_sp
tvName.textSize = activity.timeline_font_size_sp
tvMentions.textSize = activity.timeline_font_size_sp
@ -206,6 +205,9 @@ internal class ItemViewHolder(
tvTrendTagName.textSize = activity.timeline_font_size_sp
tvTrendTagCount.textSize = activity.timeline_font_size_sp
}
if(! activity.notification_tl_font_size_sp.isNaN() ){
tvBoosted.textSize = activity.notification_tl_font_size_sp
}
if(! activity.acct_font_size_sp.isNaN()) {
tvBoostedAcct.textSize = activity.acct_font_size_sp
@ -220,6 +222,7 @@ internal class ItemViewHolder(
ivThumbnail.layoutParams.width = activity.avatarIconSize
ivFollow.layoutParams.width = activity.avatarIconSize
ivBoosted.layoutParams.width = activity.avatarIconSize
ivBoosted.layoutParams.height = activity.notificationTlIconSize
this.content_invalidator = NetworkEmojiInvalidator(activity.handler, tvContent)
this.spoiler_invalidator = NetworkEmojiInvalidator(activity.handler, tvContentWarning)

View File

@ -89,7 +89,7 @@ object Pref {
class StringPref(
key : String,
private val defVal : String,
val defVal : String,
val skipImport : Boolean = false
) : BasePref<String>(key) {
@ -343,6 +343,7 @@ object Pref {
val spQuoteNameFormat = StringPref("quote_name_format", "")
val spAutoCWLines = StringPref("auto_cw_lines", "0")
val spAvatarIconSize = StringPref("avatar_icon_size", "48")
val spNotificationTlIconSize = StringPref("notification_tl_icon_size", "32")
val spMediaSizeMax = StringPref("max_media_size", "8")
val spTimelineFont = StringPref("timeline_font", "", skipImport = true)
val spTimelineFontBold = StringPref("timeline_font_bold", "", skipImport = true)
@ -362,6 +363,7 @@ 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)
}

View File

@ -332,6 +332,7 @@
/>
</LinearLayout>
<LinearLayout style="@style/setting_row_form">
<TextView
@ -341,6 +342,7 @@
/>
</LinearLayout>
<View style="@style/setting_divider"/>
<!-- =============================================== -->
@ -1260,6 +1262,46 @@
</LinearLayout>
<View style="@style/setting_divider"/>
<TextView
android:id="@+id/tvNotificationTlFontSize"
style="@style/setting_row_label"
android:labelFor="@+id/etNotificationTlFontSize"
android:text="@string/notification_tl_font_size"
/>
<LinearLayout style="@style/setting_row_form">
<EditText
android:id="@+id/etNotificationTlFontSize"
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/etNotificationTlIconSize"
android:text="@string/notification_tl_icon_size"
/>
<LinearLayout style="@style/setting_row_form">
<EditText
android:id="@+id/etNotificationTlIconSize"
style="@style/setting_horizontal_stretch"
android:gravity="center"
android:inputType="numberDecimal"
/>
</LinearLayout>
<View style="@style/setting_divider"/>
<TextView
@ -1425,344 +1467,5 @@
<View style="@style/setting_divider"/>
<!-- =============================================== -->
<!-- =============================================== -->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:text="@string/actions"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<Button-->
<!--android:id="@+id/btnAccessToken"-->
<!--style="@style/setting_horizontal_stretch"-->
<!--android:ellipsize="start"-->
<!--android:text="@string/update_access_token"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<Button-->
<!--android:id="@+id/btnAccountRemove"-->
<!--style="@style/setting_horizontal_stretch"-->
<!--android:ellipsize="start"-->
<!--android:text="@string/account_remove"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:text="@string/default_status_visibility"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<Button-->
<!--android:id="@+id/btnVisibility"-->
<!--style="@style/setting_horizontal_stretch"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:text="@string/confirm_before_boost"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<Switch-->
<!--android:id="@+id/swConfirmBeforeBoost"-->
<!--style="@style/setting_horizontal_stretch"-->
<!--android:gravity="center"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:text="@string/sensitive_content_default_open"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<Switch-->
<!--android:id="@+id/swNSFWOpen"-->
<!--style="@style/setting_horizontal_stretch"-->
<!--android:gravity="center"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:labelFor="@+id/etTargetUrl"-->
<!--android:text="@string/target_url"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<EditText-->
<!--android:id="@+id/etTargetUrl"-->
<!--style="@style/setting_edit_text"-->
<!--android:inputType="textUri"-->
<!--/>-->
<!--<Button-->
<!--android:id="@+id/btnHelpTargetUrl"-->
<!--style="@style/setting_row_help"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:text="@string/local_folder"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<TextView-->
<!--android:id="@+id/tvFolder"-->
<!--style="@style/setting_horizontal_stretch"-->
<!--android:ellipsize="start"-->
<!--/>-->
<!--<Button-->
<!--android:id="@+id/btnFolderPicker"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:minWidth="32dp"-->
<!--android:text="@string/dot_dot"-->
<!--/>-->
<!--<Button-->
<!--android:id="@+id/btnHelpFolderPicker"-->
<!--style="@style/setting_row_help"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:labelFor="@+id/etFileType"-->
<!--android:text="@string/file_type"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<EditText-->
<!--android:id="@+id/etFileType"-->
<!--style="@style/setting_edit_text"-->
<!--android:inputType="text"-->
<!--/>-->
<!--<Button-->
<!--android:id="@+id/btnFileTypeHelp"-->
<!--style="@style/setting_row_help"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:labelFor="@+id/etRepeatInterval"-->
<!--android:text="@string/repeat_interval"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<EditText-->
<!--android:id="@+id/etRepeatInterval"-->
<!--style="@style/setting_edit_text"-->
<!--android:inputType="number"-->
<!--/>-->
<!--<Button-->
<!--android:id="@+id/btnIntervalHelp"-->
<!--style="@style/setting_row_help"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:text="@string/geo_tagging_mode"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<Spinner-->
<!--android:id="@+id/spLocationMode"-->
<!--style="@style/setting_horizontal_stretch"-->
<!--/>-->
<!--<Button-->
<!--android:id="@+id/btnLocationModeHelp"-->
<!--style="@style/setting_row_help"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:labelFor="@+id/etLocationIntervalDesired"-->
<!--android:text="@string/location_interval_desired"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<EditText-->
<!--android:id="@+id/etLocationIntervalDesired"-->
<!--style="@style/setting_edit_text"-->
<!--android:inputType="number"-->
<!--/>-->
<!--<Button-->
<!--android:id="@+id/btnLocationIntervalDesiredHelp"-->
<!--style="@style/setting_row_help"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:labelFor="@+id/etLocationIntervalMin"-->
<!--android:text="@string/location_interval_min"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<EditText-->
<!--android:id="@+id/etLocationIntervalMin"-->
<!--style="@style/setting_edit_text"-->
<!--android:inputType="number"-->
<!--/>-->
<!--<Button-->
<!--android:id="@+id/btnLocationIntervalMinHelp"-->
<!--style="@style/setting_row_help"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:text="@string/force_wifi_ap"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<Switch-->
<!--android:id="@+id/swForceWifi"-->
<!--style="@style/setting_horizontal_stretch"-->
<!--android:gravity="center"-->
<!--/>-->
<!--<Button-->
<!--android:id="@+id/btnForceWifiHelp"-->
<!--style="@style/setting_row_help"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:labelFor="@+id/etSSID"-->
<!--android:text="@string/wifi_ap_ssid"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<EditText-->
<!--android:id="@+id/etSSID"-->
<!--style="@style/setting_edit_text"-->
<!--android:inputType="text"-->
<!--/>-->
<!--<Button-->
<!--android:id="@+id/btnSSIDPicker"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:minWidth="32dp"-->
<!--android:text="@string/dot_dot"-->
<!--/>-->
<!--<Button-->
<!--android:id="@+id/btnSSIDHelp"-->
<!--style="@style/setting_row_help"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:text="@string/thumbnail_auto_rotate"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<Switch-->
<!--android:id="@+id/swThumbnailAutoRotate"-->
<!--style="@style/setting_horizontal_stretch"-->
<!--android:gravity="center"-->
<!--/>-->
<!--<Button-->
<!--android:id="@+id/btnThumbnailAutoRotateHelp"-->
<!--style="@style/setting_row_help"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--style="@style/setting_row_label"-->
<!--android:text="@string/copy_before_view_send"-->
<!--/>-->
<!--<LinearLayout style="@style/setting_row_form">-->
<!--<Switch-->
<!--android:id="@+id/swCopyBeforeViewSend"-->
<!--style="@style/setting_horizontal_stretch"-->
<!--android:gravity="center"-->
<!--/>-->
<!--<Button-->
<!--android:id="@+id/btnCopyBeforeViewSendHelp"-->
<!--style="@style/setting_row_help"-->
<!--/>-->
<!--</LinearLayout>-->
<!--<View style="@style/setting_divider"/>-->
<!--<TextView-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_marginBottom="20dp"-->
<!--android:layout_marginTop="20dp"-->
<!--android:gravity="center"-->
<!--android:text="@string/setting_desc"-->
<!--/>-->
</LinearLayout>
</ScrollView>

View File

@ -685,6 +685,8 @@
<string name="cant_sync_toot">Can\'t synchronize toot.</string>
<string name="cant_change_account_when_redraft">Can\'t change account while using redraft.</string>
<string name="delete_base_status_before_toot">Delete based status before post. All of favourites,boosts will be lost. Replies will be disconnected. Media attachments will not kept on Mastodon pre-2.4.1 . Are you sure?</string>
<string name="notification_tl_font_size">Notification TL font size (unit:sp. leave empty to default. app restart required)</string>
<string name="notification_tl_icon_size">Notification TL icon size (unit:dp. default:32. app restart required)</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>-->

View File

@ -963,5 +963,7 @@
<string name="cant_sync_toot">トゥートを同期できません</string>
<string name="cant_change_account_when_redraft">再編集中は投稿先アカウントを変更できません</string>
<string name="delete_base_status_before_toot">元トゥートを削除して投稿します。お気に入りとブーストは失われます。返信は切断されます。マストドン2.4.1未満の場合は添付メディアは維持されません。よろしいですか?</string>
<string name="notification_tl_font_size">通知TLのフォントサイズ (単位:sp。空欄でデフォルト。アプリ再起動が必要)</string>
<string name="notification_tl_icon_size">通知TLのアイコンサイズ (単位:dp。デフォルト:32。アプリ再起動が必要)</string>
</resources>

View File

@ -670,4 +670,6 @@
<string name="cant_sync_toot">Can\'t synchronize toot.</string>
<string name="cant_change_account_when_redraft">Can\'t change account while using redraft.</string>
<string name="delete_base_status_before_toot">Delete based status before post. All of favourites,boosts will be lost. Replies will be disconnected. Media attachments will not kept on Mastodon pre-2.4.1 . Are you sure?</string>
<string name="notification_tl_font_size">Notification TL font size (unit:sp. leave empty to default. app restart required)</string>
<string name="notification_tl_icon_size">Notification TL icon size (unit:dp. default:32. app restart required)</string>
</resources>