/**	@name	isConnected
	@text	Connects to the Google Play Game Services

	@out	nil
*/
int MOAIGooglePlayServicesAndroid::_isConnected ( lua_State* L ) {

    JNI_GET_ENV ( jvm, env );
    MOAILuaState state ( L );

    jclass playserv = env->FindClass ( "com/ziplinegames/moai/MoaiGooglePlayServices" );
    if ( playserv == NULL ) {

        USLog::Print ( "MOAIGooglePlayServicesAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiGooglePlayServices" );
    } else {

        jmethodID isConnected = env->GetStaticMethodID ( playserv, "isConnected", "()Z" );
        if ( isConnected == NULL ) {

            USLog::Print ( "MOAIGooglePlayServicesAndroid: Unable to find static java method %s", "isConnected" );
        } else {

            bool success = ( bool ) env->CallStaticBooleanMethod ( playserv, isConnected );

            lua_pushboolean ( state, success );
            return 1;
        }
    }

    lua_pushboolean ( state, false );
    return 1;
}
/**	@name	submitScore
	@text	Submits a score for the passed in leaderboard

	@in		string leaderboardID
	@in		number score
	@out	nil
*/
int MOAIGooglePlayServicesAndroid::_submitScore ( lua_State* L ) {

    JNI_GET_ENV ( jvm, env );
    MOAILuaState state ( L );

    cc8* board = lua_tostring ( state, 1 );
    jlong score = lua_tonumber ( state, 2 );

    JNI_GET_JSTRING ( board, jboard );

    jclass playserv = env->FindClass ( "com/ziplinegames/moai/MoaiGooglePlayServices" );
    if ( playserv == NULL ) {

        USLog::Print ( "MOAIGooglePlayServicesAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiGooglePlayServices" );
    } else {

        jmethodID submitScore = env->GetStaticMethodID ( playserv, "submitScore", "(Ljava/lang/String;J)V" );
        if ( submitScore == NULL ) {

            USLog::Print ( "MOAIGooglePlayServicesAndroid: Unable to find static java method %s", "submitScore" );
        } else {

            env->CallStaticVoidMethod ( playserv, submitScore, jboard, score );
        }
    }

    return 0;
}
/**	@name	unlockAchievement
	@text	Grants an achievement to the player

	@in		string achievementID
	@out	nil
*/
int MOAIGooglePlayServicesAndroid::_unlockAchievement ( lua_State* L ) {

    JNI_GET_ENV ( jvm, env );
    MOAILuaState state ( L );

    cc8* ach = lua_tostring ( state, 1 );

    JNI_GET_JSTRING ( ach, jach );

    jclass playserv = env->FindClass ( "com/ziplinegames/moai/MoaiGooglePlayServices" );
    if ( playserv == NULL ) {

        USLog::Print ( "MOAIGooglePlayServicesAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiGooglePlayServices" );
    } else {

        jmethodID unlockAchievement = env->GetStaticMethodID ( playserv, "unlockAchievement", "(Ljava/lang/String;)V" );
        if ( unlockAchievement == NULL ) {

            USLog::Print ( "MOAIGooglePlayServicesAndroid: Unable to find static java method %s", "unlockAchievement" );
        } else {

            env->CallStaticVoidMethod ( playserv, unlockAchievement, jach );
        }
    }

    return 0;
}
예제 #4
0
/**	@name	isLoggedIn
	@text   Determine if twitter is currently authorized.

	@out    boolean isLoggedIn		True if logged in, false otherwise.
*/
int MOAITwitterAndroid::_isLoggedIn ( lua_State *L ) {

	MOAILuaState state ( L );

	JNI_GET_ENV ( jvm, env );

	jclass twitter = env->FindClass ( "com/ziplinegames/moai/MoaiTwitter" );
    if ( twitter == NULL ) {

		ZLLog::Print ( "MOAITwitterAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiTwitter" );
    } else {

    	jmethodID isLoggedIn = env->GetStaticMethodID ( twitter, "isLoggedIn", "()Z" );
    	if ( isLoggedIn  == NULL ) {

			ZLLog::Print ( "MOAITwitterAndroid: Unable to find static java method %s", "isLoggedIn" );
    	} else {

			jboolean isUserLoggedIn = env->CallStaticBooleanMethod ( twitter, isLoggedIn );
            lua_pushboolean( state, isUserLoggedIn );
		}
	}

	return 1;
}
예제 #5
0
/**	@name	init
	@text	Initialize Twitter.

	@in		string	consumerKey		    OAuth consumer key
	@in		string	consumerSecret	    OAuth consumer secret
	@in		string	callbackUrl			Available in Twitter developer settings.
	@out 	nil
*/
int MOAITwitterAndroid::_init ( lua_State* L ) {

	MOAILuaState state ( L );

	cc8* consumerKey = lua_tostring ( state, 1 );
	cc8* consumerSecret = lua_tostring ( state, 2 );
	cc8* callbackUrl = lua_tostring ( state, 3 );

	JNI_GET_ENV ( jvm, env );

	JNI_GET_JSTRING ( consumerKey , jconsumerKey );
	JNI_GET_JSTRING ( consumerSecret , jconsumerSecret );
	JNI_GET_JSTRING ( callbackUrl , jcallbackUrl );

	jclass twitter = env->FindClass ( "com/ziplinegames/moai/MoaiTwitter" );
    if ( twitter == NULL ) {

		ZLLog::Print ( "MOAITwitterAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiTwitter" );
    } else {

    	jmethodID init = env->GetStaticMethodID ( twitter, "init", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V" );
   		if ( init == NULL ) {

			ZLLog::Print ( "MOAITwitterAndroid: Unable to find static java method %s", "init" );
		} else {

			env->CallStaticVoidMethod ( twitter, init, jconsumerKey, jconsumerSecret, jcallbackUrl);
		}
	}

	return 0;
}
예제 #6
0
/**	@name	sendTweet
	@text   Tweet the provided text

	@opt	string	text		 The text for the tweet.
	@out 	nil
*/
int MOAITwitterAndroid::_sendTweet ( lua_State* L ) {

	MOAILuaState state ( L );

	cc8* text = lua_tostring ( state, 1 );

	JNI_GET_ENV ( jvm, env );

	JNI_GET_JSTRING ( text, jtext );

	jclass twitter = env->FindClass ( "com/ziplinegames/moai/MoaiTwitter" );
    if ( twitter == NULL ) {

		ZLLog::Print ( "MOAITwitterAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiTwitter" );
    } else {

    	jmethodID sendTweet = env->GetStaticMethodID ( twitter, "sendTweet", "(Ljava/lang/String;)V" );
   		if ( sendTweet == NULL ) {

			ZLLog::Print ( "MOAITwitterAndroid: Unable to find static java method %s", "sendTweet" );
		} else {

			env->CallStaticVoidMethod ( twitter, sendTweet, jtext );
		}
	}

	return 0;
}
예제 #7
0
/**	@name	getToken
	@text	Retrieve the Facebook login token.
				
	@out	string	token
*/
int MOAIFacebookAndroid::_getToken ( lua_State* L ) {
	
	MOAILuaState state ( L );
	
	JNI_GET_ENV ( jvm, env );
	
	jclass facebook = env->FindClass ( "com/ziplinegames/moai/MoaiFacebook" );
    if ( facebook == NULL ) {
	
		ZLLog::Print ( "MOAIFacebookAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiFacebook" );
    } else {
	
    	jmethodID getToken = env->GetStaticMethodID ( facebook, "getToken", "()Ljava/lang/String;" );
   		if ( getToken == NULL ) {
	
			ZLLog::Print ( "MOAIFacebookAndroid: Unable to find static java method %s", "getToken" );
		} else {
	
			jstring jtoken = ( jstring )env->CallStaticObjectMethod ( facebook, getToken );
			
			JNI_GET_CSTRING ( jtoken, token );

			lua_pushstring ( state, token );
			
			JNI_RELEASE_CSTRING ( jtoken, token );
			
			return 1;
		}
	}
	
	lua_pushnil ( state );

	return 1;
}
예제 #8
0
/**	@name	setTimer
	@text	Sets the timer value.

	@in 	id			Id
	@in 	value		Timer value
	@out 	nil
*/
int MOAIAppAndroid::_setTimer ( lua_State* L ) {

    MOAILuaState state ( L );

    cc8* id = lua_tostring ( state, 1 );
    int value = lua_tointeger ( state, 2 );

    JNI_GET_ENV ( jvm, env );

    JNI_GET_JSTRING ( id, jid );

    jclass moai = env->FindClass ( "com/ziplinegames/moai/Moai" );
    if ( moai == NULL ) {

        USLog::Print ( "MOAIAppAndroid: Unable to find java class %s", "com/ziplinegames/moai/Moai" );
    } else {

        jmethodID setTimer = env->GetStaticMethodID ( moai, "setTimer", "(Ljava/lang/String;I)V" );
        if ( setTimer == NULL ) {

            USLog::Print ( "MOAIAppAndroid: Unable to find static java method %s", "setTimer" );
        } else {

            env->CallStaticVoidMethod ( moai, setTimer, jid, value );
        }
    }

    return 0;
}
int MYMMOAIAmazonAnalytics::_init(lua_State* L) {
	MOAILuaState state(L);
	
	cc8* appKey = lua_tostring(state, 1);
	cc8* privateKey = lua_tostring(state, 2);
	
	JNI_GET_ENV (jvm, env);
	
	JNI_GET_JSTRING (appKey, jappKey);
	JNI_GET_JSTRING (privateKey, jprivateKey);
	
	jclass analytics = env->FindClass("com/meyume/moai/MYMAmazonAnalytics");
	if (analytics == NULL) {
		ZLLog::LogF ( ZLLog::CONSOLE, "MYMMOAIAmazonAnalytics: Unable to find java class %s", "com/meyume/moai/MYMAmazonAnalytics");
	} else {
		jmethodID init = env->GetStaticMethodID (analytics, "init", "(Ljava/lang/String;Ljava/lang/String;)V");
		if (init == NULL) {
			ZLLog::LogF ( ZLLog::CONSOLE, "MYMMOAIAmazonAnalytics: Unable to find static java method %s", "init");
		} else {
			env->CallStaticVoidMethod(analytics, init, jappKey, jprivateKey);
		}
	}
	
	return 0;
}
/**	@lua	getUserInfo
	@text	Gets the userinfo

	@out	nil
*/
int MOAITstoreGamecenterAndroid::_getUserInfo ( lua_State* L ) {

	MOAILuaState state ( L );
	bool wantsLogin = lua_toboolean ( state, 1 );

	JNI_GET_ENV ( jvm, env );

	jclass tstore = env->FindClass ( "com/ziplinegames/moai/MoaiTstoreGamecenter" );
    if ( tstore == NULL ) {
		
		ZLLog::LogF ( ZLLog::CONSOLE, "MOAITstoreGamecenterAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiTstoreGamecenter" );
    } else {

    	jmethodID getUserInfo = env->GetStaticMethodID ( tstore, "getUserInfo", "()V" );
    	if ( getUserInfo == NULL ) {

			ZLLog::LogF ( ZLLog::CONSOLE, "MOAITstoreGamecenterAndroid: Unable to find static java method %s", "getUserInfo" );
    	} else {

			env->CallStaticVoidMethod ( tstore, getUserInfo );
		}
	}

	return 0;
}
예제 #11
0
/**	@name	getStatusBarHeight
	@text	Gets the Height of an Android 3.x status bar

	@out 	number height
*/
int MOAIAppAndroid::_getStatusBarHeight ( lua_State* L ) {

	MOAILuaState state ( L );

	JNI_GET_ENV ( jvm, env );

	int outVal = 0;
	jclass moai = env->FindClass ( "com/ziplinegames/moai/Moai" );
    if ( moai == NULL ) {

		ZLLog::Print ( "MOAIAppAndroid: Unable to find java class %s", "com/ziplinegames/moai/Moai" );
    } else {

    	jmethodID getStatusBarHeight = env->GetStaticMethodID ( moai, "getStatusBarHeight", "()I" );
    	if ( getStatusBarHeight == NULL ) {

			ZLLog::Print ( "MOAIAppAndroid: Unable to find static java method %s", "getStatusBarHeight" );
    	} else {

			outVal = env->CallStaticIntMethod ( moai, getStatusBarHeight );
		}
	}

	lua_pushnumber ( L, outVal );

	return 1;
}
예제 #12
0
/**	@name	sendMail
    @text Send a mail with the passed in default values

    @in	string recipient
    @in	string subject
    @in	string message
    @out	nil
*/
int	MOAIAppAndroid::_sendMail ( lua_State* L ) {
    MOAILuaState state ( L );

	cc8* recipient = state.GetValue < cc8* >( 1, "" );
	cc8* subject = state.GetValue < cc8* >( 2, "" );
	cc8* message = state.GetValue < cc8* >( 3, "" );

    JNI_GET_ENV ( jvm, env );

	JNI_GET_JSTRING ( recipient, jrecipient );
	JNI_GET_JSTRING ( subject, jsubject );
	JNI_GET_JSTRING ( message, jmessage );

    jclass moai = env->FindClass ( "com/ziplinegames/moai/Moai" );
    if ( moai == NULL ) {

		ZLLog::Print ( "MOAIAppAndroid: Unable to find java class %s", "com/ziplinegames/moai/Moai" );
    } else {

    	jmethodID sendMail = env->GetStaticMethodID ( moai, "sendMail", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V" );
    	if ( sendMail == NULL ) {

			ZLLog::Print ( "MOAIAppAndroid: Unable to find static java method %s", "sendMail" );
    	} else {

			env->CallStaticVoidMethod ( moai, sendMail, jrecipient, jsubject, jmessage );
		}
	}

	return 0;
}
예제 #13
0
/**	@name	openURL
	@text	Open the given URL in the device browser.

	@in		string	url				The URL to open.
	@out 	nil
*/
int MOAIAppAndroid::_openURL ( lua_State* L ) {

    MOAILuaState state ( L );

    cc8* url = lua_tostring ( state, 1 );

    JNI_GET_ENV ( jvm, env );

    JNI_GET_JSTRING ( url, jurl );

    jclass moai = env->FindClass ( "com/ziplinegames/moai/Moai" );
    if ( moai == NULL ) {

        USLog::Print ( "MOAIAppAndroid: Unable to find java class %s", "com/ziplinegames/moai/Moai" );
    } else {

        jmethodID openURL = env->GetStaticMethodID ( moai, "openURL", "(Ljava/lang/String;)V" );
        if ( openURL == NULL ) {

            USLog::Print ( "MOAIAppAndroid: Unable to find static java method %s", "openURL" );
        } else {

            env->CallStaticVoidMethod ( moai, openURL, jurl );
        }
    }

    return 0;
}
예제 #14
0
/**	@name	share
	@text	Open a generic Android dialog to allow the user to share
			via email, SMS, Facebook, Twitter, etc.

	@in		string	prompt			The prompt to show the user.
	@in		string	subject			The subject of the message to share.
	@in		string	text			The text of the message to share.
	@out 	nil
*/
int MOAIAppAndroid::_share ( lua_State* L ) {

	MOAILuaState state ( L );

	cc8* prompt = lua_tostring ( state, 1 );
	cc8* subject = lua_tostring ( state, 2 );
	cc8* text = lua_tostring ( state, 3 );

	JNI_GET_ENV ( jvm, env );

	JNI_GET_JSTRING ( prompt, jprompt );
	JNI_GET_JSTRING ( subject, jsubject );
	JNI_GET_JSTRING ( text, jtext );

	jclass moai = env->FindClass ( "com/ziplinegames/moai/Moai" );
    if ( moai == NULL ) {

		ZLLog::Print ( "MOAIAppAndroid: Unable to find java class %s", "com/ziplinegames/moai/Moai" );
    } else {

    	jmethodID share = env->GetStaticMethodID ( moai, "share", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V" );
    	if ( share == NULL ) {

			ZLLog::Print ( "MOAIAppAndroid: Unable to find static java method %s", "share" );
    	} else {

			env->CallStaticVoidMethod ( moai, share, jprompt, jsubject, jtext );
		}
	}

	return 0;
}
예제 #15
0
/**	@name	sessionValid
	@text	Determine whether or not the current Facebook session is valid.
				
	@out 	boolean	valid
*/
int MOAIFacebookAndroid::_sessionValid ( lua_State* L ) {

	MOAILuaState state ( L );

	JNI_GET_ENV ( jvm, env );

	jclass facebook = env->FindClass ( "com/ziplinegames/moai/MoaiFacebook" );
    if ( facebook == NULL ) {

		ZLLog::Print ( "MOAIFacebookAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiFacebook" );
    } else {

    	jmethodID isSessionValid = env->GetStaticMethodID ( facebook, "isSessionValid", "()Z" );
    	if ( isSessionValid == NULL ) {

			ZLLog::Print ( "MOAIFacebookAndroid: Unable to find static java method %s", "isSessionValid" );
    	} else {

			jboolean jvalid = ( jboolean )env->CallStaticBooleanMethod ( facebook, isSessionValid );	

			lua_pushboolean ( state, jvalid );

			return 1;
		}
	}

	lua_pushboolean ( state, false );

	return 1;
}
예제 #16
0
/**	@name	init
	@text	Initialize Crittercism.
	
	@in		string appId			Available in Crittercism dashboard settings.
	@out	nil
*/
int MOAICrittercismAndroid::_init ( lua_State* L ) {
	
	MOAILuaState state ( L );

	cc8* identifier = lua_tostring ( state, 1 );

	JNI_GET_ENV ( jvm, env );
	
	JNI_GET_JSTRING ( identifier, jidentifier );

	jclass crittercism = env->FindClass ( "com/ziplinegames/moai/MoaiCrittercism" );
    if ( crittercism == NULL ) {

		USLog::Print ( "MOAICrittercismAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiCrittercism" );
    } else {

    	jmethodID init = env->GetStaticMethodID ( crittercism, "init", "(Ljava/lang/String;)V" );
    	if ( init == NULL ) {

			USLog::Print ( "MOAICrittercismAndroid: Unable to find static java method %s", "init" );
    	} else {

			env->CallStaticVoidMethod ( crittercism, init, jidentifier );				
		}
	}
			
	return 0;
}
예제 #17
0
/**	@name	getTimer
	@text	Gets the timer value.

	@in 	id			Id
	@out 	value		Timer value
*/
int MOAIAppAndroid::_getTimer ( lua_State* L ) {

    MOAILuaState state ( L );

    cc8* id = lua_tostring ( state, 1 );

    JNI_GET_ENV ( jvm, env );

    JNI_GET_JSTRING ( id, jid );

    int outVal = 0;
    jclass moai = env->FindClass ( "com/ziplinegames/moai/Moai" );
    if ( moai == NULL ) {

        USLog::Print ( "MOAIAppAndroid: Unable to find java class %s", "com/ziplinegames/moai/Moai" );
    } else {

        jmethodID getTimer = env->GetStaticMethodID ( moai, "getTimer", "(Ljava/lang/String;)I" );
        if ( getTimer == NULL ) {

            USLog::Print ( "MOAIAppAndroid: Unable to find static java method %s", "getTimer" );
        } else {

            outVal = env->CallStaticIntMethod ( moai, getTimer, jid );
        }
    }

    lua_pushnumber ( L, outVal );

    return 1;
}
int MYMMOAIAmazonAnalytics::_recordEvent(lua_State* L) {
	MOAILuaState state(L);
	JNI_GET_ENV (jvm, env);
	
	cc8* event = lua_tostring(state, 1);
	int count = lua_tointeger(state, 2);
	
	int top = state.GetTop ();
	jobjectArray array = (jobjectArray)env->NewObjectArray(top, env->FindClass("java/lang/String"), env->NewStringUTF(""));
	
	for ( int i = 3; i <= top; ++i ) {
		if ( state.IsType ( i, LUA_TSTRING )) {
			
			cc8* p = state.GetValue < cc8* >( i, "" );
			env->SetObjectArrayElement(array, i - 3, env->NewStringUTF(p));
		}
	}
	
	JNI_GET_JSTRING (event, jevent);
	
	jclass analytics = env->FindClass("com/meyume/moai/MYMAmazonAnalytics");
	if (analytics == NULL) {
		ZLLog::LogF ( ZLLog::CONSOLE, "MYMAmazonAnalytics: Unable to find java class %s", "com/meyume/moai/MYMAmazonAnalytics");
	} else {
		jmethodID recordEvent = env->GetStaticMethodID (analytics, "recordEvent", "(Ljava/lang/String;I[Ljava/lang/String;)V");
		if (recordEvent == NULL) {
			ZLLog::LogF ( ZLLog::CONSOLE, "MYMAmazonAnalytics: Unable to find static java method %s", "recordEvent");
		} else {
			env->CallStaticVoidMethod(analytics, recordEvent, jevent, count, array);
		}
	}
	
	return 0;
}
예제 #19
0
/**	@name	getExpirationDate
	@text	Retrieve the Facebook login token expiration date.
 
	@in		nil
	@out	string	token expiration date
 */
int	MOAIFacebookAndroid::_getExpirationDate	( lua_State* L ) {
	
	MOAILuaState state ( L );
	
	JNI_GET_ENV ( jvm, env );
	
	jclass facebook = env->FindClass ( "com/ziplinegames/moai/MoaiFacebook" );
    if ( facebook == NULL ) {
	
		ZLLog::Print ( "MOAIFacebookAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiFacebook" );
    } else {
	
    	jmethodID getExpirationDate = env->GetStaticMethodID ( facebook, "getExpirationDate", "()J" );
   		if ( getExpirationDate == NULL ) {
	
			ZLLog::Print ( "MOAIFacebookAndroid: Unable to find static java method %s", "getExpirationDate" );
		} else {
	
			jlong jexpires = env->CallStaticLongMethod ( facebook, getExpirationDate );			
			lua_pushnumber ( state, jexpires );
						
			return 1;
		}
	}
	
	lua_pushnil ( state );

	return 1;
}
예제 #20
0
/**	@name	setToken
	@text	Set the Facebook login token.
			
	@in		string	token			The login token. See Facebook documentation.
	@out 	nil
*/
int MOAIFacebookAndroid::_setToken ( lua_State* L ) {

	MOAILuaState state ( L );
	
	cc8* token = lua_tostring ( state, 1 );
	
	JNI_GET_ENV ( jvm, env );
	
	JNI_GET_JSTRING ( token, jtoken );
	
	jclass facebook = env->FindClass ( "com/ziplinegames/moai/MoaiFacebook" );
    if ( facebook == NULL ) {
	
		ZLLog::Print ( "MOAIFacebookAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiFacebook" );
    } else {
	
    	jmethodID setToken = env->GetStaticMethodID ( facebook, "setToken", "(Ljava/lang/String;)V" );
   		if ( setToken == NULL ) {
	
			ZLLog::Print ( "MOAIFacebookAndroid: Unable to find static java method %s", "setToken" );
		} else {
	
			env->CallStaticVoidMethod ( facebook, setToken, jtoken );		
		}
	}
	
	return 0;
}
예제 #21
0
/**	@name	setExpirationDate
	@text	Set the Facebook login token expiration date.
 
	@in		string	expirationDate			The login token expiration date. See Facebook documentation.
	@out 	nil
 */
int MOAIFacebookAndroid::_setExpirationDate ( lua_State* L ) {

	MOAILuaState state ( L );
	
	jlong expires = lua_tonumber ( state, 1 );
	
	JNI_GET_ENV ( jvm, env );
		
	jclass facebook = env->FindClass ( "com/ziplinegames/moai/MoaiFacebook" );
    if ( facebook == NULL ) {
	
		ZLLog::Print ( "MOAIFacebookAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiFacebook" );
    } else {
	
    	jmethodID setExpirationDate = env->GetStaticMethodID ( facebook, "setExpirationDate", "(J)V" );
   		if ( setExpirationDate == NULL ) {
	
			ZLLog::Print ( "MOAIFacebookAndroid: Unable to find static java method %s", "setExpirationDate" );
		} else {
	
			env->CallStaticVoidMethod ( facebook, setExpirationDate, expires );		
		}
	}
	
	return 0;
}
예제 #22
0
/**	@name	showBanner
	@text	Show AdMob banner.
			
	@in		string	adUnitId 
	@out 	nil
*/
int MOAIAdMobAndroid::_showBanner ( lua_State* L ) {

	MOAILuaState state ( L );
	
	cc8* adUnitId = lua_tostring ( state, 1 );
	
	JNI_GET_ENV ( jvm, env );
	
	JNI_GET_JSTRING ( adUnitId, jadUnitId );

	jclass admob = env->FindClass ( "com/ziplinegames/moai/MoaiAdMob" );
	if ( admob == NULL ) {
	
		USLog::Print ( "MOAIAdMobAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiAdMob" );
	} else {
	
		jmethodID showBanner = env->GetStaticMethodID ( admob, "showBanner", "(Ljava/lang/String;)V" );
		if ( showBanner == NULL ) {
	
			USLog::Print ( "MOAIAdMobAndroid: Unable to find static java method %s", "showBanner" );
		} else {
	
			env->CallStaticVoidMethod ( admob, showBanner, jadUnitId );		
		}
	}
	return 0;
}
예제 #23
0
/**	@name	showDialog
	@text	Show a native dialog to the user.
				
	@in		string		title			The title of the dialog box. Can be nil.
	@in		string		message			The message to show the user. Can be nil.
	@in		string		positive		The text for the positive response dialog button. Can be nil.
	@in		string		neutral			The text for the neutral response dialog button. Can be nil.
	@in		string		negative		The text for the negative response dialog button. Can be nil.
	@in		bool		cancelable		Specifies whether or not the dialog is cancelable
	@opt	function	callback		A function to callback when the dialog is dismissed. Default is nil.
	@out 	nil
*/
int MOAIDialogAndroid::_showDialog ( lua_State* L ) {
	
	MOAILuaState state ( L );	
	
	cc8* title = lua_tostring ( state, 1 );
	cc8* message = lua_tostring ( state, 2 );
	cc8* positive = lua_tostring ( state, 3 );
	cc8* neutral = lua_tostring ( state, 4 );
	cc8* negative = lua_tostring ( state, 5 );
	bool cancelable = lua_toboolean ( state, 6 );
	
	if ( state.IsType ( 7, LUA_TFUNCTION )) {
		
		// NOTE: This is fragile. We're storing the callback function in a global variable,
		// effectively. Invoking the showDialog method multiple times in succession can
		// therefore lead to unpredictable results. In fact, it's unknown how Android itself
		// handles multiple invocations - are they queued? On iOS, UIAlertView is LIFO and
		// new invocations supersede previous ones, but once dismissed, the system continues
		// down the alert stack.
		MOAIDialogAndroid::Get ().mDialogCallback.SetStrongRef ( state, 7 );
	}	
	
	JNI_GET_ENV ( jvm, env );

	JNI_GET_JSTRING ( title, jtitle );
	JNI_GET_JSTRING ( message, jmessage );
	JNI_GET_JSTRING ( positive, jpositive );
	JNI_GET_JSTRING ( neutral, jneutral );
	JNI_GET_JSTRING ( negative, jnegative );

	jclass moai = env->FindClass ( "com/ziplinegames/moai/Moai" );
    if ( moai == NULL ) {

		ZLLog::Print ( "MOAIDialogAndroid: Unable to find java class %s", "com/ziplinegames/moai/Moai" );
    } else {

    	jmethodID showDialog = env->GetStaticMethodID ( moai, "showDialog", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V" );
    	if ( showDialog == NULL ) {

			ZLLog::Print ( "MOAIDialogAndroid: Unable to find static java method %s", "showDialog" );
    	} else {

			env->CallStaticVoidMethod ( moai, showDialog, jtitle, jmessage, jpositive, jneutral, jnegative, cancelable );	
		}
	}
	
	return 0;
}
예제 #24
0
/**	@name	dismiss
	@text	Dismiss AdMob banner.
			
	@in		nil
	@out 	nil
*/
int MOAIAdMobAndroid::_dismiss ( lua_State* L ) {
	
	JNI_GET_ENV ( jvm, env );
	
	jclass admob = env->FindClass ( "com/ziplinegames/moai/MoaiAdMob" );
	if ( admob == NULL ) {	
		USLog::Print ( "MOAIAdMobAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiAdMob" );
	} else {
	
		jmethodID dismiss = env->GetStaticMethodID ( admob, "dismiss", "()V" );
		if ( dismiss == NULL ) {
	
			USLog::Print ( "MOAIAdMobAndroid: Unable to find static java method %s", "dismiss" );
		} else {
	
			env->CallStaticVoidMethod ( admob, dismiss );		
		}
	}
	return 0;
}
//----------------------------------------------------------------//
// This has to be called in a thread safe manner
void MOAIGetTouchesAndroid::SetActiveTouches ( jobjectArray touches ) {

	JNI_GET_ENV ( jvm, env );

	mTouches.clear();
	mHasPendingTouches = true;

	jsize touchCount = env->GetArrayLength(touches);

	//MOAIPrint("SetActiveTouches called with touch count: %d\n", touchCount);

	for(int i = 0; i < touchCount; ++i){
		jintArray touchJ = (jintArray)env->GetObjectArrayElement(touches, i);
		jint *element = env->GetIntArrayElements(touchJ, 0);

		Touch touch(element[0], element[1], element[2]);
		mTouches.push_back(touch);

		env->ReleaseIntArrayElements(touchJ, element, JNI_ABORT);
		env->DeleteLocalRef(touchJ);
	}
}
예제 #26
0
/**	@name	postToFeed
	@text	Post a message to the logged in users' news feed.
				
	@in		string	link			The URL that the post links to. See Facebook documentation.
	@in		string	picture			The URL of an image to include in the post. See Facebook documentation.
	@in		string	name			The name of the link. See Facebook documentation.
	@in		string	caption			The caption of the link. See Facebook documentation.
	@in		string	description		The description of the link. See Facebook documentation.
	@in		string	message			The message for the post. See Facebook documentation.
	@out 	nil
*/
int MOAIFacebookAndroid::_postToFeed ( lua_State* L ) {

	MOAILuaState state ( L );
	
	cc8* link = lua_tostring ( state, 1 );
	cc8* picture = lua_tostring ( state, 2 );
	cc8* name = lua_tostring ( state, 3 );
	cc8* caption = lua_tostring ( state, 4 );
	cc8* description = lua_tostring ( state, 5 );
	cc8* message = lua_tostring ( state, 6 );
	
	JNI_GET_ENV ( jvm, env );
	
	JNI_GET_JSTRING ( link, jlink );
	JNI_GET_JSTRING ( picture, jpicture );
	JNI_GET_JSTRING ( name, jname );
	JNI_GET_JSTRING ( caption, jcaption );
	JNI_GET_JSTRING ( description, jdescription );
	JNI_GET_JSTRING ( message, jmessage );
	
	jclass facebook = env->FindClass ( "com/ziplinegames/moai/MoaiFacebook" );
    if ( facebook == NULL ) {
	
		ZLLog::Print ( "MOAIFacebookAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiFacebook" );
    } else {
	
    	jmethodID postToFeed = env->GetStaticMethodID ( facebook, "postToFeed", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V" );
   		if ( postToFeed == NULL ) {
	
			ZLLog::Print ( "MOAIFacebookAndroid: Unable to find static java method %s", "postToFeed" );
		} else {
	
			env->CallStaticVoidMethod ( facebook, postToFeed, jlink, jpicture, jname, jcaption, jdescription, jmessage );	
		}
	}
		
	return 0;
}
예제 #27
0
/**	@lua	showAchievements
	@text	Shows the achievements

	@out	nil
*/
int MOAIGooglePlayServicesAndroid::_showAchievements ( lua_State* L ) {

	JNI_GET_ENV ( jvm, env );
	MOAILuaState state ( L );

	jclass playserv = env->FindClass ( "com/moaisdk/googleplayservices/MoaiGooglePlayServices" );
    if ( playserv == NULL ) {

		ZLLog::LogF ( 1, ZLLog::CONSOLE, "MOAIGooglePlayServicesAndroid: Unable to find java class %s", "ccom/moaisdk/googleplayservices/MoaiGooglePlayServices" );
    } else {

    	jmethodID showAchievements = env->GetStaticMethodID ( playserv, "showAchievements", "()V" );
   		if ( showAchievements == NULL ) {

			ZLLog::LogF ( 1, ZLLog::CONSOLE, "MOAIGooglePlayServicesAndroid: Unable to find static java method %s", "showAchievements" );
		} else {

			env->CallStaticVoidMethod ( playserv, showAchievements );
		}
	}

	return 0;
}
/**	@lua	pause
	@text	Pause video playback.
	
	@out	nil
*/
int MOAIMoviePlayerAndroid::_pause ( lua_State* L ) {
	
	MOAILuaState state ( L );
	
	JNI_GET_ENV ( jvm, env );
	
	jclass movie = env->FindClass ( "com/ziplinegames/moai/MoaiMoviePlayer" );
    if ( movie == NULL ) {

		ZLLog::LogF ( ZLLog::CONSOLE, "MOAIMoviePlayerAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiMoviePlayer" );
    } else {

    	jmethodID pause = env->GetStaticMethodID ( movie, "pause", "()V" );
    	if ( pause == NULL ) {

			ZLLog::LogF ( ZLLog::CONSOLE, "MOAIMoviePlayerAndroid: Unable to find static java method %s", "pause" );
    	} else {

			env->CallStaticVoidMethod ( movie, pause );	
		}
	}
	
	return 0;
}
/**	@name	showOfferWall
	@text	Displays the Tstore marketplace.
				
	@out	nil
*/
int MOAITstoreWallAndroid::_showOfferWall ( lua_State* L ) {
	
	MOAILuaState state ( L );

	JNI_GET_ENV ( jvm, env );

	jclass tstore = env->FindClass ( "com/ziplinegames/moai/MoaiTstoreWall" );
    if ( tstore == NULL ) {
	
		USLog::Print ( "MOAITstoreWallAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiTstoreWall" );
    } else {

    	jmethodID showOfferWall = env->GetStaticMethodID ( tstore, "showOfferWall", "()V" );
    	if ( showOfferWall == NULL ) {

			USLog::Print ( "MOAITstoreWallAndroid: Unable to find static java method %s", "showOfferWall" );
    	} else {

			env->CallStaticVoidMethod ( tstore, showOfferWall );				
		}
	}
		
	return 0;
}
예제 #30
0
/**	@name	stop
	@text	Stop video playback and reset the video player.
	
	@out	nil
*/
int MOAIMoviePlayerAndroid::_stop ( lua_State* L ) {
	
	MOAILuaState state ( L );

	JNI_GET_ENV ( jvm, env );
	
	jclass movie = env->FindClass ( "com/ziplinegames/moai/MoaiMoviePlayer" );
    if ( movie == NULL ) {

		ZLLog::Print ( "MOAIMoviePlayerAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiMoviePlayer" );
    } else {

    	jmethodID stop = env->GetStaticMethodID ( movie, "stop", "()V" );
    	if ( stop == NULL ) {

			ZLLog::Print ( "MOAIMoviePlayerAndroid: Unable to find static java method %s", "stop" );
    	} else {

			env->CallStaticVoidMethod ( movie, stop );
		}
	}
	
	return 0;
}