B4A Library [BETA] ahaShareLibrary

[LIB] [B4A SourceCode] ahaShareLibrary

Hi!

As we all have the Problems with sharing Text/Pictures via Intents and Facebook, I decided to write a small library that get rid of this Problem. It's very easy to use and takes all the work away from you :)

You can share Text, Pictures, Documents.....



It's still beta, so please report any Bugs/Wishes.

Usage is very simple:
B4X:
Dim Share as ahaShare
Share.initialize(Me, "Share")
Share.FaceBookAppID = "xxxx"
Share.FaceBookRedirectUri = "http://www.xxxxxx.xxx/"
Share.Share("Test-Subject","Test-Text")
After sharing, the Finished Event is called
B4X:
Sub Share_Finished
   ..your code here
End Sub
Screenshot :
attachment.php


PS: As you can see you can customize nearly everything:
attachment.php
attachment.php
attachment.php



This library is written in B4A :)

I hope you like it :)
  • ahaShare
    Methods:
    • IsInitialized As Boolean
      Tests whether the object has been initialized.
    • Addfile (Directory As String, Filename As String) As String
      Adds a file to the Intent
      <B>Attention: file.DirAssets and file.dirInternal will <I>NOT></I> work as Directory!!</B>
    • Addpackagefilter (PackageFilter As String) As String
      Adds a packagefilter. Packages with the given names will not be shown in the ContentChooser
      Example1: "com.google.android.keep" to hide Google Keep from the choosable Apps
      Example2: "synology" hides every Synology-App
    • Clearfiles As String
      Clears all added files
    • Initialize (Module As Object, EventName As String) As String
      Initializes the Library

      <B>Normal Library usage:</B>
      -----------------------
      <code>Dim Share as ahaShare
      Share.initialize(me, "Share")
      Share.FaceBookAppID = "xxxx"
      Share.FaceBookRedirectUri = "http://www.xxxxxx.xxx/"
      Share.Share("Test-Subject","Test-Text")</code>

      Event Finished will be raised when Sharing is finished:
      Sub Share_Finished
      ..your code here (i.e deleting temp files,...)
      End Sub

      <B>That's it :)</B>
    • Sshare (Subject As String, Text As String) As String
      Starts the ContentChooser
    Properties:
    • buttonnormalcolor As Int
      Color of the unpressed Buttons
      Standard: colors.white
    • buttonpressedcolor As Int
      Color of the pressed Button
      Standard: Colors.RGB(29,162,235)
    • cornerradius As Int
      Corner radius of the Buttons
    • facebookappid As String
      Your Facebook AppID. Needed for publishing to FaceBook.
      Tutorial by NJDude: <link>http://www.b4x.com/forum/basic4android-getting-started-tutorials/17739-tutorial-post-facebook-wall-via-b4a-app.html|http://www.b4x.com/forum/basic4android-getting-started-tutorials/17739-tutorial-post-facebook-wall-via-b4a-app.html</link>
      Attention: If not set, FaceBook will not be available to share with
    • facebookredirecturi As String
      Your Facebook RedirectUri. Needed for publishing to FaceBook.
      Tutorial by NJDude: <link>http://www.b4x.com/forum/basic4android-getting-started-tutorials/17739-tutorial-post-facebook-wall-via-b4a-app.html|http://www.b4x.com/forum/basic4android-getting-started-tutorials/17739-tutorial-post-facebook-wall-via-b4a-app.html</link>
      Attention: If not set, FaceBook will not be available to share with
    • headerbackcolor As Int
      BackColor of the Header
      Standard: Colors.Transparent
    • headertext As String
      HeaderText of the ContentChooser
      Standard: Choose
    • headertextcolor As Int
      TextColor of the Header
      Standard: Colors.RGB(49,182,255)
    • headertextsize As Int
      TextSize of the Header
      Standard: 22
    • intenttype As String
      IntentType, for example "text/*" for Text, "image/jpeg" for jpg, "image/png" for png etc..
    • linecolor As Int
      Color of the Seperatorline below the Header
      Standard: Colors.RGB(49,182,255)
    • padding As Int
      Padding
      Standard: 10dip
    • panelcolor As Int
      Color of the ContentChooser Panel
      Standard: Colors.white
    • sendingtofacebookfinishedstring As String
      The String displayed as ToastMessage after Sending to Facebook succeeded
      Standard: "Posted to Facebook"
    • sendingtofacebookstring As String
      The String displayed in the ProgressDialog while sending to FaceBook
      Standard: "Posting to Facebook..."
    • shadowcolor As Int
      Color of the Background Shadow.
      Use colors.rgb(x,x,x) for opaque background, colors.argb(x,x,x,x) for Transparency
      Standard: Colors.ARGB(150,0,0,0)
    • subject As String
      Subject (for E-Mail,..) set as android.intent.extra.SUBJECT
    • text As String
      The Message. Set as android.intent.extra.TEXT
    • textcolor As Int
      Textcolor of the Names of the displayed Packages
      Standard: Colors.Black
    • textsize As Int
      TextSize of the Names of the displayed Packages.
      Standard: 14
    • AppButtonWidth As Int
      Width of the Buttons
      Standard: 160dip
    • AppButtonHeight As Int
      Height of the Buttons
      Standard: 120dip
    • AppIconSize As Int
      Size of the Images on the Buttons
      Standard: 48dip
    • HeaderHeight As Int
      Height of the Header
      Standard: 60dip
Generated with Warwounds Library reference generator
---------------
Version 0.6
New:
_Finished Event added

Version 0.7
New:
Long click on the App-Symbol opens the Android Application Settings for the clicked app (as the original contentchooser
Fixed: Last line of Icons was not displayed. (Thanks to derez!!)
Change: More icons are displayed at once (Height of the Buttons reduced)

Version 0.8
New:
AppButtonWidth: sets the width of the Buttons
AppButtonHeight: sets the height of the Buttons
AppIconSize: Sets width & height of the AppIcons
HeaderHeight: Sets the height of the Header
Fixed: Error handling in all Subs

Version 1.0
Beta finished :)
SourceCode attached
 

Attachments

  • Example.zip
    42.3 KB · Views: 753
  • Screenshot.png
    Screenshot.png
    45.6 KB · Views: 1,567
  • Screenshot2.png
    Screenshot2.png
    30.6 KB · Views: 1,534
  • ScreenshotXS.png
    ScreenshotXS.png
    25.1 KB · Views: 1,453
  • ScreenshotS.png
    ScreenshotS.png
    33.7 KB · Views: 1,466
  • ahaShareLibrary.zip
    22.1 KB · Views: 747
  • ahaShareSource.zip
    126.2 KB · Views: 622
Last edited:

desof

Well-Known Member
Licensed User
Longtime User
Why does this happen ?


B4X:
Logger connected to:  motorola XT890
--------- beginning of /dev/log/main
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 341)
java.lang.NullPointerException
    at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:835)
    at at.ahadev.b4a.ahashare.ahashare._share(ahashare.java:569)
    at b4a.example.main._activity_create(main.java:341)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at b4a.example.main.afterFirstLayout(main.java:102)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5031)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 337)
java.lang.NullPointerException
    at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:835)
    at at.ahadev.b4a.ahashare.ahashare._share(ahashare.java:569)
    at b4a.example.main._activity_create(main.java:337)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at b4a.example.main.afterFirstLayout(main.java:102)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5031)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 337)
java.lang.NullPointerException
    at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:835)
    at at.ahadev.b4a.ahashare.ahashare._share(ahashare.java:569)
    at b4a.example.main._activity_create(main.java:337)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at b4a.example.main.afterFirstLayout(main.java:102)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5031)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
Copying updated assets files (1)
** Activity (main) Create, isFirst = true **
Error occurred on line: 35 (Main)
java.lang.NullPointerException
    at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:835)
    at at.ahadev.b4a.ahashare.ahashare._share(ahashare.java:569)
    at b4a.example.main._activity_create(main.java:379)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at b4a.example.main.afterFirstLayout(main.java:102)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5031)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
    at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **
 
Top