Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
// NOTE: Version Code Format (TargetSDK, Version Name, Build Number, Variant Code (Android: 0, WearOS: 1)
versionCode 345100070
versionName "5.10.1"
versionCode 345100100
versionName "5.10.3"

vectorDrawables {
useSupportLibrary true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.thewizrd.shared_resources.utils.Coordinate
import com.thewizrd.shared_resources.utils.DateTimeUtils
import com.thewizrd.shared_resources.utils.JSONParser
import com.thewizrd.shared_resources.utils.LocaleUtils
import com.thewizrd.shared_resources.utils.StringUtils.isNullOrWhitespace
import com.thewizrd.shared_resources.utils.ZoneIdCompat
import com.thewizrd.shared_resources.weatherdata.WeatherAPI
import com.thewizrd.shared_resources.weatherdata.WeatherProvider
Expand All @@ -33,11 +34,12 @@ import com.thewizrd.simpleweather.images.ImageDatabase
import com.thewizrd.simpleweather.images.model.ImageData
import com.thewizrd.simpleweather.updates.UpdateInfo
import com.thewizrd.weather_api.aqicn.AQICNProvider
import com.thewizrd.weather_api.google.location.AndroidLocationProvider
import com.thewizrd.weather_api.google.location.GoogleLocationProvider
import com.thewizrd.weather_api.google.location.createLocationModel
import com.thewizrd.weather_api.google.location.getFromLocationNameAsync
import com.thewizrd.weather_api.google.location.isGeocoderAvailable
import com.thewizrd.weather_api.here.auth.hereOAuthService
import com.thewizrd.weather_api.locationiq.LocationIQProvider
import com.thewizrd.weather_api.nws.SolCalcAstroProvider
import com.thewizrd.weather_api.nws.alerts.NWSAlertProvider
import com.thewizrd.weather_api.smc.SunMoonCalcProvider
Expand Down Expand Up @@ -348,16 +350,12 @@ class UnitTests {
fun androidGeocoderTest() {
runBlocking(Dispatchers.Default) {
assertTrue(isGeocoderAvailable())
val geocoder = Geocoder(context, Locale.getDefault())
val addressList = withContext(Dispatchers.IO) {
//geocoder.getFromLocation(47.6721646, -122.1706614, 1); // Washington
geocoder.getFromLocation(51.5073884, -0.1334347, 1) // London
val locationProvider = AndroidLocationProvider()
val location = withContext(Dispatchers.IO) {
locationProvider.getLocation(Coordinate(51.5073884, -0.1334347), WeatherAPI.ANDROID)
}
assertFalse(addressList.isNullOrEmpty())
val result = addressList!![0]
assertNotNull(result)
val locQVM = createLocationModel(result, WeatherAPI.ANDROID)
assertFalse(locQVM.locationName.toString().contains("null"))
assertNotNull(location)
assertFalse(location.locationName.toString().contains("null"))
}
}

Expand All @@ -381,7 +379,7 @@ class UnitTests {
Coordinate(
queryVM!!.locationLat,
queryVM.locationLong
), WeatherAPI.OPENWEATHERMAP
), WeatherAPI.GOOGLE
)
} else if (locationProvider.needsLocationFromID()) {
locationProvider.getLocationFromID(queryVM!!)
Expand All @@ -390,18 +388,57 @@ class UnitTests {
}

assertNotNull(locModel)
assertFalse(locModel?.locationName.isNullOrWhitespace())
assertTrue(locModel?.toLocationData()?.isValid == true)
}
}

@Test
@Throws(WeatherException::class)
fun locIQLocationTest() {
runBlocking(Dispatchers.Default) {
val locationProvider: WeatherLocationProvider = LocationIQProvider()
val locations = withContext(Dispatchers.IO) {
locationProvider.getLocations("Redmond, WA", WeatherAPI.LOCATIONIQ)
}
assertFalse(locations.isEmpty())

val queryVM = locations.find { it.locationName?.startsWith("Redmond") == true }
assertNotNull(queryVM)

if (locModel!!.locationTZLong.isNullOrBlank() && locModel.locationLat != 0.0 && locModel.locationLong != 0.0) {
val tzId = weatherModule.tzdbService.getTimeZone(
locModel.locationLat,
locModel.locationLong
val locModel = if (locationProvider.needsLocationFromName()) {
locationProvider.getLocationFromName(queryVM!!)
} else if (locationProvider.needsLocationFromGeocoder()) {
locationProvider.getLocation(
Coordinate(
queryVM!!.locationLat,
queryVM.locationLong
), WeatherAPI.LOCATIONIQ
)
if ("unknown" != tzId)
locModel.locationTZLong = tzId
} else if (locationProvider.needsLocationFromID()) {
locationProvider.getLocationFromID(queryVM!!)
} else {
queryVM
}

assertNotNull(locModel)
assertFalse(locModel?.locationName.isNullOrWhitespace())
assertTrue(locModel?.toLocationData()?.isValid == true)
}
}

@Test
@Throws(WeatherException::class)
fun locIQLocationGeocoderTest() {
runBlocking(Dispatchers.Default) {
val locationProvider: WeatherLocationProvider = LocationIQProvider()
val locModel = withContext(Dispatchers.IO) {
locationProvider.getLocation(Coordinate(51.5073884, -0.1334347), WeatherAPI.ANDROID)
}

assertFalse(locModel.locationTZLong.isNullOrEmpty())
assertTrue(locModel.toLocationData().isValid)
assertNotNull(locModel)
assertFalse(locModel?.locationName.isNullOrWhitespace())
assertTrue(locModel?.toLocationData()?.isValid == true)
}
}

Expand All @@ -425,7 +462,7 @@ class UnitTests {
Coordinate(
queryVM!!.locationLat,
queryVM.locationLong
), WeatherAPI.OPENWEATHERMAP
), WeatherAPI.WEATHERAPI
)
} else if (locationProvider.needsLocationFromID()) {
locationProvider.getLocationFromID(queryVM!!)
Expand All @@ -434,18 +471,8 @@ class UnitTests {
}

assertNotNull(locModel)

if (locModel!!.locationTZLong.isNullOrBlank() && locModel.locationLat != 0.0 && locModel.locationLong != 0.0) {
val tzId = weatherModule.tzdbService.getTimeZone(
locModel.locationLat,
locModel.locationLong
)
if ("unknown" != tzId)
locModel.locationTZLong = tzId
}

assertFalse(locModel.locationTZLong.isNullOrEmpty())
assertTrue(locModel.toLocationData().isValid)
assertFalse(locModel?.locationName.isNullOrWhitespace())
assertTrue(locModel?.toLocationData()?.isValid == true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ import com.thewizrd.shared_resources.utils.ContextUtils.isSmallestWidth
import com.thewizrd.shared_resources.utils.Logger
import com.thewizrd.shared_resources.weatherdata.model.AirQuality
import com.thewizrd.shared_resources.weatherdata.model.Atmosphere
import com.thewizrd.shared_resources.weatherdata.model.Beaufort
import com.thewizrd.shared_resources.weatherdata.model.Condition
import com.thewizrd.shared_resources.weatherdata.model.Forecast
import com.thewizrd.shared_resources.weatherdata.model.ForecastExtras
import com.thewizrd.shared_resources.weatherdata.model.HourlyForecast
import com.thewizrd.shared_resources.weatherdata.model.Location
import com.thewizrd.shared_resources.weatherdata.model.LocationType
import com.thewizrd.shared_resources.weatherdata.model.MinutelyForecast
import com.thewizrd.shared_resources.weatherdata.model.Pollen
import com.thewizrd.shared_resources.weatherdata.model.Precipitation
import com.thewizrd.shared_resources.weatherdata.model.UV
import com.thewizrd.shared_resources.weatherdata.model.Weather
import com.thewizrd.simpleweather.R
import com.thewizrd.simpleweather.activities.LocationSearch
Expand Down Expand Up @@ -596,15 +599,27 @@ abstract class AbstractWeatherWidgetPreferenceFragment : ToolbarPreferenceFragme
weather = getString(R.string.weather_sunny)
tempF = 70f
tempC = 21f
windDegrees = 292
windMph = 5f
windKph = 8f
windGustMph = 15f
windGustKph = 25f
feelslikeF = 75f
feelslikeC = 23f
highF = 75f
highC = 23f
lowF = 60f
lowC = 15f
icon = WeatherIcons.DAY_SUNNY
airQuality = AirQuality().apply {
index = 46
index = Random.nextInt(0, 301)
}
beaufort = Beaufort(Beaufort.BeaufortScale.valueOf(Random.nextInt(0, 12)))
uv = UV(Random.nextInt(0, 11).toFloat())
pollen = Pollen().apply {
treePollenCount = Pollen.PollenCount.VERY_HIGH
grassPollenCount = Pollen.PollenCount.LOW
ragweedPollenCount = Pollen.PollenCount.MODERATE
}
}
atmosphere = Atmosphere()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.text.style.TextAppearanceSpan
import android.util.TypedValue
import android.view.View
import android.widget.RemoteViews
import com.thewizrd.common.controls.WeatherDetailsType
import com.thewizrd.common.controls.WeatherUiModel
import com.thewizrd.common.helpers.ColorsUtils
import com.thewizrd.common.utils.ImageUtils
Expand Down Expand Up @@ -153,6 +154,10 @@ class WeatherWidget4x2Creator(context: Context, loadBackground: Boolean = true)
R.id.condition_weather,
textColor
)
updateViews.setTextColor(
R.id.condition_feelslike,
textColor
)

updateViews.setTextColor(R.id.date_panel, textColor)
updateViews.setTextColor(R.id.clock_panel, textColor)
Expand All @@ -170,6 +175,15 @@ class WeatherWidget4x2Creator(context: Context, loadBackground: Boolean = true)
weather.curTemp?.applySpan(textAppearanceSpan)
)

weather.weatherDetailsMap[WeatherDetailsType.FEELSLIKE]?.let {
updateViews.setTextViewText(
R.id.condition_feelslike,
"${it.label}: ${it.value}".applySpan(textAppearanceSpan)
)
} ?: run {
updateViews.setViewVisibility(R.id.condition_feelslike, View.GONE)
}

buildDate(location, updateViews, appWidgetId, newOptions)
// Open default clock/calendar app
updateViews.setOnClickPendingIntent(
Expand Down Expand Up @@ -361,6 +375,11 @@ class WeatherWidget4x2Creator(context: Context, loadBackground: Boolean = true)
TypedValue.COMPLEX_UNIT_SP,
12f * txtSizeMultiplier
)
updateViews.setTextViewTextSize(
R.id.condition_feelslike,
TypedValue.COMPLEX_UNIT_SP,
12f * txtSizeMultiplier
)
}

private fun updateClockSize(views: RemoteViews, appWidgetId: Int, newOptions: Bundle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ class WeatherWidget4x2TomorrowCreator(context: Context, loadBackground: Boolean
R.id.condition_weather,
textColor
)
updateViews.setTextColor(
R.id.condition_feelslike,
textColor
)

updateViews.setTextColor(R.id.date_panel, textColor)
updateViews.setTextColor(R.id.clock_panel, textColor)
Expand All @@ -189,6 +193,15 @@ class WeatherWidget4x2TomorrowCreator(context: Context, loadBackground: Boolean
weather.curTemp?.applySpan(textAppearanceSpan)
)

weather.weatherDetailsMap[WeatherDetailsType.FEELSLIKE]?.let {
updateViews.setTextViewText(
R.id.condition_feelslike,
"${it.label}: ${it.value}".applySpan(textAppearanceSpan)
)
} ?: run {
updateViews.setViewVisibility(R.id.condition_feelslike, View.GONE)
}

buildDate(location, updateViews, appWidgetId, newOptions)
// Open default clock/calendar app
updateViews.setOnClickPendingIntent(
Expand Down Expand Up @@ -659,6 +672,11 @@ class WeatherWidget4x2TomorrowCreator(context: Context, loadBackground: Boolean
TypedValue.COMPLEX_UNIT_SP,
12f * txtSizeMultiplier
)
updateViews.setTextViewTextSize(
R.id.condition_feelslike,
TypedValue.COMPLEX_UNIT_SP,
12f * txtSizeMultiplier
)
}

private fun updateClockSize(views: RemoteViews, appWidgetId: Int, newOptions: Bundle) {
Expand Down
71 changes: 46 additions & 25 deletions app/src/main/res/layout/app_widget_4x2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:baselineAligned="false"
android:orientation="horizontal">

Expand Down Expand Up @@ -156,41 +157,61 @@

</LinearLayout>

<RelativeLayout
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:orientation="vertical">

<ImageView
android:id="@+id/weather_icon"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:adjustViewBounds="true"
android:gravity="center_vertical"
android:maxWidth="60dp"
android:maxHeight="60dp"
android:scaleType="fitCenter"
tools:src="@drawable/wi_thunderstorm" />
android:orientation="horizontal"
android:paddingVertical="2dp">

<ImageView
android:id="@+id/weather_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:adjustViewBounds="true"
android:gravity="center_vertical"
android:maxWidth="60dp"
android:maxHeight="60dp"
android:scaleType="fitCenter"
tools:src="@drawable/wi_thunderstorm" />

<TextView
android:id="@+id/condition_temp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start"
android:layout_marginStart="2dp"
android:gravity="center_vertical"
android:shadowColor="#000000"
android:textColor="@android:color/white"
android:textSize="28sp"
tools:text="70°F" />

</LinearLayout>

<TextView
android:id="@+id/condition_temp"
android:layout_width="wrap_content"
android:id="@+id/condition_feelslike"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_gravity="center_vertical|start"
android:layout_marginStart="2dp"
android:layout_toEndOf="@id/weather_icon"
android:gravity="center_vertical"
android:gravity="end"
android:maxLines="1"
android:paddingStart="4dp"
android:paddingEnd="4dp"
android:shadowColor="#000000"
android:textColor="@android:color/white"
android:textSize="28sp"
tools:text="70°F" />
android:textSize="12sp"
tools:ignore="UnusedAttribute"
tools:text="Feels like: 75°" />

</RelativeLayout>
</LinearLayout>

</LinearLayout>

Expand Down
Loading