diff --git a/DOC/ChangeLog.txt b/DOC/ChangeLog.txt index 7badbbfb..ea340c42 100644 --- a/DOC/ChangeLog.txt +++ b/DOC/ChangeLog.txt @@ -14,11 +14,13 @@ // TODO fix issue for precip radar products when there is no data // TODO assess impact of scoped storage: https://developer.android.com/preview/privacy/scoped-storage // TODO linesize - swo, wb, wbgusts, sti -// TODO dual pange split when rotated not optimal (Jim) -// TODO bottomsheet for spotters +// TODO SRM - ability to add custom palette // TODO make location update interval configurable // TODO add vtec end date check to tor notif // TODO camelCase filenames in particular when acronyms longer then 2 chars exist +// TODO add user accessible debug log from try-catch data +// TODO remove unused prefs +// TODO don't display full precision in lat/lon in settings location edit [ADD] - adding something new - method, file, etc. to the repo [REM] - remove items @@ -28,8 +30,29 @@ [REF] - refactor a method, group, variable, etc. [MER] - merge +55190 2019_05_18 [IMP] add more whitespace around hazards on main screen + [IMP] don't squash whitespace in US alerts detail + [REF] camelCase and better naming + [IMP] change default warning line size from 4 to 5 (does not impact existing users). Remove default values from some help strings as + they are shown elsewhere +55189 2019_05_18 [REF] more work on 7day object + [REF] more work on cc object +55188 2019_05_18 [REF] more work on hazards object +55187 2019_05_18 [IMP] Left justify hourly text + [REF] camelCase and better naming +55186 2019_05_18 [IMP] add quad pane link in dual pane (Jim) + [IMP] in dual pane invoked from single pane save product changes (Jim) + [REF] change how ObjectForecastPackageHazards is used +55185 2019_05_17 [REF] camelCase and better naming +55184 2019_05_17 [REF] camelCase and better naming +55183 2019_05_16 [IMP] address or remove various minor FIXM/TOD + [REM] legacy GOES transformations code +55182 2019_05_16 [IMP] in location edit, if user taps GPS button save location automatically + [IMP] in severe dashboard show stats in subtitle like flutter port +55181 2019_05_15 [REM] remove county zoom change + [IMP] address or remove various minor FIXM/TOD 55180 2019_05_15 [IMP] in radar don't hide counties until zoomed out further (Craig) - [IMP] address or remove various minor FIXME/TODO + [IMP] address or remove various minor FIXM/TOD [REF] various camelCase 55179 2019_05_14 [ADD] make radarLocationUpdateInterval (GPS) configurable [BUG] SPC HREF from long press app icon was not working (crash) diff --git a/README.md b/README.md index 8e6866fd..0ef0ff78 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ https://github.com/ELY3M/wX---modded-by-ELY-M/releases # ## DONE! ==================================== +updated the code with Joshua many changes and added in zoom setting for conus radar to zoom out to (5-20-19) (Tornado day in OK!) +all watch crash bugs should be gone, hopefully! updated the code with Joshuas changes with the warnings mod/settings (4-20-19). updated the code with Joshuas changes (4-13-19). Now, you can change the radar legend text color in the color settings - it was requested by Mike T. diff --git a/TODOs.md b/TODOs.md index 7b797638..7c7c10d7 100644 --- a/TODOs.md +++ b/TODOs.md @@ -24,6 +24,8 @@ # ## DONE! ==================================== +updated the code with Joshua many changes and added in zoom setting for conus radar to zoom out to (5-20-19) (Tornado day in OK!) +all watch crash bugs should be gone, hopefully! updated the code with Joshuas changes with the warnings mod/settings (4-20-19). updated the code with Joshuas changes (4-13-19). Now, you can change the radar legend text color in the color settings - it was requested by Mike T. diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b2e515dd..99408645 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -22,8 +22,8 @@ diff --git a/app/src/main/java/joshuatee/wx/Extensions.kt b/app/src/main/java/joshuatee/wx/Extensions.kt index c18c8e5c..a8302c3f 100644 --- a/app/src/main/java/joshuatee/wx/Extensions.kt +++ b/app/src/main/java/joshuatee/wx/Extensions.kt @@ -30,8 +30,8 @@ import joshuatee.wx.util.UtilityDownload import joshuatee.wx.util.UtilityDownloadNws import joshuatee.wx.external.UtilityStringExternal -fun String.parse(matchStr: String): String { - return UtilityString.parseS(this, matchStr) +fun String.parse(match: String): String { + return UtilityString.parse(this, match) } fun String.condenseSpace(): String { @@ -42,16 +42,16 @@ fun String.truncate(size: Int): String { return UtilityStringExternal.truncate(this, size) } -fun String.parse(p: Pattern): String { - return UtilityString.parseS(this, p) +fun String.parse(pattern: Pattern): String { + return UtilityString.parse(this, pattern) } -fun String.parseColumn(matchStr: String): List { - return UtilityString.parseColumnS(this, matchStr) +fun String.parseColumn(match: String): List { + return UtilityString.parseColumn(this, match) } -fun String.parseColumn(p: Pattern): List { - return UtilityString.parseColumnS(this, p) +fun String.parseColumn(pattern: Pattern): List { + return UtilityString.parseColumn(this, pattern) } fun String.getImage(): Bitmap { @@ -75,23 +75,23 @@ fun String.getHtmlUnsafe(): String { } fun String.getNwsHtml(): String { - return UtilityDownloadNws.getNwsStringFromUrl(this) + return UtilityDownloadNws.getStringFromUrl(this) } fun String.getHtmlSep(): String { return UtilityDownload.getStringFromUrlWithSeparator(this) } -fun String.parseColumnAll(p: Pattern): List { - return UtilityString.parseColumnAllS(this, p) +fun String.parseColumnAll(pattern: Pattern): List { + return UtilityString.parseColumnAll(this, pattern) } -fun String.parseLastMatch(p: Pattern): String { - return UtilityString.parseLastMatchS(this, p) +fun String.parseLastMatch(pattern: Pattern): String { + return UtilityString.parseLastMatch(this, pattern) } -fun String.parseLastMatch(matchStr: String): String { - return UtilityString.parseLastMatchS(this, matchStr) +fun String.parseLastMatch(match: String): String { + return UtilityString.parseLastMatch(this, match) } diff --git a/app/src/main/java/joshuatee/wx/MyApplication.kt b/app/src/main/java/joshuatee/wx/MyApplication.kt index d04f5fe6..ff06155b 100644 --- a/app/src/main/java/joshuatee/wx/MyApplication.kt +++ b/app/src/main/java/joshuatee/wx/MyApplication.kt @@ -131,7 +131,7 @@ class MyApplication : Application() { .readTimeout(15, TimeUnit.SECONDS) .addInterceptor(okhttp3Interceptor) .build() - UtilityTTS.initTTS(applicationContext) + UtilityTTS.initTts(applicationContext) UtilityCities.initCitiesArray() if (!loadedBuffers) { initBuffers(this) @@ -730,7 +730,7 @@ class MyApplication : Application() { dis.close() inputStream.close() } catch (e: IOException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } } @@ -744,8 +744,9 @@ class MyApplication : Application() { const val NWS_CONUS_RADAR: String = "https://radar.weather.gov/ridge/Conus/RadarImg/latest_radaronly.gif"; const val NWS_CONUS_RADAR_GFW: String = "https://radar.weather.gov/ridge/Conus/RadarImg/latest_radaronly.gfw" var radarConusRadar: Boolean = false + var radarConusRadarZoom: Int = 173 var radarWarnings: Boolean = false - var radarTorWarnings: Boolean = true + var radarTorWarnings: Boolean = true var radarSvrWarnings: Boolean = true var radarEwwWarnings: Boolean = true var radarFfwWarnings: Boolean = true @@ -810,6 +811,7 @@ class MyApplication : Application() { private fun initRadarPreferences() { radarLocationUpdateInterval = getInitialPreference("RADAR_LOCATION_UPDATE_INTERVAL", 10) radarConusRadar = getInitialPreference("CONUS_RADAR", "false") + radarConusRadarZoom = getInitialPreference("CONUS_RADAR_ZOOM", 173) radarWarnings = getInitialPreference("COD_WARNINGS_DEFAULT", "false") radarTorWarnings = getInitialPreference("TOR_WARNINGS", "false") radarSvrWarnings = getInitialPreference("SVR_WARNINGS", "false") diff --git a/app/src/main/java/joshuatee/wx/UIPreferences.kt b/app/src/main/java/joshuatee/wx/UIPreferences.kt index 47f4166f..b4a62f22 100644 --- a/app/src/main/java/joshuatee/wx/UIPreferences.kt +++ b/app/src/main/java/joshuatee/wx/UIPreferences.kt @@ -61,7 +61,6 @@ object UIPreferences { var useAwcRadarMosaic: Boolean = false fun initPreferences(context: Context) { - val normalTextSize = Utility.readPref(context, "TEXTVIEW_FONT_SIZE", 16) // 14 16 21 MyApplication.textSizeSmall = UtilityUI.spToPx(normalTextSize - 2, context) MyApplication.textSizeNormal = UtilityUI.spToPx(normalTextSize, context) diff --git a/app/src/main/java/joshuatee/wx/UtilityWidget.kt b/app/src/main/java/joshuatee/wx/UtilityWidget.kt index 6d3cb25c..6462ea1a 100644 --- a/app/src/main/java/joshuatee/wx/UtilityWidget.kt +++ b/app/src/main/java/joshuatee/wx/UtilityWidget.kt @@ -59,7 +59,7 @@ object UtilityWidget { .activityInfo.packageName context.grantUriPermission(str, imgUri, Intent.FLAG_GRANT_READ_URI_PERMISSION) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return imgUri } @@ -143,20 +143,20 @@ object UtilityWidget { val hazardRaw = objHazards.hazards Utility.writePref(context, "HAZARD_WIDGET", objHazards.getHazardsShort()) Utility.writePref(context, "7DAY_WIDGET", objSevenDay.sevenDayShort) - if (objCc.data1 != "") { - Utility.writePref(context, "CC_WIDGET", objCc.data1) + if (objCc.data != "") { + Utility.writePref(context, "CC_WIDGET", objCc.data) } if (objCc.iconUrl != "") { Utility.writePref(context, "CC_WIDGET_ICON_URL", objCc.iconUrl) } Utility.writePref(context, "UPDTIME_WIDGET", objCc.status) - if (objSevenDay.sevenDayExtStr != "") { - Utility.writePref(context, "7DAY_EXT_WIDGET", objSevenDay.sevenDayExtStr) + if (objSevenDay.sevenDayLong != "") { + Utility.writePref(context, "7DAY_EXT_WIDGET", objSevenDay.sevenDayLong) } Utility.writePref(context, "HAZARD_URL_WIDGET", objHazards.hazards) Utility.writePref(context, "HAZARD_RAW_WIDGET", hazardRaw) - if (objSevenDay.iconstr != "") { - Utility.writePref(context, "7DAY_ICONS_WIDGET", objSevenDay.iconstr) + if (objSevenDay.iconsAsString != "") { + Utility.writePref(context, "7DAY_ICONS_WIDGET", objSevenDay.iconsAsString) } Utility.commitPref(context) update(context, CCLegacy) @@ -181,7 +181,6 @@ object UtilityWidget { } } - // FIXME create helper objects fun setupIntent( context: Context, remoteViews: RemoteViews, @@ -192,14 +191,13 @@ object UtilityWidget { actionString: String ) { val requestID = System.currentTimeMillis().toInt() - val intentAfd = Intent(context, activity) - intentAfd.putExtra(activityFlag, activityStringArr) - intentAfd.action = actionString + val intent = Intent(context, activity) + intent.putExtra(activityFlag, activityStringArr) + intent.action = actionString val stackBuilder = TaskStackBuilder.create(context) stackBuilder.addParentStack(activity) - stackBuilder.addNextIntent(intentAfd) - val pendingIntent = - stackBuilder.getPendingIntent(requestID, PendingIntent.FLAG_UPDATE_CURRENT) + stackBuilder.addNextIntent(intent) + val pendingIntent = stackBuilder.getPendingIntent(requestID, PendingIntent.FLAG_UPDATE_CURRENT) remoteViews.setOnClickPendingIntent(layoutItem, pendingIntent) } @@ -213,14 +211,13 @@ object UtilityWidget { actionString: String ) { val requestID = System.currentTimeMillis().toInt() - val intentAfd = Intent(context, activity) - intentAfd.putExtra(activityFlag, activityString) - intentAfd.action = actionString + val intent = Intent(context, activity) + intent.putExtra(activityFlag, activityString) + intent.action = actionString val stackBuilder = TaskStackBuilder.create(context) stackBuilder.addParentStack(activity) - stackBuilder.addNextIntent(intentAfd) - val pendingIntent = - stackBuilder.getPendingIntent(requestID, PendingIntent.FLAG_UPDATE_CURRENT) + stackBuilder.addNextIntent(intent) + val pendingIntent = stackBuilder.getPendingIntent(requestID, PendingIntent.FLAG_UPDATE_CURRENT) remoteViews.setOnClickPendingIntent(layoutItem, pendingIntent) } @@ -232,13 +229,12 @@ object UtilityWidget { actionString: String ) { val requestID = System.currentTimeMillis().toInt() - val intentAfd = Intent(context, activity) - intentAfd.action = actionString + val intent = Intent(context, activity) + intent.action = actionString val stackBuilder = TaskStackBuilder.create(context) stackBuilder.addParentStack(activity) - stackBuilder.addNextIntent(intentAfd) - val pendingIntent = - stackBuilder.getPendingIntent(requestID, PendingIntent.FLAG_UPDATE_CURRENT) + stackBuilder.addNextIntent(intent) + val pendingIntent = stackBuilder.getPendingIntent(requestID, PendingIntent.FLAG_UPDATE_CURRENT) remoteViews.setOnClickPendingIntent(layoutItem, pendingIntent) } diff --git a/app/src/main/java/joshuatee/wx/UtilityWidgetDownload.kt b/app/src/main/java/joshuatee/wx/UtilityWidgetDownload.kt index 02caa1fd..cc24bcb2 100644 --- a/app/src/main/java/joshuatee/wx/UtilityWidgetDownload.kt +++ b/app/src/main/java/joshuatee/wx/UtilityWidgetDownload.kt @@ -30,6 +30,7 @@ import android.graphics.Bitmap import joshuatee.wx.Extensions.getImage import joshuatee.wx.canada.UtilityCanadaImg +import joshuatee.wx.nhc.UtilityNHC import joshuatee.wx.objects.WidgetFile import joshuatee.wx.objects.WidgetFile.* import joshuatee.wx.settings.Location @@ -44,14 +45,14 @@ internal object UtilityWidgetDownload { SPCMESO -> downloadGeneric(context, SPCMESO, "SPCMESO1") STRPT -> downloadGeneric(context, STRPT, "STRPT") CONUSWV -> downloadGeneric(context, CONUSWV, "CONUSWV") - SPCSWO -> downloadSPCSWO(context) - WPCIMG -> downloadWPCIMG(context, widgetType) - NHC -> downloadNHC(context, widgetType) + SPCSWO -> downloadSpcSwo(context) + WPCIMG -> downloadWpcImage(context, widgetType) + NHC -> downloadNhc(context, widgetType) VIS -> downloadVis(context) - HWO -> downloadHWO(context) - TEXT_WPC -> downloadTextWPC(context) - AFD -> downloadAFD(context) - MOSAIC_RADAR -> downloadRadMosaic(context) + HWO -> downloadHwo(context) + TEXT_WPC -> downloadTextWpc(context) + AFD -> downloadAfd(context) + MOSAIC_RADAR -> downloadRadarMosaic(context) else -> { } } @@ -68,7 +69,7 @@ internal object UtilityWidgetDownload { } saveImage(context, bitmap, NEXRAD_RADAR.fileName) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } @@ -77,7 +78,7 @@ internal object UtilityWidgetDownload { saveImage(context, bitmap, type.fileName) } - private fun downloadSPCSWO(context: Context) { + private fun downloadSpcSwo(context: Context) { listOf("1", "2", "3", "4").forEach { val bitmap = UtilityDownload.getImageProduct(context, "SWOD$it") saveImage(context, bitmap, SPCSWO.fileName + it) @@ -89,7 +90,7 @@ internal object UtilityWidgetDownload { val bitmap = UtilityDownload.getImageProduct(context, "GOES16") saveImage(context, bitmap, VIS.fileName) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } @@ -103,7 +104,7 @@ internal object UtilityWidgetDownload { fos2?.close() } - private fun downloadHWO(context: Context) { + private fun downloadHwo(context: Context) { val widgetLocNum = Utility.readPref(context, "WIDGET_LOCATION", "1") var nws1Current = Utility.readPref(context, "NWS$widgetLocNum", "").toUpperCase(Locale.US) if (Utility.readPref(context, "WFO_REMEMBER_LOCATION", "") == "true") { @@ -116,13 +117,13 @@ internal object UtilityWidgetDownload { Utility.commitPref(context) } - private fun downloadTextWPC(context: Context) { + private fun downloadTextWpc(context: Context) { val text = UtilityDownload.getTextProduct(context, MyApplication.wpcTextFav) Utility.writePref(context, "TEXTWPC_WIDGET", text) Utility.commitPref(context) } - private fun downloadAFD(context: Context) { + private fun downloadAfd(context: Context) { val widgetLocNum = Utility.readPref(context, "WIDGET_LOCATION", "1") var nws1Current = Utility.readPref(context, "NWS$widgetLocNum", "").toUpperCase(Locale.US) if (Utility.readPref(context, "WFO_REMEMBER_LOCATION", "") == "true") { @@ -144,11 +145,11 @@ internal object UtilityWidgetDownload { } } - private fun downloadRadMosaic(context: Context) { + private fun downloadRadarMosaic(context: Context) { try { - saveImage(context, UtilityDownload.getRadarMosiac(context), MOSAIC_RADAR.fileName) + saveImage(context, UtilityDownload.getRadarMosaic(context), MOSAIC_RADAR.fileName) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } @@ -161,21 +162,21 @@ internal object UtilityWidgetDownload { val file = File(dir, fileName) fos = FileOutputStream(file) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return fos } - private fun downloadWPCIMG(context: Context, type: WidgetFile) { + private fun downloadWpcImage(context: Context, type: WidgetFile) { val imgUrl = Utility.readPref(context, "WPG_IMG_FAV_URL", UtilityWPCImages.urls[0]) val bitmap = imgUrl.getImage() saveImage(context, bitmap, type.fileName) } - private fun downloadNHC(context: Context, type: WidgetFile) { - val bm1 = "${MyApplication.nwsNhcWebsitePrefix}/xgtwo/two_atl_0d0.png".getImage() - val bm2 = "${MyApplication.nwsNhcWebsitePrefix}/xgtwo/two_pac_0d0.png".getImage() - saveImage(context, bm1, type.fileName + "0") - saveImage(context, bm2, type.fileName + "1") + private fun downloadNhc(context: Context, type: WidgetFile) { + val bitmap1 = UtilityNHC.widgetImageUrlBottom.getImage() + val bitmap2 = UtilityNHC.widgetImageUrlTop.getImage() + saveImage(context, bitmap1, type.fileName + "0") + saveImage(context, bitmap2, type.fileName + "1") } } diff --git a/app/src/main/java/joshuatee/wx/WeatherWidgetService.kt b/app/src/main/java/joshuatee/wx/WeatherWidgetService.kt index 9e73b7b6..40bdb71e 100644 --- a/app/src/main/java/joshuatee/wx/WeatherWidgetService.kt +++ b/app/src/main/java/joshuatee/wx/WeatherWidgetService.kt @@ -84,7 +84,7 @@ internal class StackRemoteViewsFactory(private val context: Context) : val tempStrArr = MyApplication.colonSpace.split(day) if (tempStrArr != null && tempStrArr.size > 1) { t1 = tempStrArr[0].replace(":", " ") + " (" + - UtilityLocationFragment.extractTemp(tempStrArr[1]) + + UtilityLocationFragment.extractTemperature(tempStrArr[1]) + MyApplication.DEGREE_SYMBOL + UtilityLocationFragment.extractWindDirection(tempStrArr[1].substring(1)) + UtilityLocationFragment.extract7DayMetrics(tempStrArr[1].substring(1)) + ")" diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/AFDActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/AFDActivity.kt index 4d4c50a1..5e022da2 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/AFDActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/AFDActivity.kt @@ -70,23 +70,23 @@ class AFDActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItemClick private var firstTime = true private lateinit var activityArguments: Array private var product = "" - private var nwsOffice = "" + private var wfo = "" private lateinit var imageMap: ObjectImageMap private var html = "" private var mapShown = false - private lateinit var notifToggle: MenuItem + private lateinit var notificationToggle: MenuItem private lateinit var star: MenuItem - private lateinit var ridArrLoc: List + private lateinit var locationList: List private val prefTokenLocation = "NWS_LOCATION_" private val prefToken = "WFO_FAV" private var ridFavOld = "" private var version = 0 - private var oldProd = "" - private var oldNwsOffice = "" + private var oldProduct = "" + private var oldWfo = "" private var wfoListPerState = mutableListOf() private val cardList = mutableListOf() - private lateinit var c0: ObjectCardText - private lateinit var spinner1: ObjectSpinner + private lateinit var textCard: ObjectCardText + private lateinit var spinner: ObjectSpinner private lateinit var contextg: Context @SuppressLint("MissingSuperCall") @@ -95,16 +95,16 @@ class AFDActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItemClick contextg = this toolbarBottom.setOnMenuItemClickListener(this) UtilityShortcut.hidePinIfNeeded(toolbarBottom) - c0 = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) + textCard = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) star = toolbarBottom.menu.findItem(R.id.action_fav) - notifToggle = toolbarBottom.menu.findItem(R.id.action_notif_text_prod) + notificationToggle = toolbarBottom.menu.findItem(R.id.action_notif_text_prod) activityArguments = intent.getStringArrayExtra(URL) - nwsOffice = activityArguments[0] + wfo = activityArguments[0] if (Utility.readPref(this, "WFO_REMEMBER_LOCATION", "") == "true") { - nwsOffice = Utility.readPref(this, "WFO_LAST_USED", Location.wfo) + wfo = Utility.readPref(this, "WFO_LAST_USED", Location.wfo) } - if (nwsOffice == "") { - nwsOffice = "OUN" + if (wfo == "") { + wfo = "OUN" } product = if (activityArguments[1] == "") { MyApplication.wfoTextFav @@ -113,85 +113,85 @@ class AFDActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItemClick } title = product version = 1 - oldProd = "" - oldNwsOffice = "" - ridArrLoc = UtilityFavorites.setupFavMenu( - this, - MyApplication.wfoFav, - nwsOffice, - prefTokenLocation, - prefToken + oldProduct = "" + oldWfo = "" + locationList = UtilityFavorites.setupFavMenu( + this, + MyApplication.wfoFav, + wfo, + prefTokenLocation, + prefToken ) - spinner1 = ObjectSpinner(this, this, this, R.id.spinner1, ridArrLoc) + spinner = ObjectSpinner(this, this, this, R.id.spinner1, locationList) imageMap = ObjectImageMap( - this, - this, - R.id.map, - toolbar, - toolbarBottom, - listOf(c0.card, scrollView) + this, + this, + R.id.map, + toolbar, + toolbarBottom, + listOf(textCard.card, scrollView) ) - imageMap.addClickHandler(::mapSwitch, UtilityImageMap::maptoWFO) + imageMap.addClickHandler(::mapSwitch, UtilityImageMap::mapToWfo) } override fun onRestart() { if (ridFavOld != MyApplication.wfoFav) { - ridArrLoc = UtilityFavorites.setupFavMenu( - this, - MyApplication.wfoFav, - nwsOffice, - prefTokenLocation, - prefToken + locationList = UtilityFavorites.setupFavMenu( + this, + MyApplication.wfoFav, + wfo, + prefTokenLocation, + prefToken ) - spinner1.refreshData(this, ridArrLoc) + spinner.refreshData(this, locationList) } super.onRestart() } private fun getContent() = GlobalScope.launch(uiDispatcher) { - updateSubmenuNotifText() - if (MyApplication.wfoFav.contains(":$nwsOffice:")) { + updateSubmenuNotificationText() + if (MyApplication.wfoFav.contains(":$wfo:")) { star.setIcon(MyApplication.STAR_ICON) } else { star.setIcon(MyApplication.STAR_OUTLINE_ICON) } scrollView.smoothScrollTo(0, 0) ridFavOld = MyApplication.wfoFav - if (product != oldProd) { + if (product != oldProduct) { version = 1 } - if (nwsOffice != oldNwsOffice) { + if (wfo != oldWfo) { version = 1 } html = withContext(Dispatchers.IO) { if (version == 1) { - UtilityDownload.getTextProduct(contextg, product + nwsOffice) + UtilityDownload.getTextProduct(contextg, product + wfo) } else { - UtilityDownload.getTextProduct(product + nwsOffice, version) + UtilityDownload.getTextProduct(product + wfo, version) } } title = product cardList.forEach { linearLayout.removeView(it) } - c0.setVisibility(View.VISIBLE) + textCard.setVisibility(View.VISIBLE) scrollView.visibility = View.VISIBLE if (html == "") { html = "None issued by this office recently." } - c0.setTextAndTranslate(Utility.fromHtml(html)) + textCard.setTextAndTranslate(Utility.fromHtml(html)) UtilityTTS.conditionalPlay(activityArguments, 2, applicationContext, html, product) if (activityArguments[1] == "") { Utility.writePref(contextg, "WFO_TEXT_FAV", product) MyApplication.wfoTextFav = product } - oldProd = product - oldNwsOffice = nwsOffice - Utility.writePref(contextg, "WFO_LAST_USED", nwsOffice) + oldProduct = product + oldWfo = wfo + Utility.writePref(contextg, "WFO_LAST_USED", wfo) } override fun onMenuItemClick(item: MenuItem): Boolean { - if (audioPlayMenu(item.itemId, html, product, product + nwsOffice)) { + if (audioPlayMenu(item.itemId, html, product, product + wfo)) { return true } when (item.itemId) { @@ -207,8 +207,8 @@ class AFDActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItemClick } R.id.action_fav -> toggleFavorite() R.id.action_notif_text_prod -> { - UtilityNotificationTextProduct.toggle(this, linearLayout, product + nwsOffice) - updateSubmenuNotifText() + UtilityNotificationTextProduct.toggle(this, linearLayout, product + wfo) + updateSubmenuNotificationText() } R.id.action_prod_by_state -> { wfoByState() @@ -229,30 +229,30 @@ class AFDActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItemClick R.id.action_rer -> getProduct("RER") R.id.action_nsh -> getProduct("NSH") R.id.action_website -> ObjectIntent( - this, - WebscreenABModels::class.java, - WebscreenABModels.URL, - arrayOf("http://www.weather.gov/" + nwsOffice.toLowerCase(Locale.US), nwsOffice) + this, + WebscreenABModels::class.java, + WebscreenABModels.URL, + arrayOf("http://www.weather.gov/" + wfo.toLowerCase(Locale.US), wfo) ) R.id.action_hazards -> ObjectIntent( - this, - ImageShowActivity::class.java, - ImageShowActivity.URL, - arrayOf( - "http://www.weather.gov/wwamap/png/" + nwsOffice.toLowerCase(Locale.US) + ".png", - "$nwsOffice WWA Map" - ) + this, + ImageShowActivity::class.java, + ImageShowActivity.URL, + arrayOf( + "http://www.weather.gov/wwamap/png/" + wfo.toLowerCase(Locale.US) + ".png", + "$wfo WWA Map" + ) ) - /* R.id.action_forecast -> ObjectIntent( - this, - WebscreenABModels::class.java, - WebscreenABModels.URL, - arrayOf(UtilityDownloadNWS.get7DayURL(Location.x, Location.y), "Local forecast") - )*/ + /* R.id.action_forecast -> ObjectIntent( + this, + WebscreenABModels::class.java, + WebscreenABModels.URL, + arrayOf(UtilityDownloadNWS.get7DayURL(Location.x, Location.y), "Local forecast") + )*/ R.id.action_share -> UtilityShare.shareText( - this, - product + nwsOffice, - Utility.fromHtml(html) + this, + product + wfo, + Utility.fromHtml(html) ) else -> return super.onOptionsItemSelected(item) } @@ -265,42 +265,41 @@ class AFDActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItemClick } private fun mapSwitch(loc: String) { - nwsOffice = loc.toUpperCase(Locale.US) + wfo = loc.toUpperCase(Locale.US) mapShown = false - ridArrLoc = UtilityFavorites.setupFavMenu( - this, - MyApplication.wfoFav, - nwsOffice, - prefTokenLocation, - prefToken + locationList = UtilityFavorites.setupFavMenu( + this, + MyApplication.wfoFav, + wfo, + prefTokenLocation, + prefToken ) - spinner1.refreshData(this, ridArrLoc) + spinner.refreshData(this, locationList) } private fun toggleFavorite() { - val ridFav = UtilityFavorites.toggleFavoriteString(this, nwsOffice, star, prefToken) - ridArrLoc = - UtilityFavorites.setupFavMenu(this, ridFav, nwsOffice, prefTokenLocation, prefToken) - spinner1.refreshData(this, ridArrLoc) + val ridFav = UtilityFavorites.toggleFavoriteString(this, wfo, star, prefToken) + locationList = UtilityFavorites.setupFavMenu(this, ridFav, wfo, prefTokenLocation, prefToken) + spinner.refreshData(this, locationList) } override fun onItemSelected(parent: AdapterView<*>, view: View?, pos: Int, id: Long) { - if (ridArrLoc.isNotEmpty()) { + if (locationList.isNotEmpty()) { when (pos) { 1 -> ObjectIntent( - this, - FavAddActivity::class.java, - FavAddActivity.TYPE, - arrayOf("WFO") + this, + FavAddActivity::class.java, + FavAddActivity.TYPE, + arrayOf("WFO") ) 2 -> ObjectIntent( - this, - FavRemoveActivity::class.java, - FavRemoveActivity.TYPE, - arrayOf("WFO") + this, + FavRemoveActivity::class.java, + FavRemoveActivity.TYPE, + arrayOf("WFO") ) else -> { - nwsOffice = ridArrLoc[pos].split(" ").getOrNull(0) ?: "" + wfo = locationList[pos].split(" ").getOrNull(0) ?: "" getContent() } } @@ -313,21 +312,21 @@ class AFDActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItemClick override fun onNothingSelected(parent: AdapterView<*>) {} - private fun updateSubmenuNotifText() { - if (UtilityNotificationTextProduct.check(product + nwsOffice)) { - notifToggle.title = resources.getString(R.string.notif_remove) + private fun updateSubmenuNotificationText() { + if (UtilityNotificationTextProduct.check(product + wfo)) { + notificationToggle.title = resources.getString(R.string.notif_remove) } else { - notifToggle.title = resources.getString(R.string.notif_add) + notificationToggle.title = resources.getString(R.string.notif_add) } } private fun wfoByState() { - val state = ridArrLoc[0].split(" ")[1] + val state = locationList[0].split(" ")[1] wfoListPerState = mutableListOf() wfoListPerState.clear() GlobalArrays.wfos - .filter { it.contains(state) } - .forEach { wfoListPerState.add(MyApplication.space.split(it)[0].replace(":", "")) } + .filter { it.contains(state) } + .forEach { wfoListPerState.add(MyApplication.space.split(it)[0].replace(":", "")) } wfoListPerState.sort() } @@ -335,10 +334,10 @@ class AFDActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItemClick val wfoProd = mutableListOf() scrollView.smoothScrollTo(0, 0) ridFavOld = MyApplication.wfoFav - if (product != oldProd) { + if (product != oldProduct) { version = 1 } - if (nwsOffice != oldNwsOffice) { + if (wfo != oldWfo) { version = 1 } title = product @@ -353,12 +352,12 @@ class AFDActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItemClick wfoProd.add(html) } } - c0.setVisibility(View.GONE) + textCard.setVisibility(View.GONE) cardList.clear() wfoProd.forEach { - val cTmp = ObjectCardText(contextg, linearLayout) - cTmp.setTextAndTranslate(Utility.fromHtml(it)) - cardList.add(cTmp.card) + val textCard = ObjectCardText(contextg, linearLayout) + textCard.setTextAndTranslate(Utility.fromHtml(it)) + cardList.add(textCard.card) } } } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/AdapterSpotter.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/AdapterSpotter.kt index a88afccb..79fbe9cd 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/AdapterSpotter.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/AdapterSpotter.kt @@ -76,24 +76,23 @@ internal class AdapterSpotter(private val mDataset: MutableList) : holder.name.text = mDataset[position].lastName + ", " + mDataset[position].firstName holder.time.text = mDataset[position].reportAt holder.email.text = mDataset[position].email.replace(MyApplication.newline, " ") - val he = holder.email - val emailAddress = holder.email.text holder.email.setOnClickListener(View.OnClickListener { val intent = Intent(Intent.ACTION_SENDTO) intent.data = Uri.parse("mailto:") - intent.putExtra(Intent.EXTRA_EMAIL, arrayOf(emailAddress)) + intent.putExtra(Intent.EXTRA_EMAIL, arrayOf(holder.email.text)) intent.putExtra(Intent.EXTRA_SUBJECT, "") - he.context.startActivity(Intent.createChooser(intent, "Send Email")) + holder.email.context.startActivity(Intent.createChooser(intent, "Send Email")) }) holder.phone.text = mDataset[position].phone.replace(MyApplication.newline, " ") - listOf(holder.time, holder.email, holder.phone).forEach { it.setAsBackgroundText() } - val hp = holder.phone + listOf(holder.time, holder.email, holder.phone).forEach { + it.setAsBackgroundText() + } holder.phone.setOnClickListener(View.OnClickListener { - val tm = hp.context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager - if (tm.phoneType != TelephonyManager.PHONE_TYPE_NONE) { + val telephonyManager = holder.phone.context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager + if (telephonyManager.phoneType != TelephonyManager.PHONE_TYPE_NONE) { val intent = Intent(Intent.ACTION_DIAL) intent.data = Uri.parse("tel:" + mDataset[position].phone) - hp.context.startActivity(intent) + holder.phone.context.startActivity(intent) } }) } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/AdapterUSWarningsImpact.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/AdapterUSWarningsImpact.kt index 8c447dee..e227eaa8 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/AdapterUSWarningsImpact.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/AdapterUSWarningsImpact.kt @@ -69,7 +69,9 @@ internal class AdapterUSWarningsImpact(private val mDataset: List - private var latlon = LatLon() - private var objCc: ObjectForecastPackageCurrentConditions? = null - private var objHazards: ObjectForecastPackageHazards? = null - private var objSevenDay: ObjectForecastPackage7Day? = null + private var latLon = LatLon() + private var objCc = ObjectForecastPackageCurrentConditions() + private var objHazards = ObjectForecastPackageHazards() + private var objSevenDay = ObjectForecastPackage7Day() private var ccTime = "" private var radarTime = "" - private var hazardsSum = "" - private var hazardRaw = "" private lateinit var cardCC: ObjectCardCC private lateinit var linearLayoutForecast: LinearLayout private lateinit var linearLayoutHazards: LinearLayout - private val hazardsCardAl = mutableListOf() - private val hazardsExpandedAl = mutableListOf() + private val hazardCards = mutableListOf() private lateinit var contextg: Context @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { + // FIXME activity_linear_layout need ll to be renamed to linearLayout, need to asses which activities are using it super.onCreate(savedInstanceState, R.layout.activity_linear_layout, null, false) activityArguments = intent.getStringArrayExtra(URL) - latlon = LatLon(activityArguments[0], activityArguments[1]) + latLon = LatLon(activityArguments[0], activityArguments[1]) title = "Forecast for" - toolbar.subtitle = latlon.latString + "," + latlon.lonString + toolbar.subtitle = latLon.latString + "," + latLon.lonString cardCC = ObjectCardCC(this, 2) ll.addView(cardCC.card) + // FIXME add wrapper class for LinearLayout below linearLayoutHazards = LinearLayout(this) linearLayoutHazards.orientation = LinearLayout.VERTICAL ll.addView(linearLayoutHazards) @@ -92,106 +90,91 @@ class AdhocForecastActivity : BaseActivity() { } private fun getContent() = GlobalScope.launch(uiDispatcher) { - var bmCc: Bitmap? = null - val bmArr = mutableListOf() + var bitmapForCurrentCondition: Bitmap? = null + val bitmaps = mutableListOf() withContext(Dispatchers.IO) { // - // CC + // Current conditions // - objCc = Utility.getCurrentConditionsByLatLon(contextg, latlon) - objHazards = Utility.getCurrentHazards(latlon) - objSevenDay = Utility.getCurrentSevenDay(latlon) - hazardRaw = objHazards!!.hazards.getHtmlSep() - bmCc = UtilityNWS.getIcon(contextg, objCc!!.iconUrl) + objCc = ObjectForecastPackageCurrentConditions(contextg, latLon) + objHazards = ObjectForecastPackageHazards(latLon) + objSevenDay = ObjectForecastPackage7Day(latLon) + bitmapForCurrentCondition = UtilityNWS.getIcon(contextg, objCc.iconUrl) // // 7day // - objSevenDay!!.iconAl.mapTo(bmArr) { UtilityNWS.getIcon(contextg, it) } + objSevenDay.icons.mapTo(bitmaps) { UtilityNWS.getIcon(contextg, it) } // // hazards // - hazardRaw = objHazards!!.hazards + //hazardRaw = objHazards!!.hazards } // // CC // - objCc?.let { _ -> - cardCC.let { - ccTime = objCc!!.status - if (bmCc != null) { - it.updateContent(bmCc!!, objCc!!, true, ccTime, radarTime) - } + cardCC.let { + ccTime = objCc.status + if (bitmapForCurrentCondition != null) { + it.updateContent(bitmapForCurrentCondition!!, objCc, true, ccTime, radarTime) } } // // 7day // - objCc?.let { - linearLayoutForecast.removeAllViewsInLayout() - val day7Arr = objSevenDay!!.fcstList - bmArr.forEachIndexed { idx, bm -> - val c7day = ObjectCard7Day(contextg, bm, true, idx, day7Arr) - c7day.setOnClickListener(View.OnClickListener { - sv.smoothScrollTo(0, 0) - }) - linearLayoutForecast.addView(c7day.card) - } - // sunrise card - val cardSunrise = ObjectCardText(contextg) - cardSunrise.center() - //cardSunrise.lightText() - try { - cardSunrise.setText( - UtilityDownload.getSunriseSunset( - contextg, - Location.currentLocationStr + linearLayoutForecast.removeAllViewsInLayout() + bitmaps.forEachIndexed { index, bitmap -> + val c7day = ObjectCard7Day(contextg, bitmap, true, index, objSevenDay.forecastList) + c7day.setOnClickListener(View.OnClickListener { + sv.smoothScrollTo(0, 0) + }) + linearLayoutForecast.addView(c7day.card) + } + // sunrise card + val cardSunrise = ObjectCardText(contextg) + cardSunrise.center() + try { + cardSunrise.setText( + UtilityTimeSunMoon.getSunriseSunset( + contextg, + Location.currentLocationStr ) + MyApplication.newline + UtilityTime.gmtTime() - ) - } catch (e: Exception) { - UtilityLog.HandleException(e) - } - linearLayoutForecast.addView(cardSunrise.card) + ) + } catch (e: Exception) { + UtilityLog.handleException(e) } + linearLayoutForecast.addView(cardSunrise.card) // // hazards // - var hazardSumAsync = "" - val idAl = hazardRaw.parseColumn("\"@id\": \"(.*?)\"") - val hazardTitles = hazardRaw.parseColumn("\"event\": \"(.*?)\"") - hazardTitles.forEach { hazardSumAsync += it + MyApplication.newline } - if (hazardSumAsync == "") { + if (objHazards.titles.isEmpty()) { linearLayoutHazards.removeAllViews() linearLayoutHazards.visibility = View.GONE } else { linearLayoutHazards.visibility = View.VISIBLE - setupHazardCards(hazardSumAsync, idAl) + setupHazardCards() } - hazardsSum = hazardSumAsync } - private fun setupHazardCards(hazStr: String, idAl: List) { + private fun setupHazardCards() { linearLayoutHazards.removeAllViews() - hazardsExpandedAl.clear() - hazardsCardAl.clear() - val tmpArr = hazStr.split(MyApplication.newline).dropLastWhile { it.isEmpty() } - tmpArr.indices.forEach { z -> - hazardsExpandedAl.add(false) - hazardsCardAl.add(ObjectCardText(contextg)) - hazardsCardAl[z].setTextSize(TypedValue.COMPLEX_UNIT_PX, MyApplication.textSizeNormal) - hazardsCardAl[z].setTextColor(UIPreferences.textHighlightColor) - hazardsCardAl[z].setText(tmpArr[z].toUpperCase(Locale.US)) - val url = idAl[z] - hazardsCardAl[z].setOnClickListener(View.OnClickListener { + hazardCards.clear() + objHazards.titles.indices.forEach { z -> + hazardCards.add(ObjectCardText(contextg)) + hazardCards[z].setPaddingAmount(MyApplication.paddingSettings) + hazardCards[z].setTextSize(TypedValue.COMPLEX_UNIT_PX, MyApplication.textSizeNormal) + hazardCards[z].setTextColor(UIPreferences.textHighlightColor) + hazardCards[z].setText(objHazards.titles[z].toUpperCase(Locale.US)) + hazardCards[z].setOnClickListener(View.OnClickListener { ObjectIntent( - contextg, - USAlertsDetailActivity::class.java, - USAlertsDetailActivity.URL, - arrayOf(url) + contextg, + USAlertsDetailActivity::class.java, + USAlertsDetailActivity.URL, + arrayOf(objHazards.urls[z]) ) }) - linearLayoutHazards.addView(hazardsCardAl[z].card) + linearLayoutHazards.addView(hazardCards[z].card) } } } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/CAPAlert.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/CAPAlert.kt index 529de361..1d330b52 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/CAPAlert.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/CAPAlert.kt @@ -24,6 +24,7 @@ package joshuatee.wx.activitiesmisc import joshuatee.wx.util.UtilityDownloadNws import joshuatee.wx.Extensions.* import joshuatee.wx.UIPreferences +import joshuatee.wx.util.UtilityLog class CAPAlert { @@ -63,15 +64,17 @@ class CAPAlert { companion object { - fun createFromURL(url: String): CAPAlert { + fun createFromUrl(url: String): CAPAlert { val expireStr = "This alert has expired" val obj = CAPAlert() obj.url = url val html = if (url.contains("NWS-IDP-PROD")) { - UtilityDownloadNws.getNwsStringFromUrlSep(url) + //UtilityLog.d("wx", url) + UtilityDownloadNws.getStringFromUrlSep(url) } else { url.getHtmlSep() } + //UtilityLog.d("wx", html) if (!html.contains("NWS-IDP-PROD")) { if (html.contains(expireStr)) { obj.text = expireStr @@ -97,6 +100,7 @@ class CAPAlert { } else { obj.title = html.parse("\"headline\": \"(.*?)\"") obj.summary = html.parse("\"description\": \"(.*?)\"") + //UtilityLog.d("wx", obj.summary) obj.instructions = html.parse("\"instruction\": \"(.*?)\"") obj.area = html.parse("\"areaDesc\": \"(.*?)\"") obj.summary = obj.summary.replace("\\n", "\n") diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/HourlyActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/HourlyActivity.kt index e9c60e5e..eb316aaf 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/HourlyActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/HourlyActivity.kt @@ -54,10 +54,10 @@ class HourlyActivity : BaseActivity(), Toolbar.OnMenuItemClickListener { private val uiDispatcher: CoroutineDispatcher = Dispatchers.Main private var htmlShare = listOf() - private lateinit var cv1: ObjectCard - private lateinit var c0: ObjectCardVerticalText + private lateinit var card: ObjectCard + private lateinit var textCard: ObjectCardVerticalText private var hourlyData = ObjectHourly() - private var locatioNumber = 0 + private var locationNumber = 0 @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { @@ -68,26 +68,26 @@ class HourlyActivity : BaseActivity(), Toolbar.OnMenuItemClickListener { true ) toolbarBottom.setOnMenuItemClickListener(this) - locatioNumber = (intent.getStringExtra(LOC_NUM).toIntOrNull() ?: 0) - 1 - cv1 = ObjectCard(this, R.color.black, R.id.cv1) - cv1.setVisibility(View.GONE) - c0 = ObjectCardVerticalText(this, 5, linearLayout, toolbar) - c0.setOnClickListener(View.OnClickListener { sv.scrollTo(0,0)}) + locationNumber = (intent.getStringExtra(LOC_NUM).toIntOrNull() ?: 0) - 1 + card = ObjectCard(this, R.color.black, R.id.cv1) + cv1.visibility = View.GONE + textCard = ObjectCardVerticalText(this, 5, linearLayout, toolbar) + textCard.setOnClickListener(View.OnClickListener { sv.scrollTo(0,0)}) title = "Hourly Forecast" - toolbar.subtitle = Location.getName(locatioNumber) + toolbar.subtitle = Location.getName(locationNumber) //UtilityLog.d("wx", UtilityTimeSunMoon.getSunTimesForHomescreen()) //UtilityLog.d("wx", UtilityTimeSunMoon.getMoonTimesForHomescreen()) getContent() } private fun getContent() = GlobalScope.launch(uiDispatcher) { - val result1 = async(Dispatchers.IO) { UtilityUSHourly.getString(locatioNumber) } + val result1 = async(Dispatchers.IO) { UtilityUSHourly.getString(locationNumber) } htmlShare = result1.await() val result2 = async(Dispatchers.IO) { UtilityUSHourly.getStringForActivity(htmlShare[1]) } hourlyData = result2.await() - cv1.setVisibility(View.VISIBLE) - c0.setText( + cv1.visibility = View.VISIBLE + textCard.setText( listOf( hourlyData.time, hourlyData.temp, @@ -96,7 +96,7 @@ class HourlyActivity : BaseActivity(), Toolbar.OnMenuItemClickListener { hourlyData.conditions ) ) - plot1() + plotData() } override fun onMenuItemClick(item: MenuItem): Boolean { @@ -109,12 +109,12 @@ class HourlyActivity : BaseActivity(), Toolbar.OnMenuItemClickListener { return true } - private fun plot1() { - val tmpArr2 = hourlyData.temp.split(MyApplication.newline).dropLastWhile { it.isEmpty() } + private fun plotData() { + val linesOfData = hourlyData.temp.split(MyApplication.newline).dropLastWhile { it.isEmpty() } val dataPoints = mutableListOf() var time = 0 - (1 until tmpArr2.size - 1).forEach { - val temp = tmpArr2[it].toIntOrNull() ?: 0 + (1 until linesOfData.size - 1).forEach { + val temp = linesOfData[it].toIntOrNull() ?: 0 time += 1 dataPoints.add(DataPoint(time.toDouble(), temp.toDouble())) } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/ImageShowActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/ImageShowActivity.kt index 36de1d11..edc3c16d 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/ImageShowActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/ImageShowActivity.kt @@ -61,7 +61,7 @@ class ImageShowActivity : BaseActivity(), Toolbar.OnMenuItemClickListener { private var urls = listOf() private var bitmap = UtilityImg.getBlankBitmap() private var shareTitle = "" - private var needsWhitebg = false + private var needsWhiteBackground = false private lateinit var img: ObjectTouchImageView private lateinit var contextg: Context @@ -81,7 +81,7 @@ class ImageShowActivity : BaseActivity(), Toolbar.OnMenuItemClickListener { title = activityArguments[1] shareTitle = activityArguments[1] if (activityArguments.size > 2) { - needsWhitebg = activityArguments[2] == "true" + needsWhiteBackground = activityArguments[2] == "true" } when { url.contains("file:") -> { @@ -103,7 +103,7 @@ class ImageShowActivity : BaseActivity(), Toolbar.OnMenuItemClickListener { private fun getContent() = GlobalScope.launch(uiDispatcher) { bitmap = withContext(Dispatchers.IO) { url.getImage() } - if (needsWhitebg) { + if (needsWhiteBackground) { bitmap = UtilityImg.addColorBG(contextg, bitmap, Color.WHITE) } img.setBitmap(bitmap) diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/NWSObsSitesActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/NWSObsSitesActivity.kt index 78b18718..9efcb7c0 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/NWSObsSitesActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/NWSObsSitesActivity.kt @@ -38,6 +38,7 @@ import joshuatee.wx.objects.ObjectIntent import joshuatee.wx.ui.ObjectRecyclerView import joshuatee.wx.util.Utility +// FIXME camelcase file name class NWSObsSitesActivity : BaseActivity(), Toolbar.OnMenuItemClickListener { private val listIds = mutableListOf() @@ -83,7 +84,7 @@ class NWSObsSitesActivity : BaseActivity(), Toolbar.OnMenuItemClickListener { if (!siteDisplay) { provSelected = UtilityStringExternal.truncate(GlobalArrays.states[position], 2) title = "$titleString ($provSelected)" - provSelected() + stateSelected() } else { when (position) { 0 -> { @@ -110,7 +111,7 @@ class NWSObsSitesActivity : BaseActivity(), Toolbar.OnMenuItemClickListener { ) } - private fun provSelected() { + private fun stateSelected() { getContent() } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/SevereDashboardActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/SevereDashboardActivity.kt index 3e94f2cc..fb39622a 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/SevereDashboardActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/SevereDashboardActivity.kt @@ -54,6 +54,17 @@ class SevereDashboardActivity : BaseActivity() { private val uiDispatcher: CoroutineDispatcher = Dispatchers.Main private val bitmaps = mutableListOf() private lateinit var contextg: Context + private var watchCount = 0 + private var mcdCount = 0 + private var mpdCount = 0 + private var svrCount = 0 + private var ffwCount = 0 + private var torCount = 0 + private var smwCount = 0 + private var ewwCount = 0 + private var svsCount = 0 + private var spsCount = 0 + override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.severe_dashboard, menu) @@ -68,12 +79,12 @@ class SevereDashboardActivity : BaseActivity() { getContent() } - private fun tvWarnClicked(filter: String) { + private fun warningsClicked(filter: String) { ObjectIntent( - contextg, - USWarningsWithRadarActivity::class.java, - USWarningsWithRadarActivity.URL, - arrayOf(filter, "us") + contextg, + USWarningsWithRadarActivity::class.java, + USWarningsWithRadarActivity.URL, + arrayOf(filter, "us") ) } @@ -104,31 +115,31 @@ class SevereDashboardActivity : BaseActivity() { } if (wTor.count > 0) { val objTor = ObjectCardText(contextg, ll, wTor.text) - objTor.setOnClickListener(View.OnClickListener { tvWarnClicked(".*?Tornado Warning.*?") }) + objTor.setOnClickListener(View.OnClickListener { warningsClicked(".*?Tornado Warning.*?") }) } if (wSvr.count > 0) { val objSvr = ObjectCardText(contextg, ll, wSvr.text) - objSvr.setOnClickListener(View.OnClickListener { tvWarnClicked(".*?Severe Thunderstorm Warning.*?") }) + objSvr.setOnClickListener(View.OnClickListener { warningsClicked(".*?Severe Thunderstorm Warning.*?") }) } if (wEww.count > 0) { val objEww = ObjectCardText(contextg, ll, wEww.text) - objEww.setOnClickListener(View.OnClickListener { tvWarnClicked(".*?Extreme Wind Warning.*?") }) + objEww.setOnClickListener(View.OnClickListener { warningsClicked(".*?Extreme Wind Warning.*?") }) } if (wFfw.count > 0) { val objFfw = ObjectCardText(contextg, ll, wFfw.text) - objFfw.setOnClickListener(View.OnClickListener { tvWarnClicked(".*?Flash Flood Warning.*?") }) + objFfw.setOnClickListener(View.OnClickListener { warningsClicked(".*?Flash Flood Warning.*?") }) } if (wSmw.count > 0) { val objSmw = ObjectCardText(contextg, ll, wSmw.text) - objSmw.setOnClickListener(View.OnClickListener { tvWarnClicked(".*?Special Marine Warning.*?") }) + objSmw.setOnClickListener(View.OnClickListener { warningsClicked(".*?Special Marine Warning.*?") }) } if (wSvs.count > 0) { val objSvs = ObjectCardText(contextg, ll, wSvs.text) - objSvs.setOnClickListener(View.OnClickListener { tvWarnClicked(".*?Severe Weather Statement.*?") }) + objSvs.setOnClickListener(View.OnClickListener { warningsClicked(".*?Severe Weather Statement.*?") }) } if (wSps.count > 0) { val objSps = ObjectCardText(contextg, ll, wSps.text) - objSps.setOnClickListener(View.OnClickListener { tvWarnClicked(".*?Special Weather Statement.*?") }) + objSps.setOnClickListener(View.OnClickListener { warningsClicked(".*?Special Weather Statement.*?") }) } @@ -143,55 +154,85 @@ class SevereDashboardActivity : BaseActivity() { val card = ObjectCardImage(contextg, ll, bitmapArrRep[it]) card.setOnClickListener(View.OnClickListener { ObjectIntent( - contextg, - SPCStormReportsActivity::class.java, - SPCStormReportsActivity.NO, - arrayOf("today") + contextg, + SPCStormReportsActivity::class.java, + SPCStormReportsActivity.NO, + arrayOf("today") ) }) } } listOf(snWat, snMcd, snMpd) - .asSequence() - .filter { it.bitmaps.size > 0 } - .forEach { severeNotice -> - severeNotice.bitmaps.indices.forEach { j -> - val card = ObjectCardImage(contextg, ll, severeNotice.bitmaps[j]) - var cla: Class<*>? = null - var claStr = "" - val claArgStr = severeNotice.strList[j] - when (severeNotice.type) { - PolygonType.MCD -> { - cla = SPCMCDWShowActivity::class.java - claStr = SPCMCDWShowActivity.NO - } - PolygonType.WATCH -> { - cla = SPCMCDWShowActivity::class.java - claStr = SPCMCDWShowActivity.NO - } - PolygonType.MPD -> { - cla = SPCMCDWShowActivity::class.java - claStr = SPCMCDWShowActivity.NO - } - else -> { + .asSequence() + .filter { it.bitmaps.size > 0 } + .forEach { severeNotice -> + severeNotice.bitmaps.indices.forEach { j -> + val card = ObjectCardImage(contextg, ll, severeNotice.bitmaps[j]) + var cla: Class<*>? = null + var claStr = "" + val claArgStr = severeNotice.numbers[j] + when (severeNotice.type) { + PolygonType.MCD -> { + cla = SPCMCDWShowActivity::class.java + claStr = SPCMCDWShowActivity.NO + } + PolygonType.WATCH -> { + cla = SPCMCDWShowActivity::class.java + claStr = SPCMCDWShowActivity.NO + } + PolygonType.MPD -> { + cla = SPCMCDWShowActivity::class.java + claStr = SPCMCDWShowActivity.NO + } + else -> { + } } + val cl = cla + val clStr = claStr + card.setOnClickListener(View.OnClickListener { + ObjectIntent( + contextg, + cl!!, + clStr, + arrayOf(claArgStr, "", severeNotice.toString()) + ) + }) } - val cl = cla - val clStr = claStr - card.setOnClickListener(View.OnClickListener { - ObjectIntent( - contextg, - cl!!, - clStr, - arrayOf(claArgStr, "", severeNotice.toString()) - ) - }) } - } bitmaps.addAll(snWat.bitmaps) bitmaps.addAll(snMcd.bitmaps) bitmaps.addAll(snMpd.bitmaps) bitmaps.addAll(bitmapArrRep) + + svrCount = wSvr.count + ffwCount = wFfw.count + torCount = wTor.count + smwCount = wSmw.count + ewwCount = wEww.count + svsCount = wSvs.count + spsCount = wSps.count + + watchCount = snWat.bitmaps.size + mcdCount = snMcd.bitmaps.size + mpdCount = snMpd.bitmaps.size + toolbar.subtitle = getSubTitle() + } + + private fun getSubTitle(): String { + var subTitle = "" + if (watchCount > 0) { + subTitle += "W($watchCount) " + } + if (mcdCount > 0) { + subTitle += "M($mcdCount) " + } + if (mpdCount > 0) { + subTitle += "P($mpdCount) " + } + if (torCount > 0 || svrCount > 0 || ffwCount > 0 || smwCount > 0 || ewwCount > 0 || svsCount > 0 || spsCount > 0) { + subTitle += " ($svrCount,$torCount,$ffwCount,$smwCount,$ewwCount,$svsCount,$spsCount)" + } + return subTitle } override fun onOptionsItemSelected(item: MenuItem): Boolean { diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/SevereNotice.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/SevereNotice.kt index d5844010..268db30f 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/SevereNotice.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/SevereNotice.kt @@ -35,7 +35,7 @@ internal class SevereNotice(val type: PolygonType) { // encapsulates a string array representation and bitmap arraylist of current mcd, wat, or mpd val bitmaps = mutableListOf() - var strList = mutableListOf() + var numbers = mutableListOf() var pattern: Pattern = Pattern.compile("") private var typeAsString = "" @@ -49,17 +49,17 @@ internal class SevereNotice(val type: PolygonType) { } } - fun getBitmaps(dataAsStringMCD: String) { - var comp = "" + fun getBitmaps(html: String) { + var zeroString = "" var url = "" when (type) { - PolygonType.MCD -> comp = "
No Mesoscale Discussions are currently in effect." - PolygonType.WATCH -> comp = "
No watches are currently valid" - PolygonType.MPD -> comp = "No MPDs are currently in effect." + PolygonType.MCD -> zeroString = "
No Mesoscale Discussions are currently in effect." + PolygonType.WATCH -> zeroString = "
No watches are currently valid" + PolygonType.MPD -> zeroString = "No MPDs are currently in effect." else -> { } } - if (!dataAsStringMCD.contains(comp)) { + if (!html.contains(zeroString)) { when (type) { PolygonType.MCD -> pattern = RegExp.mcdPatternUtilspc PolygonType.WATCH -> pattern = RegExp.watchPattern @@ -67,20 +67,20 @@ internal class SevereNotice(val type: PolygonType) { else -> { } } - strList = UtilityString.parseColumnAl(dataAsStringMCD, pattern) + numbers = UtilityString.parseColumnAl(html, pattern) } - strList.indices.forEach { count -> + numbers.indices.forEach { count -> when (type) { PolygonType.MCD -> url = "${MyApplication.nwsSPCwebsitePrefix}/products/md/mcd" + - strList[count] + ".gif" + numbers[count] + ".gif" PolygonType.WATCH -> { - strList[count] = String.format("%4s", strList[count]).replace(' ', '0') + numbers[count] = String.format("%4s", numbers[count]).replace(' ', '0') url = "${MyApplication.nwsSPCwebsitePrefix}/products/watch/ww" + - strList[count] + "_radar.gif" + numbers[count] + "_radar.gif" } PolygonType.MPD -> url = "${MyApplication.nwsWPCwebsitePrefix}/metwatch/images/mcd" + - strList[count] + ".gif" + numbers[count] + ".gif" else -> { } } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/SevereWarning.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/SevereWarning.kt index 6ad5f553..d5fef3a8 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/SevereWarning.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/SevereWarning.kt @@ -42,9 +42,9 @@ internal class SevereWarning(private val type: PolygonType) { private set fun generateString(context: Context, textTor: String) { - var nwsOfficeArr: List - var nwsOffice: String - var nwsLoc = "" + var vtecComponents: List + var wfo = "" + var wfoLocation = "" var label = "" when (type) { PolygonType.TOR -> label = "Tornado Warnings" @@ -63,13 +63,13 @@ internal class SevereWarning(private val type: PolygonType) { if (!it.startsWith("O.EXP") && vtecIsCurrent) { text += it count += 1 - nwsOfficeArr = it.split(".") - if (nwsOfficeArr.size > 1) { - nwsOffice = nwsOfficeArr[2] - nwsOffice = nwsOffice.replace("^[KP]".toRegex(), "") - nwsLoc = Utility.readPref(context, "NWS_LOCATION_$nwsOffice", "") + vtecComponents = it.split(".") + if (vtecComponents.size > 1) { + wfo = vtecComponents[2] + wfo = wfo.replace("^[KP]".toRegex(), "") + wfoLocation = Utility.readPref(context, "NWS_LOCATION_$wfo", "") } - text += " " + nwsLoc + MyApplication.newline + text += " " + wfoLocation + MyApplication.newline } } val remover = ExternalDuplicateRemover() diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/SpecialWeather.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/SpecialWeather.kt index 198b6d8a..0a82df35 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/SpecialWeather.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/SpecialWeather.kt @@ -74,7 +74,7 @@ internal class SpecialWeather(private val type: PolygonType) { .parseJsonObject(StringReader(MyApplication.severeDashboardSps.valueGet())) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } UtilityLog.d("SpecialWeather", "sps count: "+count) diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/SpottersActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/SpottersActivity.kt index 67154862..6c9e44d2 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/SpottersActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/SpottersActivity.kt @@ -127,14 +127,14 @@ class SpottersActivity : BaseActivity() { return filteredModelList } - private fun checkFav(posn: Int) { - if (MyApplication.spotterFav.contains(spotterlist[posn].uniq + ":")) { + private fun checkFavorite(position: Int) { + if (MyApplication.spotterFav.contains(spotterlist[position].uniq + ":")) { MyApplication.spotterFav = - MyApplication.spotterFav.replace(spotterlist[posn].uniq + ":", "") - spotterlist[posn].lastName = spotterlist[posn].lastName.replace("0FAV ", "") + MyApplication.spotterFav.replace(spotterlist[position].uniq + ":", "") + spotterlist[position].lastName = spotterlist[position].lastName.replace("0FAV ", "") } else { - MyApplication.spotterFav = MyApplication.spotterFav + spotterlist[posn].uniq + ":" - spotterlist[posn].lastName = "0FAV " + spotterlist[posn].lastName + MyApplication.spotterFav = MyApplication.spotterFav + spotterlist[position].uniq + ":" + spotterlist[position].lastName = "0FAV " + spotterlist[position].lastName } sortSpotters() ca.notifyDataSetChanged() @@ -185,7 +185,7 @@ class SpottersActivity : BaseActivity() { WebscreenAB::class.java, WebscreenAB.URL, arrayOf( - UtilityMap.genMapURL( + UtilityMap.genMapUrl( spotterlist[position].lat, spotterlist[position].lon, "9" @@ -209,6 +209,6 @@ class SpottersActivity : BaseActivity() { } private fun toggleFavorite(position: Int) { - checkFav(position) + checkFavorite(position) } } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/SunMoonActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/SunMoonActivity.kt index 3cd2368b..dddeded5 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/SunMoonActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/SunMoonActivity.kt @@ -41,7 +41,7 @@ class SunMoonActivity : AudioPlayActivity(), OnMenuItemClickListener { private val uiDispatcher: CoroutineDispatcher = Dispatchers.Main private var content = "" private var contentFull = "" - private lateinit var card0: ObjectCardText + private lateinit var textCard: ObjectCardText private var dataA = "" private var dataB = "" @@ -55,7 +55,7 @@ class SunMoonActivity : AudioPlayActivity(), OnMenuItemClickListener { toolbarBottom.setOnMenuItemClickListener(this) val menu = toolbarBottom.menu menu.findItem(R.id.action_playlist).isVisible = false - card0 = ObjectCardText(this, ll, toolbar, toolbarBottom) + textCard = ObjectCardText(this, ll, toolbar, toolbarBottom) getContent() } @@ -69,7 +69,7 @@ class SunMoonActivity : AudioPlayActivity(), OnMenuItemClickListener { dataB = B title = dataA toolbar.subtitle = Location.name - card0.setText(dataB + MyApplication.newline + MyApplication.newline + contentFull) + textCard.setText(dataB + MyApplication.newline + MyApplication.newline + contentFull) } override fun onMenuItemClick(item: MenuItem): Boolean { diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/TextScreenActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/TextScreenActivity.kt index f775c3c0..ef8e2195 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/TextScreenActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/TextScreenActivity.kt @@ -53,7 +53,7 @@ class TextScreenActivity : AudioPlayActivity(), OnMenuItemClickListener { private lateinit var activityArguments: Array private var url = "" private var html = "" - private lateinit var c0: ObjectCardText + private lateinit var textCard: ObjectCardText @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { @@ -69,16 +69,16 @@ class TextScreenActivity : AudioPlayActivity(), OnMenuItemClickListener { try { activityArguments = intent.getStringArrayExtra(URL) } catch (e: IllegalStateException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } url = activityArguments[0] title = activityArguments[1] - c0 = ObjectCardText(this, ll, toolbar, toolbarBottom) + textCard = ObjectCardText(this, ll, toolbar, toolbarBottom) if (!url.startsWith("http")) { if (url.contains("<")) { - c0.setText(Utility.fromHtml(url)) + textCard.setText(Utility.fromHtml(url)) } else { - c0.setText(url) + textCard.setText(url) } html = url } else { @@ -95,7 +95,7 @@ class TextScreenActivity : AudioPlayActivity(), OnMenuItemClickListener { private fun getContent() = GlobalScope.launch(uiDispatcher) { html = withContext(Dispatchers.IO) { url.getHtml() } - c0.setTextAndTranslate(Utility.fromHtml(html)) + textCard.setTextAndTranslate(Utility.fromHtml(html)) UtilityTTS.conditionalPlay(activityArguments, 2, applicationContext, html, "textscreen") } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/USAlertsDetailActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/USAlertsDetailActivity.kt index 8a648dcd..1a44b850 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/USAlertsDetailActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/USAlertsDetailActivity.kt @@ -63,7 +63,7 @@ class USAlertsDetailActivity : AudioPlayActivity(), OnMenuItemClickListener { } private fun getContent() = GlobalScope.launch(uiDispatcher) { - ca = withContext(Dispatchers.IO) { CAPAlert.createFromURL(activityArguments[0]) } + ca = withContext(Dispatchers.IO) { CAPAlert.createFromUrl(activityArguments[0]) } objAlerts.updateContent(ca, activityArguments[0]) toolbar.subtitle = objAlerts.wfoTitle title = objAlerts.title diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/USWarningsImpactActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/USWarningsImpactActivity.kt index b1e69f7a..b9a0397f 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/USWarningsImpactActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/USWarningsImpactActivity.kt @@ -53,7 +53,7 @@ class USWarningsImpactActivity : BaseActivity() { } private fun getContent() = GlobalScope.launch(uiDispatcher) { - warningsList = withContext(Dispatchers.IO) { UtilityWarningsImpact.impactWarningData } + warningsList = withContext(Dispatchers.IO) { UtilityWarningsImpact.data } val ca = AdapterUSWarningsImpact(warningsList) recyclerView.recyclerView.adapter = ca title = warningsList.size.toString() + " NWS warnings active " + diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/USWarningsWithRadarActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/USWarningsWithRadarActivity.kt index cf81b404..6b5ec86b 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/USWarningsWithRadarActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/USWarningsWithRadarActivity.kt @@ -148,7 +148,7 @@ class USWarningsWithRadarActivity : BaseActivity(), Toolbar.OnMenuItemClickListe val county = objAlertSummary.mapButtonCounty[id] if (zone!!.length > 3) { coord = if (zone.matches("[A-Z][A-Z]C.*?".toRegex())) { - UtilityLocation.getXYFromAddressOSM(county + "," + zone.substring(0, 2)) + UtilityLocation.getXYFromAddressOsm(county + "," + zone.substring(0, 2)) } else { UtilityDownloadNws.getLatLonForZone(zone) } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/UtilityWarningsImpact.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/UtilityWarningsImpact.kt index 54bb738e..5f508500 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/UtilityWarningsImpact.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/UtilityWarningsImpact.kt @@ -29,7 +29,7 @@ internal object UtilityWarningsImpact { // main site is http://www.weather.gov/crh/impact - val impactWarningData: List + val data: List get() { val warningsList = mutableListOf() val html = url.getHtmlSep() diff --git a/app/src/main/java/joshuatee/wx/audio/PlayAudioService.kt b/app/src/main/java/joshuatee/wx/audio/PlayAudioService.kt index 1e052463..83ca40e1 100644 --- a/app/src/main/java/joshuatee/wx/audio/PlayAudioService.kt +++ b/app/src/main/java/joshuatee/wx/audio/PlayAudioService.kt @@ -31,7 +31,7 @@ import android.content.Intent class PlayAudioService : IntentService("PlayAudioService") { override fun onHandleIntent(intent: Intent?) { - UtilityTTS.playAgainTTS(this) + UtilityTTS.playAgainTts(this) } } diff --git a/app/src/main/java/joshuatee/wx/audio/UtilityTTS.kt b/app/src/main/java/joshuatee/wx/audio/UtilityTTS.kt index 0e5afa06..34379295 100644 --- a/app/src/main/java/joshuatee/wx/audio/UtilityTTS.kt +++ b/app/src/main/java/joshuatee/wx/audio/UtilityTTS.kt @@ -52,7 +52,7 @@ object UtilityTTS { private var playlistNumber = 0 private var playlistArr = List(2) { "" } - fun initTTS(context: Context) { + fun initTts(context: Context) { // samsung bug, if users do not have google TTS selected it will crash - add try-catch so user can at least use rest of prog try { ttobjGlobal = TextToSpeech(context, TextToSpeech.OnInitListener { status -> @@ -63,13 +63,13 @@ object UtilityTTS { }) ttsInit = true } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } - internal fun playAgainTTS(context: Context) { + internal fun playAgainTts(context: Context) { if (!ttsInit) { - initTTS(context) + initTts(context) } ttobjGlobal!!.setSpeechRate(Utility.readPref(context, "TTS_SPEED_PREF", 10) / 10f) splitInChunks(Utility.fromHtml(TEXT_OLD), 1000).forEach { @@ -117,7 +117,7 @@ object UtilityTTS { playlistTotal = playlistArr.size currentFile = 0 ttsIsPaused = false - if (!ttsInit) initTTS(context) + if (!ttsInit) initTts(context) // clear the queue of any pending objects ttobjGlobal!!.stop() if (!mpInit) { @@ -151,7 +151,7 @@ object UtilityTTS { playlistTotal = playlistArr.size currentFile = 0 ttsIsPaused = false - if (!ttsInit) initTTS(context) + if (!ttsInit) initTts(context) // clear the queue of any pending objects ttobjGlobal!!.stop() if (!mpInit) { @@ -178,7 +178,7 @@ object UtilityTTS { } } - private fun synthesizeTextAndPlayPrevoius(context: Context) { + private fun synthesizeTextAndPlayPrevious(context: Context) { playlistArr = MyApplication.playlistStr.split(":") playlistNumber -= 1 if (playlistNumber == -1) playlistNumber = playlistArr.size - 1 @@ -186,7 +186,7 @@ object UtilityTTS { playlistTotal = playlistArr.size currentFile = 0 ttsIsPaused = false - if (!ttsInit) initTTS(context) + if (!ttsInit) initTts(context) // clear the queue of any pending objects ttobjGlobal!!.stop() if (!mpInit) { @@ -216,7 +216,7 @@ object UtilityTTS { playlistTotal = 1 currentFile = 0 ttsIsPaused = false - if (!ttsInit) initTTS(context) + if (!ttsInit) initTts(context) // clear the queue of any pending objects ttobjGlobal!!.stop() if (!mpInit) { @@ -242,7 +242,7 @@ object UtilityTTS { if (mMediaPlayer != null && mMediaPlayer!!.isPlaying) { mMediaPlayer!!.stop() } - txt = UtilityTTSTranslations.tranlasteAbbrev(txt) + txt = UtilityTTSTranslations.translateAbbreviation(txt) val myHashRender = HashMap() val musicDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC) val wxDir = File(musicDir, MyApplication.packageNameAsString) @@ -288,7 +288,7 @@ object UtilityTTS { internal fun mediaPlayerRewind(context: Context) { if (mpInit) { if (mMediaPlayer!!.currentPosition < 10000) { - synthesizeTextAndPlayPrevoius(context) + synthesizeTextAndPlayPrevious(context) } else { playMediaPlayerFile(context, 0) currentFile += 1 @@ -311,7 +311,7 @@ object UtilityTTS { mMediaPlayer?.prepare() mMediaPlayer?.start() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } diff --git a/app/src/main/java/joshuatee/wx/audio/UtilityTTSTranslations.kt b/app/src/main/java/joshuatee/wx/audio/UtilityTTSTranslations.kt index 65ec7120..d580ccaf 100644 --- a/app/src/main/java/joshuatee/wx/audio/UtilityTTSTranslations.kt +++ b/app/src/main/java/joshuatee/wx/audio/UtilityTTSTranslations.kt @@ -25,7 +25,8 @@ import java.util.Locale object UtilityTTSTranslations { - internal fun tranlasteAbbrev(sF: String): String { + // FIXME rename method arg + internal fun translateAbbreviation(sF: String): String { // http://www.spc.noaa.gov/misc/acronyms.html val s = sF.replace("...", " ") .replace(" \\-([0-9])".toRegex(), " negative $1") @@ -58,15 +59,15 @@ object UtilityTTSTranslations { // .replace(">", " ") .replace("$$", " ") - return tranlasteAbbrevChunk(s) + return translateAbbreviationChunk(s) } - fun tranlasteAbbrevForVisual(sF: String): String { + fun translateAbbreviationsForVisual(sF: String): String { val s = sF.replace(" ", " ") - return tranlasteAbbrevChunk(s) + return translateAbbreviationChunk(s) } - private fun tranlasteAbbrevChunk(sF: String): String { + private fun translateAbbreviationChunk(sF: String): String { var s = sF.toUpperCase(Locale.US) s = s.replace(" SVR ", " severe ") .replace(" TSTM ", " thunderstorm ") diff --git a/app/src/main/java/joshuatee/wx/audio/UtilityVoiceCommand.kt b/app/src/main/java/joshuatee/wx/audio/UtilityVoiceCommand.kt index f337b74b..ef4dbde1 100644 --- a/app/src/main/java/joshuatee/wx/audio/UtilityVoiceCommand.kt +++ b/app/src/main/java/joshuatee/wx/audio/UtilityVoiceCommand.kt @@ -90,9 +90,6 @@ object UtilityVoiceCommand { ) } } else if (vrString.contains("cloud")) { - //if (tokens.size > 1) { - // nws1Current = tokens[1] - //} ObjectIntent( context, GOES16Activity::class.java, diff --git a/app/src/main/java/joshuatee/wx/canada/CanadaRadarActivity.kt b/app/src/main/java/joshuatee/wx/canada/CanadaRadarActivity.kt index 9b3f0ace..dcf2389f 100644 --- a/app/src/main/java/joshuatee/wx/canada/CanadaRadarActivity.kt +++ b/app/src/main/java/joshuatee/wx/canada/CanadaRadarActivity.kt @@ -107,15 +107,15 @@ class CanadaRadarActivity : VideoRecordActivity(), OnClickListener, OnItemSelect title = "Canada" imageMap = ObjectImageMap(this, this, R.id.map, toolbar, toolbarBottom, listOf(img.img)) - imageMap.addClickHandler(::ridMapSwitch, UtilityImageMap::maptoCARid) + imageMap.addClickHandler(::ridMapSwitch, UtilityImageMap::mapToCanadaRadarSite) ridFav = Utility.readPref(this, "RID_CA_FAV", " : : :") - ridArrLoc = UtilityFavorites.setupFavMenuCA(ridFav, rid1) + ridArrLoc = UtilityFavorites.setupFavMenuCanada(ridFav, rid1) sp = ObjectSpinner(this, this, this, R.id.spinner1, ridArrLoc) } override fun onRestart() { ridFav = Utility.readPref(this, "RID_CA_FAV", " : : :") - ridArrLoc = UtilityFavorites.setupFavMenuCA(ridFav, rid1) + ridArrLoc = UtilityFavorites.setupFavMenuCanada(ridFav, rid1) sp.refreshData(this, ridArrLoc) super.onRestart() } @@ -216,14 +216,14 @@ class CanadaRadarActivity : VideoRecordActivity(), OnClickListener, OnItemSelect imageType = "rad" rid1 = r img.resetZoom() - ridArrLoc = UtilityFavorites.setupFavMenuCA(ridFav, r) + ridArrLoc = UtilityFavorites.setupFavMenuCanada(ridFav, r) sp.refreshData(this, ridArrLoc) } private fun getAnimate(frameCountStr: String) = GlobalScope.launch(uiDispatcher) { withContext(Dispatchers.IO) { animDrawable = if (imageType == "vis" || imageType == "wv" || imageType == "ir") { - UtilityCanadaImg.getGOESAnim(contextg, url) + UtilityCanadaImg.getGoesAnimation(contextg, url) } else { if (!mosaicShown) UtilityCanadaImg.getRadarAnimOptionsApplied(contextg, rad, frameCountStr) @@ -234,12 +234,12 @@ class CanadaRadarActivity : VideoRecordActivity(), OnClickListener, OnItemSelect animRan = UtilityImgAnim.startAnimation(animDrawable, img) } - override fun onItemSelected(parent: AdapterView<*>, view: View?, pos: Int, id: Long) { + override fun onItemSelected(parent: AdapterView<*>, view: View?, position: Int, id: Long) { if (firstTime) { UtilityToolbar.fullScreenMode(toolbar, toolbarBottom) firstTime = false } - when (pos) { + when (position) { 1 -> ObjectIntent( contextg, FavAddActivity::class.java, @@ -253,8 +253,8 @@ class CanadaRadarActivity : VideoRecordActivity(), OnClickListener, OnItemSelect arrayOf("RIDCA") ) else -> { - if (ridArrLoc[pos].length > 3) { - rad = UtilityStringExternal.truncate(ridArrLoc[pos], 3) + if (ridArrLoc[position].length > 3) { + rad = UtilityStringExternal.truncate(ridArrLoc[position], 3) mosaicShown = false img.resetZoom() getContent() @@ -262,7 +262,7 @@ class CanadaRadarActivity : VideoRecordActivity(), OnClickListener, OnItemSelect mosaicShown = true img.resetZoom() if (imageType == "rad") { - getMosaic(ridArrLoc[pos]) + getMosaic(ridArrLoc[position]) } else { getContent() } @@ -281,7 +281,7 @@ class CanadaRadarActivity : VideoRecordActivity(), OnClickListener, OnItemSelect private fun toggleFavorite() { ridFav = UtilityFavorites.toggleFavoriteString(this, rid1, star, "RID_CA_FAV") - ridArrLoc = UtilityFavorites.setupFavMenuCA(ridFav, rid1) + ridArrLoc = UtilityFavorites.setupFavMenuCanada(ridFav, rid1) sp.refreshData(this, ridArrLoc) } diff --git a/app/src/main/java/joshuatee/wx/canada/CanadaTextActivity.kt b/app/src/main/java/joshuatee/wx/canada/CanadaTextActivity.kt index e6acc436..e4ca32e9 100644 --- a/app/src/main/java/joshuatee/wx/canada/CanadaTextActivity.kt +++ b/app/src/main/java/joshuatee/wx/canada/CanadaTextActivity.kt @@ -72,7 +72,7 @@ class CanadaTextActivity : AudioPlayActivity(), OnMenuItemClickListener { if (prod != "https://weather.gc.ca/forecast/public_bulletins_e.html?Bulletin=fpcn48.cwao") { UtilityDownload.getTextProduct(contextg, prod) } else { - UtilityString.getHTMLandParseSep(prod, "
(.*?)
") + UtilityString.getHtmlAndParseSep(prod, "
(.*?)
") } } c0.setTextAndTranslate(Utility.fromHtml(html)) diff --git a/app/src/main/java/joshuatee/wx/canada/UtilityCanada.kt b/app/src/main/java/joshuatee/wx/canada/UtilityCanada.kt index 193f15d0..e265d4ce 100644 --- a/app/src/main/java/joshuatee/wx/canada/UtilityCanada.kt +++ b/app/src/main/java/joshuatee/wx/canada/UtilityCanada.kt @@ -32,7 +32,7 @@ import joshuatee.wx.radar.LatLon object UtilityCanada { - private val provToSector = mapOf( + private val providenceToSector = mapOf( "AB" to "PAC", "BC" to "PAC", "MB" to "PAC", @@ -56,7 +56,7 @@ object UtilityCanada { return iconList } - fun getIcons7DayAl(html: String): List { + fun getIcons7DayAsList(html: String): List { val dayAr = html.split((MyApplication.newline + MyApplication.newline)) .dropLastWhile { it.isEmpty() } return dayAr.mapTo(mutableListOf()) { translateIconName(it) } @@ -258,7 +258,7 @@ object UtilityCanada { return newName } - fun getProvHTML(prov: String): String = + fun getProvidenceHtml(prov: String): String = ("http://weather.gc.ca/forecast/canada/index_e.html?id=$prov").getHtmlSep() fun getLocationHtml(location: LatLon): String { @@ -385,7 +385,7 @@ object UtilityCanada { return warningData } - fun getECSectorFromProv(prov: String): String = provToSector[prov] ?: "" + fun getECSectorFromProv(prov: String): String = providenceToSector[prov] ?: "" fun isLabelPresent(label: String): Boolean { if (!UtilityCitiesCA.cityInit) { diff --git a/app/src/main/java/joshuatee/wx/canada/UtilityCanadaImg.kt b/app/src/main/java/joshuatee/wx/canada/UtilityCanadaImg.kt index 93b46f79..ac683069 100644 --- a/app/src/main/java/joshuatee/wx/canada/UtilityCanadaImg.kt +++ b/app/src/main/java/joshuatee/wx/canada/UtilityCanadaImg.kt @@ -38,7 +38,7 @@ import joshuatee.wx.objects.GeographyType object UtilityCanadaImg { - internal fun getGOESAnim(context: Context, url: String): AnimationDrawable { + internal fun getGoesAnimation(context: Context, url: String): AnimationDrawable { val region = url.parse("goes_(.*?)_") val imgType = url.parse("goes_.*?_(.*?)_") val urlAnim = @@ -55,7 +55,7 @@ object UtilityCanadaImg { "_" ).replace("/", "@") + ".jpg" } - return UtilityImgAnim.getAnimationDrawableFromURLList(context, urlAl, delay) + return UtilityImgAnim.getAnimationDrawableFromUrlList(context, urlAl, delay) } private fun getRadarAnimStringArray(rid: String, duration: String): String { @@ -218,7 +218,7 @@ object UtilityCanadaImg { val urlAl = urlArr.mapTo(mutableListOf()) { "http://weather.gc.ca" + it.replace("detailed/", "") } urlAl.reverse() - return UtilityImgAnim.getAnimationDrawableFromURLList( + return UtilityImgAnim.getAnimationDrawableFromUrlList( context, urlAl, UtilityImg.animInterval(context) diff --git a/app/src/main/java/joshuatee/wx/external/ExternalGifDecoder.java b/app/src/main/java/joshuatee/wx/external/ExternalGifDecoder.java index a9093ba8..94105755 100644 --- a/app/src/main/java/joshuatee/wx/external/ExternalGifDecoder.java +++ b/app/src/main/java/joshuatee/wx/external/ExternalGifDecoder.java @@ -264,7 +264,7 @@ public int read(InputStream is) { try { is.close(); } catch (Exception e) { - UtilityLog.INSTANCE.HandleException(e); + UtilityLog.INSTANCE.handleException(e); } return status; } diff --git a/app/src/main/java/joshuatee/wx/fragments/LocationFragment.kt b/app/src/main/java/joshuatee/wx/fragments/LocationFragment.kt index 90175822..0c1895f2 100644 --- a/app/src/main/java/joshuatee/wx/fragments/LocationFragment.kt +++ b/app/src/main/java/joshuatee/wx/fragments/LocationFragment.kt @@ -82,10 +82,8 @@ class LocationFragment : Fragment(), OnItemSelectedListener, OnClickListener { private var y = "" private var ts = "" private var glviewInitialized = false - private var hazardsSum = "" private var currentLoc = -1 private var sevenDayExtShown = false - private var hazardRaw = "" private lateinit var dataAdapter: ArrayAdapter private lateinit var intent: Intent private var locationCard: CardView? = null @@ -112,7 +110,7 @@ class LocationFragment : Fragment(), OnItemSelectedListener, OnClickListener { private var linearLayoutForecast: LinearLayout? = null // hazards private var linearLayoutHazards: LinearLayout? = null - private val hazardsCardAl = mutableListOf() + private val hazardsCards = mutableListOf() private val hazardsExpandedAl = mutableListOf() private var dataNotInitialized = true private var alertDialogStatus: ObjectDialogue? = null @@ -120,9 +118,9 @@ class LocationFragment : Fragment(), OnItemSelectedListener, OnClickListener { private var idxIntG = 0 private var alertDialogRadarLongPress: ObjectDialogue? = null private val alertDialogRadarLongpressAl = mutableListOf() - private var objCc: ObjectForecastPackageCurrentConditions? = null - private var objHazards: ObjectForecastPackageHazards? = null - private var objSevenDay: ObjectForecastPackage7Day? = null + private var objCc = ObjectForecastPackageCurrentConditions() + private var objHazards = ObjectForecastPackageHazards() + private var objSevenDay = ObjectForecastPackage7Day() private var locationChangedSevenDay = false private var locationChangedHazards = false private var numPanesArr = listOf() @@ -633,15 +631,6 @@ class LocationFragment : Fragment(), OnItemSelectedListener, OnClickListener { GOES16Activity.RID, arrayOf("") ) - /*ObjectIntent( - activityReference, - USNWSGOESActivity::class.java, - USNWSGOESActivity.RID, - arrayOf( - "nws", - hsImageAl[ii].product.replace("IMG-", "").toLowerCase(Locale.US) - ) - )*/ } }) } @@ -676,36 +665,37 @@ class LocationFragment : Fragment(), OnItemSelectedListener, OnClickListener { private fun setupHazardCardsCA(hazUrl: String) { linearLayoutHazards?.removeAllViews() hazardsExpandedAl.clear() - hazardsCardAl.clear() + hazardsCards.clear() hazardsExpandedAl.add(false) - hazardsCardAl.add(ObjectCardText(activityReference)) - hazardsCardAl[0].setTextSize(TypedValue.COMPLEX_UNIT_PX, MyApplication.textSizeNormal) - hazardsCardAl[0].setTextColor(UIPreferences.textHighlightColor) - hazardsCardAl[0].setText(hazUrl) + hazardsCards.add(ObjectCardText(activityReference)) + hazardsCards[0].setPaddingAmount(MyApplication.paddingSettings) + hazardsCards[0].setTextSize(TypedValue.COMPLEX_UNIT_PX, MyApplication.textSizeNormal) + hazardsCards[0].setTextColor(UIPreferences.textHighlightColor) + hazardsCards[0].setText(hazUrl) val expandIndexCa = 0 - val hazUrlCa = objHazards?.hazards ?: "" - val hazardsSumCa = objHazards?.getHazardsShort() ?: "" - hazardsCardAl[0].setOnClickListener(OnClickListener { + val hazUrlCa = objHazards.hazards + val hazardsSumCa = objHazards.getHazardsShort() + hazardsCards[0].setOnClickListener(OnClickListener { if (!hazardsExpandedAl[expandIndexCa]) { - hazardsCardAl[expandIndexCa].setTextColor(UIPreferences.backgroundColor) - hazardsCardAl[expandIndexCa].setTextSize( + hazardsCards[expandIndexCa].setTextColor(UIPreferences.backgroundColor) + hazardsCards[expandIndexCa].setTextSize( TypedValue.COMPLEX_UNIT_PX, MyApplication.textSizeSmall ) - hazardsCardAl[expandIndexCa].setText(Utility.fromHtml(hazUrlCa)) + hazardsCards[expandIndexCa].setText(Utility.fromHtml(hazUrlCa)) hazardsExpandedAl[expandIndexCa] = true } else { - hazardsCardAl[expandIndexCa].setTextColor(UIPreferences.textHighlightColor) - hazardsCardAl[expandIndexCa].setTextSize( + hazardsCards[expandIndexCa].setTextColor(UIPreferences.textHighlightColor) + hazardsCards[expandIndexCa].setTextSize( TypedValue.COMPLEX_UNIT_PX, MyApplication.textSizeNormal ) - hazardsCardAl[expandIndexCa].setText(hazardsSumCa) + hazardsCards[expandIndexCa].setText(hazardsSumCa) hazardsExpandedAl[expandIndexCa] = false scrollView.smoothScrollTo(0, 0) } }) - linearLayoutHazards?.addView(hazardsCardAl[0].card) + linearLayoutHazards?.addView(hazardsCards[0].card) } private fun setupAlertDialogStatus() { @@ -805,27 +795,26 @@ class LocationFragment : Fragment(), OnItemSelectedListener, OnClickListener { return mActivity!! } - private fun setupHazardCards(hazStr: String, idAl: List) { + private fun setupHazardCards() { linearLayoutHazards?.removeAllViews() hazardsExpandedAl.clear() - hazardsCardAl.clear() - val tmpArr = hazStr.split(MyApplication.newline).dropLastWhile { it.isEmpty() } - tmpArr.indices.forEach { z -> + hazardsCards.clear() + objHazards.titles.indices.forEach { z -> hazardsExpandedAl.add(false) - hazardsCardAl.add(ObjectCardText(activityReference)) - hazardsCardAl[z].setTextSize(TypedValue.COMPLEX_UNIT_PX, MyApplication.textSizeNormal) - hazardsCardAl[z].setTextColor(UIPreferences.textHighlightColor) - hazardsCardAl[z].setText(tmpArr[z].toUpperCase(Locale.US)) - val url = idAl[z] - hazardsCardAl[z].setOnClickListener(OnClickListener { + hazardsCards.add(ObjectCardText(activityReference)) + hazardsCards[z].setPaddingAmount(MyApplication.paddingSettings) + hazardsCards[z].setTextSize(TypedValue.COMPLEX_UNIT_PX, MyApplication.textSizeNormal) + hazardsCards[z].setTextColor(UIPreferences.textHighlightColor) + hazardsCards[z].setText(objHazards.titles[z].toUpperCase(Locale.US)) + hazardsCards[z].setOnClickListener(OnClickListener { ObjectIntent( activityReference, USAlertsDetailActivity::class.java, USAlertsDetailActivity.URL, - arrayOf(url) + arrayOf(objHazards.urls[z]) ) }) - linearLayoutHazards?.addView(hazardsCardAl[z].card) + linearLayoutHazards?.addView(hazardsCards[z].card) } } @@ -836,75 +825,72 @@ class LocationFragment : Fragment(), OnItemSelectedListener, OnClickListener { } private fun getLocationForecast() = GlobalScope.launch(uiDispatcher) { - var bmCc: Bitmap? = null + var bitmapForCurrentConditions: Bitmap? = null // // Current Conditions // withContext(Dispatchers.IO) { try { - objCc = - Utility.getCurrentConditions(activityReference, Location.currentLocation) + objCc = ObjectForecastPackageCurrentConditions(activityReference, Location.currentLocation) if (homescreenFavLocal.contains("TXT-CC2")) { - bmCc = if (Location.isUS) { - UtilityNWS.getIcon(activityReference, objCc!!.iconUrl) + bitmapForCurrentConditions = if (Location.isUS) { + UtilityNWS.getIcon(activityReference, objCc.iconUrl) } else { UtilityNWS.getIcon( activityReference, UtilityCanada.translateIconNameCurrentConditions( - objCc!!.data1, - objCc!!.status + objCc.data, + objCc.status ) ) } } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } if (isAdded) { // // Current Conditions // - objCc?.let { _ -> - cardCC?.let { - if (homescreenFavLocal.contains("TXT-CC2")) { - ccTime = objCc!!.status - if (bmCc != null) { - it.updateContent( - bmCc!!, - objCc!!, - Location.isUS, - ccTime, - radarTime - ) - } - } else { - it.setTopLine(objCc!!.data1) - ccTime = objCc!!.status - it.setStatus(ccTime + radarTime) + cardCC?.let { + if (homescreenFavLocal.contains("TXT-CC2")) { + ccTime = objCc.status + if (bitmapForCurrentConditions != null) { + it.updateContent( + bitmapForCurrentConditions!!, + objCc, + Location.isUS, + ccTime, + radarTime + ) } + } else { + it.setTopLine(objCc.data) + ccTime = objCc.status + it.setStatus(ccTime + radarTime) } } } } private fun getLocationForecastSevenDay() = GlobalScope.launch(uiDispatcher) { - val bmArr = mutableListOf() + val bitmaps = mutableListOf() if (locationChangedSevenDay) { linearLayoutForecast?.removeAllViewsInLayout() locationChangedSevenDay = false } withContext(Dispatchers.IO) { try { - objSevenDay = Utility.getCurrentSevenDay(Location.currentLocation) - Utility.writePref(activityReference, "FCST", objSevenDay?.sevenDayExtStr ?: "") + objSevenDay = ObjectForecastPackage7Day(Location.currentLocation) + Utility.writePref(activityReference, "FCST", objSevenDay.sevenDayLong) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } try { - Utility.writePref(activityReference, "FCST", objSevenDay?.sevenDayExtStr ?: "") + Utility.writePref(activityReference, "FCST", objSevenDay.sevenDayLong) if (homescreenFavLocal.contains("TXT-7DAY")) { - objSevenDay!!.iconAl.mapTo(bmArr) { + objSevenDay.icons.mapTo(bitmaps) { UtilityNWS.getIcon( activityReference, it @@ -912,55 +898,52 @@ class LocationFragment : Fragment(), OnItemSelectedListener, OnClickListener { } } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } if (isAdded) { - objSevenDay?.let { _ -> - if (homescreenFavLocal.contains("TXT-7DAY")) { - linearLayoutForecast?.removeAllViewsInLayout() - val day7Arr = objSevenDay!!.fcstList - bmArr.forEachIndexed { idx, bm -> - val c7day = - ObjectCard7Day(activityReference, bm, Location.isUS, idx, day7Arr) - c7day.setOnClickListener(OnClickListener { - scrollView.smoothScrollTo( - 0, - 0 - ) - }) - linearLayoutForecast?.addView(c7day.card) - } - // sunrise card - val cardSunrise = ObjectCardText(activityReference) - cardSunrise.center() - cardSunrise.setOnClickListener(OnClickListener { + if (homescreenFavLocal.contains("TXT-7DAY")) { + linearLayoutForecast?.removeAllViewsInLayout() + val day7Arr = objSevenDay.forecastList + bitmaps.forEachIndexed { index, bitmap -> + val c7day = ObjectCard7Day(activityReference, bitmap, Location.isUS, index, day7Arr) + c7day.setOnClickListener(OnClickListener { scrollView.smoothScrollTo( 0, 0 ) }) - try { - if (Location.isUS) { - cardSunrise.setText( - UtilityDownload.getSunriseSunset( - activityReference, - Location.currentLocationStr - ) + MyApplication.newline + UtilityTime.gmtTime() - ) - } else { - cardSunrise.setText( - UtilityDownload.getSunriseSunset( - activityReference, - Location.currentLocationStr - ) + MyApplication.newline + UtilityTime.gmtTime() - ) - } - } catch (e: Exception) { - UtilityLog.HandleException(e) + linearLayoutForecast?.addView(c7day.card) + } + // sunrise card + val cardSunrise = ObjectCardText(activityReference) + cardSunrise.center() + cardSunrise.setOnClickListener(OnClickListener { + scrollView.smoothScrollTo( + 0, + 0 + ) + }) + try { + if (Location.isUS) { + cardSunrise.setText( + UtilityTimeSunMoon.getSunriseSunset( + activityReference, + Location.currentLocationStr + ) + MyApplication.newline + UtilityTime.gmtTime() + ) + } else { + cardSunrise.setText( + UtilityTimeSunMoon.getSunriseSunset( + activityReference, + Location.currentLocationStr + ) + MyApplication.newline + UtilityTime.gmtTime() + ) } - linearLayoutForecast?.addView(cardSunrise.card) + } catch (e: Exception) { + UtilityLog.handleException(e) } + linearLayoutForecast?.addView(cardSunrise.card) } // // Canada legal card @@ -985,19 +968,20 @@ class LocationFragment : Fragment(), OnItemSelectedListener, OnClickListener { } withContext(Dispatchers.IO) { try { - objHazards = Utility.getCurrentHazards(Location.currentLocation) - hazardRaw = objHazards?.hazards ?: "" + //objHazards = Utility.getCurrentHazards(Location.currentLocation) + objHazards = if (Location.isUS(Location.currentLocation)) { + ObjectForecastPackageHazards(Location.currentLocation) + } else { + val html = UtilityCanada.getLocationHtml(Location.getLatLon(Location.currentLocation)) + ObjectForecastPackageHazards(html) + } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } if (isAdded) { if (Location.isUS) { - var hazardSumAsync = "" - val idAl = hazardRaw.parseColumn("\"id\": \"(http.*?)\"") - val hazardTitles = hazardRaw.parseColumn("\"event\": \"(.*?)\"") - hazardTitles.forEach { hazardSumAsync += it + MyApplication.newline } - if (hazardSumAsync == "") { + if (objHazards.titles.isEmpty()) { if (homescreenFavLocal.contains("TXT-HAZ")) { linearLayoutHazards?.removeAllViews() linearLayoutHazards?.visibility = View.GONE @@ -1005,18 +989,15 @@ class LocationFragment : Fragment(), OnItemSelectedListener, OnClickListener { } else { if (homescreenFavLocal.contains("TXT-HAZ")) { linearLayoutHazards?.visibility = View.VISIBLE - setupHazardCards(hazardSumAsync, idAl) + setupHazardCards() } } - hazardsSum = hazardSumAsync } else { - objCc?.let { - if (objHazards?.getHazardsShort() != "") { - hazardsSum = objHazards!!.getHazardsShort().toUpperCase(Locale.US) - if (homescreenFavLocal.contains("TXT-HAZ")) { - linearLayoutHazards?.visibility = View.VISIBLE - setupHazardCardsCA(hazardsSum) - } + if (objHazards.getHazardsShort() != "") { + val hazardsSum = objHazards.getHazardsShort().toUpperCase(Locale.US) + if (homescreenFavLocal.contains("TXT-HAZ")) { + linearLayoutHazards?.visibility = View.VISIBLE + setupHazardCardsCA(hazardsSum) } } } diff --git a/app/src/main/java/joshuatee/wx/fragments/UtilityLocationFragment.kt b/app/src/main/java/joshuatee/wx/fragments/UtilityLocationFragment.kt index 40688734..b497e246 100644 --- a/app/src/main/java/joshuatee/wx/fragments/UtilityLocationFragment.kt +++ b/app/src/main/java/joshuatee/wx/fragments/UtilityLocationFragment.kt @@ -58,21 +58,21 @@ object UtilityLocationFragment { fun extract7DayMetrics(chunk: String): String { val spacing = " " // wind 24 to 29 mph - val wind = UtilityString.parseMultipe(chunk, RegExp.sevenDayWind1, 2) + val wind = UtilityString.parseMultiple(chunk, RegExp.sevenDayWind1, 2) // wind around 9 mph val wind2 = chunk.parse(RegExp.sevenDayWind2) // 5 to 10 mph after - val wind3 = UtilityString.parseMultipe(chunk, RegExp.sevenDayWind4, 2) + val wind3 = UtilityString.parseMultiple(chunk, RegExp.sevenDayWind4, 2) // around 5 mph after val wind4 = chunk.parse(RegExp.sevenDayWind5) // 5 to 7 mph in - val wind5 = UtilityString.parseMultipe(chunk, RegExp.sevenDayWind6, 2) + val wind5 = UtilityString.parseMultiple(chunk, RegExp.sevenDayWind6, 2) // around 6 mph. val wind7 = chunk.parse(RegExp.sevenDayWind7) // with gusts as high as 21 mph var gust = chunk.parse(RegExp.sevenDayWind3) // 5 to 7 mph. - val wind9 = UtilityString.parseMultipe(chunk, RegExp.sevenDayWind9, 2) + val wind9 = UtilityString.parseMultiple(chunk, RegExp.sevenDayWind9, 2) // Winds could gusts as high as 21 mph. if (gust == "") { gust = chunk.parse(RegExp.sevenDayWind8) @@ -101,26 +101,26 @@ object UtilityLocationFragment { } } - fun setNWSIconSize(): Int = + fun setNwsIconSize(): Int = (MyApplication.dm.widthPixels * (MyApplication.nwsIconSize / 100f)).toInt() fun extractWindDirection(chunk: String): String { - val winddir1 = chunk.parseLastMatch(RegExp.sevenDayWinddir1) - val winddir2 = chunk.parseLastMatch(RegExp.sevenDayWinddir2) - val winddir3 = chunk.parseLastMatch(RegExp.sevenDayWinddir3) - val winddir4 = chunk.parseLastMatch(RegExp.sevenDayWinddir4) - val winddir5 = chunk.parseLastMatch(RegExp.sevenDayWinddir5) - val winddir6 = chunk.parseLastMatch(RegExp.sevenDayWinddir6) - val winddir7 = chunk.parseLastMatch(RegExp.sevenDayWinddir7) + val windDir1 = chunk.parseLastMatch(RegExp.sevenDayWinddir1) + val windDir2 = chunk.parseLastMatch(RegExp.sevenDayWinddir2) + val windDir3 = chunk.parseLastMatch(RegExp.sevenDayWinddir3) + val windDir4 = chunk.parseLastMatch(RegExp.sevenDayWinddir4) + val windDir5 = chunk.parseLastMatch(RegExp.sevenDayWinddir5) + val windDir6 = chunk.parseLastMatch(RegExp.sevenDayWinddir6) + val windDir7 = chunk.parseLastMatch(RegExp.sevenDayWinddir7) var retStr = "" when { - winddir4 != "" -> retStr = winddir4 - winddir3 != "" -> retStr = winddir3 - winddir2 != "" -> retStr = winddir2 - winddir1 != "" -> retStr = winddir1 - winddir5 != "" -> retStr = winddir5 - winddir6 != "" -> retStr = winddir6 - winddir7 != "" -> retStr = winddir7 + windDir4 != "" -> retStr = windDir4 + windDir3 != "" -> retStr = windDir3 + windDir2 != "" -> retStr = windDir2 + windDir1 != "" -> retStr = windDir1 + windDir5 != "" -> retStr = windDir5 + windDir6 != "" -> retStr = windDir6 + windDir7 != "" -> retStr = windDir7 } return if (retStr == "") { "" @@ -134,7 +134,7 @@ object UtilityLocationFragment { } } - fun extractTemp(blob: String): String { + fun extractTemperature(blob: String): String { var temp = blob.parse(RegExp.nws7DayTemp1) if (temp != "") { return temp @@ -182,7 +182,7 @@ object UtilityLocationFragment { return temp } - fun extractCATemp(blob: String): String { + fun extractCanadaTemperature(blob: String): String { var temp = blob.parse(RegExp.ca7DayTemp1) if (temp != "") return temp.replace("minus ", "-") temp = blob.parse(RegExp.ca7DayTemp2) @@ -230,7 +230,7 @@ object UtilityLocationFragment { return temp } - fun extractCAWindDir(fcst: String): String { + fun extractCanadaWindDirection(fcst: String): String { var wdir = fcst.parse(RegExp.ca7DayWinddir1) if (wdir == "") wdir = fcst.parse(RegExp.ca7DayWinddir2) @@ -239,12 +239,12 @@ object UtilityLocationFragment { return wdir } - fun extractCAWindSpeed(fcst: String): String { - val wspdRange = UtilityString.parseMultipe(fcst, RegExp.ca7DayWindspd1, 2) - val wspd = fcst.parse(RegExp.ca7DayWindspd2) + fun extractCanadaWindSpeed(forecast: String): String { + val wspdRange = UtilityString.parseMultiple(forecast, RegExp.ca7DayWindspd1, 2) + val wspd = forecast.parse(RegExp.ca7DayWindspd2) var gust = "" - if (fcst.contains("gusting")) { - gust = " G " + fcst.parse(RegExp.ca7DayWindspd3) + if (forecast.contains("gusting")) { + gust = " G " + forecast.parse(RegExp.ca7DayWindspd3) } if (wspdRange.size > 1 && wspdRange[0] != "" && wspdRange[1] != "") { return " " + wspdRange[0] + "-" + wspdRange[1] + gust + " km/h" diff --git a/app/src/main/java/joshuatee/wx/fragments/UtilityNWS.kt b/app/src/main/java/joshuatee/wx/fragments/UtilityNWS.kt index 0e547757..5645c05d 100644 --- a/app/src/main/java/joshuatee/wx/fragments/UtilityNWS.kt +++ b/app/src/main/java/joshuatee/wx/fragments/UtilityNWS.kt @@ -33,8 +33,10 @@ import joshuatee.wx.util.UtilityImg object UtilityNWS { + // FIXME better var naming in this class + fun getIcon(context: Context, url: String): Bitmap { - val bm: Bitmap + val bitmap: Bitmap if (url == "NULL") { return Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888) } @@ -49,28 +51,28 @@ object UtilityNWS { .replace("/", "/n") } val fnResId = UtilityNwsIcon.iconMap["$fn.png"] - bm = if (fnResId == null || fn.contains(",")) { + bitmap = if (fnResId == null || fn.contains(",")) { parseBitmap(context, fn) } else { UtilityImg.loadBitmap(context, fnResId, false) } - return bm + return bitmap } private fun parseBitmap(context: Context, url: String): Bitmap { - val bm: Bitmap - val tmpArr: List + val bitmap: Bitmap + val conditions: List if (url.contains("/")) { - tmpArr = url.split("/").dropLastWhile { it.isEmpty() } // snow,20/ovc,20 - bm = if (tmpArr.size > 1) { - dualBitmapWithNumbers(context, tmpArr[0], tmpArr[1]) + conditions = url.split("/").dropLastWhile { it.isEmpty() } // snow,20/ovc,20 + bitmap = if (conditions.size > 1) { + dualBitmapWithNumbers(context, conditions[0], conditions[1]) } else { UtilityImg.getBlankBitmap() } } else { - bm = dualBitmapWithNumbers(context, url) + bitmap = dualBitmapWithNumbers(context, url) } - return bm + return bitmap } private fun dualBitmapWithNumbers(context: Context, aF: String, bF: String): Bitmap { @@ -100,13 +102,13 @@ object UtilityNWS { if (b.contains("fg")) { leftCropB = 45 } - val bm = Bitmap.createBitmap(dimens, dimens, Bitmap.Config.ARGB_8888) - val canvas = Canvas(bm) + val bitmap = Bitmap.createBitmap(dimens, dimens, Bitmap.Config.ARGB_8888) + val canvas = Canvas(bitmap) canvas.drawColor(UtilityTheme.primaryColorFromSelectedTheme) val fnResId1 = UtilityNwsIcon.iconMap["$a.png"] val fnResId2 = UtilityNwsIcon.iconMap["$b.png"] if (fnResId1 == null || fnResId2 == null) { - return bm + return bitmap } val bm1Tmp = UtilityImg.loadBitmap(context, fnResId1, false) val bm1 = Bitmap.createBitmap(bm1Tmp, leftCropA, 0, 41, dimens) @@ -142,7 +144,7 @@ object UtilityNWS { ) canvas.drawText("$num2%", xText.toFloat(), yText.toFloat(), paint.paint) } - return bm + return bitmap } private fun dualBitmapWithNumbers(context: Context, aF: String): Bitmap { @@ -157,10 +159,10 @@ object UtilityNWS { } val dimens = 86 val numHeight = 15 - val bm = Bitmap.createBitmap(dimens, dimens, Bitmap.Config.ARGB_8888) - val canvas = Canvas(bm) + val bitmap = Bitmap.createBitmap(dimens, dimens, Bitmap.Config.ARGB_8888) + val canvas = Canvas(bitmap) canvas.drawColor(UtilityTheme.primaryColorFromSelectedTheme) - val fnResId1 = UtilityNwsIcon.iconMap["$a.png"] ?: return bm + val fnResId1 = UtilityNwsIcon.iconMap["$a.png"] ?: return bitmap val bm1Tmp = UtilityImg.loadBitmap(context, fnResId1, false) val bm1 = Bitmap.createBitmap(bm1Tmp, 0, 0, dimens, dimens) // was 41,dimens canvas.drawBitmap(bm1, 0f, 0f, Paint(Paint.FILTER_BITMAP_FLAG)) @@ -181,7 +183,7 @@ object UtilityNWS { ) canvas.drawText("$num1%", xText.toFloat(), yText.toFloat(), paint.paint) } - return bm + return bitmap } } diff --git a/app/src/main/java/joshuatee/wx/fragments/ViewPagerAdapter.kt b/app/src/main/java/joshuatee/wx/fragments/ViewPagerAdapter.kt index 812e04f5..204eb520 100644 --- a/app/src/main/java/joshuatee/wx/fragments/ViewPagerAdapter.kt +++ b/app/src/main/java/joshuatee/wx/fragments/ViewPagerAdapter.kt @@ -8,7 +8,6 @@ import joshuatee.wx.MyApplication class ViewPagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) { - //val tabTitles: Array = arrayOf("LOCAL", "SPC", "MISC", "IMAGE") val tabTitles: Array = arrayOf("LOCAL", "SPC", "MISC") override fun getCount(): Int { @@ -26,7 +25,6 @@ class ViewPagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) { 0 -> return LocationFragment() 1 -> return SPCFragment() 2 -> return MiscFragment() - //3 -> return ImagesFragmentGOES() } } return null @@ -34,7 +32,6 @@ class ViewPagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) { override fun getPageTitle(position: Int): CharSequence { tabTitles[0] = MyApplication.tabHeaders[0] - //tabTitles[3] = MyApplication.tabHeaders[3] return tabTitles[position] } diff --git a/app/src/main/java/joshuatee/wx/models/ModelsGenericActivity.kt b/app/src/main/java/joshuatee/wx/models/ModelsGenericActivity.kt index bbd5ad05..e19b530a 100644 --- a/app/src/main/java/joshuatee/wx/models/ModelsGenericActivity.kt +++ b/app/src/main/java/joshuatee/wx/models/ModelsGenericActivity.kt @@ -239,7 +239,7 @@ class ModelsGenericActivity : VideoRecordActivity(), OnMenuItemClickListener, var tmpStr: String (0 until om.spTime.size()).forEach { tmpStr = MyApplication.space.split(om.spTime[it])[0] - om.spTime[it] = "$tmpStr " + UtilityModels.convertTimeRuntoTimeString( + om.spTime[it] = "$tmpStr " + UtilityModels.convertTimeRunToTimeString( om.rtd.mostRecentRun.replace( "Z", "" @@ -259,7 +259,7 @@ class ModelsGenericActivity : VideoRecordActivity(), OnMenuItemClickListener, miStatus.title = om.rtd.mostRecentRun + " - " + om.rtd.imageCompleteStr spRun.notifyDataSetChanged() (0 until om.spTime.size()).forEach { - om.spTime[it] = om.spTime[it] + " " + UtilityModels.convertTimeRuntoTimeString( + om.spTime[it] = om.spTime[it] + " " + UtilityModels.convertTimeRunToTimeString( om.rtd.timeStrConv.replace("Z", ""), om.spTime[it], false diff --git a/app/src/main/java/joshuatee/wx/models/ModelsSPCSREFActivity.kt b/app/src/main/java/joshuatee/wx/models/ModelsSPCSREFActivity.kt index 57efb2dc..09551df5 100644 --- a/app/src/main/java/joshuatee/wx/models/ModelsSPCSREFActivity.kt +++ b/app/src/main/java/joshuatee/wx/models/ModelsSPCSREFActivity.kt @@ -141,7 +141,7 @@ class ModelsSPCSREFActivity : VideoRecordActivity(), OnMenuItemClickListener, om.displayData = DisplayData(this, this, om.numPanes, om.spTime) setupModel() spRun = ObjectSpinner(this, this, this, R.id.spinner_run) - favList = UtilityFavorites.setupFavMenuSREF( + favList = UtilityFavorites.setupFavMenuSref( MyApplication.srefFav, om.displayData.param[om.curImg] ) @@ -161,7 +161,7 @@ class ModelsSPCSREFActivity : VideoRecordActivity(), OnMenuItemClickListener, } override fun onRestart() { - favList = UtilityFavorites.setupFavMenuSREF( + favList = UtilityFavorites.setupFavMenuSref( MyApplication.srefFav, om.displayData.param[om.curImg] ) @@ -183,7 +183,7 @@ class ModelsSPCSREFActivity : VideoRecordActivity(), OnMenuItemClickListener, spRun.notifyDataSetChanged() (0 until om.spTime.size()).forEach { om.spTime[it] = om.spTime[it] + " " + - UtilityModels.convertTimeRuntoTimeString( + UtilityModels.convertTimeRunToTimeString( om.rtd.mostRecentRun.replace("z", ""), om.spTime[it].replace("f", ""), false @@ -322,7 +322,7 @@ class ModelsSPCSREFActivity : VideoRecordActivity(), OnMenuItemClickListener, private fun toggleFavorite() { UtilityFavorites.toggleFavorite(this, om.displayData.param[om.curImg], star, "SREF_FAV") - favList = UtilityFavorites.setupFavMenuSREF( + favList = UtilityFavorites.setupFavMenuSref( MyApplication.srefFav, om.displayData.param[om.curImg] ) @@ -332,7 +332,7 @@ class ModelsSPCSREFActivity : VideoRecordActivity(), OnMenuItemClickListener, private fun refreshSpinner() { om.displayData.param[om.curImg] = drw.getUrl() om.displayData.paramLabel[om.curImg] = drw.getLabel() - favList = UtilityFavorites.setupFavMenuSREF( + favList = UtilityFavorites.setupFavMenuSref( MyApplication.srefFav, om.displayData.param[om.curImg] ) diff --git a/app/src/main/java/joshuatee/wx/models/UtilityModelNCEPInputOutput.kt b/app/src/main/java/joshuatee/wx/models/UtilityModelNCEPInputOutput.kt index 8b38d922..6e57c3f4 100644 --- a/app/src/main/java/joshuatee/wx/models/UtilityModelNCEPInputOutput.kt +++ b/app/src/main/java/joshuatee/wx/models/UtilityModelNCEPInputOutput.kt @@ -40,7 +40,7 @@ internal object UtilityModelNCEPInputOutput { fun getRunTime(model: String, param: String, spinnerSectorCurrent: String): RunTimeData { val runData = RunTimeData() val runCompletionDataStr = StringBuilder(100) - var html = UtilityString.getHTMLandParse( + var html = UtilityString.getHtmlAndParse( "${MyApplication.nwsMagNcepWebsitePrefix}/model-guidance-model-parameter.php?group=Model%20Guidance&model=" + model.toUpperCase(Locale.US) + "&area=" + spinnerSectorCurrent + "&ps=area", RegExp.ncepPattern2 diff --git a/app/src/main/java/joshuatee/wx/models/UtilityModelWPCGEFSInputOutput.kt b/app/src/main/java/joshuatee/wx/models/UtilityModelWPCGEFSInputOutput.kt index 6667c7c9..62413274 100644 --- a/app/src/main/java/joshuatee/wx/models/UtilityModelWPCGEFSInputOutput.kt +++ b/app/src/main/java/joshuatee/wx/models/UtilityModelWPCGEFSInputOutput.kt @@ -39,7 +39,7 @@ internal object UtilityModelWPCGEFSInputOutput { val runTime: RunTimeData get() { val runData = RunTimeData() - val currentHour = UtilityTime.currentHourInUTC + val currentHour = UtilityTime.currentHourInUtc runData.mostRecentRun = "00" if (currentHour in 12..17) { runData.mostRecentRun = "06" diff --git a/app/src/main/java/joshuatee/wx/models/UtilityModels.kt b/app/src/main/java/joshuatee/wx/models/UtilityModels.kt index 06ac6df0..1959cfaf 100644 --- a/app/src/main/java/joshuatee/wx/models/UtilityModels.kt +++ b/app/src/main/java/joshuatee/wx/models/UtilityModels.kt @@ -174,7 +174,7 @@ object UtilityModels { fun parmInArray(arr: List, parm: String): Boolean = arr.contains(parm) - fun convertTimeRuntoTimeString(runStr: String, timeStrF: String, showDate: Boolean): String { + fun convertTimeRunToTimeString(runStr: String, timeStrF: String, showDate: Boolean): String { var timeStr = timeStrF // in response to timeStr coming in as the following on rare occasions we need to truncate // 000 Wed 8pm @@ -269,7 +269,7 @@ object UtilityModels { } (0 until listTime.size).forEach { tmpStr = MyApplication.space.split(listTime[it])[0].replace(prefix, "") - listTime[it] = prefix + tmpStr + " " + convertTimeRuntoTimeString(run, tmpStr, showDate) + listTime[it] = prefix + tmpStr + " " + convertTimeRunToTimeString(run, tmpStr, showDate) } dataAdapterTime.notifyDataSetChanged() } diff --git a/app/src/main/java/joshuatee/wx/nhc/ObjectNHC.kt b/app/src/main/java/joshuatee/wx/nhc/ObjectNHC.kt index bd569b90..325d33a2 100644 --- a/app/src/main/java/joshuatee/wx/nhc/ObjectNHC.kt +++ b/app/src/main/java/joshuatee/wx/nhc/ObjectNHC.kt @@ -69,7 +69,7 @@ class ObjectNHC(val context: Context, private val dynamicview: LinearLayout) { UtilityNHC.getHurricaneInfo("${MyApplication.nwsNhcWebsitePrefix}/nhc_at" + it.toString() + ".xml") if (dataRet.title != "") { atlSumList.add(dataRet.summary) - atlLinkList.add(UtilityString.getNWSPRE(dataRet.url)) + atlLinkList.add(UtilityString.getNwsPre(dataRet.url)) atlImg1List.add(dataRet.img1) atlImg2List.add(dataRet.img2) atlWalletList.add(dataRet.wallet) @@ -81,7 +81,7 @@ class ObjectNHC(val context: Context, private val dynamicview: LinearLayout) { UtilityNHC.getHurricaneInfo("${MyApplication.nwsNhcWebsitePrefix}/nhc_ep" + it.toString() + ".xml") if (dataRet.title != "") { pacSumList.add(dataRet.summary) - pacLinkList.add(UtilityString.getNWSPRE(dataRet.url)) + pacLinkList.add(UtilityString.getNwsPre(dataRet.url)) pacImg1List.add(dataRet.img1) pacImg2List.add(dataRet.img2) pacWalletList.add(dataRet.wallet) diff --git a/app/src/main/java/joshuatee/wx/nhc/UtilityNHC.kt b/app/src/main/java/joshuatee/wx/nhc/UtilityNHC.kt index 07647339..13ded129 100644 --- a/app/src/main/java/joshuatee/wx/nhc/UtilityNHC.kt +++ b/app/src/main/java/joshuatee/wx/nhc/UtilityNHC.kt @@ -24,10 +24,14 @@ package joshuatee.wx.nhc import android.graphics.Bitmap import joshuatee.wx.Extensions.* +import joshuatee.wx.MyApplication import joshuatee.wx.RegExp object UtilityNHC { + const val widgetImageUrlTop = "${MyApplication.nwsNhcWebsitePrefix}/xgtwo/two_atl_0d0.png" + const val widgetImageUrlBottom = "${MyApplication.nwsNhcWebsitePrefix}/xgtwo/two_pac_0d0.png" + fun getHurricaneInfo(rssUrl: String): ObjectNHCStormInfo { var title = "" var summary = "" diff --git a/app/src/main/java/joshuatee/wx/notifications/BackgroundFetch.kt b/app/src/main/java/joshuatee/wx/notifications/BackgroundFetch.kt index 1568b341..5d8b078f 100644 --- a/app/src/main/java/joshuatee/wx/notifications/BackgroundFetch.kt +++ b/app/src/main/java/joshuatee/wx/notifications/BackgroundFetch.kt @@ -89,7 +89,7 @@ class BackgroundFetch(val context: Context) { if (MyApplication.alertTornadoNotificationCurrent || MyApplication.checktor || PolygonType.SVR.pref) { try { // store data for use by severe dashboard and cod warnings - UtilityDownloadRadar.getPolygonVTEC(context) + UtilityDownloadRadar.getPolygonVtec(context) if (MyApplication.alertTornadoNotificationCurrent) { notifUrls += UtilityNotificationTornado.checkAndSendTornadoNotification( context, @@ -97,7 +97,7 @@ class BackgroundFetch(val context: Context) { ) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } else { MyApplication.severeDashboardTor.valueSet(context, "") @@ -121,7 +121,7 @@ class BackgroundFetch(val context: Context) { var mcdPre = UtilityDownload.getTextProduct(context, "SPCMCD$mdNo") if (PolygonType.MCD.pref || locationNeedsMcd) { mcdNoList = "$mcdNoList$mdNo:" - mcdLatlon += UtilityNotification.storeWatMCDLATLON(mcdPre) + mcdLatlon += UtilityNotification.storeWatMcdLatLon(mcdPre) } if (MyApplication.alertSpcmcdNotificationCurrent) { noMain = "SPC MCD #$mdNo" @@ -167,7 +167,7 @@ class BackgroundFetch(val context: Context) { } // end while find } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } else { MyApplication.severeDashboardMcd.valueSet(context, "") @@ -187,7 +187,7 @@ class BackgroundFetch(val context: Context) { var mcdPre = UtilityDownload.getTextProduct(context, "WPCMPD$mdNo") if (PolygonType.MPD.pref || locationNeedsWpcmpd) { mpdNoList = "$mpdNoList$mdNo:" - mpdLatlon += UtilityNotification.storeWatMCDLATLON(mcdPre) + mpdLatlon += UtilityNotification.storeWatMcdLatLon(mcdPre) } if (MyApplication.alertWpcmpdNotificationCurrent) { noMain = "WPC MPD #$mdNo" @@ -235,7 +235,7 @@ class BackgroundFetch(val context: Context) { } // end while find } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } else { MyApplication.severeDashboardMpd.valueSet(context, "") @@ -254,13 +254,16 @@ class BackgroundFetch(val context: Context) { mdNo = String.format("%4s", mdNo).replace(' ', '0') var mcdPre = UtilityDownload.getTextProduct(context, "SPCWAT$mdNo") watchNoList = "$watchNoList$mdNo:" - val mcdPre2 = UtilityString.getHTMLandParseLastMatch("${MyApplication.nwsSPCwebsitePrefix}/products/watch/wou$mdNo.html", RegExp.pre2Pattern) - watchLatlonList += UtilityNotification.storeWatMCDLATLON(mcdPre2) + val mcdPre2 = UtilityString.getHtmlAndParseLastMatch( + "${MyApplication.nwsSPCwebsitePrefix}/products/watch/wou$mdNo.html", + RegExp.pre2Pattern + ) + watchLatlonList += UtilityNotification.storeWatMcdLatLon(mcdPre2) if (PolygonType.MCD.pref) { if (mcdPre.contains("Severe Thunderstorm Watch")) { - watchLatlon += UtilityNotification.storeWatMCDLATLON(mcdPre2) + watchLatlon += UtilityNotification.storeWatMcdLatLon(mcdPre2) } else { - watchLatlonTor += UtilityNotification.storeWatMCDLATLON(mcdPre2) + watchLatlonTor += UtilityNotification.storeWatMcdLatLon(mcdPre2) } } if (MyApplication.alertSpcwatNotificationCurrent) { @@ -308,7 +311,7 @@ class BackgroundFetch(val context: Context) { } // end while find } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } else { MyApplication.severeDashboardWat.valueSet(context, "") diff --git a/app/src/main/java/joshuatee/wx/notifications/UtilityNotification.kt b/app/src/main/java/joshuatee/wx/notifications/UtilityNotification.kt index 38f35dcf..b9cb081a 100644 --- a/app/src/main/java/joshuatee/wx/notifications/UtilityNotification.kt +++ b/app/src/main/java/joshuatee/wx/notifications/UtilityNotification.kt @@ -250,9 +250,9 @@ object UtilityNotification { notifUrls += url + "7day" + MyApplication.notificationStrSep } if (currentUpdateTime > lastUpdateTime + 1000 * 60 * ccUpdateInterval) { - val objCc = Utility.getCurrentConditions(context, locNumInt) - val objHazards = Utility.getCurrentHazards(locNumInt) - val objSevenDay = Utility.getCurrentSevenDay(locNumInt) + val objCc = ObjectForecastPackageCurrentConditions(context, locNumInt) + val objHazards = ObjectForecastPackageHazards(locNumInt) + val objSevenDay = ObjectForecastPackage7Day(locNumInt) val updateTime = System.currentTimeMillis() Utility.writePref(context, "CC" + locNum + "_LAST_UPDATE", updateTime) if (locNum == widgetLocNum && widgetsEnabled) { @@ -260,8 +260,8 @@ object UtilityNotification { } if (MyApplication.locations[locNumInt].ccNotification) { noMain = locLabelStr - noBody = objCc.data1 + MyApplication.newline + objCc.status - noSummary = objCc.data1 + MyApplication.newline + objCc.status + noBody = objCc.data + MyApplication.newline + objCc.status + noSummary = objCc.data + MyApplication.newline + objCc.status val notifier = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val resultIntent: Intent @@ -300,7 +300,7 @@ object UtilityNotification { UtilityNWS.getIcon( context, UtilityCanada.translateIconNameCurrentConditions( - objCc.data1, + objCc.data, objCc.status ) ) @@ -326,7 +326,7 @@ object UtilityNotification { val resultIntent2 = Intent(context, TextScreenActivity::class.java) resultIntent2.putExtra( TextScreenActivity.URL, - arrayOf(objSevenDay.sevenDayExtStr, locLabelStr) + arrayOf(objSevenDay.sevenDayLong, locLabelStr) ) val stackBuilder2 = TaskStackBuilder.create(context) stackBuilder2.addParentStack(TextScreenActivity::class.java) @@ -624,7 +624,7 @@ object UtilityNotification { return noti } - internal fun storeWatMCDLATLON(html: String): String { + internal fun storeWatMcdLatLon(html: String): String { val coords = html.parseColumn("([0-9]{8}).*?") var retStr = "" var xStrTmp: String @@ -645,7 +645,7 @@ object UtilityNotification { yStrTmp = tmpDbl.toString() } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } retStr = "$retStr$xStrTmp $yStrTmp " } diff --git a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationNHC.kt b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationNHC.kt index 1886b1c1..6abfa26d 100644 --- a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationNHC.kt +++ b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationNHC.kt @@ -67,7 +67,7 @@ object UtilityNotificationNhc { if (dataRet.title != "") { atlTitleList.add(dataRet.title.replace("NHC Atlantic Wallet", "")) atlSumList.add(dataRet.summary) - atlLinkList.add(UtilityString.getNWSPRE(dataRet.url)) + atlLinkList.add(UtilityString.getNwsPre(dataRet.url)) atlImg1List.add(dataRet.img1) atlImg2List.add(dataRet.img2) atlWalletList.add(dataRet.wallet) @@ -81,7 +81,7 @@ object UtilityNotificationNhc { if (dataRet.title != "") { pacTitleList.add(dataRet.title.replace("NHC Eastern Pacific Wallet", "")) pacSumList.add(dataRet.summary) - pacLinkList.add(UtilityString.getNWSPRE(dataRet.url)) + pacLinkList.add(UtilityString.getNwsPre(dataRet.url)) pacImg1List.add(dataRet.img1) pacImg2List.add(dataRet.img2) pacWalletList.add(dataRet.wallet) diff --git a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSPC.kt b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSPC.kt index 1c666110..ea90b3b8 100644 --- a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSPC.kt +++ b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSPC.kt @@ -442,7 +442,7 @@ internal object UtilityNotificationSpc { val threatList = mutableListOf() threatList.add("SPC30percent") threatList.add("SPC15percent") - var urlBlob = UtilityString.getHTMLandParse( + var urlBlob = UtilityString.getHtmlAndParse( "${MyApplication.nwsSPCwebsitePrefix}/products/exper/day4-8/", "CLICK TO GET WUUS48 PTSD48" ) diff --git a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSpcFireWeather.kt b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSpcFireWeather.kt index 409b7695..258f2776 100644 --- a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSpcFireWeather.kt +++ b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSpcFireWeather.kt @@ -107,7 +107,7 @@ internal object UtilityNotificationSpcFireWeather { for (day in 1..2) { val urlLocal = "${MyApplication.nwsSPCwebsitePrefix}/products/fire_wx/fwdy" + day.toString() + ".html" - urlBlob = UtilityString.getHTMLandParse( + urlBlob = UtilityString.getHtmlAndParse( urlLocal, "CLICK FOR DAY [12] FIREWX AREAL OUTLINE PRODUCT .KWNSPFWFD[12]." ) @@ -141,7 +141,7 @@ internal object UtilityNotificationSpcFireWeather { yStrTmp = tmpDbl.toString() } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } retStr = "$retStr$xStrTmp $yStrTmp " } diff --git a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationTornado.kt b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationTornado.kt index 5bae5b79..889d9cce 100644 --- a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationTornado.kt +++ b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationTornado.kt @@ -46,7 +46,7 @@ internal object UtilityNotificationTornado { try { notifUrls += checkForNotifications(context, html, inBlackout) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return notifUrls } @@ -65,7 +65,7 @@ internal object UtilityNotificationTornado { for (title in hazardTitles) { if (idAl.size > i) { val url = idAl[i] - val ca = CAPAlert.createFromURL(url) + val ca = CAPAlert.createFromUrl(url) if (UtilityNotificationTools.nwsLocalAlertNotFiltered( context, title diff --git a/app/src/main/java/joshuatee/wx/notifications/WXJobService.kt b/app/src/main/java/joshuatee/wx/notifications/WXJobService.kt index 4d8009cc..1f5c5d65 100644 --- a/app/src/main/java/joshuatee/wx/notifications/WXJobService.kt +++ b/app/src/main/java/joshuatee/wx/notifications/WXJobService.kt @@ -37,7 +37,7 @@ class WXJobService : JobService() { BackgroundFetch(this).getContent() UtilityLog.d("wx", "jobservice ran BackgroundFetch") } catch (e: RejectedExecutionException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } Utility.writePref( diff --git a/app/src/main/java/joshuatee/wx/objects/PolygonType.kt b/app/src/main/java/joshuatee/wx/objects/PolygonType.kt index ca407e04..adff90f0 100644 --- a/app/src/main/java/joshuatee/wx/objects/PolygonType.kt +++ b/app/src/main/java/joshuatee/wx/objects/PolygonType.kt @@ -34,8 +34,13 @@ enum public class PolygonType constructor( MCD(MyApplication.radarColorMcd, "MCD", MyApplication.radarWatMcd, 0.0f), MPD(MyApplication.radarColorMpd, "MPD", MyApplication.radarMpd, 0.0f), - WATCH(MyApplication.radarColorSvrWatch, "WATCH_SVR", MyApplication.radarWatMcd, 0.0f), - WATCH_TORNADO(MyApplication.radarColorTorWatch, "WATCH_TOR", MyApplication.radarWatMcd, 0.0f), + WATCH(MyApplication.radarColorSvrWatch, "WATCH", MyApplication.radarWatMcd, 0.0f), + WATCH_TORNADO( + MyApplication.radarColorTorWatch, + "WATCH_TORNADO", + MyApplication.radarWatMcd, + 0.0f + ), TOR(MyApplication.radarColorTor, "TOR", MyApplication.radarTorWarnings, 0.0f), SVR(MyApplication.radarColorSvr, "SVR", MyApplication.radarSvrWarnings, 0.0f), EWW(MyApplication.radarColorEww, "EWW", MyApplication.radarEwwWarnings, 0.0f), @@ -108,7 +113,6 @@ enum public class PolygonType constructor( MCD.pref = MyApplication.radarWatMcd MPD.pref = MyApplication.radarMpd WATCH.pref = MyApplication.radarWatMcd - WATCH.pref = MyApplication.radarWatMcd WATCH_TORNADO.pref = MyApplication.radarWatMcd TOR.pref = MyApplication.radarTorWarnings SVR.pref = MyApplication.radarSvrWarnings diff --git a/app/src/main/java/joshuatee/wx/objects/ProjectionType.kt b/app/src/main/java/joshuatee/wx/objects/ProjectionType.kt index 8c16b90f..450fb151 100644 --- a/app/src/main/java/joshuatee/wx/objects/ProjectionType.kt +++ b/app/src/main/java/joshuatee/wx/objects/ProjectionType.kt @@ -33,7 +33,6 @@ enum class ProjectionType constructor( WX_RENDER_48(true, false, true, true), WX_OGL(true, false, false, false), WX_OGL_48(true, false, false, false), - NWS_GOES(true, true, false, false); } diff --git a/app/src/main/java/joshuatee/wx/radar/Level2.kt b/app/src/main/java/joshuatee/wx/radar/Level2.kt index 479834d7..6aa8ebe0 100644 --- a/app/src/main/java/joshuatee/wx/radar/Level2.kt +++ b/app/src/main/java/joshuatee/wx/radar/Level2.kt @@ -121,7 +121,7 @@ internal object Level2 { } dis2.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } catch (e: OutOfMemoryError) { UtilityLog.handleException(e) } diff --git a/app/src/main/java/joshuatee/wx/radar/ObjectOglBuffers.kt b/app/src/main/java/joshuatee/wx/radar/ObjectOglBuffers.kt index 02bf520c..13accddf 100644 --- a/app/src/main/java/joshuatee/wx/radar/ObjectOglBuffers.kt +++ b/app/src/main/java/joshuatee/wx/radar/ObjectOglBuffers.kt @@ -126,7 +126,7 @@ open class ObjectOglBuffers() { try { floatBuffer.putFloat(newValue) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } @@ -147,7 +147,7 @@ open class ObjectOglBuffers() { try { colorBuffer.put(b) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } } diff --git a/app/src/main/java/joshuatee/wx/radar/OpenGLShader.kt b/app/src/main/java/joshuatee/wx/radar/OpenGLShader.kt index 22c64662..6534bf0d 100644 --- a/app/src/main/java/joshuatee/wx/radar/OpenGLShader.kt +++ b/app/src/main/java/joshuatee/wx/radar/OpenGLShader.kt @@ -221,7 +221,7 @@ internal object OpenGLShader { GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, img, 0) UtilityLog.d("wx","Loaded texture" + ":H:" + img.height + ":W:" + img.width) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } try { diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityCanvasStormInfo.kt b/app/src/main/java/joshuatee/wx/radar/UtilityCanvasStormInfo.kt index fc5707ba..4ac7b69e 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityCanvasStormInfo.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityCanvasStormInfo.kt @@ -225,7 +225,7 @@ object UtilityCanvasStormInfo { } } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } stormListArr = FloatArray(stormList.size) stormList.indices.forEach { stormListArr[it] = stormList[it].toFloat() } diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityCanvasWindbarbs.kt b/app/src/main/java/joshuatee/wx/radar/UtilityCanvasWindbarbs.kt index 1a2c5e90..bc037f05 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityCanvasWindbarbs.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityCanvasWindbarbs.kt @@ -227,7 +227,7 @@ object UtilityCanvasWindbarbs { } // if length greater then 4 } // loop over wind barbs } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } stormListArr = FloatArray(stormList.size) stormList.indices.forEach { stormListArr[it] = stormList[it].toFloat() } diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityConusRadar.kt b/app/src/main/java/joshuatee/wx/radar/UtilityConusRadar.kt index 9f3e2c1b..2ef07521 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityConusRadar.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityConusRadar.kt @@ -389,7 +389,7 @@ object UtilityConusRadar { val file = File(dir, fileName) fos = FileOutputStream(file) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return fos } diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityLevel3TextProduct.kt b/app/src/main/java/joshuatee/wx/radar/UtilityLevel3TextProduct.kt index 53893cf0..692d4ae6 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityLevel3TextProduct.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityLevel3TextProduct.kt @@ -48,19 +48,19 @@ object UtilityLevel3TextProduct { sb.append(String(byteArrayOf(it.readByte()), charset("ISO-8859-1"))) } } catch (e: EOFException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } catch (e: OutOfMemoryError) { UtilityLog.handleException(e) } finally { try { it.close() } catch (e: IOException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return sb.toString() } diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityMetar.kt b/app/src/main/java/joshuatee/wx/radar/UtilityMetar.kt index 10104ca6..95019065 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityMetar.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityMetar.kt @@ -198,8 +198,8 @@ internal object UtilityMetar { if (tdArr.size > 1) { t = tdArr[0] d = tdArr[1] - t = UtilityMath.cTof(t.replace("M", "-")) - d = UtilityMath.cTof(d.replace("M", "-")) + t = UtilityMath.celsiusToFahrenheit(t.replace("M", "-")) + d = UtilityMath.celsiusToFahrenheit(d.replace("M", "-")) obsSite = tmpArr2[0] latlon = OBS_LATLON[obsSite] ?: arrayOf("0.0", "0.0") if (latlon[0] != "0.0") { @@ -224,7 +224,7 @@ internal object UtilityMetar { obsAlWbGust.add(latlon[0] + ":" + latlon[1] + ":" + windDir + ":" + windgustInKt) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } } diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityNexradRadial4Bit.kt b/app/src/main/java/joshuatee/wx/radar/UtilityNexradRadial4Bit.kt index b5bdcabb..3f688d99 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityNexradRadial4Bit.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityNexradRadial4Bit.kt @@ -58,7 +58,7 @@ internal object UtilityNexradRadial4Bit { val fis = context.openFileInput(fn) dis = DataInputStream(BufferedInputStream(fis)) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } try { if (dis != null) { @@ -226,7 +226,7 @@ internal object UtilityNexradRadial4Bit { } } } catch (e: IOException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } } diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityNexradRadial8Bit.kt b/app/src/main/java/joshuatee/wx/radar/UtilityNexradRadial8Bit.kt index 9789b2eb..ff6a5145 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityNexradRadial8Bit.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityNexradRadial8Bit.kt @@ -85,7 +85,7 @@ internal object UtilityNexradRadial8Bit { Utility.writePref(context, "WX_RADAR_CURRENT_INFO_WIDGET_TIME", d.toString()) } catch (e: Exception) { Utility.writePref(context, "WX_RADAR_CURRENT_INFO_WIDGET_TIME", "") - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } catch (e: AssertionError) { Utility.writePref(context, "WX_RADAR_CURRENT_INFO_WIDGET_TIME", "") } @@ -211,7 +211,7 @@ internal object UtilityNexradRadial8Bit { g += 1 } } catch (e: IOException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } } diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityRadarUI.kt b/app/src/main/java/joshuatee/wx/radar/UtilityRadarUI.kt index 8ac12272..fd38a27e 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityRadarUI.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityRadarUI.kt @@ -213,15 +213,15 @@ internal object UtilityRadarUI { alertDialogRadarLongpressAl.add("Delete all userpoints") alertDialogRadarLongPress.show() } - - fun doLongPressAction( - strName: String, - context: Context, - act: Activity, - glview: WXGLSurfaceView, - oglr: WXGLRender, - uiDispatcher: CoroutineDispatcher, - fn: (strName: String) -> Unit + + fun doLongPressAction( + strName: String, + context: Context, + act: Activity, + glview: WXGLSurfaceView, + oglr: WXGLRender, + uiDispatcher: CoroutineDispatcher, + fn: (strName: String) -> Unit ) { when { strName.contains("Show warning text") -> { @@ -502,35 +502,28 @@ internal object UtilityRadarUI { oglr.deconstructWBLines() } if (PolygonType.SWO.pref && !archiveMode) { - UtilitySWOD1.getSWO() - oglr.constructSWOLines() + UtilitySWOD1.getSwo() + oglr.constructSwoLines() } else { - oglr.deconstructSWOLines() + oglr.deconstructSwoLines() } //} //showExtras } - + fun resetGlview(glviewloc: WXGLSurfaceView, OGLRLOC: WXGLRender) { glviewloc.scaleFactor = MyApplication.wxoglSize.toFloat() / 10.0f OGLRLOC.setViewInitial(MyApplication.wxoglSize.toFloat() / 10.0f, 0.0f, 0.0f) glviewloc.requestRender() - } - - - - - - + } private fun showNearestProduct( - //act: Activity, context: Context, type: PolygonType, glview: WXGLSurfaceView, uiDispatcher: CoroutineDispatcher ) = GlobalScope.launch(uiDispatcher) { val text = withContext(Dispatchers.IO) { - UtilityWatch.showProducts(glview.newY.toDouble(), glview.newX.toDouble() * -1.0, type) + UtilityWatch.show(glview.newY.toDouble(), glview.newX.toDouble() * -1.0, type) } if (text != "") { ObjectIntent( diff --git a/app/src/main/java/joshuatee/wx/radar/UtilitySWOD1.kt b/app/src/main/java/joshuatee/wx/radar/UtilitySWOD1.kt index 09481b9f..821f8ec8 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilitySWOD1.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilitySWOD1.kt @@ -38,7 +38,7 @@ internal object UtilitySWOD1 { @SuppressLint("UseSparseArrays") val HASH_SWO = mutableMapOf>() - fun getSWO() { + fun getSwo() { val currentTime1 = System.currentTimeMillis() val currentTimeSec = currentTime1 / 1000 val refreshIntervalSec = (REFRESH_LOC_MIN * 60).toLong() @@ -91,7 +91,7 @@ internal object UtilitySWOD1 { yStrTmp = tmpDbl.toString() } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } retStr = "$retStr$xStrTmp $yStrTmp " } diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityUSImgWX.kt b/app/src/main/java/joshuatee/wx/radar/UtilityUSImgWX.kt index 0873dd00..6e58cec7 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityUSImgWX.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityUSImgWX.kt @@ -83,7 +83,7 @@ object UtilityUSImgWX { try { inputStream?.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } val layers = mutableListOf() diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityWXOGL.kt b/app/src/main/java/joshuatee/wx/radar/UtilityWXOGL.kt index f26f81c4..190daedf 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityWXOGL.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityWXOGL.kt @@ -135,16 +135,16 @@ object UtilityWXOGL { } } } catch (e: EOFException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } finally { try { dis.close() } catch (e: IOException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } output += "" return output diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerf.kt b/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerf.kt index e5b0a0cf..c0ea884b 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerf.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerf.kt @@ -114,7 +114,7 @@ internal object UtilityWXOGLPerf { curLevel = (dis2.readUnsignedByte() and 0xFF).toByte() // was dis2!!.readUnsignedByte().toInt() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } if (bin == 0) level = curLevel @@ -734,7 +734,7 @@ internal object UtilityWXOGLPerf { } dis2.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } binWord.position(0) radialStartAngle.position(0) diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerfL2.kt b/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerfL2.kt index 2fb9c54e..41b354d4 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerfL2.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerfL2.kt @@ -63,7 +63,7 @@ internal object UtilityWXOGLPerfL2 { wChannel.close() fos.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } @@ -92,7 +92,7 @@ internal object UtilityWXOGLPerfL2 { rChannel.read(binWord) rChannel.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } @@ -198,7 +198,7 @@ internal object UtilityWXOGLPerfL2 { } if (obuff.size >= 0) outputRaf.write(obuff, 0, total) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } if (total == refDecompSize || total == velDecompSize) loopCnt += 1 if (loopCnt > loopCntBreak) break @@ -207,7 +207,7 @@ internal object UtilityWXOGLPerfL2 { bis?.close() outputRaf.flush() } catch (e: IOException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return outputRaf } diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerfL3FourBit.kt b/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerfL3FourBit.kt index a5af0331..78915003 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerfL3FourBit.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerfL3FourBit.kt @@ -72,7 +72,7 @@ internal object UtilityWXOGLPerfL3FourBit { } dis.close() } catch (e: IOException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return numberOfRangeBins } diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityWatch.kt b/app/src/main/java/joshuatee/wx/radar/UtilityWatch.kt index 49c22adc..c1016576 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityWatch.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityWatch.kt @@ -32,7 +32,7 @@ import joshuatee.wx.external.ExternalPolygon internal object UtilityWatch { - fun addWat( + fun add( context: Context, provider: ProjectionType, rid1: String, @@ -90,7 +90,7 @@ internal object UtilityWatch { return warningList } - fun showProducts(lat: Double, lon: Double, type: PolygonType): String { + fun show(lat: Double, lon: Double, type: PolygonType): String { var text = "" val textWatNoList: String val mcdNoArr: Array @@ -100,36 +100,32 @@ internal object UtilityWatch { textWatNoList = MyApplication.watchNoList.valueGet() mcdNoArr = MyApplication.colon.split(textWatNoList) watchLatLon = MyApplication.watchLatlonList.valueGet() - //productStringPrefix = "SPCWAT" } PolygonType.MCD -> { textWatNoList = MyApplication.mcdNoList.valueGet() mcdNoArr = MyApplication.colon.split(textWatNoList) watchLatLon = MyApplication.mcdLatlon.valueGet() - //productStringPrefix = "SPCMCD" } PolygonType.MPD -> { textWatNoList = MyApplication.mpdNoList.valueGet() mcdNoArr = MyApplication.colon.split(textWatNoList) watchLatLon = MyApplication.mpdLatlon.valueGet() - //productStringPrefix = "WPCMPD" } else -> { textWatNoList = MyApplication.watchNoList.valueGet() mcdNoArr = MyApplication.colon.split(textWatNoList) watchLatLon = MyApplication.watchLatlonList.valueGet() - //productStringPrefix = "" } } - val latlonArr = MyApplication.colon.split(watchLatLon) + val latLonArr = MyApplication.colon.split(watchLatLon) val x = mutableListOf() val y = mutableListOf() var i: Int var testArr: List var z = 0 var notFound = true - while (z < latlonArr.size) { - testArr = latlonArr[z].split(" ") + while (z < latLonArr.size) { + testArr = latLonArr[z].split(" ") x.clear() y.clear() i = 0 diff --git a/app/src/main/java/joshuatee/wx/radar/ViewColorLegend.kt b/app/src/main/java/joshuatee/wx/radar/ViewColorLegend.kt index 9004e268..e8c19c9d 100644 --- a/app/src/main/java/joshuatee/wx/radar/ViewColorLegend.kt +++ b/app/src/main/java/joshuatee/wx/radar/ViewColorLegend.kt @@ -31,9 +31,6 @@ import android.view.View import joshuatee.wx.MyApplication import joshuatee.wx.external.UtilityStringExternal -// thanks for skeletal framework -// https://newcircle.com/s/post/1036/android_2d_graphics_example - class ViewColorLegend(context: Context, private val product: String) : View(context) { private val myPaint = Paint() diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLDownload.kt b/app/src/main/java/joshuatee/wx/radar/WXGLDownload.kt index f4a6b620..113630a3 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLDownload.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLDownload.kt @@ -173,7 +173,7 @@ class WXGLDownload { j += 1 } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return nidsArr } diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLNexrad.kt b/app/src/main/java/joshuatee/wx/radar/WXGLNexrad.kt index 358062bb..3973b466 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLNexrad.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLNexrad.kt @@ -176,4 +176,8 @@ object WXGLNexrad { Utility.writePref(context, prefPrefix + "_X" + idx.toString(), oglr.x) Utility.writePref(context, prefPrefix + "_Y" + idx.toString(), oglr.y) } + + fun saveProductPrefs(context: Context, prefPrefix: String, idx: Int, oglr: WXGLRender) { + Utility.writePref(context, prefPrefix + "_PROD" + idx.toString(), oglr.product) + } } diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel2.kt b/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel2.kt index 45a7e5a6..eb57bf34 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel2.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel2.kt @@ -76,7 +76,7 @@ class WXGLNexradLevel2 { productCode.toInt() ) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } else { if (performDecomp) { @@ -161,7 +161,7 @@ class WXGLNexradLevel2 { Utility.writePref(context, "WX_RADAR_CURRENT_INFO$radarStatusStr", radarInfo) binSize = WXGLNexrad.getBinSize(productCode.toInt()) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } if (!MyApplication.radarUseJni) UtilityFileManagement.deleteFile(context, decompFileName) } diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel3.kt b/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel3.kt index 4a1d48fc..eaeb662b 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel3.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel3.kt @@ -287,7 +287,7 @@ class WXGLNexradLevel3 { UtilityWXOGLPerfL3FourBit.decode4Bit(context, fn, radialStart, binWord) binSize = WXGLNexrad.getBinSize(productCode.toInt()) } catch (e: IOException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel3StormInfo.kt b/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel3StormInfo.kt index 55eeeb87..58af50b9 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel3StormInfo.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel3StormInfo.kt @@ -58,7 +58,7 @@ internal object WXGLNexradLevel3StormInfo { posn = retStr.parseColumn(RegExp.stiPattern1) motion = retStr.parseColumn(RegExp.stiPattern2) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) return listOf() } var posnStr = "" diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLPolygonWarnings.kt b/app/src/main/java/joshuatee/wx/radar/WXGLPolygonWarnings.kt index bf51c1db..206fad67 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLPolygonWarnings.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLPolygonWarnings.kt @@ -288,7 +288,7 @@ internal object WXGLPolygonWarnings { .parseJsonObject(StringReader(MyApplication.severeDashboardSps.valueGet())) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivity.kt b/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivity.kt index c0fd85de..f6b38b19 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivity.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivity.kt @@ -206,7 +206,7 @@ class WXGLRadarActivity : VideoRecordActivity(), OnItemSelectedListener, OnMenuI UtilityToolbar.transparentToolbars(toolbar, toolbarBottom) if (archiveMode && !spotterShowSelected) toolbarBottom.visibility = View.GONE - val latLonArrD = UtilityLocation.getGPS(this) + val latLonArrD = UtilityLocation.getGps(this) latD = latLonArrD[0] lonD = latLonArrD[1] val menu = toolbarBottom.menu @@ -233,7 +233,7 @@ class WXGLRadarActivity : VideoRecordActivity(), OnItemSelectedListener, OnMenuI img.setMaxZoom(6.0f) glview = WXGLSurfaceView(this, 1, numPanes, 1) imageMap = ObjectImageMap(this, this, R.id.map, toolbar, toolbarBottom, listOf(img, glview)) - imageMap.addClickHandler(::ridMapSwitch, UtilityImageMap::maptoRid) + imageMap.addClickHandler(::ridMapSwitch, UtilityImageMap::mapToRid) rl = findViewById(R.id.rl) rl.addView(glview) val rlArr = arrayOf(rl) @@ -473,7 +473,7 @@ class WXGLRadarActivity : VideoRecordActivity(), OnItemSelectedListener, OnMenuI UtilityLog.d("wx", "Problem moving to nexrad_anim$it") } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } var loopCnt = 0 while (inOglAnim) { @@ -496,7 +496,7 @@ class WXGLRadarActivity : VideoRecordActivity(), OnItemSelectedListener, OnMenuI ) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } animTriggerDownloads = false } diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivityMultiPane.kt b/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivityMultiPane.kt index 05c2628a..6e9ed5c8 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivityMultiPane.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivityMultiPane.kt @@ -216,7 +216,7 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene } setupAlertDialogRadarLongPress() UtilityToolbar.transparentToolbars(toolbar, toolbarBottom) - val latlonArrD = UtilityLocation.getGPS(this as Context) + val latlonArrD = UtilityLocation.getGps(this as Context) latD = latlonArrD[0] lonD = latlonArrD[1] val menu = toolbarBottom.menu @@ -224,9 +224,12 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene anim = menu.findItem(R.id.action_a) val rad3 = menu.findItem(R.id.action_radar3) val rad4 = menu.findItem(R.id.action_radar4) + val quadPaneJump = menu.findItem(R.id.action_radar_4) if (numPanes == 2) { rad3.isVisible = false rad4.isVisible = false + } else { + quadPaneJump.isVisible = false } if (!UIPreferences.radarImmersiveMode) { val blank = menu.findItem(R.id.action_blank) @@ -307,7 +310,7 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene toolbarBottom, rlArr.toList() as List + glviewArr.toList() as List ) - imageMap.addClickHandler(::ridMapSwitch, UtilityImageMap::maptoRid) + imageMap.addClickHandler(::ridMapSwitch, UtilityImageMap::mapToRid) oglInView = true numPanesArr.forEach { if (!useSinglePanePref) { @@ -484,7 +487,7 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene numPanesArr, imageMap, glviewArr, - ::getGPSFromDouble, + ::getGpsFromDouble, ::getLatLon ) withContext(Dispatchers.IO) { @@ -492,7 +495,7 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene ogl, "", contextg, - ::getGPSFromDouble, + ::getGpsFromDouble, ::getLatLon, false ) @@ -558,7 +561,7 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene ) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } var loopCnt = 0 @@ -588,7 +591,7 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene ) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } animTriggerDownloads = false @@ -801,6 +804,19 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene } } } + R.id.action_radar_4 -> { + if (!dontSavePref) { + numPanesArr.forEach { WXGLNexrad.savePrefs(this, prefPrefix, it + 1, oglrArr[it]) } + } else { + numPanesArr.forEach { WXGLNexrad.saveProductPrefs(this, prefPrefix, it + 1, oglrArr[it]) } + } + ObjectIntent( + this, + WXGLRadarActivityMultiPane::class.java, + RID, + arrayOf(joshuatee.wx.settings.Location.rid, "", "4", "true") + ) + } R.id.action_TDWR -> alertDialogTDWR() R.id.action_ridmap -> { imageMap.toggleMap() @@ -890,6 +906,8 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene super.onStop() if (!dontSavePref) { numPanesArr.forEach { WXGLNexrad.savePrefs(this, prefPrefix, it + 1, oglrArr[it]) } + } else { + numPanesArr.forEach { WXGLNexrad.saveProductPrefs(this, prefPrefix, it + 1, oglrArr[it]) } } // otherwise cpu will spin with no fix but to kill app inOglAnim = false @@ -1013,21 +1031,21 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene private fun makeUseOfNewLocation(location: Location) { latD = location.latitude lonD = location.longitude - getGPSFromDouble() + getGpsFromDouble() numPanesArr.forEach { oglrArr[it].constructLocationDot(locXCurrent, locYCurrent, false) glviewArr[it].requestRender() } } - private fun getGPSFromDouble() { + private fun getGpsFromDouble() { try { latlonArr[0] = latD.toString() latlonArr[1] = lonD.toString() locXCurrent = latlonArr[0] locYCurrent = latlonArr[1] } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLRender.kt b/app/src/main/java/joshuatee/wx/radar/WXGLRender.kt index c8ab4c7e..bc6ca0cf 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLRender.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLRender.kt @@ -98,7 +98,7 @@ class WXGLRender(private val context: Context) : Renderer { private val radarBuffers = ObjectOglRadarBuffers(context, MyApplication.nexradRadarBackgroundColor) private val spotterBuffers = ObjectOglBuffers(PolygonType.SPOTTER, zoomToHideMiscFeatures) private val stateLineBuffers = ObjectOglBuffers(GeographyType.STATE_LINES, 0.0f) - private val countyLineBuffers = ObjectOglBuffers(GeographyType.COUNTY_LINES, 0.35f) // was .75 + private val countyLineBuffers = ObjectOglBuffers(GeographyType.COUNTY_LINES, 0.75f) // was .75 private val hwBuffers = ObjectOglBuffers(GeographyType.HIGHWAYS, 0.45f) private val hwExtBuffers = ObjectOglBuffers(GeographyType.HIGHWAYS_EXTENDED, 3.00f) private val lakeBuffers = ObjectOglBuffers(GeographyType.LAKES, zoomToHideMiscFeatures) @@ -158,12 +158,10 @@ class WXGLRender(private val context: Context) : Renderer { it.draw(pn) } } - if (locdotBuffers.isInitialized && MyApplication.locdotFollowsGps) { locIconBuffers.lenInit = 0f //was locdotBuffers.lenInit UtilityWXOGLPerf.genLocdot(locIconBuffers, pn, gpsX, gpsY) } - } private var mSurfaceRatio = 0f var x: Float = 0f @@ -217,7 +215,7 @@ class WXGLRender(private val context: Context) : Renderer { triangleIndexBuffer = ByteBuffer.allocateDirect(12 * breakSize15) lineIndexBuffer = ByteBuffer.allocateDirect(4 * breakSizeLine) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } triangleIndexBuffer.order(ByteOrder.nativeOrder()) triangleIndexBuffer.position(0) @@ -311,7 +309,7 @@ class WXGLRender(private val context: Context) : Renderer { } } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } if (radarBuffers.numRangeBins == 0) { radarBuffers.numRangeBins = 460 @@ -320,67 +318,67 @@ class WXGLRender(private val context: Context) : Renderer { radarBuffers.initialize() radarBuffers.setToPositionZero() val objColPal: ObjectColorPalette = - if (MyApplication.colorMap.containsKey(radarBuffers.productCode.toInt())) { - MyApplication.colorMap[radarBuffers.productCode.toInt()]!! - } else { - MyApplication.colorMap[94]!! - } + if (MyApplication.colorMap.containsKey(radarBuffers.productCode.toInt())) { + MyApplication.colorMap[radarBuffers.productCode.toInt()]!! + } else { + MyApplication.colorMap[94]!! + } val cR = objColPal.redValues val cG = objColPal.greenValues val cB = objColPal.blueValues try { if (!product.contains("L2")) { totalBins = - if (radarBuffers.productCode != 56.toShort() && radarBuffers.productCode != 30.toShort()) { - if (!MyApplication.radarUseJni) - UtilityWXOGLPerf.decode8BitAndGenRadials(context, radarBuffers) - else { - JNI.decode8BitAndGenRadials( - UtilityIO.getFilePath(context, radarBuffers.fn), - radarL3Object.seekStart, - radarL3Object.compressedFileSize, - radarL3Object.iBuff, - radarL3Object.oBuff, - radarBuffers.floatBuffer, - radarBuffers.colorBuffer, - radarBuffers.binSize, - Color.red(radarBuffers.bgColor).toByte(), - Color.green(radarBuffers.bgColor).toByte(), - Color.blue(radarBuffers.bgColor).toByte(), - cR, - cG, - cB + if (radarBuffers.productCode != 56.toShort() && radarBuffers.productCode != 30.toShort()) { + if (!MyApplication.radarUseJni) + UtilityWXOGLPerf.decode8BitAndGenRadials(context, radarBuffers) + else { + JNI.decode8BitAndGenRadials( + UtilityIO.getFilePath(context, radarBuffers.fn), + radarL3Object.seekStart, + radarL3Object.compressedFileSize, + radarL3Object.iBuff, + radarL3Object.oBuff, + radarBuffers.floatBuffer, + radarBuffers.colorBuffer, + radarBuffers.binSize, + Color.red(radarBuffers.bgColor).toByte(), + Color.green(radarBuffers.bgColor).toByte(), + Color.blue(radarBuffers.bgColor).toByte(), + cR, + cG, + cB + ) + } + } else { + UtilityWXOGLPerf.genRadials( + radarBuffers, + radarL3Object.binWord, + radarL3Object.radialStart ) } - } else { - UtilityWXOGLPerf.genRadials( - radarBuffers, - radarL3Object.binWord, - radarL3Object.radialStart - ) - } } else { rdL2.binWord.position(0) totalBins = if (MyApplication.radarUseJni) JNI.level2GenRadials( - radarBuffers.floatBuffer, - radarBuffers.colorBuffer, - rdL2.binWord, - rdL2.radialStartAngle, - radarBuffers.numberOfRadials, - radarBuffers.numRangeBins, - radarBuffers.binSize, - radarBuffers.bgColor, - cR, - cG, - cB, - radarBuffers.productCode.toInt() + radarBuffers.floatBuffer, + radarBuffers.colorBuffer, + rdL2.binWord, + rdL2.radialStartAngle, + radarBuffers.numberOfRadials, + radarBuffers.numRangeBins, + radarBuffers.binSize, + radarBuffers.bgColor, + cR, + cG, + cB, + radarBuffers.productCode.toInt() ) else UtilityWXOGLPerf.genRadials(radarBuffers, rdL2.binWord, rdL2.radialStartAngle) } // level 2 , level 3 check } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } breakSize15 = 15000 chunkCount = 1 @@ -452,7 +450,7 @@ class WXGLRender(private val context: Context) : Renderer { triangleIndexBuffer.position(0) GLES20.glDrawElements(GLES20.GL_TRIANGLES, radarChunkCnt, GLES20.GL_UNSIGNED_SHORT, triangleIndexBuffer.slice().asShortBuffer()) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } GLES20.glLineWidth(defaultLineWidth) @@ -563,8 +561,9 @@ class WXGLRender(private val context: Context) : Renderer { //hack job!!! if (!displayHold) { Log.i(TAG, "zoom: " + zoom) + Log.i(TAG, "zoom setting: "+MyApplication.radarConusRadarZoom+ " math: "+(MyApplication.radarConusRadarZoom / 1000.0)) if (MyApplication.radarConusRadar) { - if (zoom < 0.163f) { + if (zoom < (MyApplication.radarConusRadarZoom / 1000.0).toFloat()) { Log.i(TAG, "zoom out to conusradar") drawConusRadarTest(conusRadarBuffers) } @@ -678,7 +677,7 @@ class WXGLRender(private val context: Context) : Renderer { //triangle val base = RectF(-conusbitmap.width.toFloat(), conusbitmap.height.toFloat(), conusbitmap.width.toFloat(), -conusbitmap.height.toFloat()) - val scale = 2f + val scale = 3.0f //was 2.0f UtilityLog.d("wx", "left: " + base.left) UtilityLog.d("wx", "right: " + base.right) @@ -941,26 +940,26 @@ class WXGLRender(private val context: Context) : Renderer { lineIndexBuffer.position(0) buffers.setToPositionZero() GLES20.glVertexAttribPointer( - mPositionHandle, - 2, - GLES20.GL_FLOAT, - false, - 0, - buffers.floatBuffer.slice().asFloatBuffer() + mPositionHandle, + 2, + GLES20.GL_FLOAT, + false, + 0, + buffers.floatBuffer.slice().asFloatBuffer() ) GLES20.glVertexAttribPointer( - colorHandle, - 3, - GLES20.GL_UNSIGNED_BYTE, - true, - 0, - buffers.colorBuffer + colorHandle, + 3, + GLES20.GL_UNSIGNED_BYTE, + true, + 0, + buffers.colorBuffer ) GLES20.glDrawElements( - GLES20.GL_LINES, - buffers.floatBuffer.capacity() / countDivisor, - GLES20.GL_UNSIGNED_SHORT, - lineIndexBuffer.slice().asShortBuffer() + GLES20.GL_LINES, + buffers.floatBuffer.capacity() / countDivisor, + GLES20.GL_UNSIGNED_SHORT, + lineIndexBuffer.slice().asShortBuffer() ) } } @@ -979,26 +978,26 @@ class WXGLRender(private val context: Context) : Renderer { buffers.colorBuffer.position(0) lineIndexBuffer.position(0) GLES20.glVertexAttribPointer( - mPositionHandle, - 2, - GLES20.GL_FLOAT, - false, - 0, - buffers.floatBuffer.slice().asFloatBuffer() + mPositionHandle, + 2, + GLES20.GL_FLOAT, + false, + 0, + buffers.floatBuffer.slice().asFloatBuffer() ) GLES20.glVertexAttribPointer( - colorHandle, - 3, - GLES20.GL_UNSIGNED_BYTE, - true, - 0, - buffers.colorBuffer.slice() + colorHandle, + 3, + GLES20.GL_UNSIGNED_BYTE, + true, + 0, + buffers.colorBuffer.slice() ) GLES20.glDrawElements( - GLES20.GL_LINES, - lineCnt, - GLES20.GL_UNSIGNED_SHORT, - lineIndexBuffer.slice().asShortBuffer() + GLES20.GL_LINES, + lineCnt, + GLES20.GL_UNSIGNED_SHORT, + lineIndexBuffer.slice().asShortBuffer() ) } catch (e: Exception) { @@ -1015,14 +1014,14 @@ class WXGLRender(private val context: Context) : Renderer { mtrxProjectionAndView[it] = 0.0f } Matrix.orthoM( - mtrxProjection, - 0, - (-1 * ortInt).toFloat(), - ortInt.toFloat(), - -1f * ortInt.toFloat() * (1 / mSurfaceRatio), - ortInt * (1 / mSurfaceRatio), - 1f, - -1f + mtrxProjection, + 0, + (-1 * ortInt).toFloat(), + ortInt.toFloat(), + -1f * ortInt.toFloat() * (1 / mSurfaceRatio), + ortInt * (1 / mSurfaceRatio), + 1f, + -1f ) Matrix.setLookAtM(mtrxView, 0, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1.0f, 0.0f) Matrix.multiplyMM(mtrxProjectionAndView, 0, mtrxProjection, 0, mtrxView, 0) @@ -1120,7 +1119,7 @@ class WXGLRender(private val context: Context) : Renderer { UtilityWXOGLPerf.colorGen(buffers.colorBuffer, 4 * f.size, buffers.colorArray) } } catch (e: java.lang.Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } buffers.breakSize = 15000 buffers.chunkCount = 1 @@ -1397,16 +1396,16 @@ class WXGLRender(private val context: Context) : Renderer { buffers.count = buffers.xList.size when (buffers.type) { PolygonType.LOCDOT, PolygonType.SPOTTER -> buffers.initialize( - 24 * buffers.count * buffers.triangleCount, - 12 * buffers.count * buffers.triangleCount, - 9 * buffers.count * buffers.triangleCount, - buffers.type.color + 24 * buffers.count * buffers.triangleCount, + 12 * buffers.count * buffers.triangleCount, + 9 * buffers.count * buffers.triangleCount, + buffers.type.color ) else -> buffers.initialize( - 4 * 6 * buffers.count, - 4 * 3 * buffers.count, - 9 * buffers.count, - buffers.type.color + 4 * 6 * buffers.count, + 4 * 3 * buffers.count, + 9 * buffers.count, + buffers.type.color ) } buffers.lenInit = scaleLength(buffers.lenInit) @@ -1457,7 +1456,7 @@ class WXGLRender(private val context: Context) : Renderer { var fList = listOf() when (buffers.type) { PolygonType.MCD, PolygonType.MPD, PolygonType.WATCH, PolygonType.WATCH_TORNADO -> fList = - UtilityWatch.addWat(context, provider, rid, buffers.type).toList() + UtilityWatch.add(context, provider, rid, buffers.type).toList() PolygonType.TOR, PolygonType.SVR, PolygonType.EWW, PolygonType.FFW, PolygonType.SMW, PolygonType.SVS -> fList = WXGLPolygonWarnings.addWarnings(context, provider, rid, buffers.type).toList() PolygonType.SPS -> fList = WXGLPolygonWarnings.addSPS(context, provider, rid, buffers.type).toList() PolygonType.STI -> fList = WXGLNexradLevel3StormInfo.decodeAndPlot(context, idxStr, rid, provider).toList() @@ -1554,9 +1553,9 @@ class WXGLRender(private val context: Context) : Renderer { wbCircleBuffers.count = wbCircleBuffers.xList.size wbCircleBuffers.triangleCount = 6 wbCircleBuffers.initialize( - 24 * wbCircleBuffers.count * wbCircleBuffers.triangleCount, - 12 * wbCircleBuffers.count * wbCircleBuffers.triangleCount, - 9 * wbCircleBuffers.count * wbCircleBuffers.triangleCount + 24 * wbCircleBuffers.count * wbCircleBuffers.triangleCount, + 12 * wbCircleBuffers.count * wbCircleBuffers.triangleCount, + 9 * wbCircleBuffers.count * wbCircleBuffers.triangleCount ) wbCircleBuffers.lenInit = scaleLength(wbCircleBuffers.lenInit) wbCircleBuffers.draw(pn) @@ -1567,15 +1566,15 @@ class WXGLRender(private val context: Context) : Renderer { wbCircleBuffers.isInitialized = false } - fun constructSWOLines() { - val hashSWO = UtilitySWOD1.HASH_SWO.toMap() + fun constructSwoLines() { + val hashSwo = UtilitySWOD1.HASH_SWO.toMap() colorSwo[0] = Color.MAGENTA colorSwo[1] = Color.RED colorSwo[2] = Color.rgb(255, 140, 0) colorSwo[3] = Color.YELLOW colorSwo[4] = Color.rgb(0, 100, 0) var tmpCoords: DoubleArray - val fSize = (0..4).filter { hashSWO[it] != null }.sumBy { hashSWO[it]!!.size } + val fSize = (0..4).filter { hashSwo[it] != null }.sumBy { hashSwo[it]!!.size } swoBuffers.breakSize = 15000 swoBuffers.chunkCount = 1 val totalBinsSwo = fSize / 4 @@ -1588,9 +1587,9 @@ class WXGLRender(private val context: Context) : Renderer { } swoBuffers.isInitialized = true (0..4).forEach { - if (hashSWO[it] != null) { + if (hashSwo[it] != null) { var j = 0 - while (j < hashSWO[it]!!.size) { + while (j < hashSwo[it]!!.size) { swoBuffers.putColor(Color.red(colorSwo[it]).toByte()) swoBuffers.putColor(Color.green(colorSwo[it]).toByte()) swoBuffers.putColor(Color.blue(colorSwo[it]).toByte()) @@ -1598,16 +1597,16 @@ class WXGLRender(private val context: Context) : Renderer { swoBuffers.putColor(Color.green(colorSwo[it]).toByte()) swoBuffers.putColor(Color.blue(colorSwo[it]).toByte()) tmpCoords = UtilityCanvasProjection.computeMercatorNumbers( - hashSWO[it]!![j], - (hashSWO[it]!![j + 1] * -1.0f), - pn + hashSwo[it]!![j], + (hashSwo[it]!![j + 1] * -1.0f), + pn ) swoBuffers.putFloat(tmpCoords[0].toFloat()) swoBuffers.putFloat(tmpCoords[1].toFloat() * -1.0f) tmpCoords = UtilityCanvasProjection.computeMercatorNumbers( - hashSWO[it]!![j + 2], - (hashSWO[it]!![j + 3] * -1.0f), - pn + hashSwo[it]!![j + 2], + (hashSwo[it]!![j + 3] * -1.0f), + pn ) swoBuffers.putFloat(tmpCoords[0].toFloat()) swoBuffers.putFloat(tmpCoords[1].toFloat() * -1.0f) @@ -1617,7 +1616,7 @@ class WXGLRender(private val context: Context) : Renderer { } } - fun deconstructSWOLines() { + fun deconstructSwoLines() { swoBuffers.isInitialized = false } diff --git a/app/src/main/java/joshuatee/wx/radarcolorpalettes/ObjectColorPalette.kt b/app/src/main/java/joshuatee/wx/radarcolorpalettes/ObjectColorPalette.kt index 85829ad1..217ef37e 100644 --- a/app/src/main/java/joshuatee/wx/radarcolorpalettes/ObjectColorPalette.kt +++ b/app/src/main/java/joshuatee/wx/radarcolorpalettes/ObjectColorPalette.kt @@ -52,7 +52,7 @@ class ObjectColorPalette(val context: Context, private val colormapCode: String) try { UtilityColorPalette30.gen30() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } "56" -> { @@ -60,7 +60,7 @@ class ObjectColorPalette(val context: Context, private val colormapCode: String) try { UtilityColorPalette56.gen56() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } "165" -> { @@ -68,7 +68,7 @@ class ObjectColorPalette(val context: Context, private val colormapCode: String) try { UtilityColorPalette165.loadColorMap(context) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } else -> { @@ -76,7 +76,7 @@ class ObjectColorPalette(val context: Context, private val colormapCode: String) try { UtilityColorPaletteGeneric.loadColorMap(context, colormapCode) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } } diff --git a/app/src/main/java/joshuatee/wx/settings/FavRemoveActivity.kt b/app/src/main/java/joshuatee/wx/settings/FavRemoveActivity.kt index 9b750db9..f21d49aa 100644 --- a/app/src/main/java/joshuatee/wx/settings/FavRemoveActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/FavRemoveActivity.kt @@ -64,8 +64,8 @@ class FavRemoveActivity : BaseActivity() { null, false ) - val turl = intent.getStringArrayExtra(TYPE) - type = turl[0] + val activityArguments = intent.getStringArrayExtra(TYPE) + type = activityArguments[0] when (type) { "SND" -> { prefToken = "SND_FAV" @@ -195,7 +195,7 @@ class FavRemoveActivity : BaseActivity() { "RID" -> tmpLoc = shortCode + ": " + Utility.readPref(this, prefTokenLocation + shortCode, "") "NWSTEXT" -> tmpLoc = - GlobalArrays.nwsTextProducts[UtilityFavorites.findPositionNWSTEXT(shortCode)] + GlobalArrays.nwsTextProducts[UtilityFavorites.findPositionNwsText(shortCode)] "SREF" -> tmpLoc = shortCode "RIDCA" -> tmpLoc = findCARIDLabel(shortCode) "SPCMESO" -> tmpLoc = findSPCMesoLabel(shortCode) diff --git a/app/src/main/java/joshuatee/wx/settings/Location.kt b/app/src/main/java/joshuatee/wx/settings/Location.kt index 7bdda1ba..5632bdc5 100644 --- a/app/src/main/java/joshuatee/wx/settings/Location.kt +++ b/app/src/main/java/joshuatee/wx/settings/Location.kt @@ -316,7 +316,7 @@ class Location(val context: Context, locNumInt: Int) { wfo.toUpperCase(Locale.US) ) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } else if (xStr.contains("CANADA")) { var tmpLatlon = LatLonStr() diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteEditor.kt b/app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteEditor.kt index 528c8e6f..312acdb1 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteEditor.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteEditor.kt @@ -118,9 +118,7 @@ class SettingsColorPaletteEditor : BaseActivity(), OnMenuItemClickListener { UtilityAlertDialog.showHelpText(errorCheck, this) } val fileName = "colormap" + type + palTitle.text.toString() - UtilityLog.d("wx","COLORPAL CHECK: " + fileName) if (UtilityFileManagement.internalFileExist(context, fileName)) { - UtilityLog.d("wx","COLORPAL DELETE: " + fileName) UtilityFileManagement.deleteFile(context, fileName) } } @@ -175,7 +173,7 @@ class SettingsColorPaletteEditor : BaseActivity(), OnMenuItemClickListener { } } catch (e: Exception) { errors += "Problem parsing number." - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } } diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsLocationCanadaActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsLocationCanadaActivity.kt index b64585b9..0d75fb5d 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsLocationCanadaActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsLocationCanadaActivity.kt @@ -97,7 +97,7 @@ class SettingsLocationCanadaActivity : BaseActivity() { private fun getContent() = GlobalScope.launch(uiDispatcher) { withContext(Dispatchers.IO) { - val html = UtilityCanada.getProvHTML(provSelected) + val html = UtilityCanada.getProvidenceHtml(provSelected) listIds = html.parseColumn("
  • .*?
  • ") listCity = diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsLocationCanadaMapActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsLocationCanadaMapActivity.kt index 49e9674c..8412fde1 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsLocationCanadaMapActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsLocationCanadaMapActivity.kt @@ -137,7 +137,7 @@ class SettingsLocationCanadaMapActivity : BaseActivity(), OnClickListener { } private fun mapClicked(id: Int) { - val sector = UtilityImageMap.caMAP(id) + val sector = UtilityImageMap.canadaMap(id) val cityLoc = getCityFromXML(sector) Utility.writePref(this, "LOCATION_CANADA_PROV", url.toUpperCase()) Utility.writePref(this, "LOCATION_CANADA_CITY", cityLoc) @@ -195,7 +195,7 @@ class SettingsLocationCanadaMapActivity : BaseActivity(), OnClickListener { } while (line != null) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return "" } diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsLocationGenericActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsLocationGenericActivity.kt index 1a916b8c..3ec4f3b7 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsLocationGenericActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsLocationGenericActivity.kt @@ -69,6 +69,7 @@ class SettingsLocationGenericActivity : BaseActivity(), // manual interface for searching and saving a location // + // arg1 location number companion object { const val LOC_NUM: String = "" @@ -136,10 +137,10 @@ class SettingsLocationGenericActivity : BaseActivity(), var alertNotificationWpcmpdCurrent: String = Utility.readPref(this, "ALERT_NOTIFICATION_WPCMPD$locNum", "false") locLabelCurrent = Utility.readPref(this, "LOC" + locNum + "_LABEL", "") - val locNumIntCurrent = Location.numLocations - if (locNumInt == locNumIntCurrent + 1) { + // If this this is a new location + if (locNumInt == Location.numLocations + 1) { updateTitle = false - locNumToSaveStr = locNumIntCurrent.toString() + locNumToSaveStr = Location.numLocations.toString() locLabelCurrent = "Location $locNum" // // needed to prevent old location(deleted) data from showing up when adding new @@ -157,8 +158,8 @@ class SettingsLocationGenericActivity : BaseActivity(), alertNotificationWpcmpdCurrent = "false" } updateSubTitle() - val delB = me.findItem(R.id.action_delete) - delB.isVisible = locNumIntCurrent > 1 + val deleteButton = me.findItem(R.id.action_delete) + deleteButton.isVisible = Location.numLocations > 1 locLabelEt.setText(locLabelCurrent) locXEt.setText(locXStr) locYEt.setText(locYStr) @@ -170,7 +171,6 @@ class SettingsLocationGenericActivity : BaseActivity(), locXEt.setHintTextColor(Color.GRAY) locYEt.setHintTextColor(Color.GRAY) } - alertSw = ObjectSettingsCheckBox( this, this, @@ -243,16 +243,20 @@ class SettingsLocationGenericActivity : BaseActivity(), R.string.alert_wpcmpd_switch_text ) alertWpcmpdSw.isChecked(alertNotificationWpcmpdCurrent == "true") - linearLayout.addView(alertSw.card) - linearLayout.addView(alertSoundSw.card) - linearLayout.addView(alertRadar1Sw.card) - linearLayout.addView(alertCcSw.card) - linearLayout.addView(alert7Day1Sw.card) - linearLayout.addView(alertMcdSw.card) - linearLayout.addView(alertSwoSw.card) - linearLayout.addView(alertSpcfwSw.card) - linearLayout.addView(alertWpcmpdSw.card) - hideNONUSNotifs() + listOf( + alertSw, + alertSoundSw, + alertRadar1Sw, + alertCcSw, + alert7Day1Sw, + alertMcdSw, + alertSwoSw, + alertSpcfwSw, + alertWpcmpdSw + ).forEach{ + linearLayout.addView(it.card) + } + hideNonUSNotifications() if (locNumArr[1] != "") { if (locNumArr[1] == " roaming") { locLabelEt.setText(locNumArr[1].toUpperCase(Locale.US)) @@ -302,17 +306,6 @@ class SettingsLocationGenericActivity : BaseActivity(), Utility.readPref(this, "ALERT_NOTIFICATION_SPCFW$locNum", "false") val alertNotificationWpcmpdCurrent = Utility.readPref(this, "ALERT_NOTIFICATION_WPCMPD$locNum", "false") - - /*alertRadar1Sw.card.visibility = View.VISIBLE - alertSoundSw.card.visibility = View.VISIBLE - alert7Day1Sw.card.visibility = View.VISIBLE - alertCcSw.card.visibility = View.VISIBLE - alertSw.card.visibility = View.VISIBLE - alertMcdSw.card.visibility = View.VISIBLE - alertSwoSw.card.visibility = View.VISIBLE - alertSpcfwSw.card.visibility = View.VISIBLE - alertWpcmpdSw.card.visibility = View.VISIBLE*/ - listOf(alertRadar1Sw, alertSoundSw, alert7Day1Sw, @@ -325,7 +318,6 @@ class SettingsLocationGenericActivity : BaseActivity(), ).forEach{ it.card.visibility = View.VISIBLE } - alertSw.isChecked(alertNotificationCurrent == "true") alertCcSw.isChecked(alertCcNotificationCurrent == "true") alert7Day1Sw.isChecked(alert7Day1NotificationCurrent == "true") @@ -335,8 +327,7 @@ class SettingsLocationGenericActivity : BaseActivity(), alertSwoSw.isChecked(alertNotificationSwoCurrent == "true") alertSpcfwSw.isChecked(alertNotificationSpcfwCurrent == "true") alertWpcmpdSw.isChecked(alertNotificationWpcmpdCurrent == "true") - - hideNONUSNotifs() + hideNonUSNotifications() } private fun saveLoc( @@ -366,7 +357,7 @@ class SettingsLocationGenericActivity : BaseActivity(), private fun addressSearch(type: String, address: String) = GlobalScope.launch(uiDispatcher) { var xyStr = listOf() if (type == "osm") xyStr = - withContext(Dispatchers.IO) { UtilityLocation.getXYFromAddressOSM(address) } + withContext(Dispatchers.IO) { UtilityLocation.getXYFromAddressOsm(address) } locXEt.setText(xyStr[0]) locYEt.setText(xyStr[1]) } @@ -447,12 +438,11 @@ class SettingsLocationGenericActivity : BaseActivity(), } }) menuLocal = menu - // set sv text black if white theme - // thanks David_E http://stackoverflow.com/questions/27156680/change-textcolor-in-searchview-using-android-toolbar - if (UIPreferences.themeIsWhite) changeSearchViewTextColor(searchView) + if (UIPreferences.themeIsWhite){ + changeSearchViewTextColor(searchView) + } // the SearchView's AutoCompleteTextView drop down. For some reason this wasn't working in styles.xml - val autoCompleteTextView: SearchView.SearchAutoComplete = - searchView.findViewById(R.id.search_src_text) + val autoCompleteTextView: SearchView.SearchAutoComplete = searchView.findViewById(R.id.search_src_text) if (UIPreferences.themeIsWhite) autoCompleteTextView.setDropDownBackgroundResource(R.drawable.dr_white) else @@ -493,7 +483,7 @@ class SettingsLocationGenericActivity : BaseActivity(), this, WebscreenAB::class.java, WebscreenAB.URL, - arrayOf(UtilityMap.genMapURL(xStr, yStr, "9"), "wX") + arrayOf(UtilityMap.genMapUrl(xStr, yStr, "9"), "wX") ) } else { val addressForMap = locLabelEt.text.toString() @@ -501,25 +491,25 @@ class SettingsLocationGenericActivity : BaseActivity(), this, WebscreenAB::class.java, WebscreenAB.URL, - arrayOf(UtilityMap.genMapURLFromStreetAddress(addressForMap), "wX") + arrayOf(UtilityMap.genMapUrlFromStreetAddress(addressForMap), "wX") ) } } } R.id.action_ca -> ObjectIntent(this, SettingsLocationCanadaActivity::class.java) - R.id.action_ab -> openCAMap("ab") - R.id.action_bc -> openCAMap("bc") - R.id.action_mb -> openCAMap("mb") - R.id.action_nb -> openCAMap("nb") - R.id.action_nl -> openCAMap("nl") - R.id.action_ns -> openCAMap("ns") - R.id.action_nt -> openCAMap("nt") - R.id.action_nu -> openCAMap("nu") - R.id.action_on -> openCAMap("on") - R.id.action_pe -> openCAMap("pe") - R.id.action_qc -> openCAMap("qc") - R.id.action_sk -> openCAMap("sk") - R.id.action_yt -> openCAMap("yt") + R.id.action_ab -> openCanadaMap("ab") + R.id.action_bc -> openCanadaMap("bc") + R.id.action_mb -> openCanadaMap("mb") + R.id.action_nb -> openCanadaMap("nb") + R.id.action_nl -> openCanadaMap("nl") + R.id.action_ns -> openCanadaMap("ns") + R.id.action_nt -> openCanadaMap("nt") + R.id.action_nu -> openCanadaMap("nu") + R.id.action_on -> openCanadaMap("on") + R.id.action_pe -> openCanadaMap("pe") + R.id.action_qc -> openCanadaMap("qc") + R.id.action_sk -> openCanadaMap("sk") + R.id.action_yt -> openCanadaMap("yt") R.id.action_vr -> { val i = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH) i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US") @@ -543,7 +533,7 @@ class SettingsLocationGenericActivity : BaseActivity(), when (item.itemId) { R.id.action_locate -> { if (Build.VERSION.SDK_INT < 23) { - val xy = UtilityLocation.getGPS(this) + val xy = UtilityLocation.getGps(this) locXEt.setText(xy[0].toString()) locYEt.setText(xy[1].toString()) } else { @@ -552,9 +542,10 @@ class SettingsLocationGenericActivity : BaseActivity(), Manifest.permission.ACCESS_FINE_LOCATION ) == PackageManager.PERMISSION_GRANTED ) { - val xy = UtilityLocation.getGPS(this) + val xy = UtilityLocation.getGps(this) locXEt.setText(xy[0].toString()) locYEt.setText(xy[1].toString()) + fabSaveLocation() } else { // The ACCESS_FINE_LOCATION is denied, then I request it and manage the result in // onRequestPermissionsResult() using the constant myPermissionAccessFineLocation @@ -586,7 +577,7 @@ class SettingsLocationGenericActivity : BaseActivity(), ) { when (requestCode) { myPermissionAccessFineLocation -> if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - val xy = UtilityLocation.getGPS(this) + val xy = UtilityLocation.getGps(this) locXEt.setText(xy[0].toString()) locYEt.setText(xy[1].toString()) } @@ -616,7 +607,7 @@ class SettingsLocationGenericActivity : BaseActivity(), var goodLocation = false withContext(Dispatchers.IO) { if (type == "osm") { - xyStr = UtilityLocation.getXYFromAddressOSM(address) + xyStr = UtilityLocation.getXYFromAddressOsm(address) if (xyStr.size > 1) { toastStr = Location.locationSave(contextg, locNum, xyStr[0], xyStr[1], labelStr) goodLocation = true @@ -637,7 +628,7 @@ class SettingsLocationGenericActivity : BaseActivity(), GlobalScope.launch(uiDispatcher) { var toastStr = "" var goodLocation = false - val xy = UtilityLocation.getGPS(contextg) + val xy = UtilityLocation.getGps(contextg) locXEt.setText(xy[0].toString()) locYEt.setText(xy[1].toString()) withContext(Dispatchers.IO) { @@ -670,7 +661,7 @@ class SettingsLocationGenericActivity : BaseActivity(), } } - private fun hideNONUSNotifs() { + private fun hideNonUSNotifications() { val label = locXEt.text.toString() if (label.contains("CANADA")) { notifsCa(true) @@ -705,7 +696,7 @@ class SettingsLocationGenericActivity : BaseActivity(), saveLoc("osm", locNum, xStr, yStr, labelStr) } - private fun openCAMap(s: String) { + private fun openCanadaMap(s: String) { ObjectIntent( this, SettingsLocationCanadaMapActivity::class.java, diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsLocationRecyclerViewActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsLocationRecyclerViewActivity.kt index b508a9b7..75c53b1d 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsLocationRecyclerViewActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsLocationRecyclerViewActivity.kt @@ -39,8 +39,6 @@ import joshuatee.wx.ui.ObjectFab import joshuatee.wx.ui.ObjectRecyclerViewGeneric import joshuatee.wx.ui.UtilityUI import joshuatee.wx.util.ObjectForecastPackageCurrentConditions -import joshuatee.wx.util.Utility -import joshuatee.wx.util.UtilityLog import kotlinx.coroutines.* class SettingsLocationRecyclerViewActivity : BaseActivity() { @@ -79,9 +77,9 @@ class SettingsLocationRecyclerViewActivity : BaseActivity() { currentConditions.clear() withContext(Dispatchers.IO) { for (index in MyApplication.locations.indices) { - currentConditions.add(Utility.getCurrentConditions(contextg, index)) + currentConditions.add(ObjectForecastPackageCurrentConditions(contextg, index)) currentConditions[index].formatCC() - UtilityLog.d("wx", currentConditions[index].ccLine1) + //UtilityLog.d("wx", currentConditions[index].topLine) } } updateListWithCurrentConditions() @@ -103,8 +101,8 @@ class SettingsLocationRecyclerViewActivity : BaseActivity() { val locNumIntCurrent = Location.numLocations locArr.clear() (0 until locNumIntCurrent).forEach { - MyApplication.locations[it].updateObservation(currentConditions[it].ccLine1) - locArr.add(currentConditions[it].ccLine1) + MyApplication.locations[it].updateObservation(currentConditions[it].topLine) + locArr.add(currentConditions[it].topLine) } } diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsMainActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsMainActivity.kt index dd6a1bd9..351d7b4f 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsMainActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsMainActivity.kt @@ -128,7 +128,7 @@ class SettingsMainActivity : BaseActivity() { contextg, TextScreenActivity::class.java, TextScreenActivity.URL, - arrayOf(UtilityMath.cToFTable(), "Celsius to Fahrenheit table") + arrayOf(UtilityMath.celsiusToFahrenheitTable(), "Celsius to Fahrenheit table") ) }) cardbackuppref.setOnClickListener(View.OnClickListener { backuprestore.backupPrefs(contextg) }) @@ -147,23 +147,7 @@ class SettingsMainActivity : BaseActivity() { arrayOf(UtilityAlertDialog.showVersion(this, this), "About wX") ) }) - - /*ll.addView(cardAbout.card) - ll.addView(cardLocations.card) - ll.addView(cardsn.card) - ll.addView(cardNotif.card) - ll.addView(cardWidgets.card) - ll.addView(cardColors.card) - ll.addView(cardPL.card) - ll.addView(cardRadar.card) - ll.addView(cardHS.card) - ll.addView(cardUI.card) - ll.addView(cardCtoF.card) - ll.addView(cardDeleteFiles.card) - ll.addView(cardbackuppref.card) - ll.addView(cardrestorepref.card)*/ - - listOf( + listOf( cardAbout.card, cardLocations.card, cardsn.card, diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsRadarActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsRadarActivity.kt index c3d024d5..4596e489 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsRadarActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsRadarActivity.kt @@ -574,6 +574,18 @@ class SettingsRadarActivity : BaseActivity() { ).card ) + ll.addView( + ObjectSettingsSeekbar( + this, + this, + "Conus Radar Zoom", + "CONUS_RADAR_ZOOM", + R.string.conus_radar_zoom_label, + 173, + 1, + 530 + ).card + ) ll.addView(ObjectSettingsSeekbar(this, this, "Location dot size", "RADAR_LOCDOT_SIZE", R.string.locdot_size_np, 10, 1, 75).card) ll.addView(ObjectSettingsSeekbar(this, this, "Location icon size", "RADAR_LOCICON_SIZE", R.string.locicon_size_np, 75, 1, 530).card) diff --git a/app/src/main/java/joshuatee/wx/settings/TileObjectColorPalette.kt b/app/src/main/java/joshuatee/wx/settings/TileObjectColorPalette.kt index 8f7392fa..36fb186b 100644 --- a/app/src/main/java/joshuatee/wx/settings/TileObjectColorPalette.kt +++ b/app/src/main/java/joshuatee/wx/settings/TileObjectColorPalette.kt @@ -68,7 +68,7 @@ internal class TileObjectColorPalette( try { UtilityColorPaletteGeneric.loadColorMap(context, prod) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } bitmap = UtilityUSImgWX.bitmapForColorPalette(context, prod) bitmapWithText = UtilityImg.drawTextToBitmap(context, bitmap, colorMapLabel, textColor) diff --git a/app/src/main/java/joshuatee/wx/settings/UtilityLocation.kt b/app/src/main/java/joshuatee/wx/settings/UtilityLocation.kt index 7936faa8..e6bcb703 100644 --- a/app/src/main/java/joshuatee/wx/settings/UtilityLocation.kt +++ b/app/src/main/java/joshuatee/wx/settings/UtilityLocation.kt @@ -69,18 +69,18 @@ object UtilityLocation { return latlonAl } - fun getXYFromAddressOSM(addressF: String): List { + fun getXYFromAddressOsm(addressF: String): List { val address = addressF.replace(" ", "+") val url = "http://nominatim.openstreetmap.org/search?q=$address&format=xml&polygon=0&addressdetails=1" - return UtilityString.getHTMLandParseMultipeFirstMatch( + return UtilityString.getHtmlAndParseMultipleFirstMatch( url, "lat=.(.*?).\\slon=.(.*?).\\s", 2 ).toList() } - fun getGPS(context: Context): DoubleArray { + fun getGps(context: Context): DoubleArray { val lm = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager val providers = lm.getProviders(true) var l: Location? = null @@ -209,7 +209,7 @@ object UtilityLocation { } fun checkRoamingLocation(context: Context, locNum: String, xStr: String, yStr: String) { - val currentXY = getGPS(context) + val currentXY = getGps(context) val roamingLocationDistanceCheck = Utility.readPref(context, "ROAMING_LOCATION_DISTANCE_CHECK", 5) val locX = xStr.toDoubleOrNull() ?: 0.0 @@ -246,7 +246,7 @@ object UtilityLocation { val locNumToSaveStr = locNumIntCurrent.toString() val loc = Utility.readPref(context, "NWS_LOCATION_$nwsOffice", "") val addrSend = loc.replace(" ", "+") - val xyStr = getXYFromAddressOSM(addrSend) + val xyStr = getXYFromAddressOsm(addrSend) toastStr = joshuatee.wx.settings.Location.locationSave( context, locNumToSaveStr, diff --git a/app/src/main/java/joshuatee/wx/spc/LSRbyWFOActivity.kt b/app/src/main/java/joshuatee/wx/spc/LSRbyWFOActivity.kt index 55d14b8d..7256d7f9 100644 --- a/app/src/main/java/joshuatee/wx/spc/LSRbyWFOActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/LSRbyWFOActivity.kt @@ -64,7 +64,7 @@ class LSRbyWFOActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItem private val uiDispatcher: CoroutineDispatcher = Dispatchers.Main private var firstTime = true private var prod = "" - private var nwsOffice = "" + private var wfo = "" private lateinit var imageMap: ObjectImageMap private var mapShown = false private lateinit var star: MenuItem @@ -83,34 +83,34 @@ class LSRbyWFOActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItem toolbarBottom.setOnMenuItemClickListener(this) star = toolbarBottom.menu.findItem(R.id.action_fav) val turl = intent.getStringArrayExtra(URL) - nwsOffice = turl[0] - if (nwsOffice == "") - nwsOffice = "OUN" + wfo = turl[0] + if (wfo == "") + wfo = "OUN" prod = if (turl[1] == "") MyApplication.wfoTextFav else turl[1] toolbar.title = prod locations = UtilityFavorites.setupFavMenu( - this, - MyApplication.wfoFav, - nwsOffice, - prefTokenLocation, - prefToken + this, + MyApplication.wfoFav, + wfo, + prefTokenLocation, + prefToken ) sp = ObjectSpinner(this, this, this, R.id.spinner1, locations) imageMap = ObjectImageMap(this, this, R.id.map, toolbar, toolbarBottom, listOf(scrollView)) - imageMap.addClickHandler(::mapSwitch, UtilityImageMap::maptoWFO) + imageMap.addClickHandler(::mapSwitch, UtilityImageMap::mapToWfo) } override fun onRestart() { if (ridFavOld != MyApplication.wfoFav) { locations = UtilityFavorites.setupFavMenu( - this, - MyApplication.wfoFav, - nwsOffice, - prefTokenLocation, - prefToken + this, + MyApplication.wfoFav, + wfo, + prefTokenLocation, + prefToken ) sp.refreshData(contextg, locations) } @@ -118,15 +118,15 @@ class LSRbyWFOActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItem } override fun onMenuItemClick(item: MenuItem): Boolean { - if (audioPlayMenu(item.itemId, wfoProd.toString(), prod, prod + nwsOffice)) + if (audioPlayMenu(item.itemId, wfoProd.toString(), prod, prod + wfo)) return true when (item.itemId) { R.id.action_fav -> toggleFavorite() R.id.action_map -> imageMap.toggleMap() R.id.action_share -> UtilityShare.shareText( - this, - prod + nwsOffice, - Utility.fromHtml(wfoProd.toString()) + this, + prod + wfo, + Utility.fromHtml(wfoProd.toString()) ) else -> return super.onOptionsItemSelected(item) } @@ -135,22 +135,22 @@ class LSRbyWFOActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItem private fun mapSwitch(loc: String) { scrollView.visibility = View.VISIBLE - nwsOffice = loc.toUpperCase(Locale.US) + wfo = loc.toUpperCase(Locale.US) mapShown = false locations = UtilityFavorites.setupFavMenu( - this, - MyApplication.wfoFav, - nwsOffice, - prefTokenLocation, - prefToken + this, + MyApplication.wfoFav, + wfo, + prefTokenLocation, + prefToken ) sp.refreshData(contextg, locations) } private fun toggleFavorite() { - val ridFav = UtilityFavorites.toggleFavoriteString(this, nwsOffice, star, prefToken) + val ridFav = UtilityFavorites.toggleFavoriteString(this, wfo, star, prefToken) locations = - UtilityFavorites.setupFavMenu(this, ridFav, nwsOffice, prefTokenLocation, prefToken) + UtilityFavorites.setupFavMenu(this, ridFav, wfo, prefTokenLocation, prefToken) sp.refreshData(contextg, locations) } @@ -158,19 +158,19 @@ class LSRbyWFOActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItem if (locations.isNotEmpty()) { when (pos) { 1 -> ObjectIntent( - this, - FavAddActivity::class.java, - FavAddActivity.TYPE, - arrayOf("WFO") + this, + FavAddActivity::class.java, + FavAddActivity.TYPE, + arrayOf("WFO") ) 2 -> ObjectIntent( - this, - FavRemoveActivity::class.java, - FavRemoveActivity.TYPE, - arrayOf("WFO") + this, + FavRemoveActivity::class.java, + FavRemoveActivity.TYPE, + arrayOf("WFO") ) else -> { - nwsOffice = locations[pos].split(" ").getOrNull(0) ?: "" + wfo = locations[pos].split(" ").getOrNull(0) ?: "" getContent() } } @@ -186,17 +186,17 @@ class LSRbyWFOActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItem private fun getContent() = GlobalScope.launch(uiDispatcher) { scrollView.smoothScrollTo(0, 0) ridFavOld = MyApplication.wfoFav - wfoProd = withContext(Dispatchers.IO) { lsrFromWFO } + wfoProd = withContext(Dispatchers.IO) { lsrFromWfo } linearLayout.removeAllViewsInLayout() wfoProd.forEach { ObjectCardText(contextg, linearLayout, Utility.fromHtml(it)) } } - private val lsrFromWFO: List + private val lsrFromWfo: List get() { val lsrArr = mutableListOf() - val numberLSR = UtilityString.getHTMLandParseLastMatch( - "http://forecast.weather.gov/product.php?site=$nwsOffice&issuedby=$nwsOffice&product=LSR&format=txt&version=1&glossary=0", - "product=LSR&format=TXT&version=(.*?)&glossary" + val numberLSR = UtilityString.getHtmlAndParseLastMatch( + "http://forecast.weather.gov/product.php?site=$wfo&issuedby=$wfo&product=LSR&format=txt&version=1&glossary=0", + "product=LSR&format=TXT&version=(.*?)&glossary" ) if (numberLSR == "") { lsrArr.add("None issued by this office recently.") @@ -207,8 +207,8 @@ class LSRbyWFOActivity : AudioPlayActivity(), OnItemSelectedListener, OnMenuItem } (1..maxVers + 1 step 2).mapTo(lsrArr) { UtilityDownload.getTextProduct( - "LSR$nwsOffice", - it + "LSR$wfo", + it ) } } diff --git a/app/src/main/java/joshuatee/wx/spc/ObjectWatchProduct.kt b/app/src/main/java/joshuatee/wx/spc/ObjectWatchProduct.kt index abe018b1..9a0bc603 100644 --- a/app/src/main/java/joshuatee/wx/spc/ObjectWatchProduct.kt +++ b/app/src/main/java/joshuatee/wx/spc/ObjectWatchProduct.kt @@ -44,7 +44,7 @@ internal class ObjectWatchProduct(type: PolygonType, productNumber: String) { private set var text = "" private set - var wfoArr = listOf() + var wfos = listOf() private set init { @@ -79,8 +79,8 @@ internal class ObjectWatchProduct(type: PolygonType, productNumber: String) { fun getData(context: Context) { text = UtilityDownload.getTextProduct(context, prod) bitmap = imgUrl.getImage() - val wfoStr = text.parse("ATTN...WFO...(.*?)...

    ") - wfoArr = wfoStr.split("\\.\\.\\.".toRegex()).dropLastWhile { it.isEmpty() } + val wfoString = text.parse("ATTN...WFO...(.*?)...

    ") + wfos = wfoString.split("\\.\\.\\.".toRegex()).dropLastWhile { it.isEmpty() } } val textForSubtitle: String diff --git a/app/src/main/java/joshuatee/wx/spc/SPCMCDWShowActivity.kt b/app/src/main/java/joshuatee/wx/spc/SPCMCDWShowActivity.kt index 8aecb20c..78a3342a 100644 --- a/app/src/main/java/joshuatee/wx/spc/SPCMCDWShowActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SPCMCDWShowActivity.kt @@ -105,14 +105,14 @@ class SPCMCDWShowActivity : AudioPlayActivity(), OnMenuItemClickListener { override fun onCreateContextMenu(menu: ContextMenu, v: View, menuInfo: ContextMenuInfo?) { super.onCreateContextMenu(menu, v, menuInfo) - (0 until objWatch.wfoArr.size - 1).forEach { + (0 until objWatch.wfos.size - 1).forEach { menu.add( 0, v.id, 0, - "Add location: " + objWatch.wfoArr[it] + " - " + Utility.readPref( + "Add location: " + objWatch.wfos[it] + " - " + Utility.readPref( this, - "NWS_LOCATION_" + objWatch.wfoArr[it], + "NWS_LOCATION_" + objWatch.wfos[it], "" ) ) @@ -121,11 +121,11 @@ class SPCMCDWShowActivity : AudioPlayActivity(), OnMenuItemClickListener { override fun onContextItemSelected(item: MenuItem): Boolean { val itemStr = item.title.toString() - (0 until objWatch.wfoArr.size - 1) - .filter { itemStr.contains(objWatch.wfoArr[it]) } + (0 until objWatch.wfos.size - 1) + .filter { itemStr.contains(objWatch.wfos[it]) } .forEach { UtilityLocation.saveLocationForMcd( - objWatch.wfoArr[it], + objWatch.wfos[it], contextg, ll, uiDispatcher diff --git a/app/src/main/java/joshuatee/wx/spc/SPCMCDWShowSummaryActivity.kt b/app/src/main/java/joshuatee/wx/spc/SPCMCDWShowSummaryActivity.kt index 690e0cd5..f52386ea 100644 --- a/app/src/main/java/joshuatee/wx/spc/SPCMCDWShowSummaryActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SPCMCDWShowSummaryActivity.kt @@ -150,7 +150,7 @@ class SPCMCDWShowSummaryActivity : AudioPlayActivity(), OnMenuItemClickListener bitmaps.add(imgUrl.getImage()) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } if (mcdList.size == 1) { if (number.contains("at")) { diff --git a/app/src/main/java/joshuatee/wx/spc/SPCMesoActivity.kt b/app/src/main/java/joshuatee/wx/spc/SPCMesoActivity.kt index da84f7b1..c8d6d704 100644 --- a/app/src/main/java/joshuatee/wx/spc/SPCMesoActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SPCMesoActivity.kt @@ -102,13 +102,13 @@ class SPCMesoActivity : VideoRecordActivity(), OnMenuItemClickListener, @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { - var args = intent.getStringArrayExtra(INFO) + var activityArguments = intent.getStringArrayExtra(INFO) contextg = this - if (args == null) { - args = arrayOf("", "1", "SPCMESO") + if (activityArguments == null) { + activityArguments = arrayOf("", "1", "SPCMESO") } - val numPanesStr = args[1] - numPanes = numPanesStr.toIntOrNull() ?: 0 + val numPanesAsString = activityArguments[1] + numPanes = numPanesAsString.toIntOrNull() ?: 0 if (numPanes == 1) { super.onCreate( savedInstanceState, @@ -127,10 +127,10 @@ class SPCMesoActivity : VideoRecordActivity(), OnMenuItemClickListener, ) } toolbarBottom.setOnMenuItemClickListener(this) - prefModel = args[2] - prefSector = prefModel + numPanesStr + "_SECTOR_LAST_USED" - prefParam = prefModel + numPanesStr + "_PARAM_LAST_USED" - prefParamLabel = prefModel + numPanesStr + "_PARAM_LAST_USED_LABEL" + prefModel = activityArguments[2] + prefSector = prefModel + numPanesAsString + "_SECTOR_LAST_USED" + prefParam = prefModel + numPanesAsString + "_PARAM_LAST_USED" + prefParamLabel = prefModel + numPanesAsString + "_PARAM_LAST_USED_LABEL" displayData = DisplayData(this, this, numPanes, ObjectSpinner(this as Context)) displayData.param[0] = "pmsl" displayData.paramLabel[0] = "MSL Pressure/Wind" @@ -138,8 +138,8 @@ class SPCMesoActivity : VideoRecordActivity(), OnMenuItemClickListener, displayData.param[1] = "500mb" displayData.paramLabel[1] = "500mb Analysis" } - if (args[0] != "" && numPanes == 1) { - val tmpArrFav = UtilitySPCMESO.setParamFromFav(args[0]) + if (activityArguments[0] != "" && numPanes == 1) { + val tmpArrFav = UtilitySPCMESO.setParamFromFav(activityArguments[0]) displayData.param[0] = tmpArrFav[0] displayData.paramLabel[0] = tmpArrFav[1] } else { @@ -193,11 +193,11 @@ class SPCMesoActivity : VideoRecordActivity(), OnMenuItemClickListener, } }) } - favListLabel = UtilityFavorites.setupFavMenuSPCMESO( + favListLabel = UtilityFavorites.setupFavMenuSpcMeso( MyApplication.spcmesoLabelFav, displayData.paramLabel[curImg] ) - favListParm = UtilityFavorites.setupFavMenuSPCMESO( + favListParm = UtilityFavorites.setupFavMenuSpcMeso( MyApplication.spcmesoFav, displayData.param[curImg] ) @@ -223,11 +223,11 @@ class SPCMesoActivity : VideoRecordActivity(), OnMenuItemClickListener, } override fun onRestart() { - favListLabel = UtilityFavorites.setupFavMenuSPCMESO( + favListLabel = UtilityFavorites.setupFavMenuSpcMeso( MyApplication.spcmesoLabelFav, displayData.paramLabel[curImg] ) - favListParm = UtilityFavorites.setupFavMenuSPCMESO( + favListParm = UtilityFavorites.setupFavMenuSpcMeso( MyApplication.spcmesoFav, displayData.param[curImg] ) @@ -273,10 +273,6 @@ class SPCMesoActivity : VideoRecordActivity(), OnMenuItemClickListener, imageLoaded = true if (numPanes > 1) { setTitle() - /*UtilityModels.setSubtitleRestoreIMGXYZOOM( - displayData.img, toolbar, "(" + (curImg + 1) + ")" - + displayData.paramLabel[0] + "/" + displayData.paramLabel[1] - )*/ } } @@ -401,27 +397,17 @@ class SPCMesoActivity : VideoRecordActivity(), OnMenuItemClickListener, R.id.action_img1 -> { curImg = 0 setTitle() - /*UtilityModels.setSubtitleRestoreIMGXYZOOM( - displayData.img, - toolbar, - "(" + (curImg + 1) + ")" + displayData.paramLabel[0] + "/" + displayData.paramLabel[1] - )*/ } R.id.action_img2 -> { curImg = 1 setTitle() - /*UtilityModels.setSubtitleRestoreIMGXYZOOM( - displayData.img, - toolbar, - "(" + (curImg + 1) + ")" + displayData.paramLabel[0] + "/" + displayData.paramLabel[1] - )*/ } else -> return super.onOptionsItemSelected(item) } return true } - fun setTitle() { + private fun setTitle() { UtilityModels.setSubtitleRestoreIMGXYZOOM( displayData.img, toolbar, @@ -513,17 +499,17 @@ class SPCMesoActivity : VideoRecordActivity(), OnMenuItemClickListener, } private fun toggleFavorite() { - UtilityFavorites.toggleFavoriteSPCMESO( + UtilityFavorites.toggleFavoriteSpcMeso( this, displayData.param[curImg], displayData.paramLabel[curImg], star ) - favListLabel = UtilityFavorites.setupFavMenuSPCMESO( + favListLabel = UtilityFavorites.setupFavMenuSpcMeso( MyApplication.spcmesoLabelFav, displayData.paramLabel[curImg] ) - favListParm = UtilityFavorites.setupFavMenuSPCMESO( + favListParm = UtilityFavorites.setupFavMenuSpcMeso( MyApplication.spcmesoFav, displayData.param[curImg] ) @@ -567,11 +553,11 @@ class SPCMesoActivity : VideoRecordActivity(), OnMenuItemClickListener, override fun onNothingSelected(parent: AdapterView<*>) {} private fun refreshSpinner() { - favListLabel = UtilityFavorites.setupFavMenuSPCMESO( + favListLabel = UtilityFavorites.setupFavMenuSpcMeso( MyApplication.spcmesoLabelFav, displayData.paramLabel[curImg] ) - favListParm = UtilityFavorites.setupFavMenuSPCMESO( + favListParm = UtilityFavorites.setupFavMenuSpcMeso( MyApplication.spcmesoFav, displayData.param[curImg] ) diff --git a/app/src/main/java/joshuatee/wx/spc/SPCSoundingsActivity.kt b/app/src/main/java/joshuatee/wx/spc/SPCSoundingsActivity.kt index 300da59c..1f3348e1 100644 --- a/app/src/main/java/joshuatee/wx/spc/SPCSoundingsActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SPCSoundingsActivity.kt @@ -85,7 +85,7 @@ class SPCSoundingsActivity : BaseActivity(), OnItemSelectedListener, sp = ObjectSpinner(this, this, this, R.id.spinner1, locations) imageMap = ObjectImageMap(this, this, R.id.map, toolbar, toolbarBottom, listOf(img.img)) - imageMap.addClickHandler(::mapSwitch, UtilityImageMap::maptoSND) + imageMap.addClickHandler(::mapSwitch, UtilityImageMap::mapToSnd) } override fun onRestart() { @@ -118,7 +118,7 @@ class SPCSoundingsActivity : BaseActivity(), OnItemSelectedListener, private fun getContentSPCPlot() = GlobalScope.launch(uiDispatcher) { imgUrl = "${MyApplication.nwsSPCwebsitePrefix}/obswx/maps/$upperAir" withContext(Dispatchers.IO) { - val date = UtilityString.getHTMLandParse( + val date = UtilityString.getHtmlAndParse( "${MyApplication.nwsSPCwebsitePrefix}/obswx/maps/", "/obswx/maps/" + upperAir + "_([0-9]{6}_[0-9]{2}).gif" ) diff --git a/app/src/main/java/joshuatee/wx/spc/SPCStormReportsActivity.kt b/app/src/main/java/joshuatee/wx/spc/SPCStormReportsActivity.kt index 5bd4acbe..7f52293a 100644 --- a/app/src/main/java/joshuatee/wx/spc/SPCStormReportsActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SPCStormReportsActivity.kt @@ -208,7 +208,7 @@ class SPCStormReportsActivity : AudioPlayActivity(), OnMenuItemClickListener { contextg, WebscreenAB::class.java, WebscreenAB.URL, - arrayOf(UtilityMap.genMapURL(xStr, yStr, "10"), "$xStr,$yStr") + arrayOf(UtilityMap.genMapUrl(xStr, yStr, "10"), "$xStr,$yStr") ) }) if (s.text.contains("(") && s.text.contains(")")) { diff --git a/app/src/main/java/joshuatee/wx/spc/UtilitySPCMESOInputOutput.kt b/app/src/main/java/joshuatee/wx/spc/UtilitySPCMESOInputOutput.kt index 6d977827..f59292bb 100644 --- a/app/src/main/java/joshuatee/wx/spc/UtilitySPCMESOInputOutput.kt +++ b/app/src/main/java/joshuatee/wx/spc/UtilitySPCMESOInputOutput.kt @@ -118,7 +118,7 @@ object UtilitySPCMESOInputOutput { -1 ).mapTo(urlAl) { "${MyApplication.nwsSPCwebsitePrefix}/exper/mesoanalysis/s" + sector + "/" + param + "/" + param + "_" + timeList[it] + ".gif" } } - return UtilityImgAnim.getAnimationDrawableFromURLListWhiteBG(context, urlAl, delay) + return UtilityImgAnim.getAnimationDrawableFromUrlListWhiteBG(context, urlAl, delay) } private fun stride(start: Int, end: Int, incr: Int): IntArray { diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectAlertDetail.kt b/app/src/main/java/joshuatee/wx/ui/ObjectAlertDetail.kt index 9aae7597..e94d37d7 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectAlertDetail.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectAlertDetail.kt @@ -31,6 +31,7 @@ import joshuatee.wx.R import joshuatee.wx.UIPreferences import joshuatee.wx.activitiesmisc.CAPAlert import joshuatee.wx.util.Utility +import joshuatee.wx.util.UtilityLog import joshuatee.wx.util.UtilityString class ObjectAlertDetail(val context: Context, ll: LinearLayout) { @@ -83,7 +84,7 @@ class ObjectAlertDetail(val context: Context, ll: LinearLayout) { } else { if (!url.contains("NWS-IDP-PROD")) { if (ca.title.contains("until")) { - val tmpArr = UtilityString.parseMultipe( + val tmpArr = UtilityString.parseMultiple( ca.title, "(.*?) issued (.*?) until (.*?) by (.*?)$", 4 @@ -94,7 +95,7 @@ class ObjectAlertDetail(val context: Context, ll: LinearLayout) { wfo = tmpArr[3] } else { val tmpArr = - UtilityString.parseMultipe(ca.title, "(.*?) issued (.*?) by (.*?)$", 3) + UtilityString.parseMultiple(ca.title, "(.*?) issued (.*?) by (.*?)$", 3) title = tmpArr[0] startTime = tmpArr[1] wfo = tmpArr[2] @@ -102,7 +103,7 @@ class ObjectAlertDetail(val context: Context, ll: LinearLayout) { } else { when { ca.title.contains("expiring") -> { - val tmpArr = UtilityString.parseMultipe( + val tmpArr = UtilityString.parseMultiple( ca.title, "(.*?) issued (.*?) expiring (.*?) by (.*?)$", 4 @@ -113,7 +114,7 @@ class ObjectAlertDetail(val context: Context, ll: LinearLayout) { wfo = tmpArr[3] } ca.title.contains("until") -> { - val tmpArr = UtilityString.parseMultipe( + val tmpArr = UtilityString.parseMultiple( ca.title, "(.*?) issued (.*?) until (.*?) by (.*?)$", 4 @@ -125,7 +126,7 @@ class ObjectAlertDetail(val context: Context, ll: LinearLayout) { } else -> { val tmpArr = - UtilityString.parseMultipe(ca.title, "(.*?) issued (.*?) by (.*?)$", 3) + UtilityString.parseMultiple(ca.title, "(.*?) issued (.*?) by (.*?)$", 3) title = tmpArr[0] startTime = tmpArr[1] wfo = tmpArr[2] @@ -136,8 +137,8 @@ class ObjectAlertDetail(val context: Context, ll: LinearLayout) { tvArr[1].text = context.resources.getString(R.string.uswarn_end_time, endTime) tvArr[2].text = ca.area tvArr[2].setTextColor(UIPreferences.textHighlightColor) - tvArr[3].text = Utility.fromHtml(ca.summary) - tvArr[4].text = Utility.fromHtml(ca.instructions) + tvArr[3].text = ca.summary + tvArr[4].text = ca.instructions } wfoTitle = wfo } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectAlertSummary.kt b/app/src/main/java/joshuatee/wx/ui/ObjectAlertSummary.kt index 890a0635..ee83b661 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectAlertSummary.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectAlertSummary.kt @@ -171,7 +171,7 @@ class ObjectAlertSummary( //} } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } var mapOut = map.toString() diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCAWARN.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCAWARN.kt index 4e5bd1eb..44d47962 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCAWARN.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCAWARN.kt @@ -91,7 +91,7 @@ class ObjectCAWARN( ".*?.*?.*?.*?.*?.*?(.*?).*?" ) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCard7Day.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCard7Day.kt index e0902789..02721816 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCard7Day.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCard7Day.kt @@ -80,7 +80,7 @@ class ObjectCard7Day(context: Context, bm: Bitmap, isUS: Boolean, day: Int, day7 if (dayTmpArr.size > 1) { if (isUS) { setTv1( - dayTmpArr[0].replace(":", " ") + " (" + UtilityLocationFragment.extractTemp( + dayTmpArr[0].replace(":", " ") + " (" + UtilityLocationFragment.extractTemperature( dayTmpArr[1] ) + MyApplication.DEGREE_SYMBOL @@ -90,10 +90,10 @@ class ObjectCard7Day(context: Context, bm: Bitmap, isUS: Boolean, day: Int, day7 } else { setTv1( dayTmpArr[0].replace(":", " ") + " (" - + UtilityLocationFragment.extractCATemp(dayTmpArr[1]) + + UtilityLocationFragment.extractCanadaTemperature(dayTmpArr[1]) + MyApplication.DEGREE_SYMBOL - + UtilityLocationFragment.extractCAWindDir(dayTmpArr[1]) - + UtilityLocationFragment.extractCAWindSpeed(dayTmpArr[1]) + ")" + + UtilityLocationFragment.extractCanadaWindDirection(dayTmpArr[1]) + + UtilityLocationFragment.extractCanadaWindSpeed(dayTmpArr[1]) + ")" ) } if (isUS) { diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCardAlertSummaryItem.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCardAlertSummaryItem.kt index df82d4f9..6bdd976e 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCardAlertSummaryItem.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCardAlertSummaryItem.kt @@ -76,7 +76,7 @@ class ObjectCardAlertSummaryItem(context: Context) { val startTime: String var endTime = "" if (ca.title.contains("until")) { - val tmpArr = UtilityString.parseMultipe( + val tmpArr = UtilityString.parseMultiple( ca.title, "(.*?) issued (.*?) until (.*?) by (.*?)$", // changed expiring to until 4 @@ -86,7 +86,7 @@ class ObjectCardAlertSummaryItem(context: Context) { endTime = tmpArr[2] } else { val tmpArr = - UtilityString.parseMultipe(ca.title, "(.*?) issued (.*?) by (.*?)$", 3) + UtilityString.parseMultiple(ca.title, "(.*?) issued (.*?) by (.*?)$", 3) title = tmpArr[0] startTime = tmpArr[1] } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCardCC.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCardCC.kt index fbd7ca32..320ae718 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCardCC.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCardCC.kt @@ -146,7 +146,7 @@ class ObjectCardCC(context: Context, version: Int) { ) { imageView.setImage(bitmap) val sep = " - " - val tmpArrCc = objCc.data1.split(sep).dropLastWhile { it.isEmpty() } + val tmpArrCc = objCc.data.split(sep).dropLastWhile { it.isEmpty() } val tempArr: List if (tmpArrCc.size > 4 && isUS) { tempArr = tmpArrCc[0].split("/").dropLastWhile { it.isEmpty() } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCardText.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCardText.kt index 1050c404..90f0bd1b 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCardText.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCardText.kt @@ -231,9 +231,14 @@ class ObjectCardText(private val context: Context) { }) } + fun setPaddingAmount(padding: Int) { + this.padding = padding + tv.setPadding(padding, padding, padding, padding) + } + fun setTextAndTranslate(text: String) { val localText = if (UIPreferences.translateText) { - UtilityTTSTranslations.tranlasteAbbrevForVisual(text) + UtilityTTSTranslations.translateAbbreviationsForVisual(text) } else { text } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCardVerticalText.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCardVerticalText.kt index 9332ac49..3f2c8dbe 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCardVerticalText.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCardVerticalText.kt @@ -53,7 +53,8 @@ class ObjectCardVerticalText(context: Context, numColumns: Int) { ) ll.addView(llv) tvArr.add(TextView(context)) - tvArr[it].gravity = Gravity.CENTER_HORIZONTAL + //tvArr[it].gravity = Gravity.CENTER_HORIZONTAL + tvArr[it].gravity = Gravity.START tvArr[it].layoutParams = LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectImageView.kt b/app/src/main/java/joshuatee/wx/ui/ObjectImageView.kt index 84cd41d6..f233a258 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectImageView.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectImageView.kt @@ -40,7 +40,7 @@ class ObjectImageView(context: Context) { MyApplication.paddingSmall ) val p = image.layoutParams - val imageSize = UtilityLocationFragment.setNWSIconSize() + val imageSize = UtilityLocationFragment.setNwsIconSize() p.width = imageSize p.height = imageSize image.layoutParams = p diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectWidgetCC.kt b/app/src/main/java/joshuatee/wx/ui/ObjectWidgetCC.kt index d7d2a636..2d7c1cda 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectWidgetCC.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectWidgetCC.kt @@ -33,9 +33,9 @@ import joshuatee.wx.WX import joshuatee.wx.fragments.UtilityNWS import joshuatee.wx.settings.Location import joshuatee.wx.util.Utility -import joshuatee.wx.util.UtilityDownload import joshuatee.wx.util.UtilityImg +import joshuatee.wx.util.UtilityTimeSunMoon class ObjectWidgetCC(context: Context) { @@ -58,7 +58,7 @@ class ObjectWidgetCC(context: Context) { if (Location.isUS(widgetLocNumberAsInteger)) { remoteViews.setTextViewText( R.id.location, - Location.getName(widgetLocNumberAsInteger) + " " + UtilityDownload.getSunriseSunsetShort( + Location.getName(widgetLocNumberAsInteger) + " " + UtilityTimeSunMoon.getSunriseSunsetShort( context, (widgetLocNumberAsInteger + 1).toString() ) diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectWidgetCCLegacy.kt b/app/src/main/java/joshuatee/wx/ui/ObjectWidgetCCLegacy.kt index 6551232a..9bb112d9 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectWidgetCCLegacy.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectWidgetCCLegacy.kt @@ -114,7 +114,7 @@ class ObjectWidgetCCLegacy(context: Context, allWidgetIds: IntArray) { hazardSum += MyApplication.newline + m.group(1) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } hazardSum = hazardSum.replace(("^" + MyApplication.newline).toRegex(), "") if (hazardSum != "") diff --git a/app/src/main/java/joshuatee/wx/util/AnimatedGifEncoderExternal.java b/app/src/main/java/joshuatee/wx/util/AnimatedGifEncoderExternal.java index 75320368..14dc8e67 100644 --- a/app/src/main/java/joshuatee/wx/util/AnimatedGifEncoderExternal.java +++ b/app/src/main/java/joshuatee/wx/util/AnimatedGifEncoderExternal.java @@ -930,7 +930,7 @@ private void alterneigh(int rad, int i, int b, int g, int r) { p[1] -= (a * (p[1] - g)) / alpharadbias; p[2] -= (a * (p[2] - r)) / alpharadbias; } catch (Exception e) { - UtilityLog.INSTANCE.HandleException(e); + UtilityLog.INSTANCE.handleException(e); } // prevents 1.3 miscompilation } if (k > lo) { @@ -940,7 +940,7 @@ private void alterneigh(int rad, int i, int b, int g, int r) { p[1] -= (a * (p[1] - g)) / alpharadbias; p[2] -= (a * (p[2] - r)) / alpharadbias; } catch (Exception e) { - UtilityLog.INSTANCE.HandleException(e); + UtilityLog.INSTANCE.handleException(e); } } } diff --git a/app/src/main/java/joshuatee/wx/util/ImageMap.java b/app/src/main/java/joshuatee/wx/util/ImageMap.java index edf5c4fb..fbe08330 100644 --- a/app/src/main/java/joshuatee/wx/util/ImageMap.java +++ b/app/src/main/java/joshuatee/wx/util/ImageMap.java @@ -380,13 +380,13 @@ private void loadMap(String map) { eventType = xpp.next(); } } catch (XmlPullParserException xppe) { - UtilityLog.INSTANCE.HandleException(xppe); + UtilityLog.INSTANCE.handleException(xppe); } catch (IOException ioe) { // Having trouble loading? Log this exception - UtilityLog.INSTANCE.HandleException(ioe); + UtilityLog.INSTANCE.handleException(ioe); } catch (Exception ioe) { // Having trouble loading? Log this exception - UtilityLog.INSTANCE.HandleException(ioe); + UtilityLog.INSTANCE.handleException(ioe); } } diff --git a/app/src/main/java/joshuatee/wx/util/ObjectForecastPackage7Day.kt b/app/src/main/java/joshuatee/wx/util/ObjectForecastPackage7Day.kt index 853875b1..bbf11e39 100644 --- a/app/src/main/java/joshuatee/wx/util/ObjectForecastPackage7Day.kt +++ b/app/src/main/java/joshuatee/wx/util/ObjectForecastPackage7Day.kt @@ -26,38 +26,51 @@ import joshuatee.wx.canada.UtilityCanada import joshuatee.wx.settings.Location import joshuatee.wx.Extensions.* +import joshuatee.wx.radar.LatLon -class ObjectForecastPackage7Day internal constructor(locNum: Int, html: String) { +class ObjectForecastPackage7Day { - var iconstr: String = "" + // separated by "!" + var iconsAsString: String = "" private set - var sevenDayExtStr: String = "" + var sevenDayLong: String = "" private set var sevenDayShort: String = "" private set - var iconAl: List = listOf() + var icons: List = listOf() private set - private var detailedForecastAl = mutableListOf() + private var detailedForecasts = mutableListOf() - init { - if (locNum == -1 || Location.isUS(locNum)) { - iconstr = getIcons7Day(html) - sevenDayExtStr = get7DayExt(html) + constructor() + + constructor(locNum: Int) { + if (Location.isUS(locNum)) { + val html = UtilityDownloadNws.get7DayData(Location.getLatLon(locNum)) + iconsAsString = getIcons7Day(html) + sevenDayLong = get7DayExt(html) sevenDayShort = get7DayShort(html) } else { - sevenDayExtStr = UtilityCanada.get7Day(html) - iconstr = UtilityCanada.getIcons7Day(sevenDayExtStr) - iconAl = UtilityCanada.getIcons7DayAl(sevenDayExtStr) - convertExt7DaytoList() + val html = UtilityCanada.getLocationHtml(Location.getLatLon(locNum)) + sevenDayLong = UtilityCanada.get7Day(html) + iconsAsString = UtilityCanada.getIcons7Day(sevenDayLong) + icons = UtilityCanada.getIcons7DayAsList(sevenDayLong) + convertExt7DayToList() } } - val fcstList: List - get() = detailedForecastAl + constructor(latLon: LatLon) { + val html = UtilityDownloadNws.get7DayData(latLon) + iconsAsString = getIcons7Day(html) + sevenDayLong = get7DayExt(html) + sevenDayShort = get7DayShort(html) + } + + val forecastList: List + get() = detailedForecasts - private fun convertExt7DaytoList() { - detailedForecastAl = sevenDayExtStr.split(MyApplication.newline + MyApplication.newline) - .dropLastWhile { it.isEmpty() }.toMutableList() + private fun convertExt7DayToList() { + detailedForecasts = sevenDayLong.split(MyApplication.newline + MyApplication.newline) + .dropLastWhile { it.isEmpty() }.toMutableList() } private fun getIcons7Day(html: String): String { @@ -75,10 +88,10 @@ class ObjectForecastPackage7Day internal constructor(locNum: Int, html: String) if ((nameAl.size == temperatureAl.size) && (temperatureAl.size == shortForecastAl.size) && (shortForecastAl.size == detailedForecastAl.size)) { val forecastAl = (0 until nameAl.size).mapTo(mutableListOf()) { ObjectForecast( - nameAl[it], - temperatureAl[it], - shortForecastAl[it], - detailedForecastAl[it] + nameAl[it], + temperatureAl[it], + shortForecastAl[it], + detailedForecastAl[it] ) } var forecast = MyApplication.newline + MyApplication.newline @@ -96,16 +109,16 @@ class ObjectForecastPackage7Day internal constructor(locNum: Int, html: String) val forecastAl = mutableListOf() val nameAl = html.parseColumn("\"name\": \"(.*?)\",") val temperatureAl = html.parseColumn("\"temperature\": (.*?),") - this.iconAl = html.parseColumn("\"icon\": \"(.*?)\",") + this.icons = html.parseColumn("\"icon\": \"(.*?)\",") val shortForecastAl = html.parseColumn("\"shortForecast\": \"(.*?)\",") val detailedForecastAlLocal = html.parseColumn("\"detailedForecast\": \"(.*?)\"") if (nameAl.size == temperatureAl.size && temperatureAl.size == shortForecastAl.size && shortForecastAl.size == detailedForecastAlLocal.size) { (0 until nameAl.size).mapTo(forecastAl) { ObjectForecast( - nameAl[it], - temperatureAl[it], - shortForecastAl[it], - detailedForecastAlLocal[it] + nameAl[it], + temperatureAl[it], + shortForecastAl[it], + detailedForecastAlLocal[it] ) } } @@ -113,7 +126,7 @@ class ObjectForecastPackage7Day internal constructor(locNum: Int, html: String) forecastAl.forEach { forecast += it.name + ": " + it.detailedForecast forecast += MyApplication.newline + MyApplication.newline - detailedForecastAl.add(it.name + ": " + it.detailedForecast) + detailedForecasts.add(it.name + ": " + it.detailedForecast) } return forecast } @@ -135,8 +148,29 @@ class ObjectForecastPackage7Day internal constructor(locNum: Int, html: String) "shortForecast": "Chance Rain Showers", "detailedForecast": "A chance of rain showers. Mostly cloudy, with a low around 50. Chance of precipitation is 30%." } - - + + -------- + sevenDayShort + ------ + + Tuesday Night(49): Slight Chance Rain then Chance T-storms + + Wednesday(75): Chance T-storms + + Wednesday Night(56): Partly Cloudy + +----------- +sevenDayLong +----------- + +Tuesday Night: A slight chance of rain before 8pm, then a chance of thunderstorms and a chance of rain. Mostly cloudy, with a low around 49. + + Wednesday: A chance of thunderstorms and a chance of rain before 2pm. Partly sunny, with a high near 75. + + Wednesday Night: Partly cloudy, with a low around 56. + + + */ diff --git a/app/src/main/java/joshuatee/wx/util/ObjectForecastPackageCurrentConditions.kt b/app/src/main/java/joshuatee/wx/util/ObjectForecastPackageCurrentConditions.kt index 557253fc..3a2d220d 100644 --- a/app/src/main/java/joshuatee/wx/util/ObjectForecastPackageCurrentConditions.kt +++ b/app/src/main/java/joshuatee/wx/util/ObjectForecastPackageCurrentConditions.kt @@ -30,49 +30,43 @@ import joshuatee.wx.radar.LatLon class ObjectForecastPackageCurrentConditions { - companion object { - // CA - internal fun createForCanada(html: String): ObjectForecastPackageCurrentConditions { - val obj = ObjectForecastPackageCurrentConditions() - obj.data1 = UtilityCanada.getConditions(html) - obj.status = UtilityCanada.getStatus(html) - return obj - } - } - var contextg: Context? = null - var ccLine1: String = "" - var data1: String = "" + var topLine: String = "" + var data: String = "" private set var iconUrl: String = "" private set - private var conditionsTimeStr = "" + private var time = "" var status: String = "" private set - private constructor() + constructor() - // US - internal constructor(context: Context, locNum: Int) { + constructor(context: Context, locNum: Int) { if (Location.isUS(locNum)) { val tmpArr = getConditionsViaMetar(context, Location.getLatLon(locNum)) - data1 = tmpArr[0] + // 62° / 54°(74%) - 1013 mb - ESE 7 mph - 8 mi - Partly Cloudy + data = tmpArr[0] iconUrl = tmpArr[1] - status = UtilityUS.getStatusViaMetar(context, conditionsTimeStr) + status = UtilityUS.getStatusViaMetar(context, time) + } else { + val html = UtilityCanada.getLocationHtml(Location.getLatLon(locNum)) + data = UtilityCanada.getConditions(html) + status = UtilityCanada.getStatus(html) } } - internal constructor(context: Context, location: LatLon) { + constructor(context: Context, location: LatLon) { val tmpArr = getConditionsViaMetar(context, location) - data1 = tmpArr[0] + data = tmpArr[0] iconUrl = tmpArr[1] - status = UtilityUS.getStatusViaMetar(context, conditionsTimeStr) + status = UtilityUS.getStatusViaMetar(context, time) } private fun getConditionsViaMetar(context: Context, location: LatLon): List { var sb = "" val objMetar = ObjectMetar(context, location) - conditionsTimeStr = objMetar.conditionsTimeStr + time = objMetar.conditionsTimeStr val temperature = objMetar.temperature + MyApplication.DEGREE_SYMBOL val windChill = objMetar.windChill + MyApplication.DEGREE_SYMBOL val heatIndex = objMetar.heatIndex + MyApplication.DEGREE_SYMBOL @@ -103,13 +97,13 @@ class ObjectForecastPackageCurrentConditions { // FIXME sync up with flutter/ios port fun formatCC() { val sep = " - " - val tmpArrCc = data1.split(sep) + val tmpArrCc = data.split(sep) var retStr = "" if (tmpArrCc.size > 4) { val tmpList = tmpArrCc[0].split("/") retStr = tmpArrCc[4].replace("^ ", "") + " " + tmpList[0] + tmpArrCc[2] } - ccLine1 = retStr + topLine = retStr } } diff --git a/app/src/main/java/joshuatee/wx/util/ObjectForecastPackageHazards.kt b/app/src/main/java/joshuatee/wx/util/ObjectForecastPackageHazards.kt index b2128727..b0960ecb 100644 --- a/app/src/main/java/joshuatee/wx/util/ObjectForecastPackageHazards.kt +++ b/app/src/main/java/joshuatee/wx/util/ObjectForecastPackageHazards.kt @@ -21,6 +21,7 @@ package joshuatee.wx.util +import joshuatee.wx.Extensions.parseColumn import joshuatee.wx.MyApplication import joshuatee.wx.canada.UtilityCanada import joshuatee.wx.radar.LatLon @@ -29,40 +30,42 @@ import joshuatee.wx.settings.Location class ObjectForecastPackageHazards { private var hazardsShort = "" + var urls = listOf() + var titles = listOf() var hazards: String = "" private set - private constructor() + constructor() // US - internal constructor(locNum: Int) { + constructor(locNum: Int) { if (Location.isUS(locNum) && MyApplication.homescreenFav.contains("TXT-HAZ")) { hazards = getHazardsHtml(Location.getLatLon(locNum)) + urls = hazards.parseColumn("\"id\": \"(" + MyApplication.nwsApiUrl + ".*?)\"") + titles = hazards.parseColumn("\"event\": \"(.*?)\"") } } - internal constructor(location: LatLon) { + // Canada + constructor(html: String) { + val hazArr = UtilityCanada.getHazards(html) + hazardsShort = hazArr[0] + hazards = hazArr[1] + } + + // adhoc forecast + constructor(location: LatLon) { hazards = getHazardsHtml(location) + urls = hazards.parseColumn("\"id\": \"(" + MyApplication.nwsApiUrl + ".*?)\"") + titles = hazards.parseColumn("\"event\": \"(.*?)\"") } fun getHazardsShort(): String = hazardsShort.replace("^
    ".toRegex(), "") companion object { - // CA - internal fun createForCanada(html: String): ObjectForecastPackageHazards { - val obj = ObjectForecastPackageHazards() - val hazArr = UtilityCanada.getHazards(html) - obj.hazardsShort = hazArr[0] - obj.hazards = hazArr[1] - return obj - } - fun getHazardsHtml(location: LatLon): String { - return UtilityDownloadNws.getHazardData( - "https://api.weather.gov/alerts?point=" + UtilityMath.latLonFix( - location.latString - ) + "," + UtilityMath.latLonFix(location.lonString) + "&active=1" - ) + val url = "https://api.weather.gov/alerts?point=" + UtilityMath.latLonFix(location.latString) + "," + UtilityMath.latLonFix(location.lonString) + "&active=1" + return UtilityDownloadNws.getHazardData(url) } } } diff --git a/app/src/main/java/joshuatee/wx/util/ObjectMetar.kt b/app/src/main/java/joshuatee/wx/util/ObjectMetar.kt index 135a9f81..654fd886 100644 --- a/app/src/main/java/joshuatee/wx/util/ObjectMetar.kt +++ b/app/src/main/java/joshuatee/wx/util/ObjectMetar.kt @@ -64,8 +64,6 @@ internal class ObjectMetar(context: Context, location: LatLon) { https://stackoverflow.com/questions/42803349/swift-3-0-convert-server-utc-time-to-local-time-and-visa-versa/42811162 */ - - //private val decodeIcon = true var condition = "" var temperature = "" var dewpoint = "" @@ -97,7 +95,7 @@ internal class ObjectMetar(context: Context, location: LatLon) { newValue = if (MyApplication.unitsF) { UtilityMath.roundToString(tempD) } else { - UtilityMath.fToC(tempD) + UtilityMath.fahrenheitToCelsius(tempD) } } return newValue @@ -129,8 +127,9 @@ internal class ObjectMetar(context: Context, location: LatLon) { timeOfDay = "day" } val conditionModified = condition.split(";")[0] + UtilityLog.d("wx", conditionModified) val shortCondition = UtilityMetarConditions.iconFromCondition[conditionModified] ?: "" - return "https://api.weather.gov/icons/land/$timeOfDay/$shortCondition?size=medium" + return MyApplication.nwsApiUrl + "/icons/land/$timeOfDay/$shortCondition?size=medium" } init { @@ -175,7 +174,7 @@ internal class ObjectMetar(context: Context, location: LatLon) { val localStatus = metarDataList[1].split("/") if (localStatus.size > 1) { conditionsTimeStr = - UtilityTime.convertFromUTCForMetar(localStatus[1].replace(" UTC", "")) + UtilityTime.convertFromUtcForMetar(localStatus[1].replace(" UTC", "")) } } seaLevelPressure = changePressureUnits(seaLevelPressure) diff --git a/app/src/main/java/joshuatee/wx/util/ProjectionNumbers.kt b/app/src/main/java/joshuatee/wx/util/ProjectionNumbers.kt index 190d1e8a..16c27c78 100644 --- a/app/src/main/java/joshuatee/wx/util/ProjectionNumbers.kt +++ b/app/src/main/java/joshuatee/wx/util/ProjectionNumbers.kt @@ -24,7 +24,6 @@ package joshuatee.wx.util import android.content.Context import joshuatee.wx.MyApplication import joshuatee.wx.objects.ProjectionType -import joshuatee.wx.vis.UtilityUSImgNWSGOESMercator class ProjectionNumbers { @@ -104,14 +103,6 @@ class ProjectionNumbers { } x = Utility.getRadarSiteX(radarSite) y = Utility.getRadarSiteY(radarSite) - if (provider === ProjectionType.NWS_GOES) { - val mnTmp = UtilityUSImgNWSGOESMercator.getMercatorNumbers(context, radarSite) - x = mnTmp.x - y = mnTmp.y - scale = mnTmp.scale - xCenter = mnTmp.xCenter - yCenter = mnTmp.yCenter - } oneDegreeScaleFactor = UtilityMath.pixPerDegreeLon(xDbl, scale) scaleFloat = scale.toFloat() } diff --git a/app/src/main/java/joshuatee/wx/util/Utility.kt b/app/src/main/java/joshuatee/wx/util/Utility.kt index 3ae9e130..f534acbd 100644 --- a/app/src/main/java/joshuatee/wx/util/Utility.kt +++ b/app/src/main/java/joshuatee/wx/util/Utility.kt @@ -109,7 +109,7 @@ object Utility { try { vers = context.packageManager.getPackageInfo(context.packageName, 0).versionName } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return vers } @@ -206,8 +206,7 @@ object Utility { } // FIXME deprecate these - fun readPref(key: String, value: String): String = - MyApplication.preferences.getString(key, value)!! + fun readPref(key: String, value: String): String = MyApplication.preferences.getString(key, value)!! fun theme(themeStr: String): Int = when { themeStr.startsWith("blue") -> R.style.MyCustomTheme_NOAB @@ -224,54 +223,6 @@ object Utility { else -> R.style.MyCustomTheme_NOAB } - private fun getCurrentConditionsCanada(locNum: Int): ObjectForecastPackageCurrentConditions { - val html = UtilityCanada.getLocationHtml(Location.getLatLon(locNum)) - return ObjectForecastPackageCurrentConditions.createForCanada(html) - } - - private fun getCurrentConditionsUS(context: Context, locNum: Int): ObjectForecastPackageCurrentConditions { - return ObjectForecastPackageCurrentConditions(context, locNum) - } - - fun getCurrentHazards(locNum: Int): ObjectForecastPackageHazards { - return if (Location.isUS(locNum)) { - ObjectForecastPackageHazards(locNum) - } else { - val html = UtilityCanada.getLocationHtml(Location.getLatLon(locNum)) - ObjectForecastPackageHazards.createForCanada(html) - } - } - - fun getCurrentSevenDay(locNum: Int): ObjectForecastPackage7Day { - return if (Location.isUS(locNum)) { - val html = UtilityDownloadNws.get7DayData(Location.getLatLon(locNum)) - ObjectForecastPackage7Day(locNum, html) - } else { - val html = UtilityCanada.getLocationHtml(Location.getLatLon(locNum)) - ObjectForecastPackage7Day(locNum, html) - } - } - - fun getCurrentSevenDay(location: LatLon): ObjectForecastPackage7Day { - val html = UtilityDownloadNws.get7DayData(location) - return ObjectForecastPackage7Day(-1, html) - } - - fun getCurrentHazards(location: LatLon): ObjectForecastPackageHazards { - return ObjectForecastPackageHazards(location) - } - - fun getCurrentConditionsByLatLon(context: Context, location: LatLon): ObjectForecastPackageCurrentConditions { - return ObjectForecastPackageCurrentConditions(context, location) - } - - fun getCurrentConditions(context: Context, locNum: Int): ObjectForecastPackageCurrentConditions = - if (Location.isUS(locNum)) { - getCurrentConditionsUS(context, locNum) - } else { - getCurrentConditionsCanada(locNum) - } - fun getHazards(url: String): String = url.parse(" {3}

    (.*?)") diff --git a/app/src/main/java/joshuatee/wx/util/UtilityAlertDialog.kt b/app/src/main/java/joshuatee/wx/util/UtilityAlertDialog.kt index a65f49d0..dafa2afd 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityAlertDialog.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityAlertDialog.kt @@ -71,7 +71,7 @@ object UtilityAlertDialog { try { version = activity.packageManager.getPackageInfo(activity.packageName, 0).versionName } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } val tmpStr = activity.resources.getString(R.string.about_wx) + MyApplication.newline + version diff --git a/app/src/main/java/joshuatee/wx/util/UtilityCanvasMain.kt b/app/src/main/java/joshuatee/wx/util/UtilityCanvasMain.kt index 045c659e..a8315b82 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityCanvasMain.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityCanvasMain.kt @@ -380,7 +380,7 @@ object UtilityCanvasMain { dis.close() inputStream.close() } catch (e: IOException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } } diff --git a/app/src/main/java/joshuatee/wx/util/UtilityCanvasProjection.kt b/app/src/main/java/joshuatee/wx/util/UtilityCanvasProjection.kt index b5bcd58a..1469b03d 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityCanvasProjection.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityCanvasProjection.kt @@ -63,7 +63,7 @@ object UtilityCanvasProjection { } } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } diff --git a/app/src/main/java/joshuatee/wx/util/UtilityDownload.kt b/app/src/main/java/joshuatee/wx/util/UtilityDownload.kt index 16b4e679..d91488e0 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityDownload.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityDownload.kt @@ -27,13 +27,10 @@ import java.io.BufferedReader import java.io.IOException import java.io.InputStream import java.io.InputStreamReader -import java.util.Calendar import java.util.Locale -import java.util.TimeZone import android.content.Context import android.graphics.Bitmap import android.graphics.BitmapFactory -import android.text.format.DateFormat import joshuatee.wx.MyApplication import joshuatee.wx.activitiesmisc.UtilityLightning @@ -41,8 +38,6 @@ import joshuatee.wx.activitiesmisc.UtilitySunMoon import joshuatee.wx.activitiesmisc.UtilityUSHourly import joshuatee.wx.audio.UtilityPlayList import joshuatee.wx.canada.UtilityCanadaImg -import joshuatee.wx.external.ExternalSunriseLocation -import joshuatee.wx.external.ExternalSunriseSunsetCalculator import joshuatee.wx.settings.Location import joshuatee.wx.settings.UtilityLocation import joshuatee.wx.spc.* @@ -62,7 +57,7 @@ object UtilityDownload { private fun get2KmUrl() = UtilityImg.getBlankBitmap() - fun getRadarMosiac(context: Context): Bitmap { + fun getRadarMosaic(context: Context): Bitmap { val location = Location.currentLocationStr val rid1 = Location.getRid(context, location) var bitmap: Bitmap = UtilityImg.getBlankBitmap() @@ -94,10 +89,6 @@ object UtilityDownload { ) } } else { - //val prefToken = "AWCMOSAIC_PARAM_LAST_USED" - //val index = Utility.readPref(context, prefToken, 0) - //bitmap = UtilityAwcRadarMosaic.get(UtilityAwcRadarMosaic.sectors[index]) - var product = "rad_rala" val prefTokenSector = "AWCMOSAIC_SECTOR_LAST_USED" val prefTokenProduct = "AWCMOSAIC_PRODUCT_LAST_USED" @@ -107,7 +98,7 @@ object UtilityDownload { bitmap = UtilityAwcRadarMosaic.get(sector, product) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return bitmap } @@ -144,7 +135,7 @@ object UtilityDownload { } "RAD_2KM" -> { needsBitmap = false - bm = getRadarMosiac(context) + bm = getRadarMosaic(context) } "IR_2KM", "WV_2KM", "VIS_2KM" -> { needsBitmap = false @@ -355,14 +346,14 @@ object UtilityDownload { "MIAPWS" ) || prod.contains("MIAHS") ) { - text = UtilityString.getNWSPRE("${MyApplication.nwsNhcWebsitePrefix}/text/$prod.shtml") + text = UtilityString.getNwsPre("${MyApplication.nwsNhcWebsitePrefix}/text/$prod.shtml") if (prod.contains("MIATCD")) { text = text.replace("

    ", "

    ") text = text.replace("
    ", " ") } text = text.replace("^
    ".toRegex(), "") } else if (prod.contains("MIAT")) { - text = UtilityString.getHTMLandParseSep( + text = UtilityString.getHtmlAndParseSep( "${MyApplication.nwsNhcWebsitePrefix}/ftp/pub/forecasts/discussion/$prod", "(.*)" ) @@ -381,7 +372,7 @@ object UtilityDownload { text = text.replace("
    ", " ") } } else if (prod.startsWith("SCCNS")) { - text = UtilityString.getHTMLandParseSep( + text = UtilityString.getHtmlAndParseSep( "${MyApplication.nwsWPCwebsitePrefix}/discussions/nfd" + prod.toLowerCase(Locale.US).replace( "ns", "" @@ -396,7 +387,7 @@ object UtilityDownload { } else if (prod.contains("SPCMCD")) { val no = prod.substring(6) val textUrl = "${MyApplication.nwsSPCwebsitePrefix}/products/md/md$no.html" - text = UtilityString.getHTMLandParseSep(textUrl, RegExp.pre2Pattern) + text = UtilityString.getHtmlAndParseSep(textUrl, RegExp.pre2Pattern) text = text.replace("^

    ".toRegex(), "") if (UIPreferences.nwsTextRemovelinebreaks) { text = text.replace("

    ", "

    ") @@ -406,7 +397,7 @@ object UtilityDownload { } else if (prod.contains("SPCWAT")) { val no = prod.substring(6) val textUrl = "${MyApplication.nwsSPCwebsitePrefix}/products/watch/ww$no.html" - text = UtilityString.getHTMLandParseSep(textUrl, RegExp.pre2Pattern) + text = UtilityString.getHtmlAndParseSep(textUrl, RegExp.pre2Pattern) text = text.replace("^
    ".toRegex(), "") if (UIPreferences.nwsTextRemovelinebreaks) { text = text.replace("

    ", "

    ") @@ -416,7 +407,7 @@ object UtilityDownload { val no = prod.substring(6) val textUrl = "${MyApplication.nwsWPCwebsitePrefix}/metwatch/metwatch_mpd_multi.php?md=$no" - text = UtilityString.getHTMLandParseSep(textUrl, RegExp.pre2Pattern) + text = UtilityString.getHtmlAndParseSep(textUrl, RegExp.pre2Pattern) text = text.replace("^
    ".toRegex(), "") text = text.replace("^
    ".toRegex(), "") if (UIPreferences.nwsTextRemovelinebreaks) { @@ -426,7 +417,7 @@ object UtilityDownload { } else if (prod.contains("QPFHSD")) { val textUrl = "${MyApplication.nwsWPCwebsitePrefix}/discussions/hpcdiscussions.php?disc=qpfhsd" - text = UtilityString.getHTMLandParseSep(textUrl, RegExp.pre2Pattern) + text = UtilityString.getHtmlAndParseSep(textUrl, RegExp.pre2Pattern) text = text.replace("^
    ".toRegex(), "") text = text.replace("^
    ".toRegex(), "") if (UIPreferences.nwsTextRemovelinebreaks) { @@ -450,7 +441,7 @@ object UtilityDownload { Locale.US )).getHtml() } else if (prod.contains("FWDDY38")) { - text = UtilityString.getHTMLandParseSep( + text = UtilityString.getHtmlAndParseSep( "${MyApplication.nwsSPCwebsitePrefix}/products/exper/fire_wx/", "
    (.*?)
    " ) @@ -480,24 +471,22 @@ object UtilityDownload { text = textUrl.getHtmlSep() text = text.parse(RegExp.pre2Pattern) } else if (prod.contains("PMDTHR")) { - text = UtilityString.getHTMLandParseSep( + text = UtilityString.getHtmlAndParseSep( "http://www.cpc.noaa.gov/products/predictions/threats/threats.php", "
    (.*?)
    " ) } else if (prod.contains("CTOF")) { - text = "Celsius to Fahrenheit table" + MyApplication.newline + UtilityMath.cToFTable() + text = "Celsius to Fahrenheit table" + MyApplication.newline + UtilityMath.celsiusToFahrenheitTable() } else { val t1 = prod.substring(0, 3) var t2 = prod.substring(3) t2 = t2.replace("%", "") - val html = ("https://api.weather.gov/products/types/$t1/locations/$t2").getNwsHtml() + val html = (MyApplication.nwsApiUrl + "/products/types/$t1/locations/$t2").getNwsHtml() val urlProd = html.parse("\"id\": \"(.*?)\"") - val prodHtml = ("https://api.weather.gov/products/$urlProd").getNwsHtml() + val prodHtml = (MyApplication.nwsApiUrl + "/products/$urlProd").getNwsHtml() text = UtilityString.parseAcrossLines(prodHtml, "\"productText\": \"(.*?)\\}") - //text = text.replace("\\n\\n", "
    ") - //text = text.replace("\\n", " ") - text = text.replace("\\n\\n", "

    ") - text = text.replace("\\n", "
    ") + text = text.replace("\\n\\n", "
    ") + text = text.replace("\\n", " ") } UtilityPlayList.checkAndSave(context, prod, text) return text @@ -509,7 +498,7 @@ object UtilityDownload { val t2 = prod.substring(3) val url = "http://forecast.weather.gov/product.php?site=NWS&product=$t1&issuedby=$t2&version=$version" - var text = UtilityString.getHTMLandParseSep(url, RegExp.prePattern) + var text = UtilityString.getHtmlAndParseSep(url, RegExp.prePattern) text = text.replace( "Graphics available at www.wpc.ncep.noaa.gov/basicwx/basicwx_wbg.php", "" @@ -526,100 +515,6 @@ object UtilityDownload { return text } - fun getSunriseSunset(context: Context, locNum: String): String { - val locNumInt = (locNum.toIntOrNull() ?: 0) - 1 - val lat: String - val lon: String - if (!Location.isUS(locNumInt)) { - val latArr = Location.getX(locNumInt).split(":") - val lonArr = Location.getY(locNumInt).split(":") - if (latArr.size > 2 && lonArr.size > 1) { - lat = latArr[2] - lon = lonArr[1] - } else - return "" - } else { - lat = Location.getX(locNumInt) - lon = Location.getY(locNumInt) - } - val location = ExternalSunriseLocation(lat, lon) - val calculator = ExternalSunriseSunsetCalculator(location, TimeZone.getDefault()) - val officialSunriseCal = - calculator.getOfficialSunriseCalendarForDate(Calendar.getInstance()) - val officialSunsetCal = calculator.getOfficialSunsetCalendarForDate(Calendar.getInstance()) - val srTime: String - val ssTime: String - var amStr = "" - var pmStr = "" - if (!DateFormat.is24HourFormat(context)) { - amStr = "am" - pmStr = "pm" - srTime = (officialSunriseCal.get(Calendar.HOUR)).toString() + ":" + - String.format("%2s", (officialSunriseCal.get(Calendar.MINUTE))).replace( - ' ', - '0' - ) - ssTime = (officialSunsetCal.get(Calendar.HOUR)).toString() + ":" + - String.format("%2s", (officialSunsetCal.get(Calendar.MINUTE))).replace(' ', '0') - } else { - srTime = (officialSunriseCal.get(Calendar.HOUR_OF_DAY)).toString() + ":" + - String.format("%2s", (officialSunriseCal.get(Calendar.MINUTE))).replace( - ' ', - '0' - ) - ssTime = (officialSunsetCal.get(Calendar.HOUR_OF_DAY)).toString() + ":" + - String.format("%2s", (officialSunsetCal.get(Calendar.MINUTE))).replace(' ', '0') - } - return "Sunrise: $srTime$amStr Sunset: $ssTime$pmStr" - } - - fun getSunriseSunsetShort(context: Context, locNum: String): String { - val locNumInt = (locNum.toIntOrNull() ?: 0) - 1 - val lat: String - val lon: String - if (!MyApplication.locations[locNumInt].isUS) { - val latArr = MyApplication.colon.split(Location.getX(locNumInt)) - val lonArr = MyApplication.colon.split(Location.getY(locNumInt)) - if (latArr.size > 2 && lonArr.size > 1) { - lat = latArr[2] - lon = lonArr[1] - } else - return "" - } else { - lat = Location.getX(locNumInt) - lon = Location.getY(locNumInt) - } - val location = ExternalSunriseLocation(lat, lon) - val calculator = ExternalSunriseSunsetCalculator(location, TimeZone.getDefault()) - val officialSunriseCal = - calculator.getOfficialSunriseCalendarForDate(Calendar.getInstance()) - val officialSunsetCal = calculator.getOfficialSunsetCalendarForDate(Calendar.getInstance()) - val srTime: String - val ssTime: String - var amStr = "" - var pmStr = "" - if (!DateFormat.is24HourFormat(context)) { - amStr = "am" - pmStr = "pm" - srTime = (officialSunriseCal.get(Calendar.HOUR)).toString() + ":" + - String.format("%2s", (officialSunriseCal.get(Calendar.MINUTE))).replace( - ' ', - '0' - ) - ssTime = (officialSunsetCal.get(Calendar.HOUR)).toString() + ":" + - String.format("%2s", (officialSunsetCal.get(Calendar.MINUTE))).replace(' ', '0') - } else { - srTime = (officialSunriseCal.get(Calendar.HOUR_OF_DAY)).toString() + ":" + - String.format("%2s", (officialSunriseCal.get(Calendar.MINUTE))).replace( - ' ', - '0' - ) - ssTime = (officialSunsetCal.get(Calendar.HOUR_OF_DAY)).toString() + ":" + - String.format("%2s", (officialSunsetCal.get(Calendar.MINUTE))).replace(' ', '0') - } - return "$srTime$amStr / $ssTime$pmStr" - } - fun getStringFromUrl(url: String): String { val out = StringBuilder(5000) try { @@ -678,7 +573,7 @@ object UtilityDownload { } br.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return out.toString().replace(breakStr, "
    ") } @@ -734,7 +629,7 @@ object UtilityDownload { val response = MyApplication.httpClient!!.newCall(request).execute() response.body()!!.byteStream() } catch (e: IOException) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) null } } @@ -771,7 +666,7 @@ object UtilityDownload { UtilityLog.d("wx", "getRadarStatus testtext: " + text) //try another url... UtilityLog.d("wx", "getRadarStatus trying another url for FTM") - text = UtilityString.getHTMLandParseSep( + text = UtilityString.getHtmlAndParseSep( "https://forecast.weather.gov/product.php?site=NWS&issuedby="+ridSmall.toUpperCase(Locale.US)+"&product=FTM&format=TXT&glossary=0", RegExp.prePattern ) diff --git a/app/src/main/java/joshuatee/wx/util/UtilityDownloadNWS.kt b/app/src/main/java/joshuatee/wx/util/UtilityDownloadNWS.kt index 90c2d9a2..410fcb08 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityDownloadNWS.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityDownloadNWS.kt @@ -35,13 +35,11 @@ import joshuatee.wx.RegExp object UtilityDownloadNws { - // FIXME remove nws from method name as class name already has it - private const val USER_AGENT_STR = "Android ${MyApplication.packageNameAsString} ${MyApplication.emailAsString}" fun getHazardData(url: String): String { - return getNwsStringFromUrlJson(url) + return getStringFromUrlJson(url) } fun getLatLonForZone(zone: String): List { @@ -65,9 +63,9 @@ object UtilityDownloadNws { } fun getCap(sector: String): String = if (sector == "us") { - getNwsStringFromUrlXml(MyApplication.nwsApiUrl + "/alerts/active?region_type=land") + getStringFromUrlXml(MyApplication.nwsApiUrl + "/alerts/active?region_type=land") } else { - getNwsStringFromUrlXml( + getStringFromUrlXml( MyApplication.nwsApiUrl + "/alerts/active/area/" + sector.toUpperCase( Locale.US ) @@ -77,16 +75,16 @@ object UtilityDownloadNws { // https://forecast-v3.weather.gov/documentation?redirect=legacy // http://www.nws.noaa.gov/os/notification/pns16-35forecastgov.htm - fun getNwsStringFromUrl(url: String): String = - getNWSStringFromURLBase(url, "application/vnd.noaa.dwml+xml;version=1") + fun getStringFromUrl(url: String): String = + getStringFromURLBase(url, "application/vnd.noaa.dwml+xml;version=1") - private fun getNwsStringFromUrlJson(url: String): String = - getNWSStringFromURLBase(url, "application/geo+json;version=1") + private fun getStringFromUrlJson(url: String): String = + getStringFromURLBase(url, "application/geo+json;version=1") - fun getNwsStringFromUrlNoAcceptHeader(url: String): String = - getNwsStringFromUrlBaseNoHeader(url) + fun getStringFromUrlNoAcceptHeader(url: String): String = + getStringFromUrlBaseNoHeader(url) - private fun getNWSStringFromURLBase(url: String, header: String): String { + private fun getStringFromURLBase(url: String, header: String): String { val out = StringBuilder(5000) try { val request = Request.Builder() @@ -104,12 +102,12 @@ object UtilityDownloadNws { } br.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return out.toString() } - private fun getNwsStringFromUrlBaseNoHeader(url: String): String { + private fun getStringFromUrlBaseNoHeader(url: String): String { val out = StringBuilder(5000) try { val request = Request.Builder() @@ -126,12 +124,12 @@ object UtilityDownloadNws { } br.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return out.toString() } - fun getNwsStringFromUrlSep(strURL: String): String { + fun getStringFromUrlSep(strURL: String): String { val breakStr = "ABC123_456ZZ" val out = StringBuilder(5000) try { @@ -151,13 +149,13 @@ object UtilityDownloadNws { out.append(breakStr) br.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return out.toString().replace(breakStr, "
    ") } - private fun getNwsStringFromUrlXml(url: String) = - getNWSStringFromURLBase(url, "application/atom+xml") + private fun getStringFromUrlXml(url: String) = + getStringFromURLBase(url, "application/atom+xml") // Following methods derived from flutter port in response to June 2019 change diff --git a/app/src/main/java/joshuatee/wx/util/UtilityDownloadRadar.kt b/app/src/main/java/joshuatee/wx/util/UtilityDownloadRadar.kt index 19d833ab..f916486f 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityDownloadRadar.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityDownloadRadar.kt @@ -43,62 +43,62 @@ object UtilityDownloadRadar { //val ffwUrl = baseUrl + "Flood%20Warning" - fun getPolygonVTEC(context: Context) { + fun getPolygonVtec(context: Context) { MyApplication.severeDashboardTor.valueSet( context, - UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(torUrl) + UtilityDownloadNws.getStringFromUrlNoAcceptHeader(torUrl) ) MyApplication.severeDashboardSvr.valueSet( context, - UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(svrURl) + UtilityDownloadNws.getStringFromUrlNoAcceptHeader(svrURl) ) MyApplication.severeDashboardFfw.valueSet( context, - UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(ffwUrl) + UtilityDownloadNws.getStringFromUrlNoAcceptHeader(ffwUrl) ) MyApplication.severeDashboardEww.valueSet( context, - UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(ewwUrl) + UtilityDownloadNws.getStringFromUrlNoAcceptHeader(ewwUrl) ) MyApplication.severeDashboardSmw.valueSet( context, - UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(smwUrl) + UtilityDownloadNws.getStringFromUrlNoAcceptHeader(smwUrl) ) MyApplication.severeDashboardSvs.valueSet( context, - UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(svsUrl) + UtilityDownloadNws.getStringFromUrlNoAcceptHeader(svsUrl) ) MyApplication.severeDashboardSps.valueSet( context, - UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(spsUrl) + UtilityDownloadNws.getStringFromUrlNoAcceptHeader(spsUrl) ) } fun getVtecTor(): String { - return UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(torUrl) + return UtilityDownloadNws.getStringFromUrlNoAcceptHeader(torUrl) } fun getVtecSvr(): String { - return UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(svrURl) + return UtilityDownloadNws.getStringFromUrlNoAcceptHeader(svrURl) } fun getVtecFfw(): String { - return UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(ffwUrl) + return UtilityDownloadNws.getStringFromUrlNoAcceptHeader(ffwUrl) } fun getVtecEww(): String { - return UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(ewwUrl) + return UtilityDownloadNws.getStringFromUrlNoAcceptHeader(ewwUrl) } fun getVtecSmw(): String { - return UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(smwUrl) + return UtilityDownloadNws.getStringFromUrlNoAcceptHeader(smwUrl) } fun getVtecSvs(): String { - return UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(svsUrl) + return UtilityDownloadNws.getStringFromUrlNoAcceptHeader(svsUrl) } fun getSps(): String { - return UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(spsUrl) + return UtilityDownloadNws.getStringFromUrlNoAcceptHeader(spsUrl) } fun getVtecByType(type: PolygonWarningType): String { - return UtilityDownloadNws.getNwsStringFromUrlNoAcceptHeader(baseUrl + type.urlToken) + return UtilityDownloadNws.getStringFromUrlNoAcceptHeader(baseUrl + type.urlToken) } fun getMcd(): String { diff --git a/app/src/main/java/joshuatee/wx/util/UtilityFavorites.kt b/app/src/main/java/joshuatee/wx/util/UtilityFavorites.kt index e7f4b6d0..4bcebe9b 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityFavorites.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityFavorites.kt @@ -35,17 +35,12 @@ object UtilityFavorites { private const val MODIFY_STR = "Modify..." private fun checkAndCorrectFav(context: Context, fav: String, prefToken: String) { - //UtilityLog.d("wx","fav-" + fav + "PREF:" + prefToken) - if (fav.contains("::")) { val newFav = fav.replace(":{2,}".toRegex(), ":") savePref(context, newFav, prefToken) } - if (!fav.contains(MyApplication.prefSeperator)) { - //UtilityLog.d("wx","Errorfav-" + fav) val newFav = MyApplication.prefSeperator + fav.trimStart() - //UtilityLog.d("wx","Correctedfav-" + newFav) savePref(context, newFav, prefToken) } } @@ -91,7 +86,7 @@ object UtilityFavorites { return ridArrLoc.toList() } - fun setupFavMenuCA(ridFav: String, nwsOffice: String): List { + fun setupFavMenuCanada(ridFav: String, nwsOffice: String): List { val ridArr = MyApplication.colon.split(ridFav) ridArr[0] = nwsOffice ridArr[1] = ADD_STR @@ -108,7 +103,7 @@ object UtilityFavorites { } fun toggleFavorite(context: Context, rid: String, star: MenuItem, prefToken: String) { - var ridFav: String = Utility.readPref(context, prefToken, " : : :") + var ridFav = Utility.readPref(context, prefToken, " : : :") if (ridFav.contains(rid)) { ridFav = ridFav.replace("$rid:", "") star.setIcon(MyApplication.STAR_OUTLINE_ICON) @@ -127,14 +122,13 @@ object UtilityFavorites { } // mirror of method above save it returns the string - fun toggleFavoriteString( context: Context, rid: String, star: MenuItem, prefToken: String ): String { - var ridFav: String = Utility.readPref(context, prefToken, " : : :") + var ridFav = Utility.readPref(context, prefToken, " : : :") if (ridFav.contains(rid)) { ridFav = ridFav.replace("$rid:", "") star.setIcon(MyApplication.STAR_OUTLINE_ICON) @@ -153,9 +147,9 @@ object UtilityFavorites { return ridFav } - fun toggleFavoriteSPCMESO(context: Context, rid: String, label: String, star: MenuItem) { - var ridFav: String = Utility.readPref(context, "SPCMESO_FAV", " : : :") - var ridFavLabel: String = Utility.readPref(context, "SPCMESO_LABEL_FAV", " : : :") + fun toggleFavoriteSpcMeso(context: Context, rid: String, label: String, star: MenuItem) { + var ridFav = Utility.readPref(context, "SPCMESO_FAV", " : : :") + var ridFavLabel = Utility.readPref(context, "SPCMESO_LABEL_FAV", " : : :") if (ridFav.contains(rid)) { ridFav = ridFav.replace("$rid:", "") ridFavLabel = ridFavLabel.replace("$label:", "") @@ -171,7 +165,7 @@ object UtilityFavorites { MyApplication.spcmesoLabelFav = ridFavLabel } - fun setupFavMenuSREF(ridFav: String, param: String): List { + fun setupFavMenuSref(ridFav: String, param: String): List { val ridArr = MyApplication.colon.split(ridFav) ridArr[0] = param ridArr[1] = ADD_STR @@ -186,7 +180,7 @@ object UtilityFavorites { return ridArrLoc.toList() } - fun setupFavMenuSPCMESO(ridFav: String, param: String): List { + fun setupFavMenuSpcMeso(ridFav: String, param: String): List { var ridArr = MyApplication.colon.split(ridFav) // bug experienced where somehow size was below 3 if (ridArr.size < 3) { @@ -205,7 +199,7 @@ object UtilityFavorites { return ridArrLoc.toList() } - fun setupFavMenuNWSTEXT(ridFav: String, param: String): List { + fun setupFavMenuNwsText(ridFav: String, param: String): List { val ridArr = MyApplication.colon.split(ridFav) ridArr[0] = param ridArr[1] = ADD_STR @@ -215,12 +209,12 @@ object UtilityFavorites { if (it == 1 || it == 2) ridArrLoc[it] = ridArr[it] else - ridArrLoc[it] = GlobalArrays.nwsTextProducts[findPositionNWSTEXT(ridArr[it])] + ridArrLoc[it] = GlobalArrays.nwsTextProducts[findPositionNwsText(ridArr[it])] } return ridArrLoc.toList() } - fun findPositionNWSTEXT(key: String): Int = + fun findPositionNwsText(key: String): Int = GlobalArrays.nwsTextProducts.indices.firstOrNull { GlobalArrays.nwsTextProducts[it].contains( key diff --git a/app/src/main/java/joshuatee/wx/util/UtilityIO.kt b/app/src/main/java/joshuatee/wx/util/UtilityIO.kt index 3c88d67b..9fd420af 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityIO.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityIO.kt @@ -47,7 +47,7 @@ object UtilityIO { fos.flush() fos.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } @@ -67,7 +67,7 @@ object UtilityIO { outputStream.close() inputStream.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return outputStream.toString() } @@ -87,7 +87,7 @@ object UtilityIO { output.close() input.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } @@ -111,7 +111,7 @@ object UtilityIO { fos.flush() fos.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } @@ -126,7 +126,7 @@ object UtilityIO { line = reader.readLine() } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return content } diff --git a/app/src/main/java/joshuatee/wx/util/UtilityImageMap.kt b/app/src/main/java/joshuatee/wx/util/UtilityImageMap.kt index 979c79c1..5b78c19c 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityImageMap.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityImageMap.kt @@ -25,7 +25,7 @@ import joshuatee.wx.R object UtilityImageMap { - fun maptoRid(id: Int): String = when (id) { + fun mapToRid(id: Int): String = when (id) { R.id.CBW -> "CBW" R.id.GYX -> "GYX" R.id.CXX -> "CXX" @@ -185,134 +185,7 @@ object UtilityImageMap { else -> "" } - - /* fun maptoGOESWFO(id: Int): String = when (id) { - R.id.afc -> "ak" - R.id.afg -> "ak" - R.id.ajk -> "ak" - R.id.abq -> "abq" - R.id.abr -> "abr" - R.id.akq -> "akq" - R.id.aly -> "aly" - R.id.ama -> "ama" - R.id.apx -> "apx" - R.id.arx -> "arx" - R.id.bgm -> "bgm" - R.id.bis -> "bis" - R.id.bmx -> "bmx" - R.id.bna -> "ohx" - R.id.boi -> "boi" - R.id.box -> "box" - R.id.bro -> "bro" - R.id.btv -> "btv" - R.id.buf -> "buf" - R.id.byz -> "byz" - R.id.cae -> "cae" - R.id.car -> "car" - R.id.chs -> "chs" - R.id.cle -> "cle" - R.id.crp -> "crp" - R.id.ctp -> "ctp" - R.id.cys -> "cys" - R.id.ddc -> "ddc" - R.id.bou -> "bou" - R.id.dlh -> "dlh" - R.id.dmx -> "dmx" - R.id.dtx -> "dtx" - R.id.dvn -> "dvn" - R.id.eax -> "eax" - R.id.eka -> "eka" - R.id.elp -> "epz" - R.id.ewx -> "ewx" - R.id.eyw -> "eyw" - R.id.ffc -> "ffc" - R.id.fgf -> "fgf" - R.id.fgz -> "fgz" - R.id.fsd -> "fsd" - R.id.fwd -> "fwd" - R.id.ggw -> "ggw" - R.id.gid -> "gid" - R.id.gjt -> "gjt" - R.id.gld -> "gld" - R.id.grb -> "grb" - R.id.grr -> "grr" - R.id.gsp -> "gsp" - R.id.guam -> "guam" - R.id.gyx -> "gyx" - R.id.hgx -> "hgx" - R.id.hnl -> "hi" - R.id.hnx -> "hnx" - R.id.hun -> "hun" - R.id.ict -> "ict" - R.id.ilm -> "ilm" - R.id.iln -> "iln" - R.id.ilx -> "ilx" - R.id.ind -> "ind" - R.id.iwx -> "iwx" - R.id.jan -> "jan" - R.id.jax -> "jax" - R.id.jkl -> "jkl" - R.id.lbf -> "lbf" - R.id.lch -> "lch" - R.id.lix -> "lix" - R.id.lkn -> "lkn" - R.id.lmk -> "lmk" - R.id.lot -> "lot" - R.id.lox -> "lox" - R.id.lsx -> "lsx" - R.id.lub -> "lub" - R.id.lwx -> "lwx" - R.id.lzk -> "lzk" - R.id.maf -> "maf" - R.id.meg -> "meg" - R.id.mfl -> "mfl" - R.id.mfr -> "mfr" - R.id.mhx -> "mhx" - R.id.mkx -> "mkx" - R.id.mlb -> "mlb" - R.id.mob -> "mob" - R.id.mpx -> "mpx" - R.id.mqt -> "mqt" - R.id.mrx -> "mrx" - R.id.mso -> "mso" - R.id.mtr -> "mtr" - R.id.oax -> "oax" - R.id.okx -> "okx" - R.id.otx -> "otx" - R.id.oun -> "oun" - R.id.pah -> "pah" - R.id.pbz -> "pbz" - R.id.pdt -> "pdt" - R.id.phi -> "phi" - R.id.pih -> "pih" - R.id.pqr -> "pqr" - R.id.psr -> "psr" - R.id.pub -> "pub" - R.id.rah -> "rah" - R.id.rev -> "rev" - R.id.riw -> "riw" - R.id.rlx -> "rlx" - R.id.rnk -> "rnk" - R.id.sew -> "sew" - R.id.sgf -> "sgf" - R.id.sgx -> "sgx" - R.id.shv -> "shv" - R.id.sjt -> "sjt" - R.id.sju -> "sju" - R.id.slc -> "slc" - R.id.sto -> "sto" - R.id.tbw -> "tbw" - R.id.tfx -> "tfx" - R.id.tlh -> "tae" - R.id.top -> "top" - R.id.tsa -> "tsa" - R.id.twc -> "twc" - R.id.unr -> "unr" - R.id.vef -> "vef" - else -> "" - }*/ - - fun maptoWFO(id: Int): String = when (id) { + fun mapToWfo(id: Int): String = when (id) { R.id.afc -> "afc" R.id.afg -> "afg" R.id.ajk -> "ajk" @@ -438,7 +311,7 @@ object UtilityImageMap { else -> "" } - fun maptoSND(id: Int): String = when (id) { + fun mapToSnd(id: Int): String = when (id) { R.id.ABQ -> "ABQ" R.id.ABR -> "ABR" R.id.ALB -> "ALB" @@ -521,7 +394,7 @@ object UtilityImageMap { else -> "" } - fun maptoCARid(id: Int): String = when (id) { + fun mapToCanadaRadarSite(id: Int): String = when (id) { R.id.WUJ -> "WUJ" R.id.XBE -> "XBE" R.id.WBI -> "WBI" @@ -556,7 +429,7 @@ object UtilityImageMap { else -> "" } - fun caMAP(id: Int): String = when (id) { + fun canadaMap(id: Int): String = when (id) { R.id.ab_49 -> "ab_49" R.id.ab_52 -> "ab_52" R.id.ab_59 -> "ab_59" diff --git a/app/src/main/java/joshuatee/wx/util/UtilityImg.kt b/app/src/main/java/joshuatee/wx/util/UtilityImg.kt index 584ace60..abee71e2 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityImg.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityImg.kt @@ -270,7 +270,7 @@ object UtilityImg { canvas.drawText(mText, x * scale, y * scale, paint) return bitmap } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) return Bitmap.createBitmap(10, 10, Config.ARGB_8888) } } @@ -291,7 +291,7 @@ object UtilityImg { canvas.drawText(radarStatus, x * scale, y * scale, paint) return bitmap } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) return Bitmap.createBitmap(10, 10, Config.ARGB_8888) } } diff --git a/app/src/main/java/joshuatee/wx/util/UtilityImgAnim.kt b/app/src/main/java/joshuatee/wx/util/UtilityImgAnim.kt index d7ea8f71..ef7113a3 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityImgAnim.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityImgAnim.kt @@ -48,12 +48,12 @@ object UtilityImgAnim { (0 until radarAl.size).mapTo(retAl) { radarAl[it] } } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return retAl } - fun getAnimationDrawableFromURLList( + fun getAnimationDrawableFromUrlList( context: Context, urlAl: List, delayF: Int @@ -72,7 +72,7 @@ object UtilityImgAnim { return animDrawable } - fun getAnimationDrawableFromURLListWhiteBG( + fun getAnimationDrawableFromUrlListWhiteBG( context: Context, urlAl: List, delayF: Int diff --git a/app/src/main/java/joshuatee/wx/util/UtilityLog.kt b/app/src/main/java/joshuatee/wx/util/UtilityLog.kt index 08ca5fe3..ffa35cb3 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityLog.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityLog.kt @@ -13,9 +13,6 @@ object UtilityLog { } } - // FIXME camelcase - fun HandleException(exception: Exception): Unit = exception.printStackTrace() - fun handleException(exception: Exception): Unit = exception.printStackTrace() fun handleException(exception: OutOfMemoryError): Unit = exception.printStackTrace() diff --git a/app/src/main/java/joshuatee/wx/util/UtilityMap.kt b/app/src/main/java/joshuatee/wx/util/UtilityMap.kt index cc66c674..3c9979ee 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityMap.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityMap.kt @@ -23,10 +23,10 @@ package joshuatee.wx.util object UtilityMap { - fun genMapURL(xStr: String, yStr: String, zoomLevel: String): String = + fun genMapUrl(xStr: String, yStr: String, zoomLevel: String): String = "http://www.openstreetmap.org/?mlat=$xStr&mlon=$yStr&zoom=$zoomLevel&layers=M" - fun genMapURLFromStreetAddress(streetAddr: String): String = + fun genMapUrlFromStreetAddress(streetAddr: String): String = "http://www.openstreetmap.org/search?query=" + streetAddr.replace(",", "%2C").replace( " ", "%20" diff --git a/app/src/main/java/joshuatee/wx/util/UtilityMath.kt b/app/src/main/java/joshuatee/wx/util/UtilityMath.kt index 8a55e57b..875aed41 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityMath.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityMath.kt @@ -39,7 +39,7 @@ object UtilityMath { newX = newX.replace("0$".toRegex(), "") newX = newX.replace("\\.$".toRegex(), "") } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return newX } @@ -62,7 +62,7 @@ object UtilityMath { return value } - fun cTof(valueF: String): String { + fun celsiusToFahrenheit(valueF: String): String { var value = valueF var tmpNum: Double if (MyApplication.unitsF) { @@ -73,17 +73,12 @@ object UtilityMath { return value } - /* internal fun cTof(valueDF: Double): String { - val valueD = valueDF * 9 / 5 + 32 - return round(valueD).toInt().toString() - }*/ - - internal fun fToC(valueDF: Double): String { + internal fun fahrenheitToCelsius(valueDF: Double): String { val valueD = (valueDF - 32) * 5 / 9 return round(valueD).toInt().toString() } - private fun cToFInt(valueF: Int): String { + private fun celsiusToFahrenheitAsInt(valueF: Int): String { var value = valueF var retVal = "" if (MyApplication.unitsF) { @@ -93,11 +88,11 @@ object UtilityMath { return retVal } - fun cToFTable(): String { + fun celsiusToFahrenheitTable(): String { var table = "" val cInit = -40 for (z in 40 downTo cInit) { - val f = cToFInt(z) + val f = celsiusToFahrenheitAsInt(z) table += z.toString() + " " + f + MyApplication.newline } return table diff --git a/app/src/main/java/joshuatee/wx/util/UtilityMetarConditions.kt b/app/src/main/java/joshuatee/wx/util/UtilityMetarConditions.kt index 0cbca408..ab634035 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityMetarConditions.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityMetarConditions.kt @@ -297,6 +297,8 @@ object UtilityMetarConditions { "Thunderstorm in Vicinity Fog" to "hi_tsra", "Lightning Observed" to "hi_tsra", "Cumulonimbus Clouds, Lightning Observed" to "hi_tsra", + "Cumulonimbus Clouds, Towering Cumulus Clouds Observed" to "hi_tsra", + // FIXME //"Thunderstorm in Vicinity Haze" to "hi_tsra", "Cumulonimbus Clouds Observed" to "tsra_hi", diff --git a/app/src/main/java/joshuatee/wx/util/UtilityShare.kt b/app/src/main/java/joshuatee/wx/util/UtilityShare.kt index f77214f0..1e844ce0 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityShare.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityShare.kt @@ -52,13 +52,13 @@ object UtilityShare { fos.flush() fos.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } finally { if (fos != null) try { fos.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } val formattedDate = UtilityTime.getDateAsString("yyyy-MM-dd HH:mm:ss") @@ -94,7 +94,7 @@ object UtilityShare { bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos) fos.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } val formattedDate = UtilityTime.getDateAsString("yyyy-MM-dd HH:mm:ss") val sharingIntent = Intent(Intent.ACTION_SEND) @@ -126,7 +126,7 @@ object UtilityShare { bm.compress(Bitmap.CompressFormat.PNG, 100, fos) fos.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } } val formattedDate = UtilityTime.getDateAsString("yyyy-MM-dd HH:mm:ss") @@ -155,7 +155,7 @@ object UtilityShare { bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos) fos.close() } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } val formattedDate = UtilityTime.getDateAsString("yyyy-MM-dd HH:mm:ss") val sharingIntent = Intent(Intent.ACTION_SEND) diff --git a/app/src/main/java/joshuatee/wx/util/UtilityString.kt b/app/src/main/java/joshuatee/wx/util/UtilityString.kt index 91daf24f..b2b2d8df 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityString.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityString.kt @@ -46,233 +46,226 @@ object UtilityString { return String(chars) } - /*internal fun shortenTimeV2(longTimeF: String): String { - var longTime = longTimeF - longTime = longTime.replace("-09:00", "").replace("-10:00", "").replace("-05:00", "") - .replace("T", " ").replace("-04:00", "").replace(":00 ", " ") - return longTime.replace("-06:00", "").replace("-07:00", "") - }*/ + fun getHtmlAndParse(url: String, match: String): String = url.getHtml().parse(match) - fun getHTMLandParse(url: String, matchStr: String): String = url.getHtml().parse(matchStr) + fun getHtmlAndParse(url: String, pattern: Pattern): String = url.getHtml().parse(pattern) - fun getHTMLandParse(url: String, p: Pattern): String = url.getHtml().parse(p) + fun getHtmlAndParseLastMatch(url: String, match: String): String = + url.getHtml().parseLastMatch(match) - fun getHTMLandParseLastMatch(url: String, matchStr: String): String = - url.getHtml().parseLastMatch(matchStr) + fun getHtmlAndParseLastMatch(url: String, pattern: Pattern): String = url.getHtml().parseLastMatch(pattern) - fun getHTMLandParseLastMatch(url: String, p: Pattern): String = url.getHtml().parseLastMatch(p) - - fun parseLastMatchS(str: String, p: Pattern): String { + fun parseLastMatch(str: String, pattern: Pattern): String { var content = "" try { - val m = p.matcher(str) + val m = pattern.matcher(str) while (m.find()) { content = m.group(1) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return content } - fun parseLastMatchS(str: String, matchStr: String): String { + fun parseLastMatch(string: String, match: String): String { var content = "" try { - val p = Pattern.compile(matchStr) - val m = p.matcher(str) + val p = Pattern.compile(match) + val m = p.matcher(string) while (m.find()) { content = m.group(1) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return content } - fun parseS(data: String, matchStr: String): String { + fun parse(data: String, match: String): String { var content = "" try { - val p = Pattern.compile(matchStr) + val p = Pattern.compile(match) val m = p.matcher(data) if (m.find()) content = m.group(1) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return content } - internal fun parseAcrossLines(data: String, matchStr: String): String { + internal fun parseAcrossLines(data: String, match: String): String { var content = "" try { - val p = Pattern.compile(matchStr, Pattern.DOTALL) - val m = p.matcher(data) + val pattern = Pattern.compile(match, Pattern.DOTALL) + val m = pattern.matcher(data) if (m.find()) content = m.group(1) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return content } - fun parseS(data: String, p: Pattern): String { + fun parse(data: String, pattern: Pattern): String { var content = "" try { - val m = p.matcher(data) + val m = pattern.matcher(data) if (m.find()) content = m.group(1) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return content } - fun getHTMLandParseSep(url: String, matchStr: String): String = url.getHtmlSep().parse(matchStr) + fun getHtmlAndParseSep(url: String, match: String): String = url.getHtmlSep().parse(match) - internal fun getHTMLandParseSep(url: String, p: Pattern) = url.getHtmlSep().parse(p) + internal fun getHtmlAndParseSep(url: String, pattern: Pattern) = url.getHtmlSep().parse(pattern) - fun getHTMLandParseMultipeFirstMatch( + fun getHtmlAndParseMultipleFirstMatch( url: String, - matchStr: String, + match: String, number: Int - ): MutableList = parseMultipeFirst(url.getHtml(), matchStr, number) + ): MutableList = parseMultipleFirst(url.getHtml(), match, number) - private fun parseMultipeFirst( + private fun parseMultipleFirst( data: String, - match_str: String, + match: String, number: Int ): MutableList { val result = MutableList(number) { "" } try { - val p = Pattern.compile(match_str) - val m = p.matcher(data) + val pattern = Pattern.compile(match) + val m = pattern.matcher(data) m.find() (0 until number).forEach { result[it] = m.group(it + 1) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return result } - fun parseMultipe(data: String, match_str: String, number: Int): MutableList { + fun parseMultiple(data: String, match: String, number: Int): MutableList { val result = MutableList(number) { "" } try { - val p = Pattern.compile(match_str) - val m = p.matcher(data) + val pattern = Pattern.compile(match) + val m = pattern.matcher(data) while (m.find()) { (0 until number).forEach { result[it] = m.group(it + 1) } } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return result } - fun parseMultipe(data: String, p: Pattern, number: Int): MutableList { + fun parseMultiple(data: String, pattern: Pattern, number: Int): MutableList { val result = MutableList(number) { "" } try { - val m = p.matcher(data) + val m = pattern.matcher(data) while (m.find()) { (0 until number).forEach { result[it] = m.group(it + 1) } } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return result } - fun parseColumnS(data: String, matchStr: String): List { + fun parseColumn(data: String, match: String): List { val result = mutableListOf() try { - val p = Pattern.compile(matchStr) - val m = p.matcher(data) + val pattern = Pattern.compile(match) + val m = pattern.matcher(data) while (m.find()) { result.add(m.group(1)) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return result } - fun parseColumnMutable(data: String, matchStr: String): MutableList { + fun parseColumnMutable(data: String, match: String): MutableList { val result = mutableListOf() try { - val p = Pattern.compile(matchStr) - val m = p.matcher(data) + val pattern = Pattern.compile(match) + val m = pattern.matcher(data) while (m.find()) { result.add(m.group(1)) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return result } - fun parseColumnMutable(data: String, p: Pattern): MutableList { + fun parseColumnMutable(data: String, pattern: Pattern): MutableList { val result = mutableListOf() try { - val m = p.matcher(data) + val m = pattern.matcher(data) while (m.find()) { result.add(m.group(1)) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return result } - fun parseColumnS(data: String, p: Pattern): List { + fun parseColumn(data: String, pattern: Pattern): List { val result = mutableListOf() try { - val m = p.matcher(data) + val m = pattern.matcher(data) while (m.find()) { result.add(m.group(1)) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return result } - fun parseColumnAl(data: String, p: Pattern): MutableList { + fun parseColumnAl(data: String, pattern: Pattern): MutableList { val result = mutableListOf() try { - val m = p.matcher(data) + val m = pattern.matcher(data) while (m.find()) { result.add(m.group(1)) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return result } - fun parseColumnAllS(data: String, p: Pattern): List { + fun parseColumnAll(data: String, pattern: Pattern): List { val result = mutableListOf() try { - val m = p.matcher(data) + val m = pattern.matcher(data) while (m.find()) { result.add(m.group()) } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return result } - fun parseAndCount(data: String, matchStr: String): Int { + fun parseAndCount(data: String, match: String): Int { var i = 0 try { - val p = Pattern.compile(matchStr) + val p = Pattern.compile(match) val m = p.matcher(data) while (m.find()) { i += 1 } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return i } - fun getNWSPRE(url: String): String = url.getHtmlSep().parse(RegExp.pre2Pattern) + fun getNwsPre(url: String): String = url.getHtmlSep().parse(RegExp.pre2Pattern) fun getLastXChars(s: String, x: Int): String = when { s.length == x -> s @@ -280,6 +273,6 @@ object UtilityString { else -> s } - fun addPeriodBeforeLastTwoChars(str: String): String = - StringBuilder(str).insert(str.length - 2, ".").toString() + fun addPeriodBeforeLastTwoChars(string: String): String = + StringBuilder(string).insert(string.length - 2, ".").toString() } diff --git a/app/src/main/java/joshuatee/wx/util/UtilityTime.kt b/app/src/main/java/joshuatee/wx/util/UtilityTime.kt index c7af9898..faac6e87 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityTime.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityTime.kt @@ -33,21 +33,7 @@ import joshuatee.wx.Extensions.* object UtilityTime { - /*internal fun convertFromUTC(time: String): String { - var returnTime = time - val inputFormat = SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss", Locale.US) - inputFormat.timeZone = TimeZone.getTimeZone("UTC") - val outputFormat = SimpleDateFormat("yyyy-MM-dd h:mm a", Locale.US) - try { - val date = inputFormat.parse(time.replace("+00:00", "")) - returnTime = outputFormat.format(date) - } catch (e: Exception) { - UtilityLog.HandleException(e) - } - return returnTime - }*/ - - internal fun convertFromUTCForMetar(time: String): String { + internal fun convertFromUtcForMetar(time: String): String { var returnTime = time val inputFormat = SimpleDateFormat("yyyy.MM.dd' 'HHmm", Locale.US) inputFormat.timeZone = TimeZone.getTimeZone("UTC") @@ -56,7 +42,7 @@ object UtilityTime { val date = inputFormat.parse(time) returnTime = outputFormat.format(date) } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } return returnTime } @@ -72,7 +58,7 @@ object UtilityTime { parsed = format.parse(time) t = parsed.time } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } listRun.add(format.format(Date(t - 60 * oneMinuteInMillis * it.toLong() * hours.toLong()))) } @@ -90,7 +76,7 @@ object UtilityTime { parsed = format.parse(time) t = parsed.time } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } listRun.add(format.format(Date(t - 60 * oneMinuteInMillis * it.toLong() * hours.toLong()))) } @@ -147,7 +133,7 @@ object UtilityTime { fun day(): Int = Calendar.getInstance().get(Calendar.DAY_OF_MONTH) - val currentHourInUTC: Int + val currentHourInUtc: Int get() = Calendar.getInstance(TimeZone.getTimeZone("GMT")).get(Calendar.HOUR_OF_DAY) fun isRadarTimeOld(radarTime: String): Boolean { @@ -192,25 +178,24 @@ object UtilityTime { val timeRange = (vtec).parse("-([0-9]{6}T[0-9]{4})Z") val timeInMinutes = decodeVtecTime(timeRange) val currentTimeInMinutes = decodeVtecTime(getGmtTimeForVtec()) - val vtecCurrent = currentTimeInMinutes.before(timeInMinutes) - return vtecCurrent + return currentTimeInMinutes.before(timeInMinutes) } - fun decodeVtecTime(timeRangeOriginal: String): Calendar { + private fun decodeVtecTime(timeRangeOriginal: String): Calendar { // Y2K issue val timeRange = timeRangeOriginal.replace("T","") - val year = ("20" + (timeRange).parse("([0-9]{2})[0-9]{4}[0-9]{4}")).toIntOrNull() ?: 0; - val month = ((timeRange).parse("[0-9]{2}([0-9]{2})[0-9]{2}[0-9]{4}")).toIntOrNull() ?: 0; - val day = ((timeRange).parse("[0-9]{4}([0-9]{2})[0-9]{4}")).toIntOrNull() ?: 0; - val hour = ((timeRange).parse("[0-9]{6}([0-9]{2})[0-9]{2}")).toIntOrNull() ?: 0; - val minute = ((timeRange).parse("[0-9]{6}[0-9]{2}([0-9]{2})")).toIntOrNull() ?: 0; + val year = ("20" + (timeRange).parse("([0-9]{2})[0-9]{4}[0-9]{4}")).toIntOrNull() ?: 0 + val month = ((timeRange).parse("[0-9]{2}([0-9]{2})[0-9]{2}[0-9]{4}")).toIntOrNull() ?: 0 + val day = ((timeRange).parse("[0-9]{4}([0-9]{2})[0-9]{4}")).toIntOrNull() ?: 0 + val hour = ((timeRange).parse("[0-9]{6}([0-9]{2})[0-9]{2}")).toIntOrNull() ?: 0 + val minute = ((timeRange).parse("[0-9]{6}[0-9]{2}([0-9]{2})")).toIntOrNull() ?: 0 //UtilityLog.d("wx", timeRange + "," + year.toString() + "," + month.toString() + "," + day.toString() + "," + hour.toString() + "," + minute.toString()); val cal = Calendar.getInstance() - cal.set(year, month - 1, day, hour, minute); + cal.set(year, month - 1, day, hour, minute) return cal } - fun getGmtTimeForVtec(): String{ + private fun getGmtTimeForVtec(): String{ val dateFormatGmt = SimpleDateFormat("yyMMddHHmm", Locale.US) dateFormatGmt.timeZone = TimeZone.getTimeZone("GMT") return dateFormatGmt.format(Date()) diff --git a/app/src/main/java/joshuatee/wx/util/UtilityTimeSunMoon.kt b/app/src/main/java/joshuatee/wx/util/UtilityTimeSunMoon.kt index a955bbee..85ec89a4 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityTimeSunMoon.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityTimeSunMoon.kt @@ -21,6 +21,9 @@ package joshuatee.wx.util +import android.content.Context +import android.text.format.DateFormat +import joshuatee.wx.MyApplication import joshuatee.wx.external.ExternalSunriseLocation import joshuatee.wx.external.ExternalSunriseSunsetCalculator import joshuatee.wx.external.SolarEvent @@ -82,7 +85,7 @@ object UtilityTimeSunMoon { } fun moonPhaseFromIllumination(phase: Double): String { - var phaseString: String + val phaseString: String if (phase < 0.02) { phaseString = "New Moon" } else if (0.02 <= phase && phase < 0.23) { @@ -104,4 +107,98 @@ object UtilityTimeSunMoon { } return phaseString } + + fun getSunriseSunset(context: Context, locNum: String): String { + val locNumInt = (locNum.toIntOrNull() ?: 0) - 1 + val lat: String + val lon: String + if (!Location.isUS(locNumInt)) { + val latArr = Location.getX(locNumInt).split(":") + val lonArr = Location.getY(locNumInt).split(":") + if (latArr.size > 2 && lonArr.size > 1) { + lat = latArr[2] + lon = lonArr[1] + } else + return "" + } else { + lat = Location.getX(locNumInt) + lon = Location.getY(locNumInt) + } + val location = ExternalSunriseLocation(lat, lon) + val calculator = ExternalSunriseSunsetCalculator(location, TimeZone.getDefault()) + val officialSunriseCal = + calculator.getOfficialSunriseCalendarForDate(Calendar.getInstance()) + val officialSunsetCal = calculator.getOfficialSunsetCalendarForDate(Calendar.getInstance()) + val srTime: String + val ssTime: String + var amStr = "" + var pmStr = "" + if (!DateFormat.is24HourFormat(context)) { + amStr = "am" + pmStr = "pm" + srTime = (officialSunriseCal.get(Calendar.HOUR)).toString() + ":" + + String.format("%2s", (officialSunriseCal.get(Calendar.MINUTE))).replace( + ' ', + '0' + ) + ssTime = (officialSunsetCal.get(Calendar.HOUR)).toString() + ":" + + String.format("%2s", (officialSunsetCal.get(Calendar.MINUTE))).replace(' ', '0') + } else { + srTime = (officialSunriseCal.get(Calendar.HOUR_OF_DAY)).toString() + ":" + + String.format("%2s", (officialSunriseCal.get(Calendar.MINUTE))).replace( + ' ', + '0' + ) + ssTime = (officialSunsetCal.get(Calendar.HOUR_OF_DAY)).toString() + ":" + + String.format("%2s", (officialSunsetCal.get(Calendar.MINUTE))).replace(' ', '0') + } + return "Sunrise: $srTime$amStr Sunset: $ssTime$pmStr" + } + + fun getSunriseSunsetShort(context: Context, locNum: String): String { + val locNumInt = (locNum.toIntOrNull() ?: 0) - 1 + val lat: String + val lon: String + if (!MyApplication.locations[locNumInt].isUS) { + val latArr = MyApplication.colon.split(Location.getX(locNumInt)) + val lonArr = MyApplication.colon.split(Location.getY(locNumInt)) + if (latArr.size > 2 && lonArr.size > 1) { + lat = latArr[2] + lon = lonArr[1] + } else + return "" + } else { + lat = Location.getX(locNumInt) + lon = Location.getY(locNumInt) + } + val location = ExternalSunriseLocation(lat, lon) + val calculator = ExternalSunriseSunsetCalculator(location, TimeZone.getDefault()) + val officialSunriseCal = + calculator.getOfficialSunriseCalendarForDate(Calendar.getInstance()) + val officialSunsetCal = calculator.getOfficialSunsetCalendarForDate(Calendar.getInstance()) + val srTime: String + val ssTime: String + var amStr = "" + var pmStr = "" + if (!DateFormat.is24HourFormat(context)) { + amStr = "am" + pmStr = "pm" + srTime = (officialSunriseCal.get(Calendar.HOUR)).toString() + ":" + + String.format("%2s", (officialSunriseCal.get(Calendar.MINUTE))).replace( + ' ', + '0' + ) + ssTime = (officialSunsetCal.get(Calendar.HOUR)).toString() + ":" + + String.format("%2s", (officialSunsetCal.get(Calendar.MINUTE))).replace(' ', '0') + } else { + srTime = (officialSunriseCal.get(Calendar.HOUR_OF_DAY)).toString() + ":" + + String.format("%2s", (officialSunriseCal.get(Calendar.MINUTE))).replace( + ' ', + '0' + ) + ssTime = (officialSunsetCal.get(Calendar.HOUR_OF_DAY)).toString() + ":" + + String.format("%2s", (officialSunsetCal.get(Calendar.MINUTE))).replace(' ', '0') + } + return "$srTime$amStr / $ssTime$pmStr" + } } diff --git a/app/src/main/java/joshuatee/wx/util/UtilityUS.kt b/app/src/main/java/joshuatee/wx/util/UtilityUS.kt index 6fb6d6b0..223f7288 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityUS.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityUS.kt @@ -39,22 +39,6 @@ object UtilityUS { var obsClosestClass: String = "" private val OBS_CODE_TO_LOCATION = mutableMapOf() - /*internal fun getStatus(context: Context, conditionsTimeStrF: String): String { - var conditionsTimeStr = conditionsTimeStrF - var locationName: String? = OBS_CODE_TO_LOCATION[obsClosestClass] - if (locationName == null) { - locationName = findObsName(context, obsClosestClass) - if (locationName != "" && obsClosestClass != "") { - OBS_CODE_TO_LOCATION[obsClosestClass] = locationName - } - } - conditionsTimeStr = - UtilityTime.convertFromUTC(UtilityString.shortenTimeV2(conditionsTimeStr)) - return conditionsTimeStr.replace(":00 ", " ") + " " + UtilityString.capitalizeString( - locationName - ).trim { it <= ' ' } + " (" + obsClosestClass + ") " // strip off seconds that is always 00, need to do this here - }*/ - internal fun getStatusViaMetar(context: Context, conditionsTimeStr: String): String { var locationName: String? = OBS_CODE_TO_LOCATION[obsClosestClass] if (locationName == null) { @@ -67,7 +51,7 @@ object UtilityUS { } private fun findObsName(context: Context, obsShortCode: String): String { - var locatioName = "" + var locationName = "" try { val xmlFileInputStream = context.resources.openRawResource(R.raw.stations_us4) val text = UtilityIO.readTextFile(xmlFileInputStream) @@ -76,52 +60,14 @@ object UtilityUS { val tmp = lines.lastOrNull { it.contains(",$obsShortCode") } ?: "" tmpArr = tmp.split(",") if (tmpArr.size > 2) { - locatioName = tmpArr[0] + ", " + tmpArr[1] + locationName = tmpArr[0] + ", " + tmpArr[1] } } catch (e: Exception) { - UtilityLog.HandleException(e) + UtilityLog.handleException(e) } - return locatioName + return locationName } - /*internal fun getObsFromLatLon(context: Context, location: LatLon): String { - var x = location.latString - var y = location.lonString - x = UtilityMath.latLonFix(x) - y = UtilityMath.latLonFix(y) - val key = "LLTOOBS$x,$y" - var obsClosest: String = Utility.readPref(key, "") - if (obsClosest == "") { - val obsHtml = - UtilityDownloadNWS.getNWSStringFromURL("https://api.weather.gov/points/$x,$y/stations") - obsClosest = obsHtml.parse("gov/stations/(.*?)\"") - obsClosestClass = obsClosest - if (key != "" && obsClosest != "") { - Utility.writePref(context, key, obsClosest) - } - } - obsClosestClass = obsClosest - return obsClosest - }*/ - - /* - - - "number": 1, - "name": "This Afternoon", - "startTime": "2016-12-21T14:00:00-05:00", - "endTime": "2016-12-21T18:00:00-05:00", - "isDaytime": true, - "temperature": 58, - "windSpeed": "3 mph", - "windDirection": "WSW", - "icon": "https://api-v1.weather.gov/icons/land/day/few?size=medium", - "shortForecast": "Sunny", - "detailedForecast": "Sunny, with a high near 58. West southwest wind around 3 mph." - - - */ - fun checkForNotifications( context: Context, currentLoc: Int, @@ -137,7 +83,7 @@ object UtilityUS { hazardTitles.forEach { title -> if (idAl.size > i) { val url = idAl[i] - val ca = CAPAlert.createFromURL(url) + val ca = CAPAlert.createFromUrl(url) if (UtilityNotificationTools.nwsLocalAlertNotFiltered(context, title)) { html = "$html$title
    " html = html + "Counties: " + ca.area + "
    " diff --git a/app/src/main/java/joshuatee/wx/vis/UtilityGoes.kt b/app/src/main/java/joshuatee/wx/vis/UtilityGoes.kt index 737ff0a3..50bd956e 100644 --- a/app/src/main/java/joshuatee/wx/vis/UtilityGoes.kt +++ b/app/src/main/java/joshuatee/wx/vis/UtilityGoes.kt @@ -35,8 +35,8 @@ import joshuatee.wx.util.UtilityLog object UtilityGoes { private fun getImageFileName(sector: String): String { - val fullSize = "latest"; - val size = sizeMap[sector] ?: fullSize; + val fullSize = "latest" + val size = sizeMap[sector] ?: fullSize return "$size.jpg" } @@ -59,7 +59,7 @@ object UtilityGoes { // https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/cgl/12/latest.jpg // https://cdn.star.nesdis.noaa.gov/GOES17/ABI/CONUS/GEOCOLOR/1250x750.jpg // https://cdn.star.nesdis.noaa.gov/GOES16/ABI/CONUS/GEOCOLOR/1250x750.jpg - val url = MyApplication.goes16Url + "/" + satellite + "/ABI/" + sectorLocal + "/" + product + "/" + getImageFileName(sector); + val url = MyApplication.goes16Url + "/" + satellite + "/ABI/" + sectorLocal + "/" + product + "/" + getImageFileName(sector) UtilityLog.d("wx", url) return url.getImage() } @@ -180,7 +180,7 @@ object UtilityGoes { "ssa" to "South America (south)" ) - val sizeMap = mapOf( + private val sizeMap = mapOf( "CONUS-G17" to "1250x750", "CONUS" to "1250x750", "FD" to "1808x1808", diff --git a/app/src/main/java/joshuatee/wx/vis/UtilityNWSGOESFullDisk.kt b/app/src/main/java/joshuatee/wx/vis/UtilityNWSGOESFullDisk.kt index 1b2f5673..dd8364d0 100644 --- a/app/src/main/java/joshuatee/wx/vis/UtilityNWSGOESFullDisk.kt +++ b/app/src/main/java/joshuatee/wx/vis/UtilityNWSGOESFullDisk.kt @@ -68,7 +68,7 @@ internal object UtilityNWSGOESFullDisk { val url = urlF.replace("10.gif", "") val frameCntInt = 10 val urls = (1 until frameCntInt + 1).mapTo(mutableListOf()) { "$url$it.gif" } - return UtilityImgAnim.getAnimationDrawableFromURLList( + return UtilityImgAnim.getAnimationDrawableFromUrlList( context, urls, UtilityImg.animInterval(context) diff --git a/app/src/main/java/joshuatee/wx/vis/UtilityUSImgNWSGOESMercator.kt b/app/src/main/java/joshuatee/wx/vis/UtilityUSImgNWSGOESMercator.kt deleted file mode 100644 index 3d703e64..00000000 --- a/app/src/main/java/joshuatee/wx/vis/UtilityUSImgNWSGOESMercator.kt +++ /dev/null @@ -1,284 +0,0 @@ -/* - - Copyright 2013, 2014, 2015, 2016, 2017, 2018, 2019 joshua.tee@gmail.com - - This file is part of wX. - - wX is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - wX is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with wX. If not, see . - -*/ - -package joshuatee.wx.vis - -import android.content.Context -import joshuatee.wx.util.ProjectionNumbers -import joshuatee.wx.util.Utility - -object UtilityUSImgNWSGOESMercator { - - private val GOES_HASH = mapOf( - "MOB" to "30.70,87.55", - "BMX" to "33.00,86.75", - "HUN" to "34.60,86.90", - "JAN" to "32.50,90.18", - "MEG" to "35.20,89.75", - "OHX" to "35.80,86.50", - "MRX" to "35.90,83.70", - "PAH" to "37.50,89.00", - "LMK" to "37.65,85.70", - "JKL" to "37.40,83.65", - "ILX" to "39.90,89.50", - "LOT" to "41.60,88.40", - "IWX" to "41.40,85.60", - "IND" to "39.55,86.50", - "ILN" to "39.60,83.80", - "CLE" to "41.40,81.90", - "DTX" to "42.70,83.30", - "GRR" to "43.25,85.75", - "APX" to "45.20,84.70", - "MQT" to "46.80,87.85", - "MKX" to "43.30,88.90", - "GRB" to "45.10,88.66", - "ARX" to "43.90,91.45", - "DLH" to "47.10,92.10", - "MPX" to "44.85,93.80", - "FGF" to "47.75,97.05", - "BIS" to "47.50,101.50", - "ABR" to "44.75,99.20", - "UNR" to "44.40,102.90", - "FSD" to "43.50,97.25", - "LBF" to "41.70,100.66", - "OAX" to "41.40,96.80", - "GID" to "40.50,98.80", - "MHX" to "35.15,76.55", - "ILM" to "33.90,78.70", - "RAH" to "35.70,79.00", - "TAE" to "30.30,84.50", - "JAX" to "30.40,82.00", - "TBW" to "27.75,82.30", - "MLB" to "28.25,80.60", - "MFL" to "26.10,80.90", - "EYW" to "24.60,81.60", - "TAE" to "30.25,84.50", - "FFC" to "33.45,83.90", - "CAE" to "33.80,81.05", - "CHS" to "32.28,80.80", - "GSP" to "35.20,82.20", - "OKX" to "41.00,73.25", - "ALY" to "42.80,73.90", - "BUF" to "43.20,77.50", - "BGM" to "42.20,75.68", - "LWX" to "38.90,77.80", - "AKQ" to "37.20,76.69", - "RNK" to "37.10,80.20", - "BOX" to "42.00,71.66", - "PHI" to "39.80,74.75", - "PBZ" to "40.25,80.40", - "CTP" to "40.75,77.90", - "RLX" to "38.40,81.5", - "BTV" to "44.2,73.38", - "GYX" to "44.2,70.6", - "CAR" to "45.66,68.5", - "PUB" to "38.10,104.60", - "BOU" to "39.80,104.40", - "GJT" to "39.00,108.75", - "RIW" to "43.00,108.90", - "CYS" to "42.20,105.25", - "BYZ" to "45.65,107.75", - "GGW" to "47.80,106.50", - "TFX" to "46.66,111.85", - "MSO" to "46.60,114.50", - "PIH" to "43.40,113.08", - "BOI" to "43.60,117.00", - "OTX" to "47.50,118.50", - "SEW" to "47.75,123.80", - "PQR" to "45.00,124.00", - "PDT" to "45.50,120.20", - "MFR" to "42.50,122.90", - "TWC" to "32.45,111.36", - "PSR" to "33.17,113.15", - "FGZ" to "35.15,111.23", - "VEF" to "36.25,115.90", - "REV" to "39.75,119.60", - "LKN" to "40.10,116.65", - "SLC" to "39.75,112.80", - "MAF" to "31.20,102.75", - "EPZ" to "32.00,107.00", - "LUB" to "33.80,101.55", - "AMA" to "35.80,101.55", - "SJT" to "31.85,100.37", - "FWD" to "32.20,97.00", - "EWX" to "29.75,99.27", - "CRP" to "28.00,98.18", - "BRO" to "26.60,98.18", - "HGX" to "29.75,95.60", - "ABQ" to "34.80,106.25", - "DDC" to "38.00,100.36", - "GLD" to "39.33,101.50", - "TOP" to "39.10,96.50", - "ICT" to "38.10,97.10", - "DMX" to "42.00,93.80", - "DVN" to "41.40,90.90", - "OUN" to "35.20,98.30", - "TSA" to "35.40,95.40", - "EAX" to "39.33,94.08", - "SGF" to "37.50,93.18", - "LSX" to "38.66,90.75", - "LZK" to "34.80,92.60", - "SHV" to "32.75,93.85", - "LCH" to "29.90,93.08", - "LIX" to "29.70,90.08", - "HI" to "20.53,155.94", - "EKA" to "40.40,124.55", - "HNX" to "36.40,119.40", - "LOX" to "34.50,120.15", - "STO" to "39.20,121.50", - "SGX" to "33.75,117.40", - "MTR" to "37.25,122.85" - ) - - private fun getGOESCenterNWS(ridF: String) = GOES_HASH[ridF] ?: "0.0,0.0" - - fun getMercatorNumbers(context: Context, rid1: String): ProjectionNumbers { - var scaleFactor = 41.40 - var xStr: String - var yStr: String - val xImageCenterPixels = 360.0 // 720 wide, 480 tall ( NWS Goes ) - val yImageCenterPixels = 240.0 // 720 wide, 480 tall ( NWS Goes ) - when (rid1) { - "MW" -> { - xStr = "39.00" - yStr = "92.00" - } - "GL" -> { - xStr = "45.00" - yStr = "85.00" - scaleFactor = 39.00 - } - "SE" -> { - xStr = "29.00" - yStr = "84.90" - scaleFactor = 37.00 - } - "NE" -> { - xStr = "44.00" - yStr = "75.00" - scaleFactor = 45.00 - } - "NP" -> { - xStr = "46.00" - yStr = "103.00" - scaleFactor = 46.00 - } - "CP" -> { - xStr = "39.00" - yStr = "103.00" - } - "SC" -> { - xStr = "30.00" - yStr = "99.00" - scaleFactor = 37.00 - } - "NW" -> { - xStr = "46.00" - yStr = "118.00" - scaleFactor = 46.00 - } - "MA" -> { - xStr = "38.00" - yStr = "80.00" - } - "WC" -> { - xStr = "39.00" - yStr = "118.00" - } - "SW" -> { - xStr = "30.00" - yStr = "114.00" - scaleFactor = 37.00 - } - else -> { - xStr = Utility.readPref(context, "RID_" + rid1 + "_X", "0.00") - yStr = Utility.readPref(context, "RID_" + rid1 + "_Y", "0.00") - val coords = getGOESCenterNWS(rid1).split(",") - if (coords[0] != "0.0" && coords[1] != "0.0") { - xStr = coords[0] - yStr = coords[1] - } - when (rid1) { - "HI" -> scaleFactor = 35.00 - "SLCa" -> scaleFactor = 70.00 - "TFX" -> scaleFactor = 70.00 - "MSO" -> scaleFactor = 70.00 - "MAFa" -> scaleFactor = 82.00 - "ABQa" -> scaleFactor = 82.00 - "OUNa" -> scaleFactor = 82.00 - "HGX" -> scaleFactor = 82.00 - "TSAa" -> scaleFactor = 82.00 - "MQTa" -> scaleFactor = 82.00 - "DLH" -> scaleFactor = 82.00 - "FGFa" -> scaleFactor = 82.00 - "BIS" -> scaleFactor = 82.00 - "UNRa" -> scaleFactor = 82.00 - "LSX" -> scaleFactor = 82.00 - "BYZa" -> scaleFactor = 82.00 - "BOIa" -> scaleFactor = 82.00 - "OTX" -> scaleFactor = 82.00 - "SEWa" -> scaleFactor = 82.00 - "PQRa" -> scaleFactor = 82.00 - "PDTa" -> scaleFactor = 82.00 - "LKNa" -> scaleFactor = 82.00 - "CAR" -> scaleFactor = 82.00 - "FGZ" -> scaleFactor = 82.00 - "GJT" -> scaleFactor = 82.00 - "APXa" -> scaleFactor = 82.00 - "EKA" -> scaleFactor = 82.00 - "HNXa" -> scaleFactor = 82.00 - "STO" -> scaleFactor = 82.00 - "MTR" -> scaleFactor = 82.00 - "GYXa" -> scaleFactor = 82.00 - "VEF" -> scaleFactor = 82.00 - "REV" -> scaleFactor = 82.00 - else -> scaleFactor = 130.00 // default scale for northern states - } - } - } - - when (rid1) { - "SLC" -> scaleFactor = 64.00 - "ABQ", "OUN", "MAF" -> scaleFactor = 77.00 - "TSA" -> scaleFactor = 78.00 - "HNX" -> scaleFactor = 80.00 - "LSX" -> scaleFactor = 82.00 - "LKN" -> scaleFactor = 85.00 - "RIW", "PQR", "BOI" -> scaleFactor = 88.00 - "PDT", "UNR", "SEW", "BYZ", "FGFa", "GYX", "CAR", "APX" -> scaleFactor = 91.00 - "MQT" -> scaleFactor = 93.60 - "CRP" -> scaleFactor = 115.00 - "HGX" -> scaleFactor = 73.00 - "DLH", "BIS", "OTX", "PDTa", "FGF" -> scaleFactor = 95.00 - "MPX", "ARX", "ABR" -> scaleFactor = 135.00 - "GGW" -> scaleFactor = 140.00 - "MFL", "TBW", "MLB", "EYW", "LUB", "BMX", "TAE", "MOB", "LIX", "LCH", "SHV", "FWD", "SJT", "EWX", "TWC", "PSR", "SGX" -> scaleFactor = - 110.00 - "FFC", "CHS", "CAE", "GSP", "ILM", "MHX", "HUN", "MEG", "LZK", "PUB", "LOX" -> scaleFactor = - 115.00 - "RAH" -> scaleFactor = 118.00 - "SGF", "PAH", "LMK", "JKL", "RNK", "AKQ", "DDC", "ICT" -> scaleFactor = 120.00 - "PHI", "LWX", "RLX", "ILN", "IND", "ILX", "CTP", "PBZ", "LSXa", "EAX", "TOP", "GLD", "BOU" -> scaleFactor = - 125.00 - } - return ProjectionNumbers(scaleFactor, xStr, yStr, xImageCenterPixels, yImageCenterPixels) - } -} diff --git a/app/src/main/java/joshuatee/wx/wpc/WPCImagesActivity.kt b/app/src/main/java/joshuatee/wx/wpc/WPCImagesActivity.kt index cc79a11d..397bafa2 100644 --- a/app/src/main/java/joshuatee/wx/wpc/WPCImagesActivity.kt +++ b/app/src/main/java/joshuatee/wx/wpc/WPCImagesActivity.kt @@ -55,7 +55,6 @@ class WPCImagesActivity : VideoRecordActivity(), View.OnClickListener, private var timePeriod = 1 private var firstRun = false private var imageLoaded = false - //private lateinit var img: TouchImageView2 private lateinit var actionBack: MenuItem private lateinit var actionForward: MenuItem private lateinit var drw: ObjectNavDrawerCombo diff --git a/app/src/main/java/joshuatee/wx/wpc/WPCTextProductsActivity.kt b/app/src/main/java/joshuatee/wx/wpc/WPCTextProductsActivity.kt index 720f74fd..0d8132e0 100644 --- a/app/src/main/java/joshuatee/wx/wpc/WPCTextProductsActivity.kt +++ b/app/src/main/java/joshuatee/wx/wpc/WPCTextProductsActivity.kt @@ -77,7 +77,7 @@ class WPCTextProductsActivity : AudioPlayActivity(), OnMenuItemClickListener, private lateinit var star: MenuItem private lateinit var notifToggle: MenuItem private var ridFavOld = "" - private lateinit var c0: ObjectCardText + private lateinit var textCard: ObjectCardText private lateinit var sp: ObjectSpinner private lateinit var drw: ObjectNavDrawerCombo private lateinit var contextg: Context @@ -100,8 +100,8 @@ class WPCTextProductsActivity : AudioPlayActivity(), OnMenuItemClickListener, prod = activityArguments[0] initProd = prod } - c0 = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) - products = UtilityFavorites.setupFavMenuNWSTEXT(MyApplication.nwsTextFav, prod) + textCard = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) + products = UtilityFavorites.setupFavMenuNwsText(MyApplication.nwsTextFav, prod) sp = ObjectSpinner(this, this, this, R.id.spinner1, products) UtilityWPCText.createData() drw = ObjectNavDrawerCombo( @@ -125,7 +125,7 @@ class WPCTextProductsActivity : AudioPlayActivity(), OnMenuItemClickListener, } ridFavOld = MyApplication.nwsTextFav html = withContext(Dispatchers.IO) { UtilityDownload.getTextProduct(contextg, prod) } - c0.setTextAndTranslate(Utility.fromHtml(html)) + textCard.setTextAndTranslate(Utility.fromHtml(html)) UtilityTTS.conditionalPlay(activityArguments, 2, applicationContext, html, "wpctext") if (initProd != prod) { Utility.writePref(contextg, "WPC_TEXT_FAV", prod) @@ -211,7 +211,7 @@ class WPCTextProductsActivity : AudioPlayActivity(), OnMenuItemClickListener, override fun onRestart() { if (ridFavOld != MyApplication.nwsTextFav) { - products = UtilityFavorites.setupFavMenuNWSTEXT( + products = UtilityFavorites.setupFavMenuNwsText( MyApplication.nwsTextFav, GlobalArrays.nwsTextProducts[findPosition(prod)] ) @@ -222,13 +222,13 @@ class WPCTextProductsActivity : AudioPlayActivity(), OnMenuItemClickListener, private fun toggleFavorite() { UtilityFavorites.toggleFavorite(this, prod, star, "NWS_TEXT_FAV") - products = UtilityFavorites.setupFavMenuNWSTEXT(MyApplication.nwsTextFav, prod) + products = UtilityFavorites.setupFavMenuNwsText(MyApplication.nwsTextFav, prod) sp.refreshData(this, products) } private fun changeProduct() { prod = drw.getUrl() - products = UtilityFavorites.setupFavMenuNWSTEXT( + products = UtilityFavorites.setupFavMenuNwsText( MyApplication.nwsTextFav, GlobalArrays.nwsTextProducts[findPosition(prod)] ) diff --git a/app/src/main/res/menu/uswxoglradarmultipane.xml b/app/src/main/res/menu/uswxoglradarmultipane.xml index 3e405877..0cac1fec 100644 --- a/app/src/main/res/menu/uswxoglradarmultipane.xml +++ b/app/src/main/res/menu/uswxoglradarmultipane.xml @@ -194,6 +194,10 @@ android:id="@+id/action_TDWR" android:title="@string/label_tdwr_sites" app:showAsAction="never" /> + + +Allows one to change the zoom of the conus radar viewing. + Animation speed. Lower is faster. Default is 5. -Thickness of lines for State, Rivers, highways Lines. Smaller is thinner. Default is 1. +Thickness of lines for State, Rivers, highways Lines. Smaller is thinner. -Thickness of lines for warnings. Smaller number is thinner. Default is 4. +Thickness of lines for warnings. Smaller number is thinner. -Thickness of lines for SPC Watch/MCD. Smaller number is thinner. Default is 4. +Thickness of lines for SPC Watch/MCD. Smaller number is thinner. -Thickness of lines for state lines. Smaller number is thinner. Default is 2. +Thickness of lines for state lines. Smaller number is thinner. -Thickness of lines for county outlines. Smaller number is thinner. Default is 2. +Thickness of lines for county outlines. Smaller number is thinner. -Thickness of lines for main highways. Smaller number is thinner. Default is 2. +Thickness of lines for main highways. Smaller number is thinner. -Thickness of lines for secondary highways/roads. Smaller number is thinner. Default is 2. +Thickness of lines for secondary highways/roads. Smaller number is thinner. -Thickness of lines for rivers and lakes. Smaller number is thinner. Default is 2. +Thickness of lines for rivers and lakes. Smaller number is thinner. -Thickness of lines for the GPS location circle. Smaller number is thinner. Default is 5. +Thickness of lines for the GPS location circle. Smaller number is thinner. -Allows one to change the size of the location marker. Default value is 8 +Allows one to change the size of the location marker.
    -Allows one to change the size of the GPS location Image. Default value is 75 +Allows one to change the size of the GPS location Image.
    -Allows one to change the size of the GPS location Bug. Default value is 75 +Allows one to change the size of the GPS location Bug.
    -Allows one to change the default view size for the WXOGL Nexrad radar interface. Default value is 10. Larger value is more zoomed in. +Allows one to change the default view size for the WXOGL Nexrad radar interface. Larger value is more zoomed in.
    Turn on alerts for US-wide tornado warnings. @@ -767,16 +770,16 @@ If enabled the WXOGL radar will hail signatures will show text of hail sizes -Allows one to change the size of the Hail markers. Default value is 75. +Allows one to change the size of the Hail markers.
    -Allows one to change the size of the Hail Text. Default value is 8. +Allows one to change the size of the Hail Text.
    -Allows one to change the size of the TVS markers. Default value is 75. +Allows one to change the size of the TVS markers.
    -Allows one to change the size of the Userpoints markers. Default value is 75. +Allows one to change the size of the Userpoints markers.
    WXOGL will use the last location and zoom level instead of the radar site for the current location in the main tab. @@ -788,7 +791,7 @@ Controls the number of minutes before an auto refresh is triggered if that opti Launch the application directly into the radar interface.
    -Control how much elevation is present in the UI. Default is 0. +Control how much elevation is present in the UI.
    This activity is used to manage the cards ( if enabled ) on the \"home page\" (the first screen shown when the app is launched).