Commits

Tobias W. Kjeldsen committed 0326fae

.

  • Participants

Comments (0)

Files changed (49)

File AndroidManifest.xml

+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="dk.kjeldsen"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <application android:icon="@drawable/icon" android:label="@string/app_name" 
+    				>
+        <service android:label="@string/app_name" android:name=".pictureexplorer.WallpaperService"
+        android:permission="android.permission.BIND_WALLPAPER">
+        <intent-filter>
+            <action android:name="android.service.wallpaper.WallpaperService" />
+        </intent-filter>
+        <meta-data android:name="android.service.wallpaper"
+            android:resource="@xml/myglwallpaper" />
+    </service>
+    <activity android:label="Settings" android:name=".pictureexplorer.Preferences"
+			android:exported="true">
+		</activity>
+    </application>
+    <uses-sdk android:minSdkVersion="7" />
+     <uses-feature android:name="android.software.live_wallpaper" android:required="true" />
+
+</manifest>

File lib/gson-2.1.jar

Binary file added.

File project.properties

+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-7

File res/drawable-hdpi/ic_launcher.png

Added
New image

File res/drawable-ldpi/ic_launcher.png

Added
New image

File res/drawable-mdpi/ic_launcher.png

Added
New image

File res/layout/main.xml

+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+
+    <TextView
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:text="@string/hello" />
+
+</LinearLayout>

File res/values/strings.xml

+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="hello">Hello World!</string>
+    <string name="app_name">PictureDiscover</string>
+    <string name="description">PictureDiscover</string>
+
+</resources>

File res/xml/myglwallpaper.xml

+<?xml version="1.0" encoding="utf-8"?>
+    <wallpaper xmlns:android="http://schemas.android.com/apk/res/android" android:thumbnail="@drawable/icon"
+        android:description="@string/description" android:settingsActivity="dk.kjeldsen.pictureexplorer.Preferences"
+    />

File res/xml/preferences.xml

+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+	android:title="@string/app_name" android:key="pictureexplorer">
+	<PreferenceCategory android:title="Adjust shape type">
+		<ListPreference android:title="Choose shape"
+			android:summary="Choose between many different shapes" android:key="shape"
+			android:defaultValue="1" android:entries="@array/entities"
+			android:entryValues="@array/entities" />
+	</PreferenceCategory>
+	<PreferenceCategory android:title="Adjust entities">
+		<dk.kjeldsen.lesmotion.SeekBarPreference
+			android:key="motions" android:defaultValue="20" android:max="100"
+			android:title="How many entities do you want on screen at a given time" />
+	</PreferenceCategory>
+	<PreferenceCategory android:title="Adjust angles and movement">
+	<CheckBoxPreference android:key="ambientLightning"
+			android:title="Ambient lightning" android:summary="Use ambient lightning model"
+			android:defaultValue="false" />
+		<CheckBoxPreference android:key="tiltCon"
+			android:title="Continuous angle" android:summary="Continuously change angle of view"
+			android:defaultValue="true" />
+		<CheckBoxPreference android:key="tiltRandom"
+			android:title="Random angle" android:summary="Randomly change angle of view"
+			android:defaultValue="false" />
+		<CheckBoxPreference android:key="zoomRandom"
+			android:title="Random zoom" android:summary="Randomly change zoom of view"
+			android:defaultValue="false" />
+		<CheckBoxPreference android:key="zoomCon"
+			android:title="Continuous zoom" android:summary="Continuously change zoom of view"
+			android:defaultValue="false" />
+		<dk.kjeldsen.lesmotion.SeekBarPreference
+			android:key="tilt" android:defaultValue="150"
+			android:max="360"
+			android:title="At what angle do you want to see motions evolve" />
+		<CheckBoxPreference android:key="spinDirection"
+			android:title="Spin direction" android:summary="Spin anticlockwise"
+			android:defaultValue="false" />
+		<ListPreference android:title="Choose animation speed"
+			android:summary="How fast animation render" android:key="speed"
+			android:defaultValue="1" android:entries="@array/speed"
+			android:entryValues="@array/speed" />
+	</PreferenceCategory>
+	<PreferenceCategory android:title="Distance">
+		<ListPreference android:title="Viewing distance"
+			android:summary="How far away is your vantage point" android:key="zoom"
+			android:defaultValue="-4" android:entries="@array/zoom_intervals"
+			android:entryValues="@array/zoom_intervals" />
+	</PreferenceCategory>
+	<PreferenceCategory android:title="Adjust colours">
+		<dk.kjeldsen.lesmotion.SeekBarPreference
+			android:key="r" android:defaultValue="256" android:max="256" android:title="Red intensity" />
+		<dk.kjeldsen.lesmotion.SeekBarPreference
+			android:key="g" android:defaultValue="256" android:max="256" android:title="Green intensity" />
+		<dk.kjeldsen.lesmotion.SeekBarPreference
+			android:key="b" android:defaultValue="256" android:max="256" android:title="Blue intensity" />
+		<CheckBoxPreference android:key="dayCycle"
+			android:title="Real-world sky" android:summary="Colours change according to time of day"
+			android:defaultValue="false" />
+	</PreferenceCategory>
+</PreferenceScreen>

File src/dk/kjeldsen/pictureexplorer/Picture.java

+package dk.kjeldsen.pictureexplorer;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+
+import javax.microedition.khronos.opengles.GL10;
+
+public class Picture {
+	
+	public int r, g, b;				//Stars Color
+	public float dist;				//Stars Distance From Center
+	public float angle;				//Stars Current Angle
+	public float alpha = 1.0f;				//Staring alpha
+	
+	/** The buffer holding the vertices */
+	private FloatBuffer vertexBuffer;
+	/** The buffer holding the texture coordinates */
+	private FloatBuffer textureBuffer;
+
+	/** The initial vertex definition */
+	private float vertices[] = {
+								-1.0f, -1.0f, 0.0f, 	//Bottom Left
+								1.0f, -1.0f, 0.0f, 		//Bottom Right
+								-1.0f, 1.0f, 0.0f,	 	//Top Left
+								1.0f, 1.0f, 0.0f 		//Top Right
+													};
+	
+	/** The initial texture coordinates (u, v) */	
+	private float texture[] = {
+								0.0f, 0.0f, 
+								1.0f, 0.0f, 
+								0.0f, 1.0f, 
+								1.0f, 1.0f,
+											};
+
+	/**
+	 * The Star constructor.
+	 * 
+	 * Initiate the buffers.
+	 */
+	public Picture() {
+		//
+		ByteBuffer byteBuf = ByteBuffer.allocateDirect(vertices.length * 4);
+		byteBuf.order(ByteOrder.nativeOrder());
+		vertexBuffer = byteBuf.asFloatBuffer();
+		vertexBuffer.put(vertices);
+		vertexBuffer.position(0);
+
+		//
+		byteBuf = ByteBuffer.allocateDirect(texture.length * 4);
+		byteBuf.order(ByteOrder.nativeOrder());
+		textureBuffer = byteBuf.asFloatBuffer();
+		textureBuffer.put(texture);
+		textureBuffer.position(0);
+	}
+
+	/**
+	 * The object own drawing function.
+	 * Called from the renderer to redraw this instance
+	 * with possible changes in values.
+	 * 
+	 * @param gl - The GL Context
+	 */
+	public void draw(GL10 gl) {
+		//Enable the vertex, texture and normal state
+		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
+		gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
+		
+		//Point to our buffers
+		gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
+		gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
+		
+		//Draw the vertices as triangle strip
+		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);
+		
+		//Disable the client state before leaving
+		gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
+		gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
+	}
+}

File src/dk/kjeldsen/pictureexplorer/PictureDiscover.java

+package dk.kjeldsen.pictureexplorer;
+
+public class PictureDiscover implements Runnable {
+	
+	private static PictureDiscover instance;
+	
+	private PictureDiscover() {
+		
+	}
+	
+	public static PictureDiscover instance() {
+		if(instance == null) {
+			instance = new PictureDiscover();
+		}
+		return instance;
+	}
+
+	@Override
+	public void run() {
+		// TODO Auto-generated method stub
+		
+	}
+
+}

File src/dk/kjeldsen/pictureexplorer/PictureExplorerWallpaper.java

+package dk.kjeldsen.pictureexplorer;
+
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+import net.rbgrn.android.glwallpaperservice.GLWallpaperService;
+
+import android.content.Context;
+import android.opengl.GLSurfaceView;
+import android.opengl.GLU;
+import android.opengl.GLSurfaceView.Renderer;
+import android.util.Log;
+import android.view.MotionEvent;
+
+/**
+ * This is a port of the {@link http://nehe.gamedev.net} OpenGL 
+ * tutorials to the Android 1.5 OpenGL ES platform. Thanks to 
+ * NeHe and all contributors for their great tutorials and great 
+ * documentation. This source should be used together with the
+ * textual explanations made at {@link http://nehe.gamedev.net}.
+ * The code is based on the original Visual C++ code with all
+ * comments made. It has been altered and extended to meet the
+ * Android requirements. The Java code has according comments.
+ * 
+ * If you use this code or find it helpful, please visit and send
+ * a shout to the author under {@link http://www.insanitydesign.com/}
+ * 
+ * @DISCLAIMER
+ * This source and the whole package comes without warranty. It may or may
+ * not harm your computer or cell phone. Please use with care. Any damage
+ * cannot be related back to the author. The source has been tested on a
+ * virtual environment and scanned for viruses and has passed all tests.
+ * 
+ * 
+ * This is an interpretation of "Lesson 09: Moving Bitmaps in 3D Space"
+ * for the Google Android platform.
+ * 
+ * @author Savas Ziplies (nea/INsanityDesign)
+ */
+public class PictureExplorerWallpaper implements GLWallpaperService.Renderer {
+		
+	/*
+	 * Number Of Stars To Draw.
+	 * 
+	 * Depending on the power of your machine/phone
+	 * you should reduce the number of stars.
+	 */
+	private final int num = 50;				
+	private Pictures stars;					//Our Stars class, managing all stars
+	
+	/** Is twinkle enabled? */
+	private boolean twinkle = false;
+
+	/** Is blending enabled */
+	private boolean blend = true;
+		
+	/** The Activity Context */
+	private Context context;
+	
+	/**
+	 * Set this class as renderer for this GLSurfaceView.
+	 * Request Focus and set if focusable in touch mode to
+	 * receive the Input from Screen
+	 * 
+	 * @param context - The Activity Context
+	 */
+	public PictureExplorerWallpaper(Context context) {
+		this.context = context;
+		//Set this as Renderer
+		/*this.setRenderer(this);
+		//Request focus
+		this.requestFocus();
+		this.setFocusableInTouchMode(true);*/
+		
+		//
+	}
+	
+	private void initAmbient(GL10 gl) {
+		if (context.getSharedPreferences("lesmotion", 0).getBoolean(
+				"ambientLightning", false)) {
+			gl.glEnable(GL10.GL_LIGHTING);
+			gl.glEnable(GL10.GL_LIGHT0);
+			gl.glEnable(GL10.GL_COLOR_MATERIAL);
+			// Add ambient light
+			float ambientColor[] = { 0.2f, 0.2f, 0.2f, 1.0f }; // Color(0.2,
+																// 0.2, 0.2)
+			gl.glLightModelfv(GL10.GL_LIGHT_MODEL_AMBIENT, ambientColor, 0);
+
+			// Add positioned light
+			float lightColor0[] = { 1.0f, 1.0f, 1.0f, 1.0f }; // Color (0.5, 0.5, 0.5)
+			float lightPos0[] = { 2f, 0f, 0.5f, 1f }; // Positioned at (4,
+															// 0, 8)
+			gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightColor0, 0);
+			gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPos0, 0);
+
+			// Add positioned light
+			gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightColor0, 0);
+			gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPos0, 0);
+		} else {
+			gl.glDisable(GL10.GL_LIGHTING);
+			gl.glDisable(GL10.GL_LIGHT0);
+			gl.glDisable(GL10.GL_COLOR_MATERIAL);
+		}
+	}
+
+	/**
+	 * The Surface is created/init()
+	 */
+	public void onSurfaceCreated(GL10 gl, EGLConfig config) {		
+		//Settings
+		gl.glEnable(GL10.GL_TEXTURE_2D);					//Enable Texture Mapping
+		gl.glShadeModel(GL10.GL_SMOOTH); 					//Enable Smooth Shading
+		gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); 			//Black Background
+		gl.glClearDepthf(1.0f); 							//Depth Buffer Setup
+	
+		initAmbient(gl);
+		
+		// Really Nice Perspective Calculations
+		gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
+		
+		gl.glEnable(GL10.GL_BLEND);							//Enable blending
+		gl.glDisable(GL10.GL_DEPTH_TEST);					//Disable depth test
+		gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);		//Set The Blending Function For Translucency		
+				
+		//Initiate our stars class with the number of stars
+		stars = new Pictures(context);
+		//Load the texture for the stars once during Surface creation
+		stars.loadGLTexture(gl, this.context);
+	}
+	
+	/**
+	 * Here we do our drawing
+	 */
+	public void onDrawFrame(GL10 gl) {
+		//Clear Screen And Depth Buffer
+		gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);	
+		
+		//
+		stars.draw(gl, twinkle);
+	}
+		
+
+	/**
+	 * If the surface changes, reset the view
+	 */
+	public void onSurfaceChanged(GL10 gl, int width, int height) {
+		if(height == 0) { 						//Prevent A Divide By Zero By
+			height = 1; 						//Making Height Equal One
+		}
+		
+		//Check if the blend flag has been set to enable/disable blending
+		if(blend) {
+			gl.glEnable(GL10.GL_BLEND);			//Turn Blending On
+			gl.glDisable(GL10.GL_DEPTH_TEST);	//Turn Depth Testing Off
+			
+		} else {
+			gl.glDisable(GL10.GL_BLEND);		//Turn Blending On
+			gl.glEnable(GL10.GL_DEPTH_TEST);	//Turn Depth Testing Off
+		}
+		
+		initAmbient(gl);
+
+		gl.glViewport(0, 0, width, height); 	//Reset The Current Viewport
+		gl.glMatrixMode(GL10.GL_PROJECTION); 	//Select The Projection Matrix
+		gl.glLoadIdentity(); 					//Reset The Projection Matrix
+
+		//Calculate The Aspect Ratio Of The Window
+		GLU.gluPerspective(gl, 45.0f, (float)width / (float)height, 0.1f, 100.0f);
+
+		gl.glMatrixMode(GL10.GL_MODELVIEW); 	//Select The Modelview Matrix
+		gl.glLoadIdentity(); 					//Reset The Modelview Matrix
+	}
+	
+	/**
+     * Called when the engine is destroyed. Do any necessary clean up because
+     * at this point your renderer instance is now done for.
+     */
+    public void release() {
+    }
+	
+/* ***** Listener Events ***** */	
+	/**
+	 * Override the touch screen listener.
+	 * 
+	 * React to moves and presses on the touchscreen.
+	 */
+	/*public boolean onTouchEvent(MotionEvent event) {
+		//
+		float x = event.getX();
+        float y = event.getY();
+        
+        //A press on the screen
+        if(event.getAction() == MotionEvent.ACTION_UP) {
+        	//Define an upper area of 10% to define a lower area
+        	int upperArea = this.getHeight() / 10;
+        	int lowerArea = this.getHeight() - upperArea;
+        	
+        	//
+        	if(y > lowerArea) {
+        		//Change the blend setting if the lower area left has been pressed ( NEW ) 
+        		if(x < (this.getWidth() / 2)) {
+        			if(blend) {
+        				blend = false;
+            		} else {
+            			blend = true;
+            		}
+        			
+        		//Change the twinkle setting if the lower area right has been pressed 
+        		} else {
+        			if(twinkle) {
+        				twinkle = false;
+            		} else {
+            			twinkle = true;
+            		}	
+        		}
+        	}
+        }
+        
+        //We handled the event
+		return true;
+	}*/
+}

File src/dk/kjeldsen/pictureexplorer/Pictures.java

+package dk.kjeldsen.pictureexplorer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.Random;
+
+import javax.microedition.khronos.opengles.GL10;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.opengl.GLUtils;
+
+public class Pictures {
+	
+	private int num = 50;					//Basic number of stars	
+	private Picture[] stars;					//Hold all our star instances in this array
+		
+	private Random rand = new Random();		//Initiate Random for random values of stars
+	
+	private float zoom = -5.0f;			//Distance Away From Stars
+	private float tilt = 150.0f;				//Tilt The View
+	private float spin;						//Spin Stars
+	private float speed;
+	private boolean tiltRandom;
+	private boolean tiltCon;
+	private boolean zoomRandom;
+	private boolean zoomCon;
+	private boolean zoomOut;
+	private boolean spinDirection;
+	private boolean dayCycle;
+	private int shape;
+	
+	private int r,g,b; //Starting colours
+	
+	private Date time;
+	
+	/** Our texture pointer */
+	private int[] textures = new int[1];
+	
+	/**
+	 * Constructor for our stars holder
+	 * with the number of maximum stars.
+	 * Initiate all stars with random 
+	 * numbers.
+	 * 
+	 * @param num - Number of stars
+	 */
+	public Pictures(int num) {
+		this.num = num;
+		init();
+	}
+	
+	public Pictures(Context ctx) {
+		this.num = ctx.getSharedPreferences("pictureexplorer", 0).getInt("motions", 15);
+		this.zoom = Integer.parseInt(ctx.getSharedPreferences("pictureexplorer", 0).getString("zoom", "-2"));
+		this.speed = Float.parseFloat(ctx.getSharedPreferences("pictureexplorer", 0).getString("speed", "1"))/100000f;
+		this.tilt = ctx.getSharedPreferences("pictureexplorer", 0).getInt("tilt", 150);
+		this.tiltRandom = ctx.getSharedPreferences("pictureexplorer", 0).getBoolean("tiltRandom", false);
+		this.tiltCon = ctx.getSharedPreferences("pictureexplorer", 0).getBoolean("tiltCon", true);
+		this.zoomRandom = ctx.getSharedPreferences("pictureexplorer", 0).getBoolean("zoomRandom", false);
+		this.zoomCon = ctx.getSharedPreferences("pictureexplorer", 0).getBoolean("zoomCon", false);
+		this.spinDirection = ctx.getSharedPreferences("pictureexplorer", 0).getBoolean("spinDirection", false);
+		this.r = ctx.getSharedPreferences("pictureexplorer", 0).getInt("r", 256);
+		this.g = ctx.getSharedPreferences("pictureexplorer", 0).getInt("g", 256);
+		this.b = ctx.getSharedPreferences("pictureexplorer", 0).getInt("b", 256);
+		this.dayCycle = ctx.getSharedPreferences("pictureexplorer", 0).getBoolean("dayCycle", false);
+		this.shape = Integer.parseInt(ctx.getSharedPreferences("pictureexplorer", 0).getString("shape", "1"));
+		init();
+	}
+	
+	public void init() {
+		//Initiate the stars array
+		stars = new Picture[num];
+
+		time = new Date();
+		if(dayCycle) {
+			time.setTime(System.currentTimeMillis());
+			if(time.getHours() < 5) {
+				r=0;
+				g=2;
+				b=55;
+			} else if(time.getHours() < 7) {
+				r=0;
+				g=4;
+				b=130;
+			} else if(time.getHours() < 10) {
+				r=0;
+				g=50;
+				b=255;
+			} else if(time.getHours() < 14) {
+				r=0;
+				g=70;
+				b=255;
+			} else if(time.getHours() < 16) {
+				r=0;
+				g=60;
+				b=180;
+			} else if(time.getHours() < 18) {
+				r=10;
+				g=20;
+				b=100;
+			} else if(time.getHours() < 19) {
+				r=80;
+				g=2;
+				b=150;
+			} else if(time.getHours() < 21) {
+				r=60;
+				g=0;
+				b=130;
+			} else if(time.getHours() < 23) {
+				r=40;
+				g=0;
+				b=80;
+			} else if(time.getHours() == 23) {
+				r=30;
+				g=0;
+				b=70;
+			}
+		}
+		//Initiate our stars with random colors and increasing distance
+		for(int loop = 0; loop < num; loop++) {
+			stars[loop] = new Picture();
+			stars[loop].angle = rand.nextInt(360);
+			stars[loop].dist = ((float) loop / num) * 5f;
+			stars[loop].r = rand.nextInt(r+1)-1;
+			stars[loop].g = rand.nextInt(g+1)-1;
+			stars[loop].b = rand.nextInt(b+1)-1;
+			stars[loop].alpha = 1.0f;
+		}
+		if(tiltRandom) tilt=rand.nextInt(360);
+		if(zoomRandom) zoom=-rand.nextInt(20);
+	}
+	
+	/**
+	 * The Stars drawing function.
+	 * 
+	 * @param gl - The GL Context
+	 * @param twinkle - Twinkle on or off
+	 */
+	public void draw(GL10 gl, boolean twinkle) {
+		//Bind the star texture for all stars
+		gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
+		
+		//Slowly tilt angle
+		if(tiltCon) tilt+=0.01f;
+		if(tilt>360) tilt = 1;
+		
+		if (zoomCon) {
+			if (zoom < -15)
+				zoomOut = false;
+			if (zoom > -1)
+				zoomOut = true;
+			if (zoomOut) zoom-=0.01f;
+			else zoom+=0.01f;
+		}
+		//Iterate through all stars
+		for(int loop = 0; loop < num; loop++) {
+			//Recover the current star into an object
+			Picture star = stars[loop];
+			
+			gl.glLoadIdentity();							//Reset The Current Modelview Matrix
+
+			gl.glTranslatef(0.0f, 0.0f, zoom); 				//Zoom Into The Screen (Using The Value In 'zoom')
+			gl.glRotatef(tilt, 1.0f, 0.0f, 0.0f); 			//Tilt The View (Using The Value In 'tilt')
+			if(spinDirection) {
+				gl.glRotatef(-star.angle, 0.0f, -1.0f, 0.0f); 	//Rotate To The Current Stars Angle
+				gl.glTranslatef(star.dist, 0.0f, 0.0f); 		//Move Forward On The X Plane
+				gl.glRotatef(-star.angle, 0.0f, 1.0f, 0.0f); 	//Cancel The Current Stars Angle
+			}
+			else {
+				gl.glRotatef(-star.angle, 0.0f, 1.0f, 0.0f);
+				gl.glTranslatef(star.dist, 0.0f, 0.0f); 		//Move Forward On The X Plane
+				gl.glRotatef(-star.angle, 0.0f, -1.0f, 0.0f); 	//Cancel The Current Stars Angle
+			}
+			gl.glRotatef(-tilt, 1.0f, 0.0f, 0.0f); 			//Cancel The Screen Tilt
+			
+			//Twinkle, twinkle little star
+			if(twinkle) {
+				//Twinkle with an over drawn second star
+				gl.glColor4f(	(float)stars[(num - loop) - 1].r/255, 
+								(float)stars[(num - loop) - 1].g/255, 
+								(float)stars[(num - loop) - 1].b/255, 
+								stars[(num - loop) - 1].alpha);
+				
+				//Draw
+				star.draw(gl);
+			}
+
+			//Continuously iterate and spin all stars
+			gl.glRotatef(spin, 0.0f, 0.0f, 1.0f);
+			//Set the random star color
+			gl.glColor4f((float)star.r/255, (float)star.g/255, (float)star.b/255, stars[(num - loop) - 1].alpha);
+			
+			//Draw
+			star.draw(gl);
+
+			//Increase and decrease the values
+			spin += speed;
+			star.angle += (float) loop / num;
+			star.dist -= speed;
+			//star.alpha -= 0.01f;
+			
+			//Distance zero...
+			if(star.dist < 0.0f) {
+				//Set back to a five distance
+				star.dist += 5.0f;
+				//star.alpha += 1.0f;
+				star.r = rand.nextInt(r+1)-1;
+				star.g = rand.nextInt(g+1)-1;
+				star.b = rand.nextInt(b+1)-1;
+			}
+		}
+	}
+		
+	/**
+	 * Load the textures
+	 * 
+	 * @param gl - The GL Context
+	 * @param context - The Activity context
+	 */
+	public void loadGLTexture(GL10 gl, Context context) {
+		//Get the texture from the Android resource directory
+		int drawable = R.drawable.shape1;
+		InputStream is = context.getResources().openRawResource(drawable);
+		Bitmap bitmap = null;
+		try {
+			//BitmapFactory is an Android graphics utility for images
+			bitmap = BitmapFactory.decodeStream(is);
+
+		} finally {
+			//Always clear and close
+			try {
+				is.close();
+				is = null;
+			} catch (IOException e) {
+			}
+		}
+
+		//Generate there texture pointer
+		gl.glGenTextures(1, textures, 0);
+
+		//Create Linear Filtered Texture and bind it to texture
+		gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
+		gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
+		gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
+		GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
+		
+		//Clean up
+		bitmap.recycle();
+	}
+}

File src/dk/kjeldsen/pictureexplorer/Preferences.java

+package dk.kjeldsen.pictureexplorer;
+
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+
+public class Preferences extends PreferenceActivity {
+
+	protected void onCreate(Bundle icicle) {
+		super.onCreate(icicle);
+		getPreferenceManager().setSharedPreferencesName(
+				"pictureexplorer");
+		addPreferencesFromResource(R.xml.preferences);
+	}
+
+	@Override
+	protected void onResume() {
+		super.onResume();
+	}
+
+	@Override
+	protected void onDestroy() {
+		super.onDestroy();
+	}
+}

File src/dk/kjeldsen/pictureexplorer/WallpaperService.java

+package dk.kjeldsen.pictureexplorer;
+
+import net.rbgrn.android.glwallpaperservice.*;
+
+// Original code provided by Robert Green
+// http://www.rbgrn.net/content/354-glsurfaceview-adapted-3d-live-wallpapers
+public class WallpaperService extends GLWallpaperService {
+    public WallpaperService() {
+        super();
+    }
+    
+    public Engine onCreateEngine() {
+        MyEngine engine = new MyEngine();
+        return engine;
+    }
+    
+    class MyEngine extends GLEngine {
+        LesMotionWallpaper renderer;
+        public MyEngine() {
+            super();
+            // handle prefs, other initialization
+            renderer = new LesMotionWallpaper(getApplicationContext());
+            setRenderer(renderer);
+            setRenderMode(RENDERMODE_CONTINUOUSLY);
+        }
+        
+        public void onDestroy() {
+            super.onDestroy();
+            if (renderer != null) {
+                renderer.release();
+            }
+            renderer = null;
+        }
+    }
+}

File src/gsearch/.svn/all-wcprops

+K 25
+svn:wc:ra_dav:version-url
+V 59
+/svn/!svn/ver/41/trunk/gsearch-java-client/src/main/gsearch
+END
+ToStringBuilder.java
+K 25
+svn:wc:ra_dav:version-url
+V 80
+/svn/!svn/ver/22/trunk/gsearch-java-client/src/main/gsearch/ToStringBuilder.java
+END
+Image.java
+K 25
+svn:wc:ra_dav:version-url
+V 70
+/svn/!svn/ver/21/trunk/gsearch-java-client/src/main/gsearch/Image.java
+END
+PhoneNumber.java
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/svn/!svn/ver/21/trunk/gsearch-java-client/src/main/gsearch/PhoneNumber.java
+END
+OrderBy.java
+K 25
+svn:wc:ra_dav:version-url
+V 72
+/svn/!svn/ver/34/trunk/gsearch-java-client/src/main/gsearch/OrderBy.java
+END
+NewsTopic.java
+K 25
+svn:wc:ra_dav:version-url
+V 73
+/svn/!svn/ver/3/trunk/gsearch-java-client/src/main/gsearch/NewsTopic.java
+END
+Response.java
+K 25
+svn:wc:ra_dav:version-url
+V 73
+/svn/!svn/ver/12/trunk/gsearch-java-client/src/main/gsearch/Response.java
+END
+Result.java
+K 25
+svn:wc:ra_dav:version-url
+V 71
+/svn/!svn/ver/38/trunk/gsearch-java-client/src/main/gsearch/Result.java
+END
+Client.java
+K 25
+svn:wc:ra_dav:version-url
+V 71
+/svn/!svn/ver/41/trunk/gsearch-java-client/src/main/gsearch/Client.java
+END

File src/gsearch/.svn/entries

+10
+
+dir
+49
+http://gsearch-java-client.googlecode.com/svn/trunk/gsearch-java-client/src/main/gsearch
+http://gsearch-java-client.googlecode.com/svn
+
+
+
+2009-01-03T15:23:31.854877Z
+41
+sean@seansullivan.com
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+83e03bb0-c105-11dd-ae62-6dab0a2b1684
+
+ToStringBuilder.java
+file
+
+
+
+
+2012-01-24T14:02:35.361930Z
+f3ccac12f3161c5a4b7dc684bcfefbac
+2008-12-04T04:56:28.330737Z
+22
+sean@seansullivan.com
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1168
+
+Image.java
+file
+
+
+
+
+2012-01-24T14:02:35.361930Z
+c665cfb281cc3ac6114b82cabd70c546
+2008-12-04T04:53:23.403949Z
+21
+sean@seansullivan.com
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+235
+
+PhoneNumber.java
+file
+
+
+
+
+2012-01-24T14:02:35.361930Z
+581b603fc2494d1dbe5f91766da96166
+2008-12-04T04:53:23.403949Z
+21
+sean@seansullivan.com
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+724
+
+OrderBy.java
+file
+
+
+
+
+2012-01-24T14:02:35.361930Z
+4b840c8ceb407894ee80dbf306eb196a
+2008-12-11T18:19:03.536157Z
+34
+sean@seansullivan.com
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+227
+
+NewsTopic.java
+file
+
+
+
+
+2012-01-24T14:02:35.361930Z
+cc41114f0c5a812b735d4ca1a7f6b362
+2008-12-03T06:49:37.714581Z
+3
+sean@seansullivan.com
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+397
+
+internal
+dir
+
+Response.java
+file
+
+
+
+
+2012-01-24T14:02:35.361930Z
+89ea799e80442d9650c1ebe5ab76ebc1
+2008-12-03T09:03:49.378288Z
+12
+sean@seansullivan.com
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1302
+
+Result.java
+file
+
+
+
+
+2012-01-24T14:02:35.361930Z
+7ef9696577f8a7a9559ecc8c67948b0b
+2008-12-11T18:22:50.681990Z
+38
+sean@seansullivan.com
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3592
+
+Client.java
+file
+
+
+
+
+2012-01-24T14:02:35.361930Z
+978ae5d46d7d5ce2f6fe86a6173ffa13
+2009-01-03T15:23:31.854877Z
+41
+sean@seansullivan.com
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11205
+

File src/gsearch/.svn/text-base/Client.java.svn-base

+
+package gsearch;
+
+import org.apache.http.*;
+import org.apache.http.client.*;
+import org.apache.http.client.methods.*;
+import org.apache.http.client.params.AllClientPNames;
+import org.apache.http.impl.client.*;
+import org.apache.http.util.EntityUtils;
+import com.google.gson.*;
+
+import gsearch.internal.gson.*;
+import gsearch.internal.http.*;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.net.URLDecoder;
+import java.util.*;
+
+//
+//
+//   http://code.google.com/apis/ajaxsearch/documentation/#fonje
+//
+//
+//   News search examples:
+//
+//      http://ajax.googleapis.com/ajax/services/search/news?v=1.0&geo=Portland+Oregon
+//
+//      http://ajax.googleapis.com/ajax/services/search/news?v=1.0&geo=97202
+//
+//      http://ajax.googleapis.com/ajax/services/search/news?v=1.0&geo=Singapore
+//
+//   Local search example:
+//
+//      http://ajax.googleapis.com/ajax/services/search/local?v=1.0&q=coffee&sll=45.521694,-122.691806&mrt=localonly
+//
+//   Web search example:
+//
+//      http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=google+gson
+//
+//   Book search example:
+//
+//     http://ajax.googleapis.com/ajax/services/search/books?v=1.0&q=economy
+//
+//   Image search example:
+//
+//      http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=lolcats
+//
+//   Video search example:
+//
+//      http://ajax.googleapis.com/ajax/services/search/video?v=1.0&q=lolcats&orderBy=order-by-date
+//
+//   Blog search example:
+//
+//      http://ajax.googleapis.com/ajax/services/search/blogs?v=1.0&q=lolcats
+//
+//
+
+public class Client
+{
+	private HttpClient httpClient;
+	private static final String NEWS_SEARCH_ENDPOINT = "http://ajax.googleapis.com/ajax/services/search/news";
+	private static final String LOCAL_SEARCH_ENDPOINT = "http://ajax.googleapis.com/ajax/services/search/local";
+	private static final String WEB_SEARCH_ENDPOINT = "http://ajax.googleapis.com/ajax/services/search/web";
+	private static final String BOOK_SEARCH_ENDPOINT = "http://ajax.googleapis.com/ajax/services/search/books";
+	private static final String IMAGE_SEARCH_ENDPOINT = "http://ajax.googleapis.com/ajax/services/search/images";
+	private static final String VIDEO_SEARCH_ENDPOINT = "http://ajax.googleapis.com/ajax/services/search/videos";
+	private static final String BLOG_SEARCH_ENDPOINT = "http://ajax.googleapis.com/ajax/services/search/blogs";
+	
+	private boolean compressionEnabled = false;
+	
+	public Client()
+	{
+		this(new DefaultHttpClient());
+	}
+	
+	public Client(HttpClient hClient)
+	{
+		this.httpClient = hClient;
+	
+
+		//
+		//  this user agent string has been crafted this way
+		//  so that Google's service will return gzip compressed responses
+		//  when Accept-Encoding: gzip is present in the request.
+		//
+		
+		setUserAgent("Mozilla/5.0 (Java) Gecko/20081007 gsearch-java-client");
+		
+		setConnectionTimeout( 10 * 1000 );
+		setSocketTimeout(25 * 1000);
+		
+		
+	}
+	
+	public void setUserAgent(String ua)
+	{
+		this.httpClient.getParams().setParameter(AllClientPNames.USER_AGENT, ua);
+	}
+	
+	public void setConnectionTimeout(int milliseconds)
+	{
+		httpClient.getParams().setIntParameter(AllClientPNames.CONNECTION_TIMEOUT, milliseconds);
+	}
+	
+	public void setSocketTimeout(int milliseconds)
+	{
+		httpClient.getParams().setIntParameter(AllClientPNames.SO_TIMEOUT, milliseconds);
+	}
+	
+	
+	
+	protected Response sendSearchRequest(String url, Map<String, String> params)
+	{
+		
+		if (params.get("v") == null)
+		{
+			params.put("v", "1.0");
+		}
+		
+		String json = sendHttpRequest("GET", url, params);
+		
+		Response r = fromJson(json);
+		
+		r.setJson(json);
+		
+		return r;
+	}
+	
+	
+	protected Response fromJson(String json)
+	{
+		Gson gson = GsonFactory.createGson();
+		
+		Response r = gson.fromJson(json, Response.class);
+		
+		return r;
+	}
+	
+	protected String sendHttpRequest(String httpMethod, String url, Map<String, String> params)
+	{
+		HttpClient c = getHttpClient();
+		
+		HttpUriRequest request = null;
+		
+		
+		if ("GET".equalsIgnoreCase(httpMethod))
+		{
+
+
+			String queryString = buildQueryString(params);
+			
+			url = url + queryString;
+			
+			System.out.println(url);
+			
+			request = new HttpGet(url);
+			
+		}
+		else
+		{
+			throw new RuntimeException("unsupported method: " + httpMethod);
+		}
+	
+		HttpResponse response = null;
+		HttpEntity entity = null;
+		
+		try
+		{
+			response = c.execute(request);
+
+			int statusCode = response.getStatusLine().getStatusCode();
+			
+			if (statusCode != HttpStatus.SC_OK)
+			{
+				throw new RuntimeException("unexpected HTTP response status code = " + statusCode);
+			}
+			
+			entity = response.getEntity();
+			
+			return EntityUtils.toString(entity);
+		}
+		catch (Exception ex)
+		{
+			throw new RuntimeException(ex);
+		}
+		finally
+		{
+			// todo : 
+		}
+		
+	}
+	
+	private String buildQueryString(Map<String, String> params)
+	{
+		StringBuffer query = new StringBuffer();
+		
+		if (params.size() > 0)
+		{
+			query.append("?");
+			
+			for (String key : params.keySet())
+			{
+				query.append(key);
+				query.append("=");
+				query.append(encodeParameter(params.get(key)));
+				query.append("&");
+			}
+			
+			if (query.charAt(query.length() - 1) == '&')
+			{
+				query.deleteCharAt(query.length() - 1);
+			}
+		}			
+		
+		return query.toString();
+	}
+
+	protected String decode(String s)
+	{
+		try
+		{
+			return URLDecoder.decode(s, "UTF-8");
+		} 
+		catch (UnsupportedEncodingException ex)
+		{
+			throw new RuntimeException(ex);
+		}
+	}
+	
+	protected String encodeParameter(String s)
+	{
+		try
+		{
+			return URLEncoder.encode(s, "UTF-8");
+		}
+		catch (Exception ex)
+		{
+			throw new RuntimeException(ex);
+		}
+	}
+
+	protected HttpClient getHttpClient()
+	{
+		
+		if (this.httpClient instanceof DefaultHttpClient)
+		{
+			DefaultHttpClient defaultClient = (DefaultHttpClient) httpClient;
+			
+			defaultClient.removeRequestInterceptorByClass(GzipRequestInterceptor.class);
+			defaultClient.removeResponseInterceptorByClass(GzipResponseInterceptor.class);
+			
+			if (this.isCompressionEnabled())
+			{
+				defaultClient.addRequestInterceptor(GzipRequestInterceptor.getInstance());
+				defaultClient.addResponseInterceptor(GzipResponseInterceptor.getInstance());
+			}
+			
+		}
+
+		return this.httpClient;
+	}
+	
+	/**
+	 * 
+	 * @param location  use "city, state" (example: "Miami, FL") or zip code  ("97202") or country ("Singapore")
+	 * 
+	 * @return
+	 * 
+	 */
+	public List<Result> searchNewsByLocation(String location)
+	{
+		return searchNews(null, location, null);
+	}
+	
+	/**
+	 * 
+	 * @param query  may be null
+	 * @param location  use "city, state" (example: "Miami, FL") or zip code  ("97202") or country ("Singapore")
+	 * @param topic may be null
+	 * 
+	 * @return
+	 * 
+	 */
+	public List<Result> searchNews(String query, String location, NewsTopic topic)
+	{
+		Map<String, String> params = new LinkedHashMap<String, String>();
+
+		if ( (query != null) && (query.trim().length() > 0) )
+		{
+			params.put("q", query);
+		}
+		
+		if (location != null)
+		{
+			params.put("geo", location);
+		}
+		
+		if (topic != null)
+		{
+			params.put("topic", topic.getCode());
+		}
+		
+		Response r = sendNewsSearchRequest(params);
+
+		return r.getResponseData().getResults();
+	}
+
+
+	protected Response sendNewsSearchRequest(Map<String, String> params)
+	{
+		return sendSearchRequest(NEWS_SEARCH_ENDPOINT, params);
+	}
+	
+	protected Response sendLocalSearchRequest(Map<String, String> params)
+	{
+		return sendSearchRequest(LOCAL_SEARCH_ENDPOINT, params);
+	}
+	
+	protected Response sendWebSearchRequest(Map<String, String> params)
+	{
+		return sendSearchRequest(WEB_SEARCH_ENDPOINT, params);
+	}
+
+	protected Response sendBookSearchRequest(Map<String, String> params)
+	{
+		return sendSearchRequest(BOOK_SEARCH_ENDPOINT, params);
+	}
+
+	protected Response sendImageSearchRequest(Map<String, String> params)
+	{
+		return sendSearchRequest(IMAGE_SEARCH_ENDPOINT, params);
+	}
+
+	public boolean isCompressionEnabled()
+	{
+		return compressionEnabled;
+	}
+
+	public void setCompressionEnabled(boolean b)
+	{
+		this.compressionEnabled = b;
+	}
+
+	
+	
+	/**
+	 * 
+	 * 
+	 *   send HTTP GET
+	 *   
+	 *   This method can be used to retrieve images  (JPEG, PNG, GIF)
+	 *   or any other file type
+	 *   
+	 *   @return byte array
+	 *  
+	 */
+	public byte[] getBytesFromUrl(String url)
+	{
+		try
+		{
+			HttpGet get = new HttpGet(url);
+			
+			HttpResponse response = this.getHttpClient().execute(get);
+			
+			HttpEntity entity = response.getEntity();
+			
+			if (entity == null)
+			{
+				throw new RuntimeException("response body was empty");
+			}
+			
+			return EntityUtils.toByteArray(entity);
+		}
+		catch (RuntimeException ex)
+		{
+			throw ex;
+		}
+		catch (Exception ex)
+		{
+			throw new RuntimeException(ex);
+		}
+	}
+	
+	/**
+	 * 
+	 * send HTTP GET
+	 * 
+	 */
+	public String get(String url) 
+	{
+		try
+		{
+			HttpGet get = new HttpGet(url);
+			
+			HttpResponse response = this.getHttpClient().execute(get);
+			
+			HttpEntity entity = response.getEntity();
+			
+			if (entity == null)
+			{
+				throw new RuntimeException("response body was empty");
+			}
+			
+			return EntityUtils.toString(entity);
+		}
+		catch (RuntimeException ex)
+		{
+			throw ex;
+		}
+		catch (Exception ex)
+		{
+			throw new RuntimeException(ex);
+		}
+	}
+
+	public List<Result> searchNews(NewsTopic topic)
+	{
+		return searchNews(null, null, topic);
+	}
+
+	public List<Result> searchWeb(String query)
+	{
+		Map<String, String> params = new LinkedHashMap<String, String>();
+		
+		params.put("q", query);
+		
+		Response r = sendWebSearchRequest(params);
+		
+		return r.getResponseData().getResults();
+	}
+	
+
+	public List<Result> searchBooks(String query)
+	{
+		Map<String, String> params = new LinkedHashMap<String, String>();
+		
+		params.put("q", query);
+		
+		Response r = sendBookSearchRequest(params);
+		
+		return r.getResponseData().getResults();
+	}
+	
+
+	public List<Result> searchImages(String query)
+	{
+		Map<String, String> params = new LinkedHashMap<String, String>();
+		
+		params.put("q", query);
+		
+		Response r = sendImageSearchRequest(params);
+		
+		return r.getResponseData().getResults();
+	}
+	
+
+	public List<Result> searchLocal(double lat, double lon, String query)
+	{
+		Map<String, String> params = new LinkedHashMap<String, String>();
+		
+		params.put("sll", lat + "," + lon);
+		params.put("mrt", "localonly");
+		
+		if (query != null)
+		{
+			params.put("q", query);
+		}
+		
+		Response r = sendLocalSearchRequest(params);
+		
+		return r.getResponseData().getResults();
+		
+	}
+	
+	public List<Result> searchVideos(String query, OrderBy order)
+	{
+		Map<String, String> params = new LinkedHashMap<String, String>();
+		
+		params.put("q", query);
+		
+		if (order == null)
+		{
+			order = OrderBy.RELEVANCE;
+		}
+		
+		params.put("orderBy", order.getValue());
+		
+		
+		Response r = sendVideoSearchRequest(params);
+		
+		return r.getResponseData().getResults();
+	}
+
+	protected Response sendVideoSearchRequest(Map<String, String> params)
+	{
+		return sendSearchRequest(VIDEO_SEARCH_ENDPOINT, params);
+	}
+
+	public List<Result> searchBlogs(String query)
+	{
+		Map<String, String> params = new LinkedHashMap<String, String>();
+		
+		params.put("q", query);
+		
+		Response r = sendBlogSearchRequest(params);
+		
+		return r.getResponseData().getResults();
+	}
+
+	protected Response sendBlogSearchRequest(Map<String, String> params)
+	{
+		return sendSearchRequest(BLOG_SEARCH_ENDPOINT, params);
+	}
+	
+}

File src/gsearch/.svn/text-base/Image.java.svn-base

+
+package gsearch;
+
+public class Image
+{
+	private String url;
+
+	public String getUrl()
+	{
+		return url;
+	}
+
+	public void setUrl(String u)
+	{
+		this.url = u;
+	}
+	
+	public String toString()
+	{
+		return ToStringBuilder.build(this);
+	}
+	
+}

File src/gsearch/.svn/text-base/NewsTopic.java.svn-base

+package gsearch;
+
+public enum NewsTopic
+{
+	HEADLINES("h"),
+	WORLD("w"),
+	BUSINESS("b"),
+	NATION("n"),
+	SCIENCE_AND_TECHNOLOGY("t"),
+	ELECTIONS("el"),
+	POLITICS("p"),
+	ENTERTAINMENT("e"),
+	SPORTS("s"),
+	HEALTH("m"),
+	POPULAR("po"),
+	AFRICA("af"),
+	RECOMMENDED("pe");
+	
+	private String code;
+	
+	NewsTopic(String code)
+	{
+		this.code = code;
+	}
+	
+	public String getCode()
+	{
+		return this.code;
+	}
+}

File src/gsearch/.svn/text-base/OrderBy.java.svn-base

+
+package gsearch;
+
+public enum OrderBy
+{
+	RELEVANCE("order-by-relevance"), DATE("order-by-date");
+	
+	private String value;
+	
+	OrderBy(String val) 
+	{
+		value = val;
+	}
+	
+	public String getValue()
+	{
+		return this.value;
+	}
+	
+}

File src/gsearch/.svn/text-base/PhoneNumber.java.svn-base

+
+package gsearch;
+
+public class PhoneNumber
+{
+	private String type;
+	private String number;
+	
+	public String getType()
+	{
+		return type;
+	}
+
+	public void setType(String t)
+	{
+		this.type = t;
+	}
+
+
+
+	public String getNumber()
+	{
+		return number;
+	}
+
+
+
+	public void setNumber(String n)
+	{
+		this.number = n;
+	}
+
+
+
+	public boolean isMain()
+	{
+		return "main".equalsIgnoreCase(this.getType());
+	}
+	
+	public boolean isFax()
+	{
+		return "fax".equalsIgnoreCase(this.getType());
+	}
+	
+	public boolean isMobile()
+	{
+		return "mobile".equalsIgnoreCase(this.getType());
+	}
+	
+	
+	public boolean isData()
+	{
+		return "data".equalsIgnoreCase(this.getType());
+	}
+	
+	
+	public String toString()
+	{
+		return ToStringBuilder.build(this);
+	}
+	
+}

File src/gsearch/.svn/text-base/Response.java.svn-base

+
+package gsearch;
+
+import java.util.*;
+
+public class Response
+{
+	private String json;
+	private ResponseData responseData;
+	private String responseDetails;
+	private Integer responseStatus;
+	
+	public void setJson(String j)
+	{
+		this.json = j;
+	}
+
+	
+	public ResponseData getResponseData()
+	{
+		return responseData;
+	}
+
+
+	public void setResponseData(ResponseData responseData)
+	{
+		this.responseData = responseData;
+	}
+
+
+	public String getJson()
+	{
+		return json;
+	}
+
+	public boolean isOK()
+	{
+		if (this.getResponseStatus() == null)
+		{
+			return false;
+		}
+		else
+		{
+			return this.getResponseStatus().intValue() == 200;
+		}
+	}
+	
+	public boolean isError()
+	{
+		return !isOK();
+	}
+	
+
+	public String getResponseDetails()
+	{
+		return responseDetails;
+	}
+
+
+	public void setResponseDetails(String details)
+	{
+		this.responseDetails = details;
+	}
+
+
+	public Integer getResponseStatus()
+	{
+		return responseStatus;
+	}
+
+
+	public void setResponseStatus(Integer status)
+	{
+		this.responseStatus = status;
+	}
+
+
+	public static class ResponseData
+	{
+		private List<Result> results;
+		
+		public List<Result> getResults()
+		{
+			if (results == null)
+			{
+				results = new ArrayList<Result>();
+			}
+			return results;
+		}
+
+		public void setResults(List<Result> resultList)
+		{
+			this.results = resultList;
+		}
+
+	}
+	
+}