B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Activity
Version=13.4
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: True
	#IncludeTitle: False
#End Region

' BroadcastDisplay - Dynamic layout to display broadcast messages
Sub Process_Globals
End Sub

Sub Globals
	Private pnlMain As Panel
	Private pnlHeader As Panel
	Private pnlContent As Panel
	Private pnlFooter As Panel
	Private lblPriority As Label
	Private lblTitle As Label
	Private lblMessage As Label
	Private lblTime As Label
	Private btnDismiss As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
	' Get broadcast data from intent
	Dim in As Intent = Activity.GetStartingIntent
	Dim title As String = in.GetExtra("title")
	Dim message As String = in.GetExtra("message")
	Dim priority As String = in.GetExtra("priority")
	
	If title = Null Then title = "Broadcast Message"
	If message = Null Then message = "No message content"
	If priority = Null Then priority = "normal"
	
	CreateDynamicLayout(title, message, priority)
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub CreateDynamicLayout(title As String, message As String, priority As String)
	' Main container panel
	pnlMain.Initialize("pnlMain")
	Activity.AddView(pnlMain, 0, 0, 100%x, 100%y)
	
	' Determine colors based on priority
	Dim headerColor, accentColor As Int
	Select Case priority.ToLowerCase
		Case "urgent"
			headerColor = Colors.RGB(220, 38, 38) ' Red
			accentColor = Colors.RGB(185, 28, 28) ' Dark red
		Case "high"
			headerColor = Colors.RGB(249, 115, 22) ' Orange
			accentColor = Colors.RGB(234, 88, 12) ' Dark orange
		Case "normal"
			headerColor = Colors.RGB(59, 130, 246) ' Blue
			accentColor = Colors.RGB(37, 99, 235) ' Dark blue
		Case "low"
			headerColor = Colors.RGB(107, 114, 128) ' Gray
			accentColor = Colors.RGB(75, 85, 99) ' Dark gray
		Case Else
			headerColor = Colors.RGB(59, 130, 246)
			accentColor = Colors.RGB(37, 99, 235)
	End Select
	
	' Set main background to white
	pnlMain.Color = Colors.White
	
	' Header panel (top section with priority)
	pnlHeader.Initialize("pnlHeader")
	pnlHeader.Color = headerColor
	pnlMain.AddView(pnlHeader, 0, 0, 100%x, 15%y)
	
	' Priority badge
	lblPriority.Initialize("lblPriority")
	lblPriority.Text = "  " & priority.ToUpperCase & "  "
	lblPriority.TextSize = 16
	lblPriority.TextColor = headerColor
	lblPriority.Gravity = Gravity.CENTER
	lblPriority.Typeface = Typeface.DEFAULT_BOLD
	
	' Create rounded background for priority badge
	Dim cdPriority As ColorDrawable
	cdPriority.Initialize2(Colors.White, 20dip, 0, Colors.Transparent)
	lblPriority.Background = cdPriority
	
	pnlHeader.AddView(lblPriority, 10dip, 5%y, 150dip, 40dip)
	
	' Time label
	lblTime.Initialize("lblTime")
	lblTime.Text = DateTime.Time(DateTime.Now)
	lblTime.TextSize = 14
	lblTime.TextColor = Colors.White
	lblTime.Gravity = Gravity.RIGHT
	pnlHeader.AddView(lblTime, 100%x - 120dip, 5%y, 110dip, 40dip)
	
	' Content panel (middle section with title and message)
	pnlContent.Initialize("pnlContent")
	pnlContent.Color = Colors.White
	pnlMain.AddView(pnlContent, 0, 15%y, 100%x, 70%y)
	
	' Title with icon
	lblTitle.Initialize("lblTitle")
	lblTitle.Text = "📢 " & title
	lblTitle.TextSize = 26
	lblTitle.TextColor = Colors.Black
	lblTitle.Gravity = Gravity.LEFT
	lblTitle.Typeface = Typeface.DEFAULT_BOLD
	pnlContent.AddView(lblTitle, 20dip, 20dip, 100%x - 40dip, 80dip)
	
	' Divider line
	Dim pnlDivider As Panel
	pnlDivider.Initialize("pnlDivider")
	pnlDivider.Color = Colors.RGB(229, 231, 235) ' Light gray
	pnlContent.AddView(pnlDivider, 20dip, 110dip, 100%x - 40dip, 2dip)
	
	' Message content
	lblMessage.Initialize("lblMessage")
	lblMessage.Text = message
	lblMessage.TextSize = 20
	lblMessage.TextColor = Colors.RGB(55, 65, 81) ' Dark gray
	lblMessage.Gravity = Gravity.LEFT
	pnlContent.AddView(lblMessage, 20dip, 130dip, 100%x - 40dip, 70%y - 150dip)
	
	' Footer panel (bottom section with button)
	pnlFooter.Initialize("pnlFooter")
	pnlFooter.Color = Colors.RGB(249, 250, 251) ' Very light gray
	pnlMain.AddView(pnlFooter, 0, 85%y, 100%x, 15%y)
	
	' Dismiss button
	btnDismiss.Initialize("btnDismiss")
	btnDismiss.Text = "DISMISS"
	btnDismiss.TextSize = 18
	btnDismiss.TextColor = Colors.White
	btnDismiss.Typeface = Typeface.DEFAULT_BOLD
	
	' Create rounded button with accent color
	Dim cdButton As ColorDrawable
	cdButton.Initialize2(accentColor, 10dip, 0, Colors.Transparent)
	btnDismiss.Background = cdButton
	
	pnlFooter.AddView(btnDismiss, 20dip, 3%y, 100%x - 40dip, 60dip)
End Sub

Sub btnDismiss_Click
	Activity.Finish
End Sub

Sub pnlMain_Click
	' Optional: allow tapping anywhere to close
	' Activity.Finish
End Sub
