Add a new cool icon pack
This commit is contained in:
@ -31,6 +31,7 @@ object Constants {
|
||||
|
||||
enum class WeatherIconPack(val value: Int) {
|
||||
DEFAULT(0),
|
||||
MINIMAL(1)
|
||||
MINIMAL(1),
|
||||
COOL(2)
|
||||
}
|
||||
}
|
@ -128,10 +128,8 @@ object IntentHelper {
|
||||
|
||||
putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, e.startDate + start.timeZone.getOffset(start.timeInMillis))
|
||||
putExtra(CalendarContract.EXTRA_EVENT_END_TIME, e.endDate + end.timeZone.getOffset(end.timeInMillis))
|
||||
// putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, 1)
|
||||
putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, 1)
|
||||
}
|
||||
|
||||
Log.d("ciao", "intent: ${this} - extras: ${this.extras}")
|
||||
}
|
||||
} else {
|
||||
getCalendarIntent(context).apply {
|
||||
|
@ -47,81 +47,177 @@ object WeatherHelper {
|
||||
}
|
||||
|
||||
fun getWeatherIconResource(icon: String): Int {
|
||||
when (icon) {
|
||||
return when (icon) {
|
||||
"01d" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.clear_day else R.drawable.clear_day_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.clear_day_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.clear_day_2
|
||||
else -> R.drawable.clear_day
|
||||
}
|
||||
}
|
||||
"02d" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.partly_cloudy else R.drawable.partly_cloudy_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.partly_cloudy_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.partly_cloudy_2
|
||||
else -> R.drawable.partly_cloudy
|
||||
}
|
||||
}
|
||||
"03d" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.mostly_cloudy else R.drawable.mostly_cloudy_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.mostly_cloudy_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.mostly_cloudy_2
|
||||
else -> R.drawable.mostly_cloudy
|
||||
}
|
||||
}
|
||||
"04d" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.cloudy_weather else R.drawable.cloudy_weather_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.cloudy_weather_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.cloudy_weather_2
|
||||
else -> R.drawable.cloudy_weather
|
||||
}
|
||||
}
|
||||
"09d" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.storm_weather_day else R.drawable.storm_weather_day_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.storm_weather_day_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.storm_weather_day_2
|
||||
else -> R.drawable.storm_weather_day
|
||||
}
|
||||
}
|
||||
"10d" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.rainy_day else R.drawable.rainy_day_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.rainy_day_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.rainy_day_2
|
||||
else -> R.drawable.rainy_day
|
||||
}
|
||||
}
|
||||
"11d" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.thunder_day else R.drawable.thunder_day_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.thunder_day_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.thunder_day_2
|
||||
else -> R.drawable.thunder_day
|
||||
}
|
||||
}
|
||||
"13d" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.snow_day else R.drawable.snow_day_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.snow_day_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.snow_day_2
|
||||
else -> R.drawable.snow_day
|
||||
}
|
||||
}
|
||||
"50d" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.haze_day else R.drawable.haze_day_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.haze_day_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.haze_day_2
|
||||
else -> R.drawable.haze_day
|
||||
}
|
||||
}
|
||||
"80d" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.windy_day else R.drawable.windy_day_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.windy_day_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.windy_day_2
|
||||
else -> R.drawable.windy_day
|
||||
}
|
||||
}
|
||||
"81d" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.rain_snow_day else R.drawable.rain_snow_day_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.rain_snow_day_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.rain_snow_day_2
|
||||
else -> R.drawable.rain_snow_day
|
||||
}
|
||||
}
|
||||
"82d" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.haze_weather else R.drawable.haze_weather_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.haze_weather_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.haze_weather_2
|
||||
else -> R.drawable.haze_weather
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
"01n" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.clear_night else R.drawable.clear_night_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.clear_night_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.clear_night_2
|
||||
else -> R.drawable.clear_night
|
||||
}
|
||||
}
|
||||
"02n" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.partly_cloudy_night else R.drawable.partly_cloudy_night_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.partly_cloudy_night_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.partly_cloudy_night_2
|
||||
else -> R.drawable.partly_cloudy_night
|
||||
}
|
||||
}
|
||||
"03n" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.mostly_cloudy_night else R.drawable.mostly_cloudy_night_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.mostly_cloudy_night_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.mostly_cloudy_night_2
|
||||
else -> R.drawable.mostly_cloudy_night
|
||||
}
|
||||
}
|
||||
"04n" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.cloudy_weather else R.drawable.cloudy_weather_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.cloudy_weather_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.cloudy_weather_2
|
||||
else -> R.drawable.cloudy_weather
|
||||
}
|
||||
}
|
||||
"09n" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.storm_weather_night else R.drawable.storm_weather_night_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.storm_weather_night_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.storm_weather_night_2
|
||||
else -> R.drawable.storm_weather_night
|
||||
}
|
||||
}
|
||||
"10n" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.rainy_night else R.drawable.rainy_night_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.rainy_night_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.rainy_night_2
|
||||
else -> R.drawable.rainy_night
|
||||
}
|
||||
}
|
||||
"11n" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.thunder_night else R.drawable.thunder_night_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.thunder_night_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.thunder_night_2
|
||||
else -> R.drawable.thunder_night
|
||||
}
|
||||
}
|
||||
"13n" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.snow_night else R.drawable.snow_night_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.snow_night_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.snow_night_2
|
||||
else -> R.drawable.snow_night
|
||||
}
|
||||
}
|
||||
"50n" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.haze_night else R.drawable.haze_night_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.haze_night_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.haze_night_2
|
||||
else -> R.drawable.haze_night
|
||||
}
|
||||
}
|
||||
"80n" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.windy_night else R.drawable.windy_night_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.windy_night_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.windy_night_2
|
||||
else -> R.drawable.windy_night
|
||||
}
|
||||
}
|
||||
"81n" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.rain_snow_night else R.drawable.rain_snow_night_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.rain_snow_night_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.rain_snow_night_2
|
||||
else -> R.drawable.rain_snow_night
|
||||
}
|
||||
}
|
||||
"82n" -> {
|
||||
return if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) R.drawable.haze_weather else R.drawable.haze_weather_2
|
||||
when (Preferences.weatherIconPack) {
|
||||
Constants.WeatherIconPack.COOL.value -> R.drawable.haze_weather_3
|
||||
Constants.WeatherIconPack.MINIMAL.value -> R.drawable.haze_weather_2
|
||||
else -> R.drawable.haze_weather
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
return R.drawable.unknown
|
||||
|
@ -10,6 +10,7 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.os.BuildCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
@ -28,7 +29,9 @@ import com.tommasoberlose.anotherwidget.databinding.FragmentWeatherSettingsBindi
|
||||
import com.tommasoberlose.anotherwidget.global.Constants
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.global.RequestCode
|
||||
import com.tommasoberlose.anotherwidget.helpers.ColorHelper
|
||||
import com.tommasoberlose.anotherwidget.helpers.SettingsStringHelper
|
||||
import com.tommasoberlose.anotherwidget.helpers.WeatherHelper
|
||||
import com.tommasoberlose.anotherwidget.receivers.WeatherReceiver
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.ChooseApplicationActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.CustomLocationActivity
|
||||
@ -129,9 +132,12 @@ class WeatherTabFragment : Fragment() {
|
||||
|
||||
viewModel.weatherIconPack.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
label_weather_icon_pack?.text = when (it) {
|
||||
Constants.WeatherIconPack.MINIMAL.value -> getString(R.string.settings_weather_icon_pack_minimal)
|
||||
else -> getString(R.string.settings_weather_icon_pack_default)
|
||||
label_weather_icon_pack?.text = getString(R.string.settings_weather_icon_pack_default).format((it + 1))
|
||||
weather_icon_pack.setImageDrawable(ContextCompat.getDrawable(requireContext(), WeatherHelper.getWeatherIconResource("01d")))
|
||||
if (it == Constants.WeatherIconPack.MINIMAL.value) {
|
||||
weather_icon_pack.setColorFilter(ContextCompat.getColor(requireContext(), R.color.colorPrimaryText))
|
||||
} else {
|
||||
weather_icon_pack.setColorFilter(ContextCompat.getColor(requireContext(), android.R.color.transparent))
|
||||
}
|
||||
}
|
||||
checkLocationPermission()
|
||||
@ -230,10 +236,11 @@ class WeatherTabFragment : Fragment() {
|
||||
|
||||
action_weather_icon_pack.setOnClickListener {
|
||||
if (Preferences.showWeather) {
|
||||
BottomSheetMenu<Int>(requireContext(), header = getString(R.string.settings_weather_icon_pack_title)).setSelectedValue(Preferences.weatherIconPack)
|
||||
.addItem(getString(R.string.settings_weather_icon_pack_default), Constants.WeatherIconPack.DEFAULT.value)
|
||||
.addItem(getString(R.string.settings_weather_icon_pack_minimal), Constants.WeatherIconPack.MINIMAL.value)
|
||||
.addOnSelectItemListener { value ->
|
||||
val dialog = BottomSheetMenu<Int>(requireContext(), header = getString(R.string.settings_weather_icon_pack_title)).setSelectedValue(Preferences.weatherIconPack)
|
||||
Constants.WeatherIconPack.values().forEach {
|
||||
dialog.addItem(getString(R.string.settings_weather_icon_pack_default).format(it.value + 1), it.value)
|
||||
}
|
||||
dialog.addOnSelectItemListener { value ->
|
||||
Preferences.weatherIconPack = value
|
||||
}.show()
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
it.setTextColor(ColorHelper.getFontColor())
|
||||
}
|
||||
|
||||
if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) {
|
||||
if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value || Preferences.weatherIconPack == Constants.WeatherIconPack.COOL.value) {
|
||||
listOf<ImageView>(v.action_next, v.action_previous)
|
||||
} else {
|
||||
listOf<ImageView>(v.action_next, v.action_previous, v.empty_weather_icon, v.special_weather_icon)
|
||||
@ -637,7 +637,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
it.setTextColor(ColorHelper.getSecondaryFontColor())
|
||||
}
|
||||
|
||||
if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value) {
|
||||
if (Preferences.weatherIconPack == Constants.WeatherIconPack.DEFAULT.value || Preferences.weatherIconPack == Constants.WeatherIconPack.COOL.value) {
|
||||
listOf<ImageView>(v.second_row_icon)
|
||||
} else {
|
||||
listOf<ImageView>(v.second_row_icon, v.weather_icon)
|
||||
|
Reference in New Issue
Block a user