-
Notifications
You must be signed in to change notification settings - Fork 435
Developer guide: settle the seven Monetization sentences that promise code #5810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5a962a2
Developer guide: settle the seven Monetization sentences that promise…
shai-almog 1824002
Developer guide: three review fixes on the Monetization listings
shai-almog 499df39
Developer guide: show the cached expiry before the user asks for a sync
shai-almog f8c8ce0
Developer guide: a failed sync must not cost the user the status they…
shai-almog 5cce9e5
Developer guide: the startup sync has to reach the same label
shai-almog bb20935
Developer guide: one Synchronize Receipts button, not two
shai-almog 99bc5b2
Developer guide: the two listings take the form rather than assuming one
shai-almog c586ed8
Developer guide: something has to call the two helpers
shai-almog ca3a585
Developer guide: declare the SKUs the whole chapter reads
shai-almog 7060a2d
Developer guide: the subscription start() needs the same resume guard
shai-almog a4d7c32
Developer guide: the resume needs the synchronization more than the l…
shai-almog 0310641
Developer guide: repaint the expiry label when the purchase lands
shai-almog 0940e44
Developer guide: synchronize the Purchase instance the label reads
shai-almog fb043b0
Developer guide: the rental buttons read the shared Purchase too
shai-almog d51458e
Developer guide: hold no Purchase instance at all
shai-almog b56b533
Developer guide: the purchase callback can run before the form exists
shai-almog 935a3df
Purchase: drain receipts queued while a synchronization was fetching
shai-almog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...in/java/com/codenameone/developerguide/snippets/generated/MonetizationJava101Snippet.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /* | ||
| * Copyright (c) 2012, Codename One and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * This code is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU General Public License version 2 only, as | ||
| * published by the Free Software Foundation. Codename One designates this | ||
| * particular file as subject to the "Classpath" exception as provided | ||
| * by Oracle in the LICENSE file that accompanied this code. | ||
| * | ||
| * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| * version 2 for more details (a copy is included in the LICENSE file that | ||
| * accompanied this code). | ||
| * | ||
| * You should have received a copy of the GNU General Public License version | ||
| * 2 along with this work; if not, write to the Free Software Foundation, | ||
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| * | ||
| * Please contact Codename One through http://www.codenameone.com/ if you | ||
| * need additional information or have any questions. | ||
| */ | ||
|
|
||
| package com.codenameone.developerguide.snippets.generated; | ||
|
|
||
| import com.codename1.gpu.*; | ||
| import com.codename1.ui.*; | ||
| import com.codename1.ui.animations.*; | ||
| import com.codename1.ui.events.*; | ||
| import com.codename1.ui.geom.*; | ||
| import com.codename1.ui.layouts.*; | ||
| import com.codename1.ui.list.*; | ||
| import com.codename1.ui.plaf.*; | ||
| import com.codename1.ui.util.*; | ||
| import com.codename1.components.*; | ||
| import com.codename1.charts.models.*; | ||
| import com.codename1.charts.renderers.*; | ||
| import com.codename1.charts.views.*; | ||
| import com.codename1.capture.*; | ||
| import com.codename1.io.*; | ||
| import com.codename1.l10n.*; | ||
| import com.codename1.location.*; | ||
| import com.codename1.maps.*; | ||
| import com.codename1.media.*; | ||
| import com.codename1.messaging.*; | ||
| import com.codename1.payment.*; | ||
| import com.codename1.processing.*; | ||
| import com.codename1.properties.*; | ||
| import com.codename1.push.*; | ||
| import com.codename1.security.*; | ||
| import com.codename1.social.*; | ||
| import com.codename1.ui.spinner.*; | ||
| import java.io.*; | ||
| import java.util.*; | ||
|
|
||
|
|
||
| class MonetizationJava101Snippet { | ||
|
|
||
| Form hi; | ||
| Purchase iap = Purchase.getInAppPurchase(); | ||
| String[] PRODUCTS = {"com.codename1.world.month", "com.codename1.world.year"}; | ||
| SpanLabel rentalStatus = new SpanLabel(); | ||
|
|
||
| void showRentalStatus() { | ||
| } | ||
|
|
||
| // tag::monetization-java-101[] | ||
| void addSyncButton(Form hi) { | ||
| Button syncReceipts = new Button("Synchronize Receipts"); | ||
|
|
||
| syncReceipts.addActionListener(e -> { | ||
| Purchase.getInAppPurchase().synchronizeReceipts(0, success -> { | ||
| // synchronizeReceipts reports true only when every pending | ||
| // purchase reached the receipt store AND the receipts came | ||
| // back. On false nothing was reloaded, so there is nothing | ||
| // new to show and the status on screen stays as it was. | ||
| if (success) { | ||
| showRentalStatus(); | ||
| hi.revalidate(); | ||
| } else { | ||
| ToastBar.showErrorMessage("Could not reach the receipt store"); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| hi.add(syncReceipts); | ||
| } | ||
| // end::monetization-java-101[] | ||
| } |
85 changes: 85 additions & 0 deletions
85
...in/java/com/codenameone/developerguide/snippets/generated/MonetizationJava102Snippet.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * Copyright (c) 2012, Codename One and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * This code is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU General Public License version 2 only, as | ||
| * published by the Free Software Foundation. Codename One designates this | ||
| * particular file as subject to the "Classpath" exception as provided | ||
| * by Oracle in the LICENSE file that accompanied this code. | ||
| * | ||
| * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| * version 2 for more details (a copy is included in the LICENSE file that | ||
| * accompanied this code). | ||
| * | ||
| * You should have received a copy of the GNU General Public License version | ||
| * 2 along with this work; if not, write to the Free Software Foundation, | ||
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| * | ||
| * Please contact Codename One through http://www.codenameone.com/ if you | ||
| * need additional information or have any questions. | ||
| */ | ||
|
|
||
| package com.codenameone.developerguide.snippets.generated; | ||
|
|
||
| import com.codename1.gpu.*; | ||
| import com.codename1.ui.*; | ||
| import com.codename1.ui.animations.*; | ||
| import com.codename1.ui.events.*; | ||
| import com.codename1.ui.geom.*; | ||
| import com.codename1.ui.layouts.*; | ||
| import com.codename1.ui.list.*; | ||
| import com.codename1.ui.plaf.*; | ||
| import com.codename1.ui.util.*; | ||
| import com.codename1.components.*; | ||
| import com.codename1.charts.models.*; | ||
| import com.codename1.charts.renderers.*; | ||
| import com.codename1.charts.views.*; | ||
| import com.codename1.capture.*; | ||
| import com.codename1.io.*; | ||
| import com.codename1.l10n.*; | ||
| import com.codename1.location.*; | ||
| import com.codename1.maps.*; | ||
| import com.codename1.media.*; | ||
| import com.codename1.messaging.*; | ||
| import com.codename1.payment.*; | ||
| import com.codename1.processing.*; | ||
| import com.codename1.properties.*; | ||
| import com.codename1.push.*; | ||
| import com.codename1.security.*; | ||
| import com.codename1.social.*; | ||
| import com.codename1.ui.spinner.*; | ||
| import java.io.*; | ||
| import java.util.*; | ||
|
|
||
|
|
||
| class MonetizationJava102Snippet { | ||
|
|
||
| Form hi; | ||
| Purchase iap = Purchase.getInAppPurchase(); | ||
| String[] PRODUCTS = {"com.codename1.world.month", "com.codename1.world.year"}; | ||
|
|
||
| // tag::monetization-java-102[] | ||
| // A field, not a local: the synchronization at the end of start() and the | ||
| // button above both have to reach this label. | ||
| SpanLabel rentalStatus = new SpanLabel(); | ||
|
|
||
| void addExpiryLabel(Form hi) { | ||
|
shai-almog marked this conversation as resolved.
|
||
| // The receipts already on the device answer this with no round trip, | ||
| // so the label is right the moment the form appears rather than after | ||
| // the first synchronization comes back. | ||
| showRentalStatus(); | ||
| hi.add(rentalStatus); | ||
|
shai-almog marked this conversation as resolved.
shai-almog marked this conversation as resolved.
|
||
| } | ||
|
|
||
| void showRentalStatus() { | ||
|
shai-almog marked this conversation as resolved.
|
||
| Purchase iap = Purchase.getInAppPurchase(); | ||
| if (iap.isSubscribed(PRODUCTS)) { | ||
| rentalStatus.setText("World rental expires " + iap.getExpiryDate(PRODUCTS)); | ||
|
shai-almog marked this conversation as resolved.
|
||
| } else { | ||
| rentalStatus.setText("You do not currently have a subscription to the world"); | ||
| } | ||
| } | ||
| // end::monetization-java-102[] | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.