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,111
  • AHPreferenceActivity1_02.zip
    21.4 KB · Views: 2,018
  • AHPreferenceActivity1_04.zip
    22.1 KB · Views: 2,595
  • AHPreferenceActivityExample1_04.zip
    7.1 KB · Views: 2,029
Last edited:

andrewj

Active Member
Licensed User
Longtime User
Hi,
I'm using the AddList2 method to show a set of choices. Is there any way to show the selected choice as the subtitle on the settings screen after selection?
Thanks
Andrew
 

peacemaker

Expert
Licensed User
Longtime User
HI, no plans to add a user picture selection ?
 

andrewj

Active Member
Licensed User
Longtime User
Hi,
Is there any way to trigger an event when a user either clicks on a certain setting, or when a setting changes? I'd like to trigger some onward processing, but I'd prefer not to have to create a dummy intent with all that entails. One of Erel's posts suggested that this library provides some change events, but I can't see how this works.

Thanks
Andrew
 

corwin42

Expert
Licensed User
Longtime User
Is there any way to trigger an event when a user either clicks on a certain setting, or when a setting changes? I'd like to trigger some onward processing, but I'd prefer not to have to create a dummy intent with all that entails. One of Erel's posts suggested that this library provides some change events, but I can't see how this works.

No, events are not possible.
 

itgirl

Active Member
Licensed User
Longtime User
I'm not 100% sure but i think there's a bug in the new Lib Version 1.04 in setActivity cause firs i downloaded 1.02 and it was working fine but when i downloded 1.04 it stopped working , but still One of the amazing Libs out there amazing work , thanks ;)


P.S i didn't change anything in the code just updated the Lib and it stopped working
 

corwin42

Expert
Licensed User
Longtime User
I'm not 100% sure but i think there's a bug in the new Lib Version 1.04 in setActivity cause firs i downloaded 1.02 and it was working fine but when i downloded 1.04 it stopped working , but still One of the amazing Libs out there amazing work , thanks ;)


P.S i didn't change anything in the code just updated the Lib and it stopped working

See the changelog in first post. The package name was changed to prevent conflicts with other libraries. You have to change it in the manifest of your project, too.
 

itgirl

Active Member
Licensed User
Longtime User
See the changelog in first post. The package name was changed to prevent conflicts with other libraries. You have to change it in the manifest of your project, too.
Thanks for the reply , infact i didn't change it at firs but when i run the app it showed an exception when trying to get into the preference screen and after i saw it i changed the package name and i got into the preference without any errors except the setActivity was not working :(

so i should have wrote in the first post that i changed the package name lol sorry
 

corwin42

Expert
Licensed User
Longtime User
Thanks for the reply , infact i didn't change it at firs but when i run the app it showed an exception when trying to get into the preference screen and after i saw it i changed the package name and i got into the preference without any errors except the setActivity was not working :(

so i should have wrote in the first post that i changed the package name lol sorry

What setActivity are you talking about?
 

schimanski

Well-Known Member
Licensed User
Longtime User
Hello!!

I use the AHPreference-lib to set some passwords. But I have seen, that the dictionary saves the passwords, even though I used 'addpassword'.
I know, that it is possible to prevent this with the following code. Is it possible to combine this with the password-mode of the perference?

B4X:
PasswortFTP.InputType=Bit.OR(PasswortFTP.InputType,0x00000080)

Thanks for help...
 

schimanski

Well-Known Member
Licensed User
Longtime User
O.k, I have found a way with the SLInpTypeConst-Class:

B4X:
Dim InpTyp As SLInpTypeConst
InpTyp.Initialize
Cat_FTP.AddEditText2("PasswortFTP", "Passwort", "Passwort für FTP-Zugang eingeben", "", InpTyp.TYPE_NUMBER_VARIATION_PASSWORD, True, False, "")

Greetings....
 

SCIS

Active Member
Licensed User
Longtime User
Hey, my app crashes when I open the AHPreferenceActivity while the device is in landscape mode, is this a common problem? Is there a fix available?
 

corwin42

Expert
Licensed User
Longtime User
Hey, my app crashes when I open the AHPreferenceActivity while the device is in landscape mode, is this a common problem? Is there a fix available?

Works without problem here.

Do you have a stack trace?
 

corwin42

Expert
Licensed User
Longtime User
Probably not since I don't know what that is :)

The complete error message and a logcat snippet from the error.

No one can guess what "my app crashes" means.
 

SCIS

Active Member
Licensed User
Longtime User
The complete error message and a logcat snippet from the error.

No one can guess what "my app crashes" means.

No actual error message pops up on my phone, only that the app has stopped working.

http://i.gyazo.com/02ca72891bf12dac7d2934658c452aeb.png

First line is
B4X:
java.lang.RuntimeException: Unable to start activity ComponentInfo{b4a.example/de.amberhome.objects.preferenceactivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator java.util.ArrayList.iterator()' on a null object reference

Also, what is the Dependency when creating views in a PreferenceScreen and what should I have there?

Sorry, these are probably all stupid questions, I'm new :/
 

corwin42

Expert
Licensed User
Longtime User
No actual error message pops up on my phone, only that the app has stopped working.

http://i.gyazo.com/02ca72891bf12dac7d2934658c452aeb.png

No actual error message pops up on my phone, only that the app has stopped working.

http://i.gyazo.com/02ca72891bf12dac7d2934658c452aeb.png

First line is
B4X:
java.lang.RuntimeException: Unable to start activity ComponentInfo{b4a.example/de.amberhome.objects.preferenceactivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator java.util.ArrayList.iterator()' on a null object reference

Also, what is the Dependency when creating views in a PreferenceScreen and what should I have there?

Sorry, these are probably all stupid questions, I'm new :/

First line is
B4X:
java.lang.RuntimeException: Unable to start activity ComponentInfo{b4a.example/de.amberhome.objects.preferenceactivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator java.util.ArrayList.iterator()' on a null object reference

Also, what is the Dependency when creating views in a PreferenceScreen and what should I have there?

Do you have the preference activity declared in the manifest editor? You have to add

B4X:
AddApplicationText(<activity android:name="de.amberhome.objects.preferenceactivity"/>)

there.

With the dependency you can make dependent settings. So when you uncheck a checkbox setting all dependent settings will be grayed out. I think the usage is in the example. If you don't need this feature just enter an empty string as parameter.
 

SCIS

Active Member
Licensed User
Longtime User
Do you have the preference activity declared in the manifest editor? You have to add

B4X:
AddApplicationText(<activity android:name="de.amberhome.objects.preferenceactivity"/>)

there.

With the dependency you can make dependent settings. So when you uncheck a checkbox setting all dependent settings will be grayed out. I think the usage is in the example. If you don't need this feature just enter an empty string as parameter.

I already have both of those. The crash only happens in landscape mode. When my phone is in portrait mode, I have no problem opening the settings screen :/
 
Top