Private Sub Class_Globals
Public NavDrawer As B4XDrawer
Public DrawerPanel As Panel
Private pCont As Panel
Public pContent As Panel
Public AppTitle As String
Public SectionTitle As String
Private PrevAction As String = "Swipe"
Private PrevState As String = "Closed"
Private tLongPress As Timer
Private CT As CustomToast
Private ToolTip As String
Public lTitle As Label
Private ActionBar As Panel
Private iBevel As ImageView
Private iShadow As ImageView
Private iIcon As ImageView
Private iDrawerIcon As ImageView
Private iOverflow As ImageView
Private iAction1 As ImageView
Private iAction2 As ImageView
Private iAction3 As ImageView
Private iAction4 As ImageView
Private iAction5 As ImageView
Private pHome As Panel
Private pAction1 As Panel
Private pAction2 As Panel
Private pAction3 As Panel
Private pAction4 As Panel
Private pAction5 As Panel
Private pOverflow As Panel
Private r As Reflector
Private ttl As String
Private HomeWidth As Int
Private Landscape As Boolean
Private Event1 As String
Private Event2 As String
Private Event3 As String
Private Event4 As String
Private Event5 As String
Private Name1 As String
Private Name2 As String
Private Name3 As String
Private Name4 As String
Private Name5 As String
Private sOverflow As Spinner
Private OverflowList As List
Private Thm As String
Private LtTxt As Boolean
Private Slct As Int
Private Drwr As String
Private Offset As Int
Private PrevIndicator As String
End Sub
'Initializes the ActionBar and adds it the activity
'Title = Text to be shown
'Icon = An image file in the files folder, eg "icon.png"
'LightText = Whether the title, drawer icon and overflow button should be light or dark
'Color = Color of the actionbar
'Theme = Light or Dark, themes overflow menu and drawer
'Bevel = Whether to add a bevel effect to the bottom of the bar
'Shadow = Whether to add a dropshadow below the actionbar
'Drawer = Whether to add the navigation drawer to the Activity
'OverflowItems = List of items to add to the overflow menu. List should have at least one item
'Indicator = Determines which symbol is shown in the top corner out of "Drawer", "Up", or "None"
'ADActivity = Pass the current activity. This lets the class access it
'Module = Pass Me
Public Sub Initialize(Title As String, Icon As String, LightText As Boolean, Color As Int, Theme As String, Bevel As Boolean, Shadow As Boolean, Drawer As Boolean, OverflowItems As List, Indicator As String, ADActivity As Activity, Module As Object)
#Region Initialize
lTitle.Initialize("")
ActionBar.Initialize("")
iBevel.Initialize("")
iShadow.Initialize("")
iIcon.Initialize("")
iDrawerIcon.Initialize("")
iAction1.Initialize("")
iAction2.Initialize("")
iAction3.Initialize("")
iAction4.Initialize("")
iAction5.Initialize("")
iOverflow.Initialize("")
pHome.Initialize("")
pAction1.Initialize("")
pAction2.Initialize("")
pAction3.Initialize("")
pAction4.Initialize("")
pAction5.Initialize("")
pOverflow.Initialize("")
OverflowList.Initialize
sOverflow.Initialize("sOverflow")
SectionTitle = Title
PrevIndicator = Indicator
CT.Initialize
tLongPress.Initialize("tLongPress", 1000)
pContent.Initialize("")
#End Region
#Region Get Orientation
Dim pnl As Panel
pnl = ADActivity
Dim LSInt As Int
If pnl.Height/pnl.Width < 1 Then
Landscape = True
LSInt = 1
Else
Landscape = False
LSInt = 0
End If
#End Region
If Theme = "Dark" Then
Thm = "white"
Slct = Colors.ARGB(127,255,255,255)
Else
Thm = "gray"
Slct = Colors.ARGB(127,0,0,0)
End If
lTitle.Text = Title
ttl = Title
LtTxt = LightText
If LightText Then
lTitle.TextColor = Colors.White
Else
lTitle.TextColor = Colors.Black
End If
lTitle.TextSize = 18
r.Target = lTitle
r.RunMethod2("setSingleLine", True, "java.lang.boolean")
Dim str As String
str = Icon
iIcon.SetBackgroundImage(LoadBitmap(File.DirAssets, str))
iIcon.Gravity = Gravity.FILL
ActionBar.Color = Color
Dim w, h As Int
If Landscape Then
h = 40dip
Else
h = 48dip
End If
w = pnl.Width
r.Target = pnl
If w = -1 Then w = r.RunMethod("getWidth")
If Bevel Then
iBevel.Color = Colors.ARGB(40, 0, 0, 0)
Else
iBevel.Color = Colors.Transparent
End If
Dim Bm As BitmapDrawable
Bm=GetDrawable("ic_overflow_" & Thm)
iOverflow.Bitmap=Bm.Bitmap
iOverflow.Gravity = Gravity.CENTER
Dim Bm2 As BitmapDrawable
If Indicator = "Drawer" Then
Bm2=GetDrawable("ic_drawer_" & Thm)
iDrawerIcon.Bitmap=Bm2.Bitmap
iDrawerIcon.Gravity = Gravity.CENTER_VERTICAL
Else
If Indicator = "Up" Then
Bm2=GetDrawable("ic_up_" & Thm)
iDrawerIcon.Bitmap=Bm2.Bitmap
iDrawerIcon.Gravity = Gravity.CENTER_VERTICAL
End If
End If
If Landscape Then
ActionBar.AddView(iDrawerIcon, -8dip, 4dip, 32dip, 32dip)
ActionBar.AddView(iIcon, 13dip, 4dip, 32dip, 32dip)
ActionBar.AddView(iOverflow, 100%x - 48dip, 0dip, 48dip, 40dip)
ActionBar.AddView(pHome, 0dip, 0dip, 0dip, 40dip)
ActionBar.AddView(pOverflow, 100%x - 48dip, 0, 48dip, 40dip)
ActionBar.AddView(lTitle, 58dip, 11dip - 4dip*LSInt, 0dip, 34dip)
Else
ActionBar.AddView(iDrawerIcon, -8dip, 8dip, 32dip, 32dip)
ActionBar.AddView(iIcon, 13dip, 8dip, 32dip, 32dip)
ActionBar.AddView(iOverflow, 100%x - 44dip, 4dip, 40dip, 40dip)
ActionBar.AddView(pHome, 0dip, 0dip, 0dip, 48dip)
ActionBar.AddView(pOverflow, 100%x - 48dip, 0, 48dip, 48dip)
ActionBar.AddView(lTitle, 58dip, 11dip - 4dip*LSInt, 0dip, 34dip)
End If
CallSubDelayed("", "Title_Resize")
ActionBar.AddView(iBevel, 0, h - 2dip, w, 2dip)
pnl.AddView(ActionBar, 0, 0, w, h)
#Region Listeners
If Indicator = "Drawer" Or Indicator = "Up" Then
r.Target = pHome
r.SetOnTouchListener("Home_onTouch")
r.SetOnClickListener("Home_Click")
End If
r.Target = pAction1
r.SetOnTouchListener("Action1_onTouch")
r.SetOnClickListener("Action1_Click")
r.Target = pAction2
r.SetOnTouchListener("Action2_onTouch")
r.SetOnClickListener("Action2_Click")
r.Target = pAction3
r.SetOnTouchListener("Action3_onTouch")
r.SetOnClickListener("Action3_Click")
r.Target = pAction4
r.SetOnTouchListener("Action4_onTouch")
r.SetOnClickListener("Action4_Click")
r.Target = pAction5
r.SetOnTouchListener("Action5_onTouch")
r.SetOnClickListener("Action5_Click")
r.Target = pOverflow
r.SetOnTouchListener("Overflow_onTouch")
r.SetOnClickListener("Overflow_Click")
#End Region
CallSubDelayed2("", "OverflowInit", OverflowItems)
Drwr = Indicator
If Drawer Then
pCont.Initialize("")
If Landscape Then
pnl.AddView(pCont, 0, 40dip, 100%x, 100%y - 40dip)
Else
pnl.AddView(pCont, 0, 48dip, 100%x, 100%y - 48dip)
End If
NavDrawer.Initialize(Me, "Drawer", pCont, 240dip)
'NavDrawer.Initialize("Drawer", pCont, 240dip)
NavDrawer.LeftPanel.Color = Colors.RGB(48,48,48)
DrawerPanel.Initialize("")
NavDrawer.LeftPanel.AddView(DrawerPanel, 0, 0, 240dip, pCont.Height)
pContent = NavDrawer.CenterPanel
If Theme = "Dark" Then
NavDrawer.CenterPanel.Color = Colors.RGB(48,48,48)
Else
NavDrawer.CenterPanel.Color = Colors.White
End If
End If
If Shadow Then
Bm=GetDrawable("shadow")
iShadow.Bitmap=Bm.Bitmap
iShadow.Gravity = Gravity.FILL
If Drawer Then
NavDrawer.CenterPanel.AddView(iShadow, 0, 0, w, 10dip)
CallSubDelayed("", "ShadowSendToBack")
Else
If Landscape Then
pnl.AddView(iShadow, 0, 40dip, w, 10dip)
Else
pnl.AddView(iShadow, 0, 48dip, w, 10dip)
End If
End If
End If
End Sub
Private Sub ShadowSendToBack
iShadow.BringToFront
End Sub
'Adds a single item to the actionbar
'Name = The name seen when action is longpressd or moved to the overflow menu
'Event = The sub that will be called when the button is clicked
'Icon = An image file in the files folder, eg "ic_search.png"
Public Sub AddAction(Name As String, EventName As String, Icon As String)
Title_Resize
Select ActionBar.NumberOfViews - 7
Case 0
Event1 = EventName
Name1 = Name
Dim Canvas1 As Canvas
Canvas1.Initialize(ActionBar)
If lTitle.Text = ttl Or Canvas1.MeasureStringWidth(lTitle.Text, lTitle.Typeface, lTitle.TextSize) > 200dip Then
If Landscape Then
ActionBar.AddView(iAction1, 100%x - 88dip, 4dip, 32dip, 32dip)
ActionBar.AddView(pAction1, 100%x - 96dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(iAction1, 100%x - 88dip, 8dip, 32dip, 32dip)
ActionBar.AddView(pAction1, 100%x - 96dip, 0dip, 48dip, 48dip)
End If
Dim str As String
str = Icon
iAction1.SetBackgroundImage(LoadBitmap(File.DirAssets, str))
iAction1.Gravity = Gravity.FILL
Else
OverflowList.InsertAt(0, Name & " ")
End If
Case 2
Event2 = EventName
Name2 = Name
Dim Canvas1 As Canvas
Canvas1.Initialize(ActionBar)
If lTitle.Text = ttl Or Canvas1.MeasureStringWidth(lTitle.Text, lTitle.Typeface, lTitle.TextSize) > 200dip Then
If Landscape Then
ActionBar.AddView(iAction2, 100%x - 136dip, 4dip, 32dip, 32dip)
ActionBar.AddView(pAction2, 100%x - 144dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(iAction2, 100%x - 136dip, 8dip, 32dip, 32dip)
ActionBar.AddView(pAction2, 100%x - 144dip, 0dip, 48dip, 48dip)
End If
Dim str As String
str = Icon
iAction2.SetBackgroundImage(LoadBitmap(File.DirAssets, str))
iAction2.Gravity = Gravity.FILL
Else
OverflowList.InsertAt(0, Name & " ")
End If
Case 4
Event3 = EventName
Name3 = Name
Dim Canvas1 As Canvas
Canvas1.Initialize(ActionBar)
If lTitle.Text = ttl Or Canvas1.MeasureStringWidth(lTitle.Text, lTitle.Typeface, lTitle.TextSize) > 200dip Then
If Landscape Then
ActionBar.AddView(iAction3, 100%x - 184dip, 4dip, 32dip, 32dip)
ActionBar.AddView(pAction3, 100%x - 192dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(iAction3, 100%x - 184dip, 8dip, 32dip, 32dip)
ActionBar.AddView(pAction3, 100%x - 192dip, 0dip, 48dip, 48dip)
End If
Dim str As String
str = Icon
iAction3.SetBackgroundImage(LoadBitmap(File.DirAssets, str))
iAction3.Gravity = Gravity.FILL
Else
OverflowList.InsertAt(0, Name & " ")
End If
Case 6
Event4 = EventName
Name4 = Name
#Region Test
Dim passed As Boolean
passed = False
If ttl = lTitle.Text Or lTitle.Text.Length > 16 Then
If (100%x - pHome.Width - 48dip - (ActionBar.NumberOfViews - 7)/2*48dip) > 48dip Then
passed = True
End If
End If
#End Region
If passed Then
If Landscape Then
ActionBar.AddView(iAction4, 100%x - 232dip, 4dip, 32dip, 32dip)
ActionBar.AddView(pAction4, 100%x - 240dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(iAction4, 100%x - 232dip, 8dip, 32dip, 32dip)
ActionBar.AddView(pAction4, 100%x - 240dip, 0dip, 48dip, 48dip)
End If
Dim str As String
str = Icon
iAction4.SetBackgroundImage(LoadBitmap(File.DirAssets, str))
iAction4.Gravity = Gravity.FILL
Else
OverflowList.InsertAt(0, Name & " ")
End If
Case 8
Event5 = EventName
Name5 = Name
#Region Test
Dim passed As Boolean
passed = False
If ttl = lTitle.Text Or lTitle.Text.Length > 16 Then
If (100%x - pHome.Width - 48dip - (ActionBar.NumberOfViews - 7)/2*48dip) > 48dip Then
passed = True
End If
End If
#End Region
If passed Then
If Landscape Then
ActionBar.AddView(iAction5, 100%x - 280dip, 4dip, 32dip, 32dip)
ActionBar.AddView(pAction5, 100%x - 288dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(iAction5, 100%x - 280dip, 8dip, 32dip, 32dip)
ActionBar.AddView(pAction5, 100%x - 288dip, 0dip, 48dip, 48dip)
End If
Dim str As String
str = Icon
iAction5.SetBackgroundImage(LoadBitmap(File.DirAssets, str))
iAction5.Gravity = Gravity.FILL
Else
OverflowList.InsertAt(0, Name & " ")
End If
Case 10
OverflowList.InsertAt(0, Name & " ")
End Select
End Sub
Private Sub Title_Resize
Dim Canvas1 As Canvas
Canvas1.Initialize(ActionBar)
Dim width As Float
width = Canvas1.MeasureStringWidth(lTitle.Text, lTitle.Typeface, lTitle.TextSize)
Do While width > 100%x - 58dip - (ActionBar.NumberOfViews - 7)/2*48dip - 10dip - 48dip + Offset
lTitle.Text = lTitle.Text.SubString2(0, lTitle.Text.Length - 2).Trim & "…"
width = Canvas1.MeasureStringWidth(lTitle.Text, lTitle.Typeface, lTitle.TextSize)
Loop
lTitle.width = width +10dip
pHome.width = 58dip + width + 10dip
pHome.BringToFront
HomeWidth = pHome.width
pHome.Color = Colors.Transparent
Offset = 0
End Sub
#Region Touch Events
Private Sub Home_onTouch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
pHome.Color = Slct
Select Action
Case 1
pHome.Color = Colors.Transparent
If Drwr = "Drawer" Then
If NavDrawer.LeftOpen Then
PrevAction = "cClick"
NavDrawer.LeftOpen=False
Else
PrevAction = "oClick"
NavDrawer.LeftOpen=True
End If
Else
If Drwr = "Up" Then
CallSubDelayed(Main, "Up_Click")
End If
End If
Case 2
If Drwr = "None" Then
Else
pHome.Color = Slct
End If
End Select
If Round2(Y, 0) > 48dip Then
pHome.RemoveView
If Landscape Then
ActionBar.AddView(pHome, 0, 0dip, HomeWidth, 40dip)
Else
ActionBar.AddView(pHome, 0, 0dip, HomeWidth, 48dip)
End If
pHome.Color = Colors.Transparent
End If
If Round2(X, 0) > HomeWidth Then
pHome.RemoveView
If Landscape Then
ActionBar.AddView(pHome, 0, 0dip, HomeWidth, 40dip)
Else
ActionBar.AddView(pHome, 0, 0dip, HomeWidth, 48dip)
End If
pHome.Color = Colors.Transparent
End If
If Round2(X, 0) < 0 Then
pHome.RemoveView
If Landscape Then
ActionBar.AddView(pHome, 0, 0dip, HomeWidth, 40dip)
Else
ActionBar.AddView(pHome, 0, 0dip, HomeWidth, 48dip)
End If
pHome.Color = Colors.Transparent
End If
End Sub
Private Sub Action1_onTouch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
pAction1.Color = Slct
tLongPress.Enabled = True
ToolTip = Name1
Select Action
Case 1
pAction1.Color = Colors.Transparent
tLongPress.Enabled = False
CallSubDelayed(Main, Event1)
End Select
If Round2(Y, 0) > 48dip Then
pAction1.RemoveView
If Landscape Then
ActionBar.AddView(pAction1, 100%x - 96dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction1, 100%x - 96dip, 0dip, 48dip, 48dip)
End If
pAction1.Color = Colors.Transparent
tLongPress.Enabled = False
End If
If Round2(X, 0) > 48dip Then
pAction1.RemoveView
If Landscape Then
ActionBar.AddView(pAction1, 100%x - 96dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction1, 100%x - 96dip, 0dip, 48dip, 48dip)
End If
pAction1.Color = Colors.Transparent
tLongPress.Enabled = False
End If
If Round2(X, 0) < 0 Then
pAction1.RemoveView
If Landscape Then
ActionBar.AddView(pAction1, 100%x - 96dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction1, 100%x - 96dip, 0dip, 48dip, 48dip)
End If
pAction1.Color = Colors.Transparent
tLongPress.Enabled = False
End If
End Sub
Private Sub Action2_onTouch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
pAction2.Color = Slct
tLongPress.Enabled = True
ToolTip = Name2
Select Action
Case 1
pAction2.Color = Colors.Transparent
CallSubDelayed(Main, Event2)
End Select
If Round2(Y, 0) > 48dip Then
pAction2.RemoveView
If Landscape Then
ActionBar.AddView(pAction2, 100%x - 144dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction2, 100%x - 144dip, 0dip, 48dip, 48dip)
End If
pAction2.Color = Colors.Transparent
End If
If Round2(X, 0) > 48dip Then
pAction2.RemoveView
If Landscape Then
ActionBar.AddView(pAction2, 100%x - 144dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction2, 100%x - 144dip, 0dip, 48dip, 48dip)
End If
pAction2.Color = Colors.Transparent
End If
If Round2(X, 0) < 0 Then
pAction2.RemoveView
If Landscape Then
ActionBar.AddView(pAction2, 100%x - 144dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction2, 100%x - 144dip, 0dip, 48dip, 48dip)
End If
pAction2.Color = Colors.Transparent
End If
End Sub
Private Sub Action3_onTouch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
pAction3.Color = Slct
tLongPress.Enabled = True
ToolTip = Name3
Select Action
Case 1
pAction3.Color = Colors.Transparent
CallSubDelayed(Main, Event3)
End Select
If Round2(Y, 0) > 48dip Then
pAction3.RemoveView
If Landscape Then
ActionBar.AddView(pAction3, 100%x - 192dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction3, 100%x - 192dip, 0dip, 48dip, 48dip)
End If
pAction3.Color = Colors.Transparent
End If
If Round2(X, 0) > 48dip Then
pAction3.RemoveView
If Landscape Then
ActionBar.AddView(pAction3, 100%x - 192dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction3, 100%x - 192dip, 0dip, 48dip, 48dip)
End If
pAction3.Color = Colors.Transparent
End If
If Round2(X, 0) < 0 Then
pAction3.RemoveView
If Landscape Then
ActionBar.AddView(pAction3, 100%x - 192dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction3, 100%x - 192dip, 0dip, 48dip, 48dip)
End If
pAction3.Color = Colors.Transparent
End If
End Sub
Private Sub Action4_onTouch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
pAction4.Color = Slct
tLongPress.Enabled = True
ToolTip = Name4
Select Action
Case 1
pAction4.Color = Colors.Transparent
CallSubDelayed(Main, Event4)
End Select
If Round2(Y, 0) > 48dip Then
pAction4.RemoveView
If Landscape Then
ActionBar.AddView(pAction4, 100%x - 240dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction4, 100%x - 240dip, 0dip, 48dip, 48dip)
End If
pAction4.Color = Colors.Transparent
End If
If Round2(X, 0) > 48dip Then
pAction4.RemoveView
If Landscape Then
ActionBar.AddView(pAction4, 100%x - 240dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction4, 100%x - 240dip, 0dip, 48dip, 48dip)
End If
pAction4.Color = Colors.Transparent
End If
If Round2(X, 0) < 0 Then
pAction4.RemoveView
If Landscape Then
ActionBar.AddView(pAction4, 100%x - 240dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction4, 100%x - 240dip, 0dip, 48dip, 48dip)
End If
pAction4.Color = Colors.Transparent
End If
End Sub
Private Sub Action5_onTouch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
pAction5.Color = Slct
tLongPress.Enabled = True
ToolTip = Name5
Select Action
Case 1
pAction5.Color = Colors.Transparent
CallSubDelayed(Main, Event5)
End Select
If Round2(Y, 0) > 48dip Then
pAction5.RemoveView
If Landscape Then
ActionBar.AddView(pAction5, 100%x - 288dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction5, 100%x - 288dip, 0dip, 48dip, 48dip)
End If
pAction5.Color = Colors.Transparent
End If
If Round2(X, 0) > 48dip Then
pAction5.RemoveView
If Landscape Then
ActionBar.AddView(pAction5, 100%x - 288dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction5, 100%x - 288dip, 0dip, 48dip, 48dip)
End If
pAction5.Color = Colors.Transparent
End If
If Round2(X, 0) < 0 Then
pAction5.RemoveView
If Landscape Then
ActionBar.AddView(pAction5, 100%x - 288dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction5, 100%x - 288dip, 0dip, 48dip, 48dip)
End If
pAction5.Color = Colors.Transparent
End If
End Sub
Private Sub Overflow_onTouch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
pOverflow.Color = Slct
Select Action
Case 1
pOverflow.Color = Colors.Transparent
OpenMenu
End Select
If Round2(Y, 0) > 48dip Then
pOverflow.RemoveView
If Landscape Then
ActionBar.AddView(pOverflow, 100%x - 48dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pOverflow, 100%x - 48dip, 0dip, 48dip, 48dip)
End If
pOverflow.Color = Colors.Transparent
End If
If Round2(X, 0) > 48dip Then
pOverflow.RemoveView
If Landscape Then
ActionBar.AddView(pOverflow, 100%x - 48dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pOverflow, 100%x - 48dip, 0dip, 48dip, 48dip)
End If
pOverflow.Color = Colors.Transparent
End If
If Round2(X, 0) < 0 Then
pOverflow.RemoveView
If Landscape Then
ActionBar.AddView(pOverflow, 100%x - 48dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pOverflow, 100%x - 48dip, 0dip, 48dip, 48dip)
End If
pOverflow.Color = Colors.Transparent
End If
End Sub
#End Region
Private Sub OverflowInit(Items As List)
Dim str As String
str = Items.Get(0)
If str.Length < 28 Then
For i = 1 To Round2((28-str.Length)/2,0)
str = str & " "
Next
Items.RemoveAt(0)
Items.InsertAt(0, str)
End If
Items.AddAllAt(0, OverflowList)
For i=0 To Items.Size - 1
sOverflow.Add(Items.Get(i))
Next
sOverflow.TextSize = 18
If Thm = "Dark" Or LtTxt = True Then
sOverflow.TextColor = Colors.White
sOverflow.DropdownBackgroundColor = Colors.RGB(48,48,48)
Else
sOverflow.TextColor = Colors.Black
End If
sOverflow.Color = Colors.Transparent
If Landscape Then
ActionBar.AddView(sOverflow, 100%x - 40dip, 0dip, 0dip, 40dip)
Else
ActionBar.AddView(sOverflow, 100%x - 48dip, 0dip, 0dip, 48dip)
End If
sOverflow.SendToBack
End Sub
Private Sub OpenMenu
Dim r As Reflector
r.Target = sOverflow
r.RunMethod("performClick")
End Sub
Private Sub sOverflow_ItemClick (Position As Int, Value As Object)
Dim str As String
str = Value
If str.Length = str.Trim.Length + 2 Then
CallSub(Main, str.Trim.Replace(" ", "_") & "_Click")
Else
CallSub2(Main, "Overflow_Click", str.Trim)
End If
End Sub
Private Sub GetDrawable(Name As String) As Object
Dim r As Reflector
Dim package As String
Dim id As Int
package = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
id = r.GetStaticField(package & ".R$drawable", Name)
r.Target = r.GetContext
r.Target = r.RunMethod("getResources")
Return r.RunMethod2("getDrawable", id, "java.lang.int")
End Sub
Private Sub Drawer_DrawerSlide (Position As Float, DrawerGravity As Int)
If Drwr = "Drawer" Then
If PrevIndicator = "Up" Then
If Position < 0.5 Then
iDrawerIcon.Left = -14dip + (12dip * ( 0.5 - Position))
End If
Else
If PrevState = "Closed" Then
If PrevAction = "cClick" Then
iDrawerIcon.Left = -8dip -(6dip * Position)
Else
PrevAction = "Swipe"
If Position < 0.5 Then
iDrawerIcon.Left = -14dip + (12dip * ( 0.5 - Position))
End If
End If
Else
If PrevAction = "oClick" Then
iDrawerIcon.Left = -8dip -(6dip * Position)
Else
PrevAction = "Swipe"
If Position > 0.5 Then
iDrawerIcon.Left = -8dip -(12dip * (Position - 0.5))
End If
End If
End If
End If
End If
End Sub
Private Sub Drawer_DrawerClosed(DrawerGravity As Int)
PrevState = "Opened"
lTitle.Text = SectionTitle
Drwr = PrevIndicator
Dim Bm2 As BitmapDrawable
If Drwr = "Drawer" Then
Bm2=GetDrawable("ic_drawer_" & Thm)
iDrawerIcon.Bitmap=Bm2.Bitmap
iDrawerIcon.Gravity = Gravity.CENTER_VERTICAL
Else
If Drwr = "Up" Then
Bm2=GetDrawable("ic_up_" & Thm)
iDrawerIcon.Bitmap=Bm2.Bitmap
iDrawerIcon.Gravity = Gravity.CENTER_VERTICAL
End If
End If
Offset = 24dip
Title_Resize
End Sub
Private Sub Drawer_DrawerOpened(DrawerGravity As Int)
PrevState = "Closed"
lTitle.Text = AppTitle
PrevIndicator = Drwr
Drwr = "Drawer"
Dim Bm As BitmapDrawable
Bm=GetDrawable("ic_drawer_" & Thm)
iDrawerIcon.Bitmap=Bm.Bitmap
iDrawerIcon.Gravity = Gravity.CENTER_VERTICAL
iDrawerIcon.Left = -14dip
Offset = 24dip
Title_Resize
End Sub
Private Sub tLongPress_Tick
Select ToolTip
Case Name1
temp = 1
pAction1.RemoveView
If Landscape Then
ActionBar.AddView(pAction1, 100%x - 96dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction1, 100%x - 96dip, 0dip, 48dip, 48dip)
End If
pAction1.Color = Colors.Transparent
Case Name2
temp = 2
pAction2.RemoveView
If Landscape Then
ActionBar.AddView(pAction2, 100%x - 144dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction2, 100%x - 144dip, 0dip, 48dip, 48dip)
End If
pAction2.Color = Colors.Transparent
Case Name3
temp = 3
pAction3.RemoveView
If Landscape Then
ActionBar.AddView(pAction3, 100%x - 192dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction3, 100%x - 192dip, 0dip, 48dip, 48dip)
End If
pAction3.Color = Colors.Transparent
Case Name4
temp = 4
pAction4.RemoveView
If Landscape Then
ActionBar.AddView(pAction4, 100%x - 240dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction4, 100%x - 240dip, 0dip, 48dip, 48dip)
End If
pAction4.Color = Colors.Transparent
Case Name5
temp = 5
pAction5.RemoveView
If Landscape Then
ActionBar.AddView(pAction5, 100%x - 288dip, 0dip, 48dip, 40dip)
Else
ActionBar.AddView(pAction5, 100%x - 288dip, 0dip, 48dip, 48dip)
End If
pAction5.Color = Colors.Transparent
End Select
CT.Show(ToolTip, 250, Bit.Or(Gravity.TOP, Gravity.RIGHT), 48dip*(temp + 0.4), 48dip)
tLongPress.Enabled = False
End Sub