Skip to content

Commit

Permalink
updates and working on fixing correct hail icons
Browse files Browse the repository at this point in the history
  • Loading branch information
ELY3M committed Jul 23, 2022
1 parent 270e0ff commit abcfa74
Show file tree
Hide file tree
Showing 132 changed files with 1,912 additions and 1,759 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="joshuatee.wx"
android:versionCode="55628"
android:versionName="55628-elys"
android:versionCode="55633"
android:versionName="55633-elys"
>

<uses-permission android:name="android.permission.INTERNET" />
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/joshuatee/wx/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*

Expand Down Expand Up @@ -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)
2 changes: 0 additions & 2 deletions app/src/main/java/joshuatee/wx/MyApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ class MyApplication : Application() {
lateinit var appContext: Context
var contentResolverLocal: ContentResolver? = null

val locations = mutableListOf<Location>()

fun initPreferences(context: Context) {
RadarPreferences.initRadarPreferences()
UIPreferences.initPreferences(context)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/joshuatee/wx/StartupActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/java/joshuatee/wx/activitiesmisc/CAPAlert.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -78,6 +99,7 @@ class CapAlert {
capAlert.event = eventText.parse("<cap:event>(.*?)</cap:event>")
capAlert.vtec = eventText.parse("<valueName>VTEC</valueName>.*?<value>(.*?)</value>")
capAlert.zones = eventText.parse("<valueName>UGC</valueName>.*?<value>(.*?)</value>")
capAlert.polygon = eventText.parse("<cap:polygon>(.*?)</cap:polygon>")
capAlert.text = ""
capAlert.text += capAlert.title
capAlert.text += GlobalVariables.newline + GlobalVariables.newline
Expand All @@ -91,6 +113,7 @@ class CapAlert {
if (UIPreferences.nwsTextRemovelinebreaks) {
capAlert.instructions = capAlert.instructions.replace("<br><br>", "<BR><BR>").replace("<br>", " ")
}
capAlert.points = capAlert.polygon.split(" ")
return capAlert
}

Expand Down
26 changes: 13 additions & 13 deletions app/src/main/java/joshuatee/wx/activitiesmisc/ForecastActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<ObjectCardText>()
private lateinit var scrollView: ScrollView
private lateinit var linearLayout: LinearLayout
private lateinit var box: LinearLayout
private var bitmapForCurrentCondition = UtilityImg.getBlankBitmap()
private var bitmaps = listOf<Bitmap>()

Expand All @@ -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()
}

Expand Down Expand Up @@ -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() {
Expand All @@ -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())
}
}

Expand All @@ -168,6 +168,6 @@ class ForecastActivity : BaseActivity() {

private fun saveLocation() {
val message = Location.save(this, latLon)
ObjectPopupMessage(linearLayout, message)
ObjectPopupMessage(box, message)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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) {
Expand All @@ -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) }
}
}
24 changes: 12 additions & 12 deletions app/src/main/java/joshuatee/wx/activitiesmisc/ImageShowActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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<String> = 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:") -> {
Expand All @@ -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() {
Expand All @@ -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 {
Expand Down
Loading

0 comments on commit abcfa74

Please sign in to comment.