B4A Library ColorPicker

Status
Not open for further replies.

Johan Schoeman

Expert
Licensed User
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

DonManfred

Expert
Licensed 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
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
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

Last edited:

Johan Schoeman

Expert
Licensed 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.
 

Rick Harris

Well-Known Member
Licensed User
Hi Johan,

Don't be discouraged by comments made by Don Manfred. He was rude to me as well for no reason at all and put me on his ignore list (and made a song-and-dance about this publicly in the Forum). He is behaving like an elitist, "I know it all" snob.

Some people seem to think that only experts who can make wrappers based on the latest developments deserve a place in this Forum. They seem to forget that not everyone has (extensive) Java knowlegde and/or developer expertise. Fortunately I started to use B4A nearly four years ago and thus have been (more or less) able to "grow" with B4A and Google's latest development. Nevertheless, it has been held against me by another forum member (one of Don's friends) who stated that I did not contribute enough (despite 600+ contributions), just because I cannot convert anything from Java to B4A.

Nowadays everything has become so much more complicated! I feel very sorry for the poor guys and girls who have only just started to jump on the Android developer's express train. I have noticed that less and less reactions by novices can be found in the B4A Forum. Probably they are too scared to ask. Thank goodness Erel treats everyone the same and is extremely polite, replies in a neutral fashion without any personal reproaches or comments, and is always extremely helpful. Some of the so-called experts in the Forum should take an example from him.
Don Manfred's snooty attitude is truely awful and he deserves a firm slap on his fingers from Erel (in a private posting), especially now that he is trying to scare-away a very valuable contributor to the forum like you.

You are making wonderful contributions to the forum! So what if you are using some older techniques?! It is the result that counts. Please don't stop!
 
Last edited:

LucaMs

Expert
Licensed 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!).
 

inakigarm

Well-Known Member
Licensed 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 !
 

Rick Harris

Well-Known Member
Licensed User
Hi Johan,

Don't be discouraged by comments made by Don Manfred. He was rude to me as well for no reason at all and put me on his ignore list (and made a song-and-dance about this publicly in the Forum). He is behaving like an elitist, "I know it all" snob.

Some people seem to think that only experts who can make wrappers based on the latest developments deserve a place in this Forum. They seem to forget that not everyone has (extensive) Java knowlegde and/or developer expertise. Fortunately I started to use B4A nearly four years ago and thus have been (more or less) able to "grow" with B4A and Google's latest development. Nevertheless, it has been held against me by another forum member (one of Don's friends) who stated that I did not contribute enough (despite 600+ contributions), just because I cannot convert anything from Java to B4A.

Nowadays everything has become so much more complicated! I feel very sorry for the poor guys and girls who have only just started to jump on the Android developer's express train. I have noticed that less and less reactions by novices can be found in the B4A Forum. Probably they are too scared to ask. Thank goodness Erel treats everyone the same and is extremely polite, replies in a neutral fashion without any personal reproaches or comments, and is always extremely helpful. Some of the so-called experts in the Forum should take an example from him.
Don Manfred's snooty attitude is truely awful and he deserves a firm slap on his fingers from Erel (in a private posting), especially now that he is trying to scare-away a very valuable contributor to the forum like you.

You are making wonderful contributions to the forum! So what if you are using some older techniques?! It is the result that counts. Please don't stop!
#DonManfred: I am rather amazed that you have given me a "Like". So either you realize that you have upset a number of people, or you have huge blinkers on. Johan Schuman will probably not return to the forum, thanks to your doings.
How about stepping down from your high horse and apologize to the people who now are very angry at you (?)
 
Last edited:

Erel

Administrator
Staff member
Licensed 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