<commit_before>﻿ //////////////////////////////////////////////////////////////////////////////////////
//
//  Copyright 2012 Freshplanet (http://freshplanet.com | <EMAIL>)
//  
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//  
//    http://www.apache.org/licenses/LICENSE-2.0
//  
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//  
//////////////////////////////////////////////////////////////////////////////////////

package com.freshplanet.ane.AirFacebook
{
	import flash.desktop.NativeApplication;
	import flash.events.EventDispatcher;
	import flash.events.InvokeEvent;
	import flash.events.StatusEvent;
	import flash.external.ExtensionContext;
	import flash.system.Capabilities;
	import com.freshplanet.ane.AirFacebook.FacebookPermissionEvent;

	public class Facebook extends EventDispatcher
	{
		// --------------------------------------------------------------------------------------//
		//																						 //
		// 									   PUBLIC API										 //
		// 																						 //
		// --------------------------------------------------------------------------------------//
		
		/** Facebook is supported on iOS and Android devices. */
		public static function get isSupported() : Boolean
		{
			return Capabilities.manufacturer.indexOf("iOS") > -1 || Capabilities.manufacturer.indexOf("Android") > -1;
		}
		
		public function Facebook()
		{
			if (!_instance)
			{
				_context = ExtensionContext.createExtensionContext(EXTENSION_ID, null);
				if (!_context)
				{
					log("ERROR - Extension context is null. Please check if extension.xml is setup correctly.");
					return;
				}
				_context.addEventListener(StatusEvent.STATUS, onStatus);
				
				NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvoke);
				
				_instance = this;
			}
			else
			{
				throw Error("This is a singleton, use getInstance(), do not call the constructor directly.");
			}
		}
		
		public static function getInstance() : Facebook
		{
			return _instance ? _instance : new Facebook();
		}
		
		/**
		 * If <code>true</code>, logs will be displayed at the Actionscript level.
		 * If <code>false</code>, logs will be displayed only at the native level.
		 */
		public function get logEnabled() : Boolean
		{
			return _logEnabled;
		}
		
		
		/**
		 * This is only important on Android - if you are using stage3D for display at the time you log in to FB,
		 * set this to true to avoid the display freezing
		 */
		public function setUsingStage3D(using3d:Boolean) : void 
		{
			if(Capabilities.manufacturer.indexOf("Android") > -1) {
				_context.call('setUsingStage3D', using3d);
			}
		}
		
		public function set logEnabled( value : Boolean ) : void
		{
			_logEnabled = value;
		}
		
		/**
		 * Initialize the Facebook extension.
		 * 
		 * @param appID A Facebook application ID.
		 * @param urlSchemeSuffix (Optional) The URL Scheme Suffix to be used in scenarios where multiple iOS apps
		 * use one Facebook App ID. Must contain only lowercase letters.
		 */
		public function init( appID : String, urlSchemeSuffix : String = null ) : void
		{
			if (!isSupported) return;
			
			_context.call('init', appID, urlSchemeSuffix);
		}
		
		/**
		 * Track an activation of the app
		 */
		public function activateApp() : void
		{
			if (!isSupported) return;
			
			_context.call('activateApp');
		}
		
		
		/** True if a Facebook session is open, false otherwise. */
		public function get isSessionOpen() : Boolean
		{<commit_msg>legacy boolean for graph 1.0<commit_after>﻿ //////////////////////////////////////////////////////////////////////////////////////
//
//  Copyright 2012 Freshplanet (http://fresh<EMAIL> | <EMAIL>)
//  
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//  
//    http://www.apache.org/licenses/LICENSE-2.0
//  
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//  
//////////////////////////////////////////////////////////////////////////////////////

package com.freshplanet.ane.AirFacebook
{
	import flash.desktop.NativeApplication;
	import flash.events.EventDispatcher;
	import flash.events.InvokeEvent;
	import flash.events.StatusEvent;
	import flash.external.ExtensionContext;
	import flash.system.Capabilities;
	import com.freshplanet.ane.AirFacebook.FacebookPermissionEvent;

	public class Facebook extends EventDispatcher
	{
		// --------------------------------------------------------------------------------------//
		//																						 //
		// 									   PUBLIC API										 //
		// 																						 //
		// --------------------------------------------------------------------------------------//
		
		/** Facebook is supported on iOS and Android devices. */
		public static function get isSupported() : Boolean
		{
			return Capabilities.manufacturer.indexOf("iOS") > -1 || Capabilities.manufacturer.indexOf("Android") > -1;
		}
		
		public function Facebook()
		{
			if (!_instance)
			{
				_context = ExtensionContext.createExtensionContext(EXTENSION_ID, null);
				if (!_context)
				{
					log("ERROR - Extension context is null. Please check if extension.xml is setup correctly.");
					return;
				}
				_context.addEventListener(StatusEvent.STATUS, onStatus);
				
				NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvoke);
				
				_instance = this;
			}
			else
			{
				throw Error("This is a singleton, use getInstance(), do not call the constructor directly.");
			}
		}
		
		public static function getInstance() : Facebook
		{
			return _instance ? _instance : new Facebook();
		}
		
		/**
		 * If <code>true</code>, logs will be displayed at the Actionscript level.
		 * If <code>false</code>, logs will be displayed only at the native level.
		 */
		public function get logEnabled() : Boolean
		{
			return _logEnabled;
		}
		
		
		/**
		 * This is only important on Android - if you are using stage3D for display at the time you log in to FB,
		 * set this to true to avoid the display freezing
		 */
		public function setUsingStage3D(using3d:Boolean) : void 
		{
			if(Capabilities.manufacturer.indexOf("Android") > -1) {
				_context.call('setUsingStage3D', using3d);
			}
		}
		
		public function set logEnabled( value : Boolean ) : void
		{
			_logEnabled = value;
		}
		
		/**
		 * Initialize the Facebook extension.
		 * 
		 * @param appID             A Facebook application ID.
         * @param legacyMode        TRUE enables Graph 1.0, FALSE uses current Graph API.
		 * @param urlSchemeSuffix   (Optional) The URL Scheme Suffix to be used in scenarios where multiple iOS apps
		 *                          use one Facebook App ID. Must contain only lowercase letters.
		 */
		public function init( appID : String, legacyMode : Boolean, urlSchemeSuffix : String = null ) : void
		{
			if (!isSupported) return;
			
			_context.call('init', appID, urlSchemeSuffix, legacyMode);
		}
		
		/**
		 * Track an activation of the app
		 */
		public function activateApp() : void
		{
			if (!isSupported) return;
			
			_context.call('activateApp');
		}
		
		
		/** True if a Facebook session is open, false otherwise. */
		public function get isSessionOpen() : Boolean
		{
{'fraction_non_alphanumeric': 0.17668557025834908, 'fraction_numerical': 0.004536862003780718, 'mean_word_length': 2.0336391437308867, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 25, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7658212', 'n_tokens_mistral': 2409, 'n_tokens_neox': 1976, 'n_words': 684}