allow customizing the text size

This commit is contained in:
tibbi
2020-05-10 22:27:48 +02:00
parent 38c77c8154
commit e6725130d3
4 changed files with 84 additions and 15 deletions

View File

@@ -7,9 +7,12 @@ 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.beVisibleIf
import com.simplemobiletools.commons.extensions.getFontSizeText
import com.simplemobiletools.commons.extensions.updateTextColors
import com.simplemobiletools.commons.helpers.isNougatPlus
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.dialer.R
import com.simplemobiletools.dialer.extensions.config
import kotlinx.android.synthetic.main.activity_settings.*
@@ -29,6 +32,7 @@ class SettingsActivity : SimpleActivity() {
setupManageBlockedNumbers()
setupManageSpeedDial()
setupChangeDateTimeFormat()
setupFontSize()
updateTextColors(settings_holder)
invalidateOptionsMenu()
}
@@ -78,4 +82,20 @@ class SettingsActivity : SimpleActivity() {
ChangeDateTimeFormatDialog(this) {}
}
}
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.dialer.adapters
import android.util.TypedValue
import android.view.Menu
import android.view.View
import android.view.ViewGroup
@@ -8,6 +9,7 @@ import android.widget.TextView
import com.bumptech.glide.Glide
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.getTextSize
import com.simplemobiletools.commons.extensions.highlightTextFromNumbers
import com.simplemobiletools.commons.extensions.highlightTextPart
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
@@ -22,6 +24,7 @@ class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleCo
private var textToHighlight = highlightText
private var adjustedPrimaryColor = activity.getAdjustedPrimaryColor()
private var fontSize = activity.getTextSize()
override fun getActionMenuId() = 0
@@ -75,13 +78,18 @@ class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleCo
private fun setupView(view: View, contact: SimpleContact) {
view.apply {
findViewById<TextView>(R.id.item_contact_name).setTextColor(textColor)
findViewById<TextView>(R.id.item_contact_name).text = if (textToHighlight.isEmpty()) contact.name else {
if (contact.name.contains(textToHighlight, true)) {
contact.name.highlightTextPart(textToHighlight, adjustedPrimaryColor)
} else {
contact.name.highlightTextFromNumbers(textToHighlight, adjustedPrimaryColor)
findViewById<TextView>(R.id.item_contact_name).apply {
setTextColor(textColor)
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
text = if (textToHighlight.isEmpty()) contact.name else {
if (contact.name.contains(textToHighlight, true)) {
contact.name.highlightTextPart(textToHighlight, adjustedPrimaryColor)
} else {
contact.name.highlightTextFromNumbers(textToHighlight, adjustedPrimaryColor)
}
}
}
SimpleContactsHelper(context).loadContactImage(contact.photoUri, findViewById(R.id.item_contact_image), contact.name)

View File

@@ -1,15 +1,13 @@
package com.simplemobiletools.dialer.adapters
import android.provider.CallLog.Calls
import android.util.TypedValue
import android.view.Menu
import android.view.View
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.formatDateOrTime
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
import com.simplemobiletools.commons.extensions.getFormattedDuration
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
import com.simplemobiletools.commons.views.MyRecyclerView
import com.simplemobiletools.dialer.R
@@ -24,6 +22,7 @@ class RecentCallsAdapter(activity: SimpleActivity, var recentCalls: ArrayList<Re
private val incomingCallIcon = activity.resources.getColoredDrawableWithColor(R.drawable.ic_incoming_call_vector, activity.config.textColor)
private val outgoingCallIcon = activity.resources.getColoredDrawableWithColor(R.drawable.ic_outgoing_call_vector, activity.config.textColor)
private var fontSize = activity.getTextSize()
override fun getActionMenuId() = 0
@@ -64,11 +63,21 @@ class RecentCallsAdapter(activity: SimpleActivity, var recentCalls: ArrayList<Re
private fun setupView(view: View, call: RecentCall) {
view.apply {
item_recents_name.text = call.name
item_recents_date_time.text = call.startTS.formatDateOrTime(context, true)
item_recents_name.apply {
text = call.name
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
}
item_recents_duration.beVisibleIf(call.type != Calls.MISSED_TYPE && call.type != Calls.REJECTED_TYPE && call.duration > 0)
item_recents_duration.text = call.duration.getFormattedDuration()
item_recents_date_time.apply {
text = call.startTS.formatDateOrTime(context, true)
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * 0.8f)
}
item_recents_duration.apply {
text = call.duration.getFormattedDuration()
beVisibleIf(call.type != Calls.MISSED_TYPE && call.type != Calls.REJECTED_TYPE && call.duration > 0)
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * 0.8f)
}
SimpleContactsHelper(context).loadContactImage(call.photoUri, item_recents_image, call.name)

View File

@@ -117,5 +117,37 @@
android:text="@string/manage_speed_dial" />
</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>