B4A Library AHPreferenceActivity Library

This Library is based on Erels PreferenceActivity Library and adds some hopefully useful things:

  • Checkbox entry can show On and Off summary
  • Dependencies to other entries
  • Another Listview type with Map as value/displayvalue pairs
  • AddPassword() for password entries
  • AddRingtone() for selecting notification, ringtone or alert sound

V1.01:
  • Bugfix for FC with nested PreferencesScreens
  • Added support for calling Intents (other activities)
  • Preferencescreens support dependency

V1.02:
  • Bugfix for GetUpdatedKeys not working sometimes (thanks, Erel)

V1.03:
  • Never published

V1.04:
  • Added AddEditText2() method with support for InputType and some other properties
  • !!! Changed package name to "de.amberhome.objects" !!! Change in your Manifest!

For a tutorial see PreferenceActivity Tutorial
 

Attachments

  • AHPreferenceActivityExample.zip
    6.6 KB · Views: 2,093
  • AHPreferenceActivity1_02.zip
    21.4 KB · Views: 2,003
  • AHPreferenceActivity1_04.zip
    22.1 KB · Views: 2,573
  • AHPreferenceActivityExample1_04.zip
    7.1 KB · Views: 2,010
Last edited:
D

Deleted member 103

Guest
Danke Markus!

Kann ich gut brauchen.:)
Ich habe schon die Library "PreferenceActivity" mit deine ausgetauscht.

:sign0098:
 

bluedude

Well-Known Member
Licensed User
Longtime User
corwin,

Awesome. Would it be possible to add support for the GPS settings? I would love to be able to call the internal GPS settings from the Preferences Library.

Cheers,
 

hbruno

Member
Licensed User
Longtime User
Another support ?

Thanks Markus.
Is it possible to add B4A Dialogs like inputlist, inputmultilist, colordialog, colorpickerdialog, datedialog and timedialog ?
I know, it's enormeous, but currently, i made a clock and in my preferenceactivity, i can't specify a time to wake up...
 

corwin42

Expert
Licensed User
Longtime User
Thanks Markus.
Is it possible to add B4A Dialogs like inputlist, inputmultilist, colordialog, colorpickerdialog, datedialog and timedialog ?
I know, it's enormeous, but currently, i made a clock and in my preferenceactivity, i can't specify a time to wake up...

Yes, something like that would be possible. There is an DialogPreference Class which can add dialogs to a Preference Screen. But I will have to look closer into this and perhaps I will have to ask agraham to copy some code from his dialogs library.
 

corwin42

Expert
Licensed User
Longtime User
Awesome. Would it be possible to add support for the GPS settings? I would love to be able to call the internal GPS settings from the Preferences Library.

I think that should be possible because I have seen some apps using such a feature but currently I don't know how to do it.
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
Would it be possible to let it raise events from a service? That way we can have buttons?
 

bluedude

Well-Known Member
Licensed User
Longtime User
corwin,

In B4A you call the GPS settings like this:

StartActivity(gpsMain.LocationSettingsIntent) 'Will open the relevant settings screen.

Where gpsMain is the GPS library.

Not sure why it should be more difficult than the ringtone stuff.

I really like the Preference library but because it does not support all features I still need to provide several setting solutions in my apps. Like calling the default GPS settings etc.

So in the end it does not solve the problem of app. builders.

It would be great if it could support:

- Dialogs;
- Calling other settings;
- GPS settings;

etc.

Cheers,
 

schimanski

Well-Known Member
Licensed User
Longtime User
Hello, thanks for the new features, it's very usefull for me.

But I have a problem with the following code and can't find the mistake. My app will always be closed in the line 'DisplayCat1.AddPreferenceScreen(DesignScreen)'. There is no error in the log.:confused:


B4X:
Sub Globals
  Dim DisplayManager, DesignManager As AHPreferenceManager
  Dim DisplayScreen, DesignScreen As AHPreferenceScreen
end sub

Sub CreatePreferenceScreen
  DisplayScreen.Initialize("Display","")
  Dim DisplayCat1 As AHPreferenceCategory
  DisplayCat1.Initialize("Einstellungen Display")
   
  DesignScreen.Initialize("Design","Hintergrund ändern")
  DesignScreen.AddCheckBox("CheckBoxKlassisch", "Klassisch", "", "", True, "")
  DesignScreen.AddCheckBox("CheckBoxErde", "Erde", "", "", False, "")
  DisplayCat1.AddPreferenceScreen(DesignScreen)

  DisplayCat1.AddCheckBox("CheckBoxAusrichtung", "Ausrichtung", "Auto", "Fest", True, "")
  DisplayScreen.AddPreferenceCategory(DisplayCat1)
end sub

Thanks for help
 

corwin42

Expert
Licensed User
Longtime User
In B4A you call the GPS settings like this:

StartActivity(gpsMain.LocationSettingsIntent) 'Will open the relevant settings screen.

Where gpsMain is the GPS library.

Not sure why it should be more difficult than the ringtone stuff.

The ringtone chooser is a standard preference class. For calling Intents I have to implement a custom preference class. But this is not very hard so I think I can support it in the future.

It would be great if it could support:

- Dialogs;
- Calling other settings;
- GPS settings;

For dialogs the best thing would be to pass a dialog from the dialogs library to a AddDialog() method. I don't know, if this will be possible. I have to look into it.

But I have a problem with the following code and can't find the mistake. My app will always be closed in the line 'DisplayCat1.AddPreferenceScreen(DesignScreen)'. There is no error in the log.:confused:

Even no log output in the unfiltered log?
 

schimanski

Well-Known Member
Licensed User
Longtime User
Hello corwin42!

This is what I get with unfiltered log:
 

Attachments

  • Exception AHPreference.txt
    3.1 KB · Views: 510

corwin42

Expert
Licensed User
Longtime User
This is what I get with unfiltered log:

Ok, found the bug.

The error occurs because I don't handle the dependencies for subscreens correctly. Dependencies are a bit tricky in the library and I have to set them AFTER all the preference screen structure is created and initialized. I added special handling for categories but not for screens.

I'm currently just testing some other things and then will release the new version.
 

schimanski

Well-Known Member
Licensed User
Longtime User
Hello corwin42!

I have tried to make my app with your AHPreference-Lib. But I have to much events in my menues. Is it not possible to make an easy click-event as Preference-Item, after it is possible to call another activity or a simple Messagebox?

Thenks for your efforts...
 

corwin42

Expert
Licensed User
Longtime User
Events would be very hard and ugly to implement because you would need a service to handle them. I think the best would be if Erel adds direct support for PreferenceActivities to the B4A IDE with a new module type.

In the first post is a new version (1.01) with the bug fixed that you mentioned and the possibility to call simple Intents.

I will have a look into dialogs now so it would be possible to set dates and times in preferences.
 

schimanski

Well-Known Member
Licensed User
Longtime User
Jo, danke Markus!

Hab' gar nicht gesehen, dass Du den Bug schon behoben hattest.

Gruß
 

Cody04l

Member
Licensed User
Longtime User
I will have a look into dialogs now so it would be possible to set dates and times in preferences.

Corwin42 thank you for this library. I'd like to know if you've found anything in regards to adding a dialog for dates and time within the a preferenceactivity?

Thanks,
Cody
 

Cody04l

Member
Licensed User
Longtime User
Understand. I look forward to being able to use that. Appreciate all the work you do with the libraries here.

Cody

Sent from my SGH-T989 using Tapatalk
 
Top