add a setting for changing font size
This commit is contained in:
parent
a1a93bce7f
commit
e29ad62623
|
@ -33,7 +33,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.simplemobiletools:commons:2.22.3'
|
||||
compile 'com.simplemobiletools:commons:2.22.4'
|
||||
compile 'joda-time:joda-time:2.9.1'
|
||||
compile 'com.facebook.stetho:stetho:1.4.1'
|
||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simplemobiletools.calendar.activities
|
|||
|
||||
import android.accounts.AccountManager
|
||||
import android.content.Intent
|
||||
import android.content.res.Resources
|
||||
import android.media.RingtoneManager
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
|
@ -12,6 +13,9 @@ import com.simplemobiletools.calendar.dialogs.SnoozePickerDialog
|
|||
import com.simplemobiletools.calendar.extensions.config
|
||||
import com.simplemobiletools.calendar.extensions.dbHelper
|
||||
import com.simplemobiletools.calendar.extensions.getFormattedMinutes
|
||||
import com.simplemobiletools.calendar.helpers.FONT_SIZE_LARGE
|
||||
import com.simplemobiletools.calendar.helpers.FONT_SIZE_MEDIUM
|
||||
import com.simplemobiletools.calendar.helpers.FONT_SIZE_SMALL
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
|
@ -24,6 +28,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
private val REQUEST_ACCOUNT_NAME = 3
|
||||
private val REQUEST_GOOGLE_PLAY_SERVICES = 4
|
||||
|
||||
lateinit var res: Resources
|
||||
private var mStoredPrimaryColor = 0
|
||||
|
||||
companion object {
|
||||
|
@ -35,6 +40,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings)
|
||||
res = resources
|
||||
|
||||
//credential = GoogleAccountCredential.usingOAuth2(this, arrayListOf(CalendarScopes.CALENDAR_READONLY)).setBackOff(ExponentialBackOff())
|
||||
}
|
||||
|
@ -55,6 +61,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupSnoozeDelay()
|
||||
setupEventReminder()
|
||||
setupDisplayPastEvents()
|
||||
setupFontSize()
|
||||
updateTextColors(settings_holder)
|
||||
checkPrimaryColor()
|
||||
}
|
||||
|
@ -159,7 +166,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupReminderSound() {
|
||||
val noRingtone = resources.getString(R.string.no_ringtone_selected)
|
||||
val noRingtone = res.getString(R.string.no_ringtone_selected)
|
||||
if (config.reminderSound.isEmpty()) {
|
||||
settings_reminder_sound.text = noRingtone
|
||||
} else {
|
||||
|
@ -168,7 +175,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
settings_reminder_sound_holder.setOnClickListener {
|
||||
Intent(RingtoneManager.ACTION_RINGTONE_PICKER).apply {
|
||||
putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION)
|
||||
putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, resources.getString(R.string.reminder_sound))
|
||||
putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, res.getString(R.string.reminder_sound))
|
||||
putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(config.reminderSound))
|
||||
|
||||
if (resolveActivity(packageManager) != null)
|
||||
|
@ -199,7 +206,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun updateSnoozeText() {
|
||||
settings_snooze_delay.text = resources.getQuantityString(R.plurals.minutes, config.snoozeDelay, config.snoozeDelay)
|
||||
settings_snooze_delay.text = res.getQuantityString(R.plurals.minutes, config.snoozeDelay, config.snoozeDelay)
|
||||
}
|
||||
|
||||
private fun setupEventReminder() {
|
||||
|
@ -245,6 +252,27 @@ class SettingsActivity : SimpleActivity() {
|
|||
getFormattedMinutes(displayPastEvents, false)
|
||||
}
|
||||
|
||||
private fun setupFontSize() {
|
||||
settings_font_size.text = getFontSizeText()
|
||||
settings_font_size_holder.setOnClickListener {
|
||||
val items = arrayListOf(
|
||||
RadioItem(FONT_SIZE_SMALL, res.getString(R.string.small)),
|
||||
RadioItem(FONT_SIZE_MEDIUM, res.getString(R.string.medium)),
|
||||
RadioItem(FONT_SIZE_LARGE, res.getString(R.string.large)))
|
||||
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.fontSize) {
|
||||
config.fontSize = it as Int
|
||||
settings_font_size.text = getFontSizeText()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getFontSizeText() = getString(when (config.fontSize) {
|
||||
FONT_SIZE_SMALL -> R.string.small
|
||||
FONT_SIZE_MEDIUM -> R.string.medium
|
||||
else -> R.string.large
|
||||
})
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (requestCode == GET_RINGTONE_URI) {
|
||||
|
|
|
@ -65,6 +65,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get() = prefs.getStringSet(DISPLAY_EVENT_TYPES, HashSet<String>())
|
||||
set(displayEventTypes) = prefs.edit().remove(DISPLAY_EVENT_TYPES).putStringSet(DISPLAY_EVENT_TYPES, displayEventTypes).apply()
|
||||
|
||||
var fontSize: Int
|
||||
get() = prefs.getInt(FONT_SIZE, FONT_SIZE_MEDIUM)
|
||||
set(size) = prefs.edit().putInt(FONT_SIZE, size).apply()
|
||||
|
||||
var googleSync: Boolean
|
||||
get() = prefs.getBoolean(GOOGLE_SYNC, false)
|
||||
set(googleSync) = prefs.edit().putBoolean(GOOGLE_SYNC, googleSync).apply()
|
||||
|
|
|
@ -40,6 +40,7 @@ val REMINDER_SOUND = "reminder_sound"
|
|||
val VIEW = "view"
|
||||
val REMINDER_MINUTES = "reminder_minutes"
|
||||
val DISPLAY_EVENT_TYPES = "display_event_types"
|
||||
val FONT_SIZE = "font_size"
|
||||
val GOOGLE_SYNC = "google_sync"
|
||||
val SYNC_ACCOUNT_NAME = "sync_account_name"
|
||||
val SNOOZE_DELAY = "snooze_delay"
|
||||
|
@ -109,3 +110,8 @@ val TH = "TH"
|
|||
val FR = "FR"
|
||||
val SA = "SA"
|
||||
val SU = "SU"
|
||||
|
||||
// font sizes
|
||||
val FONT_SIZE_SMALL = 0
|
||||
val FONT_SIZE_MEDIUM = 1
|
||||
val FONT_SIZE_LARGE = 2
|
||||
|
|
|
@ -414,5 +414,58 @@
|
|||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/widgets_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="@color/divider_strong"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/simple_font_size_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/big_margin"
|
||||
android:layout_marginStart="@dimen/big_margin"
|
||||
android:layout_marginTop="@dimen/activity_margin"
|
||||
android:alpha="0.6"
|
||||
android:text="@string/widgets"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/divider_strong"
|
||||
android:textSize="@dimen/small_text_size"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_font_size_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="@dimen/bigger_margin"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/bigger_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_toLeftOf="@+id/settings_font_size"
|
||||
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_alignParentRight="true"
|
||||
android:layout_marginEnd="@dimen/small_margin"
|
||||
android:layout_marginRight="@dimen/small_margin"
|
||||
android:background="@null"
|
||||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
|
@ -188,6 +188,7 @@
|
|||
<string name="google_sync">Google sync</string>
|
||||
<string name="display_past_events">Display events from the past</string>
|
||||
<string name="snooze_delay">Postpone reminder with Snooze by</string>
|
||||
<string name="widgets">Widgets</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
|
Loading…
Reference in New Issue