first stab at android.

This commit is contained in:
Bryce Covert
2017-09-21 07:28:27 -07:00
parent af87521da1
commit e02542270e
5 changed files with 41 additions and 17 deletions

View File

@@ -14,7 +14,7 @@
android:icon="@drawable/ic_launcher"
android:hardwareAccelerated="true"
android:largeHeap="true"
android:label="TicksTales">
android:label="Tick's Tales">
<activity android:name=".SplashActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
@@ -22,7 +22,9 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden" >
<intent-filter>
<action android:name='advent.core.MAIN'/>
<category android:name='android.intent.category.DEFAULT'/>

View File

@@ -1,4 +1,4 @@
(defproject advent "1.3.2-SNAPSHOT"
(defproject advent "1.3.16-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[com.badlogicgames.gdx/gdx "1.9.3" :use-resources true]
@@ -36,10 +36,10 @@
{;; Specify the path to your private
;; keystore and the the alias of the
;; key you want to sign APKs with.
;; :keystore-path "/home/user/.android/private.keystore"
;; :key-alias "mykeyalias"
;; :keystore-path "ticks-talkes-release.jks"
;; :key-alias "ticks-tales-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]}}}
:android {;; Specify the path to the Android SDK directory either

View File

@@ -2,24 +2,34 @@ package advent.core;
import clojure.lang.RT;
import clojure.lang.Symbol;
import java.util.ArrayList;
import java.util.List;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.Game;
import com.android.billingclient.api.*;
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;
@Override
public void onPurchasesUpdated(@BillingResponse int responseCode, java.util.List<Purchase> purchases) {
System.out.println("purchases");
}
public void onCreate (android.os.Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
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.android"));
} catch (Exception e) {
System.out.println("Importing failed");
e.printStackTrace();
@@ -27,14 +37,17 @@ public class MainActivity extends AndroidApplication implements PurchasesUpdated
try {
Game game = (Game) RT.var("advent.core", "advent").deref();
System.out.println("pre-init");
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??");
mBillingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(@BillingResponse int billingResponseCode) {
System.out.println("billing go");
if (billingResponseCode == BillingResponse.OK) {
mBillingClient.queryPurchaseHistoryAsync("inapp", ((PurchaseHistoryResponseListener) RT.var("advent.android", "history-listener").deref()));
System.out.println("billing ok");
// The billing client is ready. You can query purchases here.
}