From abcfa743e6d261dedd98a4e234ffded4c26a717f Mon Sep 17 00:00:00 2001 From: ELY M Date: Sat, 23 Jul 2022 09:25:26 -0500 Subject: [PATCH] updates and working on fixing correct hail icons --- app/src/main/AndroidManifest.xml | 4 +- app/src/main/java/joshuatee/wx/Extensions.kt | 4 +- .../main/java/joshuatee/wx/MyApplication.kt | 2 - .../main/java/joshuatee/wx/StartupActivity.kt | 2 +- .../joshuatee/wx/activitiesmisc/CAPAlert.kt | 23 + .../wx/activitiesmisc/ForecastActivity.kt | 26 +- .../wx/activitiesmisc/HourlyActivity.kt | 6 +- .../activitiesmisc/ImageCollectionActivity.kt | 32 +- .../wx/activitiesmisc/ImageShowActivity.kt | 24 +- .../wx/activitiesmisc/LightningActivity.kt | 20 +- .../activitiesmisc/SevereDashboardActivity.kt | 61 +- .../activitiesmisc/SpotterReportsActivity.kt | 4 +- .../wx/activitiesmisc/SpottersActivity.kt | 6 +- .../wx/activitiesmisc/TextScreenActivity.kt | 18 +- .../activitiesmisc/USAlertsDetailActivity.kt | 16 +- .../USWarningsWithRadarActivity.kt | 25 +- .../joshuatee/wx/activitiesmisc/WebView.kt | 8 +- .../wx/activitiesmisc/WfoTextActivity.kt | 36 +- .../wx/audio/SettingsPlaylistActivity.kt | 2 +- .../java/joshuatee/wx/audio/UtilityTTS.kt | 6 +- .../wx/canada/CanadaAlertsActivity.kt | 6 +- .../wx/canada/CanadaHourlyActivity.kt | 14 +- .../joshuatee/wx/canada/CanadaTextActivity.kt | 8 +- .../wx/fragments/ItemTouchHelperAdapter.kt | 2 +- .../wx/fragments/UtilityLocationFragment.kt | 8 +- .../wx/models/DisplayDataNoSpinner.kt | 18 +- .../wx/models/ModelsGenericActivity.kt | 37 +- .../wx/models/ModelsSPCHREFActivity.kt | 30 +- .../wx/models/ModelsSPCHRRRActivity.kt | 29 +- .../wx/models/ModelsSPCSREFActivity.kt | 22 +- .../wx/models/UtilityModelSPCHREFInterface.kt | 60 +- .../java/joshuatee/wx/models/UtilityModels.kt | 13 +- .../main/java/joshuatee/wx/nhc/NHCActivity.kt | 6 +- .../java/joshuatee/wx/nhc/NHCStormActivity.kt | 32 +- .../wx/nhc/ObjectCardNhcStormReportItem.kt | 15 +- .../main/java/joshuatee/wx/nhc/ObjectNHC.kt | 23 +- .../wx/notifications/UtilityNotification.kt | 24 +- .../notifications/UtilityNotificationSPC.kt | 15 +- .../UtilityNotificationSpcFireWeather.kt | 9 +- .../notifications/UtilityNotificationWPC.kt | 7 +- .../wx/objects/ObjectPolygonWatch.kt | 1 - .../wx/radar/AwcRadarMosaicActivity.kt | 22 +- app/src/main/java/joshuatee/wx/radar/Hail.kt | 12 +- .../joshuatee/wx/radar/ObjectOglBuffers.kt | 1 + .../wx/radar/RadarMosaicNwsActivity.kt | 28 +- .../java/joshuatee/wx/radar/UtilityHail.kt | 67 +++ .../java/joshuatee/wx/radar/UtilityRadarUI.kt | 13 +- .../joshuatee/wx/radar/UtilityUserPoints.kt | 15 +- .../joshuatee/wx/radar/UtilityWXOGLPerf.kt | 4 +- .../wx/radar/WXGLNexradLevel3HailIndex.kt | 91 ++- .../joshuatee/wx/radar/WXGLRadarActivity.kt | 37 +- .../wx/radar/WXGLRadarActivityMultiPane.kt | 26 +- .../java/joshuatee/wx/radar/WXGLRender.kt | 67 ++- .../java/joshuatee/wx/radar/WXGLTextObject.kt | 80 +-- .../wx/settings/ArrayAdapterSearchView.kt | 20 +- .../wx/settings/BottomSheetFragment.kt | 13 +- .../wx/settings/FavRemoveActivity.kt | 4 +- .../java/joshuatee/wx/settings/Location.kt | 530 +++++++----------- .../joshuatee/wx/settings/ObjectLocation.kt | 79 ++- .../wx/settings/ObjectSettingsCheckBox.kt | 32 +- .../wx/settings/ObjectSettingsColorLabel.kt | 3 +- .../wx/settings/ObjectSettingsSeekbar.kt | 24 +- .../wx/settings/ObjectSettingsSpinner.kt | 23 +- .../wx/settings/SettingsAboutActivity.kt | 16 +- .../wx/settings/SettingsColorPaletteEditor.kt | 12 +- .../SettingsColorPaletteListingActivity.kt | 6 +- .../settings/SettingsColorPickerActivity.kt | 6 +- .../wx/settings/SettingsColorsActivity.kt | 8 +- .../SettingsLocationCanadaMapActivity.kt | 10 +- .../SettingsLocationGenericActivity.kt | 19 +- .../SettingsLocationRecyclerViewActivity.kt | 29 +- .../wx/settings/SettingsMainActivity.kt | 21 +- .../wx/settings/SettingsNavDrawerActivity.kt | 6 +- .../settings/SettingsNotificationsActivity.kt | 180 +++--- .../wx/settings/SettingsRadarActivity.kt | 152 +++-- .../wx/settings/SettingsUIActivity.kt | 88 +-- .../wx/settings/SettingsWidgetsActivity.kt | 26 +- .../wx/settings/TileObjectColorPalette.kt | 2 +- .../joshuatee/wx/settings/UtilityLocation.kt | 15 +- .../java/joshuatee/wx/spc/LSRbyWFOActivity.kt | 12 +- .../joshuatee/wx/spc/SPCCompmapActivity.kt | 29 +- .../wx/spc/SPCFireOutlookActivity.kt | 22 +- .../java/joshuatee/wx/spc/SPCMesoActivity.kt | 56 +- .../java/joshuatee/wx/spc/SPCSWOActivity.kt | 30 +- .../wx/spc/SPCSWOStateGraphicsActivity.kt | 12 +- .../joshuatee/wx/spc/SPCSWOSummaryActivity.kt | 6 +- .../joshuatee/wx/spc/SPCSoundingsActivity.kt | 24 +- .../wx/spc/SPCStormReportsActivity.kt | 33 +- .../wx/spc/SpcFireOutlookSummaryActivity.kt | 6 +- .../wx/spc/SpcMcdWatchShowActivity.kt | 22 +- .../wx/spc/SpcMcdWatchShowSummaryActivity.kt | 14 +- .../wx/spc/SpcThunderStormOutlookActivity.kt | 8 +- .../wx/telecine/SettingsTelecineActivity.kt | 8 +- .../wx/ui/{ObjectLinearLayout.kt => HBox.kt} | 41 +- .../joshuatee/wx/ui/ObjectAlertSummary.kt | 32 +- .../main/java/joshuatee/wx/ui/ObjectButton.kt | 4 + .../java/joshuatee/wx/ui/ObjectCALegal.kt | 14 +- .../joshuatee/wx/ui/ObjectCanadaWarnings.kt | 1 - .../main/java/joshuatee/wx/ui/ObjectCard.kt | 16 +- .../java/joshuatee/wx/ui/ObjectCard7Day.kt | 17 +- ...ummaryItem.kt => ObjectCardAlertDetail.kt} | 38 +- .../wx/ui/ObjectCardBlackHeaderText.kt | 22 +- .../wx/ui/ObjectCardCurrentConditions.kt | 20 +- .../wx/ui/ObjectCardDashAlertItem.kt | 30 +- .../java/joshuatee/wx/ui/ObjectCardHSText.kt | 16 +- .../java/joshuatee/wx/ui/ObjectCardImage.kt | 4 +- .../wx/ui/ObjectCardStormReportItem.kt | 12 +- .../java/joshuatee/wx/ui/ObjectCardText.kt | 17 +- .../joshuatee/wx/ui/ObjectCardVerticalText.kt | 28 +- .../java/joshuatee/wx/ui/ObjectImageMap.kt | 17 +- .../joshuatee/wx/ui/ObjectImageSummary.kt | 14 +- .../java/joshuatee/wx/ui/ObjectNavDrawer.kt | 34 +- .../joshuatee/wx/ui/ObjectNavDrawerCombo.kt | 30 +- .../joshuatee/wx/ui/ObjectRecyclerView.kt | 20 +- .../wx/ui/ObjectRecyclerViewGeneric.kt | 8 +- .../java/joshuatee/wx/ui/ObjectTextView.kt | 38 +- .../joshuatee/wx/ui/SingleTextAdapterList.kt | 16 +- ...{ObjectTouchImageView.kt => TouchImage.kt} | 34 +- .../main/java/joshuatee/wx/ui/UtilityTheme.kt | 2 +- .../java/joshuatee/wx/ui/UtilityToolbar.kt | 4 +- app/src/main/java/joshuatee/wx/ui/VBox.kt | 112 ++++ .../joshuatee/wx/util/UtilityFavorites.kt | 4 +- .../main/java/joshuatee/wx/util/UtilityImg.kt | 5 +- .../java/joshuatee/wx/util/UtilityImgAnim.kt | 4 +- .../main/java/joshuatee/wx/util/UtilityUS.kt | 3 +- .../java/joshuatee/wx/vis/GoesActivity.kt | 42 +- .../joshuatee/wx/wpc/WPCImagesActivity.kt | 95 ++-- .../wx/wpc/WPCRainfallForecastActivity.kt | 24 +- .../wx/wpc/WPCTextProductsActivity.kt | 32 +- .../wpc/WpcRainfallForecastSummaryActivity.kt | 6 +- app/src/main/res/drawable/hailunknown.png | Bin 0 -> 2943 bytes doc/ChangeLog.md | 42 +- 132 files changed, 1912 insertions(+), 1759 deletions(-) create mode 100644 app/src/main/java/joshuatee/wx/radar/UtilityHail.kt rename app/src/main/java/joshuatee/wx/ui/{ObjectLinearLayout.kt => HBox.kt} (68%) rename app/src/main/java/joshuatee/wx/ui/{ObjectCardAlertSummaryItem.kt => ObjectCardAlertDetail.kt} (68%) rename app/src/main/java/joshuatee/wx/ui/{ObjectTouchImageView.kt => TouchImage.kt} (86%) create mode 100644 app/src/main/java/joshuatee/wx/ui/VBox.kt create mode 100644 app/src/main/res/drawable/hailunknown.png diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 00e42850..ee4e04ef 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 7e6b3d6f..edcbb0d3 100644 --- a/app/src/main/java/joshuatee/wx/Extensions.kt +++ b/app/src/main/java/joshuatee/wx/Extensions.kt @@ -24,7 +24,7 @@ package joshuatee.wx.Extensions import android.graphics.drawable.AnimationDrawable import android.view.View import java.util.regex.Pattern -import joshuatee.wx.ui.ObjectTouchImageView +import joshuatee.wx.ui.TouchImage import joshuatee.wx.ui.TouchImageView2 import joshuatee.wx.util.* @@ -88,4 +88,4 @@ fun Int.isEven() = this and 1 == 0 fun AnimationDrawable.startAnimation(img: TouchImageView2) = UtilityImgAnim.startAnimation(this, img) -fun AnimationDrawable.startAnimation(img: ObjectTouchImageView) = UtilityImgAnim.startAnimation(this, img) +fun AnimationDrawable.startAnimation(img: TouchImage) = UtilityImgAnim.startAnimation(this, img) diff --git a/app/src/main/java/joshuatee/wx/MyApplication.kt b/app/src/main/java/joshuatee/wx/MyApplication.kt index b352d502..5603c437 100644 --- a/app/src/main/java/joshuatee/wx/MyApplication.kt +++ b/app/src/main/java/joshuatee/wx/MyApplication.kt @@ -99,8 +99,6 @@ class MyApplication : Application() { lateinit var appContext: Context var contentResolverLocal: ContentResolver? = null - val locations = mutableListOf() - fun initPreferences(context: Context) { RadarPreferences.initRadarPreferences() UIPreferences.initPreferences(context) diff --git a/app/src/main/java/joshuatee/wx/StartupActivity.kt b/app/src/main/java/joshuatee/wx/StartupActivity.kt index db4f2f07..79547fdb 100644 --- a/app/src/main/java/joshuatee/wx/StartupActivity.kt +++ b/app/src/main/java/joshuatee/wx/StartupActivity.kt @@ -109,7 +109,7 @@ class StartupActivity : Activity(), ActivityCompat.OnRequestPermissionsResultCal checkfiles(R.drawable.location, "location.png") checkfiles(R.drawable.tvs, "tvs.png") checkfiles(R.drawable.userpoint, "userpoint.png") - + checkfiles(R.drawable.hailunknown, "hailunknown.png") checkfiles(R.drawable.hail05, "hail05.png") checkfiles(R.drawable.hail0, "hail0.png") checkfiles(R.drawable.hail1, "hail1.png") diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/CAPAlert.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/CAPAlert.kt index 32a04335..a1c0ddf2 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/CAPAlert.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/CAPAlert.kt @@ -27,6 +27,8 @@ import joshuatee.wx.common.GlobalVariables import joshuatee.wx.common.RegExp import joshuatee.wx.settings.UIPreferences import joshuatee.wx.objects.ObjectWarning +import joshuatee.wx.radar.LatLon +import joshuatee.wx.settings.UtilityLocation import joshuatee.wx.util.UtilityString class CapAlert { @@ -57,11 +59,30 @@ class CapAlert { private var tornadoThreat = "" var motion = "" var extended = "" + // used for XML + private var polygon = "" fun getClosestRadar(): String { return ObjectWarning.getClosestRadarCompute(points) } + fun getClosestRadarXml(): String { + if (points.size > 2) { + val latTmp = points[0] + val list1 = latTmp.split(",") + val lat = list1[0] + val lonTmp = points[0] + val list2 = lonTmp.split(",") + val lon = list2[1] + val radarSites = UtilityLocation.getNearestRadarSites(LatLon(lat, lon), 1, false) + if (radarSites.isEmpty()) { + return "" + } + return radarSites[0].name + } + return "" + } + companion object { // used by usAlerts @@ -78,6 +99,7 @@ class CapAlert { capAlert.event = eventText.parse("(.*?)") capAlert.vtec = eventText.parse("VTEC.*?(.*?)") capAlert.zones = eventText.parse("UGC.*?(.*?)") + capAlert.polygon = eventText.parse("(.*?)") capAlert.text = "" capAlert.text += capAlert.title capAlert.text += GlobalVariables.newline + GlobalVariables.newline @@ -91,6 +113,7 @@ class CapAlert { if (UIPreferences.nwsTextRemovelinebreaks) { capAlert.instructions = capAlert.instructions.replace("

", "

").replace("
", " ") } + capAlert.points = capAlert.polygon.split(" ") return capAlert } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/ForecastActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/ForecastActivity.kt index ac079184..57f16a55 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/ForecastActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/ForecastActivity.kt @@ -62,11 +62,11 @@ class ForecastActivity : BaseActivity() { private var currentConditionsTime = "" private var radarTime = "" private lateinit var objectCardCurrentConditions: ObjectCardCurrentConditions - private lateinit var linearLayoutForecast: ObjectLinearLayout - private lateinit var linearLayoutHazards: ObjectLinearLayout + private lateinit var linearLayoutForecast: VBox + private lateinit var linearLayoutHazards: VBox private val hazardCards = mutableListOf() private lateinit var scrollView: ScrollView - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private var bitmapForCurrentCondition = UtilityImg.getBlankBitmap() private var bitmaps = listOf() @@ -79,15 +79,15 @@ class ForecastActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, null, false) scrollView = findViewById(R.id.scrollView) - linearLayout = findViewById(R.id.linearLayout) - val activityArguments = intent.getStringArrayExtra(URL)!! - latLon = LatLon(activityArguments[0], activityArguments[1]) + box = findViewById(R.id.linearLayout) + val arguments = intent.getStringArrayExtra(URL)!! + latLon = LatLon(arguments[0], arguments[1]) title = "Forecast for" toolbar.subtitle = latLon.latString + "," + latLon.lonString objectCardCurrentConditions = ObjectCardCurrentConditions(this, 2) - linearLayout.addView(objectCardCurrentConditions.get()) - linearLayoutHazards = ObjectLinearLayout(this, linearLayout) - linearLayoutForecast = ObjectLinearLayout(this, linearLayout) + box.addView(objectCardCurrentConditions.get()) + linearLayoutHazards = VBox(this, box) + linearLayoutForecast = VBox(this, box) getContent() } @@ -137,13 +137,13 @@ class ForecastActivity : BaseActivity() { bitmaps.forEachIndexed { index, bitmap -> val objectCard7Day = ObjectCard7Day(this, bitmap, true, index, objectSevenDay.forecastList) objectCard7Day.setOnClickListener { scrollView.smoothScrollTo(0, 0) } - linearLayoutForecast.addView(objectCard7Day.get()) + linearLayoutForecast.addWidget(objectCard7Day.get()) } // sunrise card val objectCardText = ObjectCardText(this) objectCardText.center() objectCardText.text = (UtilityTimeSunMoon.getSunriseSunset(this, Location.currentLocationStr, false) + GlobalVariables.newline + UtilityTime.gmtTime()) - linearLayoutForecast.addView(objectCardText.get()) + linearLayoutForecast.addWidget(objectCardText.get()) } private fun setupHazardCards() { @@ -154,7 +154,7 @@ class ForecastActivity : BaseActivity() { hazardCards[z].setupHazard() hazardCards[z].text = objectHazards.titles[z].uppercase(Locale.US) hazardCards[z].setOnClickListener { ObjectIntent.showHazard(this, arrayOf(objectHazards.urls[z])) } - linearLayoutHazards.addView(hazardCards[z].get()) + linearLayoutHazards.addWidget(hazardCards[z].get()) } } @@ -168,6 +168,6 @@ class ForecastActivity : BaseActivity() { private fun saveLocation() { val message = Location.save(this, latLon) - ObjectPopupMessage(linearLayout, message) + ObjectPopupMessage(box, message) } } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/HourlyActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/HourlyActivity.kt index 85b6ad7b..62ee0796 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/HourlyActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/HourlyActivity.kt @@ -59,7 +59,7 @@ class HourlyActivity : BaseActivity() { private lateinit var objectCard: ObjectCard private lateinit var objectCardVerticalText: ObjectCardVerticalText private lateinit var scrollView: ScrollView - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private lateinit var graphCard: CardView private lateinit var graph: GraphView private var hourlyData = ObjectHourly() @@ -74,13 +74,13 @@ class HourlyActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_hourly, R.menu.shared_multigraphics, false) scrollView = findViewById(R.id.scrollView) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) graphCard = findViewById(R.id.graphCard) graph = findViewById(R.id.graph) locationNumber = (intent.getStringExtra(LOC_NUM)!!.toIntOrNull() ?: 0) - 1 objectCard = ObjectCard(this, R.color.black, R.id.graphCard) graphCard.visibility = View.GONE - objectCardVerticalText = ObjectCardVerticalText(this, 5, linearLayout, toolbar) + objectCardVerticalText = ObjectCardVerticalText(this, 5, box, toolbar) objectCardVerticalText.setOnClickListener { scrollView.scrollTo(0, 0) } title = "Hourly Forecast" toolbar.subtitle = Location.getName(locationNumber) diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/ImageCollectionActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/ImageCollectionActivity.kt index 43212f76..aec10964 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/ImageCollectionActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/ImageCollectionActivity.kt @@ -34,7 +34,7 @@ import joshuatee.wx.objects.FutureVoid import joshuatee.wx.radar.VideoRecordActivity import joshuatee.wx.ui.ObjectImagesCollection import joshuatee.wx.ui.ObjectNavDrawer -import joshuatee.wx.ui.ObjectTouchImageView +import joshuatee.wx.ui.TouchImage import joshuatee.wx.util.Utility import joshuatee.wx.util.UtilityImg import joshuatee.wx.util.UtilityImgAnim @@ -44,13 +44,13 @@ import joshuatee.wx.vis.UtilityGoesFullDisk class ImageCollectionActivity : VideoRecordActivity() { // - // used for OPC, GOES Full Disk, other? + // used for OPC, GOES Full Disk, Observations // companion object { const val TYPE = "" } private var bitmap = UtilityImg.getBlankBitmap() - private lateinit var img: ObjectTouchImageView + private lateinit var image: TouchImage private lateinit var objectNavDrawer: ObjectNavDrawer private lateinit var imageCollection: ObjectImagesCollection private var animDrawable = AnimationDrawable() @@ -72,12 +72,12 @@ class ImageCollectionActivity : VideoRecordActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_image_show_navdrawer, R.menu.imagecollection, iconsEvenlySpaced = true, bottomToolbar = false) - val activityArguments = intent.getStringArrayExtra(TYPE)!! - imageCollection = ObjectImagesCollection.imageCollectionMap[activityArguments[0]]!! + val arguments = intent.getStringArrayExtra(TYPE)!! + imageCollection = ObjectImagesCollection.imageCollectionMap[arguments[0]]!! title = imageCollection.title objectNavDrawer = ObjectNavDrawer(this, imageCollection.labels, imageCollection.urls, ::getContent) - img = ObjectTouchImageView(this, toolbar, R.id.iv, objectNavDrawer, imageCollection.prefTokenIdx) - img.setListener(objectNavDrawer, ::getContent) + image = TouchImage(this, toolbar, R.id.iv, objectNavDrawer, imageCollection.prefTokenIdx) + image.setListener(objectNavDrawer, ::getContent) objectNavDrawer.index = Utility.readPref(this, imageCollection.prefTokenIdx, 0) toolbar.setOnClickListener { objectNavDrawer.open() } getContent() @@ -95,27 +95,27 @@ class ImageCollectionActivity : VideoRecordActivity() { private fun showImage() { if (objectNavDrawer.url.contains("large_latestsfc.gif")) { - img.setMaxZoom(16.0f) + image.setMaxZoom(16.0f) } else { - img.setMaxZoom(4.0f) + image.setMaxZoom(4.0f) } - img.setBitmap(bitmap) - img.firstRunSetZoomPosn(imageCollection.prefImagePosition) + image.setBitmap(bitmap) + image.firstRunSetZoomPosn(imageCollection.prefImagePosition) invalidateOptionsMenu() } override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - objectNavDrawer.actionBarDrawerToggle.syncState() + objectNavDrawer.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - objectNavDrawer.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawer.onConfigurationChanged(newConfig) } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawer.onOptionsItemSelected(item)) { return true } when (item.itemId) { @@ -133,13 +133,13 @@ class ImageCollectionActivity : VideoRecordActivity() { } override fun onStop() { - img.imgSavePosnZoom(imageCollection.prefImagePosition) + image.imgSavePosnZoom(imageCollection.prefImagePosition) super.onStop() } private fun getAnimate() { FutureVoid(this, { animDrawable = UtilityGoesFullDisk.getAnimation(this, objectNavDrawer.url) }) - { UtilityImgAnim.startAnimation(animDrawable, img) } + { UtilityImgAnim.startAnimation(animDrawable, image) } } } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/ImageShowActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/ImageShowActivity.kt index 700bc8de..5dbd67a2 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/ImageShowActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/ImageShowActivity.kt @@ -30,7 +30,7 @@ import joshuatee.wx.Extensions.getImage import joshuatee.wx.R import joshuatee.wx.objects.FutureVoid import joshuatee.wx.ui.BaseActivity -import joshuatee.wx.ui.ObjectTouchImageView +import joshuatee.wx.ui.TouchImage import joshuatee.wx.util.UtilityIO import joshuatee.wx.util.UtilityImg import joshuatee.wx.util.UtilityShare @@ -53,7 +53,7 @@ class ImageShowActivity : BaseActivity() { private var bitmap = UtilityImg.getBlankBitmap() private var shareTitle = "" private var needsWhiteBackground = false - private lateinit var img: ObjectTouchImageView + private lateinit var image: TouchImage override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.image_show_activity, menu) @@ -63,14 +63,14 @@ class ImageShowActivity : BaseActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_image_show, R.menu.image_show_activity, false) - img = ObjectTouchImageView(this, toolbar, R.id.iv) - val activityArguments: Array = intent.getStringArrayExtra(URL)!! - url = activityArguments[0] + image = TouchImage(this, toolbar, R.id.iv) + val arguments = intent.getStringArrayExtra(URL)!! + url = arguments[0] title = "Image Viewer" - toolbar.subtitle = activityArguments[1] - shareTitle = activityArguments[1] - if (activityArguments.size > 2) { - needsWhiteBackground = activityArguments[2] == "true" + toolbar.subtitle = arguments[1] + shareTitle = arguments[1] + if (arguments.size > 2) { + needsWhiteBackground = arguments[2] == "true" } when { url.contains("file:") -> { @@ -87,7 +87,7 @@ class ImageShowActivity : BaseActivity() { private fun loadRawBitmap() { bitmap = UtilityImg.loadBitmap(this, R.drawable.radar_legend, false) - img.setBitmap(bitmap) + image.setBitmap(bitmap) } override fun onRestart() { @@ -103,11 +103,11 @@ class ImageShowActivity : BaseActivity() { if (needsWhiteBackground) { bitmap = UtilityImg.addColorBackground(this, bitmap, Color.WHITE) } - img.setBitmap(bitmap) + image.setBitmap(bitmap) } private fun getContentFromStorage() { - img.setBitmap(UtilityIO.bitmapFromInternalStorage(this, urls[1])) + image.setBitmap(UtilityIO.bitmapFromInternalStorage(this, urls[1])) } override fun onOptionsItemSelected(item: MenuItem): Boolean { diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/LightningActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/LightningActivity.kt index f0cecbe7..657930f4 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/LightningActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/LightningActivity.kt @@ -31,7 +31,7 @@ import joshuatee.wx.settings.UIPreferences import joshuatee.wx.objects.FutureVoid import joshuatee.wx.radar.VideoRecordActivity import joshuatee.wx.ui.ObjectNavDrawer -import joshuatee.wx.ui.ObjectTouchImageView +import joshuatee.wx.ui.TouchImage import joshuatee.wx.util.Utility import joshuatee.wx.util.UtilityImg import joshuatee.wx.util.UtilityShare @@ -45,7 +45,7 @@ class LightningActivity : VideoRecordActivity() { private var bitmap = UtilityImg.getBlankBitmap() private var period = "0.25" private var periodPretty = "15 MIN" - private lateinit var img: ObjectTouchImageView + private lateinit var image: TouchImage private lateinit var objectNavDrawer: ObjectNavDrawer private val prefTokenIdx = "LIGHTNING_SECTOR_IDX" @@ -58,7 +58,7 @@ class LightningActivity : VideoRecordActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_image_show_navdrawer, R.menu.lightning_activity, iconsEvenlySpaced = true, bottomToolbar = false) objectNavDrawer = ObjectNavDrawer(this, UtilityLightning.labels, UtilityLightning.urls, ::getContent) - img = ObjectTouchImageView(this, toolbar, toolbarBottom, R.id.iv, objectNavDrawer, prefTokenIdx) + image = TouchImage(this, toolbar, toolbarBottom, R.id.iv, objectNavDrawer, prefTokenIdx) objectNavDrawer.index = Utility.readPref(this, prefTokenIdx, 0) period = Utility.readPref(this, "LIGHTNING_PERIOD", period) periodPretty = UtilityLightning.getTimePretty(period) @@ -77,23 +77,25 @@ class LightningActivity : VideoRecordActivity() { } private fun showImage() { - img.setBitmap(bitmap) - img.firstRunSetZoomPosn("LIGHTNING") + image.setBitmap(bitmap) + image.firstRunSetZoomPosn("LIGHTNING") Utility.writePref(this@LightningActivity, "LIGHTNING_PERIOD", period) } override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - objectNavDrawer.actionBarDrawerToggle.syncState() + objectNavDrawer.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - objectNavDrawer.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawer.onConfigurationChanged(newConfig) } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) return true + if (objectNavDrawer.onOptionsItemSelected(item)) { + return true + } when (item.itemId) { R.id.action_share -> { if (UIPreferences.recordScreenShare) { @@ -119,7 +121,7 @@ class LightningActivity : VideoRecordActivity() { } override fun onStop() { - img.imgSavePosnZoom("LIGHTNING") + image.imgSavePosnZoom("LIGHTNING") super.onStop() } } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/SevereDashboardActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/SevereDashboardActivity.kt index 2cd56921..247928fb 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/SevereDashboardActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/SevereDashboardActivity.kt @@ -46,11 +46,11 @@ class SevereDashboardActivity : BaseActivity() { private val bitmaps = mutableListOf() private var numberOfImages = 0 - private val horizontalLinearLayouts = mutableListOf() + private val boxRows = mutableListOf() private var imagesPerRow = 2 - private lateinit var linearLayout: LinearLayout - private lateinit var linearLayoutWatches: ObjectLinearLayout - private lateinit var linearLayoutWarnings: ObjectLinearLayout + private lateinit var box: LinearLayout + private lateinit var boxImages: VBox + private lateinit var boxWarnings: VBox private val watchesByType = mapOf( PolygonType.WATCH to SevereNotice(PolygonType.WATCH), PolygonType.MCD to SevereNotice(PolygonType.MCD), @@ -71,9 +71,9 @@ class SevereDashboardActivity : BaseActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, null, false) - linearLayout = findViewById(R.id.linearLayout) - linearLayoutWatches = ObjectLinearLayout(this, linearLayout) - linearLayoutWarnings = ObjectLinearLayout(this, linearLayout) + box = findViewById(R.id.linearLayout) + boxImages = VBox(this, box) + boxWarnings = VBox(this, box) if (UtilityUI.isLandScape(this)) { imagesPerRow = 3 } @@ -111,18 +111,16 @@ class SevereDashboardActivity : BaseActivity() { } private fun updateWatch() { - linearLayoutWatches.removeAllViews() - horizontalLinearLayouts.clear() + boxImages.removeAllViews() + boxRows.clear() numberOfImages = 0 listOf(0, 1).forEach { - val card: ObjectCardImage - if (numberOfImages % imagesPerRow == 0) { - val objectLinearLayout = ObjectLinearLayout(this, linearLayoutWatches.linearLayout) - objectLinearLayout.linearLayout.orientation = LinearLayout.HORIZONTAL - horizontalLinearLayouts.add(objectLinearLayout) - card = ObjectCardImage(this, objectLinearLayout.get(), bitmaps[it], imagesPerRow) + val card = if (numberOfImages % imagesPerRow == 0) { + val hbox = HBox(this, boxImages.get()) + boxRows.add(hbox) + ObjectCardImage(this, hbox.get(), bitmaps[it], imagesPerRow) } else { - card = ObjectCardImage(this, horizontalLinearLayouts.last().get(), bitmaps[it], imagesPerRow) + ObjectCardImage(this, boxRows.last().get(), bitmaps[it], imagesPerRow) } if (it == 0) { card.setOnClickListener { ObjectIntent.showUsAlerts(this) } @@ -142,22 +140,15 @@ class SevereDashboardActivity : BaseActivity() { } private fun updateWarnings() { - linearLayoutWarnings.removeAllViews() - var numberOfWarnings = 0 + boxWarnings.removeAllViews() listOf(PolygonType.TOR, PolygonType.TST, PolygonType.FFW).forEach { val severeWarning = warningsByType[it]!! if (severeWarning.getCount() > 0) { - ObjectCardBlackHeaderText(this, linearLayoutWarnings.get(), "(" + severeWarning.getCount() + ") " + severeWarning.getName()) + ObjectCardBlackHeaderText(this, boxWarnings.get(), "(" + severeWarning.getCount() + ") " + severeWarning.getName()) severeWarning.warningList.forEach { w -> if (w.isCurrent) { - val objectCardDashAlertItem = ObjectCardDashAlertItem(this, linearLayoutWarnings.get(), w) - objectCardDashAlertItem.setListener { showWarningDetails(w.url) } - objectCardDashAlertItem.radarButton.setOnClickListener { - ObjectIntent.showRadarBySite(this, w.getClosestRadar()) - } - objectCardDashAlertItem.detailsButton.setOnClickListener { showWarningDetails(w.url) } - objectCardDashAlertItem.setId(numberOfWarnings) - numberOfWarnings += 1 + val objectCardDashAlertItem = ObjectCardDashAlertItem(this, boxWarnings.get(), w) + objectCardDashAlertItem.setListener { ObjectIntent.showHazard(this, arrayOf(w.url, "")) } } } } @@ -187,14 +178,12 @@ class SevereDashboardActivity : BaseActivity() { private fun showItems(sn: SevereNotice) { sn.bitmaps.indices.forEach { j -> - val card: ObjectCardImage - if (numberOfImages % imagesPerRow == 0) { - val objectLinearLayout = ObjectLinearLayout(this, linearLayoutWatches.get()) - objectLinearLayout.linearLayout.orientation = LinearLayout.HORIZONTAL - horizontalLinearLayouts.add(objectLinearLayout) - card = ObjectCardImage(this, objectLinearLayout.linearLayout, sn.bitmaps[j], imagesPerRow) + val card = if (numberOfImages % imagesPerRow == 0) { + val hbox = HBox(this, boxImages.get()) + boxRows.add(hbox) + ObjectCardImage(this, hbox.get(), sn.bitmaps[j], imagesPerRow) } else { - card = ObjectCardImage(this, horizontalLinearLayouts.last().get(), sn.bitmaps[j], imagesPerRow) + ObjectCardImage(this, boxRows.last().get(), sn.bitmaps[j], imagesPerRow) } if (j < sn.numbers.size) { val number = sn.numbers[j] @@ -214,8 +203,4 @@ class SevereDashboardActivity : BaseActivity() { } return true } - - private fun showWarningDetails(url: String) { - ObjectIntent.showHazard(this, arrayOf(url, "")) - } } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/SpotterReportsActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/SpotterReportsActivity.kt index 1574f986..2fb8af78 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/SpotterReportsActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/SpotterReportsActivity.kt @@ -45,7 +45,7 @@ class SpotterReportsActivity : BaseActivity() { super.onCreate(savedInstanceState, R.layout.activity_recyclerview_toolbar, null, false) objectRecyclerViewGeneric = ObjectRecyclerViewGeneric(this, R.id.card_list) val adapterSpotterReports = AdapterSpotterReports(UtilitySpotter.reports) - objectRecyclerViewGeneric.recyclerView.adapter = adapterSpotterReports + objectRecyclerViewGeneric.adapter = adapterSpotterReports updateTitles() adapterSpotterReports.setOnItemClickListener(object : AdapterSpotterReports.MyClickListener { override fun onItemClick(position: Int) { itemSelected(position) } @@ -53,7 +53,7 @@ class SpotterReportsActivity : BaseActivity() { } override fun onRestart() { - objectRecyclerViewGeneric.recyclerView.adapter = AdapterSpotterReports(UtilitySpotter.reports) + objectRecyclerViewGeneric.adapter = AdapterSpotterReports(UtilitySpotter.reports) updateTitles() super.onRestart() } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/SpottersActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/SpottersActivity.kt index c531788b..d063917b 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/SpottersActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/SpottersActivity.kt @@ -105,7 +105,7 @@ class SpottersActivity : BaseActivity() { private fun showText() { markFavorites() adapter = AdapterSpotter(spotterList) - recyclerView.recyclerView.adapter = adapter + recyclerView.adapter = adapter title = spotterList.size.toString() + " " + titleString adapter.setListener(::itemClicked) } @@ -116,7 +116,9 @@ class SpottersActivity : BaseActivity() { if (view is TextView) { view.setTextColor(Color.WHITE) } else if (view is ViewGroup) { - (0 until view.childCount).forEach { changeSearchViewTextColor(view.getChildAt(it)) } + (0 until view.childCount).forEach { + changeSearchViewTextColor(view.getChildAt(it)) + } } } } diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/TextScreenActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/TextScreenActivity.kt index 9478c7ce..0b9366e8 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/TextScreenActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/TextScreenActivity.kt @@ -46,22 +46,22 @@ class TextScreenActivity : AudioPlayActivity(), OnMenuItemClickListener { companion object { const val URL = "" } - private lateinit var activityArguments: Array + private lateinit var arguments: Array private var url = "" private var html = "" private lateinit var textCard: ObjectCardText - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout_bottom_toolbar, R.menu.shared_tts) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) toolbarBottom.menu.findItem(R.id.action_playlist).isVisible = false toolbarBottom.setOnMenuItemClickListener(this) - activityArguments = intent.getStringArrayExtra(URL)!! - url = activityArguments[0] - title = activityArguments[1] - textCard = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) + arguments = intent.getStringArrayExtra(URL)!! + url = arguments[0] + title = arguments[1] + textCard = ObjectCardText(this, box, toolbar, toolbarBottom) if (!url.startsWith("http")) { if (url.contains("<")) textCard.text = Utility.fromHtml(url) else textCard.text = url html = url @@ -87,7 +87,7 @@ class TextScreenActivity : AudioPlayActivity(), OnMenuItemClickListener { fun update() { textCard.setTextAndTranslate(Utility.fromHtml(html)) - UtilityTts.conditionalPlay(activityArguments, 2, applicationContext, html, "textscreen") + UtilityTts.conditionalPlay(arguments, 2, applicationContext, html, "textscreen") } override fun onMenuItemClick(item: MenuItem): Boolean { @@ -96,7 +96,7 @@ class TextScreenActivity : AudioPlayActivity(), OnMenuItemClickListener { return true } when (item.itemId) { - R.id.action_share -> UtilityShare.text(this, activityArguments[1], textToShare) + R.id.action_share -> UtilityShare.text(this, arguments[1], textToShare) else -> return super.onOptionsItemSelected(item) } return true diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/USAlertsDetailActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/USAlertsDetailActivity.kt index 06a4cbb0..de0f4a50 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/USAlertsDetailActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/USAlertsDetailActivity.kt @@ -41,23 +41,23 @@ class USAlertsDetailActivity : AudioPlayActivity(), OnMenuItemClickListener { companion object { const val URL = "" } - private lateinit var activityArguments: Array + private lateinit var arguments: Array private var capAlert = CapAlert() private lateinit var objectAlertDetail: ObjectAlertDetail - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private lateinit var radarIcon: MenuItem private var radarSite = "" @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_usalertsdetail, R.menu.usalerts_detail) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) ObjectCard(this, R.id.cardView) toolbarBottom.menu.findItem(R.id.action_playlist).isVisible = false radarIcon = toolbarBottom.menu.findItem(R.id.action_radar) toolbarBottom.setOnMenuItemClickListener(this) - objectAlertDetail = ObjectAlertDetail(this, linearLayout) - activityArguments = intent.getStringArrayExtra(URL)!! + objectAlertDetail = ObjectAlertDetail(this, box) + arguments = intent.getStringArrayExtra(URL)!! getContent() } @@ -67,7 +67,7 @@ class USAlertsDetailActivity : AudioPlayActivity(), OnMenuItemClickListener { } private fun getContent() { - FutureVoid(this, { capAlert = CapAlert.createFromUrl(activityArguments[0]) }, ::update) + FutureVoid(this, { capAlert = CapAlert.createFromUrl(arguments[0]) }, ::update) } private fun update() { @@ -75,10 +75,10 @@ class USAlertsDetailActivity : AudioPlayActivity(), OnMenuItemClickListener { if (radarSite == "") { radarIcon.isVisible = false } - objectAlertDetail.updateContent(capAlert, activityArguments[0]) + objectAlertDetail.updateContent(capAlert, arguments[0]) toolbar.subtitle = objectAlertDetail.wfoTitle title = objectAlertDetail.title - UtilityTts.conditionalPlay(activityArguments, 1, applicationContext, Utility.fromHtml(capAlert.text), "alert") + UtilityTts.conditionalPlay(arguments, 1, applicationContext, Utility.fromHtml(capAlert.text), "alert") } override fun onMenuItemClick(item: MenuItem): Boolean { diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/USWarningsWithRadarActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/USWarningsWithRadarActivity.kt index c8f6273a..59082fc2 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/USWarningsWithRadarActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/USWarningsWithRadarActivity.kt @@ -25,7 +25,6 @@ import android.annotation.SuppressLint import android.content.res.Configuration import android.os.Bundle import android.view.Menu -import android.widget.AdapterView import java.util.Locale import android.view.MenuItem import android.widget.LinearLayout @@ -62,7 +61,7 @@ class USWarningsWithRadarActivity : BaseActivity() { private lateinit var objectNavDrawer: ObjectNavDrawer private lateinit var objectAlertSummary: ObjectAlertSummary private lateinit var scrollView: ScrollView - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.uswarn, menu) @@ -73,15 +72,15 @@ class USWarningsWithRadarActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout_show_navdrawer, R.menu.uswarn, false) scrollView = findViewById(R.id.scrollView) - linearLayout = findViewById(R.id.linearLayout) - val activityArguments = intent.getStringArrayExtra(URL)!! - turlLocal[0] = activityArguments[0] - turlLocal[1] = activityArguments[1] - objectAlertSummary = ObjectAlertSummary(this, linearLayout, scrollView) + box = findViewById(R.id.linearLayout) + val arguments = intent.getStringArrayExtra(URL)!! + turlLocal[0] = arguments[0] + turlLocal[1] = arguments[1] + objectAlertSummary = ObjectAlertSummary(this, box, scrollView) objectNavDrawer = ObjectNavDrawer(this, objectAlertSummary.filterArray.toList()) - objectNavDrawer.listView.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ -> - objectNavDrawer.listView.setItemChecked(position, false) - objectNavDrawer.drawerLayout.closeDrawer(objectNavDrawer.listView) + objectNavDrawer.setListener2 { _, _, position, _ -> + objectNavDrawer.setItemChecked(position, false) + objectNavDrawer.close() if (objectAlertSummary.filterArray[position].length != 2) { turlLocal[0] = "^" + objectAlertSummary.filterArray[position] turlLocal[1] = "us" @@ -136,16 +135,16 @@ class USWarningsWithRadarActivity : BaseActivity() { override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - objectNavDrawer.actionBarDrawerToggle.syncState() + objectNavDrawer.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - objectNavDrawer.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawer.onConfigurationChanged(newConfig) } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawer.onOptionsItemSelected(item)) { return true } when (item.itemId) { diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/WebView.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/WebView.kt index fd5baeca..af5ce5d7 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/WebView.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/WebView.kt @@ -66,12 +66,12 @@ class WebView : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_webview_toolbar, null, false) webView = findViewById(R.id.webView) - val activityArguments = intent.getStringArrayExtra(URL)!! - url = activityArguments[0] - title = activityArguments[1] + val arguments = intent.getStringArrayExtra(URL)!! + url = arguments[0] + title = arguments[1] val webSettings = webView.settings webSettings.javaScriptEnabled = true - if (activityArguments.size > 2) { + if (arguments.size > 2) { webSettings.builtInZoomControls = true webSettings.displayZoomControls = false webSettings.useWideViewPort = true diff --git a/app/src/main/java/joshuatee/wx/activitiesmisc/WfoTextActivity.kt b/app/src/main/java/joshuatee/wx/activitiesmisc/WfoTextActivity.kt index b78f4a41..ea47120f 100644 --- a/app/src/main/java/joshuatee/wx/activitiesmisc/WfoTextActivity.kt +++ b/app/src/main/java/joshuatee/wx/activitiesmisc/WfoTextActivity.kt @@ -75,7 +75,7 @@ class WfoTextActivity : AudioPlayActivity(), OnMenuItemClickListener { companion object { const val URL = "" } private var firstTime = true - private lateinit var activityArguments: Array + private lateinit var arguments: Array private var product = "" private var wfo = "" private lateinit var imageMap: ObjectImageMap @@ -94,7 +94,7 @@ class WfoTextActivity : AudioPlayActivity(), OnMenuItemClickListener { private lateinit var objectCardText: ObjectCardText private lateinit var objectNavDrawer: ObjectNavDrawer private lateinit var scrollView: ScrollView - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private var originalWfo = "" private val fixedWidthProducts = listOf("RTP", "RWR", "CLI", "RVA") private var wfoProd = mutableListOf() @@ -113,25 +113,25 @@ class WfoTextActivity : AudioPlayActivity(), OnMenuItemClickListener { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_afd, R.menu.afd) scrollView = findViewById(R.id.scrollView) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) toolbarBottom.setOnMenuItemClickListener(this) objectNavDrawer = ObjectNavDrawer(this, UtilityWfoText.labels, UtilityWfoText.codes, ::getContentFixThis) UtilityShortcut.hidePinIfNeeded(toolbarBottom) - objectCardText = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) + objectCardText = ObjectCardText(this, box, toolbar, toolbarBottom) star = toolbarBottom.menu.findItem(R.id.action_fav) notificationToggle = toolbarBottom.menu.findItem(R.id.action_notif_text_prod) - activityArguments = intent.getStringArrayExtra(URL)!! - wfo = activityArguments[0] + arguments = intent.getStringArrayExtra(URL)!! + wfo = arguments[0] if (Utility.readPref(this, "WFO_REMEMBER_LOCATION", "") == "true") { wfo = Utility.readPref(this, "WFO_LAST_USED", Location.wfo) } if (wfo == "") { wfo = "OUN" } - product = if (activityArguments[1] == "") { + product = if (arguments[1] == "") { UIPreferences.wfoTextFav } else { - activityArguments[1] + arguments[1] } if (product.startsWith("RTP") && product.length == 5) { val state = Utility.getWfoSiteName(wfo).split(",")[0] @@ -201,7 +201,9 @@ class WfoTextActivity : AudioPlayActivity(), OnMenuItemClickListener { else -> product + wfo } toolbar.subtitle = UtilityWfoText.codeToName[product] - cardList.forEach { linearLayout.removeView(it) } + cardList.forEach { + box.removeView(it) + } objectCardText.visibility = View.VISIBLE scrollView.visibility = View.VISIBLE if (html == "") { @@ -213,8 +215,8 @@ class WfoTextActivity : AudioPlayActivity(), OnMenuItemClickListener { } else { objectCardText.typefaceDefault() } - UtilityTts.conditionalPlay(activityArguments, 2, applicationContext, html, product) - if (activityArguments[1] == "") { + UtilityTts.conditionalPlay(arguments, 2, applicationContext, html, product) + if (arguments[1] == "") { if (product.startsWith("RTP") && product.length == 5) { Utility.writePref(this, "WFO_TEXT_FAV", "RTPZZ") } else { @@ -243,7 +245,7 @@ class WfoTextActivity : AudioPlayActivity(), OnMenuItemClickListener { } R.id.action_fav -> toggleFavorite() R.id.action_notif_text_prod -> { - UtilityNotificationTextProduct.toggle(this, linearLayout, product + wfo) + UtilityNotificationTextProduct.toggle(this, box, product + wfo) updateSubmenuNotificationText() } R.id.action_prod_by_state -> { @@ -323,14 +325,14 @@ class WfoTextActivity : AudioPlayActivity(), OnMenuItemClickListener { objectCardText.visibility = View.GONE cardList.clear() wfoProd.forEach { - val textCard = ObjectCardText(this, linearLayout) + val textCard = ObjectCardText(this, box) textCard.setTextAndTranslate(it) cardList.add(textCard.get()) } } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawer.onOptionsItemSelected(item)) { return true } locationList = UtilityFavorites.setupMenu(this, UIPreferences.wfoFav, wfo, prefToken) @@ -378,13 +380,13 @@ class WfoTextActivity : AudioPlayActivity(), OnMenuItemClickListener { // For navigation drawer override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - objectNavDrawer.actionBarDrawerToggle.syncState() + objectNavDrawer.syncState() } // For navigation drawer override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - objectNavDrawer.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawer.onConfigurationChanged(newConfig) } override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean { @@ -396,7 +398,7 @@ class WfoTextActivity : AudioPlayActivity(), OnMenuItemClickListener { } KeyEvent.KEYCODE_D -> { if (event.isCtrlPressed) - objectNavDrawer.drawerLayout.openDrawer(GravityCompat.START) + objectNavDrawer.openGravity(GravityCompat.START) true } KeyEvent.KEYCODE_F -> { diff --git a/app/src/main/java/joshuatee/wx/audio/SettingsPlaylistActivity.kt b/app/src/main/java/joshuatee/wx/audio/SettingsPlaylistActivity.kt index f936fc14..38ecf190 100644 --- a/app/src/main/java/joshuatee/wx/audio/SettingsPlaylistActivity.kt +++ b/app/src/main/java/joshuatee/wx/audio/SettingsPlaylistActivity.kt @@ -105,7 +105,7 @@ class SettingsPlaylistActivity : BaseActivity(), OnMenuItemClickListener { updateList() val recyclerView = ObjectRecyclerViewGeneric(this, R.id.card_list) adapter = PlayListAdapter(playListItems) - recyclerView.recyclerView.adapter = adapter + recyclerView.adapter = adapter adapter.setListener(::itemSelected) UtilityTts.initTts(this) getContent() diff --git a/app/src/main/java/joshuatee/wx/audio/UtilityTTS.kt b/app/src/main/java/joshuatee/wx/audio/UtilityTTS.kt index 8791e089..c32d8174 100644 --- a/app/src/main/java/joshuatee/wx/audio/UtilityTTS.kt +++ b/app/src/main/java/joshuatee/wx/audio/UtilityTTS.kt @@ -62,7 +62,7 @@ object UtilityTts { } 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 + // samsung bug, if users do not have google TTS selected it will crash - add try-catch so user can at least use rest of program //if (!ttsInit) { try { ttobjGlobal = TextToSpeech(context) { status -> @@ -323,7 +323,7 @@ object UtilityTts { } } - fun conditionalPlay(activityArguments: Array, index: Int, context: Context, html: String, label: String) { - if (activityArguments.size > index && activityArguments[index] == "sound") synthesizeTextAndPlay(context, html, label) + fun conditionalPlay(arguments: Array, index: Int, context: Context, html: String, label: String) { + if (arguments.size > index && arguments[index] == "sound") synthesizeTextAndPlay(context, html, label) } } diff --git a/app/src/main/java/joshuatee/wx/canada/CanadaAlertsActivity.kt b/app/src/main/java/joshuatee/wx/canada/CanadaAlertsActivity.kt index 25674825..84d9bb3c 100644 --- a/app/src/main/java/joshuatee/wx/canada/CanadaAlertsActivity.kt +++ b/app/src/main/java/joshuatee/wx/canada/CanadaAlertsActivity.kt @@ -39,15 +39,15 @@ class CanadaAlertsActivity : BaseActivity(), Toolbar.OnMenuItemClickListener { private var firstTime = true private lateinit var objectCanadaWarnings: ObjectCanadaWarnings private lateinit var scrollView: ScrollView - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout_bottom_toolbar, R.menu.caalerts, true) scrollView = findViewById(R.id.scrollView) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) toolbarBottom.setOnMenuItemClickListener(this) - objectCanadaWarnings = ObjectCanadaWarnings(this, linearLayout, toolbar) + objectCanadaWarnings = ObjectCanadaWarnings(this, box, toolbar) objectCanadaWarnings.province = Utility.readPref(this, "CA_ALERTS_PROV", objectCanadaWarnings.province) title = "Canada Alerts" getContent() diff --git a/app/src/main/java/joshuatee/wx/canada/CanadaHourlyActivity.kt b/app/src/main/java/joshuatee/wx/canada/CanadaHourlyActivity.kt index d8fbc91a..d35aae4d 100644 --- a/app/src/main/java/joshuatee/wx/canada/CanadaHourlyActivity.kt +++ b/app/src/main/java/joshuatee/wx/canada/CanadaHourlyActivity.kt @@ -36,16 +36,16 @@ class CanadaHourlyActivity : BaseActivity() { companion object { const val LOC_NUM = "" } private var locationNumber = 0 - private lateinit var objectCardText: ObjectCardText - private lateinit var linearLayout: LinearLayout + private lateinit var text: ObjectCardText + private lateinit var box: LinearLayout @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, null, false) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) locationNumber = (intent.getStringExtra(LOC_NUM)!!.toIntOrNull() ?: 0) - 1 - objectCardText = ObjectCardText(this, linearLayout, toolbar) - ObjectCALegal(this, linearLayout, UtilityCanadaHourly.getUrl(Location.locationIndex)) + text = ObjectCardText(this, box, toolbar) + ObjectCALegal(this, box, UtilityCanadaHourly.getUrl(Location.locationIndex)) title = Location.getName(locationNumber) + " hourly forecast" getContent() } @@ -56,7 +56,7 @@ class CanadaHourlyActivity : BaseActivity() { } private fun getContent() { - objectCardText.typefaceMono() - FutureText2(this, { UtilityCanadaHourly.getString(locationNumber) }, objectCardText::setText1) + text.typefaceMono() + FutureText2(this, { UtilityCanadaHourly.getString(locationNumber) }, text::setText1) } } diff --git a/app/src/main/java/joshuatee/wx/canada/CanadaTextActivity.kt b/app/src/main/java/joshuatee/wx/canada/CanadaTextActivity.kt index c866ba00..a0980546 100644 --- a/app/src/main/java/joshuatee/wx/canada/CanadaTextActivity.kt +++ b/app/src/main/java/joshuatee/wx/canada/CanadaTextActivity.kt @@ -46,16 +46,16 @@ class CanadaTextActivity : AudioPlayActivity(), OnMenuItemClickListener { private var html = "" private lateinit var objectCardText: ObjectCardText private lateinit var scrollView: ScrollView - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout_bottom_toolbar, R.menu.canada_text) scrollView = findViewById(R.id.scrollView) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) toolbarBottom.setOnMenuItemClickListener(this) - objectCardText = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) - ObjectCALegal(this, linearLayout, GlobalVariables.canadaEcSitePrefix) + objectCardText = ObjectCardText(this, box, toolbar, toolbarBottom) + ObjectCALegal(this, box, GlobalVariables.canadaEcSitePrefix) product = Utility.readPref(this, "CA_TEXT_LASTUSED", product) getContent() } diff --git a/app/src/main/java/joshuatee/wx/fragments/ItemTouchHelperAdapter.kt b/app/src/main/java/joshuatee/wx/fragments/ItemTouchHelperAdapter.kt index f6e08c19..32c80efa 100644 --- a/app/src/main/java/joshuatee/wx/fragments/ItemTouchHelperAdapter.kt +++ b/app/src/main/java/joshuatee/wx/fragments/ItemTouchHelperAdapter.kt @@ -21,7 +21,7 @@ package joshuatee.wx.fragments import androidx.recyclerview.widget.RecyclerView -import androidx.recyclerview.widget.ItemTouchHelper +//import androidx.recyclerview.widget.ItemTouchHelper internal interface ItemTouchHelperAdapter { diff --git a/app/src/main/java/joshuatee/wx/fragments/UtilityLocationFragment.kt b/app/src/main/java/joshuatee/wx/fragments/UtilityLocationFragment.kt index 2fdbacd9..ec3b603e 100644 --- a/app/src/main/java/joshuatee/wx/fragments/UtilityLocationFragment.kt +++ b/app/src/main/java/joshuatee/wx/fragments/UtilityLocationFragment.kt @@ -28,7 +28,9 @@ import joshuatee.wx.settings.UIPreferences import joshuatee.wx.objects.ObjectIntent import joshuatee.wx.radar.WXGLRender import joshuatee.wx.settings.Location +import joshuatee.wx.util.To import joshuatee.wx.util.Utility +import joshuatee.wx.util.UtilityMath import java.util.* import java.util.regex.Pattern @@ -204,7 +206,11 @@ object UtilityLocationFragment { list.forEach { val temp = blob.parse(it) if (temp != "") { - return temp + return if (UIPreferences.unitsF) { + temp + } else { + UtilityMath.fahrenheitToCelsius(To.double(temp)) + } } } return "" diff --git a/app/src/main/java/joshuatee/wx/models/DisplayDataNoSpinner.kt b/app/src/main/java/joshuatee/wx/models/DisplayDataNoSpinner.kt index 08217f07..cfee891f 100644 --- a/app/src/main/java/joshuatee/wx/models/DisplayDataNoSpinner.kt +++ b/app/src/main/java/joshuatee/wx/models/DisplayDataNoSpinner.kt @@ -26,27 +26,29 @@ import android.content.Context import android.graphics.drawable.AnimationDrawable import joshuatee.wx.R import joshuatee.wx.ui.OnSwipeTouchListener -import joshuatee.wx.ui.TouchImageView2 +import joshuatee.wx.ui.TouchImage import joshuatee.wx.util.UtilityImg class DisplayDataNoSpinner(context: Context, activity: Activity, numPanes: Int, om: ObjectModelNoSpinner) { - var animDrawable = MutableList(numPanes) {AnimationDrawable()} + var animDrawable = MutableList(numPanes) { AnimationDrawable() } var param = MutableList(numPanes) {""} var paramLabel = MutableList(numPanes) {""} - var img = MutableList(numPanes) {TouchImageView2(context)} - var bitmap = MutableList(numPanes) {UtilityImg.getBlankBitmap()} + var img = MutableList(numPanes) { TouchImage(context) } + var bitmap = MutableList(numPanes) { UtilityImg.getBlankBitmap() } init { val resourceId = listOf(R.id.iv1, R.id.iv2) - (0 until numPanes).forEach { index -> img[index] = activity.findViewById(resourceId[index]) } + (0 until numPanes).forEach { + index -> img[index] = TouchImage(activity, resourceId[index]) + } if (numPanes > 1) { - img[0].setOnTouchImageViewListener { img[1].setZoom(img[0]) } - img[1].setOnTouchImageViewListener { img[0].setZoom(img[1]) } + img[0].setListener2 { img[1].setZoom(img[0]) } + img[1].setListener2 { img[0].setZoom(img[1]) } } (0 until numPanes).forEach { if (om.prefModel != "") { // Don't use in SPC Meso - img[it].setOnTouchListener(object : OnSwipeTouchListener(context) { + img[it].setListener(object : OnSwipeTouchListener(context) { override fun onSwipeLeft() { if (img[0].currentZoom < 1.01f) om.rightClick() } diff --git a/app/src/main/java/joshuatee/wx/models/ModelsGenericActivity.kt b/app/src/main/java/joshuatee/wx/models/ModelsGenericActivity.kt index 8ae9053e..a2879e17 100644 --- a/app/src/main/java/joshuatee/wx/models/ModelsGenericActivity.kt +++ b/app/src/main/java/joshuatee/wx/models/ModelsGenericActivity.kt @@ -29,7 +29,6 @@ import android.view.Menu import androidx.appcompat.widget.Toolbar.OnMenuItemClickListener import android.view.MenuItem import android.view.View -import android.widget.AdapterView import android.widget.LinearLayout import androidx.core.view.GravityCompat import java.util.Locale @@ -60,7 +59,7 @@ class ModelsGenericActivity : VideoRecordActivity(), OnMenuItemClickListener { private var fab1: ObjectFab? = null private var fab2: ObjectFab? = null - private var activityArguments: Array? = arrayOf() + private var arguments: Array = arrayOf() private lateinit var miStatus: MenuItem private lateinit var miStatusParam1: MenuItem private lateinit var miStatusParam2: MenuItem @@ -83,20 +82,22 @@ class ModelsGenericActivity : VideoRecordActivity(), OnMenuItemClickListener { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { - activityArguments = intent.getStringArrayExtra(INFO) - if (activityArguments == null) activityArguments = arrayOf("1", "NCEP", "NCEP") - om = ObjectModelNoSpinner(this, activityArguments!![1], activityArguments!![0]) + arguments = intent.getStringArrayExtra(INFO)!! +// if (arguments == null) { +// arguments = arrayOf("1", "NCEP", "NCEP") +// } + om = ObjectModelNoSpinner(this, arguments[1], arguments[0]) if (om.numPanes == 1) { super.onCreate(savedInstanceState, R.layout.activity_models_generic_nospinner, R.menu.models_generic, iconsEvenlySpaced = false, bottomToolbar = true) } else { super.onCreate(savedInstanceState, R.layout.activity_models_generic_multipane_nospinner, R.menu.models_generic, iconsEvenlySpaced = false, bottomToolbar = true) - val linearLayout: LinearLayout = findViewById(R.id.linearLayout) + val box: LinearLayout = findViewById(R.id.linearLayout) if (UtilityUI.isLandScape(this)) { - linearLayout.orientation = LinearLayout.HORIZONTAL + box.orientation = LinearLayout.HORIZONTAL } } toolbarBottom.setOnMenuItemClickListener(this) - title = activityArguments!![2] + title = arguments[2] val menu = toolbarBottom.menu timeMenuItem = menu.findItem(R.id.action_time) runMenuItem = menu.findItem(R.id.action_run) @@ -124,9 +125,9 @@ class ModelsGenericActivity : VideoRecordActivity(), OnMenuItemClickListener { om.displayData = DisplayDataNoSpinner(this, this, om.numPanes, om) objectNavDrawer = ObjectNavDrawer(this, om.labels, om.params) om.setUiElements(toolbar, fab1, fab2, miStatusParam1, miStatusParam2, ::getContent) - objectNavDrawer.listView.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ -> - objectNavDrawer.listView.setItemChecked(position, false) - objectNavDrawer.drawerLayout.closeDrawer(objectNavDrawer.listView) + objectNavDrawer.setListener2 { _, _, position, _ -> + objectNavDrawer.setItemChecked(position, false) + objectNavDrawer.close() om.displayData.param[om.curImg] = objectNavDrawer.tokens[position] om.displayData.paramLabel[om.curImg] = objectNavDrawer.getLabel(position) getContent() @@ -136,7 +137,7 @@ class ModelsGenericActivity : VideoRecordActivity(), OnMenuItemClickListener { } override fun onMenuItemClick(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawer.onOptionsItemSelected(item)) { return true } when (item.itemId) { @@ -161,7 +162,7 @@ class ModelsGenericActivity : VideoRecordActivity(), OnMenuItemClickListener { "(" + (om.curImg + 1).toString() + ")" + om.displayData.param[0] + "/" + om.displayData.param[1] ) } - R.id.action_multipane -> ObjectIntent.showModel(this, arrayOf("2", activityArguments!![1], activityArguments!![2])) + R.id.action_multipane -> ObjectIntent.showModel(this, arrayOf("2", arguments[1], arguments[2])) R.id.action_share -> { if (UIPreferences.recordScreenShare) { checkOverlayPerms() @@ -175,7 +176,7 @@ class ModelsGenericActivity : VideoRecordActivity(), OnMenuItemClickListener { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawer.onOptionsItemSelected(item)) { return true } when (item.itemId) { @@ -250,12 +251,12 @@ class ModelsGenericActivity : VideoRecordActivity(), OnMenuItemClickListener { override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - objectNavDrawer.actionBarDrawerToggle.syncState() + objectNavDrawer.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - objectNavDrawer.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawer.onConfigurationChanged(newConfig) } private fun genericDialog(list: List, fn: (Int) -> Unit) { @@ -386,7 +387,9 @@ class ModelsGenericActivity : VideoRecordActivity(), OnMenuItemClickListener { true } KeyEvent.KEYCODE_D -> { - if (event.isCtrlPressed) objectNavDrawer.drawerLayout.openDrawer(GravityCompat.START) + if (event.isCtrlPressed) { + objectNavDrawer.openGravity(GravityCompat.START) + } true } else -> super.onKeyUp(keyCode, event) diff --git a/app/src/main/java/joshuatee/wx/models/ModelsSPCHREFActivity.kt b/app/src/main/java/joshuatee/wx/models/ModelsSPCHREFActivity.kt index 797d1dd6..e38a0f6d 100644 --- a/app/src/main/java/joshuatee/wx/models/ModelsSPCHREFActivity.kt +++ b/app/src/main/java/joshuatee/wx/models/ModelsSPCHREFActivity.kt @@ -55,7 +55,7 @@ class ModelsSpcHrefActivity : VideoRecordActivity(), OnMenuItemClickListener { private lateinit var miStatusParam2: MenuItem private lateinit var objectNavDrawerCombo: ObjectNavDrawerCombo private lateinit var om: ObjectModelNoSpinner - private lateinit var activityArguments: Array + private lateinit var arguments: Array private lateinit var timeMenuItem: MenuItem private lateinit var runMenuItem: MenuItem @@ -71,19 +71,19 @@ class ModelsSpcHrefActivity : VideoRecordActivity(), OnMenuItemClickListener { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { - activityArguments = intent.getStringArrayExtra(INFO)!! - om = ObjectModelNoSpinner(this, activityArguments[1], activityArguments[0]) + arguments = intent.getStringArrayExtra(INFO)!! + om = ObjectModelNoSpinner(this, arguments[1], arguments[0]) if (om.numPanes == 1) { super.onCreate(savedInstanceState, R.layout.activity_models_spchref, R.menu.models_spchref, iconsEvenlySpaced = false, bottomToolbar = true) } else { super.onCreate(savedInstanceState, R.layout.activity_models_spchrefmultipane, R.menu.models_spchref, iconsEvenlySpaced = false, bottomToolbar = true) - val linearLayout: LinearLayout = findViewById(R.id.linearLayout) + val box: LinearLayout = findViewById(R.id.linearLayout) if (UtilityUI.isLandScape(this)) { - linearLayout.orientation = LinearLayout.HORIZONTAL + box.orientation = LinearLayout.HORIZONTAL } } toolbarBottom.setOnMenuItemClickListener(this) - title = activityArguments[2] + title = arguments[2] val menu = toolbarBottom.menu timeMenuItem = menu.findItem(R.id.action_time) runMenuItem = menu.findItem(R.id.action_run) @@ -117,8 +117,8 @@ class ModelsSpcHrefActivity : VideoRecordActivity(), OnMenuItemClickListener { "" ) om.setUiElements(toolbar, fab1, fab2, miStatusParam1, miStatusParam2, ::getContent) - objectNavDrawerCombo.listView.setOnChildClickListener { _, _, groupPosition, childPosition, _ -> - objectNavDrawerCombo.drawerLayout.closeDrawer(objectNavDrawerCombo.listView) + objectNavDrawerCombo.setListener2 { _, _, groupPosition, childPosition, _ -> + objectNavDrawerCombo.close() om.displayData.param[om.curImg] = objectNavDrawerCombo.getToken(groupPosition, childPosition) om.displayData.paramLabel[om.curImg] = objectNavDrawerCombo.getLabel(groupPosition, childPosition) UtilityModels.getContentNonSpinner(this, om, listOf("")) @@ -129,7 +129,9 @@ class ModelsSpcHrefActivity : VideoRecordActivity(), OnMenuItemClickListener { } override fun onMenuItemClick(item: MenuItem): Boolean { - if (objectNavDrawerCombo.actionBarDrawerToggle.onOptionsItemSelected(item)) return true + if (objectNavDrawerCombo.onOptionsItemSelected(item)) { + return true + } when (item.itemId) { R.id.action_back -> om.leftClick() R.id.action_forward -> om.rightClick() @@ -152,7 +154,7 @@ class ModelsSpcHrefActivity : VideoRecordActivity(), OnMenuItemClickListener { R.id.action_animate -> UtilityModels.getAnimate(this, om, listOf("")) R.id.action_time -> genericDialog(om.times) { om.setTimeIdx(it) } R.id.action_run -> genericDialog(om.rtd.listRun) { om.run = om.rtd.listRun[it] } - R.id.action_multipane -> ObjectIntent(this, ModelsSpcHrefActivity::class.java, INFO, arrayOf("2", activityArguments[1], activityArguments[2])) + R.id.action_multipane -> ObjectIntent(this, ModelsSpcHrefActivity::class.java, INFO, arrayOf("2", arguments[1], arguments[2])) R.id.action_share -> { if (UIPreferences.recordScreenShare) { checkOverlayPerms() @@ -166,7 +168,9 @@ class ModelsSpcHrefActivity : VideoRecordActivity(), OnMenuItemClickListener { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (objectNavDrawerCombo.actionBarDrawerToggle.onOptionsItemSelected(item)) return true + if (objectNavDrawerCombo.onOptionsItemSelected(item)) { + return true + } when (item.itemId) { R.id.action_region -> genericDialog(UtilityModelSpcHrefInterface.sectorsLong) { om.sector = UtilityModelSpcHrefInterface.sectorsLong[it] } else -> return super.onOptionsItemSelected(item) @@ -217,12 +221,12 @@ class ModelsSpcHrefActivity : VideoRecordActivity(), OnMenuItemClickListener { override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - objectNavDrawerCombo.actionBarDrawerToggle.syncState() + objectNavDrawerCombo.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - objectNavDrawerCombo.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawerCombo.onConfigurationChanged(newConfig) } private fun genericDialog(list: List, fn: (Int) -> Unit) { diff --git a/app/src/main/java/joshuatee/wx/models/ModelsSPCHRRRActivity.kt b/app/src/main/java/joshuatee/wx/models/ModelsSPCHRRRActivity.kt index 65c44985..fd622a60 100644 --- a/app/src/main/java/joshuatee/wx/models/ModelsSPCHRRRActivity.kt +++ b/app/src/main/java/joshuatee/wx/models/ModelsSPCHRRRActivity.kt @@ -30,7 +30,6 @@ import android.view.KeyEvent import android.view.Menu import android.view.MenuItem import android.view.View -import android.widget.AdapterView import android.widget.LinearLayout import java.util.Locale import joshuatee.wx.R @@ -58,7 +57,7 @@ class ModelsSpcHrrrActivity : VideoRecordActivity(), OnMenuItemClickListener { / private lateinit var miStatusParam2: MenuItem private lateinit var objectNavDrawer: ObjectNavDrawer private lateinit var om: ObjectModelNoSpinner - private lateinit var activityArguments: Array + private lateinit var arguments: Array private lateinit var timeMenuItem: MenuItem private lateinit var runMenuItem: MenuItem @@ -78,19 +77,19 @@ class ModelsSpcHrrrActivity : VideoRecordActivity(), OnMenuItemClickListener { / @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { - activityArguments = intent.getStringArrayExtra(INFO)!! - om = ObjectModelNoSpinner(this, activityArguments[1], activityArguments[0]) + arguments = intent.getStringArrayExtra(INFO)!! + om = ObjectModelNoSpinner(this, arguments[1], arguments[0]) if (om.numPanes == 1) { super.onCreate(savedInstanceState, R.layout.activity_models_generic_nospinner, R.menu.models_spchrrr, iconsEvenlySpaced = false, bottomToolbar = true) } else { super.onCreate(savedInstanceState, R.layout.activity_models_generic_multipane_nospinner, R.menu.models_spchrrr, iconsEvenlySpaced = false, bottomToolbar = true) - val linearLayout: LinearLayout = findViewById(R.id.linearLayout) + val box: LinearLayout = findViewById(R.id.linearLayout) if (UtilityUI.isLandScape(this)) { - linearLayout.orientation = LinearLayout.HORIZONTAL + box.orientation = LinearLayout.HORIZONTAL } } toolbarBottom.setOnMenuItemClickListener(this) - title = activityArguments[2] + title = arguments[2] overlayImg.addAll(listOf(*TextUtils.split(Utility.readPref(this, "SPCHRRR_OVERLAY", ""), ":"))) val menu = toolbarBottom.menu timeMenuItem = menu.findItem(R.id.action_time) @@ -117,9 +116,9 @@ class ModelsSpcHrrrActivity : VideoRecordActivity(), OnMenuItemClickListener { / om.displayData = DisplayDataNoSpinner(this, this, om.numPanes, om) objectNavDrawer = ObjectNavDrawer(this, UtilityModelSpcHrrrInterface.labels, UtilityModelSpcHrrrInterface.params) om.setUiElements(toolbar, fab1, fab2, miStatusParam1, miStatusParam2, ::getContent) - objectNavDrawer.listView.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ -> - objectNavDrawer.listView.setItemChecked(position, false) - objectNavDrawer.drawerLayout.closeDrawer(objectNavDrawer.listView) + objectNavDrawer.setListener2 { _, _, position, _ -> + objectNavDrawer.setItemChecked(position, false) + objectNavDrawer.close() om.displayData.param[om.curImg] = objectNavDrawer.tokens[position] om.displayData.paramLabel[om.curImg] = objectNavDrawer.getLabel(position) UtilityModels.getContentNonSpinner(this, om, overlayImg) @@ -130,7 +129,7 @@ class ModelsSpcHrrrActivity : VideoRecordActivity(), OnMenuItemClickListener { / } override fun onMenuItemClick(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawer.onOptionsItemSelected(item)) { return true } when (item.itemId) { @@ -163,7 +162,7 @@ class ModelsSpcHrrrActivity : VideoRecordActivity(), OnMenuItemClickListener { / overlayImg.clear() UtilityModels.getContentNonSpinner(this, om, overlayImg) } - R.id.action_multipane -> ObjectIntent(this, ModelsSpcHrrrActivity::class.java, INFO, arrayOf("2", activityArguments[1], activityArguments[2])) + R.id.action_multipane -> ObjectIntent(this, ModelsSpcHrrrActivity::class.java, INFO, arrayOf("2", arguments[1], arguments[2])) R.id.action_back -> om.leftClick() R.id.action_forward -> om.rightClick() R.id.action_animate -> UtilityModels.getAnimate(this, om, overlayImg) @@ -182,7 +181,7 @@ class ModelsSpcHrrrActivity : VideoRecordActivity(), OnMenuItemClickListener { / } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawer.onOptionsItemSelected(item)) { return true } when (item.itemId) { @@ -240,12 +239,12 @@ class ModelsSpcHrrrActivity : VideoRecordActivity(), OnMenuItemClickListener { / override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - objectNavDrawer.actionBarDrawerToggle.syncState() + objectNavDrawer.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - objectNavDrawer.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawer.onConfigurationChanged(newConfig) } private fun genericDialog(list: List, fn: (Int) -> Unit) { diff --git a/app/src/main/java/joshuatee/wx/models/ModelsSPCSREFActivity.kt b/app/src/main/java/joshuatee/wx/models/ModelsSPCSREFActivity.kt index 3900716c..8947dea8 100644 --- a/app/src/main/java/joshuatee/wx/models/ModelsSPCSREFActivity.kt +++ b/app/src/main/java/joshuatee/wx/models/ModelsSPCSREFActivity.kt @@ -59,7 +59,7 @@ class ModelsSpcSrefActivity : VideoRecordActivity(), OnMenuItemClickListener { private lateinit var star: MenuItem private var fab1: ObjectFab? = null private var fab2: ObjectFab? = null - private lateinit var activityArguments: Array + private lateinit var arguments: Array private lateinit var miStatus: MenuItem private lateinit var miStatusParam1: MenuItem private lateinit var miStatusParam2: MenuItem @@ -81,15 +81,15 @@ class ModelsSpcSrefActivity : VideoRecordActivity(), OnMenuItemClickListener { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { - activityArguments = intent.getStringArrayExtra(INFO)!! - om = ObjectModelNoSpinner(this, activityArguments[1], activityArguments[0]) + arguments = intent.getStringArrayExtra(INFO)!! + om = ObjectModelNoSpinner(this, arguments[1], arguments[0]) if (om.numPanes == 1) { super.onCreate(savedInstanceState, R.layout.activity_models_spcsref, R.menu.models_spcsref, iconsEvenlySpaced = false, bottomToolbar = true) } else { super.onCreate(savedInstanceState, R.layout.activity_models_spcsrefmultipane, R.menu.models_spcsref, iconsEvenlySpaced = false, bottomToolbar = true) - val linearLayout: LinearLayout = findViewById(R.id.linearLayout) + val box: LinearLayout = findViewById(R.id.linearLayout) if (UtilityUI.isLandScape(this)) { - linearLayout.orientation = LinearLayout.HORIZONTAL + box.orientation = LinearLayout.HORIZONTAL } } toolbarBottom.setOnMenuItemClickListener(this) @@ -100,7 +100,7 @@ class ModelsSpcSrefActivity : VideoRecordActivity(), OnMenuItemClickListener { miStatusParam2 = menu.findItem(R.id.action_status_param2) star = menu.findItem(R.id.action_fav) star.setIcon(GlobalVariables.STAR_OUTLINE_ICON) - title = activityArguments[2] + title = arguments[2] if (om.numPanes < 2) { fab1 = ObjectFab(this, R.id.fab1) { om.leftClick() @@ -184,7 +184,7 @@ class ModelsSpcSrefActivity : VideoRecordActivity(), OnMenuItemClickListener { } override fun onMenuItemClick(item: MenuItem): Boolean { - if (objectNavDrawerCombo.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawerCombo.onOptionsItemSelected(item)) { return true } when (item.itemId) { @@ -212,7 +212,7 @@ class ModelsSpcSrefActivity : VideoRecordActivity(), OnMenuItemClickListener { "(" + (om.curImg + 1).toString() + ")" + om.displayData.param[0] + "/" + om.displayData.param[1] ) } - R.id.action_multipane -> ObjectIntent(this, ModelsSpcSrefActivity::class.java, INFO, arrayOf("2", activityArguments[1], activityArguments[2])) + R.id.action_multipane -> ObjectIntent(this, ModelsSpcSrefActivity::class.java, INFO, arrayOf("2", arguments[1], arguments[2])) R.id.action_fav -> toggleFavorite() R.id.action_time -> genericDialog(om.times) { om.setTimeIdx(it) } R.id.action_run -> genericDialog(om.rtd.listRun) { om.run = om.rtd.listRun[it] } @@ -231,7 +231,7 @@ class ModelsSpcSrefActivity : VideoRecordActivity(), OnMenuItemClickListener { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (objectNavDrawerCombo.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawerCombo.onOptionsItemSelected(item)) { return true } favList = UtilityFavorites.setupMenu(this, UIPreferences.srefFav, om.displayData.param[om.curImg], prefToken) @@ -253,12 +253,12 @@ class ModelsSpcSrefActivity : VideoRecordActivity(), OnMenuItemClickListener { override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - objectNavDrawerCombo.actionBarDrawerToggle.syncState() + objectNavDrawerCombo.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - objectNavDrawerCombo.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawerCombo.onConfigurationChanged(newConfig) } private fun showHelpTextDialog() { diff --git a/app/src/main/java/joshuatee/wx/models/UtilityModelSPCHREFInterface.kt b/app/src/main/java/joshuatee/wx/models/UtilityModelSPCHREFInterface.kt index 0c1e639c..7ac9d814 100644 --- a/app/src/main/java/joshuatee/wx/models/UtilityModelSPCHREFInterface.kt +++ b/app/src/main/java/joshuatee/wx/models/UtilityModelSPCHREFInterface.kt @@ -36,7 +36,7 @@ internal object UtilityModelSpcHrefInterface { ObjectMenuTitle("Winter", 26), ObjectMenuTitle("Fire", 12), ObjectMenuTitle("Precipitation", 16), - ObjectMenuTitle("Storm Attributes", 24) + ObjectMenuTitle("Storm Attributes", 16) ) var shortCodes = Array(13) { Array(30) { "" } } @@ -179,28 +179,20 @@ internal object UtilityModelSpcHrefInterface { "qpf_012h_pmm", "qpf_012h_ps", - "cref_members hrwnssl", - "cref_members hrwarw", - "cref_members hrwnmmb", - "cref_members namnest", - "cref_pb40_members", - "cref_ps", - "ref1km_003hmax_nh40", - "ref1km_003hmax_pb40_members", - "ref1km_024hmax_nh40", - "ref1km_024hmax_pb40_members", - "uh25_003hmax_max", - "uh25_003hmax_nh075_fill", - "uh25_003hmax_nh150_fill", - "uh25_003hmax_pb075_members,uh25_003hmax_nh075", - "uh25_003hmax_pb150_members,uh25_003hmax_nh150", + "ref1km_004hmax_max", + "ref1km_024hmax_max", + "uh25_004hmax_max", + "uh25_004hmax_nh075_fill", + "uh25_004hmax_nh150_fill", + "uh25_004hmax_pb075_members,uh25_004hmax_nh075", + "uh25_004hmax_pb150_members,uh25_004hmax_nh150", "uh25_024hmax_max,uh25_024hmax_nh075", "uh25_024hmax_nh075_fill", "uh25_024hmax_nh150_fill", "uh25_024hmax_pb075_members,uh25_024hmax_nh075", "uh25_024hmax_pb150_members,uh25_024hmax_nh150", - "wspd_003hmax_max", - "wspd_003hmax_pb30_members", + "wspd_004hmax_max", + "wspd_004hmax_pb30_members", "wspd_024hmax_max", "wspd_024hmax_pb30_members" ) @@ -296,36 +288,20 @@ internal object UtilityModelSpcHrefInterface { "24-hr QPF: pmm", "24-hr QPF: stamps", - "Reflectivity: hrwnssl", - "Reflectivity: hrwarw", - "Reflectivity: hrwnmmb", - "Reflectivity: namnest", - "Reflectivity: PB[>40]", - "Reflectivity: stamps", - "3-hr max Reflectivity: max", - "3-hr max Reflectivity: PB[>40]", + "4-hr max Reflectivity: max", "24-hr max Reflectivity: max", - "24-hr max Reflectivity: PB[>40]", - "3-hr max Updraft Helicity (2-5 km): max", - "3-hr max Updraft Helicity (2-5 km): NP[>75]", - "3-hr max Updraft Helicity (2-5 km): NP[>150]", - "3-hr max Updraft Helicity (2-5 km): PB[>75]", - "3-hr max Updraft Helicity (2-5 km): PB[>150]", + "4-hr max Updraft Helicity (2-5 km): max", + "4-hr max Updraft Helicity (2-5 km): NP[>75]", + "4-hr max Updraft Helicity (2-5 km): NP[>150]", + "4-hr max Updraft Helicity (2-5 km): PB[>75]", + "4-hr max Updraft Helicity (2-5 km): PB[>150]", "24-hr max Updraft Helicity (2-5 km): max", "24-hr max Updraft Helicity (2-5 km): NP[>75]", "24-hr max Updraft Helicity (2-5 km): NP[>150]", "24-hr max Updraft Helicity (2-5 km): PB[>75]", "24-hr max Updraft Helicity (2-5 km): PB[>150]", - "3-hr max Updraft: max", - "3-hr max Updraft: PB[>20]", - "24-hr max Updraft: max", - "24-hr max Updraft: PB[>20]", - "3-hr max Wind Speed: max", - "3-hr max Wind Speed: PB[>30]", - "24-hr max Wind Speed: max", - "24-hr max Wind Speed: PB[>30]", - "10m 3-hr max Wind Speed: max PB[>30]", - "10m 3-hr max Wind Speed: PB[>30]", + "10m 4-hr max Wind Speed: max", + "10m 4-hr max Wind Speed: PB[>30]", "10m 24-hr max Wind Speed: max", "10m 24-hr max Wind Speed: PB[>30]" ) diff --git a/app/src/main/java/joshuatee/wx/models/UtilityModels.kt b/app/src/main/java/joshuatee/wx/models/UtilityModels.kt index fc008606..8e7284a0 100644 --- a/app/src/main/java/joshuatee/wx/models/UtilityModels.kt +++ b/app/src/main/java/joshuatee/wx/models/UtilityModels.kt @@ -33,7 +33,7 @@ import joshuatee.wx.Extensions.startAnimation import joshuatee.wx.common.RegExp import joshuatee.wx.settings.UIPreferences import joshuatee.wx.objects.FutureVoid -import joshuatee.wx.ui.TouchImageView2 +import joshuatee.wx.ui.TouchImage import joshuatee.wx.util.Utility import joshuatee.wx.util.UtilityImg import joshuatee.wx.util.UtilityShare @@ -53,9 +53,10 @@ object UtilityModels { { (0 until om.numPanes).forEach { if (om.numPanes > 1) { - UtilityImg.resizeViewAndSetImage(context, om.displayData.bitmap[it], om.displayData.img[it]) + UtilityImg.resizeViewAndSetImage(context, om.displayData.bitmap[it], om.displayData.img[it].get()) } else { - om.displayData.img[it].setImageBitmap(om.displayData.bitmap[it]) +// om.displayData.img[it].setImageBitmap(om.displayData.bitmap[it]) + om.displayData.img[it].setBitmap(om.displayData.bitmap[it]) } } om.animRan = false @@ -210,7 +211,7 @@ object UtilityModels { } } - fun setSubtitleRestoreIMGXYZOOM(img: MutableList, toolbar: Toolbar, string: String) { + fun setSubtitleRestoreIMGXYZOOM(img: MutableList, toolbar: Toolbar, s: String) { val x = FloatArray(img.size) val y = FloatArray(img.size) val z = FloatArray(img.size) @@ -219,14 +220,14 @@ object UtilityModels { (0 until img.size).forEach { z[it] = img[it].currentZoom if (img[it].scrollPosition != null) { - point.add(img[it].scrollPosition) + point.add(img[it].scrollPosition!!) } else { point.add(PointF(0.5f, 0.5f)) } x[it] = point[it].x y[it] = point[it].y } - toolbar.subtitle = string + toolbar.subtitle = s (0 until img.size).filter { !x[it].isNaN() && !y[it].isNaN() }.forEach { img[it].setZoom(z[it], x[it], y[it]) } diff --git a/app/src/main/java/joshuatee/wx/nhc/NHCActivity.kt b/app/src/main/java/joshuatee/wx/nhc/NHCActivity.kt index faf3f703..ae60ad17 100644 --- a/app/src/main/java/joshuatee/wx/nhc/NHCActivity.kt +++ b/app/src/main/java/joshuatee/wx/nhc/NHCActivity.kt @@ -41,7 +41,7 @@ class NhcActivity : BaseActivity() { private lateinit var objectNhc: ObjectNhc private lateinit var scrollView: ScrollView - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.nhc, menu) @@ -52,8 +52,8 @@ class NhcActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, R.menu.nhc, false) scrollView = findViewById(R.id.scrollView) - linearLayout = findViewById(R.id.linearLayout) - objectNhc = ObjectNhc(this, linearLayout) + box = findViewById(R.id.linearLayout) + objectNhc = ObjectNhc(this, box) getContent() } diff --git a/app/src/main/java/joshuatee/wx/nhc/NHCStormActivity.kt b/app/src/main/java/joshuatee/wx/nhc/NHCStormActivity.kt index ba407a25..f831018c 100644 --- a/app/src/main/java/joshuatee/wx/nhc/NHCStormActivity.kt +++ b/app/src/main/java/joshuatee/wx/nhc/NHCStormActivity.kt @@ -51,12 +51,12 @@ class NhcStormActivity : BaseActivity() { private var product = "" private val bitmaps = mutableListOf() private lateinit var objectCardText: ObjectCardText - private lateinit var linearLayout: LinearLayout - private lateinit var linearLayoutText: ObjectLinearLayout - private lateinit var linearLayoutImage: ObjectLinearLayout + private lateinit var box: LinearLayout + private lateinit var boxText: VBox + private lateinit var boxImage: VBox private var numberOfImages = 0 private var imagesPerRow = 2 - private val horizontalLinearLayouts = mutableListOf() + private val horizontalLinearLayouts = mutableListOf() private val imageUrls = listOf( "_5day_cone_with_line_and_wind_sm2.png", "_key_messages.png", @@ -79,9 +79,9 @@ class NhcStormActivity : BaseActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, R.menu.nhc_storm, false) - linearLayout = findViewById(R.id.linearLayout) - linearLayoutImage = ObjectLinearLayout(this, linearLayout) - linearLayoutText = ObjectLinearLayout(this, linearLayout) + box = findViewById(R.id.linearLayout) + boxImage = VBox(this, box) + boxText = VBox(this, box) stormData = intent.getSerializableExtra(URL) as ObjectNhcStormDetails title = stormData.name + " " + stormData.classification toolbar.subtitle = stormData.forTopHeader() @@ -118,18 +118,16 @@ class NhcStormActivity : BaseActivity() { } fun showImages() { - linearLayoutImage.removeAllViews() + boxImage.removeAllViews() numberOfImages = 0 bitmaps.forEachIndexed { index, bitmap -> if (bitmap.width > 100) { - val objectCardImage: ObjectCardImage - if (numberOfImages % imagesPerRow == 0) { - val objectLinearLayout = ObjectLinearLayout(this, linearLayoutImage.get()) - objectLinearLayout.linearLayout.orientation = LinearLayout.HORIZONTAL - horizontalLinearLayouts.add(objectLinearLayout) - objectCardImage = ObjectCardImage(this, objectLinearLayout.linearLayout, bitmap, imagesPerRow) + val objectCardImage = if (numberOfImages % imagesPerRow == 0) { + val hbox = HBox(this, boxImage.get()) + horizontalLinearLayouts.add(hbox) + ObjectCardImage(this, hbox.get(), bitmap, imagesPerRow) } else { - objectCardImage = ObjectCardImage(this, horizontalLinearLayouts.last().linearLayout, bitmap, imagesPerRow) + ObjectCardImage(this, horizontalLinearLayouts.last().get(), bitmap, imagesPerRow) } numberOfImages += 1 objectCardImage.setOnClickListener { @@ -145,8 +143,8 @@ class NhcStormActivity : BaseActivity() { } fun showText(s: String) { - linearLayoutText.removeAllViews() - objectCardText = ObjectCardText(this, linearLayoutText.get(), toolbar, toolbarBottom) + boxText.removeAllViews() + objectCardText = ObjectCardText(this, boxText.get(), toolbar, toolbarBottom) if (s.contains("<")) { objectCardText.text = Utility.fromHtml(s) } else { diff --git a/app/src/main/java/joshuatee/wx/nhc/ObjectCardNhcStormReportItem.kt b/app/src/main/java/joshuatee/wx/nhc/ObjectCardNhcStormReportItem.kt index b620a4ca..24636251 100644 --- a/app/src/main/java/joshuatee/wx/nhc/ObjectCardNhcStormReportItem.kt +++ b/app/src/main/java/joshuatee/wx/nhc/ObjectCardNhcStormReportItem.kt @@ -24,14 +24,13 @@ package joshuatee.wx.nhc import android.content.Context import android.view.Gravity import android.view.View -import android.widget.LinearLayout import joshuatee.wx.settings.UIPreferences import joshuatee.wx.ui.ObjectCard -import joshuatee.wx.ui.ObjectLinearLayout +import joshuatee.wx.ui.VBox import joshuatee.wx.ui.ObjectTextView import java.util.* -class ObjectCardNhcStormReportItem(context: Context, linearLayout: LinearLayout, stormData: ObjectNhcStormDetails) { +class ObjectCardNhcStormReportItem(context: Context, box: VBox, stormData: ObjectNhcStormDetails) { private val objectCard = ObjectCard(context) private val textViewTop = ObjectTextView(context, UIPreferences.textHighlightColor) @@ -42,17 +41,17 @@ class ObjectCardNhcStormReportItem(context: Context, linearLayout: LinearLayout, private val textViewBottom = ObjectTextView(context, backgroundText = true) init { - val objectLinearLayout = ObjectLinearLayout(context, LinearLayout.VERTICAL, Gravity.CENTER_VERTICAL) - objectLinearLayout.addViews(listOf(textViewTop.get(), textViewTime.get(), textViewMovement.get())) - objectLinearLayout.addViews(listOf(textViewPressure.get(), textViewWindSpeed.get(), textViewBottom.get())) - objectCard.addView(objectLinearLayout.linearLayout) + val vbox = VBox(context, Gravity.CENTER_VERTICAL) + vbox.addViews(listOf(textViewTop.get(), textViewTime.get(), textViewMovement.get())) + vbox.addViews(listOf(textViewPressure.get(), textViewWindSpeed.get(), textViewBottom.get())) + objectCard.addView(vbox.get()) textViewTop.text = stormData.name + " (" + stormData.classification + ") " + stormData.center textViewTime.text = stormData.dateTime.replace("T", " ").replace(":00.000Z", "Z") textViewMovement.text = "Moving: " + stormData.movement textViewPressure.text = "Min pressure: " + stormData.pressure textViewWindSpeed.text = "Max sustained: " + stormData.intensity textViewBottom.text = stormData.status + " " + stormData.binNumber + " " + stormData.id.uppercase(Locale.US) - linearLayout.addView(objectCard.get()) + box.addWidget(objectCard.get()) } fun get() = objectCard.get() diff --git a/app/src/main/java/joshuatee/wx/nhc/ObjectNHC.kt b/app/src/main/java/joshuatee/wx/nhc/ObjectNHC.kt index 963eba45..f4c5c101 100644 --- a/app/src/main/java/joshuatee/wx/nhc/ObjectNHC.kt +++ b/app/src/main/java/joshuatee/wx/nhc/ObjectNHC.kt @@ -28,7 +28,7 @@ import android.widget.LinearLayout import joshuatee.wx.ui.ObjectCardImage import joshuatee.wx.ui.ObjectCardText import joshuatee.wx.objects.ObjectIntent -import joshuatee.wx.ui.ObjectLinearLayout +import joshuatee.wx.ui.VBox import joshuatee.wx.ui.UtilityUI import joshuatee.wx.Extensions.* import joshuatee.wx.common.GlobalVariables @@ -40,7 +40,7 @@ class ObjectNhc(val context: Context, linearLayout1: LinearLayout) { private val cardNotificationHeaderText = "Currently blocked storm notifications, tap this text to clear all blocks " private var numberOfImages = 0 var imagesPerRow = 2 - private val horizontalLinearLayouts = mutableListOf() + private val horizontalLinearLayouts = mutableListOf() private val regionMap = mutableMapOf() private var stormDataList = mutableListOf() private var ids = listOf() @@ -69,8 +69,8 @@ class ObjectNhc(val context: Context, linearLayout1: LinearLayout) { private val objectCardImages = mutableListOf() val urls = mutableListOf() private val imageTitles = mutableListOf() - private val linearLayoutText = ObjectLinearLayout(context, linearLayout1) - private val linearLayoutImages = ObjectLinearLayout(context, linearLayout1) + private val boxText = VBox(context, linearLayout1) + private val linearLayoutImages = VBox(context, linearLayout1) init { if (UtilityUI.isLandScape(context)) { @@ -156,10 +156,10 @@ class ObjectNhc(val context: Context, linearLayout1: LinearLayout) { } fun showTextData() { - linearLayoutText.removeAllViewsInLayout() + boxText.removeAllViewsInLayout() val muteStr = Utility.readPref(context, "NOTIF_NHC_MUTE", "") notificationCard = ObjectCardText(context, cardNotificationHeaderText + muteStr) - linearLayoutText.addView(notificationCard!!.get()) + boxText.addWidget(notificationCard!!.get()) notificationCard?.setOnClickListener { clearNhcNotificationBlock() } if (muteStr != "") { notificationCard?.visibility = View.VISIBLE @@ -188,7 +188,7 @@ class ObjectNhc(val context: Context, linearLayout1: LinearLayout) { Utility.safeGet(windSpeedProbabilities, index), ) stormDataList.add(objectNhcStormDetails) - val card = ObjectCardNhcStormReportItem(context, linearLayoutText.get(), objectNhcStormDetails) + val card = ObjectCardNhcStormReportItem(context, boxText, objectNhcStormDetails) card.setListener { ObjectIntent.showNhcStorm(context, objectNhcStormDetails) } } } @@ -200,12 +200,13 @@ class ObjectNhc(val context: Context, linearLayout1: LinearLayout) { val objectCardImage: ObjectCardImage val bitmap = UtilityImg.getBlankBitmap() if (numberOfImages % imagesPerRow == 0) { - val objectLinearLayout = ObjectLinearLayout(context, linearLayoutImages.get()) - objectLinearLayout.linearLayout.orientation = LinearLayout.HORIZONTAL + // TODO FIXME + val objectLinearLayout = VBox(context, linearLayoutImages.get()) + objectLinearLayout.orientation = LinearLayout.HORIZONTAL horizontalLinearLayouts.add(objectLinearLayout) - objectCardImage = ObjectCardImage(context, objectLinearLayout.linearLayout, bitmap, imagesPerRow) + objectCardImage = ObjectCardImage(context, objectLinearLayout.get(), bitmap, imagesPerRow) } else { - objectCardImage = ObjectCardImage(context, horizontalLinearLayouts.last().linearLayout, bitmap, imagesPerRow) + objectCardImage = ObjectCardImage(context, horizontalLinearLayouts.last().get(), bitmap, imagesPerRow) } numberOfImages += 1 objectCardImage.setOnClickListener { ObjectIntent.showImage(context, arrayOf(urls[index], imageTitles[index])) } diff --git a/app/src/main/java/joshuatee/wx/notifications/UtilityNotification.kt b/app/src/main/java/joshuatee/wx/notifications/UtilityNotification.kt index 415356d7..c17c4116 100644 --- a/app/src/main/java/joshuatee/wx/notifications/UtilityNotification.kt +++ b/app/src/main/java/joshuatee/wx/notifications/UtilityNotification.kt @@ -69,7 +69,7 @@ object UtilityNotification { val noSummary = "" val inBlackout = UtilityNotificationUtils.checkBlackOut() val tornadoWarningString = "Tornado Warning" - if (MyApplication.locations.size > locNumInt && MyApplication.locations[locNumInt].notification) { + if (Location.locations.size > locNumInt && Location.locations[locNumInt].notification) { var locLabelStr = "(" + Location.getName(locNumInt) + ") " var alertPresent = false if (Location.isUS(locNumInt)) { @@ -91,7 +91,7 @@ object UtilityNotification { ) val cancelStr = Location.getY(locNumInt) + hazUrls.parse("(

.*?

)").replace(",".toRegex(), "").replace(" ".toRegex(), "") if (!(NotificationPreferences.alertOnlyOnce && UtilityNotificationUtils.checkToken(context, cancelStr))) { - val sound = MyApplication.locations[locNumInt].sound && !inBlackout || MyApplication.locations[locNumInt].sound && NotificationPreferences.alertBlackoutTornado + val sound = Location.locations[locNumInt].sound && !inBlackout || Location.locations[locNumInt].sound && NotificationPreferences.alertBlackoutTornado val notifObj = ObjectNotification( context, sound, @@ -112,11 +112,11 @@ object UtilityNotification { notifUrls += cancelStr + NotificationPreferences.notificationStrSep } } - if (alertPresent && MyApplication.locations[locNumInt].notificationRadar) { + if (alertPresent && Location.locations[locNumInt].notificationRadar) { val url2: String var nws1StateCurrent = "" if (Location.isUS(locNumInt)) { - val nwsLocation = Utility.getWfoSiteName(MyApplication.locations[locNumInt].wfo) + val nwsLocation = Utility.getWfoSiteName(Location.locations[locNumInt].wfo) val nwsLocationArr = RegExp.comma.split(nwsLocation) nws1StateCurrent = nwsLocationArr[0] } @@ -163,8 +163,8 @@ object UtilityNotification { var noBody: String var noSummary: String var locLabelStr: String - if (MyApplication.locations.size > locNumInt && (MyApplication.locations[locNumInt].ccNotification - || MyApplication.locations[locNumInt].sevenDayNotification + if (Location.locations.size > locNumInt && (Location.locations[locNumInt].ccNotification + || Location.locations[locNumInt].sevenDayNotification || widgetLocNum == locNum && widgetsEnabled) ) { locLabel = " current conditions" @@ -175,10 +175,10 @@ object UtilityNotification { // problem is if network is down it will be a non deterministic value so we need something different val currentUpdateTime = UtilityTime.currentTimeMillis() val lastUpdateTime = Utility.readPref(context, "CC" + locNum + "_LAST_UPDATE", 0.toLong()) - if (MyApplication.locations[locNumInt].ccNotification) { + if (Location.locations[locNumInt].ccNotification) { notifUrls += url + "CC" + NotificationPreferences.notificationStrSep } - if (MyApplication.locations[locNumInt].sevenDayNotification) { + if (Location.locations[locNumInt].sevenDayNotification) { notifUrls += url + "7day" + NotificationPreferences.notificationStrSep } if (currentUpdateTime > lastUpdateTime + 1000 * 60 * ccUpdateInterval) { @@ -187,8 +187,10 @@ object UtilityNotification { val objSevenDay = ObjectSevenDay(locNumInt) val updateTime = UtilityTime.currentTimeMillis() Utility.writePref(context, "CC" + locNum + "_LAST_UPDATE", updateTime) - if (locNum == widgetLocNum && widgetsEnabled) UtilityWidget.widgetDownloadData(context, objCc, objSevenDay, objHazards) - if (MyApplication.locations[locNumInt].ccNotification) { + if (locNum == widgetLocNum && widgetsEnabled) { + UtilityWidget.widgetDownloadData(context, objCc, objSevenDay, objHazards) + } + if (Location.locations[locNumInt].ccNotification) { noMain = locLabelStr noBody = objCc.data + GlobalVariables.newline + objCc.status noSummary = objCc.data + GlobalVariables.newline + objCc.status @@ -237,7 +239,7 @@ object UtilityNotification { ) notifier.notify(url + "CC", 1, noti) } - if (MyApplication.locations[locNumInt].sevenDayNotification) { + if (Location.locations[locNumInt].sevenDayNotification) { locLabelStr = "(" + Location.getName(locNumInt) + ")" + " 7 day" noMain = locLabelStr noBody = objSevenDay.sevenDayShort diff --git a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSPC.kt b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSPC.kt index 5b755cf2..77d691e2 100644 --- a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSPC.kt +++ b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSPC.kt @@ -21,7 +21,6 @@ package joshuatee.wx.notifications -import joshuatee.wx.MyApplication import joshuatee.wx.R import joshuatee.wx.objects.PolygonType import joshuatee.wx.settings.Location @@ -99,9 +98,9 @@ internal object UtilityNotificationSpc { return notifUrls } - fun locationNeedsMcd() = (0 until Location.numLocations).any { MyApplication.locations.getOrNull(it)?.notificationMcd ?: false } + fun locationNeedsMcd() = (0 until Location.numLocations).any { Location.locations.getOrNull(it)?.notificationMcd ?: false } - fun locationNeedsSwo() = (0 until Location.numLocations).any { MyApplication.locations.getOrNull(it)?.notificationSwo ?: false } + fun locationNeedsSwo() = (0 until Location.numLocations).any { Location.locations.getOrNull(it)?.notificationSwo ?: false } /* ... CATEGORICAL ... @@ -149,7 +148,7 @@ internal object UtilityNotificationSpc { val polygonShape = polygonFrame.build() (1..Location.numLocations).forEach { n -> val locNum = n.toString() - if (MyApplication.locations[n - 1].notificationSwo) { + if (Location.locations[n - 1].notificationSwo) { // if location is watching for MCDs pull ib lat/lon and iterate over polygons // call secondary method to send notif if required if (polygonShape.contains(Location.getLatLon(n - 1).asPoint())) { @@ -178,7 +177,7 @@ internal object UtilityNotificationSpc { val polygonShape = polygonFrame.build() for (n in 1..Location.numLocations) { val locNum = n.toString() - if (MyApplication.locations[n - 1].notificationMcd) { + if (Location.locations[n - 1].notificationMcd) { // if location is watching for MCDs pull ib lat/lon and iterate over polygons // call secondary method to send notif if required if (polygonShape.contains(Location.getLatLon(n - 1).asPoint())) notifUrls += sendMcdNotification(context, locNum, mcdNumbers.safeGet(z)) @@ -209,7 +208,7 @@ internal object UtilityNotificationSpc { val resultPendingIntent2 = PendingIntent.getActivity(context, requestID + 1, resultIntent2, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) val cancelString = "spcmcdloc$mdNo$locNum" if (!(NotificationPreferences.alertOnlyOnce && UtilityNotificationUtils.checkToken(context, cancelString))) { - val sound = MyApplication.locations[locNumInt].sound && !inBlackout + val sound = Location.locations[locNumInt].sound && !inBlackout val objectNotification = ObjectNotification( context, sound, @@ -252,7 +251,7 @@ internal object UtilityNotificationSpc { val resultPendingIntent2 = PendingIntent.getActivity(context, requestID + 1, resultIntent2, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) val cancelString = "spcswoloc$day$locNum$threatLevel$validTime" if (!(NotificationPreferences.alertOnlyOnce && UtilityNotificationUtils.checkToken(context, cancelString))) { - val sound = (MyApplication.locations.getOrNull(locNumInt)?.sound ?: false) && !inBlackout + val sound = (Location.locations.getOrNull(locNumInt)?.sound ?: false) && !inBlackout val objectNotification = ObjectNotification( context, sound, @@ -303,7 +302,7 @@ internal object UtilityNotificationSpc { val polygonShape = polygonFrame.build() (1..Location.numLocations).forEach { n -> val locNum = n.toString() - if (MyApplication.locations[n - 1].notificationSwo) { + if (Location.locations[n - 1].notificationSwo) { // if location is watching for MCDs pull ib lat/lon and iterate over polygons // call secondary method to send notif if required if (polygonShape.contains(Location.getLatLon(n - 1).asPoint())) { diff --git a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSpcFireWeather.kt b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSpcFireWeather.kt index 3a2d4744..2464af78 100644 --- a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSpcFireWeather.kt +++ b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationSpcFireWeather.kt @@ -21,7 +21,6 @@ package joshuatee.wx.notifications -import joshuatee.wx.MyApplication import joshuatee.wx.R import joshuatee.wx.settings.Location import joshuatee.wx.external.ExternalPoint @@ -40,8 +39,8 @@ import joshuatee.wx.settings.NotificationPreferences internal object UtilityNotificationSpcFireWeather { fun locationNeedsSpcFireWeather() = (0 until Location.numLocations).any { - MyApplication.locations.getOrNull(it)?.notificationSpcFw ?: false - } + Location.locations.getOrNull(it)?.notificationSpcFw ?: false + } private fun sendSpcFireWeatherNotification(context: Context, locNum: String, day: Int, threatLevel: String, validTime: String): String { val locNumInt = (locNum.toIntOrNull() ?: 0) - 1 @@ -55,7 +54,7 @@ internal object UtilityNotificationSpcFireWeather { val objectPendingIntents = ObjectPendingIntents(context, SpcFireOutlookSummaryActivity::class.java) val cancelString = "spcfwloc$day$locNum$threatLevel$validTime" if (!(NotificationPreferences.alertOnlyOnce && UtilityNotificationUtils.checkToken(context, cancelString))) { - val sound = MyApplication.locations[locNumInt].sound && !inBlackout + val sound = Location.locations[locNumInt].sound && !inBlackout val objectNotification = ObjectNotification( context, sound, @@ -109,7 +108,7 @@ internal object UtilityNotificationSpcFireWeather { val polygonShape = polygonFrame.build() (1..Location.numLocations).forEach { n -> val locNum = n.toString() - if (MyApplication.locations.getOrNull(n - 1)?.notificationSpcFw == true) { + if (Location.locations.getOrNull(n - 1)?.notificationSpcFw == true) { // if location is watching for MCDs pull ib lat/lon and iterate over polygons // call secondary method to send notif if required if (polygonShape.contains(Location.getLatLon(n - 1).asPoint())) { diff --git a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationWPC.kt b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationWPC.kt index 94c508ec..4f82c9b5 100644 --- a/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationWPC.kt +++ b/app/src/main/java/joshuatee/wx/notifications/UtilityNotificationWPC.kt @@ -21,7 +21,6 @@ package joshuatee.wx.notifications -import joshuatee.wx.MyApplication import joshuatee.wx.R import joshuatee.wx.settings.Location import joshuatee.wx.spc.SpcMcdWatchShowActivity @@ -41,7 +40,7 @@ import joshuatee.wx.settings.NotificationPreferences internal object UtilityNotificationWpc { - fun locationNeedsMpd() = (0 until Location.numLocations).any { MyApplication.locations.getOrNull(it)?.notificationWpcMpd ?: false } + fun locationNeedsMpd() = (0 until Location.numLocations).any { Location.locations.getOrNull(it)?.notificationWpcMpd ?: false } fun sendMpdLocationNotifications(context: Context): String { val textMcd = ObjectPolygonWatch.polygonDataByType[MPD]!!.latLonList.value @@ -59,7 +58,7 @@ internal object UtilityNotificationWpc { val polygon2 = poly2.build() (1..Location.numLocations).forEach { n -> val locNum = n.toString() - if (MyApplication.locations[n - 1].notificationWpcMpd) { + if (Location.locations[n - 1].notificationWpcMpd) { // if location is watching for MCDs pull ib lat/lon and iterate over polygons // call secondary method to send notification if required val contains = polygon2.contains(Location.getLatLon(n - 1).asPoint()) @@ -89,7 +88,7 @@ internal object UtilityNotificationWpc { ) val cancelStr = "wpcmpdloc$mdNo$locNum" if (!(NotificationPreferences.alertOnlyOnce && UtilityNotificationUtils.checkToken(context, cancelStr))) { - val sound = MyApplication.locations[locNumInt].sound && !inBlackout + val sound = Location.locations[locNumInt].sound && !inBlackout val objectNotification = ObjectNotification( context, sound, diff --git a/app/src/main/java/joshuatee/wx/objects/ObjectPolygonWatch.kt b/app/src/main/java/joshuatee/wx/objects/ObjectPolygonWatch.kt index e984efcd..c43ddbce 100644 --- a/app/src/main/java/joshuatee/wx/objects/ObjectPolygonWatch.kt +++ b/app/src/main/java/joshuatee/wx/objects/ObjectPolygonWatch.kt @@ -22,7 +22,6 @@ package joshuatee.wx.objects import android.content.Context -import joshuatee.wx.common.GlobalVariables import joshuatee.wx.util.* class ObjectPolygonWatch(val context: Context, val type: PolygonType) { diff --git a/app/src/main/java/joshuatee/wx/radar/AwcRadarMosaicActivity.kt b/app/src/main/java/joshuatee/wx/radar/AwcRadarMosaicActivity.kt index 91d23f37..ea946ea5 100644 --- a/app/src/main/java/joshuatee/wx/radar/AwcRadarMosaicActivity.kt +++ b/app/src/main/java/joshuatee/wx/radar/AwcRadarMosaicActivity.kt @@ -46,7 +46,7 @@ class AwcRadarMosaicActivity : VideoRecordActivity() { private var animRan = false private var animDrawable = AnimationDrawable() - private lateinit var img: ObjectTouchImageView + private lateinit var image: TouchImage private var bitmap = UtilityImg.getBlankBitmap() private lateinit var objectNavDrawer: ObjectNavDrawer private val prefImagePosition = "AWCRADARMOSAIC" @@ -64,10 +64,10 @@ class AwcRadarMosaicActivity : VideoRecordActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_image_show_navdrawer, R.menu.awcmosaic, iconsEvenlySpaced = true, bottomToolbar = false) objectNavDrawer = ObjectNavDrawer(this, UtilityAwcRadarMosaic.labels, UtilityAwcRadarMosaic.sectors) { getContent(product) } - img = ObjectTouchImageView(this, toolbar, R.id.iv, objectNavDrawer, "") + image = TouchImage(this, toolbar, R.id.iv, objectNavDrawer, "") toolbar.setOnClickListener { objectNavDrawer.open() } - img.setMaxZoom(8.0f) - img.setListener(objectNavDrawer) { getContent(product) } + image.setMaxZoom(8.0f) + image.setListener(objectNavDrawer) { getContent(product) } sector = Utility.readPref(this, prefTokenSector, sector) product = Utility.readPref(this, prefTokenProduct, product) objectNavDrawer.index = UtilityAwcRadarMosaic.sectors.indexOf(sector) @@ -87,9 +87,9 @@ class AwcRadarMosaicActivity : VideoRecordActivity() { } private fun showImage() { - img.setBitmap(bitmap) + image.setBitmap(bitmap) animRan = false - img.firstRunSetZoomPosn(prefImagePosition) + image.firstRunSetZoomPosn(prefImagePosition) Utility.writePref(this, prefTokenSector, objectNavDrawer.url) Utility.writePref(this, prefTokenProduct, product) } @@ -97,21 +97,21 @@ class AwcRadarMosaicActivity : VideoRecordActivity() { private fun getAnimate() { FutureVoid(this, { animDrawable = UtilityAwcRadarMosaic.getAnimation(this, objectNavDrawer.url, product) }) - { animRan = UtilityImgAnim.startAnimation(animDrawable, img) } + { animRan = UtilityImgAnim.startAnimation(animDrawable, image) } } override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - objectNavDrawer.actionBarDrawerToggle.syncState() + objectNavDrawer.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - objectNavDrawer.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawer.onConfigurationChanged(newConfig) } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawer.onOptionsItemSelected(item)) { return true } when (item.itemId) { @@ -142,7 +142,7 @@ class AwcRadarMosaicActivity : VideoRecordActivity() { } override fun onStop() { - img.imgSavePosnZoom(prefImagePosition) + image.imgSavePosnZoom(prefImagePosition) super.onStop() } } diff --git a/app/src/main/java/joshuatee/wx/radar/Hail.kt b/app/src/main/java/joshuatee/wx/radar/Hail.kt index 78c92c93..a45c40b1 100644 --- a/app/src/main/java/joshuatee/wx/radar/Hail.kt +++ b/app/src/main/java/joshuatee/wx/radar/Hail.kt @@ -7,16 +7,18 @@ Made by ELY M. package joshuatee.wx.radar -class Hail internal constructor(hailicon: String, hailsize: String, lat: Double, lon: Double) { - var hailicon: String = "" - var hailsize: String = "" +class Hail internal constructor(hailIcon: String, hailSize: String, hailSizeNumber: Double, lat: Double, lon: Double) { + var hailIcon: String = "" + var hailSize: String = "" + var hailSizeNumber = 0.0 var lat: Double = 0.0 var lon: Double = 0.0 init { - this.hailicon = hailicon - this.hailsize = hailsize + this.hailIcon = hailIcon + this.hailSize = hailSize + this.hailSizeNumber = hailSizeNumber this.lat = lat this.lon = lon } diff --git a/app/src/main/java/joshuatee/wx/radar/ObjectOglBuffers.kt b/app/src/main/java/joshuatee/wx/radar/ObjectOglBuffers.kt index 6f28ff06..a4302a48 100644 --- a/app/src/main/java/joshuatee/wx/radar/ObjectOglBuffers.kt +++ b/app/src/main/java/joshuatee/wx/radar/ObjectOglBuffers.kt @@ -73,6 +73,7 @@ open class ObjectOglBuffers() { var type = PolygonType.NONE var geotype = GeographyType.NONE var warningType: ObjectPolygonWarning? = null + var hailIcon: String = "hailunknown.png" constructor(type: PolygonType) : this() { this.type = type } diff --git a/app/src/main/java/joshuatee/wx/radar/RadarMosaicNwsActivity.kt b/app/src/main/java/joshuatee/wx/radar/RadarMosaicNwsActivity.kt index 70be33d0..44ebce4b 100644 --- a/app/src/main/java/joshuatee/wx/radar/RadarMosaicNwsActivity.kt +++ b/app/src/main/java/joshuatee/wx/radar/RadarMosaicNwsActivity.kt @@ -50,7 +50,7 @@ class RadarMosaicNwsActivity : VideoRecordActivity() { private var animRan = false private var animDrawable = AnimationDrawable() - private lateinit var img: ObjectTouchImageView + private lateinit var image: TouchImage private var bitmap = UtilityImg.getBlankBitmap() private lateinit var objectNavDrawer: ObjectNavDrawer private val prefImagePosition = "RADARMOSAICNWS" @@ -71,14 +71,14 @@ class RadarMosaicNwsActivity : VideoRecordActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_image_show_navdrawer, R.menu.radarnwsmosaic, iconsEvenlySpaced = true, bottomToolbar = false) - val activityArguments = intent.getStringArrayExtra(URL)!! + val arguments = intent.getStringArrayExtra(URL)!! objectNavDrawer = ObjectNavDrawer(this, UtilityNwsRadarMosaic.labels, UtilityNwsRadarMosaic.sectors) { getContent() } - img = ObjectTouchImageView(this, toolbar, R.id.iv, objectNavDrawer, "") + image = TouchImage(this, toolbar, R.id.iv, objectNavDrawer, "") toolbar.setOnClickListener { objectNavDrawer.open() } - img.setMaxZoom(8.0f) - img.setListener(objectNavDrawer) { getContent() } - if (activityArguments.isNotEmpty() && activityArguments[0] != "") { - sector = activityArguments[0] + image.setMaxZoom(8.0f) + image.setListener(objectNavDrawer) { getContent() } + if (arguments.isNotEmpty() && arguments[0] != "") { + sector = arguments[0] } // sector = Utility.readPref(this, prefTokenSector, sector) objectNavDrawer.index = UtilityNwsRadarMosaic.sectors.indexOf(sector) @@ -100,9 +100,9 @@ class RadarMosaicNwsActivity : VideoRecordActivity() { } private fun showImage() { - img.setBitmap(bitmap) + image.setBitmap(bitmap) animRan = false - img.firstRunSetZoomPosn(prefImagePosition) + image.firstRunSetZoomPosn(prefImagePosition) Utility.writePref(this, prefTokenSector, objectNavDrawer.url) } @@ -114,22 +114,22 @@ class RadarMosaicNwsActivity : VideoRecordActivity() { animateButton.setIcon(GlobalVariables.ICON_STOP_WHITE) FutureVoid(this, { animDrawable = UtilityNwsRadarMosaic.getAnimation(this, objectNavDrawer.url) }) - { animRan = UtilityImgAnim.startAnimation(animDrawable, img) } + { animRan = UtilityImgAnim.startAnimation(animDrawable, image) } } } override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - objectNavDrawer.actionBarDrawerToggle.syncState() + objectNavDrawer.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - objectNavDrawer.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawer.onConfigurationChanged(newConfig) } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawer.onOptionsItemSelected(item)) { return true } when (item.itemId) { @@ -152,7 +152,7 @@ class RadarMosaicNwsActivity : VideoRecordActivity() { } override fun onStop() { - img.imgSavePosnZoom(prefImagePosition) + image.imgSavePosnZoom(prefImagePosition) super.onStop() } } diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityHail.kt b/app/src/main/java/joshuatee/wx/radar/UtilityHail.kt new file mode 100644 index 00000000..23e31c8d --- /dev/null +++ b/app/src/main/java/joshuatee/wx/radar/UtilityHail.kt @@ -0,0 +1,67 @@ +/* + + 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 . + +*/ +//modded by ELY M. + +package joshuatee.wx.radar + +import android.content.Context +import android.preference.PreferenceManager +import joshuatee.wx.MyApplication +import joshuatee.wx.objects.DistanceUnit +import joshuatee.wx.util.Utility +import joshuatee.wx.util.UtilityLog +import java.util.regex.Pattern + + +object UtilityHail { + internal var hailList = mutableListOf() + private var initialized = false + private var tmpsize = 1 + internal var x = DoubleArray(1) + internal var y = DoubleArray(1) + var hailIcon: String = "" + var hailSize: String = "" + var hailSizeNumber = 0.0 + var lat: Double = 0.0 + var lon: Double = 0.0 + + + + + val hailData: MutableList + get() { + if (!initialized) { + hailList = mutableListOf() + UtilityLog.d("hailList", "Got hailList values: ") + hailList.add( + Hail(hailIcon, hailSize, hailSizeNumber, lat, lon)) + initialized = true + } + + return hailList + } + + + + + + +} diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityRadarUI.kt b/app/src/main/java/joshuatee/wx/radar/UtilityRadarUI.kt index 32c401bd..d32b2c6a 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityRadarUI.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityRadarUI.kt @@ -34,7 +34,7 @@ import joshuatee.wx.ui.ObjectImageMap import joshuatee.wx.util.* import kotlin.math.roundToInt import joshuatee.wx.Extensions.* -import joshuatee.wx.MyApplication +import joshuatee.wx.MyApplication //elys mod //need context... import joshuatee.wx.objects.* import joshuatee.wx.settings.RadarPreferences @@ -143,11 +143,12 @@ internal object UtilityRadarUI { longPressList.add("Nearest observation: " + obsSite.name + " (" + obsSite.distance.roundToInt() + " mi)") longPressList.add("Nearest forecast: $latLonTitle") longPressList.add("Nearest meteogram: " + obsSite.name) - if (RadarPreferences.radarSpotters || RadarPreferences.radarSpottersLabel) longPressList.add("Spotter Info") + //elys mod longPressList.add("Current radar status message: " + wxglRender.rid) - val getridpoint: String = UtilityLocation.getNearestRadarSite(LatLon(pointX.toString(), pointY.toString())) - longPressList.add("Nearest radar status message: " + getridpoint) - longPressList.add("Userpoint info: " + latLonTitle) + val getridpoint: String = UtilityLocation.getNearestRadarSite(LatLon(pointX.toString(), pointY.toString())) + longPressList.add("Nearest radar status message: " + getridpoint) + if (RadarPreferences.radarSpotters || RadarPreferences.radarSpottersLabel) longPressList.add("Spotter Info") + longPressList.add("Userpoint info: " + latLonTitle) longPressList.add("Add userpoint for: " + latLonTitle) longPressList.add("Delete userpoint for: " + latLonTitle) longPressList.add("Delete all userpoints") @@ -305,7 +306,7 @@ internal object UtilityRadarUI { //elys mod if (PolygonType.USERPOINTS.pref && !archiveMode) wxglRender.constructUserPoints() else wxglRender.deconstructUserPoints() - if (imageMap != null && imageMap.map.visibility != View.VISIBLE) { + if (imageMap != null && imageMap.visibility != View.VISIBLE) { paneList.forEach { wxglSurfaceViews[it].visibility = View.VISIBLE } } } diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityUserPoints.kt b/app/src/main/java/joshuatee/wx/radar/UtilityUserPoints.kt index 22104f97..f6ed8e69 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityUserPoints.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityUserPoints.kt @@ -36,8 +36,6 @@ object UtilityUserPoints { internal var name = "" private var initialized = false private var tmpsize = 1 - private const val REFRESH_LOC_MIN = 1 - private var lastRefresh = 0.toLong() internal var x = DoubleArray(1) private set internal var y = DoubleArray(1) @@ -49,12 +47,7 @@ object UtilityUserPoints { val userPointsData: MutableList get() { - var currentTime = System.currentTimeMillis() - val currentTimeSec = currentTime / 1000 - //val refreshIntervalSec = (REFRESH_LOC_MIN * 60).toLong() - //val currentTimeSec = currentTime / 1000 - val refreshIntervalSec = (REFRESH_LOC_MIN * 60).toLong() - if (currentTimeSec > lastRefresh + refreshIntervalSec || !initialized) { + if (!initialized) { userPointsList = mutableListOf() val latAl = mutableListOf() val lonAl = mutableListOf() @@ -90,19 +83,17 @@ object UtilityUserPoints { latAl.indices.forEach { x[it] = latAl[it].toDoubleOrNull() ?: 0.0 y[it] = -1.0 * (lonAl[it].toDoubleOrNull() ?: 0.0) - UtilityLog.d("userpoint", "Userpoint latlon: x: " + x[it] + " y: " + x[it]) + UtilityLog.d("userpoint", "haillist latlon: x: " + x[it] + " y: " + x[it]) } } else { - UtilityLog.d("userpoint", "Userpoint latlon: set to 0.0 :(") + UtilityLog.d("userpoint", "haillist latlon: set to 0.0 :(") x = DoubleArray(1) y = DoubleArray(1) x[0] = 0.0 y[0] = 0.0 } initialized = true - currentTime = System.currentTimeMillis() - lastRefresh = currentTime / 1000 } } } diff --git a/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerf.kt b/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerf.kt index a31cd242..d9673f0f 100644 --- a/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerf.kt +++ b/app/src/main/java/joshuatee/wx/radar/UtilityWXOGLPerf.kt @@ -609,7 +609,7 @@ internal object UtilityWXOGLPerf { } catch (e: Exception) { UtilityLog.handleException(e) } } -//elys mods + //elys mods fun genConus(buffers: ObjectOglBuffers, pn: ProjectionNumbers, x: Double, y: Double) { buffers.setToPositionZero() val pixYD: Float @@ -653,7 +653,7 @@ internal object UtilityWXOGLPerf { } } - //for tvs / hi imagees + //for tvs / hi images fun genMarkerList(buffers: ObjectOglBuffers, pn: ProjectionNumbers, x: DoubleArray, y: DoubleArray) { var pointX: Double var pointY: Double diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel3HailIndex.kt b/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel3HailIndex.kt index 327e2c5b..25cbed21 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel3HailIndex.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLNexradLevel3HailIndex.kt @@ -29,12 +29,12 @@ import joshuatee.wx.external.ExternalGlobalCoordinates import joshuatee.wx.Extensions.* import joshuatee.wx.settings.UtilityLocation import joshuatee.wx.util.UtilityLog +import java.io.File import java.util.regex.Pattern internal object WXGLNexradLevel3HailIndex { private const val hiBaseFn = "nids_hi_tab" - private const val markerSize = 0.015 var hailList = mutableListOf() private val pattern1: Pattern = Pattern.compile("AZ/RAN(.*?)V") @@ -43,35 +43,10 @@ internal object WXGLNexradLevel3HailIndex { private val pattern4: Pattern = Pattern.compile("[0-9]*\\.?[0-9]+") private val pattern5: Pattern = Pattern.compile("\\d+") + var hailSizeNumber = 0.0 + var hailSizeText = "Unknown" + var hailSizeIcon = "hailunknown.png" -/* - val hailData: MutableList - get() { - var currentTime = System.currentTimeMillis() - val currentTimeSec = currentTime / 1000 - val refreshIntervalSec = (REFRESH_LOC_MIN * 60).toLong() - if (currentTimeSec > lastRefresh + refreshIntervalSec || !initialized) { - hailList = mutableListOf() - - - hailList.add( - Spotter( - tmpArr[0], - tmpArr[1], - tmpArr[2], - tmpArr[3], - ) - ) - - } - - initialized = true - currentTime = System.currentTimeMillis() - lastRefresh = currentTime / 1000 - - return hailList - } -*/ fun decodeAndPlot(context: Context, radarSite: String, fnSuffix: String): List { val fileName = hiBaseFn + fnSuffix @@ -79,7 +54,7 @@ internal object WXGLNexradLevel3HailIndex { val location = UtilityLocation.getSiteLocation(radarSite) //make sure we clear the list or we get duplicate texts hailList.clear() - //File("/sdcard/wX/hail2").copyTo(File("/data/user/0/joshuatee.wx/files/nids_hi_tab0"), true); + ///File("/sdcard/wX/hailtest").copyTo(File("/data/user/0/joshuatee.wx/files/nids_hi_tab0"), true) WXGLDownload.getNidsTab(context, "HI", radarSite, fileName) val posn: List val hailPercent: List @@ -116,9 +91,10 @@ internal object WXGLNexradLevel3HailIndex { var k = 0 // k is used to track hail size which is /2 of other 2 arrays for (s in posnNumbers.indices step 2) { val hailSizeDbl = hailSizeNumbers[k].toDoubleOrNull() ?: 0.0 - var hailSizeText = "unknown" - UtilityLog.d("wx", "hailSizeNumbers: "+hailSizeDbl) - UtilityLog.d("wx", "hailPercentNumbers: "+hailPercentNumbers[s].toIntOrNull()) + //var hailSizeText = "Unknown" + //var hailSizeIcon = "hailunknown.png" + //UtilityLog.d("hailindex", "hailSizeNumbers: "+hailSizeDbl) + //UtilityLog.d("hailindex", "hailPercentNumbers: "+hailPercentNumbers[s].toIntOrNull()) if (hailSizeDbl > 0.24 && ((hailPercentNumbers[s].toIntOrNull() ?: 0) > 60 || (hailPercentNumbers[s + 1].toDoubleOrNull() ?: 0.0) > 60)) { val ecc = ExternalGeodeticCalculator() val degree = posnNumbers[s].toDoubleOrNull() ?: 0.0 @@ -150,64 +126,79 @@ internal object WXGLNexradLevel3HailIndex { */ + hailSizeText = hailSizeDbl.toString() + if (hailSizeDbl > 0.24) { + hailSizeNumber = 0.25 hailSizeText = "0.25" - WXGLRender.hailSizeIcon = "hail05.png" + hailSizeIcon = "hail05.png" } if (hailSizeDbl > 0.49) { + hailSizeNumber = 0.50 hailSizeText = "0.50" - WXGLRender.hailSizeIcon = "hail0.png" + hailSizeIcon = "hail0.png" } if (hailSizeDbl > 0.74) { + hailSizeNumber = 0.75 hailSizeText = "0.75" - WXGLRender.hailSizeIcon = "hail0.png" + hailSizeIcon = "hail0.png" } if (hailSizeDbl > 0.99) { + hailSizeNumber = 1.00 hailSizeText = "1.00" - WXGLRender.hailSizeIcon = "hail1.png" + hailSizeIcon = "hail1.png" } if (hailSizeDbl > 1.49) { + hailSizeNumber = 1.50 hailSizeText = "1.50" - WXGLRender.hailSizeIcon = "hail1.png" + hailSizeIcon = "hail1.png" } if (hailSizeDbl > 1.99) { + hailSizeNumber = 2.00 hailSizeText = "2.00" - WXGLRender.hailSizeIcon = "hail2.png" + hailSizeIcon = "hail2.png" } if (hailSizeDbl > 2.49) { + hailSizeNumber = 2.50 hailSizeText = "2.50" - WXGLRender.hailSizeIcon = "hail2.png" + hailSizeIcon = "hail2.png" } if (hailSizeDbl > 2.99) { + hailSizeNumber = 3.00 hailSizeText = "3.00" - WXGLRender.hailSizeIcon = "hail3.png" + hailSizeIcon = "hail3.png" } if (hailSizeDbl > 3.49) { + hailSizeNumber = 3.50 hailSizeText = "3.50" - WXGLRender.hailSizeIcon = "hail3.png" + hailSizeIcon = "hail3.png" } if (hailSizeDbl > 3.99) { + hailSizeNumber = 4.00 hailSizeText = "4.00" - WXGLRender.hailSizeIcon = "hail4.png" + hailSizeIcon = "hail4.png" } if (hailSizeDbl > 4.49) { + hailSizeNumber = 4.50 hailSizeText = "4.50" - WXGLRender.hailSizeIcon = "hail4.png" + hailSizeIcon = "hail4.png" } - //TODO add big hail --- only use 1 icon for any hail over 5 inch + //big hail --- only use 1 icon for any hail over 5 inch if (hailSizeDbl > 4.99) { + hailSizeNumber = 5.00 hailSizeText = "Big Hail!" - WXGLRender.hailSizeIcon = "hailbig.png" + hailSizeIcon = "hailbig.png" } - hailList.add(Hail(WXGLRender.hailSizeIcon, hailSizeText, ec.latitude, ec.longitude * -1.0)) + hailList.add(Hail(hailSizeIcon, hailSizeText, hailSizeNumber, ec.latitude, ec.longitude * -1.0)) - UtilityLog.d("wx", "hailSizeIcon: "+WXGLRender.hailSizeIcon) - UtilityLog.d("wx", "hailSizeText: "+hailSizeText) - UtilityLog.d("wx", "hailSizeDbl: "+hailSizeDbl) + UtilityLog.d("hailindex", "hailSizeIcon: "+hailSizeIcon) + UtilityLog.d("hailindex", "hailSizeText: "+hailSizeText) + UtilityLog.d("hailindex", "hailSizeNumber: "+hailSizeNumber) + UtilityLog.d("hailindex", "hailSizeDbl: "+hailSizeDbl) diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivity.kt b/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivity.kt index 6cbba7b4..3d06df45 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivity.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivity.kt @@ -185,24 +185,24 @@ class WXGLRadarActivity : VideoRecordActivity(), OnMenuItemClickListener { isGetContentInProgress = false locXCurrent = joshuatee.wx.settings.Location.x locYCurrent = joshuatee.wx.settings.Location.y - val activityArguments = intent.getStringArrayExtra(RID) + val arguments = intent.getStringArrayExtra(RID) paneList = (0 until numberOfPanes).toList() UtilityFileManagement.deleteCacheFiles(this) // for L2 archive called from storm reports - if (activityArguments != null) { - if (activityArguments.size > 6) { - urlStr = activityArguments[4] - locXCurrent = activityArguments[5] - locYCurrent = activityArguments[6] + if (arguments != null) { + if (arguments.size > 6) { + urlStr = arguments[4] + locXCurrent = arguments[5] + locYCurrent = arguments[6] archiveMode = true - } else if (activityArguments.size > 4) { - spotterId = activityArguments[4] + } else if (arguments.size > 4) { + spotterId = arguments[4] spotterShowSelected = true } - if (activityArguments.size > 3) { + if (arguments.size > 3) { fixedSite = true } - if (activityArguments.size < 7) { + if (arguments.size < 7) { archiveMode = false } } @@ -239,8 +239,9 @@ class WXGLRadarActivity : VideoRecordActivity(), OnMenuItemClickListener { menu.findItem(R.id.action_jellybean_drawtools).isVisible = false // disable new Level3 super-res until NWS is past deployment phase - //menu.findItem(R.id.action_n0b).isVisible = false - //menu.findItem(R.id.action_n0g).isVisible = false + //elys mod - I enabled those menus + menu.findItem(R.id.action_n0b).isVisible = true + menu.findItem(R.id.action_n0g).isVisible = true delay = UtilityImg.animInterval(this) img = findViewById(R.id.iv) @@ -267,17 +268,17 @@ class WXGLRadarActivity : VideoRecordActivity(), OnMenuItemClickListener { ) wxglRender.product = "N0Q" oglInView = true - if (activityArguments == null) { + if (arguments == null) { wxglRender.rid = joshuatee.wx.settings.Location.rid } else { - wxglRender.rid = activityArguments[0] + wxglRender.rid = arguments[0] } // hack, in rare cases a user will save a location that doesn't pick up RID if (wxglRender.rid == "") { wxglRender.rid = "TLX" } - if (activityArguments != null && activityArguments.size > 2) { - wxglRender.product = activityArguments[2] + if (arguments != null && arguments.size > 2) { + wxglRender.product = arguments[2] if (wxglRender.product == "N0R") { wxglRender.product = "N0Q" } @@ -337,7 +338,7 @@ class WXGLRadarActivity : VideoRecordActivity(), OnMenuItemClickListener { restarted = true restartedZoom = true paneList.forEach { - if (objectImageMap.map.visibility == View.GONE) { + if (objectImageMap.visibility == View.GONE) { wxglTextObjects[it].initializeLabels(this) wxglTextObjects[it].addLabels() } @@ -1161,7 +1162,7 @@ class WXGLRadarActivity : VideoRecordActivity(), OnMenuItemClickListener { private fun showMap() { objectImageMap.toggleMap() - if (objectImageMap.map.visibility != View.GONE) { + if (objectImageMap.visibility != View.GONE) { UtilityWXGLTextObject.hideLabels(numberOfPanes, wxglTextObjects) } else { UtilityWXGLTextObject.showLabels(numberOfPanes, wxglTextObjects) diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivityMultiPane.kt b/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivityMultiPane.kt index 16290620..dab4b881 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivityMultiPane.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLRadarActivityMultiPane.kt @@ -133,15 +133,15 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { - val activityArguments = intent.getStringArrayExtra(RID) - if (activityArguments != null && activityArguments.size > 3 ) { - if (activityArguments[3] == "true") { // invoked from single pane radar + val arguments = intent.getStringArrayExtra(RID) + if (arguments != null && arguments.size > 3 ) { + if (arguments[3] == "true") { // invoked from single pane radar doNotSavePref = true useSinglePanePref = true } } landScape = UtilityUI.isLandScape(this) - numberOfPanes = activityArguments!![2].toIntOrNull() ?: 0 + numberOfPanes = arguments!![2].toIntOrNull() ?: 0 panesList = (0 until numberOfPanes).toList() UtilityFileManagement.deleteCacheFiles(this) isGetContentInProgress = false @@ -235,11 +235,11 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene menu.findItem(R.id.action_tilt_blank).isVisible = false menu.findItem(R.id.action_tools_blank).isVisible = false } - - //elys mod - I enabled those menus + // disable new Level3 super-res until NWS is past deployment phase - //menu.findItem(R.id.action_n0b).isVisible = false - //menu.findItem(R.id.action_n0g).isVisible = false + //elys mod - I enabled those menus + menu.findItem(R.id.action_n0b).isVisible = true + menu.findItem(R.id.action_n0g).isVisible = true delay = UtilityImg.animInterval(this) panesList.forEach { @@ -308,8 +308,8 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene objectImageMap.addClickHandler(::ridMapSwitch, UtilityImageMap::mapToRid) oglInView = true panesList.forEach { - var initialRadarSite = activityArguments[0] - if (activityArguments[0] == "") { + var initialRadarSite = arguments[0] + if (arguments[0] == "") { initialRadarSite = joshuatee.wx.settings.Location.rid } if (!useSinglePanePref) { @@ -411,7 +411,7 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene animateButton.title = animateButtonPlayString restartedZoom = true panesList.forEach { - if (objectImageMap.map.visibility == View.GONE) { + if (objectImageMap.visibility == View.GONE) { wxglTextObjects[it].initializeLabels(this) wxglTextObjects[it].addLabels() } @@ -786,7 +786,7 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene R.id.action_TDWR -> alertDialogTdwr() R.id.action_ridmap -> { objectImageMap.toggleMap() - oglInView = if (objectImageMap.map.visibility != View.GONE) { + oglInView = if (objectImageMap.visibility != View.GONE) { UtilityWXGLTextObject.hideLabels(numberOfPanes, wxglTextObjects) false } else { @@ -1158,7 +1158,7 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene private fun showMap() { objectImageMap.toggleMap() - if (objectImageMap.map.visibility != View.GONE) { + if (objectImageMap.visibility != View.GONE) { UtilityWXGLTextObject.hideLabels(numberOfPanes, wxglTextObjects) } else { UtilityWXGLTextObject.showLabels(numberOfPanes, wxglTextObjects) diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLRender.kt b/app/src/main/java/joshuatee/wx/radar/WXGLRender.kt index b1fa7ffc..fca131f8 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLRender.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLRender.kt @@ -69,8 +69,6 @@ class WXGLRender(private val context: Context, val paneNumber: Int) : Renderer { const val ortIntGlobal = 400 var oneDegreeScaleFactorGlobal = 0.0f private set - var hailSizeIcon = "hail0.png" - var hailSize = 0.toDouble() var degreesPerPixellat = -0.017971305190311 //had - var degreesPerPixellon = 0.017971305190311 @@ -464,15 +462,37 @@ class WXGLRender(private val context: Context, val paneNumber: Int) : Renderer { } } - - if (zoom > hiBuffers.scaleCutOff) { - drawHI(hiBuffers) + //elys mod - hailmod +/* + //picked one of images :( + listOf(hiBuffers).forEach { + if (zoom > it.scaleCutOff) { + drawHI(it, it.hailIcon) + Log.i("haildraw", "hail it: " +it) + Log.i("haildraw", "hailicon: " + it.hailIcon) } + } +*/ + + + //images overlaying :( + WXGLNexradLevel3HailIndex.hailList.indices.forEach { + if (zoom > hiBuffers.scaleCutOff) { + drawHI(hiBuffers, WXGLNexradLevel3HailIndex.hailList[it].hailIcon) + Log.i("haildraw", "hail it: " + it) + Log.i("haildraw", "hailicon: " + WXGLNexradLevel3HailIndex.hailList[it].hailIcon) + } + } + - if (zoom > tvsBuffers.scaleCutOff) { - drawTVS(tvsBuffers) + + listOf(tvsBuffers).forEach { + if (zoom > it.scaleCutOff) { + drawTVS(it) + } } + GLES20.glLineWidth(3.0f) listOf(stiBuffers, wbGustsBuffers, wbBuffers).forEach { if (zoom > it.scaleCutOff) { @@ -493,8 +513,10 @@ class WXGLRender(private val context: Context, val paneNumber: Int) : Renderer { if (RadarPreferences.radarUserPoints) { + listOf(userPointsBuffers).forEach { if (zoom > userPointsBuffers.scaleCutOff) { - drawUserPoints(userPointsBuffers) + drawUserPoints(it) + } } } @@ -532,8 +554,6 @@ class WXGLRender(private val context: Context, val paneNumber: Int) : Renderer { wpcFrontBuffersList.forEach { drawElement(it) } } - - } //displayhold @@ -892,7 +912,8 @@ class WXGLRender(private val context: Context, val paneNumber: Int) : Renderer { } //FIXME need to pick a icon based on hail size// - private fun drawHI(buffers: ObjectOglBuffers) { + //elys mod - hailmod + private fun drawHI(buffers: ObjectOglBuffers, hailIcon: String) { if (buffers.isInitialized) { buffers.setToPositionZero() GLES20.glUseProgram(OpenGLShader.sp_loadimage) @@ -901,7 +922,7 @@ class WXGLRender(private val context: Context, val paneNumber: Int) : Renderer { sizeHandle = GLES20.glGetUniformLocation(OpenGLShader.sp_loadimage, "imagesize") GLES20.glUniform1f(sizeHandle, RadarPreferences.radarHiSize.toFloat()) iTexture = GLES20.glGetUniformLocation(OpenGLShader.sp_loadimage, "u_texture") - hiId = OpenGLShader.LoadTexture(GlobalVariables.FilesPath + hailSizeIcon) + hiId = OpenGLShader.LoadTexture(GlobalVariables.FilesPath + hailIcon) GLES20.glVertexAttribPointer(positionHandle, 2, GLES20.GL_FLOAT, false, 0, buffers.floatBuffer.slice().asFloatBuffer()) GLES20.glEnableVertexAttribArray(positionHandle) GLES20.glActiveTexture(GLES20.GL_TEXTURE0) @@ -915,8 +936,9 @@ class WXGLRender(private val context: Context, val paneNumber: Int) : Renderer { } - } + Log.i("hailicon in drawhi", "hailicon: " + hailIcon) + } // FIXME CRASHING HERE sometimes -- FIXED via "displayhold" code /* @@ -1271,19 +1293,36 @@ class WXGLRender(private val context: Context, val paneNumber: Int) : Renderer { spotterBuffers.isInitialized = false } + //elys mod - hailmod fun constructHi() { hiBuffers.lenInit = 0f //RadarPreferences.radarHiSize.toFloat() val stormList = WXGLNexradLevel3HailIndex.decodeAndPlot(context, rid, indexString) hiBuffers.setXYList(stormList) + hiBuffers.hailIcon = WXGLNexradLevel3HailIndex.hailSizeIcon WXGLNexradLevel3HailIndex.hailList constructMarker(hiBuffers) + + //Log.i("hailconst", "hail size: " + WXGLNexradLevel3HailIndex.hailSizeText) + //Log.i("hailconst", "hail setIcon: " + WXGLNexradLevel3HailIndex.hailSizeIcon) + //Log.i("hailconst", "hail setDouble: " + WXGLNexradLevel3HailIndex.hailSizeNumber) +/* + WXGLNexradLevel3HailIndex.hailList.indices.forEach { + + hiBuffers.hailIcon = WXGLNexradLevel3HailIndex.hailList[it].hailIcon + Log.i("hailconst", "hailSize: " + WXGLNexradLevel3HailIndex.hailList[it].hailSize) + Log.i("hailconst", "hailIcon: " + WXGLNexradLevel3HailIndex.hailList[it].hailIcon) + Log.i("hailconst", "hailSizeNumber: " + WXGLNexradLevel3HailIndex.hailList[it].hailSizeNumber) + constructMarker(hiBuffers) + } +*/ + } fun deconstructHi() { hiBuffers.isInitialized = false } - + //elys mod fun constructUserPoints() { userPointsBuffers.lenInit = 0f UtilityUserPoints.userPointsData diff --git a/app/src/main/java/joshuatee/wx/radar/WXGLTextObject.kt b/app/src/main/java/joshuatee/wx/radar/WXGLTextObject.kt index 566d1295..b060436b 100644 --- a/app/src/main/java/joshuatee/wx/radar/WXGLTextObject.kt +++ b/app/src/main/java/joshuatee/wx/radar/WXGLTextObject.kt @@ -26,6 +26,7 @@ import android.content.Context import android.graphics.Color import android.util.TypedValue import android.view.View +import android.widget.ImageView import android.widget.RelativeLayout import android.widget.TextView import joshuatee.wx.MyApplication @@ -38,7 +39,6 @@ import joshuatee.wx.objects.ProjectionType import joshuatee.wx.settings.RadarPreferences import joshuatee.wx.util.ProjectionNumbers import joshuatee.wx.util.UtilityCanvasProjection -import joshuatee.wx.util.UtilityLog import kotlin.math.* @@ -238,9 +238,9 @@ class WXGLTextObject( WXGLNexradLevel3HailIndex.hailList.indices.forEach { checkAndDrawText( wxglSurfaceView.hailLabels, - WXGLNexradLevel3HailIndex.hailList[it].lat - 0.130 / wxglRender.zoom, //move down to under HI icon + WXGLNexradLevel3HailIndex.hailList[it].lat - 0.163 / wxglRender.zoom, //move down to under HI icon WXGLNexradLevel3HailIndex.hailList[it].lon, - WXGLNexradLevel3HailIndex.hailList[it].hailsize, + WXGLNexradLevel3HailIndex.hailList[it].hailSize, RadarPreferences.radarColorHiText ) } @@ -260,80 +260,6 @@ class WXGLTextObject( } } - private fun addHail() { - projectionNumbers = ProjectionNumbers(wxglRender.rid, ProjectionType.WX_OGL) - var foundhail: Boolean = false - var hailLat: Double - var hailLon: Double - wxglSurfaceView.hailTextView = mutableListOf() - var aa = 0 - - UtilityLog.d("wx", "hailList.size: "+WXGLNexradLevel3HailIndex.hailList.size) - - if (WXGLNexradLevel3HailIndex.hailList.size < 0) { - UtilityLog.d("wx", "haillist < 0") - foundhail = true - } - - while (aa < WXGLNexradLevel3HailIndex.hailList.size) { - aa += 1 - } - - if (foundhail) { - UtilityLog.d("wx", "hail found") - hailLat = WXGLNexradLevel3HailIndex.hailList[aa].lat //move down abit - hailLon = WXGLNexradLevel3HailIndex.hailList[aa].lon - - scale = getScale() - oglrZoom = 1.0f - if (wxglRender.zoom < 1.0f) { - oglrZoom = wxglRender.zoom * 0.8f - } - if (wxglRender.zoom > 0.5) { - showHail() - for (c in 0 until 1) { - val drawText = checkButDoNotDrawText( - wxglSurfaceView.hailTextView, - hailLat, - hailLon, //move down abit so can read - RadarPreferences.radarColorHiText, - UIPreferences.textSizeSmall * oglrZoom * 1.5f * RadarPreferences.radarHiTextSize - ) - if (drawText) { - wxglSurfaceView.hailTextView[c].text = WXGLNexradLevel3HailIndex.hailList[aa].hailsize - - } - } - } else { - hideHail() - } - - } //foundhail - - } - - private fun showHail() { - if (wxglSurfaceView.hailTextView.size > 0) { - var c = 0 - while (c < 1) { - wxglSurfaceView.hailTextView[c].visibility = View.VISIBLE - c += 1 - } - } - } - - private fun hideHail() { - if (hailSingleLabelTvArrInit) - if (wxglSurfaceView.hailTextView.size > 0) { - var c = 0 - while (c < wxglSurfaceView.hailTextView.size) { - wxglSurfaceView.hailTextView[c].visibility = View.GONE - c += 1 - } - } - } - - private fun checkAndDrawText(textViews: MutableList, lat: Double, lon: Double, text: String, color: Int) { val coordinates = UtilityCanvasProjection.computeMercatorNumbers(lat, lon, projectionNumbers) val renderX: Float diff --git a/app/src/main/java/joshuatee/wx/settings/ArrayAdapterSearchView.kt b/app/src/main/java/joshuatee/wx/settings/ArrayAdapterSearchView.kt index 9b18432b..61c0e0d9 100644 --- a/app/src/main/java/joshuatee/wx/settings/ArrayAdapterSearchView.kt +++ b/app/src/main/java/joshuatee/wx/settings/ArrayAdapterSearchView.kt @@ -17,9 +17,13 @@ class ArrayAdapterSearchView : SearchView { private var searchAutoComplete: SearchAutoComplete = findViewById(R.id.search_src_text) - constructor(context: Context) : super(context) { initialize() } + constructor(context: Context) : super(context) { + initialize() + } - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { initialize() } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { + initialize() + } private fun initialize() { this.setAdapter(null) @@ -28,9 +32,15 @@ class ArrayAdapterSearchView : SearchView { override fun setSuggestionsAdapter(adapter: CursorAdapter) {} - fun setOnItemClickListener(listener: AdapterView.OnItemClickListener?) { searchAutoComplete.onItemClickListener = listener } + fun setOnItemClickListener(listener: AdapterView.OnItemClickListener?) { + searchAutoComplete.onItemClickListener = listener + } - fun setAdapter(adapter: ArrayAdapter<*>?) { searchAutoComplete.setAdapter>(adapter) } + fun setAdapter(adapter: ArrayAdapter<*>?) { + searchAutoComplete.setAdapter>(adapter) + } - fun setText(text: String) { searchAutoComplete.setText(text) } + fun setText(text: String) { + searchAutoComplete.setText(text) + } } diff --git a/app/src/main/java/joshuatee/wx/settings/BottomSheetFragment.kt b/app/src/main/java/joshuatee/wx/settings/BottomSheetFragment.kt index 6a1adfce..854e220e 100644 --- a/app/src/main/java/joshuatee/wx/settings/BottomSheetFragment.kt +++ b/app/src/main/java/joshuatee/wx/settings/BottomSheetFragment.kt @@ -36,9 +36,14 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment import joshuatee.wx.ui.ObjectTextView import joshuatee.wx.util.Utility -class BottomSheetFragment(private val actContext: Context, val position: Int, private val topLabel: String, private val usedForLocation: Boolean) : BottomSheetDialogFragment() { +class BottomSheetFragment( + private val actContext: Context, + val position: Int, + private val topLabel: String, + private val usedForLocation: Boolean + ) : BottomSheetDialogFragment() { - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private lateinit var label: TextView lateinit var functions: List<(Int) -> Unit> lateinit var labelList: List @@ -62,7 +67,7 @@ class BottomSheetFragment(private val actContext: Context, val position: Int, pr label.setBackgroundColor(Color.BLACK) } } - linearLayout = fragmentView!!.findViewById(R.id.linearLayout) + box = fragmentView!!.findViewById(R.id.linearLayout) labelList.forEachIndexed { index, it -> val item = ObjectTextView(actContext, it) textViewList.add(item) @@ -78,7 +83,7 @@ class BottomSheetFragment(private val actContext: Context, val position: Int, pr functions[index](position) dismiss() } - linearLayout.addView(item.get()) + box.addView(item.get()) } return fragmentView } diff --git a/app/src/main/java/joshuatee/wx/settings/FavRemoveActivity.kt b/app/src/main/java/joshuatee/wx/settings/FavRemoveActivity.kt index cfb5b74d..cdffc224 100644 --- a/app/src/main/java/joshuatee/wx/settings/FavRemoveActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/FavRemoveActivity.kt @@ -58,8 +58,8 @@ class FavRemoveActivity : BaseActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_recyclerview_toolbar, null, false) - val activityArguments = intent.getStringArrayExtra(TYPE) - type = activityArguments!![0] + val arguments = intent.getStringArrayExtra(TYPE)!! + type = arguments[0] var verboseTitle = "" when (type) { "SND" -> { diff --git a/app/src/main/java/joshuatee/wx/settings/Location.kt b/app/src/main/java/joshuatee/wx/settings/Location.kt index e62cf407..1eb39175 100644 --- a/app/src/main/java/joshuatee/wx/settings/Location.kt +++ b/app/src/main/java/joshuatee/wx/settings/Location.kt @@ -22,7 +22,6 @@ package joshuatee.wx.settings import android.content.Context -import joshuatee.wx.MyApplication import joshuatee.wx.canada.UtilityCanada import joshuatee.wx.radar.LatLon import joshuatee.wx.util.Utility @@ -31,362 +30,261 @@ import joshuatee.wx.Extensions.* import joshuatee.wx.common.GlobalDictionaries import joshuatee.wx.util.UtilityString -// implement up/down mini fab in settings -// hide fabs if only one location -// if up arrow selected , read in j ( as B ) and j-1 ( as A ) provided j > 0 -// if down arrow selected , read in j ( as A ) and j+1 ( as B ) provided j < num_loc-2 -// handle corner cases later -// if up selected, write out A(j) and B(j-1) -// if down selected, write out A(j+1) and B(j) - -class Location(val context: Context, locNumInt: Int) { - - val x: String - val y: String - val name: String - private val countyCurrent: String - private val zoneCurrent: String - val wfo: String - val rid: String - val state: String - private val nwsStateCurrent: String - private val alertNotificationCurrent: String - private val alertNotificationRadarCurrent: String - private val alertCcNotificationCurrent: String - private val alertSevenDayNotificationCurrent: String - private val alertNotificationSoundCurrent: String - private val alertNotificationMcdCurrent: String - private val alertNotificationSwoCurrent: String - private val alertNotificationSpcfwCurrent: String - private val alertNotificationWpcmpdCurrent: String - val isUS: Boolean - var observation = "" - private val prefNumberString: String - - init { - val jStr = (locNumInt + 1).toString() - prefNumberString = jStr - x = Utility.readPref(context, "LOC" + jStr + "_X", "0.0") - y = Utility.readPref(context, "LOC" + jStr + "_Y", "0.0") - name = Utility.readPref(context, "LOC" + jStr + "_LABEL", "") - countyCurrent = Utility.readPref(context, "COUNTY$jStr", "") - zoneCurrent = Utility.readPref(context, "ZONE$jStr", "") - wfo = Utility.readPref(context, "NWS$jStr", "") - rid = Utility.readPref(context, "RID$jStr", "") - nwsStateCurrent = Utility.readPref(context, "NWS" + jStr + "_STATE", "") - alertNotificationCurrent = Utility.readPref(context, "ALERT" + jStr + "_NOTIFICATION", "false") - alertNotificationRadarCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_RADAR$jStr", "false") - alertCcNotificationCurrent = Utility.readPref(context, "ALERT_CC" + jStr + "_NOTIFICATION", "false") - alertSevenDayNotificationCurrent = Utility.readPref(context, "ALERT_7DAY_" + jStr + "_NOTIFICATION", "false") - alertNotificationSoundCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_SOUND$jStr", "false") - alertNotificationMcdCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_MCD$jStr", "false") - alertNotificationSwoCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_SWO$jStr", "false") - alertNotificationSpcfwCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_SPCFW$jStr", "false") - alertNotificationWpcmpdCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_WPCMPD$jStr", "false") - state = Utility.getWfoSiteName(wfo).split(",")[0] - observation = Utility.readPref(context, "LOC" + jStr + "_OBSERVATION", "") - isUS = us(x) - addToListOfNames(name) - } - - fun saveToNewSlot(newLocNumInt: Int) { - val iStr = (newLocNumInt + 1).toString() - Utility.writePref(context, "ALERT" + iStr + "_NOTIFICATION", alertNotificationCurrent) - Utility.writePref(context, "ALERT_CC" + iStr + "_NOTIFICATION", alertCcNotificationCurrent) - Utility.writePref(context, "ALERT_7DAY_" + iStr + "_NOTIFICATION", alertSevenDayNotificationCurrent) - Utility.writePref(context, "ALERT_NOTIFICATION_SOUND$iStr", alertNotificationSoundCurrent) - Utility.writePref(context, "ALERT_NOTIFICATION_MCD$iStr", alertNotificationMcdCurrent) - Utility.writePref(context, "ALERT_NOTIFICATION_SWO$iStr", alertNotificationSwoCurrent) - Utility.writePref(context, "ALERT_NOTIFICATION_SPCFW$iStr", alertNotificationSpcfwCurrent) - Utility.writePref(context, "ALERT_NOTIFICATION_WPCMPD$iStr", alertNotificationWpcmpdCurrent) - Utility.writePref(context, "ALERT_NOTIFICATION_RADAR$iStr", alertNotificationRadarCurrent) - Utility.writePref(context, "LOC" + iStr + "_X", x) - Utility.writePref(context, "LOC" + iStr + "_Y", y) - Utility.writePref(context, "LOC" + iStr + "_LABEL", name) - Utility.writePref(context, "COUNTY$iStr", countyCurrent) - Utility.writePref(context, "ZONE$iStr", zoneCurrent) - Utility.writePref(context, "NWS$iStr", wfo) - Utility.writePref(context, "RID$iStr", rid) - Utility.writePref(context, "NWS" + iStr + "_STATE", nwsStateCurrent) - Utility.writePref(context, "LOC" + iStr + "_OBSERVATION", observation) - refreshLocationData(context) - } - - fun updateObservation(observation: String) { - this.observation = observation - Utility.writePref(context, "LOC" + prefNumberString + "_OBSERVATION", observation) - } - - val notification get() = alertNotificationCurrent.startsWith("t") - - val notificationRadar get() = alertNotificationRadarCurrent.startsWith("t") - - val ccNotification get() = alertCcNotificationCurrent.startsWith("t") - - val sevenDayNotification get() = alertSevenDayNotificationCurrent.startsWith("t") - - val sound get() = alertNotificationSoundCurrent.startsWith("t") - - val notificationMcd get() = alertNotificationMcdCurrent.startsWith("t") - - val notificationSwo get() = alertNotificationSwoCurrent.startsWith("t") - - val notificationSpcFw get() = alertNotificationSpcfwCurrent.startsWith("t") +object Location { - val notificationWpcMpd get() = alertNotificationWpcmpdCurrent.startsWith("t") + val locations = mutableListOf() + var numLocations = 1 + var currentLocation = 0 + private set - companion object { + val listOf = mutableListOf () - // TODO FIXME migrate to this - val locations = mutableListOf() + fun us(xStr: String) = if (xStr.isNotEmpty()) Character.isDigit(xStr[0]) else true - var numLocations = 1 - var currentLocation = 0 - private set - - val listOf = mutableListOf () + fun addToListOfNames(name: String) { + listOf.add(name) + } - fun us(xStr: String) = if (xStr.isNotEmpty()) Character.isDigit(xStr[0]) else true + fun checkCurrentLocationValidity() { + if (currentLocation >= locations.size) { + currentLocation = locations.lastIndex + currentLocationStr = (currentLocation + 1).toString() + } + } - fun addToListOfNames(name: String) { listOf.add(name) } + private fun clearListOfNames() { + listOf.clear() + } - fun checkCurrentLocationValidity() { - if (currentLocation >= MyApplication.locations.size) { - currentLocation = MyApplication.locations.lastIndex - currentLocationStr = (currentLocation + 1).toString() - } - } + private fun initNumLocations(context: Context) { + val numberOfLocations = Utility.readPref(context, "LOC_NUM_INT", 1) + setNumLocations(context, numberOfLocations) + } - private fun clearListOfNames() { listOf.clear() } + private fun setNumLocations(context: Context, numLocations: Int) { + Location.numLocations = numLocations + Utility.writePref(context, "LOC_NUM_INT", numLocations) + } - private fun initNumLocations(context: Context) { - val numberOfLocations = Utility.readPref(context, "LOC_NUM_INT", 1) - setNumLocations(context, numberOfLocations) - } + var currentLocationStr: String + get() = (currentLocation + 1).toString() + set(currentLocationStr) { currentLocation = (currentLocationStr.toIntOrNull() ?: 0) - 1 } - private fun setNumLocations(context: Context, numLocations: Int) { - Location.numLocations = numLocations - Utility.writePref(context, "LOC_NUM_INT", numLocations) - } + val state get() = locations.getOrNull(currentLocation)?.state ?: "MI" - var currentLocationStr: String - get() = (currentLocation + 1).toString() - set(currentLocationStr) { currentLocation = (currentLocationStr.toIntOrNull() ?: 0) - 1 } + val wfo get() = locations.getOrNull(currentLocation)?.wfo ?: "DTX" - val state get() = MyApplication.locations.getOrNull(currentLocation)?.state ?: "MI" + val rid get() = locations.getOrNull(currentLocation)?.rid ?: "DTX" - val wfo get() = MyApplication.locations.getOrNull(currentLocation)?.wfo ?: "DTX" + val x get() = locations.getOrNull(currentLocation)?.x ?: "0.0" - val rid get() = MyApplication.locations.getOrNull(currentLocation)?.rid ?: "DTX" + val y get() = locations.getOrNull(currentLocation)?.y ?: "-0.0" - val x get() = MyApplication.locations.getOrNull(currentLocation)?.x ?: "0.0" + val latLon get() = LatLon(x, y) - val y get() = MyApplication.locations.getOrNull(currentLocation)?.y ?: "-0.0" + val name get() = locations.getOrNull(currentLocation)?.name ?: "" - val latLon get() = LatLon(x, y) + fun getName(locNum: Int) = locations.getOrNull(locNum)?.name ?: "0.0" - val name get() = MyApplication.locations.getOrNull(currentLocation)?.name ?: "" + fun getX(locNum: Int) = locations.getOrNull(locNum)?.x ?: "0.0" - fun getName(locNum: Int) = MyApplication.locations.getOrNull(locNum)?.name ?: "0.0" + fun getY(locNum: Int) = locations.getOrNull(locNum)?.y ?: "-0.0" - fun getX(locNum: Int) = MyApplication.locations.getOrNull(locNum)?.x ?: "0.0" + fun getRid(locNum: Int) = locations.getOrNull(locNum)?.rid ?: "DTX" - fun getY(locNum: Int) = MyApplication.locations.getOrNull(locNum)?.y ?: "-0.0" + fun getWfo(locNum: Int) = locations.getOrNull(locNum)?.wfo ?: "DTX" - fun getRid(locNum: Int) = MyApplication.locations.getOrNull(locNum)?.rid ?: "DTX" + fun getObservation(locNum: Int) = locations.getOrNull(locNum)?.observation ?: "" - fun getWfo(locNum: Int) = MyApplication.locations.getOrNull(locNum)?.wfo ?: "DTX" + fun getLatLon(locNum: Int) = LatLon(getX(locNum), getY(locNum)) - fun getObservation(locNum: Int) = MyApplication.locations.getOrNull(locNum)?.observation ?: "" + fun getIdentifier(locNum: Int): String { + val lat = locations.getOrNull(locNum)?.x ?: "" + val lon = locations.getOrNull(locNum)?.y ?: "" + return "LAT" + lat + "LON" + lon + } - fun getLatLon(locNum: Int) = LatLon(getX(locNum), getY(locNum)) + val locationIndex get() = currentLocation - fun getIdentifier(locNum: Int): String { - val lat = MyApplication.locations.getOrNull(locNum)?.x ?: "" - val lon = MyApplication.locations.getOrNull(locNum)?.y ?: "" - return "LAT" + lat + "LON" + lon - } + fun isUS(locationNumber: Int) = locations.getOrNull(locationNumber)?.isUS ?: true - val locationIndex get() = currentLocation + fun isUS(locationNumberString: String) = locations[locationNumberString.toInt() - 1].isUS - fun isUS(locationNumber: Int) = MyApplication.locations.getOrNull(locationNumber)?.isUS ?: true + val isUS get() = locations.getOrNull(currentLocation)?.isUS ?: true - fun isUS(locationNumberString: String) = MyApplication.locations[locationNumberString.toInt() - 1].isUS + fun getRid(context: Context, locNum: String) = Utility.readPref(context, "RID$locNum", "") - val isUS get() = MyApplication.locations.getOrNull(currentLocation)?.isUS ?: true + fun refreshLocationData(context: Context) { + initNumLocations(context) + locations.clear() + clearListOfNames() + (0 until numLocations).mapTo(locations) { ObjectLocation(context, it) } + addToListOfNames(ADD_LOC_STR) + checkCurrentLocationValidity() + } - fun getRid(context: Context, locNum: String) = Utility.readPref(context, "RID$locNum", "") + private fun getWfoRadarSiteFromPoint(location: LatLon): List { + val pointData = ("https://api.weather.gov/points/" + location.latString + "," + location.lonString).getNwsHtml() + // "cwa": "IWX", + // "radarStation": "KGRR" + val wfo = pointData.parse("\"cwa\": \"(.*?)\"") + var radarStation = pointData.parse("\"radarStation\": \"(.*?)\"") + radarStation = UtilityString.getLastXChars(radarStation, 3) + return listOf(wfo, radarStation) + } - fun refreshLocationData(context: Context) { - initNumLocations(context) - MyApplication.locations.clear() - clearListOfNames() - (0 until numLocations).mapTo(MyApplication.locations) { Location(context, it) } - addToListOfNames(ADD_LOC_STR) - checkCurrentLocationValidity() - } + fun save(context: Context, latLon: LatLon) = + save(context, (numLocations + 1).toString(), latLon.latString, latLon.lonString, latLon.toString()) - private fun getWfoRadarSiteFromPoint(location: LatLon): List { - val pointData = ("https://api.weather.gov/points/" + location.latString + "," + location.lonString).getNwsHtml() - // "cwa": "IWX", - // "radarStation": "KGRR" - val wfo = pointData.parse("\"cwa\": \"(.*?)\"") - var radarStation = pointData.parse("\"radarStation\": \"(.*?)\"") - radarStation = UtilityString.getLastXChars(radarStation, 3) - return listOf(wfo, radarStation) + fun save(context: Context, locNum: String, xStr: String, yStr: String, labelStr: String): String { + if (xStr == "" || yStr == "" || labelStr == "") { + return "Location label, latitude, and longitude all must have valid values, please try again." } - - fun save(context: Context, latLon: LatLon) = - save(context, (numLocations + 1).toString(), latLon.latString, latLon.lonString, latLon.toString()) - - fun save(context: Context, locNum: String, xStr: String, yStr: String, labelStr: String): String { - if (xStr == "" || yStr == "" || labelStr == "") return "Location label, latitude, and longitude all must have valid values, please try again." - val locNumInt = locNum.toIntOrNull() ?: 0 - val locNumIntCurrent = numLocations - val locNumToSave = if (locNumInt == locNumIntCurrent + 1) locNumInt else locNumIntCurrent - Utility.writePref(context, "LOC" + locNum + "_X", xStr) - Utility.writePref(context, "LOC" + locNum + "_Y", yStr) - Utility.writePref(context, "LOC" + locNum + "_LABEL", labelStr) - var wfo = "" - var radarSite = "" - if (us(xStr)) { - setNumLocations(context, locNumToSave) - val wfoAndRadar = getWfoRadarSiteFromPoint(LatLon(xStr, yStr)) - wfo = wfoAndRadar[0] - radarSite = wfoAndRadar[1] - if (wfo == "") { - wfo = UtilityLocation.getNearestOffice( "WFO", LatLon(xStr, yStr)).lowercase(Locale.US) - } - if (radarSite == "") { - radarSite = UtilityLocation.getNearestOffice( "RADAR", LatLon(xStr, yStr)) - } - // CT shows mosaic not nexrad so the old way is needed - if (radarSite == "") { - radarSite = GlobalDictionaries.wfoToRadarSite[wfo.uppercase(Locale.US)] ?: "" - } - Utility.writePref(context, "RID$locNum", radarSite.uppercase(Locale.US)) - Utility.writePref(context, "NWS$locNum", wfo.uppercase(Locale.US)) - } else if (xStr.contains("CANADA")) { - var tmpLatLon = LatLon() - if (xStr.length < 12) { - // if we are here then the user used the submenu - // need to calculate lat/lon first as get rid is now coded to parse on ":" for both x/y - // first check if the label is present in the database - if (UtilityCanada.isLabelPresent(labelStr)) { - tmpLatLon = UtilityCanada.getLatLonFromLabel(labelStr) - } - } - var prov = "" - val parseProv = xStr.split(":").dropLastWhile { it.isEmpty() } - if (parseProv.isNotEmpty()) { - prov = parseProv[1] - } - var id = "" - val parseId = yStr.split(":").dropLastWhile { it.isEmpty() } - if (parseId.isNotEmpty()) { - id = parseId[0] - } - if (xStr.length > 12) { - tmpLatLon = LatLon(parseProv[2], parseId[1]) + val locNumInt = locNum.toIntOrNull() ?: 0 + val locNumIntCurrent = numLocations + val locNumToSave = if (locNumInt == locNumIntCurrent + 1) locNumInt else locNumIntCurrent + Utility.writePref(context, "LOC" + locNum + "_X", xStr) + Utility.writePref(context, "LOC" + locNum + "_Y", yStr) + Utility.writePref(context, "LOC" + locNum + "_LABEL", labelStr) + var wfo = "" + var radarSite = "" + if (us(xStr)) { + setNumLocations(context, locNumToSave) + val wfoAndRadar = getWfoRadarSiteFromPoint(LatLon(xStr, yStr)) + wfo = wfoAndRadar[0] + radarSite = wfoAndRadar[1] + if (wfo == "") { + wfo = UtilityLocation.getNearestOffice( "WFO", LatLon(xStr, yStr)).lowercase(Locale.US) + } + if (radarSite == "") { + radarSite = UtilityLocation.getNearestOffice( "RADAR", LatLon(xStr, yStr)) + } + // CT shows mosaic not nexrad so the old way is needed + if (radarSite == "") { + radarSite = GlobalDictionaries.wfoToRadarSite[wfo.uppercase(Locale.US)] ?: "" + } + Utility.writePref(context, "RID$locNum", radarSite.uppercase(Locale.US)) + Utility.writePref(context, "NWS$locNum", wfo.uppercase(Locale.US)) + } else if (xStr.contains("CANADA")) { + var tmpLatLon = LatLon() + if (xStr.length < 12) { + // if we are here then the user used the submenu + // need to calculate lat/lon first as get rid is now coded to parse on ":" for both x/y + // first check if the label is present in the database + if (UtilityCanada.isLabelPresent(labelStr)) { + tmpLatLon = UtilityCanada.getLatLonFromLabel(labelStr) } - Utility.writePref(context, "LOC" + locNum + "_X", "CANADA" + ":" + prov + ":" + tmpLatLon.latString) - Utility.writePref(context, "LOC" + locNum + "_Y", id + ":" + tmpLatLon.lonString) - setNumLocations(context, locNumToSave) - radarSite = UtilityCanada.getRadarSite(xStr, yStr) - Utility.writePref(context, "RID$locNum", radarSite.uppercase(Locale.US)) - Utility.writePref(context, "NWS" + locNum + "_STATE", prov) - Utility.writePref(context, "ZONE$locNum", "") - Utility.writePref(context, "COUNTY$locNum", "") - Utility.writePref(context, "NWS$locNum", "") } - refreshLocationData(context) - setCurrentLocationStr(context, locNum) - return "Saving location $locNum as $labelStr ($xStr,$yStr) " + wfo.uppercase(Locale.US) + "(" + radarSite.uppercase(Locale.US) + ")" + var prov = "" + val parseProv = xStr.split(":").dropLastWhile { it.isEmpty() } + if (parseProv.isNotEmpty()) { + prov = parseProv[1] + } + var id = "" + val parseId = yStr.split(":").dropLastWhile { it.isEmpty() } + if (parseId.isNotEmpty()) { + id = parseId[0] + } + if (xStr.length > 12) { + tmpLatLon = LatLon(parseProv[2], parseId[1]) + } + Utility.writePref(context, "LOC" + locNum + "_X", "CANADA" + ":" + prov + ":" + tmpLatLon.latString) + Utility.writePref(context, "LOC" + locNum + "_Y", id + ":" + tmpLatLon.lonString) + setNumLocations(context, locNumToSave) + radarSite = UtilityCanada.getRadarSite(xStr, yStr) + Utility.writePref(context, "RID$locNum", radarSite.uppercase(Locale.US)) + Utility.writePref(context, "NWS" + locNum + "_STATE", prov) + Utility.writePref(context, "ZONE$locNum", "") + Utility.writePref(context, "COUNTY$locNum", "") + Utility.writePref(context, "NWS$locNum", "") } + refreshLocationData(context) + setCurrentLocationStr(context, locNum) + return "Saving location $locNum as $labelStr ($xStr,$yStr) " + wfo.uppercase(Locale.US) + "(" + radarSite.uppercase(Locale.US) + ")" + } - private fun setCurrentLocationStr(context: Context, locNum: String) { - Utility.writePref(context, "CURRENT_LOC_FRAGMENT", locNum) - currentLocationStr = locNum - } + private fun setCurrentLocationStr(context: Context, locNum: String) { + Utility.writePref(context, "CURRENT_LOC_FRAGMENT", locNum) + currentLocationStr = locNum + } - fun delete(context: Context, locToDeleteStr: String) { - val locToDeleteInt = locToDeleteStr.toIntOrNull() ?: 0 - val locNumIntCurrent = numLocations - val locNumIntCurrentStr = locNumIntCurrent.toString() - if (locToDeleteInt == locNumIntCurrent) { + fun delete(context: Context, locToDeleteStr: String) { + val locToDeleteInt = locToDeleteStr.toIntOrNull() ?: 0 + val locNumIntCurrent = numLocations + val locNumIntCurrentStr = locNumIntCurrent.toString() + if (locToDeleteInt == locNumIntCurrent) { + setNumLocations(context, locNumIntCurrent - 1) + } else { + var i = locToDeleteInt + while (i < locNumIntCurrent) { + val j = i + 1 + val jStr = j.toString() + val iStr = i.toString() + val locObsCurrent = Utility.readPref(context, "LOC" + jStr + "_OBSERVATION", "") + val locXCurrent = Utility.readPref(context, "LOC" + jStr + "_X", "") + val locYCurrent = Utility.readPref(context, "LOC" + jStr + "_Y", "") + val locLabelCurrent = Utility.readPref(context, "LOC" + jStr + "_LABEL", "") + val nwsCurrent = Utility.readPref(context, "NWS$jStr", "") + val ridCurrent = Utility.readPref(context, "RID$jStr", "") + val nwsStateCurrent = Utility.readPref(context, "NWS" + jStr + "_STATE", "") + val alertNotificationCurrent = Utility.readPref(context, "ALERT" + jStr + "_NOTIFICATION", "false") + val alertNotificationRadarCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_RADAR$jStr", "false") + val alertCcNotificationCurrent = Utility.readPref(context, "ALERT_CC" + jStr + "_NOTIFICATION", "false") + val alert7Day1NotificationCurrent = Utility.readPref(context, "ALERT_7DAY_" + jStr + "_NOTIFICATION", "false") + val alertNotificationSoundCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_SOUND$jStr", "false") + val alertNotificationMcdCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_MCD$jStr", "false") + val alertNotificationSwoCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_SWO$jStr", "false") + val alertNotificationSpcfwCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_SPCFW$jStr", "false") + val alertNotificationWpcmpdCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_WPCMPD$jStr", "false") + Utility.writePref(context, "ALERT" + iStr + "_NOTIFICATION", alertNotificationCurrent) + Utility.writePref(context, "ALERT_CC" + iStr + "_NOTIFICATION", alertCcNotificationCurrent) + Utility.writePref(context, "ALERT_7DAY_" + iStr + "_NOTIFICATION", alert7Day1NotificationCurrent) + Utility.writePref(context, "ALERT_NOTIFICATION_SOUND$iStr", alertNotificationSoundCurrent) + Utility.writePref(context, "ALERT_NOTIFICATION_MCD$iStr", alertNotificationMcdCurrent) + Utility.writePref(context, "ALERT_NOTIFICATION_SWO$iStr", alertNotificationSwoCurrent) + Utility.writePref(context, "ALERT_NOTIFICATION_SPCFW$iStr", alertNotificationSpcfwCurrent) + Utility.writePref(context, "ALERT_NOTIFICATION_WPCMPD$iStr", alertNotificationWpcmpdCurrent) + Utility.writePref(context, "ALERT_NOTIFICATION_RADAR$iStr", alertNotificationRadarCurrent) + Utility.writePref(context, "LOC" + iStr + "_OBSERVATION", locObsCurrent) + Utility.writePref(context, "LOC" + iStr + "_X", locXCurrent) + Utility.writePref(context, "LOC" + iStr + "_Y", locYCurrent) + Utility.writePref(context, "LOC" + iStr + "_LABEL", locLabelCurrent) + Utility.writePref(context, "NWS$iStr", nwsCurrent) + Utility.writePref(context, "RID$iStr", ridCurrent) + Utility.writePref(context, "NWS" + iStr + "_STATE", nwsStateCurrent) setNumLocations(context, locNumIntCurrent - 1) - } else { - var i = locToDeleteInt - while (i < locNumIntCurrent) { - val j = i + 1 - val jStr = j.toString() - val iStr = i.toString() - val locObsCurrent = Utility.readPref(context, "LOC" + jStr + "_OBSERVATION", "") - val locXCurrent = Utility.readPref(context, "LOC" + jStr + "_X", "") - val locYCurrent = Utility.readPref(context, "LOC" + jStr + "_Y", "") - val locLabelCurrent = Utility.readPref(context, "LOC" + jStr + "_LABEL", "") - val nwsCurrent = Utility.readPref(context, "NWS$jStr", "") - val ridCurrent = Utility.readPref(context, "RID$jStr", "") - val nwsStateCurrent = Utility.readPref(context, "NWS" + jStr + "_STATE", "") - val alertNotificationCurrent = Utility.readPref(context, "ALERT" + jStr + "_NOTIFICATION", "false") - val alertNotificationRadarCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_RADAR$jStr", "false") - val alertCcNotificationCurrent = Utility.readPref(context, "ALERT_CC" + jStr + "_NOTIFICATION", "false") - val alert7Day1NotificationCurrent = Utility.readPref(context, "ALERT_7DAY_" + jStr + "_NOTIFICATION", "false") - val alertNotificationSoundCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_SOUND$jStr", "false") - val alertNotificationMcdCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_MCD$jStr", "false") - val alertNotificationSwoCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_SWO$jStr", "false") - val alertNotificationSpcfwCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_SPCFW$jStr", "false") - val alertNotificationWpcmpdCurrent = Utility.readPref(context, "ALERT_NOTIFICATION_WPCMPD$jStr", "false") - Utility.writePref(context, "ALERT" + iStr + "_NOTIFICATION", alertNotificationCurrent) - Utility.writePref(context, "ALERT_CC" + iStr + "_NOTIFICATION", alertCcNotificationCurrent) - Utility.writePref(context, "ALERT_7DAY_" + iStr + "_NOTIFICATION", alert7Day1NotificationCurrent) - Utility.writePref(context, "ALERT_NOTIFICATION_SOUND$iStr", alertNotificationSoundCurrent) - Utility.writePref(context, "ALERT_NOTIFICATION_MCD$iStr", alertNotificationMcdCurrent) - Utility.writePref(context, "ALERT_NOTIFICATION_SWO$iStr", alertNotificationSwoCurrent) - Utility.writePref(context, "ALERT_NOTIFICATION_SPCFW$iStr", alertNotificationSpcfwCurrent) - Utility.writePref(context, "ALERT_NOTIFICATION_WPCMPD$iStr", alertNotificationWpcmpdCurrent) - Utility.writePref(context, "ALERT_NOTIFICATION_RADAR$iStr", alertNotificationRadarCurrent) - Utility.writePref(context, "LOC" + iStr + "_OBSERVATION", locObsCurrent) - Utility.writePref(context, "LOC" + iStr + "_X", locXCurrent) - Utility.writePref(context, "LOC" + iStr + "_Y", locYCurrent) - Utility.writePref(context, "LOC" + iStr + "_LABEL", locLabelCurrent) - Utility.writePref(context, "NWS$iStr", nwsCurrent) - Utility.writePref(context, "RID$iStr", ridCurrent) - Utility.writePref(context, "NWS" + iStr + "_STATE", nwsStateCurrent) - setNumLocations(context, locNumIntCurrent - 1) - i += 1 - } - } - // blank out for next loc add - Utility.writePref(context, "ALERT" + locNumIntCurrentStr + "_NOTIFICATION", "false") - Utility.writePref(context, "ALERT_CC" + locNumIntCurrentStr + "_NOTIFICATION", "false") - Utility.writePref(context, "ALERT_7DAY_" + locNumIntCurrentStr + "_NOTIFICATION", "false") - Utility.writePref(context, "ALERT_NOTIFICATION_SOUND$locNumIntCurrentStr", "false") - Utility.writePref(context, "ALERT_NOTIFICATION_RADAR$locNumIntCurrentStr", "false") - Utility.writePref(context, "ALERT_NOTIFICATION_MCD$locNumIntCurrentStr", "false") - Utility.writePref(context, "ALERT_NOTIFICATION_SWO$locNumIntCurrentStr", "false") - Utility.writePref(context, "ALERT_NOTIFICATION_SPCFW$locNumIntCurrentStr", "false") - Utility.writePref(context, "ALERT_NOTIFICATION_WPCMPD$locNumIntCurrentStr", "false") - val locFragCurrentInt = currentLocation - if (locToDeleteInt == (locFragCurrentInt + 1)) { - Utility.writePref(context, "CURRENT_LOC_FRAGMENT", "1") - currentLocationStr = "1" - } else if (locFragCurrentInt > locToDeleteInt) { - val shiftNum = (locFragCurrentInt - 1).toString() - Utility.writePref(context, "CURRENT_LOC_FRAGMENT", shiftNum) - currentLocationStr = shiftNum + i += 1 } - val widgetLocNum = Utility.readPref(context, "WIDGET_LOCATION", "1") - val widgetLocNumInt = widgetLocNum.toIntOrNull() ?: 0 - if (locToDeleteInt == widgetLocNumInt) { - Utility.writePref(context, "WIDGET_LOCATION", "1") - } else if (widgetLocNumInt > locToDeleteInt) { - val shiftNum = (widgetLocNumInt - 1).toString() - Utility.writePref(context, "WIDGET_LOCATION", shiftNum) - } - refreshLocationData(context) } - - private const val ADD_LOC_STR = "Add Location..." + // blank out for next loc add + Utility.writePref(context, "ALERT" + locNumIntCurrentStr + "_NOTIFICATION", "false") + Utility.writePref(context, "ALERT_CC" + locNumIntCurrentStr + "_NOTIFICATION", "false") + Utility.writePref(context, "ALERT_7DAY_" + locNumIntCurrentStr + "_NOTIFICATION", "false") + Utility.writePref(context, "ALERT_NOTIFICATION_SOUND$locNumIntCurrentStr", "false") + Utility.writePref(context, "ALERT_NOTIFICATION_RADAR$locNumIntCurrentStr", "false") + Utility.writePref(context, "ALERT_NOTIFICATION_MCD$locNumIntCurrentStr", "false") + Utility.writePref(context, "ALERT_NOTIFICATION_SWO$locNumIntCurrentStr", "false") + Utility.writePref(context, "ALERT_NOTIFICATION_SPCFW$locNumIntCurrentStr", "false") + Utility.writePref(context, "ALERT_NOTIFICATION_WPCMPD$locNumIntCurrentStr", "false") + val locFragCurrentInt = currentLocation + if (locToDeleteInt == (locFragCurrentInt + 1)) { + Utility.writePref(context, "CURRENT_LOC_FRAGMENT", "1") + currentLocationStr = "1" + } else if (locFragCurrentInt > locToDeleteInt) { + val shiftNum = (locFragCurrentInt - 1).toString() + Utility.writePref(context, "CURRENT_LOC_FRAGMENT", shiftNum) + currentLocationStr = shiftNum + } + val widgetLocNum = Utility.readPref(context, "WIDGET_LOCATION", "1") + val widgetLocNumInt = widgetLocNum.toIntOrNull() ?: 0 + if (locToDeleteInt == widgetLocNumInt) { + Utility.writePref(context, "WIDGET_LOCATION", "1") + } else if (widgetLocNumInt > locToDeleteInt) { + val shiftNum = (widgetLocNumInt - 1).toString() + Utility.writePref(context, "WIDGET_LOCATION", shiftNum) + } + refreshLocationData(context) } + + private const val ADD_LOC_STR = "Add Location..." } diff --git a/app/src/main/java/joshuatee/wx/settings/ObjectLocation.kt b/app/src/main/java/joshuatee/wx/settings/ObjectLocation.kt index b1f7330d..0b1d20ff 100644 --- a/app/src/main/java/joshuatee/wx/settings/ObjectLocation.kt +++ b/app/src/main/java/joshuatee/wx/settings/ObjectLocation.kt @@ -22,16 +22,7 @@ package joshuatee.wx.settings import android.content.Context -//import joshuatee.wx.MyApplication -//import joshuatee.wx.canada.UtilityCanada -//import joshuatee.wx.radar.LatLon import joshuatee.wx.util.Utility -//import java.util.* -//import joshuatee.wx.Extensions.* -//import joshuatee.wx.GlobalDictionaries -//import joshuatee.wx.util.UtilityString - -// TODO FIXME not currently used class ObjectLocation(val context: Context, locNumInt: Int) { @@ -83,49 +74,49 @@ class ObjectLocation(val context: Context, locNumInt: Int) { Location.addToListOfNames(name) } -// fun saveToNewSlot(newLocNumInt: Int) { -// val iStr = (newLocNumInt + 1).toString() -// Utility.writePref(context, "ALERT" + iStr + "_NOTIFICATION", alertNotificationCurrent) -// Utility.writePref(context, "ALERT_CC" + iStr + "_NOTIFICATION", alertCcNotificationCurrent) -// Utility.writePref(context, "ALERT_7DAY_" + iStr + "_NOTIFICATION", alertSevenDayNotificationCurrent) -// Utility.writePref(context, "ALERT_NOTIFICATION_SOUND$iStr", alertNotificationSoundCurrent) -// Utility.writePref(context, "ALERT_NOTIFICATION_MCD$iStr", alertNotificationMcdCurrent) -// Utility.writePref(context, "ALERT_NOTIFICATION_SWO$iStr", alertNotificationSwoCurrent) -// Utility.writePref(context, "ALERT_NOTIFICATION_SPCFW$iStr", alertNotificationSpcfwCurrent) -// Utility.writePref(context, "ALERT_NOTIFICATION_WPCMPD$iStr", alertNotificationWpcmpdCurrent) -// Utility.writePref(context, "ALERT_NOTIFICATION_RADAR$iStr", alertNotificationRadarCurrent) -// Utility.writePref(context, "LOC" + iStr + "_X", x) -// Utility.writePref(context, "LOC" + iStr + "_Y", y) -// Utility.writePref(context, "LOC" + iStr + "_LABEL", name) -// Utility.writePref(context, "COUNTY$iStr", countyCurrent) -// Utility.writePref(context, "ZONE$iStr", zoneCurrent) -// Utility.writePref(context, "NWS$iStr", wfo) -// Utility.writePref(context, "RID$iStr", rid) -// Utility.writePref(context, "NWS" + iStr + "_STATE", nwsStateCurrent) -// Utility.writePref(context, "LOC" + iStr + "_OBSERVATION", observation) -// Location.refreshLocationData(context) -// } - -// fun updateObservation(observation: String) { -// this.observation = observation -// Utility.writePref(context, "LOC" + prefNumberString + "_OBSERVATION", observation) -// } + fun saveToNewSlot(newLocNumInt: Int) { + val iStr = (newLocNumInt + 1).toString() + Utility.writePref(context, "ALERT" + iStr + "_NOTIFICATION", alertNotificationCurrent) + Utility.writePref(context, "ALERT_CC" + iStr + "_NOTIFICATION", alertCcNotificationCurrent) + Utility.writePref(context, "ALERT_7DAY_" + iStr + "_NOTIFICATION", alertSevenDayNotificationCurrent) + Utility.writePref(context, "ALERT_NOTIFICATION_SOUND$iStr", alertNotificationSoundCurrent) + Utility.writePref(context, "ALERT_NOTIFICATION_MCD$iStr", alertNotificationMcdCurrent) + Utility.writePref(context, "ALERT_NOTIFICATION_SWO$iStr", alertNotificationSwoCurrent) + Utility.writePref(context, "ALERT_NOTIFICATION_SPCFW$iStr", alertNotificationSpcfwCurrent) + Utility.writePref(context, "ALERT_NOTIFICATION_WPCMPD$iStr", alertNotificationWpcmpdCurrent) + Utility.writePref(context, "ALERT_NOTIFICATION_RADAR$iStr", alertNotificationRadarCurrent) + Utility.writePref(context, "LOC" + iStr + "_X", x) + Utility.writePref(context, "LOC" + iStr + "_Y", y) + Utility.writePref(context, "LOC" + iStr + "_LABEL", name) + Utility.writePref(context, "COUNTY$iStr", countyCurrent) + Utility.writePref(context, "ZONE$iStr", zoneCurrent) + Utility.writePref(context, "NWS$iStr", wfo) + Utility.writePref(context, "RID$iStr", rid) + Utility.writePref(context, "NWS" + iStr + "_STATE", nwsStateCurrent) + Utility.writePref(context, "LOC" + iStr + "_OBSERVATION", observation) + Location.refreshLocationData(context) + } + + fun updateObservation(observation: String) { + this.observation = observation + Utility.writePref(context, "LOC" + prefNumberString + "_OBSERVATION", observation) + } val notification get() = alertNotificationCurrent.startsWith("t") val notificationRadar get() = alertNotificationRadarCurrent.startsWith("t") -// val ccNotification get() = alertCcNotificationCurrent.startsWith("t") + val ccNotification get() = alertCcNotificationCurrent.startsWith("t") val sevenDayNotification get() = alertSevenDayNotificationCurrent.startsWith("t") val sound get() = alertNotificationSoundCurrent.startsWith("t") -// val notificationMcd get() = alertNotificationMcdCurrent.startsWith("t") -// -// val notificationSwo get() = alertNotificationSwoCurrent.startsWith("t") -// -// val notificationSpcFw get() = alertNotificationSpcfwCurrent.startsWith("t") -// -// val notificationWpcMpd get() = alertNotificationWpcmpdCurrent.startsWith("t") + val notificationMcd get() = alertNotificationMcdCurrent.startsWith("t") + + val notificationSwo get() = alertNotificationSwoCurrent.startsWith("t") + + val notificationSpcFw get() = alertNotificationSpcfwCurrent.startsWith("t") + + val notificationWpcMpd get() = alertNotificationWpcmpdCurrent.startsWith("t") } diff --git a/app/src/main/java/joshuatee/wx/settings/ObjectSettingsCheckBox.kt b/app/src/main/java/joshuatee/wx/settings/ObjectSettingsCheckBox.kt index df4b7843..12310369 100644 --- a/app/src/main/java/joshuatee/wx/settings/ObjectSettingsCheckBox.kt +++ b/app/src/main/java/joshuatee/wx/settings/ObjectSettingsCheckBox.kt @@ -23,21 +23,14 @@ package joshuatee.wx.settings import android.app.NotificationManager import android.content.Context -import android.util.TypedValue import android.view.Gravity import android.widget.CheckBox import android.widget.CompoundButton -import android.widget.LinearLayout -import android.widget.TextView -import joshuatee.wx.Extensions.setPadding import joshuatee.wx.MyApplication import joshuatee.wx.notifications.UtilityNotification import joshuatee.wx.objects.GeographyType import joshuatee.wx.radar.RadarGeometry -import joshuatee.wx.ui.ObjectCard -import joshuatee.wx.ui.ObjectCardText -import joshuatee.wx.ui.ObjectDialogue -import joshuatee.wx.ui.ObjectLinearLayout +import joshuatee.wx.ui.* import joshuatee.wx.util.Utility import joshuatee.wx.util.UtilityAlertDialog @@ -47,19 +40,20 @@ class ObjectSettingsCheckBox(context: Context, label: String, pref: String, strI private val checkBox = CheckBox(context) init { - val textView = TextView(context) - ObjectCardText.textViewSetup(textView) - textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, UIPreferences.textSizeNormal) - textView.setTextColor(UIPreferences.backgroundColor) + val textView = ObjectTextView(context) + textView.wrap() +// ObjectCardText.textViewSetup(textView) +// textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, UIPreferences.textSizeNormal) +// textView.setTextColor(UIPreferences.backgroundColor) textView.setPadding(UIPreferences.paddingSettings) - textView.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f) +// textView.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f) textView.text = label - textView.gravity = Gravity.CENTER_VERTICAL +// textView.gravity = Gravity.CENTER_VERTICAL val strInner = context.resources.getString(strId) textView.setOnClickListener { ObjectDialogue(context, strInner) } - val objectLinearLayout = ObjectLinearLayout(context, LinearLayout.HORIZONTAL, Gravity.CENTER_VERTICAL) - objectLinearLayout.matchParent() - objectLinearLayout.addView(textView) + val hbox = HBox(context, Gravity.CENTER_VERTICAL) + hbox.matchParent() + hbox.addWidget(textView.get()) checkBox.gravity = Gravity.CENTER_VERTICAL val truePrefs = listOf( "COD_HW_DEFAULT", @@ -129,8 +123,8 @@ class ObjectSettingsCheckBox(context: Context, label: String, pref: String, strI } } } - objectLinearLayout.addView(checkBox) - objectCard.addView(objectLinearLayout.linearLayout) + hbox.addWidget(checkBox) + objectCard.addView(hbox.get()) } fun isChecked(value: Boolean) { diff --git a/app/src/main/java/joshuatee/wx/settings/ObjectSettingsColorLabel.kt b/app/src/main/java/joshuatee/wx/settings/ObjectSettingsColorLabel.kt index 6e8e4104..d1b0ff56 100644 --- a/app/src/main/java/joshuatee/wx/settings/ObjectSettingsColorLabel.kt +++ b/app/src/main/java/joshuatee/wx/settings/ObjectSettingsColorLabel.kt @@ -24,7 +24,6 @@ package joshuatee.wx.settings import android.content.Context import android.graphics.Color import android.view.Gravity -import android.widget.LinearLayout import androidx.core.content.ContextCompat import joshuatee.wx.R import joshuatee.wx.objects.ObjectIntent @@ -40,7 +39,7 @@ internal class ObjectSettingsColorLabel(val context: Context, label: String, pri init { refreshColor() objectTextView.setPadding(UIPreferences.paddingSettings) - objectTextView.get().layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f) + objectTextView.wrap() objectTextView.text = label objectTextView.setBackgroundColor(ContextCompat.getColor(context, R.color.black)) objectCard.setCardBackgroundColor(ContextCompat.getColor(context, R.color.black)) diff --git a/app/src/main/java/joshuatee/wx/settings/ObjectSettingsSeekbar.kt b/app/src/main/java/joshuatee/wx/settings/ObjectSettingsSeekbar.kt index 6066d1fe..aa4dbcad 100644 --- a/app/src/main/java/joshuatee/wx/settings/ObjectSettingsSeekbar.kt +++ b/app/src/main/java/joshuatee/wx/settings/ObjectSettingsSeekbar.kt @@ -50,30 +50,30 @@ internal class ObjectSettingsSeekBar( "CARD_CORNER_RADIUS" -> (Utility.readPref(context, pref, 0)) else -> Utility.readPref(context, pref, defValue) } - private val objectTextView = ObjectTextView(context) + private val text = ObjectTextView(context) private val seekBar = SeekBar(context) init { - objectTextView.setPadding(UIPreferences.padding) - objectTextView.get().layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f) - objectTextView.gravity = Gravity.TOP - objectTextView.setOnClickListener { ObjectDialogue(context, context.resources.getString(strId)) } - val objectLinearLayout = ObjectLinearLayout(context, LinearLayout.VERTICAL, Gravity.CENTER_VERTICAL) - objectLinearLayout.matchParent() - objectLinearLayout.addView(objectTextView.get()) + text.setPadding(UIPreferences.padding) + text.wrap() + text.gravity = Gravity.TOP + text.setOnClickListener { ObjectDialogue(context, context.resources.getString(strId)) } + val vbox = VBox(context, Gravity.CENTER_VERTICAL) + vbox.matchParent() + vbox.addWidget(text.get()) seekBar.max = highValue - lowValue seekBar.progress = convert(initValue) val padding = 30 val layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) layoutParams.setMargins(padding, padding, padding, padding) seekBar.layoutParams = layoutParams - objectLinearLayout.addView(seekBar) - objectCard.addView(objectLinearLayout.linearLayout) + vbox.addWidget(seekBar) + objectCard.addView(vbox.get()) updateLabel() seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { if (pref == "TEXTVIEW_FONT_SIZE") { - objectTextView.get().setTextSize(TypedValue.COMPLEX_UNIT_PX, UtilityUI.spToPx(convertForSave(seekBar.progress), context)) + text.get().setTextSize(TypedValue.COMPLEX_UNIT_PX, UtilityUI.spToPx(convertForSave(seekBar.progress), context)) } updateLabel() } @@ -100,7 +100,7 @@ internal class ObjectSettingsSeekBar( private fun convertForSave(value: Int) = value + lowValue fun updateLabel() { - objectTextView.text = label + " (default is " + defValue.toString() + "): " + convertForSave(seekBar.progress).toString() + text.text = label + " (default is " + defValue.toString() + "): " + convertForSave(seekBar.progress).toString() } val card get() = objectCard.get() diff --git a/app/src/main/java/joshuatee/wx/settings/ObjectSettingsSpinner.kt b/app/src/main/java/joshuatee/wx/settings/ObjectSettingsSpinner.kt index e8795de3..e325cc07 100644 --- a/app/src/main/java/joshuatee/wx/settings/ObjectSettingsSpinner.kt +++ b/app/src/main/java/joshuatee/wx/settings/ObjectSettingsSpinner.kt @@ -27,7 +27,6 @@ import android.view.Gravity import android.view.View import android.widget.AdapterView import android.widget.ArrayAdapter -import android.widget.LinearLayout import android.widget.Spinner import joshuatee.wx.R import joshuatee.wx.ui.* @@ -39,15 +38,15 @@ class ObjectSettingsSpinner(context: Context, label: String, pref: String, prefI private val objectCard = ObjectCard(context) init { - val objectTextView = ObjectTextView(context) - objectTextView.setPadding(UIPreferences.paddingSettings) - objectTextView.get().layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f) - objectTextView.text = label - objectTextView.gravity = Gravity.CENTER_VERTICAL - objectTextView.setOnClickListener { ObjectDialogue(context, context.resources.getString(strId)) } - val objectLinearLayout = ObjectLinearLayout(context, LinearLayout.HORIZONTAL, Gravity.CENTER_VERTICAL) - objectLinearLayout.matchParent() - objectLinearLayout.addView(objectTextView.get()) + val text = ObjectTextView(context) + text.setPadding(UIPreferences.paddingSettings) + text.wrap() + text.text = label + text.gravity = Gravity.CENTER_VERTICAL + text.setOnClickListener { ObjectDialogue(context, context.resources.getString(strId)) } + val hbox = HBox(context, Gravity.CENTER_VERTICAL) + hbox.matchParent() + hbox.addWidget(text.get()) val spinner = Spinner(context) if (UIPreferences.themeInt == R.style.MyCustomTheme_white_NOAB) { setupSpinner(spinner, false) @@ -77,8 +76,8 @@ class ObjectSettingsSpinner(context: Context, label: String, pref: String, prefI value += ": " + Utility.readPref(context, "LOC" + value + "_LABEL", "").take(20) } spinner.setSelection(dataAdapter.getPosition(value)) - objectLinearLayout.addView(spinner) - objectCard.addView(objectLinearLayout.linearLayout) + hbox.addWidget(spinner) + objectCard.addView(hbox.get()) } val card get() = objectCard.get() diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsAboutActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsAboutActivity.kt index 092f5b6c..4fd7e3b7 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsAboutActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsAboutActivity.kt @@ -45,8 +45,8 @@ class SettingsAboutActivity : BaseActivity() { private val iOSUrl = "https://apps.apple.com/us/app/wxl23/id1171250052" //private val releaseNotesUrl = "https://docs.google.com/document/u/1/d/e/2PACX-1vT-YfH9yH_qmxLHe25UGlJvHHj_25qmTHJoeWPBbNWlvS4nm0YBmFeAnEpeel3GTL3OYKnvXkMNbnOX/pub" private val releaseNotesUrl = "https://github.com/ELY3M/wX---modded-by-ELY-M/blob/master/README.md" - private lateinit var linearLayout: LinearLayout - + private lateinit var box: LinearLayout + override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.generic_about, menu) return true @@ -55,26 +55,26 @@ class SettingsAboutActivity : BaseActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, R.menu.generic_about, false) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) val version = Utility.getVersion(this) toolbar.subtitle = "version: $version" - val faqButton = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) + val faqButton = ObjectCardText(this, box, toolbar, toolbarBottom) faqButton.setTextColor(UIPreferences.textHighlightColor) faqButton.text = "View FAQ (current app issues listed at top)" faqButton.setOnClickListener { ObjectIntent.showWeb(this, faqUrl) } - val releaseNotesButton = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) + val releaseNotesButton = ObjectCardText(this, box, toolbar, toolbarBottom) releaseNotesButton.setTextColor(UIPreferences.textHighlightColor) releaseNotesButton.text = "View release notes" releaseNotesButton.setOnClickListener { ObjectIntent.showWeb(this, releaseNotesUrl) } - textCard = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) + textCard = ObjectCardText(this, box, toolbar, toolbarBottom) val cardDeleteFiles = ObjectCardText(this, "Delete old radar files (should not be needed)", UIPreferences.textSizeNormal, UIPreferences.paddingSettings) cardDeleteFiles.setOnClickListener { - ObjectPopupMessage(linearLayout, "Deleted old radar files: " + UtilityFileManagement.deleteCacheFiles(this)) + ObjectPopupMessage(box, "Deleted old radar files: " + UtilityFileManagement.deleteCacheFiles(this)) } - linearLayout.addView(cardDeleteFiles.get()) + box.addView(cardDeleteFiles.get()) displayContent() } diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteEditor.kt b/app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteEditor.kt index 0844e194..3843b61f 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteEditor.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteEditor.kt @@ -52,7 +52,7 @@ class SettingsColorPaletteEditor : BaseActivity(), OnMenuItemClickListener { private const val READ_REQUEST_CODE = 42 } - private lateinit var activityArguments: Array + private lateinit var arguments: Array private var formattedDate = "" private var name = "" private var type = "" @@ -75,16 +75,16 @@ class SettingsColorPaletteEditor : BaseActivity(), OnMenuItemClickListener { } } showLoadFromFileMenuItem() - activityArguments = intent.getStringArrayExtra(URL)!! - type = activityArguments[0] + arguments = intent.getStringArrayExtra(URL)!! + type = arguments[0] typeAsInt = type.toIntOrNull() ?: 94 title = "Palette Editor" toolbar.subtitle = WXGLNexrad.productCodeStringToName[typeAsInt] formattedDate = UtilityTime.getDateAsString("MMdd") - name = if (activityArguments[2].contains("false")) activityArguments[1] else activityArguments[1] + "_" + formattedDate + name = if (arguments[2].contains("false")) arguments[1] else arguments[1] + "_" + formattedDate palTitle.setText(name) palTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, UIPreferences.textSizeLarge) - palContent.setText(UtilityColorPalette.getColorMapStringFromDisk(this, typeAsInt, activityArguments[1])) + palContent.setText(UtilityColorPalette.getColorMapStringFromDisk(this, typeAsInt, arguments[1])) palContent.setTextSize(TypedValue.COMPLEX_UNIT_PX, UIPreferences.textSizeNormal) } @@ -155,7 +155,7 @@ class SettingsColorPaletteEditor : BaseActivity(), OnMenuItemClickListener { override fun onMenuItemClick(item: MenuItem): Boolean { when (item.itemId) { - R.id.action_reset -> palContent.setText(UtilityColorPalette.getColorMapStringFromDisk(this, typeAsInt, activityArguments[1])) + R.id.action_reset -> palContent.setText(UtilityColorPalette.getColorMapStringFromDisk(this, typeAsInt, arguments[1])) R.id.action_clear -> palContent.setText("") R.id.action_help -> ObjectDialogue(this,"Not implemented yet.") R.id.action_share -> UtilityShare.textAsAttachment(this, palTitle.text.toString(), palContent.text.toString(), "wX_colormap_" + palTitle.text.toString() + ".txt") diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteListingActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteListingActivity.kt index 125f6961..9b8c5865 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteListingActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteListingActivity.kt @@ -34,16 +34,16 @@ import joshuatee.wx.ui.ObjectCardText class SettingsColorPaletteListingActivity : BaseActivity() { private var cardColorPalettes = mutableListOf() - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, null, false) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) WXGLNexrad.colorPaletteProducts.forEach { product -> val card = ObjectCardText( this, - linearLayout, + box, WXGLNexrad.productCodeStringToName[product] + ": " + ObjectColorPalette.radarColorPalette[product], UIPreferences.textSizeNormal, UIPreferences.paddingSettings diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsColorPickerActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsColorPickerActivity.kt index 8aa6982e..75236c6d 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsColorPickerActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsColorPickerActivity.kt @@ -67,9 +67,9 @@ class SettingsColorPickerActivity : AppCompatActivity(), OnColorChangedListener setSupportActionBar(toolbar) supportActionBar!!.setDisplayHomeAsUpEnabled(true) UtilityToolbar.fullScreenMode(toolbar, false) - val activityArguments = intent.getStringArrayExtra(INFO) - prefVal = activityArguments!![0] - title = activityArguments[1] + val arguments = intent.getStringArrayExtra(INFO) + prefVal = arguments!![0] + title = arguments[1] color = UtilityColor.setColor(prefVal) val currentColor = Utility.readPref(this, prefVal, color) buttonDefault.setTextColor(color) diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsColorsActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsColorsActivity.kt index e7718e45..5e0e734a 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsColorsActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsColorsActivity.kt @@ -35,13 +35,13 @@ import joshuatee.wx.ui.BaseActivity class SettingsColorsActivity : BaseActivity() { private var objectSettingsColorLabels = listOf() - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, null, false) - linearLayout = findViewById(R.id.linearLayout) - linearLayout.setBackgroundColor(Color.BLACK) + box = findViewById(R.id.linearLayout) + box.setBackgroundColor(Color.BLACK) val mapColorToPref = mutableMapOf( "Highway color" to "RADAR_COLOR_HW", "Secondary Highway color" to "RADAR_COLOR_HW_EXT", @@ -77,7 +77,7 @@ class SettingsColorsActivity : BaseActivity() { } objectSettingsColorLabels = mapColorToPref.keys.sorted().map { ObjectSettingsColorLabel(this, it, mapColorToPref[it]!!) } objectSettingsColorLabels.forEach { - linearLayout.addView(it.get()) + box.addView(it.get()) } } diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsLocationCanadaMapActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsLocationCanadaMapActivity.kt index ff51e951..92de2933 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsLocationCanadaMapActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsLocationCanadaMapActivity.kt @@ -48,8 +48,8 @@ class SettingsLocationCanadaMapActivity : BaseActivity(), OnClickListener { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_settings_location_canada_map, null, false) - val activityArguments = intent.getStringArrayExtra(URL) - url = activityArguments!![0] + val arguments = intent.getStringArrayExtra(URL)!! + url = arguments[0] title = url.uppercase(Locale.US) toolbar.subtitle = "Select a location and then use the back arrow to save." var imgRes = 0 @@ -163,7 +163,11 @@ class SettingsLocationCanadaMapActivity : BaseActivity(), OnClickListener { private fun getCityFromXml(token: String): String { val data = UtilityIO.readTextFileFromRaw(this.resources, R.raw.maps) val lines = data.split(GlobalVariables.newline) - lines.forEach { if (it.contains(token)) return it.parse("title=\"(.*?)\"") } + lines.forEach { + if (it.contains(token)) { + return it.parse("title=\"(.*?)\"") + } + } return "" } } diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsLocationGenericActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsLocationGenericActivity.kt index 76eefb26..8a0ba80c 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsLocationGenericActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsLocationGenericActivity.kt @@ -79,7 +79,7 @@ class SettingsLocationGenericActivity : BaseActivity(), OnMenuItemClickListener private lateinit var locLabelEt: EditText private lateinit var locXEt: EditText private lateinit var locYEt: EditText - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private lateinit var rl: RelativeLayout @SuppressLint("MissingSuperCall") @@ -88,16 +88,19 @@ class SettingsLocationGenericActivity : BaseActivity(), OnMenuItemClickListener locLabelEt = findViewById(R.id.locLabelEt) locXEt = findViewById(R.id.locXEt) locYEt = findViewById(R.id.locYEt) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) rl = findViewById(R.id.rl) + UtilityCitiesExtended.create(this) + UtilityCitiesCanada.initialize() + toolbarBottom.setOnMenuItemClickListener(this) Utility.writePref(this, "LOCATION_CANADA_PROV", "") Utility.writePref(this, "LOCATION_CANADA_CITY", "") Utility.writePref(this, "LOCATION_CANADA_ID", "") ObjectFab(this, R.id.fab) { fabSaveLocation() } val me = toolbarBottom.menu - listOf(R.id.cv1).forEach { ObjectCard(this, it) } + ObjectCard(this, R.id.cv1) val locNumArr = intent.getStringArrayExtra(LOC_NUM) locNum = locNumArr!![0] val locNumInt = locNum.toIntOrNull() ?: 0 @@ -222,7 +225,7 @@ class SettingsLocationGenericActivity : BaseActivity(), OnMenuItemClickListener alertSpcfwSw, alertWpcmpdSw ).forEach{ - linearLayout.addView(it.get()) + box.addView(it.get()) } hideNonUSNotifications() } @@ -308,8 +311,8 @@ class SettingsLocationGenericActivity : BaseActivity(), OnMenuItemClickListener val inflater = menuInflater inflater.inflate(R.menu.settings_location_generic, menu) val searchView = menu.findItem(R.id.ab_search).actionView as ArrayAdapterSearchView - UtilityCitiesExtended.create(this) - UtilityCitiesCanada.initialize() +// UtilityCitiesExtended.create(this) +// UtilityCitiesCanada.initialize() val combinedCitiesList = UtilityCitiesExtended.cityLabels.toList() val cityArrayAdapter = ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, combinedCitiesList) cityArrayAdapter.setDropDownViewResource(UIPreferences.spinnerLayout) @@ -511,7 +514,9 @@ class SettingsLocationGenericActivity : BaseActivity(), OnMenuItemClickListener private fun updateSubTitle() { val subTitleString = "WFO: " + Utility.readPref(this, "NWS$locNum", "") + " - Nexrad: " + Utility.readPref(this, "RID$locNum", "") - if (subTitleString != "WFO: - Nexrad: " && updateTitle) toolbar.subtitle = subTitleString + if (subTitleString != "WFO: - Nexrad: " && updateTitle) { + toolbar.subtitle = subTitleString + } } private fun changeSearchViewTextColor(view: View?) { diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsLocationRecyclerViewActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsLocationRecyclerViewActivity.kt index 5bfe2109..6045151d 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsLocationRecyclerViewActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsLocationRecyclerViewActivity.kt @@ -23,7 +23,6 @@ package joshuatee.wx.settings import android.annotation.SuppressLint import android.os.Bundle -import joshuatee.wx.MyApplication import joshuatee.wx.R import joshuatee.wx.notifications.UtilityWXJobService import joshuatee.wx.objects.FutureVoid @@ -50,7 +49,7 @@ class SettingsLocationRecyclerViewActivity : BaseActivity() { updateList() recyclerView = ObjectRecyclerViewGeneric(this, R.id.card_list) settingsLocationAdapterList = SettingsLocationAdapterList(locations) - recyclerView.recyclerView.adapter = settingsLocationAdapterList + recyclerView.adapter = settingsLocationAdapterList updateTitle() settingsLocationAdapterList.setListener(::itemSelected) getContent() @@ -63,7 +62,7 @@ class SettingsLocationRecyclerViewActivity : BaseActivity() { } private fun download() { - MyApplication.locations.indices.forEach { index -> + Location.locations.indices.forEach { index -> val objectForecastPackageCurrentConditions = ObjectCurrentConditions(this, index) currentConditions.add(objectForecastPackageCurrentConditions) objectForecastPackageCurrentConditions.format() @@ -77,14 +76,14 @@ class SettingsLocationRecyclerViewActivity : BaseActivity() { private fun updateList() { locations = MutableList(Location.numLocations) { "" } - MyApplication.locations.forEach { + Location.locations.forEach { it.updateObservation("") } } private fun updateListWithCurrentConditions() { locations.clear() - MyApplication.locations.forEachIndexed { index, location -> + Location.locations.forEachIndexed { index, location -> location.updateObservation(currentConditions[index].topLine) locations.add(currentConditions[index].topLine) } @@ -93,7 +92,7 @@ class SettingsLocationRecyclerViewActivity : BaseActivity() { override fun onRestart() { updateList() settingsLocationAdapterList = SettingsLocationAdapterList(locations) - recyclerView.recyclerView.adapter = settingsLocationAdapterList + recyclerView.adapter = settingsLocationAdapterList updateTitle() Location.refreshLocationData(this) getContent() @@ -122,19 +121,19 @@ class SettingsLocationRecyclerViewActivity : BaseActivity() { updateTitle() UtilityWXJobService.startService(this) } else { - ObjectPopupMessage(recyclerView.recyclerView, "Must have at least one location.") + ObjectPopupMessage(recyclerView.get(), "Must have at least one location.") } } private fun moveUp(position: Int) { if (position > 0) { - val locA = Location(this, position - 1) - val locB = Location(this, position) + val locA = ObjectLocation(this, position - 1) + val locB = ObjectLocation(this, position) locA.saveToNewSlot(position) locB.saveToNewSlot(position - 1) } else { - val locA = Location(this, Location.numLocations - 1) - val locB = Location(this, 0) + val locA = ObjectLocation(this, Location.numLocations - 1) + val locB = ObjectLocation(this, 0) locA.saveToNewSlot(0) locB.saveToNewSlot(Location.numLocations - 1) } @@ -143,13 +142,13 @@ class SettingsLocationRecyclerViewActivity : BaseActivity() { private fun moveDown(position: Int) { if (position < Location.numLocations - 1) { - val locA = Location(this, position) - val locB = Location(this, position + 1) + val locA = ObjectLocation(this, position) + val locB = ObjectLocation(this, position + 1) locA.saveToNewSlot(position + 1) locB.saveToNewSlot(position) } else { - val locA = Location(this, position) - val locB = Location(this, 0) + val locA = ObjectLocation(this, position) + val locB = ObjectLocation(this, 0) locA.saveToNewSlot(0) locB.saveToNewSlot(position) } diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsMainActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsMainActivity.kt index 3c3102ee..af34aa39 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsMainActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsMainActivity.kt @@ -36,17 +36,14 @@ import joshuatee.wx.ui.ObjectCardText import joshuatee.wx.ui.UtilityTheme import joshuatee.wx.util.* -//elys mod - deletefiles keep in -import joshuatee.wx.ui.UtilityUI - class SettingsMainActivity : BaseActivity() { - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, null, false) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) UtilityTheme.setPrimaryColor(this) val backuprestore = UtilityBackupRestore() val version = Utility.getVersion(this) @@ -78,25 +75,25 @@ class SettingsMainActivity : BaseActivity() { cardAbout.setOnClickListener { ObjectIntent(this, SettingsAboutActivity::class.java) } listOf( cardAbout.get(), + cardCtoF.get(), + cardColors.get(), + cardHS.get(), cardLocations.get(), - cardsn.get(), cardNotif.get(), - cardWidgets.get(), - cardColors.get(), cardPL.get(), cardRadar.get(), - cardHS.get(), + cardsn.get(), cardUI.get(), - cardCtoF.get(), + cardWidgets.get(), cardDeleteFiles.get(), cardbackuppref.get(), cardrestorepref.get() ).forEach { - linearLayout.addView(it) + box.addView(it) } //elys mod - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Check for Internet on startup", diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsNavDrawerActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsNavDrawerActivity.kt index 231cbcc6..552a618c 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsNavDrawerActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsNavDrawerActivity.kt @@ -32,17 +32,17 @@ import joshuatee.wx.util.UtilityAlertDialog class SettingsNavDrawerActivity : BaseActivity() { private var tokenList = "" - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_settings_navdrawer, null, false) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) tokenList = UtilityNavDrawer.getNavDrawerTokenList(this) title = "Navigation Drawer" toolbar.subtitle = "Turn items off or on for the main screen nav drawer." UtilityNavDrawer.labels.forEach { - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, it, diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsNotificationsActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsNotificationsActivity.kt index 40ca2b0c..89bf5f30 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsNotificationsActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsNotificationsActivity.kt @@ -46,49 +46,49 @@ import joshuatee.wx.util.Utility class SettingsNotificationsActivity : BaseActivity() { - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, null, false) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) toolbar.subtitle = "Please tap on text for additional help." - val cardSound = ObjectCardText(this, linearLayout, "Notification sound chooser", UIPreferences.textSizeNormal, UIPreferences.paddingSettings) - val cardWFOFilter = ObjectCardText(this, linearLayout, "WFO notification filter", UIPreferences.textSizeNormal, UIPreferences.paddingSettings) + val cardSound = ObjectCardText(this, box, "Notification sound chooser", UIPreferences.textSizeNormal, UIPreferences.paddingSettings) + val cardWFOFilter = ObjectCardText(this, box, "WFO notification filter", UIPreferences.textSizeNormal, UIPreferences.paddingSettings) ObjectCardText( this, - linearLayout, + box, "Text product notifications: " + UtilityNotificationTextProduct.showAll(), UIPreferences.textSizeNormal, UIPreferences.paddingSettings ) cardSound.setOnClickListener { notifSoundPicker() } cardWFOFilter.setOnClickListener { showWFONotificationFilterDialogue() } - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "US Tornado", - "ALERT_TORNADO_NOTIFICATION", - R.string.b_tornado + "NHC Advisories EPAC", + "ALERT_NHC_EPAC_NOTIFICATION", + R.string.b_nhc_epac ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "SPC MCD", - "ALERT_SPCMCD_NOTIFICATION", - R.string.b_mcd + "NHC Advisories ATL", + "ALERT_NHC_ATL_NOTIFICATION", + R.string.b_nhc_atl ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "SPC Watch", - "ALERT_SPCWAT_NOTIFICATION", - R.string.b_wat + "SPC MCD", + "ALERT_SPCMCD_NOTIFICATION", + R.string.b_mcd ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "SPC SWO", @@ -96,7 +96,7 @@ class SettingsNotificationsActivity : BaseActivity() { R.string.b_swo ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "SPC SWO include slight", @@ -104,111 +104,111 @@ class SettingsNotificationsActivity : BaseActivity() { R.string.b_swo2 ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "WPC MPD", - "ALERT_WPCMPD_NOTIFICATION", - R.string.b_mpd + "SPC Watch", + "ALERT_SPCWAT_NOTIFICATION", + R.string.b_wat ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "NHC Advisories EPAC", - "ALERT_NHC_EPAC_NOTIFICATION", - R.string.b_nhc_epac + "US Tornado", + "ALERT_TORNADO_NOTIFICATION", + R.string.b_tornado ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "NHC Advisories ATL", - "ALERT_NHC_ATL_NOTIFICATION", - R.string.b_nhc_atl + "WPC MPD", + "ALERT_WPCMPD_NOTIFICATION", + R.string.b_mpd ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "US Tornado Sound", - "ALERT_NOTIFICATION_SOUND_TORNADO", - R.string.alert_sound_tornado_label + "Sound: NHC Advisories EPAC", + "ALERT_NOTIFICATION_SOUND_NHC_EPAC", + R.string.alert_sound_nhc_epac_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "SPC MCD Sound", - "ALERT_NOTIFICATION_SOUND_SPCMCD", - R.string.alert_sound_spcmcd_label + "Sound: NHC Advisories ATL", + "ALERT_NOTIFICATION_SOUND_NHC_ATL", + R.string.alert_sound_nhc_atl_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "SPC Watch Sound", - "ALERT_NOTIFICATION_SOUND_SPCWAT", - R.string.alert_sound_spcwat_label + "Sound: SPC MCD", + "ALERT_NOTIFICATION_SOUND_SPCMCD", + R.string.alert_sound_spcmcd_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "SPC SWO Sound", + "Sound: SPC SWO", "ALERT_NOTIFICATION_SOUND_SPCSWO", R.string.alert_sound_spcswo_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "WPC MPD Sound", - "ALERT_NOTIFICATION_SOUND_WPCMPD", - R.string.alert_sound_wpcmpd_label + "Sound: SPC Watch", + "ALERT_NOTIFICATION_SOUND_SPCWAT", + R.string.alert_sound_spcwat_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "NHC Advisories EPAC Sound", - "ALERT_NOTIFICATION_SOUND_NHC_EPAC", - R.string.alert_sound_nhc_epac_label + "Sound: Text products", + "ALERT_NOTIFICATION_SOUND_TEXT_PROD", + R.string.alert_sound_text_prod_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "NHC Advisories ATL Sound", - "ALERT_NOTIFICATION_SOUND_NHC_ATL", - R.string.alert_sound_nhc_atl_label + "Sound: US Tornado", + "ALERT_NOTIFICATION_SOUND_TORNADO", + R.string.alert_sound_tornado_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "Text products Sound", - "ALERT_NOTIFICATION_SOUND_TEXT_PROD", - R.string.alert_sound_text_prod_label + "Sound: WPC MPD Sound", + "ALERT_NOTIFICATION_SOUND_WPCMPD", + R.string.alert_sound_wpcmpd_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "Play sound repeatedly", - "NOTIF_SOUND_REPEAT", - R.string.tv_notif_sound_repeat_label + "Alert only once", + "ALERT_ONLYONCE", + R.string.alert_onlyonce_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "Notif text to speech", - "NOTIF_TTS", - R.string.tv_notif_tts_label + "Auto cancel notifs", + "ALERT_AUTOCANCEL", + R.string.alert_autocancel_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Blackout alert sounds", @@ -216,23 +216,23 @@ class SettingsNotificationsActivity : BaseActivity() { R.string.alert_blackout_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "Alert only once", - "ALERT_ONLYONCE", - R.string.alert_onlyonce_label + "Notif text to speech", + "NOTIF_TTS", + R.string.tv_notif_tts_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "Auto cancel notifs", - "ALERT_AUTOCANCEL", - R.string.alert_autocancel_label + "Play sound repeatedly", + "NOTIF_SOUND_REPEAT", + R.string.tv_notif_sound_repeat_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Tor warn override blackout", @@ -240,7 +240,7 @@ class SettingsNotificationsActivity : BaseActivity() { R.string.alert_blackout_tornado_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Notification check interval in minutes", @@ -251,24 +251,24 @@ class SettingsNotificationsActivity : BaseActivity() { 121 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, - "Notification blackout - PM(h)", - "ALERT_BLACKOUT_PM", - R.string.alert_blackout_pm_np_label, - 22, + "Notification blackout - AM(h)", + "ALERT_BLACKOUT_AM", + R.string.alert_blackout_am_np_label, + 7, 0, 23 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, - "Notification blackout - AM(h)", - "ALERT_BLACKOUT_AM", - R.string.alert_blackout_am_np_label, - 7, + "Notification blackout - PM(h)", + "ALERT_BLACKOUT_PM", + R.string.alert_blackout_pm_np_label, + 22, 0, 23 ).card diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsRadarActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsRadarActivity.kt index fb90eb39..41aded8a 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsRadarActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsRadarActivity.kt @@ -42,19 +42,19 @@ import joshuatee.wx.util.Utility class SettingsRadarActivity : BaseActivity() { - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, null, false) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) toolbar.subtitle = "Please tap on text for additional help." val textSize = UIPreferences.textSizeLarge val padding = UIPreferences.paddingSettings - ObjectCardText(this, linearLayout, "Colors", textSize, SettingsColorsActivity::class.java, padding) - ObjectCardText(this, linearLayout, "Color Palettes", textSize, SettingsColorPaletteListingActivity::class.java, padding) - ObjectCardText(this, linearLayout, "Screen Recorder", textSize, SettingsTelecineActivity::class.java, padding) - linearLayout.addView( + ObjectCardText(this, box, "Colors", textSize, SettingsColorsActivity::class.java, padding) + ObjectCardText(this, box, "Color Palettes", textSize, SettingsColorPaletteListingActivity::class.java, padding) + ObjectCardText(this, box, "Screen Recorder", textSize, SettingsTelecineActivity::class.java, padding) + box.addView( ObjectSettingsCheckBox( this, "Warnings (TST/TOR/FFW)", @@ -63,7 +63,7 @@ class SettingsRadarActivity : BaseActivity() { ).get() ) RadarPreferences.radarWarningPolygons.forEach { - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, it.name, @@ -72,7 +72,7 @@ class SettingsRadarActivity : BaseActivity() { ).get() ) } - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "SPC MCD/Watches", @@ -80,7 +80,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.radar_show_watch_default_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "WPC MPDs", @@ -88,7 +88,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.radar_show_mpd_default_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Location marker", @@ -102,7 +102,7 @@ class SettingsRadarActivity : BaseActivity() { "LOCDOT_FOLLOWS_GPS", R.string.locdot_follows_gps_label ) - linearLayout.addView(gpsSw.get()) + box.addView(gpsSw.get()) gpsSw.setOnCheckedChangeListener { compoundButton, _ -> RadarPreferences.locationDotFollowsGps = compoundButton.isChecked if (RadarPreferences.locationDotFollowsGps != Utility.readPref( @@ -121,7 +121,7 @@ class SettingsRadarActivity : BaseActivity() { } //elys mod - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Location Heading Bug", @@ -129,8 +129,7 @@ class SettingsRadarActivity : BaseActivity() { ).get() ) - - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Black background", @@ -138,7 +137,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.nws_black_bg_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Canadian and Mexican borders", @@ -146,7 +145,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.camx_borders_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Center radar on location", @@ -154,7 +153,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.radar_center_on_location_default_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Cities", @@ -164,7 +163,7 @@ class SettingsRadarActivity : BaseActivity() { ) //elys mod - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Conus Radar", @@ -172,7 +171,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.conus_radar_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Convective Outlook Day One", @@ -180,7 +179,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.show_swo_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Counties", @@ -188,7 +187,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.show_county_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Counties use high resolution data", @@ -196,7 +195,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.county_hires_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "County labels", @@ -205,7 +204,7 @@ class SettingsRadarActivity : BaseActivity() { ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Hail index", @@ -213,7 +212,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.show_hi_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Highways", @@ -221,7 +220,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.cod_hw_default_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Launch app directly to radar", @@ -229,7 +228,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.launch_to_radar_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Lakes and rivers", @@ -237,7 +236,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.cod_lakes_default_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Multi-pane: share lat/lon/zoom", @@ -245,7 +244,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.dualpaneshareposn_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Multipurpose radar icons", @@ -253,7 +252,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.radar_icons_level2_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Observations", @@ -261,7 +260,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.obs_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Remember location / product", @@ -269,7 +268,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.rememberloc_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Screen stays on and auto refresh radar", @@ -277,7 +276,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.autorefresh_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Secondary roads", @@ -285,7 +284,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.hw_enh_ext_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Spotters", @@ -293,7 +292,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.spotters_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Spotter labels", @@ -301,7 +300,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.spotters_label_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "States use high resolution data", @@ -309,7 +308,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.state_hires_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Storm tracks", @@ -318,7 +317,7 @@ class SettingsRadarActivity : BaseActivity() { ).get() ) //elys mod - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Hail index", @@ -327,7 +326,7 @@ class SettingsRadarActivity : BaseActivity() { ).get() ) //elys mod - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Hail labels", @@ -335,7 +334,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.show_hi_label_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Tornado Vortex Signature", @@ -343,7 +342,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.show_tvs_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Use JNI for radar (beta)", @@ -352,7 +351,7 @@ class SettingsRadarActivity : BaseActivity() { ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Wind barbs", @@ -360,7 +359,7 @@ class SettingsRadarActivity : BaseActivity() { R.string.obs_windbarbs_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "WPC Fronts and pressure highs and lows", @@ -369,7 +368,7 @@ class SettingsRadarActivity : BaseActivity() { ).get() ) //elys mod - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Enable userpoints icons on radar", @@ -382,7 +381,7 @@ class SettingsRadarActivity : BaseActivity() { // start of slides // - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Animation speed", @@ -395,7 +394,7 @@ class SettingsRadarActivity : BaseActivity() { ) //elys mod //radar legends settings// - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Color Legend width", @@ -406,7 +405,7 @@ class SettingsRadarActivity : BaseActivity() { 100 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Color Legend text size", @@ -420,7 +419,7 @@ class SettingsRadarActivity : BaseActivity() { /////// //elys mod //Conus Radar Zoom - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Conus Radar Zoom", @@ -433,7 +432,7 @@ class SettingsRadarActivity : BaseActivity() { ) //elys mod - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Default line size", @@ -445,7 +444,7 @@ class SettingsRadarActivity : BaseActivity() { ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "GPS update interval", @@ -456,7 +455,7 @@ class SettingsRadarActivity : BaseActivity() { 60 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Refresh interval", @@ -467,7 +466,7 @@ class SettingsRadarActivity : BaseActivity() { 15 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Aviation dot size", @@ -478,7 +477,7 @@ class SettingsRadarActivity : BaseActivity() { 50 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Convective outlook line size", @@ -489,7 +488,7 @@ class SettingsRadarActivity : BaseActivity() { 10 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "County line size", @@ -500,7 +499,7 @@ class SettingsRadarActivity : BaseActivity() { 10 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Detailed observations Zoom", @@ -511,7 +510,7 @@ class SettingsRadarActivity : BaseActivity() { 10 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Draw tool line size", @@ -523,7 +522,7 @@ class SettingsRadarActivity : BaseActivity() { ).card ) /* - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "GPS Circle line size", @@ -537,7 +536,7 @@ class SettingsRadarActivity : BaseActivity() { */ //elys mod - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Hail icon size", @@ -550,7 +549,7 @@ class SettingsRadarActivity : BaseActivity() { ) //elys mod - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Hail Text size", @@ -561,8 +560,7 @@ class SettingsRadarActivity : BaseActivity() { 20 ).card ) - - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Highway line size", @@ -573,7 +571,7 @@ class SettingsRadarActivity : BaseActivity() { 10 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Lake line size", @@ -586,7 +584,7 @@ class SettingsRadarActivity : BaseActivity() { ) //elys mod - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Location icon size", @@ -599,7 +597,7 @@ class SettingsRadarActivity : BaseActivity() { ) //elys mod - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Location bug size", @@ -610,8 +608,7 @@ class SettingsRadarActivity : BaseActivity() { 530 ).card ) - - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "MCD/MPD/Watch line size", @@ -622,7 +619,7 @@ class SettingsRadarActivity : BaseActivity() { 10 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Secondary road line size", @@ -633,7 +630,7 @@ class SettingsRadarActivity : BaseActivity() { 10 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "State line size", @@ -644,7 +641,7 @@ class SettingsRadarActivity : BaseActivity() { 10 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Storm spotter size", @@ -655,7 +652,7 @@ class SettingsRadarActivity : BaseActivity() { 50 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Storm tracks line size", @@ -666,7 +663,7 @@ class SettingsRadarActivity : BaseActivity() { 10 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Text size", @@ -679,7 +676,7 @@ class SettingsRadarActivity : BaseActivity() { ) //elys mod - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "TVS icon size", @@ -692,7 +689,7 @@ class SettingsRadarActivity : BaseActivity() { ) //elys mod - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Userpoints icon size", @@ -703,8 +700,7 @@ class SettingsRadarActivity : BaseActivity() { 530 ).card ) - - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Warning line size", @@ -715,7 +711,7 @@ class SettingsRadarActivity : BaseActivity() { 10 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Wind barbs line size", @@ -726,11 +722,7 @@ class SettingsRadarActivity : BaseActivity() { 10 ).card ) - - - - - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "WXOGL initial view size", diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsUIActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsUIActivity.kt index fef86291..3d47b9aa 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsUIActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsUIActivity.kt @@ -60,7 +60,7 @@ class SettingsUIActivity : BaseActivity() { private var tilesPerRowStart = 0 private var navDrawerMainScreen = false private var navDrawerMainScreenOnRight = true - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private lateinit var et1: EditText private lateinit var et2: EditText private lateinit var et3: EditText @@ -68,7 +68,7 @@ class SettingsUIActivity : BaseActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_settings_ui, null, false) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) et1 = findViewById(R.id.et1) et2 = findViewById(R.id.et2) et3 = findViewById(R.id.et3) @@ -81,12 +81,12 @@ class SettingsUIActivity : BaseActivity() { val padding = UIPreferences.paddingSettings if (UIPreferences.navDrawerMainScreen) { val cardNavDrawer = ObjectCardText(this, "Navigation Drawer Configuration", textSize, SettingsNavDrawerActivity::class.java, padding) - linearLayout.addView(cardNavDrawer.get()) + box.addView(cardNavDrawer.get()) } ObjectCard(this, R.id.cv_tab_labels) setupEditText() (0 until 20).forEach { textSizeArr.add(((it + 1) * 50).toString()) } - linearLayout.addView( + box.addView( ObjectSettingsSpinner( this, "Theme (restarts app)", @@ -96,7 +96,7 @@ class SettingsUIActivity : BaseActivity() { colorArr ).card ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Check for SPC MCD/Watches", @@ -104,7 +104,7 @@ class SettingsUIActivity : BaseActivity() { R.string.checkspc_switch_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Check for WPC MPDs", @@ -112,7 +112,7 @@ class SettingsUIActivity : BaseActivity() { R.string.checkwpc_switch_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Check for TOR,TST,FFW", @@ -120,7 +120,7 @@ class SettingsUIActivity : BaseActivity() { R.string.checktor_switch_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Dual-pane radar from main screen", @@ -128,15 +128,15 @@ class SettingsUIActivity : BaseActivity() { R.string.dualpane_radar_icon_tv ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, - "Fahrenheit in current conditions", + "Fahrenheit in current conditions/7day", "UNITS_F", R.string.units_f_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Fullscreen mode", @@ -144,7 +144,7 @@ class SettingsUIActivity : BaseActivity() { R.string.fullscreen_mode_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "GOES GLM for lightning (requires restart)", @@ -152,7 +152,7 @@ class SettingsUIActivity : BaseActivity() { R.string.use_goes_for_lightning ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Hide top toolbar (restarts app)", @@ -160,7 +160,7 @@ class SettingsUIActivity : BaseActivity() { R.string.hide_top_toolbar_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Icons evenly spaced", @@ -168,7 +168,7 @@ class SettingsUIActivity : BaseActivity() { R.string.icons_spacing_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Lock toolbars", @@ -176,7 +176,7 @@ class SettingsUIActivity : BaseActivity() { R.string.lock_toolbars_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Main screen radar button (requires restart)", @@ -184,7 +184,7 @@ class SettingsUIActivity : BaseActivity() { R.string.mainscreen_radar_button ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Media control notification", @@ -192,7 +192,7 @@ class SettingsUIActivity : BaseActivity() { R.string.media_control_notif_tv ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Millibars in current conditions", @@ -200,7 +200,7 @@ class SettingsUIActivity : BaseActivity() { R.string.units_m_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Models: use FAB", @@ -208,7 +208,7 @@ class SettingsUIActivity : BaseActivity() { R.string.fab_in_models_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Navigation drawer on main screen", @@ -216,7 +216,7 @@ class SettingsUIActivity : BaseActivity() { R.string.nav_drawer_main_screen_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Navigation drawer on main screen is on right side", @@ -224,7 +224,7 @@ class SettingsUIActivity : BaseActivity() { R.string.nav_drawer_main_screen_on_right_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "NWS Text: remove line breaks", @@ -232,7 +232,7 @@ class SettingsUIActivity : BaseActivity() { R.string.nws_text_removelinebreak_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Prevent accidental exit", @@ -240,7 +240,7 @@ class SettingsUIActivity : BaseActivity() { R.string.prevent_accidental_exit_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Simple mode (restarts app)", @@ -248,7 +248,7 @@ class SettingsUIActivity : BaseActivity() { R.string.simple_mode_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Radar: immersive mode", @@ -256,7 +256,7 @@ class SettingsUIActivity : BaseActivity() { R.string.radar_immersive_mode_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Radar: transparent status bar", @@ -264,7 +264,7 @@ class SettingsUIActivity : BaseActivity() { R.string.radar_statusbar_transparent_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Radar: transparent toolbars", @@ -272,7 +272,7 @@ class SettingsUIActivity : BaseActivity() { R.string.radar_toolbar_transparent_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Record screen for sharing", @@ -280,7 +280,7 @@ class SettingsUIActivity : BaseActivity() { R.string.record_screen_share_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Translate abbreviations", @@ -288,7 +288,7 @@ class SettingsUIActivity : BaseActivity() { R.string.translate_text_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Use AWC Radar Mosaic", @@ -296,7 +296,7 @@ class SettingsUIActivity : BaseActivity() { R.string.use_awc_mosaic, ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Use new NWS API for 7 day", @@ -304,7 +304,7 @@ class SettingsUIActivity : BaseActivity() { R.string.use_nws_api ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Use new NWS API for Hourly", @@ -312,7 +312,7 @@ class SettingsUIActivity : BaseActivity() { R.string.use_nws_api_hourly ).get() ) -// linearLayout.addView( +// box.addView( // ObjectSettingsCheckBox( // this, // "Show VR button on main screen", @@ -320,7 +320,7 @@ class SettingsUIActivity : BaseActivity() { // R.string.vr_button_label // ).card // ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "WFO: remember location", @@ -328,7 +328,7 @@ class SettingsUIActivity : BaseActivity() { R.string.wfo_remember ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Widgets: prevent opening app on tap", @@ -339,7 +339,7 @@ class SettingsUIActivity : BaseActivity() { // // sliders // - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Animation - frames for toolbar icon", @@ -350,7 +350,7 @@ class SettingsUIActivity : BaseActivity() { 40 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Card corner radius", @@ -361,7 +361,7 @@ class SettingsUIActivity : BaseActivity() { 10 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Home screen text length", @@ -372,7 +372,7 @@ class SettingsUIActivity : BaseActivity() { 1000 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Image tiles per row", @@ -383,7 +383,7 @@ class SettingsUIActivity : BaseActivity() { 10 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "NWS icon size", @@ -394,7 +394,7 @@ class SettingsUIActivity : BaseActivity() { 50 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Refresh interval for location in minutes", @@ -405,7 +405,7 @@ class SettingsUIActivity : BaseActivity() { 120 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Text size", @@ -416,7 +416,7 @@ class SettingsUIActivity : BaseActivity() { 25 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Text to speech speed, requires app restart", @@ -427,7 +427,7 @@ class SettingsUIActivity : BaseActivity() { 20 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "UI elevation height", diff --git a/app/src/main/java/joshuatee/wx/settings/SettingsWidgetsActivity.kt b/app/src/main/java/joshuatee/wx/settings/SettingsWidgetsActivity.kt index 251e7f92..2769543d 100644 --- a/app/src/main/java/joshuatee/wx/settings/SettingsWidgetsActivity.kt +++ b/app/src/main/java/joshuatee/wx/settings/SettingsWidgetsActivity.kt @@ -38,19 +38,19 @@ class SettingsWidgetsActivity : BaseActivity(), CompoundButton.OnCheckedChangeLi private val sectors = listOf("regional", "usa") private val nexradCenterList = listOf("Center", "NW", "NE", "SW", "SE", "N", "E", "S", "W") - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private lateinit var abSwitch: SwitchCompat @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_settings_widgets, null, false) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) abSwitch = findViewById(R.id.abSwitch) toolbar.subtitle = "Please tap on text for additional help." val locations = (1 until Location.numLocations + 1).map { "$it: " + Utility.readPref(this, "LOC" + it + "_LABEL", "").take(20) } - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Do not show 7day in CC widget", @@ -58,7 +58,7 @@ class SettingsWidgetsActivity : BaseActivity(), CompoundButton.OnCheckedChangeLi R.string.cc_widget_show_sevenday ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Download AFD", @@ -66,7 +66,7 @@ class SettingsWidgetsActivity : BaseActivity(), CompoundButton.OnCheckedChangeLi R.string.loc1_txt_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Download HWO", @@ -74,7 +74,7 @@ class SettingsWidgetsActivity : BaseActivity(), CompoundButton.OnCheckedChangeLi R.string.loc1_txt_hwo_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Download mosaics", @@ -82,7 +82,7 @@ class SettingsWidgetsActivity : BaseActivity(), CompoundButton.OnCheckedChangeLi R.string.loc1_mosaics_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Download nexrad radar", @@ -90,7 +90,7 @@ class SettingsWidgetsActivity : BaseActivity(), CompoundButton.OnCheckedChangeLi R.string.loc1_radar_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Download radar mosaic", @@ -98,7 +98,7 @@ class SettingsWidgetsActivity : BaseActivity(), CompoundButton.OnCheckedChangeLi R.string.loc1_mosaics_rad_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsSpinner( this, "Radar mosaic level", @@ -108,7 +108,7 @@ class SettingsWidgetsActivity : BaseActivity(), CompoundButton.OnCheckedChangeLi sectors ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSpinner( this, "Location", @@ -118,7 +118,7 @@ class SettingsWidgetsActivity : BaseActivity(), CompoundButton.OnCheckedChangeLi locations ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSpinner( this, "Nexrad centered at:", @@ -128,7 +128,7 @@ class SettingsWidgetsActivity : BaseActivity(), CompoundButton.OnCheckedChangeLi nexradCenterList ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Widget check interval in minutes", @@ -139,7 +139,7 @@ class SettingsWidgetsActivity : BaseActivity(), CompoundButton.OnCheckedChangeLi 120 ).card ) - linearLayout.addView( + box.addView( ObjectSettingsSeekBar( this, "Widget nexrad size", diff --git a/app/src/main/java/joshuatee/wx/settings/TileObjectColorPalette.kt b/app/src/main/java/joshuatee/wx/settings/TileObjectColorPalette.kt index 47fe0d01..7ff78249 100644 --- a/app/src/main/java/joshuatee/wx/settings/TileObjectColorPalette.kt +++ b/app/src/main/java/joshuatee/wx/settings/TileObjectColorPalette.kt @@ -35,7 +35,7 @@ import joshuatee.wx.util.UtilityLog internal class TileObjectColorPalette(val colorMapLabel: String, val toolbar: Toolbar, val prefToken: String, context: Context, product: String, val builtin: Boolean) { - val bitmapWithText: Bitmap + internal val bitmapWithText: Bitmap init { val oldMap: String diff --git a/app/src/main/java/joshuatee/wx/settings/UtilityLocation.kt b/app/src/main/java/joshuatee/wx/settings/UtilityLocation.kt index c139a6d3..4efabfd7 100644 --- a/app/src/main/java/joshuatee/wx/settings/UtilityLocation.kt +++ b/app/src/main/java/joshuatee/wx/settings/UtilityLocation.kt @@ -27,7 +27,6 @@ import android.content.pm.PackageManager import android.location.Location import android.location.LocationManager import androidx.core.content.ContextCompat -import joshuatee.wx.MyApplication import joshuatee.wx.common.GlobalArrays import joshuatee.wx.radar.LatLon import joshuatee.wx.radar.RID @@ -209,11 +208,11 @@ object UtilityLocation { return LatLon(x, y) } - fun hasAlerts(locNum: Int) = MyApplication.locations[locNum].notification - || MyApplication.locations[locNum].notificationMcd - || MyApplication.locations[locNum].ccNotification - || MyApplication.locations[locNum].sevenDayNotification - || MyApplication.locations[locNum].notificationSpcFw - || MyApplication.locations[locNum].notificationSwo - || MyApplication.locations[locNum].notificationWpcMpd + fun hasAlerts(locNum: Int) = joshuatee.wx.settings.Location.locations[locNum].notification + || joshuatee.wx.settings.Location.locations[locNum].notificationMcd + || joshuatee.wx.settings.Location.locations[locNum].ccNotification + || joshuatee.wx.settings.Location.locations[locNum].sevenDayNotification + || joshuatee.wx.settings.Location.locations[locNum].notificationSpcFw + || joshuatee.wx.settings.Location.locations[locNum].notificationSwo + || joshuatee.wx.settings.Location.locations[locNum].notificationWpcMpd } diff --git a/app/src/main/java/joshuatee/wx/spc/LSRbyWFOActivity.kt b/app/src/main/java/joshuatee/wx/spc/LSRbyWFOActivity.kt index ff3d7f91..de9ae0e0 100644 --- a/app/src/main/java/joshuatee/wx/spc/LSRbyWFOActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/LSRbyWFOActivity.kt @@ -57,7 +57,7 @@ class LsrByWfoActivity : AudioPlayActivity(), OnMenuItemClickListener { private var mapShown = false private lateinit var star: MenuItem private lateinit var scrollView: ScrollView - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private var locations = listOf() private val prefToken = "WFO_FAV" private var ridFavOld = "" @@ -79,11 +79,11 @@ class LsrByWfoActivity : AudioPlayActivity(), OnMenuItemClickListener { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_afd, R.menu.lsrbywfo) scrollView = findViewById(R.id.scrollView) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) toolbarBottom.setOnMenuItemClickListener(this) star = toolbarBottom.menu.findItem(R.id.action_fav) - val activityArguments = intent.getStringArrayExtra(URL) - wfo = activityArguments!![0] + val arguments = intent.getStringArrayExtra(URL)!! + wfo = arguments[0] if (wfo == "") { wfo = "OUN" } @@ -174,7 +174,7 @@ class LsrByWfoActivity : AudioPlayActivity(), OnMenuItemClickListener { } scrollView.smoothScrollTo(0, 0) ridFavOld = UIPreferences.wfoFav - linearLayout.removeAllViewsInLayout() + box.removeAllViewsInLayout() FutureVoid(this, ::downloadFirst, ::getLsrFromWfo) } @@ -209,7 +209,7 @@ class LsrByWfoActivity : AudioPlayActivity(), OnMenuItemClickListener { var i = 0 (1..maxVersions + 1 step 2).forEach { version -> lsrList.add("") - textList.add(ObjectCardText(this@LsrByWfoActivity, linearLayout)) + textList.add(ObjectCardText(this, box)) val iFinal = i FutureVoid(this, { download(iFinal, version) }, { update(iFinal) }) i += 1 diff --git a/app/src/main/java/joshuatee/wx/spc/SPCCompmapActivity.kt b/app/src/main/java/joshuatee/wx/spc/SPCCompmapActivity.kt index bda686f6..cc255508 100644 --- a/app/src/main/java/joshuatee/wx/spc/SPCCompmapActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SPCCompmapActivity.kt @@ -26,12 +26,11 @@ import android.os.Bundle import android.content.res.Configuration import android.view.Menu import android.view.MenuItem -import android.widget.AdapterView import joshuatee.wx.R import joshuatee.wx.objects.FutureVoid import joshuatee.wx.ui.BaseActivity import joshuatee.wx.ui.ObjectNavDrawer -import joshuatee.wx.ui.ObjectTouchImageView +import joshuatee.wx.ui.TouchImage import joshuatee.wx.util.Utility import joshuatee.wx.util.UtilityImg import joshuatee.wx.util.UtilityShare @@ -39,7 +38,7 @@ import joshuatee.wx.util.UtilityShare class SpcCompmapActivity : BaseActivity() { private var layerStr = "" - private lateinit var img: ObjectTouchImageView + private lateinit var image: TouchImage private var bitmap = UtilityImg.getBlankBitmap() private lateinit var objectNavDrawer: ObjectNavDrawer private val paramList = UtilitySpcCompmap.labels.toMutableList() @@ -53,9 +52,9 @@ class SpcCompmapActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_image_show_navdrawer, R.menu.shared_multigraphics, false) objectNavDrawer = ObjectNavDrawer(this, paramList) - objectNavDrawer.listView.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ -> - objectNavDrawer.listView.setItemChecked(position, false) - objectNavDrawer.drawerLayout.closeDrawer(objectNavDrawer.listView) + objectNavDrawer.setListener2 { _, _, position, _ -> + objectNavDrawer.setItemChecked(position, false) + objectNavDrawer.close() val positionStr = UtilitySpcCompmap.urlIndex[position] if (paramList[position].contains("(on)")) { paramList[position] = paramList[position].replace("\\(on\\) ".toRegex(), "") @@ -68,7 +67,7 @@ class SpcCompmapActivity : BaseActivity() { } } toolbar.setOnClickListener { objectNavDrawer.open() } - img = ObjectTouchImageView(this, R.id.iv) + image = TouchImage(this, R.id.iv) layerStr = Utility.readPref(this, "SPCCOMPMAP_LAYERSTR", "a7:a19:") // mslp, hpc fronts setupInitLayerString() getContent() @@ -89,8 +88,8 @@ class SpcCompmapActivity : BaseActivity() { break } } - objectNavDrawer.listView.setItemChecked(position, false) - objectNavDrawer.drawerLayout.closeDrawer(objectNavDrawer.listView) + objectNavDrawer.setItemChecked(position, false) + objectNavDrawer.close() if (!paramList[position].contains("(on)")) { paramList[position] = "(on) " + paramList[position] } @@ -106,23 +105,23 @@ class SpcCompmapActivity : BaseActivity() { } private fun showImage() { - img.setBitmap(bitmap) - img.firstRunSetZoomPosn("SPCCOMPMAP") + image.setBitmap(bitmap) + image.firstRunSetZoomPosn("SPCCOMPMAP") Utility.writePref(this, "SPCCOMPMAP_LAYERSTR", layerStr) } override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - objectNavDrawer.actionBarDrawerToggle.syncState() + objectNavDrawer.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - objectNavDrawer.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawer.onConfigurationChanged(newConfig) } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawer.onOptionsItemSelected(item)) { return true } when (item.itemId) { @@ -133,7 +132,7 @@ class SpcCompmapActivity : BaseActivity() { } override fun onStop() { - img.imgSavePosnZoom("SPCCOMPMAP") + image.imgSavePosnZoom("SPCCOMPMAP") super.onStop() } } diff --git a/app/src/main/java/joshuatee/wx/spc/SPCFireOutlookActivity.kt b/app/src/main/java/joshuatee/wx/spc/SPCFireOutlookActivity.kt index 2ab86e4f..a2b09d4c 100644 --- a/app/src/main/java/joshuatee/wx/spc/SPCFireOutlookActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SPCFireOutlookActivity.kt @@ -54,31 +54,31 @@ class SpcFireOutlookActivity : AudioPlayActivity(), OnMenuItemClickListener { private var textProduct = "" private var imageUrl = "" private var bitmap = UtilityImg.getBlankBitmap() - private lateinit var activityArguments: Array + private lateinit var arguments: Array private lateinit var objectCardImage: ObjectCardImage private lateinit var objectCardText: ObjectCardText - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private var tabletInLandscape = false private var html = "" @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout_bottom_toolbar, R.menu.spcmcdshowdetail) - activityArguments = intent.getStringArrayExtra(NUMBER)!! - textProduct = activityArguments[0] - imageUrl = activityArguments[1] + arguments = intent.getStringArrayExtra(NUMBER)!! + textProduct = arguments[0] + imageUrl = arguments[1] title = "Fire Weather Outlook" toolbar.subtitle = "SPC $textProduct" - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) toolbarBottom.setOnMenuItemClickListener(this) tabletInLandscape = UtilityUI.isTablet() && UtilityUI.isLandScape(this) if (tabletInLandscape) { - linearLayout.orientation = LinearLayout.HORIZONTAL - objectCardImage = ObjectCardImage(this, linearLayout, UtilityImg.getBlankBitmap(), 2) + box.orientation = LinearLayout.HORIZONTAL + objectCardImage = ObjectCardImage(this, box, UtilityImg.getBlankBitmap(), 2) } else { - objectCardImage = ObjectCardImage(this, linearLayout) + objectCardImage = ObjectCardImage(this, box) } - objectCardText = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) + objectCardText = ObjectCardText(this, box, toolbar, toolbarBottom) getContent() } @@ -100,7 +100,7 @@ class SpcFireOutlookActivity : AudioPlayActivity(), OnMenuItemClickListener { private fun showText() { objectCardText.text = html - UtilityTts.conditionalPlay(activityArguments, 1, applicationContext, objectCardText.text, textProduct) + UtilityTts.conditionalPlay(arguments, 1, applicationContext, objectCardText.text, textProduct) } override fun onMenuItemClick(item: MenuItem): Boolean { diff --git a/app/src/main/java/joshuatee/wx/spc/SPCMesoActivity.kt b/app/src/main/java/joshuatee/wx/spc/SPCMesoActivity.kt index 7ae7caa1..cd9e23c3 100644 --- a/app/src/main/java/joshuatee/wx/spc/SPCMesoActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SPCMesoActivity.kt @@ -27,6 +27,7 @@ import android.content.res.Configuration import androidx.appcompat.widget.Toolbar.OnMenuItemClickListener import android.view.Menu import android.view.MenuItem +import android.widget.ImageView import android.widget.LinearLayout import joshuatee.wx.Extensions.getHtml import joshuatee.wx.Extensions.safeGet @@ -86,7 +87,7 @@ class SpcMesoActivity : VideoRecordActivity(), OnMenuItemClickListener { private var prefModel = "" private lateinit var prefParam: String private lateinit var prefParamLabel: String - private lateinit var drw: ObjectNavDrawerCombo + private lateinit var objectNavDrawerCombo: ObjectNavDrawerCombo private lateinit var displayData: DisplayDataNoSpinner private val prefToken = "SPCMESO_FAV" @@ -102,11 +103,11 @@ class SpcMesoActivity : VideoRecordActivity(), OnMenuItemClickListener { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { - var activityArguments = intent.getStringArrayExtra(INFO) - if (activityArguments == null) { - activityArguments = arrayOf("", "1", "SPCMESO") - } - val numPanesAsString = activityArguments[1] + val arguments = intent.getStringArrayExtra(INFO)!! +// if (arguments == null) { +// arguments = arrayOf("", "1", "SPCMESO") +// } + val numPanesAsString = arguments[1] numPanes = numPanesAsString.toIntOrNull() ?: 0 if (numPanes == 1) { super.onCreate(savedInstanceState, R.layout.activity_spcmeso, R.menu.spcmesomultipane, iconsEvenlySpaced = false, bottomToolbar = true) @@ -119,7 +120,7 @@ class SpcMesoActivity : VideoRecordActivity(), OnMenuItemClickListener { } toolbarBottom.setOnMenuItemClickListener(this) title = "SPC Meso" - prefModel = activityArguments[2] + prefModel = arguments[2] prefSector = prefModel + numPanesAsString + "_SECTOR_LAST_USED" prefParam = prefModel + numPanesAsString + "_PARAM_LAST_USED" prefParamLabel = prefModel + numPanesAsString + "_PARAM_LAST_USED_LABEL" @@ -130,8 +131,8 @@ class SpcMesoActivity : VideoRecordActivity(), OnMenuItemClickListener { displayData.param[1] = "500mb" displayData.paramLabel[1] = "500mb Analysis" } - if (activityArguments[0] != "" && numPanes == 1) { - val tmpArrFav = UtilitySpcMeso.setParamFromFav(activityArguments[0]) + if (arguments[0] != "" && numPanes == 1) { + val tmpArrFav = UtilitySpcMeso.setParamFromFav(arguments[0]) displayData.param[0] = tmpArrFav displayData.paramLabel[0] = UtilitySpcMeso.getLabelFromParam(tmpArrFav) } else { @@ -175,7 +176,7 @@ class SpcMesoActivity : VideoRecordActivity(), OnMenuItemClickListener { menuCounty.title = on + menuCountyStr } if (numPanes == 1) { - displayData.img[0].setOnTouchListener(object : OnSwipeTouchListener(this) { + displayData.img[0].setListener(object : OnSwipeTouchListener(this) { override fun onSwipeLeft() { if (displayData.img[curImg].currentZoom < 1.01f) { val index = UtilitySpcMeso.moveForward(getFavList()) showProductInFavList(index) @@ -188,10 +189,10 @@ class SpcMesoActivity : VideoRecordActivity(), OnMenuItemClickListener { }) } UtilitySpcMeso.create() - drw = ObjectNavDrawerCombo(this, UtilitySpcMeso.groups, UtilitySpcMeso.longCodes, UtilitySpcMeso.shortCodes, "") - drw.listView.setOnChildClickListener { _, _, groupPosition, childPosition, _ -> - drw.drawerLayout.closeDrawer(drw.listView) - setAndLaunchParam(drw.getToken(groupPosition, childPosition), groupPosition, childPosition) + objectNavDrawerCombo = ObjectNavDrawerCombo(this, UtilitySpcMeso.groups, UtilitySpcMeso.longCodes, UtilitySpcMeso.shortCodes, "") + objectNavDrawerCombo.setListener2 { _, _, groupPosition, childPosition, _ -> + objectNavDrawerCombo.close() + setAndLaunchParam(objectNavDrawerCombo.getToken(groupPosition, childPosition), groupPosition, childPosition) getContent() true } @@ -219,14 +220,15 @@ class SpcMesoActivity : VideoRecordActivity(), OnMenuItemClickListener { } } ) { - (0 until numPanes).forEach { - if (numPanes > 1) { - UtilityImg.resizeViewAndSetImage(this, displayData.bitmap[it], displayData.img[it]) - } else { - displayData.img[it].setImageBitmap(displayData.bitmap[it]) - } - displayData.img[it].maxZoom = 4f - animRan = false + (0 until numPanes).forEach { + if (numPanes > 1) { + UtilityImg.resizeViewAndSetImage(this, displayData.bitmap[it], displayData.img[it].get() as ImageView) + } else { +// displayData.img[it].setImageBitmap(displayData.bitmap[it]) + displayData.img[it].setBitmap(displayData.bitmap[it]) + } + displayData.img[it].setMaxZoom(4.0f) + animRan = false } if (!firstRun) { (0 until numPanes).forEach { @@ -266,7 +268,9 @@ class SpcMesoActivity : VideoRecordActivity(), OnMenuItemClickListener { } override fun onMenuItemClick(item: MenuItem): Boolean { - if (drw.actionBarDrawerToggle.onOptionsItemSelected(item)) return true + if (objectNavDrawerCombo.onOptionsItemSelected(item)) { + return true + } when (item.itemId) { R.id.action_toggleRadar -> { if (showRadar) { @@ -396,7 +400,7 @@ class SpcMesoActivity : VideoRecordActivity(), OnMenuItemClickListener { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (drw.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawerCombo.onOptionsItemSelected(item)) { return true } favListParm = UtilityFavorites.setupMenu(this, UIPreferences.spcMesoFav, displayData.param[curImg], prefToken) @@ -435,12 +439,12 @@ class SpcMesoActivity : VideoRecordActivity(), OnMenuItemClickListener { override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - drw.actionBarDrawerToggle.syncState() + objectNavDrawerCombo.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - drw.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawerCombo.onConfigurationChanged(newConfig) } private fun getHelp() { diff --git a/app/src/main/java/joshuatee/wx/spc/SPCSWOActivity.kt b/app/src/main/java/joshuatee/wx/spc/SPCSWOActivity.kt index cd77d584..7bfeaab3 100644 --- a/app/src/main/java/joshuatee/wx/spc/SPCSWOActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SPCSWOActivity.kt @@ -30,15 +30,12 @@ import androidx.appcompat.widget.Toolbar.OnMenuItemClickListener import joshuatee.wx.R import joshuatee.wx.audio.AudioPlayActivity import joshuatee.wx.audio.UtilityTts -import joshuatee.wx.ui.ObjectCardImage -import joshuatee.wx.ui.ObjectCardText import joshuatee.wx.util.UtilityDownload import joshuatee.wx.util.UtilityShare import joshuatee.wx.Extensions.* import joshuatee.wx.objects.FutureVoid import joshuatee.wx.objects.ObjectIntent -import joshuatee.wx.ui.ObjectLinearLayout -import joshuatee.wx.ui.UtilityUI +import joshuatee.wx.ui.* import joshuatee.wx.util.UtilityImg class SpcSwoActivity : AudioPlayActivity(), OnMenuItemClickListener { @@ -55,11 +52,11 @@ class SpcSwoActivity : AudioPlayActivity(), OnMenuItemClickListener { private var html = "" private val bitmaps = MutableList(5) { UtilityImg.getBlankBitmap() } private var urls = listOf() - private lateinit var activityArguments: Array + private lateinit var arguments: Array private var day = "" private var playlistProd = "" private lateinit var objectCardText: ObjectCardText - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private val objectCardImageList = mutableListOf() private var imagesPerRow = 2 private var imageLabel = "" @@ -67,28 +64,27 @@ class SpcSwoActivity : AudioPlayActivity(), OnMenuItemClickListener { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout_bottom_toolbar, R.menu.spcswo) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) if (UtilityUI.isLandScape(this) && UtilityUI.isTablet()) { imagesPerRow = 4 } toolbarBottom.setOnMenuItemClickListener(this) var numberOfImages = 0 - val horizontalLinearLayouts = mutableListOf() + val horizontalLinearLayouts = mutableListOf() (0..4).forEach { index -> if (numberOfImages % imagesPerRow == 0) { - val objectLinearLayout = ObjectLinearLayout(this, linearLayout) - objectLinearLayout.linearLayout.orientation = LinearLayout.HORIZONTAL - horizontalLinearLayouts.add(objectLinearLayout) - objectCardImageList.add(ObjectCardImage(this, objectLinearLayout.linearLayout)) + val hbox = HBox(this, box) + horizontalLinearLayouts.add(hbox) + objectCardImageList.add(ObjectCardImage(this, hbox.get())) } else { - objectCardImageList.add(ObjectCardImage(this, horizontalLinearLayouts.last().linearLayout)) + objectCardImageList.add(ObjectCardImage(this, horizontalLinearLayouts.last().get())) } objectCardImageList[index].visibility = View.GONE numberOfImages += 1 } - objectCardText = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) - activityArguments = intent.getStringArrayExtra(NUMBER)!! - day = activityArguments[0] + objectCardText = ObjectCardText(this, box, toolbar, toolbarBottom) + arguments = intent.getStringArrayExtra(NUMBER)!! + day = arguments[0] title = "Day $day Convective Outlook" val menu = toolbarBottom.menu val miTornado = menu.findItem(R.id.action_share_tornado) @@ -146,7 +142,7 @@ class SpcSwoActivity : AudioPlayActivity(), OnMenuItemClickListener { private fun showText() { objectCardText.text = html toolbar.subtitle = html.parse("(Valid.*?Z - [0-9]{6}Z)") - if (activityArguments[1] == "sound") { + if (arguments[1] == "sound") { UtilityTts.synthesizeTextAndPlay(applicationContext, html, "spcswo") } } diff --git a/app/src/main/java/joshuatee/wx/spc/SPCSWOStateGraphicsActivity.kt b/app/src/main/java/joshuatee/wx/spc/SPCSWOStateGraphicsActivity.kt index e03deac4..7034fa72 100644 --- a/app/src/main/java/joshuatee/wx/spc/SPCSWOStateGraphicsActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SPCSWOStateGraphicsActivity.kt @@ -49,7 +49,7 @@ class SpcSwoStateGraphicsActivity : VideoRecordActivity() { private var day = "" private var imgUrl = "" - private lateinit var img: ObjectTouchImageView + private lateinit var image: TouchImage private var state = "" private var bitmap = UtilityImg.getBlankBitmap() private var firstTime = true @@ -70,7 +70,7 @@ class SpcSwoStateGraphicsActivity : VideoRecordActivity() { super.onCreate(savedInstanceState, R.layout.activity_spcswostate, R.menu.spcswostate_top, iconsEvenlySpaced = true, bottomToolbar = false) day = intent.getStringArrayExtra(NO)!![0] state = Utility.getWfoSiteName(Location.wfo).split(",")[0] - img = ObjectTouchImageView(this, toolbar, R.id.iv) + image = TouchImage(this, toolbar, R.id.iv) getContent() } @@ -87,8 +87,8 @@ class SpcSwoStateGraphicsActivity : VideoRecordActivity() { } private fun showImage() { - img.setBitmap(bitmap) - img.firstRunSetZoomPosn(imgPrefToken) + image.setBitmap(bitmap) + image.firstRunSetZoomPosn(imgPrefToken) } override fun onOptionsItemSelected(item: MenuItem): Boolean { @@ -98,7 +98,7 @@ class SpcSwoStateGraphicsActivity : VideoRecordActivity() { UtilityToolbar.fullScreenMode(this) firstTime = false } - img.setZoom(1.0f) + image.setZoom(1.0f) state = GlobalArrays.states[it].split(":")[0] getContent() } @@ -123,7 +123,7 @@ class SpcSwoStateGraphicsActivity : VideoRecordActivity() { } override fun onStop() { - img.imgSavePosnZoom(imgPrefToken) + image.imgSavePosnZoom(imgPrefToken) super.onStop() } } diff --git a/app/src/main/java/joshuatee/wx/spc/SPCSWOSummaryActivity.kt b/app/src/main/java/joshuatee/wx/spc/SPCSWOSummaryActivity.kt index 9f3ac348..ec7f7a03 100644 --- a/app/src/main/java/joshuatee/wx/spc/SPCSWOSummaryActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SPCSWOSummaryActivity.kt @@ -40,7 +40,7 @@ class SpcSwoSummaryActivity : BaseActivity() { private val bitmaps = MutableList(8){ UtilityImg.getBlankBitmap() } private var imagesPerRow = 2 - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private lateinit var objectImageSummary: ObjectImageSummary override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -52,13 +52,13 @@ class SpcSwoSummaryActivity : BaseActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, R.menu.spc_swo_summary, false) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) if (UtilityUI.isLandScape(this)) { imagesPerRow = 3 } toolbar.subtitle = "SPC" title = "Convective Outlooks" - objectImageSummary = ObjectImageSummary(this, linearLayout, bitmaps) + objectImageSummary = ObjectImageSummary(this, box, bitmaps) getContent() } diff --git a/app/src/main/java/joshuatee/wx/spc/SPCSoundingsActivity.kt b/app/src/main/java/joshuatee/wx/spc/SPCSoundingsActivity.kt index 8120589d..048aa7c3 100644 --- a/app/src/main/java/joshuatee/wx/spc/SPCSoundingsActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SPCSoundingsActivity.kt @@ -44,7 +44,7 @@ class SpcSoundingsActivity : BaseActivity(), OnMenuItemClickListener { companion object { const val URL = "" } private var imgUrl = "" - private lateinit var img: ObjectTouchImageView + private lateinit var image: TouchImage private lateinit var imageMap: ObjectImageMap private var office = "" private var mapShown = false @@ -70,9 +70,9 @@ class SpcSoundingsActivity : BaseActivity(), OnMenuItemClickListener { super.onCreate(savedInstanceState, R.layout.activity_spcsoundings, R.menu.spcsoundings, true) toolbarBottom.setOnMenuItemClickListener(this) star = toolbarBottom.menu.findItem(R.id.action_fav) - img = ObjectTouchImageView(this, toolbar, toolbarBottom, R.id.iv) + image = TouchImage(this, toolbar, toolbarBottom, R.id.iv) office = UtilityLocation.getNearestSoundingSite(Location.latLon) - imageMap = ObjectImageMap(this, R.id.map, toolbar, toolbarBottom, listOf(img.get())) + imageMap = ObjectImageMap(this, R.id.map, toolbar, toolbarBottom, listOf(image.get())) imageMap.addClickHandler(::mapSwitch, UtilityImageMap::mapToSnd) getContent() } @@ -94,10 +94,10 @@ class SpcSoundingsActivity : BaseActivity(), OnMenuItemClickListener { } private fun showImage() { - img.visibility = View.VISIBLE - img.setBitmap(bitmap) - img.setMaxZoom(4f) - img.firstRunSetZoomPosn("SOUNDING") + image.visibility = View.VISIBLE + image.setBitmap(bitmap) + image.setMaxZoom(4f) + image.firstRunSetZoomPosn("SOUNDING") Utility.writePref(this, "SOUNDING_SECTOR", office) } @@ -113,9 +113,9 @@ class SpcSoundingsActivity : BaseActivity(), OnMenuItemClickListener { } private fun showSpcPlot() { - img.visibility = View.VISIBLE - img.setBitmap(bitmap) - img.setMaxZoom(4f) + image.visibility = View.VISIBLE + image.setBitmap(bitmap) + image.setMaxZoom(4f) } override fun onMenuItemClick(item: MenuItem): Boolean { @@ -145,7 +145,7 @@ class SpcSoundingsActivity : BaseActivity(), OnMenuItemClickListener { office = location mapShown = false getContent() - img.resetZoom() + image.resetZoom() } private fun toggleFavorite() { @@ -191,7 +191,7 @@ class SpcSoundingsActivity : BaseActivity(), OnMenuItemClickListener { } override fun onStop() { - img.imgSavePosnZoom("SOUNDING") + image.imgSavePosnZoom("SOUNDING") super.onStop() } } diff --git a/app/src/main/java/joshuatee/wx/spc/SPCStormReportsActivity.kt b/app/src/main/java/joshuatee/wx/spc/SPCStormReportsActivity.kt index 95bd0282..13814f68 100644 --- a/app/src/main/java/joshuatee/wx/spc/SPCStormReportsActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SPCStormReportsActivity.kt @@ -33,7 +33,6 @@ import android.view.ContextMenu import android.view.MenuItem import android.view.View import android.view.ContextMenu.ContextMenuInfo -import android.widget.AdapterView import android.widget.LinearLayout import android.widget.ScrollView import joshuatee.wx.Extensions.getHtmlSep @@ -87,24 +86,24 @@ class SpcStormReportsActivity : AudioPlayActivity(), OnMenuItemClickListener { private var stormReports = mutableListOf() private lateinit var objectNavDrawer: ObjectNavDrawer private lateinit var scrollView: ScrollView - private lateinit var linearLayoutMain: LinearLayout + private lateinit var box: LinearLayout private lateinit var objectCardImage: ObjectCardImage - private lateinit var boxImages: ObjectLinearLayout - private lateinit var boxText: ObjectLinearLayout + private lateinit var boxImages: VBox + private lateinit var boxText: VBox @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout_show_navdrawer_bottom_toolbar, R.menu.spc_stormreports) scrollView = findViewById(R.id.scrollView) - linearLayoutMain = findViewById(R.id.linearLayout) - boxImages = ObjectLinearLayout(this, linearLayoutMain) - boxText = ObjectLinearLayout(this, linearLayoutMain) + box = findViewById(R.id.linearLayout) + boxImages = VBox(this, box) + boxText = VBox(this, box) objectCardImage = ObjectCardImage(this, boxImages.get(), UtilityImg.getBlankBitmap()) toolbarBottom.setOnMenuItemClickListener(this) toolbarBottom.menu.findItem(R.id.action_playlist).isVisible = false - val activityArguments = intent.getStringArrayExtra(NO) - no = activityArguments!![0] + val arguments = intent.getStringArrayExtra(NO)!! + no = arguments[0] val cal = Calendar.getInstance() year = cal.get(Calendar.YEAR) month = cal.get(Calendar.MONTH) @@ -122,9 +121,9 @@ class SpcStormReportsActivity : AudioPlayActivity(), OnMenuItemClickListener { textUrl = "${GlobalVariables.nwsSPCwebsitePrefix}/climo/reports/$no.csv" stateArray = listOf("") objectNavDrawer = ObjectNavDrawer(this, stateArray) - objectNavDrawer.listView.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ -> - objectNavDrawer.listView.setItemChecked(position, false) - objectNavDrawer.drawerLayout.closeDrawer(objectNavDrawer.listView) + objectNavDrawer.setListener2 { _, _, position, _ -> + objectNavDrawer.setItemChecked(position, false) + objectNavDrawer.close() filter = stateArray.getOrNull(position) ?: "" getContent() } @@ -198,7 +197,7 @@ class SpcStormReportsActivity : AudioPlayActivity(), OnMenuItemClickListener { } val stormCard = ObjectCardStormReportItem(this) stormCard.setId(k) - boxText.addView(stormCard.get()) + boxText.addWidget(stormCard.get()) stormCard.setTextFields(stormReport) if (!isHeader) { registerForContextMenu(stormCard.get()) @@ -263,12 +262,12 @@ class SpcStormReportsActivity : AudioPlayActivity(), OnMenuItemClickListener { override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - objectNavDrawer.actionBarDrawerToggle.syncState() + objectNavDrawer.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - objectNavDrawer.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawer.onConfigurationChanged(newConfig) } override fun onCreateContextMenu(menu: ContextMenu, v: View, menuInfo: ContextMenuInfo?) { @@ -328,7 +327,7 @@ class SpcStormReportsActivity : AudioPlayActivity(), OnMenuItemClickListener { } override fun onMenuItemClick(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawer.onOptionsItemSelected(item)) { return true } if (audioPlayMenu(item.itemId, out.toString(), "spcstreports", "spcstreports")) { @@ -345,7 +344,7 @@ class SpcStormReportsActivity : AudioPlayActivity(), OnMenuItemClickListener { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawer.onOptionsItemSelected(item)) { return true } return super.onOptionsItemSelected(item) diff --git a/app/src/main/java/joshuatee/wx/spc/SpcFireOutlookSummaryActivity.kt b/app/src/main/java/joshuatee/wx/spc/SpcFireOutlookSummaryActivity.kt index ea43f1b1..f526ba99 100644 --- a/app/src/main/java/joshuatee/wx/spc/SpcFireOutlookSummaryActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SpcFireOutlookSummaryActivity.kt @@ -42,7 +42,7 @@ class SpcFireOutlookSummaryActivity : BaseActivity() { private val bitmaps = MutableList(UtilitySpcFireOutlook.urls.size) { UtilityImg.getBlankBitmap() } private var imagesPerRow = 2 - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private lateinit var objectImageSummary: ObjectImageSummary override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -53,13 +53,13 @@ class SpcFireOutlookSummaryActivity : BaseActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, R.menu.shared_multigraphics, false) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) if (UtilityUI.isLandScape(this)) { imagesPerRow = 3 } toolbar.subtitle = "SPC" title = "Fire Weather Outlooks" - objectImageSummary = ObjectImageSummary(this, linearLayout, bitmaps) + objectImageSummary = ObjectImageSummary(this, box, bitmaps) getContent() } diff --git a/app/src/main/java/joshuatee/wx/spc/SpcMcdWatchShowActivity.kt b/app/src/main/java/joshuatee/wx/spc/SpcMcdWatchShowActivity.kt index a1c94db6..f6cdbeef 100644 --- a/app/src/main/java/joshuatee/wx/spc/SpcMcdWatchShowActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SpcMcdWatchShowActivity.kt @@ -52,29 +52,29 @@ class SpcMcdWatchShowActivity : AudioPlayActivity(), OnMenuItemClickListener { companion object { const val NUMBER = "" } private var number = "" - private lateinit var activityArguments: Array + private lateinit var arguments: Array private lateinit var objectCardImage: ObjectCardImage private lateinit var objectCardText: ObjectCardText private lateinit var objectWatchProduct: ObjectWatchProduct - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private var tabletInLandscape = false @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout_bottom_toolbar, R.menu.spcmcdshowdetail) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) toolbarBottom.setOnMenuItemClickListener(this) tabletInLandscape = UtilityUI.isTablet() && UtilityUI.isLandScape(this) if (tabletInLandscape) { - linearLayout.orientation = LinearLayout.HORIZONTAL - objectCardImage = ObjectCardImage(this, linearLayout, UtilityImg.getBlankBitmap(), 2) + box.orientation = LinearLayout.HORIZONTAL + objectCardImage = ObjectCardImage(this, box, UtilityImg.getBlankBitmap(), 2) } else { - objectCardImage = ObjectCardImage(this, linearLayout) + objectCardImage = ObjectCardImage(this, box) } - objectCardText = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) - activityArguments = intent.getStringArrayExtra(NUMBER)!! - number = activityArguments[0] - when (activityArguments[2]) { + objectCardText = ObjectCardText(this, box, toolbar, toolbarBottom) + arguments = intent.getStringArrayExtra(NUMBER)!! + number = arguments[0] + when (arguments[2]) { "MCD" -> objectWatchProduct = ObjectWatchProduct(PolygonType.MCD, number) "WATCH" -> objectWatchProduct = ObjectWatchProduct(PolygonType.WATCH, number) "MPD" -> objectWatchProduct = ObjectWatchProduct(PolygonType.MPD, number) @@ -103,7 +103,7 @@ class SpcMcdWatchShowActivity : AudioPlayActivity(), OnMenuItemClickListener { objectCardImage.setOnClickListener { ObjectIntent.showImage(this@SpcMcdWatchShowActivity, arrayOf(objectWatchProduct.imgUrl, objectWatchProduct.title, "true")) } - UtilityTts.conditionalPlay(activityArguments, 1, applicationContext, objectWatchProduct.text, objectWatchProduct.prod) + UtilityTts.conditionalPlay(arguments, 1, applicationContext, objectWatchProduct.text, objectWatchProduct.prod) } override fun onMenuItemClick(item: MenuItem): Boolean { diff --git a/app/src/main/java/joshuatee/wx/spc/SpcMcdWatchShowSummaryActivity.kt b/app/src/main/java/joshuatee/wx/spc/SpcMcdWatchShowSummaryActivity.kt index 9666d158..7d462c78 100644 --- a/app/src/main/java/joshuatee/wx/spc/SpcMcdWatchShowSummaryActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SpcMcdWatchShowSummaryActivity.kt @@ -69,13 +69,13 @@ class SpcMcdWatchShowSummaryActivity : AudioPlayActivity(), OnMenuItemClickListe private lateinit var miUrl: MenuItem private lateinit var miImage: MenuItem private lateinit var polygonType: PolygonType - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private var mcdList = listOf() @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout_bottom_toolbar, R.menu.spcmcdshowdetail) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) toolbarBottom.setOnMenuItemClickListener(this) val menu = toolbarBottom.menu miAll = menu.findItem(R.id.action_share_all) @@ -138,21 +138,21 @@ class SpcMcdWatchShowSummaryActivity : AudioPlayActivity(), OnMenuItemClickListe titleString = "MCD " + mcdNumbers[0] product = "SPCMCD" + mcdNumbers[0] } - text = UtilityDownload.getTextProduct(this@SpcMcdWatchShowSummaryActivity, product) + text = UtilityDownload.getTextProduct(this, product) } } private fun update() { mcdList.indices.forEach { mcdIndex -> - val objectCardImage = ObjectCardImage(this@SpcMcdWatchShowSummaryActivity, linearLayout, bitmaps[mcdIndex]) + val objectCardImage = ObjectCardImage(this, box, bitmaps[mcdIndex]) objectCardImage.setOnClickListener { - ObjectIntent.showMcd(this@SpcMcdWatchShowSummaryActivity, arrayOf(mcdNumbers[mcdIndex], "", polygonType.toString())) + ObjectIntent.showMcd(this, arrayOf(mcdNumbers[mcdIndex], "", polygonType.toString())) } } if (mcdList.size == 1) { val wfoStr = text.parse("ATTN...WFO...(.*?)... ") wfos = wfoStr.split("\\.\\.\\.".toRegex()).dropLastWhile { it.isEmpty() } - ObjectCardText(this@SpcMcdWatchShowSummaryActivity, linearLayout, toolbar, toolbarBottom, Utility.fromHtml(text)) + ObjectCardText(this, box, toolbar, toolbarBottom, Utility.fromHtml(text)) title = titleString if (!number.contains("at")) { toolbar.subtitle = text.parse("Areas affected...(.*?)
") @@ -167,7 +167,7 @@ class SpcMcdWatchShowSummaryActivity : AudioPlayActivity(), OnMenuItemClickListe title = titleString } if (mcdList.isEmpty()) { - ObjectCardText(this@SpcMcdWatchShowSummaryActivity, linearLayout, toolbar, toolbarBottom, nothingPresentStr) + ObjectCardText(this, box, toolbar, toolbarBottom, nothingPresentStr) } } diff --git a/app/src/main/java/joshuatee/wx/spc/SpcThunderStormOutlookActivity.kt b/app/src/main/java/joshuatee/wx/spc/SpcThunderStormOutlookActivity.kt index 21931726..2e8f823a 100644 --- a/app/src/main/java/joshuatee/wx/spc/SpcThunderStormOutlookActivity.kt +++ b/app/src/main/java/joshuatee/wx/spc/SpcThunderStormOutlookActivity.kt @@ -43,7 +43,7 @@ class SpcThunderStormOutlookActivity : BaseActivity() { private var bitmaps = mutableListOf() private var urls = listOf() private var imagesPerRow = 2 - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private lateinit var objectImageSummary: ObjectImageSummary override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -54,7 +54,7 @@ class SpcThunderStormOutlookActivity : BaseActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, R.menu.shared_multigraphics, false) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) if (UtilityUI.isLandScape(this)) { imagesPerRow = 3 } @@ -74,8 +74,8 @@ class SpcThunderStormOutlookActivity : BaseActivity() { private fun getImages() { bitmaps = MutableList(urls.size){ UtilityImg.getBlankBitmap() } - linearLayout.removeAllViews() - objectImageSummary = ObjectImageSummary(this, linearLayout, bitmaps) + box.removeAllViews() + objectImageSummary = ObjectImageSummary(this, box, bitmaps) urls.indices.forEach { FutureVoid(this, { bitmaps[it] = urls[it].getImage() }, { updateImage(it) }) } diff --git a/app/src/main/java/joshuatee/wx/telecine/SettingsTelecineActivity.kt b/app/src/main/java/joshuatee/wx/telecine/SettingsTelecineActivity.kt index 3ad62f5f..4910948e 100644 --- a/app/src/main/java/joshuatee/wx/telecine/SettingsTelecineActivity.kt +++ b/app/src/main/java/joshuatee/wx/telecine/SettingsTelecineActivity.kt @@ -22,7 +22,7 @@ class SettingsTelecineActivity : BaseActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, null, false) - val linearLayout: LinearLayout = findViewById(R.id.linearLayout) + val box: LinearLayout = findViewById(R.id.linearLayout) val vidSize = listOf("100", "75", "50") val vidSpinner = ObjectSettingsSpinner( this, @@ -32,8 +32,8 @@ class SettingsTelecineActivity : BaseActivity() { R.string.widget_nexrad_size_label, vidSize ) - linearLayout.addView(vidSpinner.card) - linearLayout.addView( + box.addView(vidSpinner.card) + box.addView( ObjectSettingsCheckBox( this, "Three Second Countdown", @@ -41,7 +41,7 @@ class SettingsTelecineActivity : BaseActivity() { R.string.loc1_radar_label ).get() ) - linearLayout.addView( + box.addView( ObjectSettingsCheckBox( this, "Recording Notification", diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectLinearLayout.kt b/app/src/main/java/joshuatee/wx/ui/HBox.kt similarity index 68% rename from app/src/main/java/joshuatee/wx/ui/ObjectLinearLayout.kt rename to app/src/main/java/joshuatee/wx/ui/HBox.kt index 4a1a4778..13281729 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectLinearLayout.kt +++ b/app/src/main/java/joshuatee/wx/ui/HBox.kt @@ -26,37 +26,28 @@ import android.view.Gravity import android.view.View import android.widget.LinearLayout -class ObjectLinearLayout(val context: Context) { +class HBox(val context: Context) { - val linearLayout = LinearLayout(context) + private val linearLayout = LinearLayout(context) + + init { + linearLayout.orientation = LinearLayout.HORIZONTAL + } constructor(context: Context, parentView: LinearLayout) : this(context) { - linearLayout.orientation = LinearLayout.VERTICAL parentView.addView(linearLayout) } - constructor(context: Context, orientation: Int) : this(context) { this.orientation = orientation } - - constructor(context: Context, orientation: Int, gravity: Int) : this(context, orientation) { this.gravity = gravity } - - fun removeAllViewsInLayout() { - linearLayout.removeAllViewsInLayout() + constructor(context: Context, gravity: Int) : this(context) { + this.gravity = gravity } - fun addView(child: View) { + fun addWidget(child: View) { linearLayout.addView(child) } - fun addView(objectTextView: ObjectTextView) { - linearLayout.addView(objectTextView.get()) - } - - fun addView(objectLinearLayout: ObjectLinearLayout) { - linearLayout.addView(objectLinearLayout.linearLayout) - } - - fun addView(objectImageView: ObjectImageView) { - linearLayout.addView(objectImageView.get()) + fun addLayout(objectLinearLayout: VBox) { + linearLayout.addView(objectLinearLayout.get()) } fun addViews(children: List) { @@ -73,14 +64,20 @@ class ObjectLinearLayout(val context: Context) { linearLayout.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT) } - fun get(): LinearLayout { - return linearLayout + fun wrap() { + linearLayout.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT) } + fun get() = linearLayout + var visibility get() = linearLayout.visibility set(value) { linearLayout.visibility = value } + var isBaselineAligned + get() = linearLayout.isBaselineAligned + set(value) { linearLayout.isBaselineAligned = value } + var orientation get() = linearLayout.orientation set(value) { linearLayout.orientation = value } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectAlertSummary.kt b/app/src/main/java/joshuatee/wx/ui/ObjectAlertSummary.kt index 90773af8..e01db810 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectAlertSummary.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectAlertSummary.kt @@ -25,7 +25,6 @@ import android.content.Context import android.graphics.Bitmap import android.widget.LinearLayout import android.widget.ScrollView -import joshuatee.wx.common.GlobalDictionaries import java.util.Locale import joshuatee.wx.activitiesmisc.CapAlert import joshuatee.wx.common.GlobalVariables @@ -42,10 +41,6 @@ class ObjectAlertSummary(private val context: Context, private val linearLayout: private set var filterArray = listOf() private set - private val mapButtonZone = mutableMapOf() - private val mapButtonNws = mutableMapOf() - private val mapButtonState = mutableMapOf() - private val mapButtonCounty = mutableMapOf() var bitmap = UtilityImg.getBlankBitmap() private var objectCardImageView = ObjectCardImage(context, bitmap) private val cardText = ObjectCardText(context) @@ -70,10 +65,6 @@ class ObjectAlertSummary(private val context: Context, private val linearLayout: totalAlertsCnt = 0 val mapEvent = mutableMapOf() val mapState = mutableMapOf() - mapButtonNws.clear() - mapButtonState.clear() - mapButtonCounty.clear() - mapButtonZone.clear() val map = mutableMapOf() var i = 0 try { @@ -81,10 +72,7 @@ class ObjectAlertSummary(private val context: Context, private val linearLayout: val alerts = UtilityString.parseColumnMutable(data, "(.*?)") alerts.forEach { alert -> capAlerts.add(CapAlert.initializeFromCap(alert)) } capAlerts.forEach { capAlert -> - val counties = capAlert.area.split(";") - val firstCounty = if (counties.isNotEmpty()) counties[0] else "" val zones = capAlert.zones.split(" ") - val firstZone = if (zones.isNotEmpty()) zones[0] else "" totalAlertsCnt += 1 val tmpStateList = zones.asSequence().filter { it.length > 1 }.map { it.substring(0, 2) } val uniqueStates = tmpStateList.toSet() @@ -109,18 +97,10 @@ class ObjectAlertSummary(private val context: Context, private val linearLayout: unique2States.forEach { state -> val frequencyLocal = map[state] map[state] = if (frequencyLocal == null) 1 else frequencyLocal + 1 - mapButtonState[i] = state } - val objectCardAlertSummaryItem = ObjectCardAlertSummaryItem(context) - objectCardAlertSummaryItem.setId(i) - mapButtonNws[i] = nwsOffice - mapButtonCounty[i] = firstCounty - mapButtonZone[i] = firstZone + val objectCardAlertSummaryItem = ObjectCardAlertDetail(context) objectCardAlertSummaryItem.setTextFields(nwsOffice, nwsLoc, capAlert) - val url = capAlert.url - objectCardAlertSummaryItem.setListener { showWarningDetails(url) } - objectCardAlertSummaryItem.radarButton.setOnClickListener { radarInterface(nwsOffice) } - objectCardAlertSummaryItem.detailsButton.setOnClickListener { showWarningDetails(url) } + objectCardAlertSummaryItem.setListener { ObjectIntent.showHazard(context, arrayOf(capAlert.url, "")) } linearLayout.addView(objectCardAlertSummaryItem.get()) i += 1 } @@ -151,13 +131,5 @@ class ObjectAlertSummary(private val context: Context, private val linearLayout: } } - private fun radarInterface(office: String) { - ObjectIntent.showRadarBySite(context, GlobalDictionaries.wfoToRadarSite[office] ?: "") - } - - private fun showWarningDetails(url: String) { - ObjectIntent.showHazard(context, arrayOf(url, "")) - } - fun getTitle(title: String) = "(" + totalAlertsCnt + ") " + title.uppercase(Locale.US) + " Alerts" } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectButton.kt b/app/src/main/java/joshuatee/wx/ui/ObjectButton.kt index 80fa52a2..4ff07faf 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectButton.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectButton.kt @@ -54,5 +54,9 @@ class ObjectButton(context: Context, title: String, icon: Int) { button.setOnClickListener(fn) } + var visibility + get() = button.visibility + set(value) { button.visibility = value } + fun get() = button } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCALegal.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCALegal.kt index e0a95998..80f1f6a1 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCALegal.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCALegal.kt @@ -29,15 +29,15 @@ import joshuatee.wx.R import joshuatee.wx.objects.ObjectIntent import joshuatee.wx.objects.TextSize -class ObjectCALegal(context: Context, linearLayout: LinearLayout, url: String) { +class ObjectCALegal(context: Context, box: LinearLayout, url: String) { - private val objectCardText = ObjectCardText(context) + private val text = ObjectCardText(context) init { - objectCardText.refreshTextSize(TextSize.SMALL) - objectCardText.center() - objectCardText.setOnClickListener { ObjectIntent(context, Intent.ACTION_VIEW, Uri.parse(url)) } - objectCardText.text = context.resources.getText(R.string.main_screen_ca_disclaimor).toString() - linearLayout.addView(objectCardText.get()) + text.refreshTextSize(TextSize.SMALL) + text.center() + text.setOnClickListener { ObjectIntent(context, Intent.ACTION_VIEW, Uri.parse(url)) } + text.text = context.resources.getText(R.string.main_screen_ca_disclaimor).toString() + box.addView(text.get()) } } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCanadaWarnings.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCanadaWarnings.kt index 66eacf57..7ac9f57d 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCanadaWarnings.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCanadaWarnings.kt @@ -22,7 +22,6 @@ package joshuatee.wx.ui import android.app.Activity -import android.content.Context import androidx.appcompat.widget.Toolbar import android.widget.LinearLayout import java.util.Locale diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCard.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCard.kt index 1b0ca7ed..058172bf 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCard.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCard.kt @@ -47,21 +47,27 @@ class ObjectCard { card.preventCornerOverlap = true } - constructor(context: Context, color: Int) : this(context) { card.setCardBackgroundColor(color) } + constructor(context: Context, color: Int) : this(context) { + card.setCardBackgroundColor(color) + } constructor(itemView: View, resId: Int) { card = itemView.findViewById(resId) setupCard() } - constructor(itemView: View, color: Int, resId: Int) : this(itemView, resId) { card.setCardBackgroundColor(color) } + constructor(itemView: View, color: Int, resId: Int) : this(itemView, resId) { + card.setCardBackgroundColor(color) + } constructor(activity: Activity, resId: Int) { card = activity.findViewById(resId) setupCard() } - constructor(activity: Activity, color: Int, resId: Int) : this(activity, resId) { card.setCardBackgroundColor(color) } + constructor(activity: Activity, color: Int, resId: Int) : this(activity, resId) { + card.setCardBackgroundColor(color) + } var visibility: Int get() = card.visibility @@ -71,8 +77,8 @@ class ObjectCard { card.addView(view) } - fun addView(objectLinearLayout: ObjectLinearLayout) { - card.addView(objectLinearLayout.linearLayout) + fun addView(objectLinearLayout: VBox) { + card.addView(objectLinearLayout.get()) } fun setOnClickListener(fn: View.OnClickListener) { diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCard7Day.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCard7Day.kt index f48744c8..b882787f 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCard7Day.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCard7Day.kt @@ -24,7 +24,6 @@ package joshuatee.wx.ui import android.content.Context import android.graphics.Bitmap import android.view.View -import android.widget.LinearLayout import joshuatee.wx.settings.UIPreferences import joshuatee.wx.common.GlobalVariables import joshuatee.wx.fragments.UtilityLocationFragment @@ -38,16 +37,16 @@ class ObjectCard7Day(context: Context, bitmap: Bitmap, isUS: Boolean, day: Int, private val bottomLineText = ObjectTextView(context, backgroundText = true) init { - val horizontalContainer = ObjectLinearLayout(context, LinearLayout.HORIZONTAL) - val verticalContainer = ObjectLinearLayout(context, LinearLayout.VERTICAL) + val hbox = HBox(context) + val vbox = VBox(context) topLineText.setPadding(UIPreferences.padding, 0, UIPreferences.paddingSmall, 0) bottomLineText.setPadding(UIPreferences.padding, 0, UIPreferences.paddingSmall, 0) - verticalContainer.addViews(listOf(topLineText.get(), bottomLineText.get())) + vbox.addViews(listOf(topLineText.get(), bottomLineText.get())) if (!UIPreferences.locfragDontShowIcons) { - horizontalContainer.addView(objectImageView) + hbox.addWidget(objectImageView.get()) } - horizontalContainer.addView(verticalContainer) - objectCard.addView(horizontalContainer) + hbox.addLayout(vbox) + objectCard.addView(hbox.get()) val items = if (forecasts.size > day) { forecasts[day].split(": ") } else { @@ -87,7 +86,9 @@ class ObjectCard7Day(context: Context, bitmap: Bitmap, isUS: Boolean, day: Int, bottomLineText.text = text } - fun setOnClickListener(fn: View.OnClickListener) = objectCard.setOnClickListener(fn) + fun setOnClickListener(fn: View.OnClickListener) { + objectCard.setOnClickListener(fn) + } fun refreshTextSize() { topLineText.refreshTextSize(TextSize.MEDIUM) diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCardAlertSummaryItem.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCardAlertDetail.kt similarity index 68% rename from app/src/main/java/joshuatee/wx/ui/ObjectCardAlertSummaryItem.kt rename to app/src/main/java/joshuatee/wx/ui/ObjectCardAlertDetail.kt index 41bdcecd..3d7df247 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCardAlertSummaryItem.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCardAlertDetail.kt @@ -24,14 +24,15 @@ package joshuatee.wx.ui import android.content.Context import android.view.Gravity import android.view.View -import android.widget.LinearLayout import joshuatee.wx.Extensions.parseMultiple import joshuatee.wx.settings.UIPreferences import joshuatee.wx.activitiesmisc.CapAlert import joshuatee.wx.common.GlobalVariables +import joshuatee.wx.objects.ObjectIntent import joshuatee.wx.objects.TextSize +import joshuatee.wx.util.UtilityLog -class ObjectCardAlertSummaryItem(context: Context) { +class ObjectCardAlertDetail(val context: Context) { private val objectCard = ObjectCard(context) private val textViewTop = ObjectTextView(context, UIPreferences.textHighlightColor) @@ -39,27 +40,22 @@ class ObjectCardAlertSummaryItem(context: Context) { private val textViewStart = ObjectTextView(context, TextSize.SMALL) private val textViewEnd = ObjectTextView(context, TextSize.SMALL) private val textViewBottom = ObjectTextView(context, backgroundText = true) - val radarButton = ObjectButton(context,"Radar", GlobalVariables.ICON_RADAR) - val detailsButton = ObjectButton(context,"Details", GlobalVariables.ICON_CURRENT) + private val radarButton = ObjectButton(context,"Radar", GlobalVariables.ICON_RADAR) + private val detailsButton = ObjectButton(context,"Details", GlobalVariables.ICON_CURRENT) init { - val objectLinearLayout = ObjectLinearLayout(context, LinearLayout.VERTICAL, Gravity.CENTER_VERTICAL) - objectLinearLayout.addViews(listOf(textViewTop.get(), textViewTitle.get(), textViewStart.get(), textViewEnd.get(), textViewBottom.get())) - val linearLayoutHorizontal = LinearLayout(context) - val layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT) - linearLayoutHorizontal.layoutParams = layoutParams - linearLayoutHorizontal.addView(radarButton.get()) - linearLayoutHorizontal.addView(detailsButton.get()) - objectLinearLayout.addView(linearLayoutHorizontal) - objectCard.addView(objectLinearLayout) + val vbox = VBox(context, Gravity.CENTER_VERTICAL) + vbox.addViews(listOf(textViewTop.get(), textViewTitle.get(), textViewStart.get(), textViewEnd.get(), textViewBottom.get())) + val hbox = HBox(context) + hbox.wrap() + hbox.addWidget(radarButton.get()) + hbox.addWidget(detailsButton.get()) + vbox.addLayout(hbox.get()) + objectCard.addView(vbox) } fun get() = objectCard.get() - fun setId(id: Int) { - objectCard.setId(id) - } - fun setListener(fn: View.OnClickListener) { objectCard.setOnClickListener(fn) } @@ -91,5 +87,13 @@ class ObjectCardAlertSummaryItem(context: Context) { } else { textViewEnd.visibility = View.GONE } + if (capAlert.points.size < 2) { + UtilityLog.d("WX", "POINTS HIDE") + radarButton.visibility = View.GONE + } else { + UtilityLog.d("WX", "POINTS NO HIDE " + capAlert.points.size + " " + capAlert.getClosestRadarXml()) + radarButton.setOnClickListener { ObjectIntent.showRadarBySite(context, capAlert.getClosestRadarXml()) } + } + detailsButton.setOnClickListener { ObjectIntent.showHazard(context, arrayOf(capAlert.url, "")) } } } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCardBlackHeaderText.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCardBlackHeaderText.kt index e205cd44..657312b3 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCardBlackHeaderText.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCardBlackHeaderText.kt @@ -29,15 +29,15 @@ import android.widget.LinearLayout import joshuatee.wx.settings.UIPreferences import joshuatee.wx.objects.TextSize -class ObjectCardBlackHeaderText(context: Context, val linearLayout: LinearLayout, val text: String) { +class ObjectCardBlackHeaderText(context: Context, val linearLayout: LinearLayout, val title: String) { private val objectCard = ObjectCard(context) - private val objectTextView = ObjectTextView(context, UIPreferences.textHighlightColor) + private val text = ObjectTextView(context, UIPreferences.textHighlightColor) init { - val objectLinearLayout = ObjectLinearLayout(context, LinearLayout.VERTICAL, Gravity.CENTER_VERTICAL) - objectLinearLayout.addView(objectTextView) - objectCard.addView(objectLinearLayout) + val vbox = VBox(context, Gravity.CENTER_VERTICAL) + vbox.addWidget(text.get()) + objectCard.addView(vbox) linearLayout.addView(objectCard.get()) setTextHeader() } @@ -47,11 +47,11 @@ class ObjectCardBlackHeaderText(context: Context, val linearLayout: LinearLayout } private fun setTextHeader() { - objectTextView.text = text - objectTextView.setTextSize(TextSize.LARGE) - objectTextView.setPadding(20) - objectTextView.color = UIPreferences.textHighlightColor - objectTextView.setBackgroundColor(Color.BLACK) - objectTextView.setTextColor(Color.WHITE) + text.text = title + text.setTextSize(TextSize.LARGE) + text.setPadding(20) + text.color = UIPreferences.textHighlightColor + text.setBackgroundColor(Color.BLACK) + text.setTextColor(Color.WHITE) } } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCardCurrentConditions.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCardCurrentConditions.kt index a081d916..dda21cde 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCardCurrentConditions.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCardCurrentConditions.kt @@ -32,21 +32,21 @@ import joshuatee.wx.util.ObjectCurrentConditions class ObjectCardCurrentConditions(context: Context, version: Int) { - private val objCard = ObjectCard(context) + private val objectCard = ObjectCard(context) private val objectImageView = ObjectImageView(context) private val textViewTop = ObjectTextView(context, TextSize.MEDIUM) private val textViewBottom = ObjectTextView(context, backgroundText = true) private val textViewMiddle = ObjectTextView(context, backgroundText = true) init { - val linearLayoutHorizontal = ObjectLinearLayout(context, LinearLayout.HORIZONTAL) - val linearLayoutVertical = ObjectLinearLayout(context, LinearLayout.VERTICAL, Gravity.CENTER_VERTICAL) + val hbox = HBox(context) + val vbox = VBox(context, Gravity.CENTER_VERTICAL) if (version == 2) { textViewTop.setPadding(UIPreferences.padding, 0, UIPreferences.paddingSmall, 0) textViewMiddle.setPadding(UIPreferences.padding, 0, UIPreferences.paddingSmall, 0) textViewBottom.setPadding(UIPreferences.padding, 0, UIPreferences.paddingSmall, UIPreferences.paddingSmall) - linearLayoutVertical.addViews(listOf(textViewTop.get(), textViewMiddle.get(), textViewBottom.get())) - linearLayoutHorizontal.addViews(listOf(objectImageView.get(), linearLayoutVertical.linearLayout)) + vbox.addViews(listOf(textViewTop.get(), textViewMiddle.get(), textViewBottom.get())) + hbox.addViews(listOf(objectImageView.get(), vbox.get())) } else { // legacy code textViewTop.gravity = Gravity.CENTER @@ -55,14 +55,14 @@ class ObjectCardCurrentConditions(context: Context, version: Int) { textViewTop.setPadding(UIPreferences.padding, 0, UIPreferences.padding, 0) textViewBottom.setPadding(UIPreferences.padding, 0, UIPreferences.padding, 2) textViewMiddle.setPadding(UIPreferences.padding, 0, UIPreferences.padding, 0) - linearLayoutHorizontal.orientation = LinearLayout.VERTICAL - linearLayoutHorizontal.addView(textViewTop) - linearLayoutHorizontal.addView(textViewBottom) + hbox.orientation = LinearLayout.VERTICAL + hbox.addWidget(textViewTop.get()) + hbox.addWidget(textViewBottom.get()) } - objCard.addView(linearLayoutHorizontal) + objectCard.addView(hbox.get()) } - fun get() = objCard.get() + fun get() = objectCard.get() fun refreshTextSize() { textViewTop.refreshTextSize(TextSize.MEDIUM) diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCardDashAlertItem.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCardDashAlertItem.kt index 2ef6d380..a7ebd5a4 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCardDashAlertItem.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCardDashAlertItem.kt @@ -27,9 +27,10 @@ import android.view.View import android.widget.LinearLayout import joshuatee.wx.settings.UIPreferences import joshuatee.wx.common.GlobalVariables +import joshuatee.wx.objects.ObjectIntent import joshuatee.wx.objects.ObjectWarning -class ObjectCardDashAlertItem(context: Context, val linearLayout: LinearLayout, private val warning: ObjectWarning) { +class ObjectCardDashAlertItem(val context: Context, val linearLayout: LinearLayout, private val warning: ObjectWarning) { private val objectCard = ObjectCard(context) private val textViewTop = ObjectTextView(context, UIPreferences.textHighlightColor) @@ -37,23 +38,24 @@ class ObjectCardDashAlertItem(context: Context, val linearLayout: LinearLayout, private val textViewStart = ObjectTextView(context) private val textViewEnd = ObjectTextView(context) private val textViewBottom = ObjectTextView(context, backgroundText = true) - val radarButton = ObjectButton(context,"Radar", GlobalVariables.ICON_RADAR) - val detailsButton = ObjectButton(context,"Details", GlobalVariables.ICON_CURRENT) + private val radarButton = ObjectButton(context,"Radar", GlobalVariables.ICON_RADAR) + private val detailsButton = ObjectButton(context,"Details", GlobalVariables.ICON_CURRENT) init { - val linearLayoutVertical = ObjectLinearLayout(context, LinearLayout.VERTICAL, Gravity.CENTER_VERTICAL) + val vbox = VBox(context, Gravity.CENTER_VERTICAL) listOf(textViewTop, textViewTitle, textViewStart, textViewEnd, textViewBottom).forEach { - linearLayoutVertical.addView(it) + vbox.addWidget(it.get()) } - val layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT) - val linearLayoutHorizontal = LinearLayout(context) - linearLayoutHorizontal.layoutParams = layoutParams - linearLayoutHorizontal.addView(radarButton.get()) - linearLayoutHorizontal.addView(detailsButton.get()) - linearLayoutVertical.addView(linearLayoutHorizontal) - objectCard.addView(linearLayoutVertical) + val hbox = HBox(context) + hbox.wrap() + hbox.addWidget(radarButton.get()) + hbox.addWidget(detailsButton.get()) + vbox.addLayout(hbox.get()) + objectCard.addView(vbox) setTextFields() linearLayout.addView(objectCard.get()) + radarButton.setOnClickListener { ObjectIntent.showRadarBySite(context, warning.getClosestRadar()) } + detailsButton.setOnClickListener { ObjectIntent.showHazard(context, arrayOf(warning.url, "")) } } fun setListener(fn: View.OnClickListener) { @@ -67,8 +69,4 @@ class ObjectCardDashAlertItem(context: Context, val linearLayout: LinearLayout, textViewEnd.text = warning.expires.replace("T", " ").replace(Regex(":00-0[0-9]:00"), "").replace(Regex(":00-10:00"), "") textViewBottom.text = warning.area } - - fun setId(id: Int) { - objectCard.setId(id) - } } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCardHSText.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCardHSText.kt index 91570b0c..85d3bc17 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCardHSText.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCardHSText.kt @@ -23,25 +23,24 @@ package joshuatee.wx.ui import android.content.Context import android.graphics.Typeface -import android.util.TypedValue import android.view.View -import android.widget.TextView +import joshuatee.wx.objects.TextSize import joshuatee.wx.settings.UIPreferences import joshuatee.wx.util.Utility class ObjectCardHSText(context: Context, val product: String) { private val objectCard = ObjectCard(context) - private val textView = TextView(context) + private val textView = ObjectTextView(context) private var textShort = "" private var textLong = "" private var textShownSmall = true init { - ObjectCardText.textViewSetup(textView) - textView.setTextIsSelectable(true) - textView.isFocusable = false - objectCard.addView(textView) +// ObjectCardText.textViewSetup(textView) +// textView.setTextIsSelectable(true) +// textView.isFocusable = false + objectCard.addView(textView.get()) } fun toggleText() { @@ -77,7 +76,8 @@ class ObjectCardHSText(context: Context, val product: String) { } fun refreshTextSize() { - textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, UIPreferences.textSizeSmall) + textView.refreshTextSize(TextSize.SMALL) +// textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, UIPreferences.textSizeSmall) } private fun setTextLong(text: String) { diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCardImage.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCardImage.kt index bb7ad2ee..f7cd3146 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCardImage.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCardImage.kt @@ -106,7 +106,9 @@ open class ObjectCardImage { objectCard.addView(img) } - fun resetZoom() = img.resetZoom() + fun resetZoom() { + img.resetZoom() + } protected val card get() = objectCard.get() diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCardStormReportItem.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCardStormReportItem.kt index e1bedbc1..ca5d1ec0 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCardStormReportItem.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCardStormReportItem.kt @@ -25,7 +25,6 @@ import android.content.Context import android.graphics.Color import android.view.Gravity import android.view.View -import android.widget.LinearLayout import joshuatee.wx.settings.UIPreferences import joshuatee.wx.objects.TextSize import joshuatee.wx.spc.StormReport @@ -39,18 +38,21 @@ class ObjectCardStormReportItem(context: Context) { private val textViewBottom = ObjectTextView(context, backgroundText = true) init { - val linearLayoutVertical = ObjectLinearLayout(context, LinearLayout.VERTICAL, Gravity.CENTER_VERTICAL) - linearLayoutVertical.addViews(listOf(textViewTop.get(), textViewTitle.get(), textViewBottom.get())) - objectCard.addView(linearLayoutVertical) + val vbox = VBox(context, Gravity.CENTER_VERTICAL) + vbox.addViews(listOf(textViewTop.get(), textViewTitle.get(), textViewBottom.get())) + objectCard.addView(vbox) } fun get() = objectCard.get() + // This is needed for long press on the card for archived L2 radar (unreliable feature which should be removed) fun setId(id: Int) { objectCard.setId(id) } - fun setListener(fn: View.OnClickListener) = objectCard.setOnClickListener(fn) + fun setListener(fn: View.OnClickListener) { + objectCard.setOnClickListener(fn) + } fun setTextFields(stormReport: StormReport) { textViewTop.text = stormReport.state + ", " + stormReport.city + " " + stormReport.time diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCardText.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCardText.kt index 283b79ef..abfcbd46 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCardText.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCardText.kt @@ -48,7 +48,9 @@ class ObjectCardText(context: Context) { objectCard.addView(tv) } - constructor(context: Context, linearLayout: LinearLayout) : this(context) { linearLayout.addView(get()) } + constructor(context: Context, linearLayout: LinearLayout) : this(context) { + linearLayout.addView(get()) + } constructor(context: Context, linearLayout: LinearLayout, toolbar: Toolbar, toolbarBottom: Toolbar) : this(context) { linearLayout.addView(get()) @@ -234,12 +236,13 @@ class ObjectCardText(context: Context) { } companion object { - fun textViewSetup(textView: TextView) { - textView.setPadding(UIPreferences.padding) - textView.gravity = Gravity.START - textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, UIPreferences.textSizeSmall) - textView.setTextColor(UIPreferences.backgroundColor) - } + +// fun textViewSetup(textView: TextView) { +// textView.setPadding(UIPreferences.padding) +// textView.gravity = Gravity.START +// textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, UIPreferences.textSizeSmall) +// textView.setTextColor(UIPreferences.backgroundColor) +// } fun textViewSetup(objectCardText: ObjectCardText) { objectCardText.tv.setPadding(objectCardText.padding) diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectCardVerticalText.kt b/app/src/main/java/joshuatee/wx/ui/ObjectCardVerticalText.kt index 106935ac..d8144fdc 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectCardVerticalText.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectCardVerticalText.kt @@ -22,33 +22,31 @@ package joshuatee.wx.ui import android.content.Context -import android.util.TypedValue import android.view.Gravity import android.view.View import android.widget.LinearLayout -import android.widget.TextView import androidx.appcompat.widget.Toolbar -import joshuatee.wx.settings.UIPreferences +import joshuatee.wx.objects.TextSize class ObjectCardVerticalText(context: Context, numberOfColumns: Int) { private val objectCard = ObjectCard(context) - private val textViews = mutableListOf() + private val textViews = mutableListOf() init { - val objectLinearLayout = ObjectLinearLayout(context, LinearLayout.HORIZONTAL, Gravity.CENTER) - objectLinearLayout.linearLayout.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT) - objectLinearLayout.linearLayout.isBaselineAligned = false - objectCard.addView(objectLinearLayout) + val objectLinearLayout = HBox(context, Gravity.CENTER) + objectLinearLayout.matchParent() + objectLinearLayout.isBaselineAligned = false + objectCard.addView(objectLinearLayout.get()) repeat(numberOfColumns) { - val linearLayout = LinearLayout(context) - linearLayout.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f) - objectLinearLayout.linearLayout.addView(linearLayout) - val textView = TextView(context) + val hbox = HBox(context) + hbox.wrap() + objectLinearLayout.addWidget(hbox.get()) + val textView = ObjectTextView(context) textViews.add(textView) textView.gravity = Gravity.START - textView.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT) - linearLayout.addView(textView) + textView.wrap() + hbox.addWidget(textView.get()) } } @@ -61,7 +59,7 @@ class ObjectCardVerticalText(context: Context, numberOfColumns: Int) { if (list.size == textViews.size) { list.indices.forEach { textViews[it].text = list[it] - textViews[it].setTextSize(TypedValue.COMPLEX_UNIT_PX, UIPreferences.textSizeSmall) + textViews[it].refreshTextSize(TextSize.SMALL) } } } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectImageMap.kt b/app/src/main/java/joshuatee/wx/ui/ObjectImageMap.kt index f5ea536c..943e0217 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectImageMap.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectImageMap.kt @@ -37,8 +37,7 @@ class ObjectImageMap( private val views: List ) { - // TODO FIXME make private - val map: ImageMap = activity.findViewById(resId) + private val map: ImageMap = activity.findViewById(resId) private var isRadarWithTransparent = false init { @@ -72,7 +71,9 @@ class ObjectImageMap( fun hideMap() { if (map.visibility != View.GONE) { map.visibility = View.GONE - views.forEach { it.visibility = View.VISIBLE } + views.forEach { + it.visibility = View.VISIBLE + } if (isRadarWithTransparent) { UtilityToolbar.transparentToolbars(toolbar, toolbarBottom) } @@ -80,7 +81,9 @@ class ObjectImageMap( } private fun setupMap() { - views.forEach { it.visibility = View.GONE } + views.forEach { + it.visibility = View.GONE + } setupImageMap(toolbar, toolbarBottom) map.visibility = View.VISIBLE } @@ -107,4 +110,10 @@ class ObjectImageMap( layoutParams.width = MyApplication.dm.widthPixels map.layoutParams = layoutParams } + + var visibility + get() = map.visibility + set(value) { map.visibility = value } + + fun get() = map } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectImageSummary.kt b/app/src/main/java/joshuatee/wx/ui/ObjectImageSummary.kt index 92d35eca..aa5c7169 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectImageSummary.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectImageSummary.kt @@ -39,16 +39,14 @@ class ObjectImageSummary(context: Context, val linearLayout: LinearLayout, val b val imagesPerRow = 2 linearLayout.removeAllViews() var numberOfImages = 0 - val horizontalLinearLayouts = mutableListOf() + val horizontalLinearLayouts = mutableListOf() bitmaps.forEach { bitmap -> - val objectCardImage: ObjectCardImage - if (numberOfImages % imagesPerRow == 0) { - val objectLinearLayout = ObjectLinearLayout(context, linearLayout) - objectLinearLayout.linearLayout.orientation = LinearLayout.HORIZONTAL - horizontalLinearLayouts.add(objectLinearLayout) - objectCardImage = ObjectCardImage(context, objectLinearLayout.linearLayout, bitmap, imagesPerRow) + val objectCardImage = if (numberOfImages % imagesPerRow == 0) { + val hbox = HBox(context, linearLayout) + horizontalLinearLayouts.add(hbox) + ObjectCardImage(context, hbox.get(), bitmap, imagesPerRow) } else { - objectCardImage = ObjectCardImage(context, horizontalLinearLayouts.last().linearLayout, bitmap, imagesPerRow) + ObjectCardImage(context, horizontalLinearLayouts.last().get(), bitmap, imagesPerRow) } objectCardImages.add(objectCardImage) numberOfImages += 1 diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectNavDrawer.kt b/app/src/main/java/joshuatee/wx/ui/ObjectNavDrawer.kt index 3a00703a..34f3073e 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectNavDrawer.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectNavDrawer.kt @@ -22,7 +22,9 @@ package joshuatee.wx.ui import android.app.Activity +import android.content.res.Configuration import android.graphics.Color +import android.view.MenuItem import android.view.View import android.view.ViewGroup import android.widget.AdapterView @@ -36,9 +38,9 @@ import joshuatee.wx.util.Utility class ObjectNavDrawer(val activity: Activity, private var labels: List) { - val drawerLayout: DrawerLayout = activity.findViewById(R.id.drawer_layout) - val listView: ListView = activity.findViewById(R.id.left_drawer) - val actionBarDrawerToggle: ActionBarDrawerToggle + private val drawerLayout: DrawerLayout = activity.findViewById(R.id.drawer_layout) + private val listView: ListView = activity.findViewById(R.id.left_drawer) + private val actionBarDrawerToggle: ActionBarDrawerToggle var tokens = listOf() var index = 0 @@ -138,7 +140,33 @@ class ObjectNavDrawer(val activity: Activity, private var labels: List) } } + fun setListener2(fn: AdapterView.OnItemClickListener) { + listView.onItemClickListener = fn + } + + fun setItemChecked(position: Int, value: Boolean) { + listView.setItemChecked(position, value) + } + fun open() { drawerLayout.openDrawer(listView) } + + fun openGravity(gravity: Int) { + drawerLayout.openDrawer(gravity) + } + + fun close() { + drawerLayout.closeDrawer(listView) + } + + fun syncState() { + actionBarDrawerToggle.syncState() + } + + fun onConfigurationChanged(newConfig: Configuration) { + actionBarDrawerToggle.onConfigurationChanged(newConfig) + } + + fun onOptionsItemSelected(item: MenuItem) = actionBarDrawerToggle.onOptionsItemSelected(item) } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectNavDrawerCombo.kt b/app/src/main/java/joshuatee/wx/ui/ObjectNavDrawerCombo.kt index c47eb1a5..cf7e586d 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectNavDrawerCombo.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectNavDrawerCombo.kt @@ -22,10 +22,12 @@ package joshuatee.wx.ui import android.app.Activity +import android.content.res.Configuration import android.graphics.Color import androidx.drawerlayout.widget.DrawerLayout import androidx.appcompat.app.ActionBarDrawerToggle import android.util.SparseArray +import android.view.MenuItem import android.widget.ExpandableListView import joshuatee.wx.util.MyExpandableListAdapter import joshuatee.wx.R @@ -40,9 +42,9 @@ class ObjectNavDrawerCombo( prefPrefix: String ) { - val drawerLayout: DrawerLayout = activity.findViewById(R.id.drawer_layout) - val listView: ExpandableListView = activity.findViewById(R.id.left_drawer) - val actionBarDrawerToggle: ActionBarDrawerToggle + private val drawerLayout: DrawerLayout = activity.findViewById(R.id.drawer_layout) + private val listView: ExpandableListView = activity.findViewById(R.id.left_drawer) + private val actionBarDrawerToggle: ActionBarDrawerToggle var imgIdx: Int var imgGroupIdx: Int @@ -86,4 +88,26 @@ class ObjectNavDrawerCombo( true } } + + fun setListener2(fn: ExpandableListView.OnChildClickListener) { + listView.setOnChildClickListener(fn) + } + + fun open() { + drawerLayout.openDrawer(listView) + } + + fun close() { + drawerLayout.closeDrawer(listView) + } + + fun syncState() { + actionBarDrawerToggle.syncState() + } + + fun onConfigurationChanged(newConfig: Configuration) { + actionBarDrawerToggle.onConfigurationChanged(newConfig) + } + + fun onOptionsItemSelected(item: MenuItem) = actionBarDrawerToggle.onOptionsItemSelected(item) } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectRecyclerView.kt b/app/src/main/java/joshuatee/wx/ui/ObjectRecyclerView.kt index df5621f7..2d4476e7 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectRecyclerView.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectRecyclerView.kt @@ -28,39 +28,39 @@ import androidx.recyclerview.widget.RecyclerView class ObjectRecyclerView(activity: Activity, resourceId: Int, list: MutableList, fn: (Int) -> Unit) { private val recyclerView: RecyclerView = activity.findViewById(resourceId) - private var ca = SingleTextAdapterList(list) + private var adapter = SingleTextAdapterList(list) init { recyclerView.setHasFixedSize(true) val linearLayoutManager = LinearLayoutManager(activity) linearLayoutManager.orientation = RecyclerView.VERTICAL recyclerView.layoutManager = linearLayoutManager - recyclerView.adapter = ca - ca.setOnItemClickListener(object : SingleTextAdapterList.MyClickListener { + recyclerView.adapter = adapter + adapter.setOnItemClickListener(object : SingleTextAdapterList.MyClickListener { override fun onItemClick(position: Int) { fn(position) } }) } fun refreshList(list: MutableList) { - ca = SingleTextAdapterList(list) - recyclerView.adapter = ca + adapter = SingleTextAdapterList(list) + recyclerView.adapter = adapter } fun notifyDataSetChanged() { - ca.notifyDataSetChanged() + adapter.notifyDataSetChanged() } fun setItem(index: Int, str: String) { - ca.setItem(index, str) + adapter.setItem(index, str) } - fun getItem(index: Int) = ca.getItem(index) + fun getItem(index: Int) = adapter.getItem(index) fun deleteItem(index: Int) { - ca.deleteItem(index) + adapter.deleteItem(index) } fun get() = recyclerView - override fun toString() = ca.toString() + override fun toString() = adapter.toString() } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectRecyclerViewGeneric.kt b/app/src/main/java/joshuatee/wx/ui/ObjectRecyclerViewGeneric.kt index 2a599af5..635bfca3 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectRecyclerViewGeneric.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectRecyclerViewGeneric.kt @@ -27,7 +27,7 @@ import androidx.recyclerview.widget.RecyclerView class ObjectRecyclerViewGeneric(activity: Activity, resourceId: Int) { - val recyclerView: RecyclerView = activity.findViewById(resourceId) + private val recyclerView: RecyclerView = activity.findViewById(resourceId) init { recyclerView.setHasFixedSize(true) @@ -39,4 +39,10 @@ class ObjectRecyclerViewGeneric(activity: Activity, resourceId: Int) { fun scrollToPosition(position: Int) { recyclerView.scrollToPosition(position) } + + var adapter + get() = recyclerView.adapter + set(value) { recyclerView.adapter = value } + + fun get() = recyclerView } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectTextView.kt b/app/src/main/java/joshuatee/wx/ui/ObjectTextView.kt index 524da366..84961a9c 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectTextView.kt +++ b/app/src/main/java/joshuatee/wx/ui/ObjectTextView.kt @@ -22,10 +22,12 @@ package joshuatee.wx.ui import android.content.Context +import android.graphics.Typeface import androidx.appcompat.widget.AppCompatTextView import android.util.TypedValue import android.view.Gravity import android.view.View +import android.widget.LinearLayout import joshuatee.wx.Extensions.setPadding import joshuatee.wx.settings.UIPreferences import joshuatee.wx.objects.TextSize @@ -52,9 +54,13 @@ class ObjectTextView(val context: Context) { tv.gravity = Gravity.START } - constructor(context: Context, text: String) : this(context) { tv.text = text } + constructor(context: Context, text: String) : this(context) { + tv.text = text + } - constructor(context: Context, color: Int) : this(context) { this.color = color } + constructor(context: Context, color: Int) : this(context) { + this.color = color + } constructor(context: Context, backgroundText: Boolean) : this(context) { if (backgroundText) { @@ -62,7 +68,9 @@ class ObjectTextView(val context: Context) { } } - constructor(view: View, resourceId: Int) : this(view.context) { tv = view.findViewById(resourceId) } + constructor(view: View, resourceId: Int) : this(view.context) { + tv = view.findViewById(resourceId) + } constructor(view: View, resourceId: Int, backgroundText: Boolean) : this(view, resourceId) { tv = view.findViewById(resourceId) @@ -71,16 +79,22 @@ class ObjectTextView(val context: Context) { } } - constructor(view: View, resourceId: Int, color: Int) : this(view, resourceId) { this.color = color } + constructor(view: View, resourceId: Int, color: Int) : this(view, resourceId) { + this.color = color + } constructor(view: View, resourceId: Int, size: TextSize) : this(view.context, size) { tv = view.findViewById(resourceId) refreshTextSize(size) } - constructor(view: View, resourceId: Int, color: Int, size: TextSize) : this(view, resourceId, size) { this.color = color } + constructor(view: View, resourceId: Int, color: Int, size: TextSize) : this(view, resourceId, size) { + this.color = color + } - constructor(context: Context, size: TextSize) : this(context) { refreshTextSize(size) } + constructor(context: Context, size: TextSize) : this(context) { + refreshTextSize(size) + } fun refreshTextSize(size: TextSize) { when (size) { @@ -98,6 +112,10 @@ class ObjectTextView(val context: Context) { get() = tv.currentTextColor set(newValue) { tv.setTextColor(newValue) } + var typeface: Typeface + get() = tv.typeface + set(newValue) { tv.typeface = newValue } + private fun setAsBackgroundText() { setAsSmallText() tv.setTextColor(UIPreferences.textSmallThemeColor) @@ -108,6 +126,14 @@ class ObjectTextView(val context: Context) { tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, UIPreferences.textSizeSmall) } + fun matchParent() { + tv.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT) + } + + fun wrap() { + tv.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f) + } + fun setOnClickListener(fn: View.OnClickListener) { tv.setOnClickListener(fn) } diff --git a/app/src/main/java/joshuatee/wx/ui/SingleTextAdapterList.kt b/app/src/main/java/joshuatee/wx/ui/SingleTextAdapterList.kt index a5c5ad94..7f765a5c 100644 --- a/app/src/main/java/joshuatee/wx/ui/SingleTextAdapterList.kt +++ b/app/src/main/java/joshuatee/wx/ui/SingleTextAdapterList.kt @@ -21,17 +21,23 @@ class SingleTextAdapterList(private val dataSet: MutableList) : Recycler } // was onItemClick(adapterPosition) - override fun onClick(v: View) { myClickListener!!.onItemClick(layoutPosition) } + override fun onClick(v: View) { + myClickListener!!.onItemClick(layoutPosition) + } } - fun setOnItemClickListener(myClickListenerloc: MyClickListener) { myClickListener = myClickListenerloc } + fun setOnItemClickListener(myClickListenerloc: MyClickListener) { + myClickListener = myClickListenerloc + } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DataObjectHolder { val view = LayoutInflater.from(parent.context).inflate(R.layout.textview, parent, false) return DataObjectHolder(view) } - override fun onBindViewHolder(holder: DataObjectHolder, position: Int) { holder.label.text = dataSet[position] } + override fun onBindViewHolder(holder: DataObjectHolder, position: Int) { + holder.label.text = dataSet[position] + } fun deleteItem(index: Int) { dataSet.removeAt(index) @@ -39,7 +45,9 @@ class SingleTextAdapterList(private val dataSet: MutableList) : Recycler } fun setItem(index: Int, str: String) { - if (index < dataSet.size) dataSet[index] = str + if (index < dataSet.size) { + dataSet[index] = str + } notifyDataSetChanged() } diff --git a/app/src/main/java/joshuatee/wx/ui/ObjectTouchImageView.kt b/app/src/main/java/joshuatee/wx/ui/TouchImage.kt similarity index 86% rename from app/src/main/java/joshuatee/wx/ui/ObjectTouchImageView.kt rename to app/src/main/java/joshuatee/wx/ui/TouchImage.kt index f014ddee..83986845 100644 --- a/app/src/main/java/joshuatee/wx/ui/ObjectTouchImageView.kt +++ b/app/src/main/java/joshuatee/wx/ui/TouchImage.kt @@ -24,13 +24,14 @@ package joshuatee.wx.ui import android.app.Activity import android.content.Context import android.graphics.Bitmap +import android.graphics.PointF import android.graphics.drawable.AnimationDrawable import android.view.View import androidx.appcompat.widget.Toolbar import joshuatee.wx.util.Utility import joshuatee.wx.util.UtilityImg -class ObjectTouchImageView { +class TouchImage { private var img: TouchImageView2 private val context: Context @@ -39,6 +40,11 @@ class ObjectTouchImageView { private var prefTokenIdx = "" private var drw: ObjectNavDrawer? = null + constructor(context: Context) { + img = TouchImageView2(context) + this.context = context + } + constructor(activity: Activity, resourceId: Int) { img = activity.findViewById(resourceId) this.context = activity @@ -77,6 +83,16 @@ class ObjectTouchImageView { get() = img.visibility set(value) { img.visibility = value } + val currentZoom + get() = img.currentZoom + +// var maxZoom +// get() = img.maxZoom +// set(value) { img.maxZoom = value } + + val scrollPosition: PointF? + get() = img.scrollPosition + fun setBitmap(bitmap: Bitmap) { img.setImageBitmap(bitmap) imageLoaded = true @@ -105,6 +121,14 @@ class ObjectTouchImageView { img.setZoom(zoom) } + fun setZoom(image: TouchImage) { + img.setZoom(image.currentZoom) + } + + fun setZoom(x: Float, y: Float, z: Float) { + img.setZoom(x, y, z) + } + fun setListener(drw: ObjectNavDrawer, fn: () -> Unit) { img.setOnTouchListener(object : OnSwipeTouchListener(context) { override fun onSwipeLeft() { @@ -117,6 +141,14 @@ class ObjectTouchImageView { }) } + fun setListener(fn: OnSwipeTouchListener) { + img.setOnTouchListener(fn) + } + + fun setListener2(fn: () -> Unit) { + img.setOnTouchImageViewListener { fn() } + } + fun firstRunSetZoomPosn(pref: String) { if (!firstRun) { img.setZoom(pref) diff --git a/app/src/main/java/joshuatee/wx/ui/UtilityTheme.kt b/app/src/main/java/joshuatee/wx/ui/UtilityTheme.kt index 3b818282..50ed7e58 100644 --- a/app/src/main/java/joshuatee/wx/ui/UtilityTheme.kt +++ b/app/src/main/java/joshuatee/wx/ui/UtilityTheme.kt @@ -29,7 +29,7 @@ import joshuatee.wx.util.Utility object UtilityTheme { - val primaryColorFromSelectedTheme: Int + val primaryColorFromSelectedTheme get() = UIPreferences.primaryColor fun getPrimaryColorFromSelectedTheme(context: Context, color: Int): Int { diff --git a/app/src/main/java/joshuatee/wx/ui/UtilityToolbar.kt b/app/src/main/java/joshuatee/wx/ui/UtilityToolbar.kt index 186ef62d..86004377 100644 --- a/app/src/main/java/joshuatee/wx/ui/UtilityToolbar.kt +++ b/app/src/main/java/joshuatee/wx/ui/UtilityToolbar.kt @@ -50,7 +50,9 @@ object UtilityToolbar { } } - fun fullScreenMode(activity: VideoRecordActivity) = fullScreenMode(activity.toolbar, activity.toolbarBottom) + fun fullScreenMode(activity: VideoRecordActivity) { + fullScreenMode(activity.toolbar, activity.toolbarBottom) + } fun fullScreenMode(toolbar: Toolbar) { toolbar.elevation = UIPreferences.elevationPref diff --git a/app/src/main/java/joshuatee/wx/ui/VBox.kt b/app/src/main/java/joshuatee/wx/ui/VBox.kt new file mode 100644 index 00000000..3627273b --- /dev/null +++ b/app/src/main/java/joshuatee/wx/ui/VBox.kt @@ -0,0 +1,112 @@ +/* + + Copyright 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 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.ui + +import android.content.Context +import android.view.Gravity +import android.view.View +import android.widget.LinearLayout + +class VBox(val context: Context) { + + private val linearLayout = LinearLayout(context) + + init { + linearLayout.orientation = LinearLayout.VERTICAL + } + + constructor(context: Context, parentView: LinearLayout) : this(context) { + linearLayout.orientation = LinearLayout.VERTICAL + parentView.addView(linearLayout) + } + + constructor(context: Context, orientation: Int, parentView: LinearLayout) : this(context) { + linearLayout.orientation = orientation + parentView.addView(linearLayout) + } + +// constructor(context: Context, orientation: Int) : this(context) { +// this.orientation = orientation +// } +// +// constructor(context: Context, orientation: Int, gravity: Int) : this(context, orientation) { +// this.gravity = gravity +// } + + constructor(context: Context, gravity: Int) : this(context) { + linearLayout.orientation = LinearLayout.VERTICAL + this.gravity = gravity + } + + fun removeAllViewsInLayout() { + linearLayout.removeAllViewsInLayout() + } + + fun addWidget(child: View) { + linearLayout.addView(child) + } + + fun addLayout(child: LinearLayout) { + linearLayout.addView(child) + } + + fun addViews(children: List) { + children.forEach { + linearLayout.addView(it) + } + } + + fun removeAllViews() { + linearLayout.removeAllViews() + } + + fun matchParent() { + linearLayout.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT) + } + + fun wrap() { + linearLayout.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT) + } + + fun get() = linearLayout + + var visibility + get() = linearLayout.visibility + set(value) { linearLayout.visibility = value } + +// var isBaselineAligned +// get() = linearLayout.isBaselineAligned +// set(value) { linearLayout.isBaselineAligned = value } + + var orientation + get() = linearLayout.orientation + set(value) { linearLayout.orientation = value } + + private var gravityBacking = Gravity.START + + var gravity + get() = gravityBacking + set(value) { + linearLayout.gravity = value + gravityBacking = value + } +} diff --git a/app/src/main/java/joshuatee/wx/util/UtilityFavorites.kt b/app/src/main/java/joshuatee/wx/util/UtilityFavorites.kt index c76cd7b3..57b12272 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityFavorites.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityFavorites.kt @@ -65,7 +65,9 @@ object UtilityFavorites { fun setupMenu(context: Context, favoriteString: String, value: String, prefToken: String): List { checkAndCorrect(context, favoriteString, prefToken) var favorites = favoriteString.split(":").dropLastWhile { it.isEmpty() }.toMutableList() - if (favorites.size < 3) favorites = MutableList(3) { "" } + if (favorites.size < 3) { + favorites = MutableList(3) { "" } + } favorites[0] = value favorites[1] = ADD_STR favorites[2] = MODIFY_STR diff --git a/app/src/main/java/joshuatee/wx/util/UtilityImg.kt b/app/src/main/java/joshuatee/wx/util/UtilityImg.kt index 0063a937..55a80e0d 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityImg.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityImg.kt @@ -42,6 +42,7 @@ import joshuatee.wx.MyApplication import joshuatee.wx.settings.UIPreferences import joshuatee.wx.radar.WXGLNexrad import joshuatee.wx.ui.ObjectNavDrawer +import joshuatee.wx.ui.TouchImage import joshuatee.wx.ui.TouchImageView2 import joshuatee.wx.ui.UtilityUI @@ -70,7 +71,7 @@ object UtilityImg { fun getBitmapAddWhiteBackground(context: Context, imgUrl: String) = layerDrawableToBitmap(listOf(ColorDrawable(Color.WHITE), BitmapDrawable(context.resources, imgUrl.getImage()))) - fun imgRestorePosnZoom(context: Context, img: TouchImageView2, prefStr: String) { + fun imgRestorePosnZoom(context: Context, img: TouchImage, prefStr: String) { img.setZoom( Utility.readPref(context, prefStr + "_ZOOM", 1.0f), Utility.readPref(context, prefStr + "_X", 0.5f), @@ -78,7 +79,7 @@ object UtilityImg { ) } - fun imgSavePosnZoom(context: Context, img: TouchImageView2, prefStr: String) { + fun imgSavePosnZoom(context: Context, img: TouchImage, prefStr: String) { val poi = img.scrollPosition var z = img.currentZoom if (poi != null) { diff --git a/app/src/main/java/joshuatee/wx/util/UtilityImgAnim.kt b/app/src/main/java/joshuatee/wx/util/UtilityImgAnim.kt index c6a9f305..f825e811 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityImgAnim.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityImgAnim.kt @@ -27,7 +27,7 @@ import android.graphics.drawable.AnimationDrawable import android.graphics.drawable.BitmapDrawable import joshuatee.wx.Extensions.getImage import joshuatee.wx.ui.TouchImageView2 -import joshuatee.wx.ui.ObjectTouchImageView +import joshuatee.wx.ui.TouchImage object UtilityImgAnim { @@ -96,7 +96,7 @@ object UtilityImgAnim { return true } - fun startAnimation(animationDrawable: AnimationDrawable, img: ObjectTouchImageView): Boolean { + fun startAnimation(animationDrawable: AnimationDrawable, img: TouchImage): Boolean { img.setImageDrawable(animationDrawable) animationDrawable.isOneShot = false animationDrawable.start() diff --git a/app/src/main/java/joshuatee/wx/util/UtilityUS.kt b/app/src/main/java/joshuatee/wx/util/UtilityUS.kt index 8b36a84a..528ce6a0 100644 --- a/app/src/main/java/joshuatee/wx/util/UtilityUS.kt +++ b/app/src/main/java/joshuatee/wx/util/UtilityUS.kt @@ -25,7 +25,6 @@ import android.content.Context import android.graphics.Color import androidx.core.app.NotificationCompat import joshuatee.wx.Extensions.* -import joshuatee.wx.MyApplication import joshuatee.wx.R import joshuatee.wx.activitiesmisc.CapAlert import joshuatee.wx.activitiesmisc.USAlertsDetailActivity @@ -81,7 +80,7 @@ object UtilityUS { val objectPendingIntents = ObjectPendingIntents(context, USAlertsDetailActivity::class.java, USAlertsDetailActivity.URL, arrayOf(url, ""), arrayOf(url, "sound")) val tornadoWarningPresent = title.contains(tornadoWarningString) if (!(NotificationPreferences.alertOnlyOnce && UtilityNotificationUtils.checkToken(context, url))) { - val sound = MyApplication.locations[currentLoc].sound && !inBlackout || MyApplication.locations[currentLoc].sound + val sound = Location.locations[currentLoc].sound && !inBlackout || Location.locations[currentLoc].sound && tornadoWarningPresent && NotificationPreferences.alertBlackoutTornado val objectNotification = ObjectNotification( context, diff --git a/app/src/main/java/joshuatee/wx/vis/GoesActivity.kt b/app/src/main/java/joshuatee/wx/vis/GoesActivity.kt index 7d812b83..9e5ce5b6 100644 --- a/app/src/main/java/joshuatee/wx/vis/GoesActivity.kt +++ b/app/src/main/java/joshuatee/wx/vis/GoesActivity.kt @@ -52,13 +52,13 @@ class GoesActivity : VideoRecordActivity() { companion object { const val RID = "" } private var bitmap = UtilityImg.getBlankBitmap() - private lateinit var img: ObjectTouchImageView + private lateinit var image: TouchImage private var animDrawable = AnimationDrawable() private lateinit var objectNavDrawer: ObjectNavDrawer private var sector = "cgl" private var oldSector = "cgl" private var savePrefs = true - private lateinit var activityArguments: Array + private lateinit var arguments: Array private val prefImagePosition = "GOES16_IMG" // NHC var goesFloater = false @@ -76,12 +76,12 @@ class GoesActivity : VideoRecordActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_image_show_navdrawer, R.menu.goes16, iconsEvenlySpaced = true, bottomToolbar = false) UtilityShortcut.hidePinIfNeeded(toolbarBottom) - activityArguments = intent.getStringArrayExtra(RID)!! + arguments = intent.getStringArrayExtra(RID)!! objectNavDrawer = ObjectNavDrawer(this, UtilityGoes.labels, UtilityGoes.codes) { getContent(sector) } - img = ObjectTouchImageView(this, toolbar, R.id.iv, objectNavDrawer, "") + image = TouchImage(this, toolbar, R.id.iv, objectNavDrawer, "") toolbar.setOnClickListener { objectNavDrawer.open() } - img.setMaxZoom(8.0f) - img.setListener(objectNavDrawer) { getContent(sector) } + image.setMaxZoom(8.0f) + image.setListener(objectNavDrawer) { getContent(sector) } readPrefs() getContent(sector) } @@ -99,22 +99,22 @@ class GoesActivity : VideoRecordActivity() { } private fun display() { - img.setBitmap(bitmap) - img.firstRunSetZoomPosn(prefImagePosition) + image.setBitmap(bitmap) + image.firstRunSetZoomPosn(prefImagePosition) if (oldSector != sector) { - img.setZoom(1.0f) + image.setZoom(1.0f) oldSector = sector } } override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - objectNavDrawer.actionBarDrawerToggle.syncState() + objectNavDrawer.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - objectNavDrawer.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawer.onConfigurationChanged(newConfig) } private fun writePrefs() { @@ -125,20 +125,20 @@ class GoesActivity : VideoRecordActivity() { } private fun readPrefs() { - if (activityArguments.isNotEmpty() && activityArguments[0] == "") { + if (arguments.isNotEmpty() && arguments[0] == "") { sector = Utility.readPref(this, "GOES16_SECTOR", sector) objectNavDrawer.index = Utility.readPref(this, "GOES16_IMG_FAV_IDX", 0) - } else if (activityArguments.size > 1 && activityArguments[0].contains("http")) { + } else if (arguments.size > 1 && arguments[0].contains("http")) { // NHC floater goesFloater = true - goesFloaterUrl = activityArguments[0] + goesFloaterUrl = arguments[0] objectNavDrawer.index = 0 sector = goesFloaterUrl savePrefs = false } else { - if (activityArguments.size > 1) { - sector = activityArguments[0] - objectNavDrawer.index = To.int(activityArguments[1]) + if (arguments.size > 1) { + sector = arguments[0] + objectNavDrawer.index = To.int(arguments[1]) savePrefs = false } } @@ -146,7 +146,7 @@ class GoesActivity : VideoRecordActivity() { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (objectNavDrawer.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawer.onOptionsItemSelected(item)) { return true } when (item.itemId) { @@ -209,7 +209,7 @@ class GoesActivity : VideoRecordActivity() { } override fun onStop() { - img.imgSavePosnZoom(prefImagePosition) + image.imgSavePosnZoom(prefImagePosition) super.onStop() } @@ -217,11 +217,11 @@ class GoesActivity : VideoRecordActivity() { if (!goesFloater) { FutureVoid(this, { animDrawable = UtilityGoes.getAnimation(this, objectNavDrawer.url, sector, frameCount) }) - { animDrawable.startAnimation(img) } + { animDrawable.startAnimation(image) } } else { FutureVoid(this, { animDrawable = UtilityGoes.getAnimationGoesFloater(this, objectNavDrawer.url, sector, frameCount) }) - { animDrawable.startAnimation(img) } + { animDrawable.startAnimation(image) } } } } diff --git a/app/src/main/java/joshuatee/wx/wpc/WPCImagesActivity.kt b/app/src/main/java/joshuatee/wx/wpc/WPCImagesActivity.kt index 44c5c878..bf909e7c 100644 --- a/app/src/main/java/joshuatee/wx/wpc/WPCImagesActivity.kt +++ b/app/src/main/java/joshuatee/wx/wpc/WPCImagesActivity.kt @@ -33,14 +33,8 @@ import joshuatee.wx.R import joshuatee.wx.settings.UIPreferences import joshuatee.wx.objects.FutureVoid import joshuatee.wx.radar.VideoRecordActivity -import joshuatee.wx.ui.ObjectNavDrawerCombo -import joshuatee.wx.ui.OnSwipeTouchListener -import joshuatee.wx.ui.TouchImageView2 -import joshuatee.wx.ui.UtilityToolbar -import joshuatee.wx.util.Utility -import joshuatee.wx.util.UtilityDownload -import joshuatee.wx.util.UtilityImg -import joshuatee.wx.util.UtilityShare +import joshuatee.wx.ui.* +import joshuatee.wx.util.* class WpcImagesActivity : VideoRecordActivity(), View.OnClickListener { @@ -48,13 +42,12 @@ class WpcImagesActivity : VideoRecordActivity(), View.OnClickListener { private var bitmap = UtilityImg.getBlankBitmap() private var timePeriod = 1 - private var firstRun = false - private var imageLoaded = false - private lateinit var drw: ObjectNavDrawerCombo - private lateinit var activityArguments: Array - private lateinit var img: TouchImageView2 + private lateinit var objectNavDrawerCombo: ObjectNavDrawerCombo + private lateinit var arguments: Array + private lateinit var image: TouchImage private var calledFromHomeScreen = false private var homeScreenId = "" + private val prefImagePosition = "WPCIMG" override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.wpcimages, menu) @@ -66,7 +59,7 @@ class WpcImagesActivity : VideoRecordActivity(), View.OnClickListener { val actionForward = menu.findItem(R.id.action_forward) actionBack!!.isVisible = false actionForward!!.isVisible = false - if (drw.getUrl().contains("https://graphical.weather.gov/images/conus/")) { + if (objectNavDrawerCombo.getUrl().contains("https://graphical.weather.gov/images/conus/")) { actionBack.isVisible = true actionForward.isVisible = true } @@ -76,28 +69,28 @@ class WpcImagesActivity : VideoRecordActivity(), View.OnClickListener { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_wpcimages, R.menu.wpcimages, iconsEvenlySpaced = true, bottomToolbar = false) - img = findViewById(R.id.img) - img.setOnClickListener(this) - img.setOnTouchListener(object : OnSwipeTouchListener(this) { + image = TouchImage(this, R.id.img) + image.setOnClickListener(this) + image.setListener(object : OnSwipeTouchListener(this) { override fun onSwipeLeft() { - if (img.currentZoom < 1.01f) showNextImg() + if (image.currentZoom < 1.01f) showNextImg() } override fun onSwipeRight() { - if (img.currentZoom < 1.01f) showPrevImg() + if (image.currentZoom < 1.01f) showPrevImg() } }) - activityArguments = intent.getStringArrayExtra(URL)!! - activityArguments.let { - if (activityArguments.size > 1 && activityArguments[0] == "HS") { - homeScreenId = activityArguments[1] + arguments = intent.getStringArrayExtra(URL)!! + arguments.let { + if (arguments.size > 1 && arguments[0] == "HS") { + homeScreenId = arguments[1] calledFromHomeScreen = true } } UtilityWpcImages.create() - drw = ObjectNavDrawerCombo(this, UtilityWpcImages.groups, UtilityWpcImages.longCodes, UtilityWpcImages.shortCodes, "WPG_IMG") - drw.setListener { getContent() } - toolbar.setOnClickListener { drw.drawerLayout.openDrawer(drw.listView) } + objectNavDrawerCombo = ObjectNavDrawerCombo(this, UtilityWpcImages.groups, UtilityWpcImages.longCodes, UtilityWpcImages.shortCodes, "WPG_IMG") + objectNavDrawerCombo.setListener { getContent() } + toolbar.setOnClickListener { objectNavDrawerCombo.open() } getContent() } @@ -109,7 +102,7 @@ class WpcImagesActivity : VideoRecordActivity(), View.OnClickListener { private fun getContent() { if (!calledFromHomeScreen) { title = "Images" - toolbar.subtitle = drw.getLabel() + toolbar.subtitle = objectNavDrawerCombo.getLabel() } else { title = "Images" toolbar.subtitle = GlobalArrays.nwsImageProducts.findLast { it.startsWith("$homeScreenId:") }!!.split(":")[1] @@ -120,13 +113,13 @@ class WpcImagesActivity : VideoRecordActivity(), View.OnClickListener { private fun download() { if (!calledFromHomeScreen) { val getUrl = when { - drw.getUrl().contains("https://graphical.weather.gov/images/conus/") -> drw.getUrl() + timePeriod + "_conus.png" - drw.getUrl().contains("aviationweather") -> drw.getUrl() - else -> drw.getUrl() + objectNavDrawerCombo.getUrl().contains("https://graphical.weather.gov/images/conus/") -> objectNavDrawerCombo.getUrl() + timePeriod + "_conus.png" + objectNavDrawerCombo.getUrl().contains("aviationweather") -> objectNavDrawerCombo.getUrl() + else -> objectNavDrawerCombo.getUrl() } - Utility.writePref(this, "WPG_IMG_FAV_URL", drw.getUrl()) - Utility.writePref(this, "WPG_IMG_IDX", drw.imgIdx) - Utility.writePref(this, "WPG_IMG_GROUPIDX", drw.imgGroupIdx) + Utility.writePref(this, "WPG_IMG_FAV_URL", objectNavDrawerCombo.getUrl()) + Utility.writePref(this, "WPG_IMG_IDX", objectNavDrawerCombo.imgIdx) + Utility.writePref(this, "WPG_IMG_GROUPIDX", objectNavDrawerCombo.imgGroupIdx) bitmap = getUrl.getImage() } else { bitmap = UtilityDownload.getImageProduct(this, homeScreenId) @@ -135,27 +128,23 @@ class WpcImagesActivity : VideoRecordActivity(), View.OnClickListener { } private fun update() { - img.setImageBitmap(bitmap) - if (!firstRun && activityArguments.size < 2) { - img.setZoom("WPCIMG") - firstRun = true - } - imageLoaded = true + image.setBitmap(bitmap) + image.firstRunSetZoomPosn(prefImagePosition) invalidateOptionsMenu() } override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - drw.actionBarDrawerToggle.syncState() + objectNavDrawerCombo.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - drw.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawerCombo.onConfigurationChanged(newConfig) } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (drw.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawerCombo.onOptionsItemSelected(item)) { return true } when (item.itemId) { @@ -171,7 +160,7 @@ class WpcImagesActivity : VideoRecordActivity(), View.OnClickListener { if (UIPreferences.recordScreenShare) { checkOverlayPerms() } else - UtilityShare.bitmap(this, drw.getLabel(), bitmap) + UtilityShare.bitmap(this, objectNavDrawerCombo.getLabel(), bitmap) } else -> return super.onOptionsItemSelected(item) } @@ -185,26 +174,24 @@ class WpcImagesActivity : VideoRecordActivity(), View.OnClickListener { } override fun onStop() { - if (imageLoaded && activityArguments.size < 2) { - UtilityImg.imgSavePosnZoom(this, img, "WPCIMG") - } + image.imgSavePosnZoom(prefImagePosition) super.onStop() } private fun showNextImg() { - drw.imgIdx += 1 - if (UtilityWpcImages.shortCodes[drw.imgGroupIdx][drw.imgIdx] == "") { - drw.imgIdx = 0 + objectNavDrawerCombo.imgIdx += 1 + if (UtilityWpcImages.shortCodes[objectNavDrawerCombo.imgGroupIdx][objectNavDrawerCombo.imgIdx] == "") { + objectNavDrawerCombo.imgIdx = 0 } getContent() } private fun showPrevImg() { - drw.imgIdx -= 1 - if (drw.imgIdx == -1) { - for (j in UtilityWpcImages.shortCodes[drw.imgGroupIdx].indices) { - if (UtilityWpcImages.shortCodes[drw.imgGroupIdx][j] == "") { - drw.imgIdx = j - 1 + objectNavDrawerCombo.imgIdx -= 1 + if (objectNavDrawerCombo.imgIdx == -1) { + for (j in UtilityWpcImages.shortCodes[objectNavDrawerCombo.imgGroupIdx].indices) { + if (UtilityWpcImages.shortCodes[objectNavDrawerCombo.imgGroupIdx][j] == "") { + objectNavDrawerCombo.imgIdx = j - 1 break } } diff --git a/app/src/main/java/joshuatee/wx/wpc/WPCRainfallForecastActivity.kt b/app/src/main/java/joshuatee/wx/wpc/WPCRainfallForecastActivity.kt index ab222f69..c7404b63 100644 --- a/app/src/main/java/joshuatee/wx/wpc/WPCRainfallForecastActivity.kt +++ b/app/src/main/java/joshuatee/wx/wpc/WPCRainfallForecastActivity.kt @@ -54,30 +54,30 @@ class WpcRainfallForecastActivity : AudioPlayActivity(), OnMenuItemClickListener private var textProduct = "" private var imageUrl = "" private var bitmap = UtilityImg.getBlankBitmap() - private lateinit var activityArguments: Array + private lateinit var arguments: Array private lateinit var objectCardImage: ObjectCardImage private lateinit var objectCardText: ObjectCardText - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private var tabletInLandscape = false private var html = "" @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout_bottom_toolbar, R.menu.spcmcdshowdetail) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) toolbarBottom.setOnMenuItemClickListener(this) tabletInLandscape = UtilityUI.isTablet() && UtilityUI.isLandScape(this) if (tabletInLandscape) { - linearLayout.orientation = LinearLayout.HORIZONTAL - objectCardImage = ObjectCardImage(this, linearLayout, UtilityImg.getBlankBitmap(), 2) + box.orientation = LinearLayout.HORIZONTAL + objectCardImage = ObjectCardImage(this, box, UtilityImg.getBlankBitmap(), 2) } else { - objectCardImage = ObjectCardImage(this, linearLayout) + objectCardImage = ObjectCardImage(this, box) } - objectCardText = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) - activityArguments = intent.getStringArrayExtra(NUMBER)!! - textProduct = activityArguments[0] - imageUrl = activityArguments[1] - title = "Day " + activityArguments[2] + " Excessive Rainfall Discussion" + objectCardText = ObjectCardText(this, box, toolbar, toolbarBottom) + arguments = intent.getStringArrayExtra(NUMBER)!! + textProduct = arguments[0] + imageUrl = arguments[1] + title = "Day " + arguments[2] + " Excessive Rainfall Discussion" toolbar.subtitle = textProduct getContent() } @@ -89,7 +89,7 @@ class WpcRainfallForecastActivity : AudioPlayActivity(), OnMenuItemClickListener private fun showText() { objectCardText.text = html - UtilityTts.conditionalPlay(activityArguments, 1, applicationContext, objectCardText.text, textProduct) + UtilityTts.conditionalPlay(arguments, 1, applicationContext, objectCardText.text, textProduct) } private fun showImage() { diff --git a/app/src/main/java/joshuatee/wx/wpc/WPCTextProductsActivity.kt b/app/src/main/java/joshuatee/wx/wpc/WPCTextProductsActivity.kt index c93cc452..e40f32a6 100644 --- a/app/src/main/java/joshuatee/wx/wpc/WPCTextProductsActivity.kt +++ b/app/src/main/java/joshuatee/wx/wpc/WPCTextProductsActivity.kt @@ -54,7 +54,7 @@ class WpcTextProductsActivity : AudioPlayActivity(), OnMenuItemClickListener { companion object { const val URL = "" } - private lateinit var activityArguments: Array + private lateinit var arguments: Array private var product = "" private var html = "" private var initialProduct = "" @@ -63,9 +63,9 @@ class WpcTextProductsActivity : AudioPlayActivity(), OnMenuItemClickListener { private lateinit var notificationToggle: MenuItem private var ridFavOld = "" private lateinit var textCard: ObjectCardText - private lateinit var drw: ObjectNavDrawerCombo + private lateinit var objectNavDrawerCombo: ObjectNavDrawerCombo private lateinit var scrollView: ScrollView - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private val prefToken = "NWS_TEXT_FAV" override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -82,21 +82,21 @@ class WpcTextProductsActivity : AudioPlayActivity(), OnMenuItemClickListener { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_wpctextproducts, R.menu.wpctext_products) scrollView = findViewById(R.id.scrollView) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) toolbarBottom.setOnMenuItemClickListener(this) star = toolbarBottom.menu.findItem(R.id.action_fav) notificationToggle = toolbarBottom.menu.findItem(R.id.action_notif_text_prod) - activityArguments = intent.getStringArrayExtra(URL)!! - if (activityArguments[0] == "pmdspd") { + arguments = intent.getStringArrayExtra(URL)!! + if (arguments[0] == "pmdspd") { product = UIPreferences.wpcTextFav } else { - product = activityArguments[0] + product = arguments[0] initialProduct = product } - textCard = ObjectCardText(this, linearLayout, toolbar, toolbarBottom) + textCard = ObjectCardText(this, box, toolbar, toolbarBottom) UtilityWpcText.create() - drw = ObjectNavDrawerCombo(this, UtilityWpcText.groups, UtilityWpcText.longCodes, UtilityWpcText.shortCodes, "") - drw.setListener(::changeProduct) + objectNavDrawerCombo = ObjectNavDrawerCombo(this, UtilityWpcText.groups, UtilityWpcText.longCodes, UtilityWpcText.shortCodes, "") + objectNavDrawerCombo.setListener(::changeProduct) getContent() } @@ -121,7 +121,7 @@ class WpcTextProductsActivity : AudioPlayActivity(), OnMenuItemClickListener { } else { textCard.typefaceDefault() } - UtilityTts.conditionalPlay(activityArguments, 2, applicationContext, html, "wpctext") + UtilityTts.conditionalPlay(arguments, 2, applicationContext, html, "wpctext") if (initialProduct != product) { Utility.writePref(this, "WPC_TEXT_FAV", product) UIPreferences.wpcTextFav = product @@ -136,7 +136,7 @@ class WpcTextProductsActivity : AudioPlayActivity(), OnMenuItemClickListener { when (item.itemId) { R.id.action_fav -> toggleFavorite() R.id.action_notif_text_prod -> { - UtilityNotificationTextProduct.toggle(this, linearLayout, product.uppercase(Locale.US)) + UtilityNotificationTextProduct.toggle(this, box, product.uppercase(Locale.US)) updateSubmenuNotificationText() } R.id.action_share -> UtilityShare.text(this, product, textToShare) @@ -146,7 +146,7 @@ class WpcTextProductsActivity : AudioPlayActivity(), OnMenuItemClickListener { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (drw.actionBarDrawerToggle.onOptionsItemSelected(item)) { + if (objectNavDrawerCombo.onOptionsItemSelected(item)) { return true } products = UtilityFavorites.setupMenu(this, UIPreferences.nwsTextFav, product, prefToken) @@ -187,7 +187,7 @@ class WpcTextProductsActivity : AudioPlayActivity(), OnMenuItemClickListener { } private fun changeProduct() { - product = drw.getUrl() + product = objectNavDrawerCombo.getUrl() getContent() } @@ -201,11 +201,11 @@ class WpcTextProductsActivity : AudioPlayActivity(), OnMenuItemClickListener { override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - drw.actionBarDrawerToggle.syncState() + objectNavDrawerCombo.syncState() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - drw.actionBarDrawerToggle.onConfigurationChanged(newConfig) + objectNavDrawerCombo.onConfigurationChanged(newConfig) } } diff --git a/app/src/main/java/joshuatee/wx/wpc/WpcRainfallForecastSummaryActivity.kt b/app/src/main/java/joshuatee/wx/wpc/WpcRainfallForecastSummaryActivity.kt index 36957218..0495225f 100644 --- a/app/src/main/java/joshuatee/wx/wpc/WpcRainfallForecastSummaryActivity.kt +++ b/app/src/main/java/joshuatee/wx/wpc/WpcRainfallForecastSummaryActivity.kt @@ -38,7 +38,7 @@ class WpcRainfallForecastSummaryActivity : BaseActivity() { private val bitmaps = MutableList(UtilityWpcRainfallForecast.urls.size){ UtilityImg.getBlankBitmap() } private var imagesPerRow = 2 - private lateinit var linearLayout: LinearLayout + private lateinit var box: LinearLayout private lateinit var objectImageSummary: ObjectImageSummary override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -49,13 +49,13 @@ class WpcRainfallForecastSummaryActivity : BaseActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState, R.layout.activity_linear_layout, R.menu.shared_multigraphics, false) - linearLayout = findViewById(R.id.linearLayout) + box = findViewById(R.id.linearLayout) if (UtilityUI.isLandScape(this)) { imagesPerRow = 3 } title = "Excessive Rainfall Outlooks" toolbar.subtitle = "WPC" - objectImageSummary = ObjectImageSummary(this, linearLayout, bitmaps) + objectImageSummary = ObjectImageSummary(this, box, bitmaps) getContent() } diff --git a/app/src/main/res/drawable/hailunknown.png b/app/src/main/res/drawable/hailunknown.png new file mode 100644 index 0000000000000000000000000000000000000000..80315e4a5bc3c51333280882d8896a2a3bc9916a GIT binary patch literal 2943 zcmV-_3xM>AP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z00020Nkl literal 0 HcmV?d00001 diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index 2aade383..269fe0b9 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -9,17 +9,11 @@ // TODO [ADD] 'getter for defaultDisplay: Display!' is deprecated. Deprecated in Java // TODO [ADD] 'getMetrics(DisplayMetrics!): Unit' is deprecated. Deprecated in Java // TODO [FIX] code cleanup in utilDownloadMcd/w/mpd -// TODO [REF] add ObjectLocation -// TODO [FIX] 7day not honoring C/F setting -// TODO [FIX] usalerts sps don't show radar icon if no poly // TODO [REF] migrate all to Future* (models/radar/LocationFragment) -// TODO [FIX] textual vwp is not looking to good -// TODO [ADD] alphabetize notif prefs in settings // TODO [ADD] have nexrad long press verbiage match iOS version // TODO [REF] replace String.format with stuff in to. // TODO [FIX] review multipane data usage // TODO [FIX] snow squall warning enabled - no way to long press -// TODO [FIX] settings label for C/F to indicate what it modifies // TODO [ADD] user request for metar homescreen widget // TODO [ADD] user request for dawn/dusk, look to migrate to: https://github.com/phototime/solarized-android // TODO [REF] ExternalGeodeticCalculator -> convert from class to object since all static @@ -36,12 +30,44 @@ // [ADD] handle deprecations in UtilityUI https://stackoverflow.com/questions/62577645/android-view-view-systemuivisibility-deprecated-what-is-the-replacement // [FIX] settings color pal editor shows "null" // [REF] ImageCollection toolbar.setOnClickListener { drw.drawerLayout.openDrawer(drw.listView) } -// [REF] shorten name of some objects ObjectTouchImageView -> ObjectTouchImage, etc +// [REF] shorten name of some objects , etc, ObjectTextView +// [FIX] nexrad invoked from alert will not keep site when jump to multipane // [ADD] Class for star icon +// [FIX] USAlerts state count is not accurate +// [REF] scan for and refactor: val layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT) +// [REF] Look for LinearLayout that should be ObjectLinearLayout +// [REF] Use ObjectTextView in ObjectCardVerticalText and ObjectSettings* +// [REF] XML based LinearLayout should be used to initialize ObjectLinearLayout +// [REF] scan for android.widget.TextView, have ObjectTextView accept layout id +// [REF] move Spinner, SeekBar, CheckBox, ColorLabel to UI - rename to match desktop if needed ``` [[_TOC_]] -## 55628 2022_07_20 +## 55633 2022_07_23 + +## 55632 2022_07_23 +* [REF] misc refactor +* [FIX] 7day not honoring C/F setting +* [REF] ObjectTouchImageView -> TouchImage +* [REF] DisplayDataNoSpinner and WpcImagesActivity were not using TouchImage (using raw TouchImageView2) + +## 55631 2022_07_22 +* [REF] misc refactor + +## 55630 2022_07_22 +* [REF] misc refactor + +## 55629 2022_07_22 +* [FIX] slowness in LocationEdit search icon appearing by loading cities before the activity is displayed +* [FIX] SPC HREF - some images not working, more work is needed (non-production model service) +* [ADD] Settings->Notification: alphabetize with logical groups +* [ADD] Settings: alphabetize +* [FIX] In usalerts for sps (special weather statement) and other alerts - don't show radar button if no polygon data is present +* [REF] rename ObjectCardAlertSummaryItem to ObjectCardAlertDetail, move button connections into card + +## 55628 2022_07_21 +* [REF] add ObjectLocation +* [REF] move MyApplication.locations to Location ## 55627 2022_07_20 * [FIX] Nexrad: if non-default option to use hi-res State lines data, not all lines were showing