Skip to content

Commit

Permalink
Changes made to improve UI before authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
francispotter committed Mar 14, 2011
1 parent 47c89c0 commit 70786d3
Show file tree
Hide file tree
Showing 22 changed files with 165 additions and 96 deletions.
9 changes: 2 additions & 7 deletions explorer/android/.actionScriptProperties
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,16 @@
<application path="AndroidApplication.mxml">
<airExcludes/>
</application>
<application path="/seti-android/[source path] core-src/AndroidApplication.as">
<airExcludes/>
</application>
</applications>
<modules/>
<buildCSSFiles/>
<flashCatalyst validateFlashCatalystCompatibility="false"/>
<buildTargets>
<buildTarget androidSettingsVersion="1" buildTargetName="com.adobe.flexide.multiplatform.android.platform">
<multiPlatformSettings enabled="true" includePlatformLibs="false" platformID="com.adobe.flexide.multiplatform.android.platform" version="2"/>
<airSettings airCertificatePath="/Users/francispotter/Documents/Git/SETIQuest/explorer/android/hathersage.p12" airTimestamp="true" version="1">
<airExcludes>
<pathEntry path="AndroidApplication.swf"/>
</airExcludes>
<airExcludes/>
</airSettings>
<multiPlatformSettings enabled="true" includePlatformLibs="false" platformID="com.adobe.flexide.multiplatform.android.platform" version="2"/>
<actionScriptSettings version="1"/>
</buildTarget>
<buildTarget buildTargetName="default">
Expand Down
11 changes: 6 additions & 5 deletions explorer/android/src/AndroidApplication-app.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
Values can also be 1-part or 2-part. It is not necessary to have a 3-part value.
An updated version of application must have a versionNumber value higher than the previous version. Required for namespace >= 2.5 . -->
<versionNumber>11.64.2</versionNumber>
<versionNumber>11.70.2</versionNumber>

<!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. -->
<!-- <versionLabel></versionLabel> -->
Expand Down Expand Up @@ -177,7 +177,7 @@
<!-- </iPhone> -->

<!-- Specify Android specific tags that get passed to AndroidManifest.xml file. -->
<!--<android>
<!-- <android>
<manifestAdditions>
<![CDATA[
<manifest android:installLocation="auto">
Expand All @@ -198,16 +198,17 @@
</manifest>
]]>
</manifestAdditions>
</android> -->
</android>
-->
<!-- End of the schema for adding the android specific tags in AndroidManifest.xml file -->

<android>
<manifestAdditions><![CDATA[
<manifest installLocation="auto">
<manifest android:installLocation="auto">
<!--See the Adobe AIR documentation for more information about setting Google Android permissions-->
<!--Removing the permission android.permission.INTERNET will have the side effect
of preventing you from debugging your application on your device-->
<uses-permission name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET"/>
<!--<uses-permission name="android.permission.WRITE_EXTERNAL_STORAGE"/>-->
<!--<uses-permission name="android.permission.READ_PHONE_STATE"/>-->
<!--<uses-permission name="android.permission.ACCESS_FINE_LOCATION"/>-->
Expand Down
11 changes: 9 additions & 2 deletions explorer/android/src/AndroidApplication.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
creationComplete="creationCompleteHandler(event)"
backgroundColor="#000000"
>
<!-- Embed the fonts -->
<fx:Style source="SETICore.css"/>
<fx:Script>
<![CDATA[
import com.hg94.core.AuthenticationSystem;
Expand Down Expand Up @@ -44,7 +46,12 @@
NativeApplication.nativeApplication.exit();
}
protected function explorer_creationCompleteHandler(event:FlexEvent):void
/** The AndroidAuthenticationSystem cannot be instantiated until after the SETIQuestExplorer is AddedToStage.
* That's because it needs the "stage" value, which is not yet set on creationComplete.
*/
protected function explorer_addedToStageHandler(event:Event):void
{
var rectangle:Rectangle = new Rectangle(0, 0, this.width, this.height);
this.explorer.authenticationSystem = new AndroidAuthenticationSystem(rectangle, this.stage);
Expand All @@ -56,5 +63,5 @@
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<view:SETIQuestExplorer id="explorer" height="100%" width="100%" creationComplete="explorer_creationCompleteHandler(event)"/>
<view:SETIQuestExplorer id="explorer" height="100%" width="100%" addedToStage="explorer_addedToStageHandler(event)"/>
</s:Application>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ package com.hg94.core.android
public class AndroidAuthenticationSystem extends EventDispatcher implements IAuthenticationSystem
{

protected static var queryParameterName:String = "_session_id";
protected static var sessionIDParameterName:String = "_session_id";

protected static var roleParameterName:String = "role";

protected static var authenticationPath:String = "/auth/facebook";

protected var rectangle:Rectangle;

Expand Down Expand Up @@ -61,7 +65,7 @@ package com.hg94.core.android
this.stageWebView.addEventListener(ErrorEvent.ERROR,errorHandler);
this.stageWebView.addEventListener(LocationChangeEvent.LOCATION_CHANGING,locationChangingHandler);
this.stageWebView.addEventListener(LocationChangeEvent.LOCATION_CHANGE,locationChangeHandler);
this.stageWebView.loadURL(urlRoot);
this.stageWebView.loadURL(urlRoot + AndroidAuthenticationSystem.authenticationPath);
}

/**
Expand All @@ -86,12 +90,22 @@ package com.hg94.core.android

private function locationChangeHandler(event:LocationChangeEvent):void {
if (event.location.indexOf("air_active") > 0) {
var offset:int = event.location.indexOf(AndroidAuthenticationSystem.queryParameterName);

// Add one for the equals
var session_id:String = event.location.substr(offset + AndroidAuthenticationSystem.queryParameterName.length+1);
trace("New Session ID is " + session_id);
this.sessionID = session_id;

// Get the query parameters as an object

var query:String = event.location.split( "?" )[ 1 ];
var argStrings:Array = query.split( "&" );
var args:Object = {};
while(argStrings.length) {
var arg:Array = argStrings.shift().split("=");
args[arg[0]] = arg[1];
}


// Use that to get the session ID

this.sessionID = args[AndroidAuthenticationSystem.sessionIDParameterName];
this.saveSessionID();
this.stageWebView.dispose();
this.dispatchEvent(AuthenticationEvent.getCompleteEvent());
Expand All @@ -109,7 +123,7 @@ package com.hg94.core.android

public function prepareHTTPService(httpService:HTTPService):void {
var headers:Object = httpService.headers;
headers["Cookie"] = AndroidAuthenticationSystem.queryParameterName + "=" + this.sessionID;
headers["Cookie"] = AndroidAuthenticationSystem.sessionIDParameterName + "=" + this.sessionID;
}

protected function saveSessionID():void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.hg94.core.browser
{
import com.hg94.core.IAuthenticationSystem;

import flash.events.ErrorEvent;
import flash.events.Event;

import mx.rpc.http.HTTPService;
Expand All @@ -13,9 +14,13 @@ package com.hg94.core.browser
//TODO: implement function
}


/** Web app should make sure we are logged in; just throw an error if we aren't.
*/

public function authenticate(urlRoot:String):void
{
//TODO: implement function
this.dispatchEvent(new ErrorEvent(ErrorEvent.ERROR))
}

public function prepareHTTPService(httpService:HTTPService):void
Expand Down
6 changes: 3 additions & 3 deletions explorer/core/src/SETICore.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
@font-face
{
fontFamily: "Myriad Pro";
src: url("assets/fonts/MyriadPro-Regular.otf");
src: url("/assets/fonts/MyriadPro-Regular.otf");
embedAsCFF: true;
}
@font-face
{
fontFamily: "Myriad Pro Black";
src: url("assets/fonts/MyriadPro-Black.otf");
src: url("/assets/fonts/MyriadPro-Black.otf");
embedAsCFF: true;
}
@font-face
{
fontFamily: "Myriad Pro Semibold";
src: url("assets/fonts/MyriadPro-Semibold.otf");
src: url("/assets/fonts/MyriadPro-Semibold.otf");
embedAsCFF: true;
}

16 changes: 16 additions & 0 deletions explorer/core/src/com/hg94/core/IAuthenticationSystemComponent.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.hg94.core {

import flash.display.Stage;
import flash.geom.Rectangle;



public interface IAuthenticationSystemComponent {

/** Returns a rectangle which can be used to overlay a web browser in Android.
* Might just use getBounds(this.stage) to retun its entire self.
*/

function getWebViewRegion():Rectangle;
}
}
9 changes: 0 additions & 9 deletions explorer/core/src/com/hg94/core/SessionIDManager.as

This file was deleted.

8 changes: 7 additions & 1 deletion explorer/core/src/com/hg94/seti/controller/GetUserAPICall.as
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ package com.hg94.seti.controller {
override protected function handleResult(resultXML:XML):void {
var event:GetUserAPICallCompleteEvent = new GetUserAPICallCompleteEvent();
event.isLoggedIn = (resultXML.localName() == "user");
if (!event.isLoggedIn) {
if (event.isLoggedIn) {
var user:User = new User();
user.name = resultXML.name;
user.role = resultXML.role;
this._model["user"] = user;
} else {
this._model["user"] = null;
this._authenticationSystem.logout();
}
this.dispatchEvent(event);
Expand Down
10 changes: 4 additions & 6 deletions explorer/core/src/com/hg94/seti/model/User.as
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.hg94.seti.model {

public class User {
public function User() {
}

public var assignment:Assignment;

public var username:String;

public var name:String;

public var role:String;

}
}
Loading

0 comments on commit 70786d3

Please sign in to comment.