B4A Library [B4X] [XUI] AS Settings

Mashiane

Expert
Licensed User
Longtime User
make this reusable to display different properties depending on choices
Can I please clarify..

For example, assuming that you have these properties...



I'd like to use the same settings component but clear and replace these with some other options. The clearing will remove all the displayed settings and I am able to add others

As an example, my "AS Settings" component is named propbag. So I want to reuse it on button click like.

B4X:
Sub PageSettings
    AS_Properties.DeleteAllProperties
    propbag.AddGroup("Basic","Basic Settings")
    propbag.AddProperty_Text("Basic", "pagename", "Page Name", "", Null, "Page 1", 100dip, propbag.InputType_Text)
    propbag.AddProperty_Boolean("Basic","PropertyName_1","Boolean Property True","Description Test Text",Null,True)
End Sub

This will display a text box with boolean only.

B4X:
Sub ComponentSettings
    AS_Properties.DeleteAllProperties
    propbag.AddGroup("Basic","Basic Settings")
    propbag.AddProperty_Text("Basic", "componentname", "Component Name", "" , Null, "Test", 100dip, propbag.InputType_Text)
End Sub

I hope you understand, can I do that with this?
 

Alexander Stolte

Expert
Licensed User
Longtime User
I hope you understand
No I do not.
You need to call AS_Settings1.Create if you want to build the list new.
This property clears the customlistview and builds the view new with the properties you add with e.g. propbag.AddProperty_Boolean.

For further questions it would be useful to make a separate thread. Here no one will find an answer if he uses the search.
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.03
    • AS_Settings
      • Add ResetGroups - Removes the groups, so that you can fill the view with new groups, without the groups that were previously visible
Example
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.05
    • AS_Settings
      • B4J Focused TextField at start bugfix
      • Add SetProperty_Boolean - Sets the value of a property as if the user had clicked the switch
        • The _ValueChanged event is triggered
      • Add GetProperty - Gets the property object
SetProperty_Boolean
In the following example, PropertyName_2 and PropertyName_3 are set to the same value as PropertyName_1. e.g. PropertyName_2 and PropertyName_3 are dependent on PropertyName_1, if PropertyName_1 = False then the other 2 should also be False.
B4X:
Private Sub AS_Settings1_ValueChanged(Property As ASSettings_Property, Value As Object)
    Select Property.PropertyName
        Case "PropertyName_1"
            AS_Settings1.SetProperty_Boolean("PropertyName_2",Value)
            AS_Settings1.SetProperty_Boolean("PropertyName_3",Value)
        Case Else
            Log("PropertyName: " & Property.PropertyName & " Value: " & Value)
    End Select
End Sub

GetProperty
The object property has a new variable called "view". It contains the view with which the user interacts. e.g. for a boolean it is the B4XSwitch, for a text it is the TextField.

In the following example, I deactivate PropertyName_2 and PropertyName_3 whenever PropertyName_1 is not True.
B4X:
Private Sub AS_Settings1_ValueChanged(Property As ASSettings_Property, Value As Object)
    Select Property.PropertyName
        Case "PropertyName_1"
            AS_Settings1.GetProperty("PropertyName_2").View.As(B4XSwitch).Enabled = Value
            AS_Settings1.GetProperty("PropertyName_3").View.As(B4XSwitch).Enabled = Value
        Case Else
            Log("PropertyName: " & Property.PropertyName & " Value: " & Value)
    End Select
End Sub


I have opened 2 new example threads so that the whole thing is not forgotten:
 
Last edited:

AnandGupta

Expert
Licensed User
Longtime User
In the following example, PropertyName_2 and PropertyName_3 are set to the same value as PropertyName_1. e.g. PropertyName_2 and PropertyName_3 are dependent on PropertyName_1, if PropertyName_1 = False then the other 2 should also be False.
This is what many many members were asking for in Preference Dialog. Now all of them will thank you for fulfilling there wish.
 

Alexander Stolte

Expert
Licensed User
Longtime User
The next version is a huge update, with a complete rewrite of the most logic and handling.

One of the new features is paging, you can create as many pages as you want, to show sub, sub, sub settings and options.
You can get a small insight in the following video. In the video you can see a 2nd new feature.


The backend has not been touched, all your saved settings are untouched.
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 2.00
    • AS_Settings
      • Add AddSpaceItem
      • Add AddDescriptionItem
      • Add multi page support
      • Events should be added again, as all type names have changed
AddDescriptionItem


AddSpaceItem
Is a space item without content, you can set a custom height
Multi page support
Multipage support is a important feature, it allows you to outsource settings to a second page.
As there are too many different designs for headers, I opted for the bottom sheet version.

Breaking changes
The complete library has been rewritten, most commands need a .MainPage in front of them. Just have a look at the example projects, they are all up to date.
 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 2.01
    • AS_SettingsPage
      • Add AddProperty_SelectionList - You can create single choice or multiple choice options
        • MultiSelect - If true more than one item can selected. If false only one item is selected if you click, it deselect the previous item
        • CanDeselectAll - If false, then the last item cannot be deselected, it need min one selected
    • AS_Settings
      • Add Designer Property SelectionItemSelectionColor - Color of the selection indicator
        • Default: White
      • Add Type AS_Settings_Property_SelectionList
      • Add Type AS_Settings_SelectionListItem
      • Add CreateSelectionListItem - Needed to build the items
AddProperty_SelectionList

New tutorial:
 

lordjuergen

Member
Licensed User
Longtime User
How can I change the PropertyColor as the "PropertyColor" changes the background color. The property textcolor is always white and I don't find the way to change this.
 

Alexander Stolte

Expert
Licensed User
Longtime User
There are an option - as the ASScheduler_Theme - to change the theme to a light mode?
Currently not yet. I've put it on the to-do list

The property textcolor is always white and I don't find the way to change this.
B4X:
AS_Settings1.PropertyProperties.TextColor = xui.Color_Red
A few color things are still hardcoded, but should be fixed when I have finished the function to switch from dark to light
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 2.02
    • AS_SettingsPage
      • Added seperators to the SelectionList property
      • The ValueChanged event works now with the SelectionList Property
      • The .Refresh function is now smooth
      • BugFixes on the PropertyName height and Description height
 

Sergio Haurat

Active Member
Licensed User
Longtime User
Hello @Alexander Stolte, I am trying to integrate this library into my project and I am encountering the following problem:

My code:
B4X:
Sub Class_Globals
  Private appSettings As AS_Settings
End Sub

Private Sub B4XPage_Appear
  appSettings.MainPage.AddGroup("set_fed_club", mdlFunctions.loc.Localize("settings_short"))
  appSettings.MainPage.AddProperty_Action("set_fed_club", "set_fed", mdlFunctions.loc.Localize("fed_desc"), mdlFunctions.loc.Localize("fed"), Null, 0)
  appSettings.MainPage.AddProperty_Action("set_fed_club", "set_club", mdlFunctions.loc.Localize("club_desc"), mdlFunctions.loc.Localize("club"), Null, 0)
    
  appSettings.MainPage.AddGroup("set_adv", mdlFunctions.loc.Localize("set_advance"))
  appSettings.MainPage.AddProperty_Boolean("set_adv", "connectTo", "Boolean Value", "Boolean description", Null, True)

  appSettings.MainPage.BottomText = mdlFunctions.loc.Localize("settings_desc")
  appSettings.MainPage.Create
End Sub

The lines 7 and 8 with "AddProperty_Action" show me this "java.lang"


Line 11 with AddProperty_Boolean, if I don't comment it, it stops the application and generates the following error


The example app doesn't have this problem. I have reviewed the code many times and I cannot solve it. What do you suggest me ?
 

Alexander Stolte

Expert
Licensed User
Longtime User
Hello @Alexander Stolte, I am trying to integrate this library into my project and I am encountering the following problem:
Please provide an example project what shows the error and please make a new thread for questions. Thanks
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 2.03
    • AS_Settings
      • BugFixes and Improvemets
      • Add CreateList - Creates an list with just one line of code
      • Add Designer Property PropertyTextColor
      • Add set Theme
      • Add get Theme_Dark
      • Add get Theme_Light
      • Add Designer Property ThemeChangeTransition
        • Default: Fade

Just one line of code to change the theme
B4X:
Private Sub Switch1_ValueChanged (Value As Boolean)
    If Value Then
        AS_Settings1.Theme = AS_Settings1.Theme_Dark
    Else
        AS_Settings1.Theme = AS_Settings1.Theme_Light
    End If
End Sub
 

Blueforcer

Well-Known Member
Licensed User
Longtime User
Hey Alexander,
the example project works great. but as soon as i use it in my app in debug mode i get this error:


B4X:
B4A line: 41
isMainPage = Settings.Pages.NumberOfViews = 0
shell\src\de\dinotec\netplus\as_settingspage_subs_0.java:3125: error: cannot find symbol
__ref.setField ("_ismainpage" /*RemoteObject*/ ,BA.ObjectToBoolean(RemoteObject.solveBoolean("=",as_settingspage._settings.runClassMethod (de.dinotec.netplus.as_settings.class, "_getpages" /*RemoteObject*/ ).runMethod(true,"getNumberOfViews"),BA.numberCast(double.class, 0))));
                                                                                                                          ^
  symbol:   method runClassMethod(Class<as_settings>,String)
  location: variable _settings of type settings
1 error

It works in release mode.

currently i just instantiate it with
Private AS_Settings1 As AS_Settings
nothing else and it still crash while compiling.

any idea whats the cause of this?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…