Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ELY3M committed Feb 10, 2020
1 parent 85e8e6f commit 8df7abd
Show file tree
Hide file tree
Showing 117 changed files with 1,283 additions and 1,106 deletions.
32 changes: 29 additions & 3 deletions DOC/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// TODO [ADD] Level 2 BV colormap and wrapping (Alex)
// TODO [ADD] Level 2 BV colormap and wrapping (Alex)a
// TODO [FIX] base velocity legend
// TODO [ADD] line size - swo, wb, wb gusts, sti
// TODO [REF] OkHttp 3.13 Requires Android 5+ – Square Corner Blog – Medium https://medium.com/square-corner-blog/okhttp-3-13-requires-android-5-818bb78d07ce
Expand All @@ -11,9 +11,35 @@
// TODO [ADD] textual obs in fixed radars on homescreen
// TODO [ADD] use ENUM instead of RID_FAV WFO_FAV SND_FAV (util/UtilityFavorites)
// TODO [FIX] dual/quad pane radar don't take up the entire screen on chomeOS
// TODO [REF] migrate off WebscreenABModels?
// TODO [REF] move off MyApplication.colon.split MyApplication.colon.space
// TODO miscPref.split(":").dropLastWhile { it.isEmpty() }
// TODO [ADD] use Smaller images on larger screens
// TODO [REF] use LatLon in Spotter, SpotterReports and other places that have lat and lon

55349 2020_02_02 [REF] utilFav/SettingsHomeScreen refactoring
55360 2020_02_09
55359 2020_02_09 [REF] lint
[ADD] CPC 3 month temp/precip outlook in WPC Images
[ADD] NHC change format to severe dashboard including tap on image to open in dedicated fashion
[ADD] re-architect Severe Dashboard image handling, if Landscape show 3 images per row
55358 2020_02_08 [ADD] substantial revamp of utilDownload, WFO text, national text with regards to data download and presentation
55357 2020_02_08 [REF] lint (utilDownload)
[ADD] substantial revamp of utilDownload, WFO text, national text with regards to data download and presentation
55356 2020_02_08 [REF] migrate off WebscreenABModels
[FIX] use alternative sources for text products: WFO: AFD, SPC Convective Outlooks, Short Range disc
55355 2020_02_06 [FIX] hourly now has quotes around temp
[ADD] keyboard shortcut for location selector on main screen
55354 2020_02_06 [ADD] have WebView respect TextSize setting
55353 2020_02_05 [REF] misc refactor
[ADD] SpcMcdWatchShowActivity - if tablet in landscape change orientation of linearLayout
55352 2020_02_04 [FIX] settings -> radar -> text size, default value was changing
[ADD] settings -> UI -> text size - size of text in card changes as you move along slider
[FIX] don't show - show warnings - in radar long press unless warnings are enabled
[FIX] LocationFragment - don't pass context when querying radar time
55351 2020_02_04 [FIX] WPCImage widget had to have launch updated to use flags (would crash otherwise)
55350 2020_02_04 [FIX] update google doc links to point to published versions in settings -> about
[FIX] in SettingsLocationRecyclerViewActivity remove broadcastReceiver that is not needed
[REF] bottom sheet refactor to move more stuff into constructor
55349 2020_02_03 [REF] utilFav/SettingsHomeScreen refactoring
[REF] lint cleanup
55348 2020_02_02 [REF] utilFav/SettingsHomeScreen refactoring
55347 2020_02_01 [ADD] move to normal twitter w/o tokens
Expand Down
8 changes: 2 additions & 6 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"
package="joshuatee.wx"
android:versionCode="55349"
android:versionName="55349"
android:versionCode="55360"
android:versionName="55360"
>

<uses-permission android:name="android.permission.INTERNET" />
Expand Down Expand Up @@ -583,10 +583,6 @@
android:label="Manage Home Screen"
android:parentActivityName="WX" >
</activity>
<activity
android:name=".activitiesmisc.WebscreenABModels"
android:parentActivityName="WX" >
</activity>
<activity
android:name=".audio.VoiceCommandActivity"
android:theme="@style/Theme.Transparent" >
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/joshuatee/wx/CommonActionBarFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ open class CommonActionBarFragment : AppCompatActivity(), OnMenuItemClickListene
//not removing this - ELY M.
R.id.action_forecast_webpage -> ObjectIntent(
this,
WebscreenABModels::class.java,
WebscreenABModels.URL,
WebView::class.java,
WebView.URL,
arrayOf(
"http://forecast.weather.gov/MapClick.php?lon=" + Location.latLon.lonString + "&lat=" + Location.latLon.latString,
"Local forecast"
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/joshuatee/wx/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ fun String.removeBreaks(): String {
return this.replace(" <br>", " ")
}

fun String.removeHtml(): String {
return this.replace(Regex("\\<[^>]*>"),"")
}

fun String.removeLineBreaks(): String {
return this
.replace("\n", "ABC123")
Expand Down Expand Up @@ -97,6 +101,14 @@ fun String.getHtml(): String {
}
}

fun String.getHtmlWithNewLine(): String {
return if (Build.VERSION.SDK_INT > 20) {
UtilityDownload.getStringFromUrlWithNewLine(this)
} else {
UtilityDownload.getStringFromUrlUnsafe(this)
}
}

//fun String.getHtmlUnsafe(): String {
// return UtilityDownload.getStringFromUrlUnsafe(this)
//}
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/joshuatee/wx/MyApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class MyApplication : Application() {
const val nwsApiUrl = "https://api.weather.gov"
const val nwsSwpcWebSitePrefix = "https://services.swpc.noaa.gov"
const val canadaEcSitePrefix = "https://weather.gc.ca"
const val tgftpSitePrefix = "https://tgftp.nws.noaa.gov"
const val nwsWeatherGov: String = "https://w1.weather.gov"
const val prefSeparator: String = " : : :"
const val sep = "ABC123"
Expand Down Expand Up @@ -766,6 +767,7 @@ class MyApplication : Application() {
var radarSpotterSize: Int = 0
var radarAviationSize: Int = 0
var radarTextSize: Float = 0f
var radarTextSizeDefault: Float = 1.0f
var radarUserPointSize: Int = 0
var radarLocdotSize: Int = 0
var radarLocIconSize: Int = 0
Expand Down Expand Up @@ -845,7 +847,7 @@ class MyApplication : Application() {
radarObsExtZoom = getInitialPreference("RADAR_OBS_EXT_ZOOM", 7)
radarSpotterSize = getInitialPreference("RADAR_SPOTTER_SIZE", radarSpotterSizeDefault)
radarAviationSize = getInitialPreference("RADAR_AVIATION_SIZE", radarAviationSizeDefault)
radarTextSize = getInitialPreference("RADAR_TEXT_SIZE", 1.0f)
radarTextSize = getInitialPreference("RADAR_TEXT_SIZE", radarTextSizeDefault)
radarUserPointSize = getInitialPreference("RADAR_USERPOINT_SIZE", 100)
radarLocdotSize = getInitialPreference("RADAR_LOCDOT_SIZE", radarLocationDotSizeDefault)
radarLocIconSize = getInitialPreference("RADAR_LOCICON_SIZE", 100)
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/joshuatee/wx/UIPreferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ object UIPreferences {
var useAwcRadarMosaic: Boolean = false
var nwsIconSizeDefault = 20
var normalTextSizeDefault = 16
var normalTextSize: Int = 16

fun initPreferences(context: Context) {
if (UtilityUI.isTablet()) {
normalTextSizeDefault = 18
}
val normalTextSize = Utility.readPref(context, "TEXTVIEW_FONT_SIZE", normalTextSizeDefault) // 14 16 21
normalTextSize = Utility.readPref(context, "TEXTVIEW_FONT_SIZE", normalTextSizeDefault) // 14 16 21
MyApplication.textSizeSmall = UtilityUI.spToPx(normalTextSize - 2, context)
MyApplication.textSizeNormal = UtilityUI.spToPx(normalTextSize, context)
MyApplication.textSizeLarge = UtilityUI.spToPx(normalTextSize + 5, context)
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/joshuatee/wx/WX.kt
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ class WX : CommonActionBarFragment() {
}
KeyEvent.KEYCODE_L -> {
if (event.isCtrlPressed) {
openActivity(this, "LTG")
//openActivity(this, "LTG")
val currentFragment = supportFragmentManager.fragments.first() as LocationFragment
currentFragment.showLocations()
}
return true
}
Expand Down
13 changes: 6 additions & 7 deletions app/src/main/java/joshuatee/wx/activitiesmisc/AFDActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class AfdActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItemClick
private lateinit var spinner: ObjectSpinner
private lateinit var drw: ObjectNavDrawer
private var originalWfo = ""
private val fixedWidthProducts = listOf("RTP", "RWR", "CLI")
private val fixedWidthProducts = listOf("RTP", "RWR", "CLI", "RVA")

@SuppressLint("MissingSuperCall")
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -172,8 +172,6 @@ class AfdActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItemClick
if (wfo != oldWfo) {
version = 1
}


html = withContext(Dispatchers.IO) {
if (product != "CLI") {
if (version == 1) {
Expand Down Expand Up @@ -203,7 +201,8 @@ class AfdActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItemClick
if (fixedWidthProducts.contains(product)) {
textCard.setTextAndTranslate(html)
} else {
textCard.setTextAndTranslate(Utility.fromHtml(html))
//textCard.setTextAndTranslate(Utility.fromHtml(html))
textCard.setTextAndTranslate(html)
}
if (fixedWidthProducts.contains(product)) {
textCard.tv.typeface = Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL)
Expand Down Expand Up @@ -248,9 +247,9 @@ class AfdActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItemClick
R.id.action_pin -> UtilityShortcut.create(this, ShortcutType.AFD)
R.id.action_website -> ObjectIntent(
this,
WebscreenABModels::class.java,
WebscreenABModels.URL,
arrayOf("https://www.weather.gov/" + wfo.toLowerCase(Locale.US), wfo)
WebView::class.java,
WebView.URL,
arrayOf("https://www.weather.gov/" + wfo.toLowerCase(Locale.US), wfo, "extended")
)
R.id.action_hazards -> ObjectIntent(
this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ internal class AdapterSpotter(private val dataSet: MutableList<Spotter>) :
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DataObjectHolder {
val view =
LayoutInflater.from(parent.context).inflate(R.layout.cardview_spotter, parent, false)
val view = LayoutInflater.from(parent.context).inflate(R.layout.cardview_spotter, parent, false)
return DataObjectHolder(view)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ internal class AdapterUSWarningsImpact(private val dataSet: List<ObjectImpactGra
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DataObjectHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.cardview_uswarningsimpact, parent, false)
val view = LayoutInflater.from(parent.context).inflate(R.layout.cardview_uswarningsimpact, parent, false)
return DataObjectHolder(view)
}

Expand Down
151 changes: 65 additions & 86 deletions app/src/main/java/joshuatee/wx/activitiesmisc/CAPAlert.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,115 +45,94 @@ class CapAlert {
var effective: String = ""
var expires: String = ""

/*constructor(
url: String,
title: String,
event: String,
area: String,
zones: String,
vtec: String
) {
this.url = url
this.title = title
this.event = event
this.area = area
this.zones = zones
this.vtec = vtec
}*/

companion object {

// used by usAlerts
fun initializeFromCap(eventText: String): CapAlert {
val obj = CapAlert()
obj.url = eventText.parse("<id>(.*?)</id>")
obj.title = eventText.parse("<title>(.*?)</title>")
obj.summary = eventText.parse("<summary>(.*?)</summary>")
obj.instructions = eventText.parse("</description>.*?<instruction>(.*?)</instruction>.*?<areaDesc>")
obj.area = eventText.parse("<cap:areaDesc>(.*?)</cap:areaDesc>")
obj.area = obj.area.replace("&apos;", "'")
obj.effective = eventText.parse("<cap:effective>(.*?)</cap:effective>")
obj.expires = eventText.parse("<cap:expires>(.*?)</cap:expires>")
obj.event = eventText.parse("<cap:event>(.*?)</cap:event>")
obj.vtec = eventText.parse("<valueName>VTEC</valueName>.*?<value>(.*?)</value>")
obj.zones = eventText.parse("<valueName>UGC</valueName>.*?<value>(.*?)</value>")
obj.text = "<h4><b>"
obj.text += obj.title
obj.text += "</b></h4>"
obj.text += "<b>Counties: "
obj.text += obj.area
obj.text += "</b><br><br>"
obj.text += obj.summary
obj.text += "<br><br><br>"
obj.text += obj.instructions
obj.text += "<br><br><br>"
obj.summary = obj.summary.replace("<br>\\*", "<br><br>*")
val capAlert = CapAlert()
capAlert.url = eventText.parse("<id>(.*?)</id>")
capAlert.title = eventText.parse("<title>(.*?)</title>")
capAlert.summary = eventText.parse("<summary>(.*?)</summary>")
capAlert.instructions = eventText.parse("</description>.*?<instruction>(.*?)</instruction>.*?<areaDesc>")
capAlert.area = eventText.parse("<cap:areaDesc>(.*?)</cap:areaDesc>")
capAlert.area = capAlert.area.replace("&apos;", "'")
capAlert.effective = eventText.parse("<cap:effective>(.*?)</cap:effective>")
capAlert.expires = eventText.parse("<cap:expires>(.*?)</cap:expires>")
capAlert.event = eventText.parse("<cap:event>(.*?)</cap:event>")
capAlert.vtec = eventText.parse("<valueName>VTEC</valueName>.*?<value>(.*?)</value>")
capAlert.zones = eventText.parse("<valueName>UGC</valueName>.*?<value>(.*?)</value>")
capAlert.text = "<h4><b>"
capAlert.text += capAlert.title
capAlert.text += "</b></h4>"
capAlert.text += "<b>Counties: "
capAlert.text += capAlert.area
capAlert.text += "</b><br><br>"
capAlert.text += capAlert.summary
capAlert.text += "<br><br><br>"
capAlert.text += capAlert.instructions
capAlert.text += "<br><br><br>"
capAlert.summary = capAlert.summary.replace("<br>\\*", "<br><br>*")
if (UIPreferences.nwsTextRemovelinebreaks) {
obj.instructions = obj.instructions.replace("<br><br>", "<BR><BR>").replace("<br>", " ")
capAlert.instructions = capAlert.instructions.replace("<br><br>", "<BR><BR>").replace("<br>", " ")
}
return obj
return capAlert
}

fun createFromUrl(url: String): CapAlert {
val expireStr = "This alert has expired"
val obj = CapAlert()
obj.url = url
val capAlert = CapAlert()
capAlert.url = url
val html = if (url.contains("NWS-IDP-PROD")) {
UtilityDownloadNws.getStringFromUrlSep(url)
} else {
url.getHtmlSep()
}
if (!html.contains("NWS-IDP-PROD")) {
if (html.contains(expireStr)) {
obj.text = expireStr
capAlert.text = expireStr
} else {
obj.title = html.parse("<headline>(.+?)</headline>.*?<description>")
obj.summary =
html.parse("</headline>.*?<description>(.*?)</description>.*?<instruction>")
obj.instructions =
html.parse("</description>.*?<instruction>(.*?)</instruction>.*?<areaDesc>")
obj.area = html.parse("</instruction>.*?<areaDesc>(.*?)</areaDesc>.*?")
obj.area = obj.area.replace("&apos;", "'")
obj.text = "<h4><b>"
obj.text += obj.title
obj.text += "</b></h4>"
obj.text += "<b>Counties: "
obj.text += obj.area
obj.text += "</b><br><br>"
obj.text += obj.summary
obj.text += "<br><br><br>"
obj.text += obj.instructions
obj.text += "<br><br><br>"
capAlert.title = html.parse("<headline>(.+?)</headline>.*?<description>")
capAlert.summary = html.parse("</headline>.*?<description>(.*?)</description>.*?<instruction>")
capAlert.instructions = html.parse("</description>.*?<instruction>(.*?)</instruction>.*?<areaDesc>")
capAlert.area = html.parse("</instruction>.*?<areaDesc>(.*?)</areaDesc>.*?")
capAlert.area = capAlert.area.replace("&apos;", "'")
capAlert.text = "<h4><b>"
capAlert.text += capAlert.title
capAlert.text += "</b></h4>"
capAlert.text += "<b>Counties: "
capAlert.text += capAlert.area
capAlert.text += "</b><br><br>"
capAlert.text += capAlert.summary
capAlert.text += "<br><br><br>"
capAlert.text += capAlert.instructions
capAlert.text += "<br><br><br>"
}
} else {
obj.title = html.parse("\"headline\": \"(.*?)\"")
obj.summary = html.parse("\"description\": \"(.*?)\"")
obj.instructions = html.parse("\"instruction\": \"(.*?)\"")
obj.area = html.parse("\"areaDesc\": \"(.*?)\"")
//obj.summary = obj.summary.replace("\\n", "\n")
obj.summary = obj.summary.replace("\\n\\n", "ABC123")
obj.summary = obj.summary.replace("\\n", " ")
obj.summary = obj.summary.replace("ABC123", "\n\n")
//obj.instructions = obj.instructions.replace("\\n", "\n")
obj.instructions = obj.instructions.replace("\\n", " ")
obj.text = "<h4><b>"
obj.text += obj.title
obj.text += "</b></h4>"
obj.text += "<b>Counties: "
obj.text += obj.area
obj.text += "</b><br><br>"
obj.text += obj.summary
obj.text += "<br><br><br>"
obj.text += obj.instructions
obj.text += "<br><br><br>"
capAlert.title = html.parse("\"headline\": \"(.*?)\"")
capAlert.summary = html.parse("\"description\": \"(.*?)\"")
capAlert.instructions = html.parse("\"instruction\": \"(.*?)\"")
capAlert.area = html.parse("\"areaDesc\": \"(.*?)\"")
capAlert.summary = capAlert.summary.replace("\\n\\n", "ABC123")
capAlert.summary = capAlert.summary.replace("\\n", " ")
capAlert.summary = capAlert.summary.replace("ABC123", "\n\n")
capAlert.instructions = capAlert.instructions.replace("\\n", " ")
capAlert.text = "<h4><b>"
capAlert.text += capAlert.title
capAlert.text += "</b></h4>"
capAlert.text += "<b>Counties: "
capAlert.text += capAlert.area
capAlert.text += "</b><br><br>"
capAlert.text += capAlert.summary
capAlert.text += "<br><br><br>"
capAlert.text += capAlert.instructions
capAlert.text += "<br><br><br>"
}
obj.summary = obj.summary.replace("<br>\\*".toRegex(), "<br><br>*")
capAlert.summary = capAlert.summary.replace("<br>\\*".toRegex(), "<br><br>*")
if (UIPreferences.nwsTextRemovelinebreaks) {
obj.instructions = obj.instructions.replace("<br><br>", "<BR><BR>")
obj.instructions = obj.instructions.replace("<br>", " ")
capAlert.instructions = capAlert.instructions.replace("<br><br>", "<BR><BR>")
capAlert.instructions = capAlert.instructions.replace("<br>", " ")
}

return obj
return capAlert
}
}
}
Expand Down
Loading

0 comments on commit 8df7abd

Please sign in to comment.