Feature: Added Alarm Clock to HomeScreen.
This commit is contained in:
@@ -2,6 +2,7 @@ package com.github.droidworksstudio.launcher.helper
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.AlarmManager
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
@@ -10,12 +11,17 @@ import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.style.ImageSpan
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import android.view.WindowInsets
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.appcompat.widget.LinearLayoutCompat
|
||||
import androidx.navigation.NavOptions
|
||||
import com.github.droidworksstudio.common.showLongToast
|
||||
@@ -172,6 +178,38 @@ class AppHelper @Inject constructor() {
|
||||
return dailyWordsArray[wordIndex]
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
fun getNextAlarm(context: Context, preferenceHelper: PreferenceHelper): CharSequence {
|
||||
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
val nextAlarmClock = alarmManager.nextAlarmClock
|
||||
|
||||
if (nextAlarmClock == null) return "No alarm is set."
|
||||
|
||||
val alarmTime = nextAlarmClock.triggerTime
|
||||
val formattedTime = SimpleDateFormat("EEE, MMM d hh:mm a", Locale.getDefault()).format(alarmTime)
|
||||
|
||||
val drawable = AppCompatResources.getDrawable(context, R.drawable.ic_alarm_clock)
|
||||
val fontSize = TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
(preferenceHelper.alarmClockTextSize / 1.5).toFloat(),
|
||||
context.resources.displayMetrics
|
||||
).toInt()
|
||||
|
||||
drawable?.setBounds(0, 0, fontSize, fontSize)
|
||||
|
||||
return SpannableStringBuilder(" ").apply {
|
||||
drawable?.let {
|
||||
setSpan(
|
||||
ImageSpan(it, ImageSpan.ALIGN_CENTER),
|
||||
0, 1,
|
||||
SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
}
|
||||
append(" $formattedTime")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun shareApplicationButton(context: Context) {
|
||||
val shareIntent = Intent(Intent.ACTION_SEND)
|
||||
val description = context.getString(R.string.advanced_settings_share_application_description, context.getString(R.string.app_name))
|
||||
|
||||
@@ -43,6 +43,10 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
|
||||
get() = prefs.getBoolean(Constants.SHOW_DAILY_WORD, false)
|
||||
set(value) = prefs.edit().putBoolean(Constants.SHOW_DAILY_WORD, value).apply()
|
||||
|
||||
var showAlarmClock: Boolean
|
||||
get() = prefs.getBoolean(Constants.SHOW_ALARM_CLOCK, false)
|
||||
set(value) = prefs.edit().putBoolean(Constants.SHOW_ALARM_CLOCK, value).apply()
|
||||
|
||||
var showWeatherWidget: Boolean
|
||||
get() = prefs.getBoolean(Constants.SHOW_WEATHER_WIDGET, false)
|
||||
set(value) = prefs.edit().putBoolean(Constants.SHOW_WEATHER_WIDGET, value).apply()
|
||||
@@ -59,6 +63,10 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
|
||||
get() = prefs.getInt(Constants.DATE_COLOR, setColor.toInt())
|
||||
set(value) = prefs.edit().putInt(Constants.DATE_COLOR, value).apply()
|
||||
|
||||
var alarmClockColor: Int
|
||||
get() = prefs.getInt(Constants.ALARM_CLOCK_COLOR, setColor.toInt())
|
||||
set(value) = prefs.edit().putInt(Constants.ALARM_CLOCK_COLOR, value).apply()
|
||||
|
||||
var timeColor: Int
|
||||
get() = prefs.getInt(Constants.TIME_COLOR, setColor.toInt())
|
||||
set(value) = prefs.edit().putInt(Constants.TIME_COLOR, value).apply()
|
||||
@@ -127,6 +135,10 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
|
||||
get() = prefs.getInt(Constants.HOME_TIME_ALIGNMENT, Gravity.START)
|
||||
set(value) = prefs.edit().putInt(Constants.HOME_TIME_ALIGNMENT, value).apply()
|
||||
|
||||
var homeAlarmClockAlignment: Int
|
||||
get() = prefs.getInt(Constants.HOME_ALARM_CLOCK_ALIGNMENT, Gravity.START)
|
||||
set(value) = prefs.edit().putInt(Constants.HOME_ALARM_CLOCK_ALIGNMENT, value).apply()
|
||||
|
||||
var homeDailyWordAlignment: Int
|
||||
get() = prefs.getInt(Constants.HOME_DAILY_WORD_ALIGNMENT, Gravity.START)
|
||||
set(value) = prefs.edit().putInt(Constants.HOME_DAILY_WORD_ALIGNMENT, value).apply()
|
||||
@@ -147,6 +159,10 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
|
||||
get() = prefs.getFloat(Constants.APP_TEXT_SIZE, 24f)
|
||||
set(value) = prefs.edit().putFloat(Constants.APP_TEXT_SIZE, value).apply()
|
||||
|
||||
var alarmClockTextSize: Float
|
||||
get() = prefs.getFloat(Constants.ALARM_CLOCK_TEXT_SIZE, 22f)
|
||||
set(value) = prefs.edit().putFloat(Constants.ALARM_CLOCK_TEXT_SIZE, value).apply()
|
||||
|
||||
var dailyWordTextSize: Float
|
||||
get() = prefs.getFloat(Constants.DAILY_WORD_TEXT_SIZE, 18f)
|
||||
set(value) = prefs.edit().putFloat(Constants.DAILY_WORD_TEXT_SIZE, value).apply()
|
||||
|
||||
@@ -77,6 +77,10 @@ class AlignmentBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
binding.selectWordTextSize.apply {
|
||||
text = appHelper.gravityToString(preferenceHelper.homeDailyWordAlignment)
|
||||
}
|
||||
|
||||
binding.selectAlarmClockTextSize.apply {
|
||||
text = appHelper.gravityToString(preferenceHelper.homeAlarmClockAlignment)
|
||||
}
|
||||
}
|
||||
|
||||
private fun observeClickListener() {
|
||||
@@ -99,6 +103,11 @@ class AlignmentBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
selectedAlignment = REQUEST_KEY_WORD_ALIGNMENT
|
||||
showListDialog(selectedAlignment)
|
||||
}
|
||||
|
||||
binding.bottomAlignmentAlarmClockView.setOnClickListener {
|
||||
selectedAlignment = REQUEST_KEY_ALARM_CLOCK_ALIGNMENT
|
||||
showListDialog(selectedAlignment)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +153,14 @@ class AlignmentBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
binding.selectWordTextSize
|
||||
)
|
||||
}
|
||||
|
||||
REQUEST_KEY_ALARM_CLOCK_ALIGNMENT -> {
|
||||
setAlignment(
|
||||
selectedAlignment,
|
||||
gravity,
|
||||
binding.selectAlarmClockTextSize
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
dialog.show()
|
||||
@@ -178,6 +195,11 @@ class AlignmentBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
alignmentGetter = { preferenceHelper.homeDailyWordAlignment }
|
||||
}
|
||||
|
||||
REQUEST_KEY_ALARM_CLOCK_ALIGNMENT -> {
|
||||
alignmentPreference = { preferenceViewModel.setHomeAlarmClockAppAlignment(it) }
|
||||
alignmentGetter = { preferenceHelper.homeAlarmClockAlignment }
|
||||
}
|
||||
|
||||
else -> return
|
||||
}
|
||||
|
||||
@@ -190,6 +212,7 @@ class AlignmentBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
private const val REQUEST_KEY_DATE_ALIGNMENT = "REQUEST_KEY_DATE_ALIGNMENT"
|
||||
private const val REQUEST_KEY_TIME_ALIGNMENT = "REQUEST_KEY_TIME_ALIGNMENT"
|
||||
private const val REQUEST_KEY_APP_ALIGNMENT = "REQUEST_KEY_APP_ALIGNMENT"
|
||||
private const val REQUEST_KEY_ALARM_CLOCK_ALIGNMENT = "REQUEST_KEY_ALARM_CLOCK_ALIGNMENT"
|
||||
private const val REQUEST_KEY_WORD_ALIGNMENT = "REQUEST_KEY_WORD_ALIGNMENT"
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,11 @@ class ColorBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
setTextColor(preferenceHelper.batteryColor)
|
||||
}
|
||||
|
||||
binding.selectAlarmClockTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.alarmClockColor)
|
||||
setTextColor(preferenceHelper.alarmClockColor)
|
||||
}
|
||||
|
||||
binding.selectWordTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.dailyWordColor)
|
||||
setTextColor(preferenceHelper.dailyWordColor)
|
||||
@@ -138,6 +143,14 @@ class ColorBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
)
|
||||
}
|
||||
|
||||
binding.bottomColorAlarmClockView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectAlarmClockTextColor,
|
||||
REQUEST_KEY_DAILY_ALARM_CLOCK_COLOR,
|
||||
preferenceHelper.alarmClockColor
|
||||
)
|
||||
}
|
||||
|
||||
binding.bottomColorWidgetBackgroundView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectWidgetBackgroundColor,
|
||||
@@ -170,11 +183,6 @@ class ColorBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
setTextColor(pickedColor)
|
||||
}
|
||||
when (requestCode) {
|
||||
REQUEST_KEY_DAILY_WORD_COLOR -> {
|
||||
preferenceViewModel.setDailyWordColor(pickedColor)
|
||||
Log.d("Tag", "Settings Daily Color: ${Integer.toHexString(pickedColor)}")
|
||||
}
|
||||
|
||||
REQUEST_KEY_BATTERY_COLOR -> {
|
||||
preferenceViewModel.setBatteryColor(pickedColor)
|
||||
Log.d("Tag", "Settings Battery Color: ${Integer.toHexString(pickedColor)}")
|
||||
@@ -195,6 +203,16 @@ class ColorBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
Log.d("Tag", "Settings Time Color: ${Integer.toHexString(color)}")
|
||||
}
|
||||
|
||||
REQUEST_KEY_DAILY_ALARM_CLOCK_COLOR -> {
|
||||
preferenceViewModel.setAlarmClockColor(pickedColor)
|
||||
Log.d("Tag", "Settings Alarm Clock Color: ${Integer.toHexString(pickedColor)}")
|
||||
}
|
||||
|
||||
REQUEST_KEY_DAILY_WORD_COLOR -> {
|
||||
preferenceViewModel.setDailyWordColor(pickedColor)
|
||||
Log.d("Tag", "Settings Daily Word Color: ${Integer.toHexString(pickedColor)}")
|
||||
}
|
||||
|
||||
REQUEST_KEY_WIDGET_BACKGROUND_COLOR -> {
|
||||
preferenceViewModel.setWidgetBackgroundColor(pickedColor)
|
||||
Log.d("Tag", "Settings Widget Background Color: ${Integer.toHexString(color)}")
|
||||
@@ -213,6 +231,7 @@ class ColorBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
companion object {
|
||||
private const val REQUEST_KEY_DATE_COLOR = "REQUEST_DATE_COLOR"
|
||||
private const val REQUEST_KEY_TIME_COLOR = "REQUEST_TIME_COLOR"
|
||||
private const val REQUEST_KEY_DAILY_ALARM_CLOCK_COLOR = "REQUEST_KEY_DAILY_ALARM_CLOCK_COLOR"
|
||||
private const val REQUEST_KEY_DAILY_WORD_COLOR = "REQUEST_DAILY_WORD_COLOR"
|
||||
private const val REQUEST_KEY_APP_COLOR = "REQUEST_APP_COLOR"
|
||||
private const val REQUEST_KEY_BATTERY_COLOR = "REQUEST_BATTERY_COLOR"
|
||||
|
||||
@@ -57,6 +57,8 @@ class TextBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
binding.selectTimeTextSize.setText("${preferenceHelper.timeTextSize}")
|
||||
binding.selectAppTextSize.setText("${preferenceHelper.appTextSize}")
|
||||
binding.selectBatteryTextSize.setText("${preferenceHelper.batteryTextSize}")
|
||||
binding.selectAlarmClockTextSize.setText("${preferenceHelper.alarmClockTextSize}")
|
||||
binding.selectDailyWordTextSize.setText("${preferenceHelper.dailyWordTextSize}")
|
||||
}
|
||||
|
||||
private fun observeValueChange() {
|
||||
@@ -64,17 +66,23 @@ class TextBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
val timeValue = binding.selectTimeTextSize.text.toString()
|
||||
val appValue = binding.selectAppTextSize.text.toString()
|
||||
val batteryValue = binding.selectBatteryTextSize.text.toString()
|
||||
val alarmValue = binding.selectAlarmClockTextSize.text.toString()
|
||||
val wordValue = binding.selectDailyWordTextSize.text.toString()
|
||||
|
||||
val dateFloatValue = parseFloatValue(dateValue, preferenceHelper.dateTextSize)
|
||||
val timeFloatValue = parseFloatValue(timeValue, preferenceHelper.timeTextSize)
|
||||
val appFloatValue = parseFloatValue(appValue, preferenceHelper.appTextSize)
|
||||
val batteryFloatValue = parseFloatValue(batteryValue, preferenceHelper.batteryTextSize)
|
||||
val alarmFloatValue = parseFloatValue(alarmValue, preferenceHelper.alarmClockTextSize)
|
||||
val wordFloatValue = parseFloatValue(wordValue, preferenceHelper.dailyWordTextSize)
|
||||
dismiss()
|
||||
|
||||
preferenceViewModel.setDateTextSize(dateFloatValue)
|
||||
preferenceViewModel.setTimeTextSize(timeFloatValue)
|
||||
preferenceViewModel.setAppTextSize(appFloatValue)
|
||||
preferenceViewModel.setBatteryTextSize(batteryFloatValue)
|
||||
preferenceViewModel.setAlarmClockTextSize(alarmFloatValue)
|
||||
preferenceViewModel.setDailyWordTextSize(wordFloatValue)
|
||||
}
|
||||
|
||||
private fun parseFloatValue(text: String, defaultValue: Float): Float {
|
||||
|
||||
@@ -139,6 +139,7 @@ class HomeFragment : Fragment(),
|
||||
|
||||
preferenceViewModel.setShowTime(preferenceHelper.showTime)
|
||||
preferenceViewModel.setShowDate(preferenceHelper.showDate)
|
||||
preferenceViewModel.setShowAlarmClock(preferenceHelper.showAlarmClock)
|
||||
preferenceViewModel.setShowDailyWord(preferenceHelper.showDailyWord)
|
||||
}
|
||||
|
||||
@@ -252,9 +253,11 @@ class HomeFragment : Fragment(),
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
private fun observeUserInterfaceSettings() {
|
||||
preferenceViewModel.setShowTime(preferenceHelper.showTime)
|
||||
preferenceViewModel.setShowDate(preferenceHelper.showDate)
|
||||
preferenceViewModel.setShowAlarmClock(preferenceHelper.showAlarmClock)
|
||||
preferenceViewModel.setShowDailyWord(preferenceHelper.showDailyWord)
|
||||
preferenceViewModel.setShowBattery(preferenceHelper.showBattery)
|
||||
|
||||
@@ -297,6 +300,17 @@ class HomeFragment : Fragment(),
|
||||
preferenceHelper.showDailyWord
|
||||
)
|
||||
}
|
||||
|
||||
preferenceViewModel.showDailyWordLiveData.observe(viewLifecycleOwner) {
|
||||
appHelper.updateUI(
|
||||
binding.alarm,
|
||||
preferenceHelper.homeAlarmClockAlignment,
|
||||
preferenceHelper.alarmClockColor,
|
||||
preferenceHelper.alarmClockTextSize,
|
||||
preferenceHelper.showAlarmClock
|
||||
)
|
||||
}
|
||||
|
||||
binding.apply {
|
||||
nestScrollView.hideKeyboard()
|
||||
|
||||
@@ -312,6 +326,7 @@ class HomeFragment : Fragment(),
|
||||
date.format12Hour = datePattern
|
||||
date.format24Hour = datePattern
|
||||
|
||||
alarm.text = appHelper.getNextAlarm(context, preferenceHelper)
|
||||
word.text = appHelper.wordOfTheDay(resources)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ class SettingsLookFeelFragment : Fragment(),
|
||||
timeSwitchCompat.isChecked = preferenceHelper.showTime
|
||||
dateSwitchCompat.isChecked = preferenceHelper.showDate
|
||||
batterySwitchCompat.isChecked = preferenceHelper.showBattery
|
||||
alarmClockSwitchCompat.isChecked = preferenceHelper.showAlarmClock
|
||||
dailyWordSwitchCompat.isChecked = preferenceHelper.showDailyWord
|
||||
appIconsSwitchCompat.isChecked = preferenceHelper.showAppIcon
|
||||
appIconDotsSwitchCompat.isChecked = preferenceHelper.showAppIconAsDots
|
||||
@@ -158,6 +159,10 @@ class SettingsLookFeelFragment : Fragment(),
|
||||
preferenceViewModel.setShowBattery(isChecked)
|
||||
}
|
||||
|
||||
alarmClockSwitchCompat.setOnCheckedChangeListener { _, isChecked ->
|
||||
preferenceViewModel.setShowAlarmClock(isChecked)
|
||||
}
|
||||
|
||||
dailyWordSwitchCompat.setOnCheckedChangeListener { _, isChecked ->
|
||||
preferenceViewModel.setShowDailyWord(isChecked)
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ object Constants {
|
||||
const val SHOW_DATE = "SHOW_DATE"
|
||||
const val SHOW_TIME = "SHOW_TIME"
|
||||
const val SHOW_DAILY_WORD = "SHOW_DAILY_WORD"
|
||||
const val SHOW_ALARM_CLOCK = "SHOW_ALARM_CLOCK"
|
||||
const val SHOW_BATTERY = "SHOW_BATTERY"
|
||||
const val SHOW_STATUS_BAR = "SHOW_STATUS_BAR"
|
||||
|
||||
@@ -39,6 +40,7 @@ object Constants {
|
||||
const val DATE_COLOR = "DATE_COLOR"
|
||||
const val TIME_COLOR = "TIME_COLOR"
|
||||
const val BATTERY_COLOR = "BATTERY_COLOR"
|
||||
const val ALARM_CLOCK_COLOR = "ALARM_CLOCK_COLOR"
|
||||
const val DAILY_WORD_COLOR = "DAILY_WORD_COLOR"
|
||||
const val WIDGET_BACKGROUND_COLOR = "WIDGET_BACKGROUND_COLOR"
|
||||
const val WIDGET_TEXT_COLOR = "WIDGET_TEXT_COLOR"
|
||||
@@ -48,6 +50,7 @@ object Constants {
|
||||
const val DATE_TEXT_SIZE = "DATE_TEXT_SIZE"
|
||||
const val TIME_TEXT_SIZE = "TIME_TEXT_SIZE"
|
||||
const val APP_TEXT_SIZE = "APP_TEXT_SIZE"
|
||||
const val ALARM_CLOCK_TEXT_SIZE = "ALARM_CLOCK_TEXT_SIZE"
|
||||
const val DAILY_WORD_TEXT_SIZE = "DAILY_WORD_TEXT_SIZE"
|
||||
|
||||
const val APP_TEXT_PADDING = "APP_TEXT_PADDING"
|
||||
@@ -64,6 +67,7 @@ object Constants {
|
||||
const val HOME_DATE_ALIGNMENT = "HOME_DATE_ALIGNMENT"
|
||||
const val HOME_TIME_ALIGNMENT = "HOME_TIME_ALIGNMENT"
|
||||
const val HOME_APP_ALIGNMENT = "HOME_APP_ALIGNMENT"
|
||||
const val HOME_ALARM_CLOCK_ALIGNMENT = "HOME_ALARM_CLOCK_ALIGNMENT"
|
||||
const val HOME_DAILY_WORD_ALIGNMENT = "HOME_DAILY_WORD_ALIGNMENT"
|
||||
|
||||
const val NOTIFICATION_SERVICE = "statusbar"
|
||||
|
||||
@@ -17,6 +17,7 @@ class PreferenceViewModel @Inject constructor(
|
||||
val showTimeLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
val showDateLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
val showDailyWordLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
val showAlarmClockLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
val showBatteryLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val showWeatherWidgetLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val showWeatherWidgetSunSetRiseLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
@@ -26,11 +27,13 @@ class PreferenceViewModel @Inject constructor(
|
||||
private val homeAppAlignmentLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val homeDateAlignmentLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val homeTimeAlignmentLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val homeAlarmClockAlignmentLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val homeDailyWordAlignmentLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val dateColorLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val timeColorLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val batteryColorLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val dailyWordColorLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val alarmClockColorLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val widgetBackgroundColorLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val widgetTextColorLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val appColorLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
@@ -38,6 +41,8 @@ class PreferenceViewModel @Inject constructor(
|
||||
private val timeTextSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
private val appTextSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
private val batteryTextSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
private val alarmClockTextSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
private val dailyWordTextSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
private val autoOpenAppsLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val searchFromStartLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val autoKeyboardLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
@@ -86,6 +91,11 @@ class PreferenceViewModel @Inject constructor(
|
||||
showDailyWordLiveData.postValue(preferenceHelper.showDailyWord)
|
||||
}
|
||||
|
||||
fun setShowAlarmClock(showAlarmClock: Boolean) {
|
||||
preferenceHelper.showAlarmClock = showAlarmClock
|
||||
showAlarmClockLiveData.postValue(preferenceHelper.showAlarmClock)
|
||||
}
|
||||
|
||||
fun setShowAppIcons(showAppIcons: Boolean) {
|
||||
preferenceHelper.showAppIcon = showAppIcons
|
||||
showAppIconLiveData.postValue(preferenceHelper.showAppIcon)
|
||||
@@ -96,6 +106,11 @@ class PreferenceViewModel @Inject constructor(
|
||||
showAppIconAsDotsLiveData.postValue(preferenceHelper.showAppIconAsDots)
|
||||
}
|
||||
|
||||
fun setAlarmClockColor(alarmClockColor: Int) {
|
||||
preferenceHelper.alarmClockColor = alarmClockColor
|
||||
alarmClockColorLiveData.postValue(preferenceHelper.alarmClockColor)
|
||||
}
|
||||
|
||||
fun setDailyWordColor(dailyWordColor: Int) {
|
||||
preferenceHelper.dailyWordColor = dailyWordColor
|
||||
dailyWordColorLiveData.postValue(preferenceHelper.dailyWordColor)
|
||||
@@ -176,6 +191,11 @@ class PreferenceViewModel @Inject constructor(
|
||||
homeDailyWordAlignmentLiveData.postValue(preferenceHelper.homeDailyWordAlignment)
|
||||
}
|
||||
|
||||
fun setHomeAlarmClockAppAlignment(homeAlarmClockAlignment: Int) {
|
||||
preferenceHelper.homeAlarmClockAlignment = homeAlarmClockAlignment
|
||||
homeAlarmClockAlignmentLiveData.postValue(preferenceHelper.homeAlarmClockAlignment)
|
||||
}
|
||||
|
||||
fun setDateTextSize(dateTextSize: Float) {
|
||||
preferenceHelper.dateTextSize = dateTextSize
|
||||
dateTextSizeLiveData.postValue(preferenceHelper.dateTextSize)
|
||||
@@ -196,6 +216,16 @@ class PreferenceViewModel @Inject constructor(
|
||||
batteryTextSizeLiveData.postValue(preferenceHelper.batteryTextSize)
|
||||
}
|
||||
|
||||
fun setAlarmClockTextSize(alarmTextSize: Float) {
|
||||
preferenceHelper.alarmClockTextSize = alarmTextSize
|
||||
alarmClockTextSizeLiveData.postValue(preferenceHelper.alarmClockTextSize)
|
||||
}
|
||||
|
||||
fun setDailyWordTextSize(dailyWordTextSize: Float) {
|
||||
preferenceHelper.dailyWordTextSize = dailyWordTextSize
|
||||
dailyWordTextSizeLiveData.postValue(preferenceHelper.dailyWordTextSize)
|
||||
}
|
||||
|
||||
fun setAppPaddingSize(appPaddingSize: Float) {
|
||||
preferenceHelper.homeAppPadding = appPaddingSize
|
||||
appPaddingSizeLiveData.postValue(preferenceHelper.homeAppPadding)
|
||||
|
||||
19
app/src/main/res/drawable/ic_alarm_clock.xml
Normal file
19
app/src/main/res/drawable/ic_alarm_clock.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="m2.7,7.2c1.3,-2.1 3.4,-3.6 5.9,-4.2 0.1,0 0.3,-0.2 0.4,-0.4 0,-0.1 0,-0.3 -0.1,-0.5 -0.8,-1.3 -2.2,-2.1 -3.7,-2.1 -2.5,0 -4.5,2 -4.5,4.5 0,1 0.4,2 1,2.7 0.1,0.2 0.3,0.2 0.5,0.2 0.2,0 0.3,-0.1 0.5,-0.2z" />
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="m18.7,0c-1.6,0 -2.9,0.8 -3.7,2.1 -0.1,0.1 -0.2,0.3 -0.1,0.5q0.1,0.3 0.4,0.4c2.5,0.6 4.6,2.1 6,4.1 0.1,0.2 0.3,0.3 0.5,0.3q0.3,0 0.5,-0.2c0.5,-0.8 0.9,-1.7 0.9,-2.7 0,-2.5 -2,-4.5 -4.5,-4.5z" />
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="m18.5,21l0.8,1.1c0.4,0.5 0.2,1.2 -0.3,1.6q-0.3,0.2 -0.6,0.2c-0.4,0 -0.7,-0.2 -0.9,-0.5l-0.8,-1.1c-1.4,0.7 -3,1.1 -4.7,1.1 -1.7,0 -3.3,-0.4 -4.7,-1.1l-0.8,1.1c-0.3,0.3 -0.6,0.5 -0.9,0.5q-0.4,0 -0.7,-0.2c-0.5,-0.4 -0.6,-1.1 -0.2,-1.6l0.8,-1.1c-2,-1.8 -3.3,-4.5 -3.3,-7.4 0,-1.7 0.4,-3.3 1.2,-4.7 1.4,-2.6 4,-4.5 7,-4.9q0.8,-0.2 1.6,-0.2 0.7,0 1.5,0.2c3,0.4 5.6,2.3 7.1,4.9 0.7,1.4 1.2,3 1.2,4.7 0,2.9 -1.3,5.6 -3.3,7.4zM19,13.6c0,-1.2 -0.3,-2.3 -0.8,-3.3 -1.1,-2 -3,-3.3 -5.2,-3.6q-0.5,-0.1 -1,-0.1 -0.6,0 -1.1,0.1c-2.2,0.3 -4.1,1.7 -5.1,3.6 -0.6,1 -0.9,2.1 -0.9,3.3 0,3.9 3.2,7.1 7.1,7.1 3.9,0 7,-3.2 7,-7.1z" />
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="m15.9,15.3l-2.7,-1.7q-0.1,-0.5 -0.4,-0.8l0.1,-3.3c0,-0.5 -0.3,-0.8 -0.8,-0.8 -0.4,-0.1 -0.8,0.3 -0.8,0.7l-0.1,3.4c-0.3,0.2 -0.5,0.6 -0.5,1.1 0,0.7 0.5,1.3 1.3,1.3q0.3,0 0.5,-0.2l2.6,1.6q0.2,0.1 0.4,0.1c0.3,0 0.5,-0.1 0.7,-0.3 0.2,-0.4 0.1,-0.9 -0.3,-1.1z" />
|
||||
</vector>
|
||||
@@ -133,6 +133,42 @@
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/bottom_alignment_alarm_clock_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/select_alarm_clock_title"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_alarm"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded,TouchTargetSizeCheck" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/select_alarm_clock_text_size"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/bottom_alignment_word_view"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -169,6 +169,42 @@
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/bottom_color_alarm_clock_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/select_alarm_clock_title"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_alarm"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded,TouchTargetSizeCheck" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/select_alarm_clock_text_color"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/bottom_color_word_view"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -170,6 +170,78 @@
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/select_daily_word_title"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="numberDecimal"
|
||||
android:text="@string/appearance_bottom_dialog_desc_word"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded,TouchTargetSizeCheck" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
android:id="@+id/select_daily_word_text_size"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="numberDecimal"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded,SpeakableTextPresentCheck,TouchTargetSizeCheck,VisualLintTextFieldSize" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/select_alarm_clock_title"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="numberDecimal"
|
||||
android:text="@string/appearance_bottom_dialog_desc_alarm"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded,TouchTargetSizeCheck" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
android:id="@+id/select_alarm_clock_text_size"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="numberDecimal"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded,SpeakableTextPresentCheck,TouchTargetSizeCheck,VisualLintTextFieldSize" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -77,6 +77,14 @@
|
||||
android:textSize="32sp"
|
||||
tools:text="Thu, 30 Dec" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/alarm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:textSize="32sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/word"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -184,6 +184,37 @@
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/alarmClock_text"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_display_alarm_clock"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/alarmClock_switchCompat"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleX="0.7"
|
||||
android:scaleY="0.8"
|
||||
android:thumb="@drawable/shape_switch_thumb"
|
||||
app:track="@drawable/selector_switch"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
<string name="settings_display_date">Show Date</string>
|
||||
<string name="settings_display_time">Show Time</string>
|
||||
<string name="settings_display_battery">Show Battery</string>
|
||||
<string name="settings_display_alarm_clock">Show Alarm Clock</string>
|
||||
<string name="settings_display_daily_word">Show Daily Word</string>
|
||||
<string name="settings_display_app_icons">Show App Icons</string>
|
||||
<string name="settings_display_app_icon_dots">Show App Icons As Dots</string>
|
||||
@@ -115,6 +116,7 @@
|
||||
<string name="appearance_bottom_dialog_desc_date">Date\u0020:\u0020</string>
|
||||
<string name="appearance_bottom_dialog_desc_time">Time\u0020:\u0020 </string>
|
||||
<string name="appearance_bottom_dialog_desc_app">App\u0020:\u0020</string>
|
||||
<string name="appearance_bottom_dialog_desc_alarm">Alarm\u0020:\u0020</string>
|
||||
<string name="appearance_bottom_dialog_desc_word">Word\u0020:\u0020</string>
|
||||
<string name="appearance_bottom_dialog_desc_battery">Battery\u0020:\u0020 </string>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user