B4A Library ColorPicker

Status
Not open for further replies.
A nice ColorPicker that wraps this Github project. Posting the following:
1. B4A Sample project
2. B4A Library files - copy them to your additional library folder.

You will also need android-support-v4.jar and android-support-v7-appcompat.jar in your additional library folder.

Take note of the following in the B4A project and set your own path accordingly:
B4X:
#AdditionalRes: C:\Android\extras\android\support\v7\appcompat\res, android.support.v7.appcompat

Also take note of the files in the B4A project's /Objects/res/blabla folders. Make sure these files are set to READ ONLY.

You also need to download / enable AppCompat V2.00 (by @corwin42 - it is somewhere on the forum)

The lib raises two events in B4A
1. The color selected (as an Int and as a hex string)
2. When cancel is pressed on the dialog

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aColorPicker
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

'#AdditionalRes: ..\resource

#AdditionalRes: C:\Android\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\google\google-play-services\libproject\google-play-services_lib\res, com.google.android.gms
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design

'#ExcludeClasses: .games, .drive, .ads, .fitness, .wearable, .measurement, .cast, .auth, .nearby
'#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .gcm, .maps, .panorama

#Extends: android.support.v7.app.AppCompatActivity

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
   
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Button1 As Button
    Dim cp As ColorPicker
    Private Panel1 As Panel
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
   
    Activity.LoadLayout("main")
    cp.Initialize("cp")
   
    Panel1.Color = Colors.Transparent
   
End Sub

Sub Activity_Resume
   

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click

    cp.StartPicker

End Sub

Sub cp_selected_color(mycolor As Int, hexcolor As String)
   
    Panel1.Color = mycolor
    Log("Hex Color = " & hexcolor)
   
End Sub

Sub cp_selection_cancelled
   
    Log("SELECTION WAS CANCELLED")
   
End Sub

Library:
ColorPicker
Author:
Github: QuadFlask, Wrapped by: Johan Schoeman
Version: 1
  • ColorPicker
    Events:
    • selected_color (selectedcolor As Int, hexcolor As String)
    • selection_cancelled
    Methods:
    • Initialize (paramString As String)
    • StartPicker

1.png



2.png


3.png


4.png


5.png
 

Attachments

  • b4aColorPicker.zip
    11.3 KB · Views: 282
  • ColorPickerLibFiles.zip
    47.8 KB · Views: 298

DonManfred

Expert
Licensed User
Longtime User
No like from me.

AppCompat is V3,x the newest! Why using V2.0????? No need for #additionalRes with newest appcompat version!
Additional no need for a android-support-v4.jar in additional libs!

Android has changed the system. Why should anyone use an old (out-of-date) support-v4-jar?

You are going backwards....
 

Johan Schoeman

Expert
Licensed User
Longtime User
No like from me.

AppCompat is V3,x the newest! Why using V2.0????? No need for #additionalRes with newest appcompat version!
Additional no need for a android-support-v4.jar in additional libs!

Android has changed the system. Why should anyone use an old (out-of-date) support-v4-jar?

You are going backwards....
It still works...and I guess also accommodates older versions of B4A (older than V6.00)

But if you want to use it in B4A V6.00 then just make sure all the below is commented in the B4A project:
B4X:
'#AdditionalRes: ..\resource

'#AdditionalRes: C:\Android\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\google\google-play-services\libproject\google-play-services_lib\res, com.google.android.gms
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design

'#ExcludeClasses: .games, .drive, .ads, .fitness, .wearable, .measurement, .cast, .auth, .nearby
'#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .gcm, .maps, .panorama

'#Extends: android.support.v7.app.AppCompatActivity

...and in stead of AppCompat V2.00 you should enable AppCompat V3.20

And a LIKE is not important at all. If you don't LIKE it then all that you have to do is not to click on LIKE, ignore the posting, and move on with life.
 
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
Here is an update - missed some stuff on the previous version. This will allow you to set the text of the title as well as that of the OK and Cancel buttons. You can also choose between Circle or Flower as the color picker view

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aColorPicker
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

'#AdditionalRes: ..\resource

#AdditionalRes: C:\Android\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\google\google-play-services\libproject\google-play-services_lib\res, com.google.android.gms
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design

'#ExcludeClasses: .games, .drive, .ads, .fitness, .wearable, .measurement, .cast, .auth, .nearby
'#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .gcm, .maps, .panorama

#Extends: android.support.v7.app.AppCompatActivity

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
 
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Button1 As Button
    Dim cp As ColorPicker
    Private Panel1 As Panel
 
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
 
    Activity.LoadLayout("main")
    cp.Initialize("cp")
 
    Panel1.Color = Colors.Transparent
    cp.DialogTitle = "Select a Color"
    cp.PositiveButtonText = "Gotcha!"
    cp.CancelButtonText = "Oh no man!"
    cp.ColorPickerWheelType = cp.WHEEL_TYPE_CIRCLE             'or cp.cp.ColorPickerWheelType = cp.WHEEL_TYPE_FLOWER
 
End Sub

Sub Activity_Resume
 

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click

    cp.StartPicker

End Sub

Sub cp_selected_color(mycolor As Int, hexcolor As String)
 
    Panel1.Color = mycolor
    Log("Hex Color = " & hexcolor)
 
End Sub

Sub cp_selection_cancelled
 
    Log("SELECTION WAS CANCELLED")
 
End Sub

Library
ColorPicker
Author:
Github: QuadFlask, Wrapped by: Johan Schoeman
Version: 1
  • ColorPicker
    Events:
    • selected_color (selectedcolor As Int, hexcolor As String)
    • selection_cancelled
    Fields:
    • WHEEL_TYPE_CIRCLE As Int
    • WHEEL_TYPE_FLOWER As Int
    Methods:
    • Initialize (paramString As String)
    • StartPicker
    Properties:
    • CancelButtonText As String [write only]
    • ColorPickerWheelType As Int [write only]
    • DialogTitle As String [write only]
    • PositiveButtonText As String [write only]


As a CIRCLE (the pic in post#1 is of type FLOWER)
6.png
 

Attachments

  • b4aColorPicker.zip
    11.4 KB · Views: 183
  • ColorPickerLibFiles.zip
    48.2 KB · Views: 190
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
No like from me.

AppCompat is V3,x the newest! Why using V2.0????? No need for #additionalRes with newest appcompat version!
Additional no need for a android-support-v4.jar in additional libs!

Android has changed the system. Why should anyone use an old (out-of-date) support-v4-jar?

You are going backwards....
Manfred, you have assisted me to finally take the decision to stop having anything to do with the B4A forum - it will free up a lot of time to do other things that are far more important in life. I am done with posting anything further on the forum - I will rather do wrappers for the challenge that it presents for me personally than to do it and post it on the forum and having it subjected to such negative commentary by you.
 

LucaMs

Expert
Licensed User
Longtime User
Manfred, you have assisted me to finally take the decision to stop having anything to do with the B4A forum
Bad motivation.

On the other hand, there are no valid reasons to leave the Forum :)


In addition, all members of the Forum appreciate your work.

Most likely I will use one of your libraries (I will inform you properly!).
 

LucaMs

Expert
Licensed User
Longtime User
another forum member... who stated that I did not contribute enough
Someone else said my 10,000 posts are only spam (and this surprised me, since I have never written anything against this person) but does it matter? None ;)
 

inakigarm

Well-Known Member
Licensed User
Longtime User
Sad to hear this!!! Always waiting for your new wrapped library

I hope you'll reconsider this decision cause I'm sure mostly all users thanks your effort and work time to contribute for B4A development (like other users also do)

Thanks again Johan !
 

LucaMs

Expert
Licensed User
Longtime User
So either you realize that you have upset a number of people, or you have huge blinkers on
... or his "Like" was ironic; or he has read too quickly your post, as I do too often :)
 
Last edited by a moderator:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Johan, all members of the forum, starting with me, appreciate your work and will be more than happy to see you here.

I do agree with DonManfred that it is important to use the new maven based configuration otherwise it will be difficult for most developers to use your libraries, especially with other libraries that use the new system.

Thread is closed.
 
Status
Not open for further replies.
Top