Add clock text color
This commit is contained in:
parent
cb6c2c7764
commit
d86d2cadd4
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@ -18,7 +18,7 @@ android {
|
|||||||
applicationId "com.tommasoberlose.anotherwidget"
|
applicationId "com.tommasoberlose.anotherwidget"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 77
|
versionCode 78
|
||||||
versionName "2.0.5"
|
versionName "2.0.5"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
Binary file not shown.
@ -45,6 +45,9 @@ object Preferences : KotprefModel() {
|
|||||||
var backgroundCardColor by stringPref(default = "#000000")
|
var backgroundCardColor by stringPref(default = "#000000")
|
||||||
var backgroundCardAlpha by stringPref(default = "00")
|
var backgroundCardAlpha by stringPref(default = "00")
|
||||||
|
|
||||||
|
var clockTextColor by stringPref(default = "#FFFFFF")
|
||||||
|
var clockTextAlpha by stringPref(default = "FF")
|
||||||
|
|
||||||
var textMainSize by floatPref(key = "PREF_TEXT_MAIN_SIZE", default = 26f)
|
var textMainSize by floatPref(key = "PREF_TEXT_MAIN_SIZE", default = 26f)
|
||||||
var textSecondSize by floatPref(key = "PREF_TEXT_SECOND_SIZE", default = 18f)
|
var textSecondSize by floatPref(key = "PREF_TEXT_SECOND_SIZE", default = 18f)
|
||||||
var clockTextSize by floatPref(key = "PREF_TEXT_CLOCK_SIZE", default = 90f)
|
var clockTextSize by floatPref(key = "PREF_TEXT_CLOCK_SIZE", default = 90f)
|
||||||
|
@ -17,22 +17,41 @@ object BitmapHelper {
|
|||||||
//Define a bitmap with the same size as the view
|
//Define a bitmap with the same size as the view
|
||||||
val measuredWidth = View.MeasureSpec.makeMeasureSpec(width ?: view.width, if (width != null) View.MeasureSpec.EXACTLY else View.MeasureSpec.AT_MOST)
|
val measuredWidth = View.MeasureSpec.makeMeasureSpec(width ?: view.width, if (width != null) View.MeasureSpec.EXACTLY else View.MeasureSpec.AT_MOST)
|
||||||
val measuredHeight = View.MeasureSpec.makeMeasureSpec(height ?: view.height, if (height != null) View.MeasureSpec.EXACTLY else View.MeasureSpec.UNSPECIFIED)
|
val measuredHeight = View.MeasureSpec.makeMeasureSpec(height ?: view.height, if (height != null) View.MeasureSpec.EXACTLY else View.MeasureSpec.UNSPECIFIED)
|
||||||
view.measure(measuredWidth, measuredHeight)
|
view.measure(
|
||||||
|
if (measuredWidth > 0) measuredWidth else 0,
|
||||||
|
if (measuredHeight > 0) measuredHeight else 0
|
||||||
|
)
|
||||||
|
|
||||||
|
val calculatedWidth = view.measuredWidth
|
||||||
|
val widgetWidth = if (calculatedWidth in 1..16000) {
|
||||||
|
calculatedWidth
|
||||||
|
} else if (width != null && width > 0) {
|
||||||
|
width
|
||||||
|
} else {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
val calculatedHeight = view.measuredHeight
|
||||||
|
val widgetHeight = if (calculatedHeight in 1..16000) {
|
||||||
|
calculatedHeight
|
||||||
|
} else if (height != null && height > 0) {
|
||||||
|
height
|
||||||
|
} else {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
|
||||||
if (draw) {
|
if (draw) {
|
||||||
FirebaseCrashlytics.getInstance().setCustomKey("initialWidth", width ?: -1)
|
FirebaseCrashlytics.getInstance().setCustomKey("WIDTH SPEC", measuredWidth)
|
||||||
FirebaseCrashlytics.getInstance().setCustomKey("initialHeight", height ?: -1)
|
FirebaseCrashlytics.getInstance().setCustomKey("HEIGHT SPEC", measuredHeight)
|
||||||
FirebaseCrashlytics.getInstance().setCustomKey("measuredWidth", view.measuredWidth)
|
FirebaseCrashlytics.getInstance().setCustomKey("VIEW measuredWidth", view.measuredWidth)
|
||||||
FirebaseCrashlytics.getInstance().setCustomKey("measuredWidth_spec", measuredWidth)
|
FirebaseCrashlytics.getInstance().setCustomKey("VIEW measuredHeight", view.measuredHeight)
|
||||||
FirebaseCrashlytics.getInstance().setCustomKey("measuredHeight", view.measuredHeight)
|
FirebaseCrashlytics.getInstance().setCustomKey("WIDGET final width", measuredWidth)
|
||||||
FirebaseCrashlytics.getInstance()
|
FirebaseCrashlytics.getInstance().setCustomKey("WIDGET final height", view.measuredHeight)
|
||||||
.setCustomKey("measuredHeight_spec", measuredHeight)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
val btm = Bitmap.createBitmap(
|
val btm = Bitmap.createBitmap(
|
||||||
view.measuredWidth,
|
widgetWidth,
|
||||||
view.measuredHeight,
|
widgetHeight,
|
||||||
if (draw) Bitmap.Config.ARGB_8888 else Bitmap.Config.ALPHA_8
|
if (draw) Bitmap.Config.ARGB_8888 else Bitmap.Config.ALPHA_8
|
||||||
)
|
)
|
||||||
if (draw) {
|
if (draw) {
|
||||||
|
@ -4,14 +4,12 @@ import android.Manifest
|
|||||||
import android.content.ContentUris
|
import android.content.ContentUris
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.provider.CalendarContract
|
import android.provider.CalendarContract
|
||||||
import android.util.Log
|
|
||||||
import com.tommasoberlose.anotherwidget.services.EventListenerJob
|
import com.tommasoberlose.anotherwidget.services.EventListenerJob
|
||||||
import com.tommasoberlose.anotherwidget.db.EventRepository
|
import com.tommasoberlose.anotherwidget.db.EventRepository
|
||||||
import com.tommasoberlose.anotherwidget.models.Event
|
import com.tommasoberlose.anotherwidget.models.Event
|
||||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||||
import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver
|
import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver
|
||||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
import com.tommasoberlose.anotherwidget.ui.fragments.MainFragment
|
||||||
import com.tommasoberlose.anotherwidget.ui.fragments.AppMainFragment
|
|
||||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||||
import me.everything.providers.android.calendar.CalendarProvider
|
import me.everything.providers.android.calendar.CalendarProvider
|
||||||
@ -128,7 +126,7 @@ object CalendarHelper {
|
|||||||
UpdatesReceiver.setUpdates(context)
|
UpdatesReceiver.setUpdates(context)
|
||||||
MainWidget.updateWidget(context)
|
MainWidget.updateWidget(context)
|
||||||
|
|
||||||
EventBus.getDefault().post(AppMainFragment.UpdateUiMessageEvent())
|
EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCalendarList(context: Context): List<me.everything.providers.android.calendar.Calendar> {
|
fun getCalendarList(context: Context): List<me.everything.providers.android.calendar.Calendar> {
|
||||||
|
@ -30,6 +30,29 @@ object ColorHelper {
|
|||||||
Color.parseColor("#000000")
|
Color.parseColor("#000000")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fun getClockFontColor(): Int {
|
||||||
|
return try {
|
||||||
|
Color.parseColor("#%s%s".format(Preferences.clockTextAlpha, Preferences.clockTextColor.replace("#", "")))
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Color.parseColor("#FFFFFFFF")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getClockFontColorAlpha(): Int {
|
||||||
|
return try {
|
||||||
|
Preferences.clockTextAlpha.toIntValue().toDouble() * 255 / 100
|
||||||
|
} catch (e: Exception) {
|
||||||
|
"FF".toIntValue().toDouble() * 255 / 100
|
||||||
|
}.roundToInt()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getClockFontColorRgb(): Int {
|
||||||
|
return try {
|
||||||
|
Color.parseColor(Preferences.clockTextColor)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Color.parseColor("#000000")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getBackgroundColor(): Int {
|
fun getBackgroundColor(): Int {
|
||||||
return try {
|
return try {
|
||||||
|
@ -3,18 +3,11 @@ package com.tommasoberlose.anotherwidget.helpers
|
|||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.util.EventLog
|
|
||||||
import android.util.Log
|
|
||||||
import com.google.android.gms.location.LocationServices
|
import com.google.android.gms.location.LocationServices
|
||||||
import com.kwabenaberko.openweathermaplib.constants.Units
|
|
||||||
import com.kwabenaberko.openweathermaplib.implementation.OpenWeatherMapHelper
|
|
||||||
import com.kwabenaberko.openweathermaplib.implementation.callbacks.CurrentWeatherCallback
|
|
||||||
import com.kwabenaberko.openweathermaplib.models.currentweather.CurrentWeather
|
|
||||||
import com.tommasoberlose.anotherwidget.R
|
import com.tommasoberlose.anotherwidget.R
|
||||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||||
import com.tommasoberlose.anotherwidget.network.WeatherNetworkApi
|
import com.tommasoberlose.anotherwidget.network.WeatherNetworkApi
|
||||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
import com.tommasoberlose.anotherwidget.ui.fragments.MainFragment
|
||||||
import com.tommasoberlose.anotherwidget.ui.fragments.AppMainFragment
|
|
||||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
@ -39,7 +32,7 @@ object WeatherHelper {
|
|||||||
Preferences.customLocationLon = location.longitude.toString()
|
Preferences.customLocationLon = location.longitude.toString()
|
||||||
|
|
||||||
networkApi.updateWeather()
|
networkApi.updateWeather()
|
||||||
EventBus.getDefault().post(AppMainFragment.UpdateUiMessageEvent())
|
EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package com.tommasoberlose.anotherwidget.network
|
package com.tommasoberlose.anotherwidget.network
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
|
||||||
import com.kwabenaberko.openweathermaplib.constants.Units
|
import com.kwabenaberko.openweathermaplib.constants.Units
|
||||||
import com.kwabenaberko.openweathermaplib.implementation.OpenWeatherMapHelper
|
import com.kwabenaberko.openweathermaplib.implementation.OpenWeatherMapHelper
|
||||||
import com.kwabenaberko.openweathermaplib.implementation.callbacks.CurrentWeatherCallback
|
import com.kwabenaberko.openweathermaplib.implementation.callbacks.CurrentWeatherCallback
|
||||||
import com.kwabenaberko.openweathermaplib.models.currentweather.CurrentWeather
|
import com.kwabenaberko.openweathermaplib.models.currentweather.CurrentWeather
|
||||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||||
import com.tommasoberlose.anotherwidget.helpers.WeatherHelper
|
import com.tommasoberlose.anotherwidget.helpers.WeatherHelper
|
||||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
import com.tommasoberlose.anotherwidget.ui.fragments.MainFragment
|
||||||
import com.tommasoberlose.anotherwidget.ui.fragments.AppMainFragment
|
|
||||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
|
|
||||||
@ -27,7 +25,7 @@ class WeatherNetworkApi(val context: Context) {
|
|||||||
Preferences.weatherRealTempUnit = Preferences.weatherTempUnit
|
Preferences.weatherRealTempUnit = Preferences.weatherTempUnit
|
||||||
MainWidget.updateWidget(context)
|
MainWidget.updateWidget(context)
|
||||||
|
|
||||||
EventBus.getDefault().post(AppMainFragment.UpdateUiMessageEvent())
|
EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,10 +12,10 @@ class ViewPagerAdapter(fragmentActivity: FragmentActivity) :
|
|||||||
|
|
||||||
override fun createFragment(position: Int): Fragment {
|
override fun createFragment(position: Int): Fragment {
|
||||||
return when (position) {
|
return when (position) {
|
||||||
1 -> CalendarSettingsFragment.newInstance()
|
1 -> CalendarTabFragment.newInstance()
|
||||||
2 -> WeatherSettingsFragment.newInstance()
|
2 -> WeatherTabFragment.newInstance()
|
||||||
3 -> ClockSettingsFragment.newInstance()
|
3 -> ClockTabFragment.newInstance()
|
||||||
else -> GeneralSettingsFragment.newInstance()
|
else -> GeneralTabFragment.newInstance()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,7 +7,6 @@ import android.os.Bundle
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
@ -43,10 +42,10 @@ import kotlinx.coroutines.launch
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.Comparator
|
import kotlin.Comparator
|
||||||
|
|
||||||
class CalendarSettingsFragment : Fragment() {
|
class CalendarTabFragment : Fragment() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance() = CalendarSettingsFragment()
|
fun newInstance() = CalendarTabFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var viewModel: MainViewModel
|
private lateinit var viewModel: MainViewModel
|
@ -6,7 +6,6 @@ import android.content.BroadcastReceiver
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.content.pm.ApplicationInfo
|
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@ -20,29 +19,35 @@ import androidx.lifecycle.ViewModelProvider
|
|||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.chibatching.kotpref.bulk
|
import com.chibatching.kotpref.bulk
|
||||||
import com.tommasoberlose.anotherwidget.R
|
import com.tommasoberlose.anotherwidget.R
|
||||||
|
import com.tommasoberlose.anotherwidget.components.BottomSheetColorPicker
|
||||||
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
|
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
|
||||||
import com.tommasoberlose.anotherwidget.databinding.FragmentClockSettingsBinding
|
import com.tommasoberlose.anotherwidget.databinding.FragmentClockSettingsBinding
|
||||||
import com.tommasoberlose.anotherwidget.global.Constants
|
import com.tommasoberlose.anotherwidget.global.Constants
|
||||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||||
import com.tommasoberlose.anotherwidget.global.RequestCode
|
import com.tommasoberlose.anotherwidget.global.RequestCode
|
||||||
import com.tommasoberlose.anotherwidget.helpers.AlarmHelper
|
import com.tommasoberlose.anotherwidget.helpers.AlarmHelper
|
||||||
|
import com.tommasoberlose.anotherwidget.helpers.ColorHelper
|
||||||
|
import com.tommasoberlose.anotherwidget.helpers.ColorHelper.toHexValue
|
||||||
|
import com.tommasoberlose.anotherwidget.helpers.ColorHelper.toIntValue
|
||||||
import com.tommasoberlose.anotherwidget.ui.activities.ChooseApplicationActivity
|
import com.tommasoberlose.anotherwidget.ui.activities.ChooseApplicationActivity
|
||||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||||
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
||||||
import com.tommasoberlose.anotherwidget.utils.toast
|
|
||||||
import kotlinx.android.synthetic.main.fragment_clock_settings.*
|
import kotlinx.android.synthetic.main.fragment_clock_settings.*
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
|
|
||||||
|
|
||||||
class ClockSettingsFragment : Fragment() {
|
class ClockTabFragment : Fragment() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance() = ClockSettingsFragment()
|
fun newInstance() = ClockTabFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var viewModel: MainViewModel
|
private lateinit var viewModel: MainViewModel
|
||||||
|
private lateinit var colors: IntArray
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@ -67,6 +72,12 @@ class ClockSettingsFragment : Fragment() {
|
|||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
|
val lazyColors = requireContext().resources.getIntArray(R.array.material_colors)
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
colors = lazyColors
|
||||||
|
}
|
||||||
|
}
|
||||||
setupListener()
|
setupListener()
|
||||||
updateNextAlarmWarningUi()
|
updateNextAlarmWarningUi()
|
||||||
}
|
}
|
||||||
@ -94,6 +105,28 @@ class ClockSettingsFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
viewModel.clockTextColor.observe(viewLifecycleOwner, Observer {
|
||||||
|
maintainScrollPosition {
|
||||||
|
if (Preferences.clockTextAlpha == "00") {
|
||||||
|
clock_text_color_label?.text = getString(R.string.transparent)
|
||||||
|
} else {
|
||||||
|
clock_text_color_label?.text =
|
||||||
|
"#%s".format(Integer.toHexString(ColorHelper.getClockFontColor())).toUpperCase()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
viewModel.clockTextAlpha.observe(viewLifecycleOwner, Observer {
|
||||||
|
maintainScrollPosition {
|
||||||
|
if (Preferences.clockTextAlpha == "00") {
|
||||||
|
clock_text_color_label?.text = getString(R.string.transparent)
|
||||||
|
} else {
|
||||||
|
clock_text_color_label?.text =
|
||||||
|
"#%s".format(Integer.toHexString(ColorHelper.getClockFontColor())).toUpperCase()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
viewModel.clockBottomMargin.observe(viewLifecycleOwner, Observer {
|
viewModel.clockBottomMargin.observe(viewLifecycleOwner, Observer {
|
||||||
maintainScrollPosition {
|
maintainScrollPosition {
|
||||||
clock_bottom_margin_label?.text = when (it) {
|
clock_bottom_margin_label?.text = when (it) {
|
||||||
@ -136,6 +169,23 @@ class ClockSettingsFragment : Fragment() {
|
|||||||
}.show()
|
}.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
action_clock_text_color.setOnClickListener {
|
||||||
|
BottomSheetColorPicker(requireContext(),
|
||||||
|
colors = colors,
|
||||||
|
header = getString(R.string.settings_font_color_title),
|
||||||
|
getSelected = ColorHelper::getClockFontColorRgb,
|
||||||
|
onColorSelected = { color: Int ->
|
||||||
|
val colorString = Integer.toHexString(color)
|
||||||
|
Preferences.clockTextColor = "#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||||
|
},
|
||||||
|
showAlphaSelector = true,
|
||||||
|
alpha = Preferences.clockTextAlpha.toIntValue(),
|
||||||
|
onAlphaChangeListener = { alpha ->
|
||||||
|
Preferences.clockTextAlpha = alpha.toHexValue()
|
||||||
|
}
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
|
||||||
action_clock_bottom_margin_size.setOnClickListener {
|
action_clock_bottom_margin_size.setOnClickListener {
|
||||||
BottomSheetMenu<Int>(requireContext(), header = getString(R.string.settings_show_next_alarm_title)).setSelectedValue(Preferences.clockBottomMargin)
|
BottomSheetMenu<Int>(requireContext(), header = getString(R.string.settings_show_next_alarm_title)).setSelectedValue(Preferences.clockBottomMargin)
|
||||||
.addItem(getString(R.string.settings_clock_bottom_margin_subtitle_none), Constants.ClockBottomMargin.NONE.value)
|
.addItem(getString(R.string.settings_clock_bottom_margin_subtitle_none), Constants.ClockBottomMargin.NONE.value)
|
@ -3,9 +3,7 @@ package com.tommasoberlose.anotherwidget.ui.fragments
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Color
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@ -33,10 +31,10 @@ import kotlinx.coroutines.launch
|
|||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
|
|
||||||
class GeneralSettingsFragment : Fragment() {
|
class GeneralTabFragment : Fragment() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance() = GeneralSettingsFragment()
|
fun newInstance() = GeneralTabFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var viewModel: MainViewModel
|
private lateinit var viewModel: MainViewModel
|
@ -17,13 +17,11 @@ import android.widget.RelativeLayout
|
|||||||
import androidx.core.animation.addListener
|
import androidx.core.animation.addListener
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.databinding.DataBindingUtil
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.Navigation
|
import androidx.navigation.Navigation
|
||||||
import androidx.navigation.fragment.FragmentNavigator
|
|
||||||
import com.google.android.material.badge.BadgeDrawable
|
import com.google.android.material.badge.BadgeDrawable
|
||||||
import com.google.android.material.tabs.TabLayoutMediator
|
import com.google.android.material.tabs.TabLayoutMediator
|
||||||
import com.google.android.material.transition.MaterialSharedAxis
|
import com.google.android.material.transition.MaterialSharedAxis
|
||||||
@ -50,10 +48,10 @@ import org.greenrobot.eventbus.EventBus
|
|||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
|
|
||||||
class AppMainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeListener {
|
class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance() = AppMainFragment()
|
fun newInstance() = MainFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var viewModel: MainViewModel
|
private lateinit var viewModel: MainViewModel
|
||||||
@ -91,9 +89,9 @@ class AppMainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeL
|
|||||||
}.attach()
|
}.attach()
|
||||||
|
|
||||||
// Init clock
|
// Init clock
|
||||||
time.setTextColor(ColorHelper.getFontColor())
|
time.setTextColor(ColorHelper.getClockFontColor())
|
||||||
time.setTextSize(TypedValue.COMPLEX_UNIT_SP, Preferences.clockTextSize.toPixel(requireContext()))
|
time.setTextSize(TypedValue.COMPLEX_UNIT_SP, Preferences.clockTextSize.toPixel(requireContext()))
|
||||||
time_am_pm.setTextColor(ColorHelper.getFontColor())
|
time_am_pm.setTextColor(ColorHelper.getClockFontColor())
|
||||||
time_am_pm.setTextSize(TypedValue.COMPLEX_UNIT_SP, Preferences.clockTextSize.toPixel(requireContext()) / 5 * 2)
|
time_am_pm.setTextSize(TypedValue.COMPLEX_UNIT_SP, Preferences.clockTextSize.toPixel(requireContext()) / 5 * 2)
|
||||||
time_container.isVisible = Preferences.showClock
|
time_container.isVisible = Preferences.showClock
|
||||||
|
|
||||||
@ -151,8 +149,8 @@ class AppMainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeL
|
|||||||
)
|
)
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
// Clock
|
// Clock
|
||||||
time.setTextColor(ColorHelper.getFontColor())
|
time.setTextColor(ColorHelper.getClockFontColor())
|
||||||
time_am_pm.setTextColor(ColorHelper.getFontColor())
|
time_am_pm.setTextColor(ColorHelper.getClockFontColor())
|
||||||
time.setTextSize(
|
time.setTextSize(
|
||||||
TypedValue.COMPLEX_UNIT_SP,
|
TypedValue.COMPLEX_UNIT_SP,
|
||||||
Preferences.clockTextSize.toPixel(requireContext())
|
Preferences.clockTextSize.toPixel(requireContext())
|
@ -41,10 +41,10 @@ import kotlinx.android.synthetic.main.fragment_weather_settings.scrollView
|
|||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class WeatherSettingsFragment : Fragment() {
|
class WeatherTabFragment : Fragment() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance() = WeatherSettingsFragment()
|
fun newInstance() = WeatherTabFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var viewModel: MainViewModel
|
private lateinit var viewModel: MainViewModel
|
@ -27,10 +27,11 @@ class MainViewModel : ViewModel() {
|
|||||||
val openEventDetails = Preferences.asLiveData(Preferences::openEventDetails)
|
val openEventDetails = Preferences.asLiveData(Preferences::openEventDetails)
|
||||||
val calendarAppName = Preferences.asLiveData(Preferences::calendarAppName)
|
val calendarAppName = Preferences.asLiveData(Preferences::calendarAppName)
|
||||||
|
|
||||||
|
|
||||||
// Clock Settings
|
// Clock Settings
|
||||||
val showClock = Preferences.asLiveData(Preferences::showClock)
|
val showClock = Preferences.asLiveData(Preferences::showClock)
|
||||||
val clockTextSize = Preferences.asLiveData(Preferences::clockTextSize)
|
val clockTextSize = Preferences.asLiveData(Preferences::clockTextSize)
|
||||||
|
val clockTextColor = Preferences.asLiveData(Preferences::clockTextColor)
|
||||||
|
val clockTextAlpha = Preferences.asLiveData(Preferences::clockTextAlpha)
|
||||||
|
|
||||||
val clockAppName = Preferences.asLiveData(Preferences::clockAppName)
|
val clockAppName = Preferences.asLiveData(Preferences::clockAppName)
|
||||||
val showNextAlarm = Preferences.asLiveData(Preferences::showNextAlarm)
|
val showNextAlarm = Preferences.asLiveData(Preferences::showNextAlarm)
|
||||||
|
@ -334,8 +334,8 @@ class MainWidget : AppWidgetProvider() {
|
|||||||
views.setViewVisibility(R.id.clock_bottom_margin_medium, View.GONE)
|
views.setViewVisibility(R.id.clock_bottom_margin_medium, View.GONE)
|
||||||
views.setViewVisibility(R.id.clock_bottom_margin_large, View.GONE)
|
views.setViewVisibility(R.id.clock_bottom_margin_large, View.GONE)
|
||||||
} else {
|
} else {
|
||||||
views.setTextColor(R.id.time, ColorHelper.getFontColor())
|
views.setTextColor(R.id.time, ColorHelper.getClockFontColor())
|
||||||
views.setTextColor(R.id.time_am_pm, ColorHelper.getFontColor())
|
views.setTextColor(R.id.time_am_pm, ColorHelper.getClockFontColor())
|
||||||
views.setTextViewTextSize(
|
views.setTextViewTextSize(
|
||||||
R.id.time,
|
R.id.time,
|
||||||
TypedValue.COMPLEX_UNIT_SP,
|
TypedValue.COMPLEX_UNIT_SP,
|
||||||
|
@ -141,6 +141,43 @@
|
|||||||
style="@style/AnotherWidget.Settings.Subtitle"/>
|
style="@style/AnotherWidget.Settings.Subtitle"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:id="@+id/action_clock_text_color"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:src="@drawable/round_palette"
|
||||||
|
android:tint="@color/colorPrimaryText"/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/AnotherWidget.Settings.Title"
|
||||||
|
android:text="@string/settings_clock_text_color_title"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/clock_text_color_label"
|
||||||
|
style="@style/AnotherWidget.Settings.Subtitle"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
app:startDestination="@id/appMainFragment">
|
app:startDestination="@id/appMainFragment">
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/appMainFragment"
|
android:id="@+id/appMainFragment"
|
||||||
android:name="com.tommasoberlose.anotherwidget.ui.fragments.AppMainFragment"
|
android:name="com.tommasoberlose.anotherwidget.ui.fragments.MainFragment"
|
||||||
android:label="AppMainFragment" >
|
android:label="AppMainFragment" >
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_appMainFragment_to_appSettingsFragment"
|
android:id="@+id/action_appMainFragment_to_appSettingsFragment"
|
||||||
|
@ -207,4 +207,5 @@
|
|||||||
<string name="transparent">Transparent</string>
|
<string name="transparent">Transparent</string>
|
||||||
<string name="next_alarm_warning">The next alarm clock seems to be wrong.\nIt has been set by %s.</string>
|
<string name="next_alarm_warning">The next alarm clock seems to be wrong.\nIt has been set by %s.</string>
|
||||||
<string name="settings_title">Settings</string>
|
<string name="settings_title">Settings</string>
|
||||||
|
<string name="settings_clock_text_color_title">Clock text color</string>
|
||||||
</resources>
|
</resources>
|
@ -187,4 +187,5 @@
|
|||||||
<string name="transparent">Transparent</string>
|
<string name="transparent">Transparent</string>
|
||||||
<string name="next_alarm_warning">The next alarm clock seems to be wrong.\nIt has been set by %s.</string>
|
<string name="next_alarm_warning">The next alarm clock seems to be wrong.\nIt has been set by %s.</string>
|
||||||
<string name="settings_title">Settings</string>
|
<string name="settings_title">Settings</string>
|
||||||
|
<string name="settings_clock_text_color_title">Clock text color</string>
|
||||||
</resources>
|
</resources>
|
@ -186,4 +186,5 @@
|
|||||||
<string name="transparent">Trasparente</string>
|
<string name="transparent">Trasparente</string>
|
||||||
<string name="next_alarm_warning">La sveglia sembra impostata male.\nÈ stata impostata dall\'app %s.</string>
|
<string name="next_alarm_warning">La sveglia sembra impostata male.\nÈ stata impostata dall\'app %s.</string>
|
||||||
<string name="settings_title">Impostazioni</string>
|
<string name="settings_title">Impostazioni</string>
|
||||||
|
<string name="settings_clock_text_color_title">Colore orologio</string>
|
||||||
</resources>
|
</resources>
|
@ -198,4 +198,5 @@
|
|||||||
<string name="transparent">Transparent</string>
|
<string name="transparent">Transparent</string>
|
||||||
<string name="next_alarm_warning">The next alarm clock seems to be wrong.\nIt has been set by %s.</string>
|
<string name="next_alarm_warning">The next alarm clock seems to be wrong.\nIt has been set by %s.</string>
|
||||||
<string name="settings_title">Settings</string>
|
<string name="settings_title">Settings</string>
|
||||||
|
<string name="settings_clock_text_color_title">Clock text color</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
xmlns:dist="http://schemas.android.com/apk/distribution"
|
xmlns:dist="http://schemas.android.com/apk/distribution"
|
||||||
featureSplit="tasksintegration"
|
featureSplit="tasksintegration"
|
||||||
package="com.tommasoberlose.anotherwidget"
|
package="com.tommasoberlose.anotherwidget"
|
||||||
android:versionCode="76"
|
android:versionCode="78"
|
||||||
android:versionName="2.0.5" >
|
android:versionName="2.0.5" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#Fri May 08 01:05:26 CEST 2020
|
#Fri May 08 11:53:34 CEST 2020
|
||||||
base.0=/Users/tommaso/Documents/MyCode/another-widget/tasksintegration/build/intermediates/dex/debug/mergeProjectDexDebug/out/classes.dex
|
base.0=/Users/tommaso/Documents/MyCode/another-widget/tasksintegration/build/intermediates/dex/debug/mergeProjectDexDebug/out/classes.dex
|
||||||
path.0=classes.dex
|
path.0=classes.dex
|
||||||
renamed.0=classes.dex
|
renamed.0=classes.dex
|
||||||
|
Binary file not shown.
@ -4,7 +4,7 @@
|
|||||||
featureSplit="tasksintegration"
|
featureSplit="tasksintegration"
|
||||||
package="com.tommasoberlose.anotherwidget"
|
package="com.tommasoberlose.anotherwidget"
|
||||||
android:targetSandboxVersion="2"
|
android:targetSandboxVersion="2"
|
||||||
android:versionCode="76"
|
android:versionCode="78"
|
||||||
android:versionName="2.0.5" >
|
android:versionName="2.0.5" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
3 xmlns:dist="http://schemas.android.com/apk/distribution"
|
3 xmlns:dist="http://schemas.android.com/apk/distribution"
|
||||||
4 featureSplit="tasksintegration"
|
4 featureSplit="tasksintegration"
|
||||||
5 package="com.tommasoberlose.anotherwidget"
|
5 package="com.tommasoberlose.anotherwidget"
|
||||||
6 android:versionCode="76"
|
6 android:versionCode="78"
|
||||||
7 android:versionName="2.0.5" >
|
7 android:versionName="2.0.5" >
|
||||||
8
|
8
|
||||||
9 <uses-sdk
|
9 <uses-sdk
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
xmlns:dist="http://schemas.android.com/apk/distribution"
|
xmlns:dist="http://schemas.android.com/apk/distribution"
|
||||||
featureSplit="tasksintegration"
|
featureSplit="tasksintegration"
|
||||||
package="com.tommasoberlose.anotherwidget"
|
package="com.tommasoberlose.anotherwidget"
|
||||||
android:versionCode="76"
|
android:versionCode="78"
|
||||||
android:versionName="2.0.5" >
|
android:versionName="2.0.5" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
xmlns:dist="http://schemas.android.com/apk/distribution"
|
xmlns:dist="http://schemas.android.com/apk/distribution"
|
||||||
featureSplit="tasksintegration"
|
featureSplit="tasksintegration"
|
||||||
package="com.tommasoberlose.anotherwidget"
|
package="com.tommasoberlose.anotherwidget"
|
||||||
android:versionCode="76"
|
android:versionCode="78"
|
||||||
android:versionName="2.0.5" >
|
android:versionName="2.0.5" >
|
||||||
|
|
||||||
<uses-sdk android:targetSdkVersion="29" />
|
<uses-sdk android:targetSdkVersion="29" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user