android-lib/src/main/java/io/v/android/security/BlessingsManager.java
/**
     * Mints a new set of {@link Blessings} that are persisted in {@link SharedPreferences} under
     * the provided key.
     * <p>
     * If {@code googleAccount} is non-{@code null} and non-empty, mints the blessings using
     * that account;  otherwise, prompts the user to pick one of the installed Google accounts
     * (if there is more than one installed).
     * <p>
     * This method will start an activity to handle the creation of new blessings.  Hence, you
     * should be prepared that your activity will be stopped and re-started, at the minimum.
     * <p>
     * This method is re-entrant: if invoked the 2nd time while the 1st invocation is still
     * pending, the future associated with the 2nd invocation will overwrite the 1st future: the
     * 1st future will never be invoked.
     * <p>
     * This method must be invoked on the UI thread.
     *
     * @param activity      android {@link Activity} requesting blessings
     * @param key           a key in {@link SharedPreferences} under which the newly minted
     *                      blessings are persisted
     * @param googleAccount a Google account to use to mint the blessings; if {@code null} or
     *                      empty, user will be prompted to pick one of the installed Google
     *                      accounts, if there is more than one installed
     * @param setAsDefault  if true, the returned {@link Blessings} will be set as default
     *                      blessings for the app
     * @return              a new {@link ListenableFuture} whose result are the newly minted
     *                      {@link Blessings}
     */
Mints a new set of  Blessings that are persisted in  SharedPreferences under
the provided key.

If  googleAccount is non- null and non-empty, mints the blessings using
that account;  otherwise, prompts the user to pick one of the installed Google accounts
(if there is more than one installed).

This method will start an activity to handle the creation of new blessings.  Hence, you
should be prepared that your activity will be stopped and re-started, at the minimum.

This method is re-entrant: if invoked the 2nd time while the 1st invocation is still
pending, the future associated with the 2nd invocation will overwrite the 1st future: the
1st future will never be invoked.

This method must be invoked on the UI thread.


Mints a new set of Blessings that are persisted in SharedPreferences under the provided key . If googleAccount is non - null and non - empty mints the blessings using that account ; otherwise prompts the user to pick one of the installed Google accounts ( if there is more than one installed ) . This method will start an activity to handle the creation of new blessings . Hence you should be prepared that your activity will be stopped and re - started at the minimum . This method is re - entrant : if invoked the 2nd time while the 1st invocation is still pending the future associated with the 2nd invocation will overwrite the 1st future : the 1st future will never be invoked . This method must be invoked on the UI thread .
public static ListenableFuture<Blessings> mintBlessings(VContext ctx,
            final Activity activity, String key, String googleAccount, boolean setAsDefault) {
        if (Looper.myLooper() != Looper.getMainLooper()) {
            return Futures.immediateFailedFuture(new VException("mintBlessings() must be invoked " +
                    "on the UI thread"));
        }
        if (mintFuture != null) {
            mintFuture = SettableFuture.create();
            return setAsDefault ? wrapWithSetAsDefault(ctx, activity, mintFuture) : mintFuture;
        }
        mintFuture = SettableFuture.create();
        FragmentTransaction transaction = activity.getFragmentManager().beginTransaction();
        BlessingsManager fragment = new BlessingsManager();
        fragment.mPrefKey = key;
        fragment.mGoogleAccount = googleAccount;
        transaction.add(fragment, UUID.randomUUID().toString());
        transaction.commit();  
        return setAsDefault ? wrapWithSetAsDefault(ctx, activity, mintFuture) : mintFuture;
    }
public static ListenableFuture < Blessings > mintBlessings ( VContext ctx , final Activity activity , String key , String googleAccount , boolean setAsDefault ) { if ( Looper . myLooper ( ) != Looper . getMainLooper ( ) ) { return Futures . immediateFailedFuture ( new VException ( "mintBlessings() must be invoked " + "on the UI thread" ) ) ; } if ( mintFuture != null ) { mintFuture = SettableFuture . create ( ) ; return setAsDefault ? wrapWithSetAsDefault ( ctx , activity , mintFuture ) : mintFuture ; } mintFuture = SettableFuture . create ( ) ; FragmentTransaction transaction = activity . getFragmentManager ( ) . beginTransaction ( ) ; BlessingsManager fragment = new BlessingsManager ( ) ; fragment . mPrefKey = key ; fragment . mGoogleAccount = googleAccount ; transaction . add ( fragment , UUID . randomUUID ( ) . toString ( ) ) ; transaction . commit ( ) ; return setAsDefault ? wrapWithSetAsDefault ( ctx , activity , mintFuture ) : mintFuture ; }
Mints a new set of {@link Blessings} that are persisted in {@link SharedPreferences} under
 the provided key.
Mints a new set of { @link Blessings } that are persisted in { @link SharedPreferences } under the provided key .
// Mint already in progress, which means that the invoking activity has been // destroyed and then recreated.  Register the new future to be invoked on completion // of that mint.  Note that it is safe and desirable to override the old future // as it's invocation would be handled by a destroyed activity. // this will invoke the fragment's onCreate() immediately.