allow customizing the text size

This commit is contained in:
tibbi 2020-06-17 22:28:32 +02:00
parent a85eb77d31
commit ea16415503
5 changed files with 92 additions and 11 deletions

View File

@ -7,8 +7,10 @@ import android.os.Bundle
import android.view.Menu
import com.simplemobiletools.commons.activities.ManageBlockedNumbersActivity
import com.simplemobiletools.commons.dialogs.ChangeDateTimeFormatDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.isNougatPlus
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.smsmessenger.R
import com.simplemobiletools.smsmessenger.extensions.config
import com.simplemobiletools.smsmessenger.helpers.refreshMessages
@ -31,6 +33,7 @@ class SettingsActivity : SimpleActivity() {
setupUseEnglish()
setupManageBlockedNumbers()
setupChangeDateTimeFormat()
setupFontSize()
updateTextColors(settings_scrollview)
if (blockedNumbersAtPause != -1 && blockedNumbersAtPause != getBlockedNumbers().hashCode()) {
@ -87,4 +90,20 @@ class SettingsActivity : SimpleActivity() {
}
}
}
private fun setupFontSize() {
settings_font_size.text = getFontSizeText()
settings_font_size_holder.setOnClickListener {
val items = arrayListOf(
RadioItem(FONT_SIZE_SMALL, getString(R.string.small)),
RadioItem(FONT_SIZE_MEDIUM, getString(R.string.medium)),
RadioItem(FONT_SIZE_LARGE, getString(R.string.large)),
RadioItem(FONT_SIZE_EXTRA_LARGE, getString(R.string.extra_large)))
RadioGroupDialog(this@SettingsActivity, items, config.fontSize) {
config.fontSize = it as Int
settings_font_size.text = getFontSizeText()
}
}
}
}

View File

@ -1,5 +1,6 @@
package com.simplemobiletools.smsmessenger.adapters
import android.util.TypedValue
import android.view.Menu
import android.view.View
import android.view.ViewGroup
@ -7,6 +8,7 @@ import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.extensions.getTextSize
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
import com.simplemobiletools.commons.models.SimpleContact
import com.simplemobiletools.commons.views.FastScroller
@ -17,6 +19,7 @@ import java.util.*
class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleContact>, recyclerView: MyRecyclerView, fastScroller: FastScroller?,
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
private var fontSize = activity.getTextSize()
override fun getActionMenuId() = 0
@ -57,11 +60,17 @@ class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleCo
private fun setupView(view: View, contact: SimpleContact) {
view.apply {
findViewById<TextView>(R.id.item_contact_name).text = contact.name
findViewById<TextView>(R.id.item_contact_name).setTextColor(textColor)
findViewById<TextView>(R.id.item_contact_name).apply {
text = contact.name
setTextColor(textColor)
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * 1.2f)
}
findViewById<TextView>(R.id.item_contact_number).text = contact.phoneNumber
findViewById<TextView>(R.id.item_contact_number).setTextColor(textColor)
findViewById<TextView>(R.id.item_contact_number).apply {
text = contact.phoneNumber
setTextColor(textColor)
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
}
SimpleContactsHelper(context).loadContactImage(contact.photoUri, findViewById(R.id.item_contact_image), contact.name)
}

View File

@ -3,6 +3,7 @@ package com.simplemobiletools.smsmessenger.adapters
import android.content.Intent
import android.graphics.Typeface
import android.text.TextUtils
import android.util.TypedValue
import android.view.Menu
import android.view.View
import android.view.ViewGroup
@ -12,6 +13,7 @@ import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.addBlockedNumber
import com.simplemobiletools.commons.extensions.formatDateOrTime
import com.simplemobiletools.commons.extensions.getTextSize
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.helpers.KEY_PHONE
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
@ -28,6 +30,7 @@ import kotlinx.android.synthetic.main.item_conversation.view.*
class ConversationsAdapter(activity: SimpleActivity, var conversations: ArrayList<Conversation>, recyclerView: MyRecyclerView, fastScroller: FastScroller,
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
private var fontSize = activity.getTextSize()
init {
setupDragListener(true)
@ -186,9 +189,20 @@ class ConversationsAdapter(activity: SimpleActivity, var conversations: ArrayLis
view.apply {
conversation_frame.isSelected = selectedKeys.contains(conversation.thread_id)
conversation_address.text = conversation.title
conversation_body_short.text = conversation.snippet
conversation_date.text = conversation.date.formatDateOrTime(context, true)
conversation_address.apply {
text = conversation.title
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * 1.2f)
}
conversation_body_short.apply {
text = conversation.snippet
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
}
conversation_date.apply {
text = conversation.date.formatDateOrTime(context, true)
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * 0.8f)
}
if (conversation.read) {
conversation_address.setTypeface(null, Typeface.NORMAL)

View File

@ -5,6 +5,7 @@ import android.content.Intent
import android.graphics.drawable.Drawable
import android.net.Uri
import android.telephony.SubscriptionManager
import android.util.TypedValue
import android.view.Menu
import android.view.View
import android.view.ViewGroup
@ -42,8 +43,8 @@ import kotlinx.android.synthetic.main.item_thread_date_time.view.*
class ThreadAdapter(activity: SimpleActivity, var messages: ArrayList<ThreadItem>, recyclerView: MyRecyclerView, fastScroller: FastScroller,
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
private val roundedCornersRadius = resources.getDimension(R.dimen.normal_margin).toInt()
private var fontSize = activity.getTextSize()
@SuppressLint("MissingPermission")
private val hasMultipleSIMCards = SubscriptionManager.from(activity).activeSubscriptionInfoList?.size ?: 0 > 1
@ -181,7 +182,10 @@ class ThreadAdapter(activity: SimpleActivity, var messages: ArrayList<ThreadItem
private fun setupView(view: View, message: Message) {
view.apply {
thread_message_holder.isSelected = selectedKeys.contains(message.id)
thread_message_body.text = message.body
thread_message_body.apply {
text = message.body
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
}
thread_message_body.beVisibleIf(message.body.isNotEmpty())
if (message.isReceivedMessage()) {
@ -286,7 +290,10 @@ class ThreadAdapter(activity: SimpleActivity, var messages: ArrayList<ThreadItem
private fun setupDateTime(view: View, dateTime: ThreadDateTime) {
view.apply {
thread_date_time.text = dateTime.date.formatDateOrTime(context, false)
thread_date_time.apply {
text = dateTime.date.formatDateOrTime(context, false)
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
}
thread_date_time.setTextColor(textColor)
thread_sim_icon.beVisibleIf(hasMultipleSIMCards)

View File

@ -117,5 +117,37 @@
app:switchPadding="@dimen/medium_margin" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_font_size_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_font_size_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/settings_font_size"
android:paddingLeft="@dimen/medium_margin"
android:paddingRight="@dimen/medium_margin"
android:text="@string/font_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_font_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="@dimen/medium_margin"
android:background="@null"
android:clickable="false" />
</RelativeLayout>
</LinearLayout>
</ScrollView>