B4A Library Iconify (Button, Label, Togglebutton, Toast with IconFont Icons)

This is a wrap for this Github Project: Iconify2
It is basically the same as my wrap for the IconicFontEngine but it has some cool advantages.

More exactly this wrap is a mix out of Iconify2 and PrettyToast in one Library.

Note that you need B4A 6+ to use the Library as the provided custom views used the new CustomViewProperties. Additional the lib now uses maven artifacts.

androids.png


Installation: Download the library and the two fonts-archive. Extract all files to your Additional libs folder.
1st zip: jar and xml of the lib.
2nd and 3rd zip. the fonts.

Iconify
Author:
DonManfred (wrapper)
Version: 2.22
  • EntypoModule
    Methods:
    • Initialize
    • IsInitialized As Boolean
    Properties:
    • Characters As Map [read only]
  • FontAwesomeModule
    Methods:
    • Initialize
    • IsInitialized As Boolean
    Properties:
    • Characters As Map [read only]
  • IconButton
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • Tag As Object
    • Text As CharSequence [write only]
    • TextColor As Int [write only]
    • TextSize As Int [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int
  • IconDrawable
    Methods:
    • Initialize (icf As Iconify, icon As String) As IconDrawableWrapper
    • IsInitialized As Boolean
    • actionBarSize As IconDrawableWrapper
      Set the size of this icon to the standard Android ActionBar.
      Return type: @return:The current IconDrawable for chaining.
    • alpha (alpha As Int) As IconDrawableWrapper
      Set the alpha of this drawable.
      alpha: The alpha, between 0 (transparent) and 255 (opaque).
      Return type: @return:The current IconDrawable for chaining.
    • color (color As Int) As IconDrawableWrapper
      Set the color of the drawable.
      color: The color, usually from android.graphics.Color or 0xFF012345.
      Return type: @return:The current IconDrawable for chaining.
    • setState (stateSet() As Int) As Boolean
    • size (size As Int) As IconDrawableWrapper
      Set the size of the drawable.
      size: The size in density-independent pixels (dp).
      Return type: @return:The current IconDrawable for chaining.
  • IconTextView
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • Tag As Object
    • Text As CharSequence [write only]
    • TextColor As Int [write only]
    • TextSize As Int [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int
  • IconToggleButton
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • Tag As Object
    • Text As CharSequence [write only]
    • TextColor As Int [write only]
    • TextOff As CharSequence [write only]
    • TextOn As CharSequence [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int
  • Iconify
    Methods:
    • Initialize
    • IsInitialized As Boolean
    • addIcons (textViews() As TextView)
      Replace "{}" tags in the given text views with actual icons, requesting the IconFontDescriptors
      one after the others.<p>
      <strong>This is a one time call.</strong> If you call {@link TextView#setText(CharSequence)} after this,
      you'll need to call it again.
      textViews: The TextView(s) to enhance.
    • with (iconFontDescriptor As IconFontDescriptor) As IconifyInitializer
      Add support for a new icon font.
      iconFontDescriptor: The IconDescriptor holding the ttf file reference and its mappings.
      Return type: @return:An initializer instance for chain calls.
  • IoniconsModule
    Methods:
    • Initialize
    • IsInitialized As Boolean
    Properties:
    • Characters As Map [read only]
  • MaterialCommunityModule
    Methods:
    • Initialize
    • IsInitialized As Boolean
    Properties:
    • Characters As Map [read only]
  • MaterialModule
    Methods:
    • Initialize
    • IsInitialized As Boolean
    Properties:
    • Characters As Map [read only]
  • MeteoconsModule
    Methods:
    • Initialize
    • IsInitialized As Boolean
    Properties:
    • Characters As Map [read only]
  • PrettyToast
    Methods:
    • Initialize
    • IsInitialized As Boolean
    • showDim (msg As String)
    • showDim2 (msg As String, leftIcon As String)
    • showDim3 (msg As String, leftIcon As String, rightIcon As String)
    • showDim4 (msg As String, leftIcon As String, rightIcon As String, duration As Int)
    • showError (msg As String)
    • showError2 (msg As String, leftIcon As String)
    • showError3 (msg As String, leftIcon As String, rightIcon As String)
    • showError4 (msg As String, leftIcon As String, rightIcon As String, duration As Int)
    • showInfo (msg As String)
    • showInfo2 (msg As String, leftIcon As String)
    • showInfo3 (msg As String, leftIcon As String, rightIcon As String)
    • showInfo4 (msg As String, leftIcon As String, rightIcon As String, duration As Int)
    • showSuccess (msg As String)
    • showSuccess2 (msg As String, leftIcon As String)
    • showSuccess3 (msg As String, leftIcon As String, rightIcon As String)
    • showSuccess4 (msg As String, leftIcon As String, rightIcon As String, duration As Int)
    • showWarning (msg As String)
    • showWarning2 (msg As String, leftIcon As String)
    • showWarning3 (msg As String, leftIcon As String, rightIcon As String)
    • showWarning4 (msg As String, leftIcon As String, rightIcon As String, duration As Int)
    Properties:
    • Gravity As Gravity [write only]
    • Text As String [write only]
  • PrettyToastBuilder
    Methods:
    • Initialize As PrettyToastBuilderWrapper
    • IsInitialized As Boolean
    • build As PrettyToast
    • withGravity (gravity As Gravity) As PrettyToastBuilderWrapper
  • SimpleLineIconsModule
    Methods:
    • Initialize
    • IsInitialized As Boolean
    Properties:
    • Characters As Map [read only]
  • ToastGravity
    Methods:
    • Initialize (gravity As Int, XOffset As Int, YOffset As Int)
    • IsInitialized As Boolean
    Properties:
    • Gravity As Int
    • XOffset As Int
    • YOffset As Int
  • TypiconsModule
    Methods:
    • Initialize
    • IsInitialized As Boolean
    Properties:
    • Characters As Map [read only]
  • WeathericonsModule
    Methods:
    • Initialize
    • IsInitialized As Boolean
    Properties:
    • Characters As Map [read only]


Sample Code
B4X:
    IconButton1.Text = "I {fa-heart-o 200% #ff0000} to {fa-code} on {fa-android 400% spin #ccddaa}"
    IconTextView1.Text = "I {fa-heart-o spin 32dp #ff0000} to {fa-code} on {fa-android 400% #ccddaa}"
    IconToggleButton1.Text = "{ion-social-github 675% #00cc00}"

Iconify.png




If you want to donate for my work building the wrapper you can do it here:
 

Attachments

  • spinning.gif
    spinning.gif
    411.8 KB · Views: 335
  • IconifyEx.zip
    23.9 KB · Views: 413
  • libIconifyV1.0.0.zip
    198 KB · Views: 301
  • IconifyV1.1.zip
    199.7 KB · Views: 200
  • IconifyV1.11.zip
    199.8 KB · Views: 196
  • IconifyV2.22.zip
    44.8 KB · Views: 342
  • IconifyFonts1.zip
    372 KB · Views: 294
  • IconifyFonts2.zip
    326.1 KB · Views: 334
Last edited:

Bel

Member
Licensed User
@DonManfred
Thanks for sharing

B4X:
B4A version: 5.80
Parsing code.    (0.01s)
Compiling code.    (0.90s)
Compiling layouts code.    (0.00s)
Generating R file.    Error
..\resources\layout\toast_custom.xml:8: error: Error: No resource found that matches the given name (at 'src' with value '@drawable/ukraine_flag').
 

Bel

Member
Licensed User
@DonManfred
tnx.Solved

But....

B4X:
main_activity_create (java line: 385)
java.lang.RuntimeException: java.lang.RuntimeException: Font asset not found iconify/android-iconify-fontawesome.ttf
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:208)
    at b4a.example.iconify.main._activity_create(main.java:385)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at b4a.example.iconify.main.afterFirstLayout(main.java:102)
    at b4a.example.iconify.main.access$000(main.java:17)
    at b4a.example.iconify.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6856)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.RuntimeException: Font asset not found iconify/android-iconify-fontawesome.ttf
    at android.graphics.Typeface.createFromAsset(Typeface.java:274)
    at com.joanzapata.iconify.internal.IconFontDescriptorWrapper.getTypeface(IconFontDescriptorWrapper.java:41)
    at com.joanzapata.iconify.internal.ParsingUtil.recursivePrepareSpannableIndexes(ParsingUtil.java:181)
    at com.joanzapata.iconify.internal.ParsingUtil.parse(ParsingUtil.java:37)
    at com.joanzapata.iconify.Iconify.compute(Iconify.java:59)
    at com.joanzapata.iconify.widget.IconButton.setText(IconButton.java:34)
    at android.widget.TextView.setText(TextView.java:4670)
    at de.donmanfred.IconButtonWrapper.DesignerCreateView(IconButtonWrapper.java:44)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:70)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
    ... 16 more
 

prajinpraveen

Active Member
Licensed User
excellent library, many thanks.

is there is way to update the fonts. I tried updating the fontawesome font file to 4.6 . Doesnot use the latest fonts eg: fa-blind

how do we use other font libraries such as Meteocons and Material Design Fonts.
 

DonManfred

Expert
Licensed User
how do we use other font libraries such as Meteocons and Material Design Fonts.
See the objects in the lib.

Something like
B4X:
dim meteo as MeteoconsModule
meteo.initialize
iconify.with(meteo)

is there is way to update the fonts.
The lib behind needs to be updated to the newer font first. then i can update the wrapper... But the lib at github ist 4.5...
 

prajinpraveen

Active Member
Licensed User
Thanks for the quick response.

B4X:
i have added this
dim meteo as MeteoconsModule
meteo.initialize
iconify.with(meteo)

I need to know how to add text in the button. with fontawesome it is "fa-facebook"
fontawesome 4.6 released
 

prajinpraveen

Active Member
Licensed User
thanks i will. i see you have added the wrapper already in this library for fonts such as MeteoconsModule, Weathericons.
what we need is how to call the fonts :)
 

DonManfred

Expert
Licensed User
Maybe i forgot something to wrap
yes i did ;)

I´ve updated the library respectively the fonts to have a method to get all characters.
B4X:
    Log(Meteocons.Characters)

See updated library V1.1 in post #1
 
Top