first stab at android.
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:hardwareAccelerated="true"
|
android:hardwareAccelerated="true"
|
||||||
android:largeHeap="true"
|
android:largeHeap="true"
|
||||||
android:label="TicksTales">
|
android:label="Tick's Tales">
|
||||||
<activity android:name=".SplashActivity"
|
<activity android:name=".SplashActivity"
|
||||||
android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@@ -22,7 +22,9 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".MainActivity">
|
<activity android:name=".MainActivity"
|
||||||
|
android:screenOrientation="landscape"
|
||||||
|
android:configChanges="orientation|keyboardHidden" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name='advent.core.MAIN'/>
|
<action android:name='advent.core.MAIN'/>
|
||||||
<category android:name='android.intent.category.DEFAULT'/>
|
<category android:name='android.intent.category.DEFAULT'/>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
(defproject advent "1.3.2-SNAPSHOT"
|
(defproject advent "1.3.16-SNAPSHOT"
|
||||||
:description "FIXME: write description"
|
:description "FIXME: write description"
|
||||||
|
|
||||||
:dependencies [[com.badlogicgames.gdx/gdx "1.9.3" :use-resources true]
|
:dependencies [[com.badlogicgames.gdx/gdx "1.9.3" :use-resources true]
|
||||||
@@ -36,10 +36,10 @@
|
|||||||
{;; Specify the path to your private
|
{;; Specify the path to your private
|
||||||
;; keystore and the the alias of the
|
;; keystore and the the alias of the
|
||||||
;; key you want to sign APKs with.
|
;; key you want to sign APKs with.
|
||||||
;; :keystore-path "/home/user/.android/private.keystore"
|
;; :keystore-path "ticks-talkes-release.jks"
|
||||||
;; :key-alias "mykeyalias"
|
;; :key-alias "ticks-tales-release"
|
||||||
:build-type :release
|
:build-type :release
|
||||||
:aot :all
|
:aot :all-with-unused
|
||||||
:aot-exclude-ns [cljs.core.async.macros cljs.core.impl-ioc-macros cljs.core.impl.ioc_macros]}}}
|
:aot-exclude-ns [cljs.core.async.macros cljs.core.impl-ioc-macros cljs.core.impl.ioc_macros]}}}
|
||||||
|
|
||||||
:android {;; Specify the path to the Android SDK directory either
|
:android {;; Specify the path to the Android SDK directory either
|
||||||
|
|||||||
@@ -2,24 +2,34 @@ package advent.core;
|
|||||||
|
|
||||||
import clojure.lang.RT;
|
import clojure.lang.RT;
|
||||||
import clojure.lang.Symbol;
|
import clojure.lang.Symbol;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||||
import com.badlogic.gdx.Game;
|
import com.badlogic.gdx.Game;
|
||||||
import com.android.billingclient.api.*;
|
import com.android.billingclient.api.*;
|
||||||
import com.android.billingclient.api.BillingClient.BillingResponse;
|
import com.android.billingclient.api.BillingClient.BillingResponse;
|
||||||
|
import com.android.billingclient.api.BillingClient.SkuType;
|
||||||
|
import com.android.billingclient.api.SkuDetails.SkuDetailsResult;
|
||||||
|
import com.android.billingclient.api.BillingFlowParams;
|
||||||
|
import com.android.billingclient.api.BillingFlowParams.Builder;
|
||||||
|
|
||||||
|
public class MainActivity extends AndroidApplication {
|
||||||
|
public boolean triggerPurchase() {
|
||||||
|
BillingFlowParams.Builder builder = new BillingFlowParams.Builder()
|
||||||
|
.setSku("game").setType(SkuType.INAPP);
|
||||||
|
int returnValue = mBillingClient.launchBillingFlow(this, builder.build());
|
||||||
|
return returnValue == BillingClient.BillingResponse.OK || returnValue == BillingClient.BillingResponse.ITEM_ALREADY_OWNED;
|
||||||
|
}
|
||||||
|
|
||||||
public class MainActivity extends AndroidApplication implements PurchasesUpdatedListener {
|
|
||||||
private BillingClient mBillingClient;
|
private BillingClient mBillingClient;
|
||||||
@Override
|
|
||||||
public void onPurchasesUpdated(@BillingResponse int responseCode, java.util.List<Purchase> purchases) {
|
|
||||||
System.out.println("purchases");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCreate (android.os.Bundle savedInstanceState) {
|
public void onCreate (android.os.Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
try {
|
try {
|
||||||
RT.var("clojure.core", "require").invoke(Symbol.intern("clojure.core.async"));
|
RT.var("clojure.core", "require").invoke(Symbol.intern("clojure.core.async"));
|
||||||
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.core"));
|
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.core"));
|
||||||
|
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.android"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Importing failed");
|
System.out.println("Importing failed");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -27,14 +37,17 @@ public class MainActivity extends AndroidApplication implements PurchasesUpdated
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
Game game = (Game) RT.var("advent.core", "advent").deref();
|
Game game = (Game) RT.var("advent.core", "advent").deref();
|
||||||
|
System.out.println("pre-init");
|
||||||
initialize(game);
|
initialize(game);
|
||||||
mBillingClient = new BillingClient.Builder(this).setListener(this).build();
|
System.out.println("before bill??");
|
||||||
|
mBillingClient = new BillingClient.Builder(this).setListener((PurchasesUpdatedListener) RT.var("advent.android", "listener").deref()).build();
|
||||||
System.out.println("billing??");
|
System.out.println("billing??");
|
||||||
mBillingClient.startConnection(new BillingClientStateListener() {
|
mBillingClient.startConnection(new BillingClientStateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onBillingSetupFinished(@BillingResponse int billingResponseCode) {
|
public void onBillingSetupFinished(@BillingResponse int billingResponseCode) {
|
||||||
System.out.println("billing go");
|
System.out.println("billing go");
|
||||||
if (billingResponseCode == BillingResponse.OK) {
|
if (billingResponseCode == BillingResponse.OK) {
|
||||||
|
mBillingClient.queryPurchaseHistoryAsync("inapp", ((PurchaseHistoryResponseListener) RT.var("advent.android", "history-listener").deref()));
|
||||||
System.out.println("billing ok");
|
System.out.println("billing ok");
|
||||||
// The billing client is ready. You can query purchases here.
|
// The billing client is ready. You can query purchases here.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,9 @@
|
|||||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
||||||
[com.badlogic.gdx.graphics.g2d TextureRegion]
|
[com.badlogic.gdx.graphics.g2d TextureRegion]
|
||||||
[com.badlogic.gdx Gdx Application]
|
[com.badlogic.gdx Gdx Application]
|
||||||
[java.io FileOutputStream File PrintStream])
|
[java.io FileOutputStream File PrintStream]))
|
||||||
)
|
|
||||||
|
(def has-purchased? (atom false))
|
||||||
|
|
||||||
(defonce am (asset-manager))
|
(defonce am (asset-manager))
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
[play-clj.ui :refer :all]
|
[play-clj.ui :refer :all]
|
||||||
[play-clj.utils :refer :all]
|
[play-clj.utils :refer :all]
|
||||||
[play-clj.g2d :refer :all])
|
[play-clj.g2d :refer :all])
|
||||||
(:import [com.badlogic.gdx.graphics Color]))
|
(:import [com.badlogic.gdx.graphics Color]
|
||||||
|
[com.badlogic.gdx Application Gdx]))
|
||||||
|
|
||||||
(println "loading " *ns*)
|
(println "loading " *ns*)
|
||||||
|
|
||||||
@@ -377,8 +378,15 @@
|
|||||||
:label "Pit of destiny"
|
:label "Pit of destiny"
|
||||||
:cursor :look
|
:cursor :look
|
||||||
:script (actions/get-script entities
|
:script (actions/get-script entities
|
||||||
(actions/walk-to entities :ego [154 41])
|
(println "billing purchased before" @@(resolve 'advent.core/has-purchased?))
|
||||||
(actions/talk entities :ego "Wow! That's a long way down."))
|
|
||||||
|
(when-not @@(resolve 'advent.core/has-purchased?)
|
||||||
|
(.triggerPurchase (Gdx/app))
|
||||||
|
(a/<!! @(resolve 'advent.android/purchase-chan)))
|
||||||
|
(println "billing purchased now:" @@(resolve 'advent.core/has-purchased?))
|
||||||
|
(when @@(resolve 'advent.core/has-purchased?)
|
||||||
|
(actions/walk-to entities :ego [154 41])
|
||||||
|
(actions/talk entities :ego "Wow! That's a long way down.")))
|
||||||
:scripts {:shovel (actions/get-script entities
|
:scripts {:shovel (actions/get-script entities
|
||||||
(actions/walk-to entities :ego [154 41])
|
(actions/walk-to entities :ego [154 41])
|
||||||
(actions/talk entities :ego "I guess I'm doomed to be a gravedigger.")
|
(actions/talk entities :ego "I guess I'm doomed to be a gravedigger.")
|
||||||
|
|||||||
Reference in New Issue
Block a user