Browse Source

fixed conflicts

Alexander Brakowski 10 years ago
parent
commit
9d6764c74c

+ 2 - 1
AndroidManifest.xml

@@ -28,7 +28,8 @@
         <activity
             android:name="de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity"
             android:configChanges="keyboardHidden|orientation|screenSize"
-            android:label="@string/app_name" >
+            android:label="@string/app_name"
+            android:screenOrientation="portrait" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 

+ 9 - 5
src/de/tudarmstadt/informatik/hostage/ui2/activity/MainActivity.java

@@ -10,6 +10,7 @@ import android.app.FragmentTransaction;
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Configuration;
+import android.content.res.TypedArray;
 import android.os.Bundle;
 import android.support.v4.app.ActionBarDrawerToggle;
 import android.support.v4.widget.DrawerLayout;
@@ -51,15 +52,19 @@ public class MainActivity extends Activity {
 		super.onCreate(savedInstanceState);
 		MainActivity.context = getApplicationContext();
 
+		setContentView(R.layout.activity_drawer_main);
+
 		ThreatIndicatorGLRenderer.assets = getAssets();
 		ThreatIndicatorGLRenderer.setThreatLevel(0);
-
-		setContentView(R.layout.activity_drawer_main);
+		// set background color
+		TypedArray arr = getTheme().obtainStyledAttributes(
+				new int[] { android.R.attr.colorBackground });
+		ThreatIndicatorGLRenderer.setBackgroundColor(arr.getColor(0, 0xFFFFFF));
+		arr.recycle();
 
 		ActionBar actionBar = getActionBar();
 		actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE
-				| ActionBar.DISPLAY_SHOW_HOME
-				| ActionBar.DISPLAY_HOME_AS_UP);
+				| ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
 
 		mTitle = mDrawerTitle = getTitle();
 		mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
@@ -118,7 +123,6 @@ public class MainActivity extends Activity {
 		return super.onOptionsItemSelected(item);
 	}
 
-
 	@Override
 	public void setTitle(CharSequence title) {
 		mTitle = title;

+ 32 - 24
src/de/tudarmstadt/informatik/hostage/ui2/fragment/opengl/ThreatIndicatorGLRenderer.java

@@ -10,6 +10,7 @@ import javax.microedition.khronos.opengles.GL10;
 import android.content.res.AssetManager;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
+import android.graphics.Color;
 
 import android.opengl.GLES20;
 import android.opengl.GLSurfaceView.Renderer;
@@ -23,6 +24,13 @@ public class ThreatIndicatorGLRenderer implements Renderer {
 	public static void setThreatLevel(int level) {
 		threatLevel = level;
 	}
+
+	public static void setBackgroundColor(int color) {
+		backgroundColor[0] = (float)Color.red(color) / 255.0f;
+		backgroundColor[1] = (float)Color.green(color) / 255.0f;
+		backgroundColor[2] = (float)Color.blue(color) / 255.0f;
+	}
+	private static float[] backgroundColor = new float[3];
 	
 	public static AssetManager assets;
 	
@@ -42,30 +50,6 @@ public class ThreatIndicatorGLRenderer implements Renderer {
 
 	public ThreatIndicatorGLRenderer() {}
 	
-	public int loadTexture(String filePath) {
-		Bitmap bitmap = null;
-		try {
-			bitmap = BitmapFactory.decodeStream(assets.open(filePath));
-		} catch (IOException e) {
-			e.printStackTrace();
-			return 0;
-		}
-		
-		int[] names = {0};
-		GLES20.glGenTextures(1, names, 0);
-		int tex = names[0];
-		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex);
-
-		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
-		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
-		GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
-		bitmap.recycle(); // memory is now gpu -> free it
-		
-		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex);
-		
-		return tex;
-	}
-	
 	public void onSurfaceCreated(GL10 arg0, EGLConfig arg1) {
 		//GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
 		GLES20.glEnable(GLES20.GL_DEPTH_TEST);
@@ -173,6 +157,30 @@ public class ThreatIndicatorGLRenderer implements Renderer {
 		GLES20.glViewport(0, 0, width, height);
 	}
 	
+	public int loadTexture(String filePath) {
+		Bitmap bitmap = null;
+		try {
+			bitmap = BitmapFactory.decodeStream(assets.open(filePath));
+		} catch (IOException e) {
+			e.printStackTrace();
+			return 0;
+		}
+		
+		int[] names = {0};
+		GLES20.glGenTextures(1, names, 0);
+		int tex = names[0];
+		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex);
+
+		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
+		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
+		GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
+		bitmap.recycle(); // memory is now gpu -> free it
+		
+		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex);
+		
+		return tex;
+	}
+	
 	// see http://stackoverflow.com/questions/309424/read-convert-an-inputstream-to-a-string
 	private static String inputStreamToString(InputStream is) {
 	    Scanner scanner = new Scanner(is);