Skip to content

Commit

Permalink
Fewer errors, LoomDemo.java still needs lots of fixes, the fixes I ma…
Browse files Browse the repository at this point in the history
…de for others might not be lasting.
  • Loading branch information
SmilyOrg committed Mar 20, 2015
1 parent 094f336 commit 4b3e5ea
Show file tree
Hide file tree
Showing 39 changed files with 52 additions and 85 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -100,3 +100,5 @@ loom/vendor/luajit/libluajit64.a
loom/vendor/luajit/libluajit32.a
output
gems
loom/engine/SDL2/platform/android/java/bin/
loom/engine/SDL2/platform/android/java/gen/
8 changes: 4 additions & 4 deletions application/android/src/co/theengine/loomdemo/LoomAdMob.java
Expand Up @@ -11,8 +11,6 @@

import com.google.ads.*;

import org.cocos2dx.lib.Cocos2dxGLSurfaceView;

/**
* Java class that manages Admob instances. This maps directly to the platformAdMob C API
*/
Expand All @@ -26,8 +24,10 @@ private static void deferNativeCallback(String data, long callback, long payload
final long fCallback = callback;
final long fPayload = payload;
final int fType = type;

Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable() {

final Activity activity = LoomAdMob.activity;
// TODO: does this require queueEvent?
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
nativeCallback(fData, fCallback, fPayload, fType);
Expand Down
11 changes: 2 additions & 9 deletions application/android/src/co/theengine/loomdemo/LoomDemo.java
Expand Up @@ -23,11 +23,6 @@ of this software and associated documentation files (the "Software"), to deal
****************************************************************************/
package co.theengine.loomdemo;

import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxEditText;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
import org.cocos2dx.lib.Cocos2dxRenderer;

import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Configuration;
Expand Down Expand Up @@ -62,14 +57,12 @@ of this software and associated documentation files (the "Software"), to deal

import com.dolby.DolbyAudio;

import org.libsdl.app.SDLActivity;

public class LoomDemo extends Cocos2dxActivity {

private Cocos2dxGLSurfaceView mGLView;
public class LoomDemo extends SDLActivity {

public static LoomDemo instance = null;


public static String getMetadataString(Context context, String key)
{
String metaString = null;
Expand Down
Expand Up @@ -38,8 +38,6 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;

import org.cocos2dx.lib.Cocos2dxGLSurfaceView;



// Loom.Facebook API
Expand Down Expand Up @@ -242,7 +240,8 @@ public void run()
public void onComplete(Bundle values, FacebookException error)
{
final boolean fSuccess = (error == null) ? true : false;
Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable()
// TODO: does this require queueEvent?
activity.runOnUiThread(new Runnable()
{
@Override
public void run()
Expand Down Expand Up @@ -346,7 +345,8 @@ else if(exception instanceof FacebookServiceException)
}

final int fErrorCode = errorCode;
Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable()
// TODO: does this require queueEvent?
activity.runOnUiThread(new Runnable()
{
@Override
public void run()
Expand Down
14 changes: 8 additions & 6 deletions application/android/src/co/theengine/loomdemo/LoomHTTP.java
Expand Up @@ -19,8 +19,6 @@

import org.apache.http.entity.ByteArrayEntity;

import org.cocos2dx.lib.Cocos2dxGLSurfaceView;

import android.util.Log;

/**
Expand Down Expand Up @@ -97,7 +95,8 @@ public void onSuccess(byte[] binaryData) {

final String rfResponse = fResponse;

Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable() {
// TODO: does this require queueEvent?
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
// Log.d(TAG, "Main view thread submitting '" + rfResponse + "'' from queue!");
Expand Down Expand Up @@ -135,7 +134,8 @@ public void onFailure(Throwable error, String content) {

Log.d("LoomHTTP", "Failed request with message: " + content);

Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable() {
// TODO: does this require queueEvent?
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
LoomHTTP.onFailure(fContent, callback, payload);
Expand All @@ -157,7 +157,8 @@ else if(httpMethod.equals("POST"))
}
else
{
Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable()
// TODO: does this require queueEvent?
activity.runOnUiThread(new Runnable()
{
@Override
public void run() {
Expand All @@ -169,7 +170,8 @@ public void run() {
catch(Exception e)
{
Log.d("LoomHTTP", "Failed to make request due to: " + e.toString());
Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable()
// TODO: does this require queueEvent?
activity.runOnUiThread(new Runnable()
{
@Override
public void run() {
Expand Down
7 changes: 4 additions & 3 deletions application/android/src/co/theengine/loomdemo/LoomMobile.java
Expand Up @@ -10,8 +10,6 @@
import android.provider.Settings.System;
import android.net.Uri;

import org.cocos2dx.lib.Cocos2dxGLSurfaceView;



/**
Expand All @@ -29,6 +27,7 @@ public class LoomMobile

///vars
private static Activity _context;
private static Activity activity;
private static Vibrator _vibrator;
private static boolean _canVibrate;
private static Uri _customURI = null;
Expand All @@ -39,6 +38,7 @@ public class LoomMobile
public static void onCreate(Activity ctx)
{
_context = ctx;
activity = LoomAdMob.activity;

//vibration initialization
_canVibrate = false;
Expand Down Expand Up @@ -80,7 +80,8 @@ public static void onCreate(Activity ctx)
else
{
//notify that we've launched via a custom URL
Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable()
// TODO: does this require queueEvent?
activity.runOnUiThread(new Runnable()
{
@Override
public void run()
Expand Down
10 changes: 6 additions & 4 deletions application/android/src/co/theengine/loomdemo/LoomSensors.java
Expand Up @@ -14,8 +14,6 @@
import android.graphics.Matrix;
import android.util.Log;

import org.cocos2dx.lib.Cocos2dxGLSurfaceView;




Expand Down Expand Up @@ -328,6 +326,7 @@ public void onAccuracyChanged(Sensor sensor, int accuracy)
private static final String TAG = "Loom Sensors";

private static Context _context;
private static Activity activity;
private static SensorManager _sensorManager;
private static int _naturalRotation;
private static AndroidSensor[] _sensorList;
Expand All @@ -338,6 +337,7 @@ public void onAccuracyChanged(Sensor sensor, int accuracy)
public static void onCreate(Activity context)
{
_context = context;
activity = LoomAdMob.activity;

//store sensor manager
_sensorManager = (SensorManager)_context.getSystemService(Context.SENSOR_SERVICE);
Expand Down Expand Up @@ -468,7 +468,8 @@ private static void onRotationChanged(float x, float y, float z)
final float fZ = z;

///make sure to call the delegate in the main thread
Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable()
// TODO: does this require queueEvent?
activity.runOnUiThread(new Runnable()
{
@Override
public void run()
Expand All @@ -486,7 +487,8 @@ private static void onGravityChanged(float x, float y, float z)
final float fZ = z;

///make sure to call the delegate in the main thread
Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable()
// TODO: does this require queueEvent?
activity.runOnUiThread(new Runnable()
{
@Override
public void run()
Expand Down
8 changes: 5 additions & 3 deletions application/android/src/co/theengine/loomdemo/LoomTeak.java
@@ -1,14 +1,13 @@
package co.theengine.loomdemo;

import android.app.Activity;
import android.util.Log;
import android.os.Bundle;
import android.content.Intent;
import android.content.Context;

import com.CarrotInc.Carrot.Carrot;

import org.cocos2dx.lib.Cocos2dxGLSurfaceView;


public class LoomTeak
{
Expand All @@ -17,10 +16,12 @@ public class LoomTeak

static Carrot mTeak = null;

protected static Activity activity;


public static void onCreate(LoomDemo loomDemo, String facebookAppId)
{
activity = LoomAdMob.activity;
if(mTeak == null)
{
String teakKey = LoomDemo.getMetadataString(loomDemo, TEAK_SECRET_KEY);
Expand All @@ -36,7 +37,8 @@ public static void onCreate(LoomDemo loomDemo, String facebookAppId)
public void authenticationStatusChanged(int authStatus)
{
final int _authStatus = authStatus;
Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable()
// TODO: does this require queueEvent?
activity.runOnUiThread(new Runnable()
{
@Override
public void run()
Expand Down
12 changes: 7 additions & 5 deletions application/android/src/co/theengine/loomdemo/LoomVideo.java
Expand Up @@ -14,6 +14,7 @@
import android.view.ViewGroup;
import android.view.MotionEvent;
import android.view.View.OnTouchListener;
import android.view.SurfaceView;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
Expand All @@ -23,9 +24,8 @@
import android.view.KeyEvent;
import android.graphics.Color;

import org.cocos2dx.lib.Cocos2dxGLSurfaceView;


import org.libsdl.app.SDLActivity;
import org.libsdl.app.SDLActivity.SDLSurface;

/**
* Java Class that exposes Android fullscreen video playback
Expand Down Expand Up @@ -348,7 +348,8 @@ private static void cleanup()
_rootView.setBackgroundColor(Color.TRANSPARENT);

///give focus back to the main surface view after we have removed the video view
Cocos2dxGLSurfaceView.mainView.requestFocus();
// TODO: reimplement
//SDLActivity.getSurface().requestFocus();
}


Expand Down Expand Up @@ -397,7 +398,8 @@ private static void deferNativeCallback(int type, String data)
final int fType = type;
final String fData = data;

Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable()
// TODO: does this require queueEvent?
_context.runOnUiThread(new Runnable()
{
@Override
public void run()
Expand Down
Expand Up @@ -12,8 +12,6 @@
import android.webkit.WebChromeClient;
import android.widget.RelativeLayout;

import org.cocos2dx.lib.Cocos2dxGLSurfaceView;

/**
* Java class that manages WebView instances. This maps directly to the platformWebView C API
*/
Expand All @@ -28,7 +26,8 @@ private static void deferNativeCallback(String data, long callback, long payload
final long fPayload = payload;
final int fType = type;

Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable() {
// TODO: does this require queueEvent?
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
nativeCallback(fData, fCallback, fPayload, fType);
Expand Down
Expand Up @@ -21,8 +21,6 @@
import android.os.RemoteException;
import android.util.Log;

import org.cocos2dx.lib.Cocos2dxGLSurfaceView;

/**
* Provides Store functionality for Loom apps.
*
Expand Down Expand Up @@ -399,8 +397,8 @@ private static void deferNativeCallback(int type, String data)
{
final int fType = type;
final String fData = data;

Cocos2dxGLSurfaceView.mainView.queueEvent(new Runnable() {
// TODO: does this require queueEvent?
_activity.runOnUiThread(new Runnable() {
@Override
public void run() {
nativeCallback(fType, fData);
Expand Down
2 changes: 0 additions & 2 deletions loom/common/platform/platformMobileAndroid.cpp
Expand Up @@ -20,8 +20,6 @@

#include "loom/common/platform/platform.h"

#define LOOM_PLATFORM LOOM_PLATFORM_ANDROID

#if LOOM_PLATFORM == LOOM_PLATFORM_ANDROID

#include <jni.h>
Expand Down
Binary file not shown.
Binary file not shown.
10 changes: 0 additions & 10 deletions loom/engine/SDL2/platform/android/java/bin/build.prop

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

22 changes: 0 additions & 22 deletions loom/engine/SDL2/platform/android/java/gen/org/libsdl/app/R.java

This file was deleted.

2 changes: 2 additions & 0 deletions loom/engine/SDL2/platform/android/java/project.properties
Expand Up @@ -10,5 +10,7 @@
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

android.library=true

# Project target.
target=android-13

0 comments on commit 4b3e5ea

Please sign in to comment.