Giter VIP home page Giter VIP logo

donations's Introduction

Android Donations Lib

Android Donations Lib supports donations by Google Play Store, Flattr, PayPal, and Bitcoin.

It is used in projects, such as OpenKeychain, AdAway, FasterGPS, and NTPSync.

NOTE: Google mailed me to remove PayPal donation capability when publishing on Google Play! Thus, you should build "product flavors" defined by the example: One version with Google Play donation capability and one with Paypal, Flattr, and Bitcoin!

How to use

  1. Add dependency to your build.gradle:
    repositories {
        jcenter()
    }
    
    dependencies {
        compile 'org.sufficientlysecure:donations:2.6'
    }
    
  2. Instantiate the fragment where you want to use it. Check out the example app for this: DonationsActivity.java
  3. Don't forget to pass through results in onActivityResult() back to the fragment as shown in DonationsActivity.java.
  4. When publishing the app you must create managed in-app products for your app in the Google Play Store that matches the ones you defined in private static final String[] GOOGLE_CATALOG

Build flavors

  1. Keep in mind that Google forbits other payment methods besides Google Play. Thus, in the example, two build flavors are used. Check out ExampleApp/build.gradle. The build script adds DONATIONS_GOOGLE to the auto generated BuildConfig.java.
  2. Add <uses-permission android:name="android.permission.INTERNET" /> to product flavors that use Flattr
  3. Add <uses-permission android:name="com.android.vending.BILLING" /> to product flavors that use Google Play In-app billing

Screenshots

Product Flavor: Google Product Flavor: Fdroid
Screenshot Screenshot

Translations

Help translating on Transifex.

Build Example App with Gradle

  1. Have Android SDK "tools", "platform-tools", and "build-tools" directories in your PATH (http://developer.android.com/sdk/index.html)
  2. Export ANDROID_HOME pointing to your Android SDK
  3. Download Android Support Repository, and Google Repository using Android SDK Manager
  4. Execute ./gradlew build

Add the lib to your project

Changelog

2.6

  • Force Intent chooser for PayPal
  • Min SDK 14

2.5

  • Sync translations

2.4

  • Fix NPE without billing service

2.3

  • Publish to JCenter

2.2

  • Updated build files
  • Added bitcoin support (thanks to Oleg Vaskevich)

2.1

  • Permissions are now defined per product flavor, they were removed from library's AndroidManifest

2.0

  • Now uses Gradle Build System (http://tools.android.com/tech-docs/new-build-system)
  • No xml configuration needed anymore!
  • Fragment can be instantiated and used in any Activity.
  • You can build "product flavors" defined by the ExampleApp: One version with Google Play Donation capability and one with Paypal and Flattr! (Google mailed me to remove PayPal donation capability when publishing on Google Play!)

Contribute

Fork Android Donations Lib and do a pull request. I will merge your changes back into the main project.

donations's People

Contributors

allanwang avatar badnetmask avatar btimofeev avatar demantz avatar dschuermann avatar friedger avatar ianhanniballake avatar javinator9889 avatar oleg-codaio avatar swoker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

donations's Issues

IllegalStateException on Google Play billing when started twice

As far as i know its not allowed to run multiple asynctask for google in app billing.But this library is creating new tasks if pressed donate button twice.Maybe it needs to check if a task is already running and react according to it.

12-20 22:29:20.860 8218-8218/? E/AndroidRuntime: java.lang.IllegalStateException: Can't start async operation (launchPurchaseFlow) because another async operation(launchPurchaseFlow) is in progress.
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at org.sufficientlysecure.donations.google.util.IabHelper.flagStartAsync(IabHelper.java:820)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at org.sufficientlysecure.donations.google.util.IabHelper.launchPurchaseFlow(IabHelper.java:374)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at org.sufficientlysecure.donations.DonationsFragment.donateGoogleOnClick(DonationsFragment.java:350)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at org.sufficientlysecure.donations.DonationsFragment$1.onClick(DonationsFragment.java:226)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at android.view.View.performClick(View.java:4785)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at android.view.View$PerformClick.run(View.java:19884)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:746)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5343)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:702)

IAB helper not set up exception

Occasionally I get the following exception while using the library:

java.lang.IllegalStateException: IAB helper is not set up. Can't perform operation: launchPurchaseFlow
at org.sufficientlysecure.donations.google.util.IabHelper.checkSetupDone(IabHelper.java:781)
at org.sufficientlysecure.donations.google.util.IabHelper.launchPurchaseFlow(IabHelper.java:371)
at org.sufficientlysecure.donations.DonationsFragment.donateGoogleOnClick(DonationsFragment.java:345)
at org.sufficientlysecure.donations.DonationsFragment$1.onClick(DonationsFragment.java:218)
at android.view.View.performClick(View.java:4439)
at android.widget.Button.performClick(Button.java:148)
at android.view.View$PerformClick.run(View.java:18395)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5319)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)

Illegal state exception

First crash log :
java.lang.IllegalStateException:
at android.support.v4.app.Fragment.requireContext (Fragment.java:611)
at android.support.v4.app.Fragment.getResources (Fragment.java:675)
at android.support.v4.app.Fragment.getString (Fragment.java:697)
at org.sufficientlysecure.donations.DonationsFragment$2.onIabSetupFinished (DonationsFragment.java:243)
at org.sufficientlysecure.donations.google.util.IabHelper$1.onServiceConnected (IabHelper.java:230)
at android.app.LoadedApk$ServiceDispatcher.doConnected (LoadedApk.java:1101)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run (LoadedApk.java:1118)
at android.os.Handler.handleCallback (Handler.java:733)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:136)
at android.app.ActivityThread.main (ActivityThread.java:5590)
at java.lang.reflect.Method.invokeNative (Native Method)
at java.lang.reflect.Method.invoke (Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1280)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1096)
at dalvik.system.NativeStart.main (Native Method)

Second crash log :

java.lang.IllegalStateException:
at org.sufficientlysecure.donations.google.util.IabHelper.checkSetupDone (IabHelper.java:784)
at org.sufficientlysecure.donations.google.util.IabHelper.launchPurchaseFlow (IabHelper.java:374)
at org.sufficientlysecure.donations.DonationsFragment.donateGoogleOnClick (DonationsFragment.java:332)
at org.sufficientlysecure.donations.DonationsFragment$1.onClick (DonationsFragment.java:220)
at android.view.View.performClick (View.java:4508)
at android.view.View$PerformClick.run (View.java:18675)
at android.os.Handler.handleCallback (Handler.java:733)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:136)
at android.app.ActivityThread.main (ActivityThread.java:5590)
at java.lang.reflect.Method.invokeNative (Native Method)
at java.lang.reflect.Method.invoke (Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1280)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1096)
at dalvik.system.NativeStart.main (Native Method)

Can we use this library and upload the app to playstore?

Hi, I just want to make sure before I used this library for donation purpose inside my app since I've read reddit and stackoverflow threads talking about their app got rejected/banned because having donation button which not used google IAP. Thanks

Link error when using PayPal app

Hi,
it seems that with the PayPal official app installed, when prompted to choose a "browser", if you click on it, the PayPal app redirects anyway to the browser but the page gets a 404 error.
Instead, if you choose a browser in the app chooser, the link works and one can log in and make the donation.

libnl-3-android issues

@dschuermann
Sorry to post msg at this project, It is because the libnl-3-android project(https://github.com/dschuermann/libnl-3-android) do not have issues module.

I have a project imlinhao/android-iw-libnl3#1 that depends on the libnl-3-android project, but because of the version update of ubuntu and android ndk, there be some problems of the project.

I want to know whether you have some blogs of how to porting libnl to android, or maybe update the libnl-3-android project using the newly libnl and newly compile tool like ubuntu 14.04 and android ndk 10c.

Thank you very much, and you can contact me at [email protected].

Attempt to read from field 'java.lang.String org.sufficientlysecure.donations.google.util.Purchase.mItemType' on a null object reference

Fatal Exception: java.lang.NullPointerException
Attempt to read from field 'java.lang.String org.sufficientlysecure.donations.google.util.Purchase.mItemType' on a null object reference
raw
org.sufficientlysecure.donations.google.util.IabHelper.consume (IabHelper.java)
org.sufficientlysecure.donations.google.util.IabHelper$3.run (IabHelper.java)
java.lang.Thread.run (Thread.java:818)

translations

make transifex config and pull newest translations from adaway translations

How is it going?

Hi,

I wanted to add donation options into my app (preferable PayPal, Google Payment would be OK too).

But is this till allowed? I find conflicting entries in the internet.

Can you tell me more about it?

Make donations__google_android_market_promt_array configurable

donations__google_android_market_promt_array should be configurable as donations__google_catalog so it should not be the donations__google_android_market_promt_array in lib resources but a string-array name d donations__google_catalog_labels in donations__config.xml then:

        // choose donation amount
        mGoogleSpinner = (Spinner) getActivity().findViewById(
                R.id.donations__google_android_market_spinner);
        int nameResourceID = getActivity().getResources().getIdentifier("donations__google_catalog_labels", "array",
            getActivity().getApplicationInfo().packageName);

        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
            nameResourceID,
                android.R.layout.simple_spinner_item);

Feature request

is it possible, to query if a user has already submitted a donation ?
E.g. yes / no
or
Amount of donations so far ?
This API would be very nice

Paypal fix or way around

I used to have a paypal option in my apps, reading the google support information they say that web cannot open a Paypal link a WebBrowser requesting for donations because can be used for tricking user to donate an amount they don't agree with. So, after some days trying I figured a way around.

Easy instead of launching Paypal Fragment to manage Paypal just command your app to open the phone default WebBrowser in your paypal.me link. I'll leave an example below.

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://paypal.me/juanjshb"));
startActivity(browserIntent);

Hope it help. It works for me

force close/ reopen app

after click donation google button, and dismiss dialog. if i click again, app forceclose.

Strip the exclamation mark from buttons

For politeness the exclamation mark should be removed from the button in all translations. No one want's to be talked to in imperative. "DONATE!" they will not.

is paypal donation still functionable?

Hi,

I downloaded the App FasterGPS and have a look on donation page.
However, there is not more paypal donation, only google play? I wonder why. thanks!

Translations

Hello!
Thank you for this library - it works perfectly, and saved tons of time!

Though Russian and Ukrainian translations are marked as 100% done on Transifex, i see English everywhere except Donate button on that languages. Could you please sync translations?
If you need some help with translation to that two languages - i'd be glad to help.

unmanaged vs managed in-app product

Hi,

the readme of this library states that one should create unmanaged products in the developer console. However, i read that since billing v3 only managed products are available? Is this a bug in the readme or am i missing something?

thanks
matthias

IABHelper not setup

Recently I commented in the issue #15 because this error is happening again.

I managed to solve it by doing this trick, but the latest version of the lib was not managing it:
(as the code is a bit longer, I will add a PasteBin for better visualization):

--> https://pastebin.com/Wda6FwPz

Google Play Warning

Please have a look at this error google play giving me a warning when I have submit my application after integrate your library.

=== GOOGLE PLAY WARNING ===
Security alert
Your app is using an unsafe implementation of WebViewClient.onReceivedSslError handler. Please see this Google Help Center article for details, including the deadline for fixing the vulnerability.
Vulnerable classes:
com.github.gorbin.asne.core.OAuthActivity$1

Genymotion emulator: NullPointerException on run

I could get it working changing:

public class IabHelper {
.....
List tmpList = mContext.getPackageManager().queryIntentServices(serviceIntent, 0);
if (tmpList==null && !tmpList.isEmpty()) {
....

In my case tmpList is null

Log file:
10-06 23:43:33.876 987-987/org.sufficientlysecure.donations.example D/dalvikvm: Late-enabling CheckJNI
10-06 23:43:33.988 987-987/org.sufficientlysecure.donations.example D/Donations Library: Creating IAB helper.
10-06 23:43:33.992 987-987/org.sufficientlysecure.donations.example D/Donations Library: Starting setup.
10-06 23:43:33.992 987-987/org.sufficientlysecure.donations.example D/IabHelper: Starting in-app billing setup.
10-06 23:43:33.992 987-987/org.sufficientlysecure.donations.example D/AndroidRuntime: Shutting down VM
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa62ed288)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: FATAL EXCEPTION: main
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.sufficientlysecure.donations.example/org.sufficientlysecure.donations.example.DonationsActivity}: java.lang.NullPointerException
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:130)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:4745)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: Caused by: java.lang.NullPointerException
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at org.sufficientlysecure.donations.google.util.IabHelper.startSetup(IabHelper.java:268)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at org.sufficientlysecure.donations.DonationsFragment.onActivityCreated(DonationsFragment.java:242)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1797)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:979)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:551)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.app.Activity.performStart(Activity.java:5018)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:130) 
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137) 
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:4745) 
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) 
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511) 
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
10-06 23:43:33.996 987-987/org.sufficientlysecure.donations.example E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method) 

make configurable by xml

Make library configurable by xml as seen in the fork.
Also make xml booleans to enable/disable google play, flattr, and paypal

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.