com.adobe.fre.FREContext Java Examples

The following examples show how to use com.adobe.fre.FREContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImmersiveHeightFunction.java    From air-ane-fullscreen with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public FREObject call(FREContext context, FREObject[] args) 
{
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
	{
		try
		{
			View decorView = context.getActivity().getWindow().getDecorView();
			Point outSize = new Point();
			
			decorView.getDisplay().getRealSize(outSize);
			
			return FREObject.newObject(outSize.y);
		}
		catch (Exception e0) {}
	}
	
	try { return FREObject.newObject(0); }
	catch (Exception e1) { return null; }
}
 
Example #2
Source File: ConsumeFunction.java    From AndroidInAppPurchase with Apache License 2.0 6 votes vote down vote up
@Override
public FREObject call(FREContext arg0, FREObject[] arg1)
{	
	try
	{
		FREObject sku = arg1[0];
		
		Billing.getInstance().consume(sku.getAsString());
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
	
	return null;
}
 
Example #3
Source File: InitFunction.java    From AndroidInAppPurchase with Apache License 2.0 6 votes vote down vote up
@Override
public FREObject call(FREContext arg0, FREObject[] arg1)
{
	ExtensionContext ctx = (ExtensionContext)arg0;
	
	try
	{
		FREObject input = arg1[0]; 
		String base64EncodedPublicKey = input.getAsString();
	
		Billing billing = Billing.getInstance();
		billing.init(arg0.getActivity(), ctx, base64EncodedPublicKey);
	}
	catch (Exception e)
	{ 
		e.printStackTrace();
	} 
	
	return null;
}
 
Example #4
Source File: ShowFunction.java    From ANEAdMob with Apache License 2.0 6 votes vote down vote up
public FREObject call(FREContext frectx, FREObject[] args)
{
	ExtensionContext ctx = (ExtensionContext)frectx;

	try
  {
		FREObject adID = args[0];
  	FREObject size = args[1];
  	FREObject halign = args[2];
  	FREObject valign = args[3];
  	FREObject testDevice = args[4];
  	
  	ctx._adMobMan.show(adID.getAsString(), size.getAsInt(), halign.getAsInt(), valign.getAsInt(), (testDevice != null ? testDevice.getAsString() : null));
  }
	catch(Exception e)
  {
  	e.printStackTrace();
  	ctx.dispatchStatusEventAsync("BANNER_SHOW_FAIL", e.getMessage());
  }

	return null;
}
 
Example #5
Source File: CacheInterstitialFunction.java    From ANEAdMob with Apache License 2.0 6 votes vote down vote up
public FREObject call(FREContext frectx, FREObject[] args)
{
	ExtensionContext ctx = (ExtensionContext)frectx;

	try
  {
		FREObject adID = args[0];
  	FREObject testDevice = args[1];
  	ctx._adMobMan.cacheInterstitial(adID.getAsString(), (testDevice != null ? testDevice.getAsString() : null));
  }
	catch(Exception e)
  {
  	e.printStackTrace();
  	ctx.dispatchStatusEventAsync("INTERSTITIAL_CACHE_FAIL", e.getMessage());
  }

	return null;
}
 
Example #6
Source File: InitFunction.java    From ANEAdMob with Apache License 2.0 6 votes vote down vote up
public FREObject call(FREContext frectx, FREObject[] args)
{
	ExtensionContext ctx = (ExtensionContext)frectx;
	Activity act = ctx.getActivity();

  try
  {
 		ctx._adMobMan = new AdMobManager(act, ctx);
  	
  	ctx.dispatchStatusEventAsync("INIT_OK", "");
  }
  catch(Exception e)
  {
  	e.printStackTrace();
  	ctx.dispatchStatusEventAsync("INIT_FAIL", e.getMessage());
  }

  return null;
}
 
Example #7
Source File: AndroidLicensing.java    From vpn-over-dns with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void checkLicense( FREContext freContext, Context context, String publicKey )
{
    // Log.i("vpnoverdns", "checkLicense()");
	// This sample code uses Secure.ANDROID_ID only for device identification. Strenthen this string by using as many device specific
	// string so as to make it as unique as possible as this is used for obfuscating the server response.
		
	// ANDROID_ID is a 64-bit number (as a hex string) that is randomly generated on the device's first boot and should remain 
	// constant for the lifetime of the device. This value may change if a factory reset is performed on the device.  
	String deviceId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);

	// Library calls this callback when it's done verifying with Android licensing server
	mLicenseCheckerCallback =  new AndroidLicenseCheckerCallback(freContext);
	
	// Construct the LicenseChecker object with a policy and call checkAccess(). In case a developer wants to change the policy to
	// be used he needs to replace  the "ServerManagedPolicy" with the policy name with any other policy, if required. 
	// ServerManagedPolicy is defined in License Verification Library (LVL) provided by android. 

	// ServerManagedPolicy policy = new ServerManagedPolicy(context, new AESObfuscator(SALT, context.getPackageName(), deviceId));
	StrictPolicy policy = new StrictPolicy();
	
	mChecker = new LicenseChecker(context, policy, publicKey);
	mChecker.checkAccess(mLicenseCheckerCallback);
}
 
Example #8
Source File: SslGet.java    From vpn-over-dns with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public FREObject call(FREContext ctx, FREObject passedArgs[]) {
	try {
		FREObject input1 = passedArgs[0];
		url = input1.getAsString();

		FREObject input2 = passedArgs[1];
		query = input2.getAsString();

		FREObject input3 = passedArgs[2];
		timeout = input3.getAsInt();

		new Thread(this).start();

	} catch (final Exception ex) {
		ex.printStackTrace();
	}

	return null;
}
 
Example #9
Source File: TcpInit.java    From vpn-over-dns with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public FREObject call(FREContext ctx, FREObject passedArgs[]) {
	this.ctx = ctx;

	try {
		FREObject port1_obj = passedArgs[0];
		int port1 = port1_obj.getAsInt();

		synchronized (listening_ports) {
			listening_ports.add(port1);
		}
		
		new Thread(this).start();

	} catch (final Exception ex) {
		System.err.println(ex);
		ex.printStackTrace();
	}

	return null;
}
 
Example #10
Source File: AirGooglePlayGamesReportScoreFunction.java    From ANE-Google-Play-Game-Services with Apache License 2.0 6 votes vote down vote up
@Override
public FREObject call(FREContext arg0, FREObject[] arg1) {
	// TODO Auto-generated method stub
	
	// Retrieve alert parameters
	String leaderboardId = null;
	int newScore = 0;
	try
	{
		leaderboardId = arg1[0].getAsString();
		newScore = arg1[1].getAsInt();
	}
	catch (Exception e)
	{
		e.printStackTrace();
		return null;
	}

	Extension.context.createHelperIfNeeded(arg0.getActivity());
	Extension.context.reportScore(leaderboardId, newScore);
	
	return null;
}
 
Example #11
Source File: AirGooglePlayGamesReportAchievementFunction.java    From ANE-Google-Play-Game-Services with Apache License 2.0 6 votes vote down vote up
@Override
public FREObject call(FREContext arg0, FREObject[] arg1) {
	String achievementId = null;
	double percent = 0;
	try
	{
		achievementId = arg1[0].getAsString();
		percent = arg1[1].getAsDouble();
	}
	catch (Exception e)
	{
		e.printStackTrace();
		return null;
	}

	Extension.context.createHelperIfNeeded(arg0.getActivity());
	if (percent == 0) // it means we have unlocked it.
	{
		Extension.context.reportAchivements(achievementId);
	} else
	{
		Extension.context.reportAchivements(achievementId, percent);
	}
	
	return null;
}
 
Example #12
Source File: AirGooglePlayGamesGetLeaderboardFunction.java    From ANE-Google-Play-Game-Services with Apache License 2.0 6 votes vote down vote up
@Override
  public FREObject call(FREContext arg0, FREObject[] arg1) {

      Extension.context.createHelperIfNeeded(arg0.getActivity());

      // Retrieve alert parameters
      String leaderboardId = null;
      try
      {
          leaderboardId = arg1[0].getAsString();
      }
      catch (Exception e)
      {
          e.printStackTrace();
          return null;
      }

      if( leaderboardId != null )
          Extension.context.getLeaderboard( leaderboardId );

return null;

  }
 
Example #13
Source File: AirGooglePlayGamesGetActivePlayerName.java    From ANE-Google-Play-Game-Services with Apache License 2.0 6 votes vote down vote up
@Override
public FREObject call(FREContext arg0, FREObject[] arg1) {
	
	Extension.context.createHelperIfNeeded(arg0.getActivity());
	Player player = Games.Players.getCurrentPlayer(Extension.context.getApiClient());
	
	FREObject playerName = null;
	if (player != null)
	{
		try {
			playerName = FREObject.newObject(player.getDisplayName());
		} catch (FREWrongThreadException e) {
			e.printStackTrace();
		}
	}
	
	return playerName;
}
 
Example #14
Source File: IsOperationalFunction.java    From face-detection-ane with Apache License 2.0 6 votes vote down vote up
@Override
public FREObject call( FREContext context, FREObject[] args ) {
	super.call( context, args );

	AIR.log( "FaceDetection::isOperational" );

	Activity activity = AIR.getContext().getActivity();

	FaceDetector.Builder fb = new FaceDetector.Builder( activity.getApplicationContext() );
	final FaceDetector detector = fb.build();
	try {
		return FREObject.newObject( detector.isOperational() );
	} catch( FREWrongThreadException e ) {
		e.printStackTrace();
	}

	return null;
}
 
Example #15
Source File: SetSystemUiVisibilityFunction.java    From air-ane-fullscreen with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public FREObject call(FREContext context, FREObject[] args) 
{
	try
	{
		final FullScreenContext fsc = (FullScreenContext) context;
		
		int uiOptions = args[0].getAsInt();
		
		fsc.resetUi();
		fsc.setSystemUiVisibility(uiOptions);
	}
	catch (Exception e0)
	{
		try { return FREObject.newObject(false); }
		catch (Exception e1) { return null; }
	}
	
	try { return FREObject.newObject(true); }
	catch (Exception e2) {}
	
	return null;
}
 
Example #16
Source File: ImmersiveWidthFunction.java    From air-ane-fullscreen with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public FREObject call(FREContext context, FREObject[] args) 
{
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
	{
		try
		{
			View decorView = context.getActivity().getWindow().getDecorView();
			Point outSize = new Point();
			
			decorView.getDisplay().getRealSize(outSize);
			
			return FREObject.newObject(outSize.x);
		}
		catch (Exception e0) {} 
	}
	
	try { return FREObject.newObject(0); }
	catch (Exception e1) { return null; }
}
 
Example #17
Source File: AirGooglePlayStartAtLaunch.java    From ANE-Google-Play-Game-Services with Apache License 2.0 5 votes vote down vote up
@Override
public FREObject call(FREContext arg0, FREObject[] arg1) {
	Extension.context.logEvent("AirGooglePlayStartAtLaunch");
	Intent intent = new Intent(arg0.getActivity().getApplicationContext(), SignInActivity.class);
	intent.putExtra("shouldStartSignInFlow", false);
	arg0.getActivity().startActivity(intent);
	
	return null;
}
 
Example #18
Source File: AirGooglePlayGamesShowAchievementsFunction.java    From ANE-Google-Play-Game-Services with Apache License 2.0 5 votes vote down vote up
@Override
public FREObject call(FREContext arg0, FREObject[] arg1) {

	Extension.context.createHelperIfNeeded(arg0.getActivity());
       if (Extension.context.isSignedIn()) {
       	arg0.getActivity().startActivityForResult(Games.Achievements.getAchievementsIntent(Extension.context.getApiClient()), RC_UNUSED);
       }
	
	return null;
}
 
Example #19
Source File: ShowInterstitialFunction.java    From ANEAdMob with Apache License 2.0 5 votes vote down vote up
public FREObject call(FREContext frectx, FREObject[] args)
{
	ExtensionContext ctx = (ExtensionContext)frectx;

	ctx._adMobMan.showInterstitial();

	return null;
}
 
Example #20
Source File: GetVersionFunction.java    From ANE-Crashlytics with Apache License 2.0 5 votes vote down vote up
public FREObject call(FREContext context, FREObject[] args) {
	super.call(context, args);
	
	try {
		return FREObject.newObject(Crashlytics.getInstance().getVersion());
	}
	catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
Example #21
Source File: StartFunction.java    From ANE-Crashlytics with Apache License 2.0 5 votes vote down vote up
public FREObject call(FREContext context, FREObject[] args) {
	super.call(context, args);

       final FREContext cont = context;

       final CrashlyticsListener crashlyticsListener = new CrashlyticsListener() {
           @Override
           public void crashlyticsDidDetectCrashDuringPreviousExecution(){
               cont.dispatchStatusEventAsync(Constants.AirCrashlyticsEvent_CRASH_DETECTED_DURING_PREVIOUS_EXECUTION, "No crash data");
           }
       };
       
       boolean debugMode = getBooleanFromFREObject(args[0]);
       final CrashlyticsCore crashlyticsCore = new CrashlyticsCore
               .Builder()
               .listener(crashlyticsListener)
               .build();

       final Crashlytics crashlytics = new Crashlytics.Builder().core(crashlyticsCore).build();
       final Fabric fabric = new Fabric.Builder(context.getActivity().getApplicationContext())
               .kits(crashlytics)
               .debuggable(debugMode)
               .build();
       Fabric.with(fabric);

	return null;
}
 
Example #22
Source File: SetIntFunction.java    From ANE-Crashlytics with Apache License 2.0 5 votes vote down vote up
public FREObject call(FREContext context, FREObject[] args) {
	super.call(context, args);
	
	String key = getStringFromFREObject(args[0]);
	int value = getIntFromFREObject(args[1]);
	Crashlytics.setInt(key, value);
	
	return null;
}
 
Example #23
Source File: PurchaseFunction.java    From AndroidInAppPurchase with Apache License 2.0 5 votes vote down vote up
@Override
public FREObject call(FREContext arg0, FREObject[] arg1)
{	
	try
	{
		if(Billing.getInstance().activity() == null) //don't start another activity, if there is one already
		{
			FREObject sku = arg1[0];
			FREObject type = arg1[1];
			FREObject payload = arg1[2];
			
			if(sku == null || sku.getAsString().length() == 0)
				Billing.getInstance()._ctx.dispatchStatusEventAsync("PURCHASE_ERROR", "Invalid product id.");
			else if(type == null || type.getAsString().length() == 0)
				Billing.getInstance()._ctx.dispatchStatusEventAsync("PURCHASE_ERROR", "Invalid purchase type.");
			else //everything's ok
			{
				Billing.getInstance().schedulePurchase(sku.getAsString(), type.getAsString(), (payload == null ? null : payload.getAsString()));
			
				Intent intent = new Intent(arg0.getActivity(), BillingActivity.class);
				arg0.getActivity().startActivity(intent);
			}
		}
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
	
	return null;
}
 
Example #24
Source File: SetFloatFunction.java    From ANE-Crashlytics with Apache License 2.0 5 votes vote down vote up
public FREObject call(FREContext context, FREObject[] args) {
	super.call(context, args);
	
	String key = getStringFromFREObject(args[0]);
	double value = getDoubleFromFREObject(args[1]);
	Crashlytics.setFloat(key, (float)value);
	
	return null;
}
 
Example #25
Source File: AndroidLicensingExtension.java    From vpn-over-dns with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public FREContext createContext( String extId )
{

/*
 * Creates a new instance of AndroidLicensingExtensionContext when the context is created from the actionscript code
 */
	
	//System.out.println("**** InitializeExtension:createContext");
	
	return new AndroidLicensingExtensionContext();
}
 
Example #26
Source File: InitFunction.java    From air-ane-fullscreen with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public FREObject call(FREContext context, FREObject[] args) 
{
	FullScreenContext fsc = (FullScreenContext) context;
	
	// Enable window focus change events
	fsc.init();
	
	return null;
}
 
Example #27
Source File: GetSkuDetailsFunction.java    From AndroidInAppPurchase with Apache License 2.0 5 votes vote down vote up
@Override
public FREObject call(FREContext arg0, FREObject[] arg1)
{	
	try
	{
		FREObject sku = arg1[0];
		FREObject res = FREObject.newObject("com.pozirk.payment.android.InAppSkuDetails", null);
		
		SkuDetails skuDetails = Billing.getInstance().getSKuDetails(sku.getAsString());
		
		if(skuDetails != null)
		{
			res.setProperty("_sku", FREObject.newObject(skuDetails.getSku()));
			res.setProperty("_type", FREObject.newObject(skuDetails.getType()));
			res.setProperty("_price", FREObject.newObject(skuDetails.getPrice()));
			res.setProperty("_title", FREObject.newObject(skuDetails.getTitle()));
			res.setProperty("_descr", FREObject.newObject(skuDetails.getDescription()));
			
			return res;
		}
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
	
	return null;
}
 
Example #28
Source File: Leaderboards.java    From google-play-game-services-ane with MIT License 5 votes vote down vote up
@Override
public FREObject call(FREContext context, FREObject[] args) {
	

	Intent intent = new Intent(context.getActivity(), StubActivity.class);
	intent.setAction(StubActivity.ACTION_SHOW_LEADERBOARD_BY_ID_ACTIVITY);
	context.getActivity().startActivity(intent);
	return null;
}
 
Example #29
Source File: Achievements.java    From google-play-game-services-ane with MIT License 5 votes vote down vote up
@Override
public FREObject call(FREContext context, FREObject[] arg1) {

	Intent intent = new Intent(context.getActivity(), StubActivity.class);
	intent.setAction(StubActivity.ACTION_SHOW_ACHIEVEMENTS_ACTIVITY);
	context.getActivity().startActivity(intent);
	return null;
}
 
Example #30
Source File: GetApiKeyFunction.java    From ANE-Crashlytics with Apache License 2.0 5 votes vote down vote up
public FREObject call(FREContext context, FREObject[] args) {
	super.call(context, args);
	
	try {
		Activity activity = context.getActivity();
		ApplicationInfo ai = activity.getPackageManager().getApplicationInfo(activity.getPackageName(), PackageManager.GET_META_DATA);
	    String apiKey = ai.metaData.getString("io.fabric.ApiKey");
		return FREObject.newObject(apiKey);
	}
	catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}