B4A Library FancyButton V1.0.3

Discussion in 'Additional libraries, classes and official updates' started by DonManfred, Mar 4, 2015.

  1. DonManfred

    DonManfred Expert Licensed User

    FancyBtn This Library-Wrapper is based on this Github-Project.
    FancyBtn
    Version: 1.03

    • Methods:
      • onTouch (view As View, motionEvent As MotionEvent) As Boolean
    • FancyBtn
      Events:
      • click (v as Object As , tag As Object)
      • hover (v as Object As , tag As Object)
      • ondismiss (v as Object As , tag As Object)
      Methods:
      • AddToParent (Parent As ViewGroup, left As Int, top As Int, width As Int, height As Int)
      • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
      • Initialize (EventName As String, iconres As String, IconPosition As Int, tag As Object, AllowDismiss As Boolean)
      • IsInitialized As Boolean
      • uniplus (s As String) As String
      Properties:
      • Background As Drawable [write only]
      • BackgroundColor As Int [write only]
        Sets the BackgroundColor to use with the FancyButton
      • BackgroundColor2 As String [write only]
        Sets the BackgroundColor to use with the FancyButton
        here you can give a hexstring representating the color
      • BorderColor As Int [write only]
        Sets the BorderColor to use with the FancyButton
      • BorderWidth As Int [write only]
        Sets the BorderWidth to use with the FancyButton
      • CustomIconFont As String [write only]
        Set a new Iconfont to use in the FancyButton.
        It must be a name from a file in the assets-folder
        fontawesome.ttf for ex.
      • CustomTextFont As String [write only]
        Set a new Textfont to use in the FancyButton.
        It must be a name from a file in the assets-folder
        robotoregular.ttf for ex.
      • FontIconSize As Int [write only]
        Sets the Size of the icon to use with the FancyButton
        Only works when using an Icon from the IconFont.
      • Icon As String [write only]
        Sets the Icon to use with the FancyButton. You need to give an unicode
        string representating the Icon in the Iconfont. For ex. ?
      • IconDrawable As String [write only]
        Sets the Icon to use with the FancyButton
        You can give the filename of a drawable in the
        drawable folder in your res folder.
      • IconPosition As Int [write only]
        Set the Icon-Position of the FancyButton.
        1 = Left
        POSITION_LEFT = 1;
        POSITION_RIGHT = 2;
        POSITION_TOP = 3;
        POSITION_BOTTOM = 4;
      • Left As Int
      • Radius As Int [write only]
        Sets the Radius to use with the FancyButtons edges
      • Tag As Object
        Sets the Tag for this FancyButton
      • Text As String [write only]
        Sets the Text to use with the FancyButton
      • TextSize As Int [write only]
        Sets the Textsize to use with the FancyButton
      • Textcolor As Int [write only]
        Sets the TextColor to use with the FancyButton
      • Top As Int
      • Visible As Boolean
        Sets the FancyButtons visibility
      • Width As Int

    See this cheat for a list of all included Icons in the Iconfont

    [​IMG]

    This library is Donationware. You can download the library, you can test the library. But if you want to USE the library in your App you need to Donate for it.
    Please click here to donate (You can donate any amount you want to donate for the library (or my work) :)
    [​IMG]
     

    Attached Files:

    Last edited: Mar 10, 2015
  2. migrec

    migrec Member Licensed User

    You released it this late? now I can't sleep :D Thanks @DonManfred !
     
    Erel, Cableguy and DonManfred like this.
  3. DonManfred

    DonManfred Expert Licensed User


    :D
     
    ellpopeb4a, Peter Simpson and migrec like this.
  4. cambopad

    cambopad Active Member Licensed User

    Another great lib to test :)
    Thanks you!
     
  5. daemon

    daemon Active Member Licensed User

    Does it include 'Slide to unlock' kind of button?
     
  6. DonManfred

    DonManfred Expert Licensed User

  7. bluedude

    bluedude Well-Known Member Licensed User

    See my post in pgogress wheel. Could this easily be combined with the progresswheel for a click and progress button?
     
  8. Peter Simpson

    Peter Simpson Expert Licensed User

    Ooh very nice :)
     
    DonManfred likes this.
  9. DonManfred

    DonManfred Expert Licensed User

    To whom it may concern:

    Fancy Buttons can use 9-Patch images

    a9p_09_11_01063.9.png

    [​IMG]


    a9p_09_11_00712.9.png

    [​IMG]

    You need the following sub and the files must be in objects\res\drawable\

    Code:
    Sub SetNinePatchDrawable(Control As View, ImageName As String)
       
    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", ImageName)
       r.Target = r.GetContext
       r.Target = r.RunMethod(
    "getResources")
       
    Control.Background = r.RunMethod2("getDrawable"id"java.lang.int")
    End Sub
    You can set a 9-patch to an FancyButton with
    Code:
    SetNinePatchDrawable(FancyButton1,"a9p_09_11_00712")
    to set the file "a9p_09_11_00712.9.png" as 9-patch
     
  10. MarcoRome

    MarcoRome Expert Licensed User

    Hi DonManfred if i have 2 button f1, f2 .

    Code:
    Sub fb_click
    .... 
    Sender or what ?? 
    End sub
    Possibile one little example ?
    Thank you
    Marco
     
  11. DonManfred

    DonManfred Expert Licensed User

    My plan is to release New Version tomorrow.
    Will do an example for this too
     
    MarcoRome likes this.
  12. MarcoRome

    MarcoRome Expert Licensed User

    Hi all. Today our good DonManfred is Busy... and so this is for management to click event:



    Code:
    fb1.Initialize("fb1","\uf082",0)
        
    Activity.AddView(fb1, 0,0dip,100dip,100dip)
        fb1.TextSize = 
    30
        fb1.Radius = 
    50dip
        fb1.Text = 
    "FB"
        fb1.Tag = 
    "1"
       
        fb2.Initialize(
    "fb2","\uf0ed",3)
        
    Activity.AddView(fb2,110dip,0dip,100dip,100dip)
        fb2.BackgroundColor = 
    Colors.Red
        fb2.BorderColor = 
    Colors.Yellow
        fb2.BorderWidth = 
    1dip
        fb2.Text = 
    "Cloud"
        fb2.Tag = 
    "2"
       
    .................
     
    'For manage the click event
     
    Sub fb1_Click
    Log(fb1.Tag)
    End Sub
    Sub fb2_Click
    Log(fb2.Tag)
    End Sub
    That all.
    Thank you DonManfred for this great library.
    Tomorrow you shall have my contribution ( donate ) to your work.
    Bye
    Marco
     
  13. DonManfred

    DonManfred Expert Licensed User

    I have updated the lib (Post #1)
    In the Initialize you now have an additional Parameter "AllowDismiss" true/false
    When set to true the button will become a "SwipeToDismiss-Feature"

    Additional i have extended the Exmple showing how to use the new Versions of the Event-subs.

    Code:
    Sub fb_ondismiss(v As Object, Tag As Object)
        
    Log($"fb_ondismiss"$)
        
    Log("token: "&Tag)
        
    If v Is FancyBtn Then
            
    Dim fb As FancyBtn = v
            
    Log("fbtag: "&fb.Tag)
        
    End If
        
    'fb.Text = "X"
       
    End Sub

    Sub fb_Click(v As Object, Tag As Object)
        
    Log($"fb_Click"$)
        
    If v Is FancyBtn Then
            
    Dim fb As FancyBtn = v
            fb.Text = 
    "Clicked"
        
    End If
    End Sub
    Sub fb_LongClick(v As Object, Tag As Object)
        
    Log($"fb_LongClick"$)
        
    If v Is FancyBtn Then
            
    Dim fb As FancyBtn = v
            fb.Text = 
    "LongClicked"
        
    End If
    End Sub
     
    MarcoRome and ellpopeb4a like this.
  14. MarcoRome

    MarcoRome Expert Licensed User

    Hi DonManfred, all work fine.
    A suggestion if i can. In the property can you add also "Pressed Drawable Color" so when user press button change color.
    Marco
     
  15. DonManfred

    DonManfred Expert Licensed User

    i must check this first if that is possible
     
    MarcoRome likes this.
  16. DonManfred

    DonManfred Expert Licensed User

    There is no such property in this view. You can for sure change the buttons color (or set another 9patch-drawable) when you press the button. But this is not really a "pressed-state"...

    What you can do:
    DONT use SwipeToDismiss to get the OnTouch event raise in your app... On Motion.Down you set the pressed color on this button and on Motion.Up you set back the old color...

    BUT: I need to extend the lib to raise an event for onTouch (it´s actually not exposed/biuiltin in library) instead of the SwipetoDismiss event.
     
    MarcoRome likes this.
  17. tdocs2

    tdocs2 Well-Known Member Licensed User

    Hello, Don, and thank you for this lib.

    I am trying it out, but I get this error:

    Code:
    B4A version 4.30
    Parsing code.                           
    0.00
    Compiling code.                         
    0.02
       
    ObfuscatorMap.txt 
    file created in Objects folder.
    Compiling layouts code.                 
    0.02
    Generating R 
    file.                      0.05
    Compiling generated Java code.          Error
    B4A line: 
    37
    fb1.Initialize(\
    javac 
    1.7.0_51
    src\b4a\example\main.java:
    330: error: method Initialize in class FancyBtn cannot be applied to given types;
    mostCurrent._v5.Initialize(processBA,
    "fb","\\uf082",(int) (0),(Object)(1),anywheresoftware.b4a.keywords.Common.True);
                   ^
      required: BA,
    String,String,int
      found: BA,
    String,String,int,Object,boolean
      reason: actual 
    and formal argument lists differ in length
    1 error
     
  18. DonManfred

    DonManfred Expert Licensed User

    have you tried it without obfuscation? Just a thought and dont know whether this is relevant.
    The method you are calling (maybe initialize?) needs 3 parameters but you are giving 5 parameters.
     
  19. DonManfred

    DonManfred Expert Licensed User

    Which version (Libraries-Tab) are you using? 1.0 or 1.0.3?
    Make sure you downloaded libFancyButtonV1.0.3.zip from #1
     
  20. MarcoRome

    MarcoRome Expert Licensed User

    I using the Library without problem (i compile in obfuscation mode without problem)... maybe is "old" library.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice