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,000
  • AHPreferenceActivity1_02.zip
    21.4 KB · Views: 1,922
  • AHPreferenceActivity1_04.zip
    22.1 KB · Views: 2,476
  • AHPreferenceActivityExample1_04.zip
    7.1 KB · Views: 1,900
Last edited:

yttrium

Active Member
Licensed User
Longtime User
I think corwin explained a while back that the library only supports some simple kind of intents not all kinds.

Sent from my GT-I9305 using Tapatalk 2

I would think the built-in Email intent is fairly simple...
 

yttrium

Active Member
Licensed User
Longtime User

thedesolatesoul

Expert
Licensed User
Longtime User
Hmm.

Does Android open a browser for a url starting with mailto: or does it launch the email intent?

mailto opens the default gmail client.

B4X:
Sub SendFeedback
    Dim Message As Intent
    Uri = "mailto:[email protected]?" & _
        "subject=Feedback&body=[Please write your feedback here]"
   Message.Initialize(Message.ACTION_VIEW, Uri)
   StartActivity(Message)
End Sub
Credits to NJDude.
 

yttrium

Active Member
Licensed User
Longtime User
mailto opens the default gmail client.

B4X:
Sub SendFeedback
    Dim Message As Intent
    Uri = "mailto:[email protected]?" & _
        "subject=Feedback&body=[Please write your feedback here]"
   Message.Initialize(Message.ACTION_VIEW, Uri)
   StartActivity(Message)
End Sub
Credits to NJDude.

Works beautifully. Thanks!
 

mterveen

Member
Licensed User
Longtime User
Yes, but I get this error:

B4X:
Parsing code.                           0.19
Compiling code.                         Error
Error compiling program.
Error description: Too many parameters.
Occurred on line: 132
screen2.AddEditText("op1","Option 1","text for option 1","",False,"chkBox1")
Word: chkBox1

i have the same issue with addpassword. in one case it asks for a boolean parameter. when you add the boolean parameter you get the error that there are now too many parameters. help!!
 

corwin42

Expert
Licensed User
Longtime User
i have the same issue with addpassword. in one case it asks for a boolean parameter. when you add the boolean parameter you get the error that there are now too many parameters. help!!

Be sure that you don't have both PreferenceActivity and AHPreferenceActivity checked on the library tab.
 

mterveen

Member
Licensed User
Longtime User
bump for developer response

corwin42 or yttrium - are you able to get the addedittext working with version 1.03? i need the use of addedittext2 in 1.03 but also the addpassword and addedittext feature of 1.02. if so could you post a working example. thx.
 

mterveen

Member
Licensed User
Longtime User
Anybody

corwin42 or yttrium - are you able to get the addedittext working with version 1.03? i need the use of addedittext2 in 1.03 but also the addpassword and addedittext feature of 1.02. if so could you post a working example. thx.


is this library still supported? hello???
 

corwin42

Expert
Licensed User
Longtime User
Sorry I'm currently very busy with other things. Will try your issue in the next days.

PS: most times it is better and easier to reproduce an issue if you provide an example project.
 

mterveen

Member
Licensed User
Longtime User
version 1.03

thx for your response. understand how crazy it can get. basically all i did is download your example from post 1 but use the version 1.03 later in this thread. i'm guessing that 1.03 is not supported by you and i just need to stay with 1.02, although i REALLY like the extra features in 1.03 with forcing the entry type in edittext settings.
 

mterveen

Member
Licensed User
Longtime User
update

corwin42 - have you had a chance to evaluate adding the ability to force the edittext to a specific type as is shown in ver 1.03?
 

corwin42

Expert
Licensed User
Longtime User
corwin42 - have you had a chance to evaluate adding the ability to force the edittext to a specific type as is shown in ver 1.03?

Sorry, no. I will have a look at it now.
 

corwin42

Expert
Licensed User
Longtime User
corwin42 - have you had a chance to evaluate adding the ability to force the edittext to a specific type as is shown in ver 1.03?

Done. Version 1.04 added to first post and sources uploaded to github repository
 

mterveen

Member
Licensed User
Longtime User
corwin - just saw your post. thx so very much for the update. really appreciate your commitment to this community.


****edit ****

had another thought! i love the way this thing works. however, is there a way you could make it work also using a user specified file/directory to store other settings. for example, using the lib is great for storing general app settings. however, in my app i also have other Images/views that the user can modify various attributes on, eg. colors,fonts, etc. it would be nice to be able to use this library and its features to store these secondary attributes. specifically i have multiple "dashboards" with various gauges on it (analog, digital, etc.). each gauge can be customized using a common set (20 to 30) of attributes. it would be fantastic if i could attach a secondary "preference" activity for each dashboard using your library vs implementing some type of custom listview.

****edit 2****
or even an internal object of some sort that could be populated from another source and then used as the "map" for the preference activity, with all changes being stored back to the internal map object which could then be distributed back to the original source.
 
Last edited:

shashkiranr

Active Member
Licensed User
Longtime User
Hi Corwin,

Thank you for the library :)

I have a 2 questions.

1. Is it possible to add a button at the bottom of the preference screen. If yes. then kindly let me know how to go about it.

2. I need to add the settings screen as view in a panel. but since the Preference screen is not a view i am not able to do it.

Kindly let me know your Inputs regarding this.

Regards,
SK
 
Top