Add a new cool icon pack

This commit is contained in:
Tommaso Berlose 2020-05-19 19:48:33 +02:00
parent c2c54a04d2
commit a3392dabcf
45 changed files with 149 additions and 51 deletions

Binary file not shown.

View File

@ -18,8 +18,8 @@ android {
applicationId "com.tommasoberlose.anotherwidget"
minSdkVersion 23
targetSdkVersion 29
versionCode 96
versionName "2.0.9"
versionCode 97
versionName "2.0.10"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Binary file not shown.

View File

@ -31,6 +31,7 @@ object Constants {
enum class WeatherIconPack(val value: Int) {
DEFAULT(0),
MINIMAL(1)
MINIMAL(1),
COOL(2)
}
}

View File

@ -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 {

View File

@ -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

View File

@ -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()
}

View File

@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -327,6 +327,7 @@
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:id="@+id/weather_icon_pack"
android:src="@drawable/round_cloud_queue"
android:tint="@color/colorPrimaryText"/>
<LinearLayout

View File

@ -106,8 +106,7 @@
<string name="action_open_provider">Gå til OpenWeatherMap.com</string>
<string name="api_key_info_all_set">Der kan gå op til 10 minutter inden din API nøgle er aktiveret. Vejret vil blive opdateret så snart det er tilgængeligt.</string>
<string name="settings_weather_icon_pack_title">Ikonpakke</string>
<string name="settings_weather_icon_pack_default">Standard</string>
<string name="settings_weather_icon_pack_minimal">Minimal</string>
<string name="settings_weather_icon_pack_default">Ikonpakke %d</string>
<!-- Clock -->
<string name="settings_clock_title">Ur</string>

View File

@ -104,8 +104,7 @@
<string name="action_open_provider">Kunjungi OpenWeatherMap.com</string>
<string name="api_key_info_all_set">Mungkin membutuhkan lebih kurang 10 menit sebelum kunci API anda diaktifkan. Cuaca akan diperbarui segera setelah data tersedia.</string>
<string name="settings_weather_icon_pack_title">Paket ikon</string>
<string name="settings_weather_icon_pack_default">Bawaan</string>
<string name="settings_weather_icon_pack_minimal">Minimal</string>
<string name="settings_weather_icon_pack_default">Paket ikon %d</string>
<!-- Clock -->
<string name="settings_clock_title">Jam</string>

View File

@ -102,9 +102,8 @@
<string name="api_key_subtitle_3">Copia qui la chiave API e salva la nuova configurazione.</string>
<string name="action_open_provider">Apri OpenWeatherMap.com</string>
<string name="api_key_info_all_set">La chiave API potrebbe aver bisogno di più di 20 minuti per diventare attiva, aggiorneremo il meteo non appena sarà possibile.</string>
<string name="settings_weather_icon_pack_title">Stile icone</string>
<string name="settings_weather_icon_pack_default">Default</string>
<string name="settings_weather_icon_pack_minimal">Minimal</string>
<string name="settings_weather_icon_pack_title">Icon pack</string>
<string name="settings_weather_icon_pack_default">Icon pack %d</string>
<!-- Clock -->
<string name="settings_clock_title">Orologio</string>

View File

@ -103,8 +103,7 @@
<string name="action_open_provider">Перейти на OpenWeatherMap.com</string>
<string name="api_key_info_all_set">Активация ключа может занять до десяти минут. Погода обновится как только появится возможность.</string>
<string name="settings_weather_icon_pack_title">Набор иконок</string>
<string name="settings_weather_icon_pack_default">По умолчанию</string>
<string name="settings_weather_icon_pack_minimal">Минималистичный</string>
<string name="settings_weather_icon_pack_default">Набор иконок %d</string>
<!-- Clock -->
<string name="settings_clock_title">Часы</string>

View File

@ -106,8 +106,7 @@
<string name="action_open_provider">Go to OpenWeatherMap.com</string>
<string name="api_key_info_all_set">It may take up to ten minutes before your API key is activated. The weather will be updated as soon as it is available.</string>
<string name="settings_weather_icon_pack_title">Icon pack</string>
<string name="settings_weather_icon_pack_default">Default</string>
<string name="settings_weather_icon_pack_minimal">Minimal</string>
<string name="settings_weather_icon_pack_default">Icon pack %d</string>
<!-- Clock -->
<string name="settings_clock_title">Clock</string>