Skip to content

Commit

Permalink
55937-elys
Browse files Browse the repository at this point in the history
  • Loading branch information
ELY M committed Jan 29, 2025
1 parent 9288549 commit 900f4b2
Show file tree
Hide file tree
Showing 20 changed files with 219 additions and 250 deletions.
2 changes: 0 additions & 2 deletions DOC/Todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

## Bugs

* [FIX] back button handling in WebView for API
36 [https://developer.android.com/guide/navigation/navigation-custom-back](https://developer.android.com/guide/navigation/navigation-custom-back)
* [FIX] during recent AS updates

```
Expand Down
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ android {

defaultConfig {
compileSdk 35
// compileSdkPreview "Baklava"
}

defaultConfig {
applicationId "elys.joshuatee.wx"
// 2023-09-09 changed from 23 to 25
minSdkVersion 27
targetSdkVersion 35
// targetSdkPreview 'Baklava'

// Stops the Gradle plugin’s automatic rasterization of vectors (2016_02_25 add 23.2 )
// vectorDrawables.useSupportLibrary = true
multiDexEnabled true
Expand Down Expand Up @@ -118,6 +121,7 @@ android {
checkReleaseBuilds false
disable 'Typos'
}
// compileSdkPreview 'Baklava'
}

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="55936"
android:versionName="55936-elys">
android:versionCode="55937"
android:versionName="55937-elys">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/joshuatee/wx/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import java.util.regex.Pattern
import joshuatee.wx.ui.TouchImage
import joshuatee.wx.util.To
import joshuatee.wx.util.Utility
import joshuatee.wx.util.UtilityDownloadNws
import joshuatee.wx.util.UtilityImgAnim
import joshuatee.wx.util.UtilityNetworkIO
import joshuatee.wx.util.UtilityString
Expand Down Expand Up @@ -84,7 +83,7 @@ fun String.getHtmlWithNewLineWithRetry(expectedMinSize: Long): String {
return html
}

fun String.getNwsHtml() = UtilityDownloadNws.getStringFromUrlBaseNoAcceptHeader1(this)
fun String.getNwsHtml() = UtilityNetworkIO.getStringFromUrlBaseNoAcceptHeader1(this)

fun String.getNwsHtmlWithRetry(expectedMinSize: Long): String {
var html = this.getNwsHtml()
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/joshuatee/wx/misc/CapAlert.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

package joshuatee.wx.misc

import joshuatee.wx.util.UtilityDownloadNws
import joshuatee.wx.common.GlobalVariables
import joshuatee.wx.common.RegExp
import joshuatee.wx.objects.ObjectWarning
Expand All @@ -30,6 +29,7 @@ import joshuatee.wx.parse
import joshuatee.wx.parseFirst
import joshuatee.wx.radar.RadarSites
import joshuatee.wx.removeLineBreaksCap
import joshuatee.wx.util.UtilityNetworkIO
import joshuatee.wx.util.UtilityString

@Suppress("SpellCheckingInspection")
Expand Down Expand Up @@ -115,7 +115,7 @@ class CapAlert {
fun createFromUrl(url: String): CapAlert {
val capAlert = CapAlert()
capAlert.url = url
val html = UtilityDownloadNws.getStringFromUrlSep(url)
val html = UtilityNetworkIO.getStringFromUrlSep(url)
capAlert.points = getWarningsFromJson(html)
capAlert.title = html.parse("\"headline\": \"(.*?)\"")
capAlert.summary = html.parse("\"description\": \"(.*?)\"")
Expand Down
27 changes: 14 additions & 13 deletions app/src/main/java/joshuatee/wx/misc/WebView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import android.view.Menu
import android.view.MenuItem
import android.webkit.WebView
import android.webkit.WebViewClient
//import androidx.activity.addCallback
import androidx.activity.addCallback
import joshuatee.wx.R
import joshuatee.wx.settings.UIPreferences
import joshuatee.wx.objects.Route
Expand Down Expand Up @@ -86,11 +86,12 @@ class WebView : BaseActivity() {
webView.loadData(url, "text/html", null)
}

// onBackPressedDispatcher.addCallback(this) {
// if (webView.canGoBack()) {
// webView.goBack()
// }
// }
// https://developer.android.com/guide/navigation/navigation-custom-back
onBackPressedDispatcher.addCallback(this) {
if (webView.canGoBack()) {
webView.goBack()
}
}
}

override fun onOptionsItemSelected(item: MenuItem): Boolean = when (item.itemId) {
Expand All @@ -102,11 +103,11 @@ class WebView : BaseActivity() {
else -> super.onOptionsItemSelected(item)
}

override fun onBackPressed() {
if (webView.canGoBack()) {
webView.goBack()
} else {
super.onBackPressed()
}
}
// override fun onBackPressed() {
// if (webView.canGoBack()) {
// webView.goBack()
// } else {
// super.onBackPressed()
// }
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ object NotificationLocal {
inBlackout: Boolean
): String {
val tornadoWarningString = "Tornado Warning"
val html = Hazards.getHazardsHtml(Location.getLatLon(locationIndex))
val html = Hazards.getHtml(Location.getLatLon(locationIndex))
var notificationUrls = ""
val locationLabel = "(" + Location.getName(locationIndex) + ") "
val ids = html.parseColumn("\"@id\": \"(.*?)\"")
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/joshuatee/wx/objects/PolygonWarning.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import joshuatee.wx.radar.Warnings
import joshuatee.wx.settings.RadarPreferences
import joshuatee.wx.util.Utility
import joshuatee.wx.util.UtilityDownloadNws
import joshuatee.wx.util.UtilityNetworkIO

class PolygonWarning(val context: Context, val type: PolygonWarningType) {

Expand All @@ -43,7 +44,7 @@ class PolygonWarning(val context: Context, val type: PolygonWarningType) {

fun download() {
if (timer.isRefreshNeeded()) {
val html = UtilityDownloadNws.getStringFromUrlBaseNoHeader1(getUrl())
val html = UtilityNetworkIO.getStringFromUrlBaseNoHeader1(getUrl())
if (html != "") {
storage.valueSet(context, html)
}
Expand Down
16 changes: 13 additions & 3 deletions app/src/main/java/joshuatee/wx/settings/SettingsRadarActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,18 @@ class SettingsRadarActivity : BaseActivity() {
Switch(this, "Location Heading Bug", "LOCDOT_BUG", R.string.locdot_bug_label),
//elys mod end
Switch(this, "Black background", "NWS_RADAR_BG_BLACK", R.string.nws_black_bg_label),
Switch(this, "Canadian and Mexican borders", "RADAR_CAMX_BORDERS", R.string.camx_borders_label),
Switch(this, "Center radar on location", "RADAR_CENTER_ON_LOCATION", R.string.radar_center_on_location_default_label),
Switch(
this,
"Canadian and Mexican borders",
"RADAR_CAMX_BORDERS",
R.string.camx_borders_label
),
Switch(
this,
"Center radar on location",
"RADAR_CENTER_ON_LOCATION",
R.string.radar_center_on_location_default_label
),
Switch(this, "Cities", "COD_CITIES_DEFAULT", R.string.cod_cities_default_label),
Switch(this, "Counties", "RADAR_SHOW_COUNTY", R.string.show_county_label),
Switch(this, "County labels", "RADAR_COUNTY_LABELS", R.string.show_county_labels_label),
Expand Down Expand Up @@ -186,7 +196,7 @@ class SettingsRadarActivity : BaseActivity() {
this,
"SPC Fire Weather Outlook Day One",
"RADAR_SHOW_FIRE",
R.string.show_swo_label
R.string.show_fire_label
),
Switch(this, "Spotters", "WXOGL_SPOTTERS", R.string.spotters_label),
Switch(this, "Spotter labels", "WXOGL_SPOTTERS_LABEL", R.string.spotters_label_label),
Expand Down
71 changes: 0 additions & 71 deletions app/src/main/java/joshuatee/wx/ui/CardVerticalText.kt

This file was deleted.

10 changes: 5 additions & 5 deletions app/src/main/java/joshuatee/wx/ui/HBox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ class HBox(val context: Context) {
linearLayout.visibility = value
}

var isBaselineAligned
get() = linearLayout.isBaselineAligned
set(value) {
linearLayout.isBaselineAligned = value
}
// var isBaselineAligned
// get() = linearLayout.isBaselineAligned
// set(value) {
// linearLayout.isBaselineAligned = value
// }

var orientation
get() = linearLayout.orientation
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/joshuatee/wx/ui/Text.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ class Text(val context: Context) : Widget {
tv.setTextSize(unit, size)
}

fun setSizeHourly() {
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, UtilityUI.spToPx(14, context))
}
// fun setSizeHourly() {
// tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, UtilityUI.spToPx(14, context))
// }

fun setMonoSpaced() {
tv.typeface = Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL)
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/joshuatee/wx/util/DownloadImage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ object DownloadImage {
"WEATHERSTORY" -> {
needsBitmap = false
bitmap = WeatherStory.getUrl().getImage()
// bitmap =
// ("https://www.weather.gov/images/" + Location.wfo.lowercase(Locale.US) + "/wxstory/Tab2FileL.png").getImage()
}

"WFOWARNINGS" -> {
Expand Down Expand Up @@ -296,7 +294,6 @@ object DownloadImage {

"SND" -> {
needsBitmap = false
// bitmap = UtilitySpcSoundings.getImage(context, UtilityLocation.getNearestSoundingSite(Location.latLon))
bitmap = UtilitySpcSoundings.getImage(
context,
SoundingSites.sites.getNearest(Location.latLon)
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/java/joshuatee/wx/util/DownloadText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ object DownloadText {

prod.startsWith("VFD") -> {
val t2 = prod.substring(3)
// text = (GlobalVariables.NWS_AWC_WEBSITE_PREFIX + "/fcstdisc/data?cwa=K$t2").getHtmlWithNewLine()
// text = text.parseAcrossLines("<!-- raw data starts -->(.*?)<!-- raw data ends -->")
text =
(GlobalVariables.NWS_AWC_WEBSITE_PREFIX + "/api/data/fcstdisc?cwa=K$t2" + "&type=afd").getHtmlWithNewLine()
text = text.removeLineBreaks().removeHtml()
Expand Down Expand Up @@ -266,8 +264,6 @@ object DownloadText {
prod.startsWith("RWR") -> {
val product = prod.substring(0, 3)
val location = prod.substring(3).replace("%", "")
// val locationName = UtilityLocation.getWfoSiteName(location)
// val state = locationName.split(",")[0]
val state = WfoSites.getState(location)
val url =
"https://forecast.weather.gov/product.php?site=$location&issuedby=$state&product=$product"
Expand Down
16 changes: 7 additions & 9 deletions app/src/main/java/joshuatee/wx/util/Hazards.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package joshuatee.wx.util
import joshuatee.wx.parseColumn
import joshuatee.wx.settings.UIPreferences
import joshuatee.wx.common.GlobalVariables
import joshuatee.wx.getNwsHtml
import joshuatee.wx.objects.LatLon
import joshuatee.wx.settings.Location

Expand All @@ -40,28 +41,25 @@ class Hazards {
// US
constructor(locationNumber: Int) {
if (Location.isUS(locationNumber) && UIPreferences.homescreenFav.contains("TXT-HAZ")) {
hazards = getHazardsHtml(Location.getLatLon(locationNumber))
hazards = getHtml(Location.getLatLon(locationNumber))
urls = hazards.parseColumn("\"id\": \"(" + GlobalVariables.NWS_API_URL + ".*?)\"")
titles = hazards.parseColumn("\"event\": \"(.*?)\"")
}
}

// adhoc forecast
constructor(latLon: LatLon) {
hazards = getHazardsHtml(latLon)
hazards = getHtml(latLon)
urls = hazards.parseColumn("\"id\": \"(" + GlobalVariables.NWS_API_URL + ".*?)\"")
titles = hazards.parseColumn("\"event\": \"(.*?)\"")
}

fun getHazardsShort(): String = hazardsShort.replace("^<BR>".toRegex(), "")

companion object {
fun getHazardsHtml(latLon: LatLon): String {
val url =
"https://api.weather.gov/alerts?point=" + UtilityMath.latLonFix(latLon.latString) + "," + UtilityMath.latLonFix(
latLon.lonString
) + "&active=1"
return UtilityDownloadNws.getHazardData(url)
}
fun getHtml(latLon: LatLon): String =
("https://api.weather.gov/alerts?point=" + UtilityMath.latLonFix(latLon.latString) + "," + UtilityMath.latLonFix(
latLon.lonString
) + "&active=1").getNwsHtml()
}
}
8 changes: 0 additions & 8 deletions app/src/main/java/joshuatee/wx/util/Utility.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ object Utility {
var diagnostics = ""
diagnostics += MyApplication.dm.widthPixels.toString() + " Screen width" + GlobalVariables.newline
diagnostics += MyApplication.dm.heightPixels.toString() + " Screen height" + GlobalVariables.newline
// diagnostics += UtilityUI.statusBarHeight(activity).toString() + " Status bar height" + GlobalVariables.newline
var landScape = false
if (activity.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
landScape = true
Expand All @@ -57,13 +56,6 @@ object Utility {
return diagnostics
}

// fun getVersion(context: Context): String = try {
// context.packageManager.getPackageInfo(context.packageName, 0).versionName
// } catch (e: Exception) {
// UtilityLog.handleException(e)
// ""
// }

fun getVersion(context: Context): String =
context.packageManager.getPackageInfo(context.packageName, 0).versionName ?: ""

Expand Down
Loading

0 comments on commit 900f4b2

Please sign in to comment.