From 7f71c1d5e7e89969c40e7dbd178c7d8abc0bc5a2 Mon Sep 17 00:00:00 2001
From: akwizgran <michael@briarproject.org>
Date: Mon, 11 Mar 2013 14:24:43 +0000
Subject: [PATCH] Show a spinner while Guice is initialising.

---
 briar-android/AndroidManifest.xml             |  6 ++-
 .../briar/android/SplashScreenActivity.java   | 37 +++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100644 briar-android/src/net/sf/briar/android/SplashScreenActivity.java

diff --git a/briar-android/AndroidManifest.xml b/briar-android/AndroidManifest.xml
index 5dbdd97713..0b0771da6e 100644
--- a/briar-android/AndroidManifest.xml
+++ b/briar-android/AndroidManifest.xml
@@ -25,13 +25,17 @@
 			</intent-filter>
 		</service>
 		<activity
-			android:name=".android.HomeScreenActivity"
+			android:name=".android.SplashScreenActivity"
 			android:label="@string/app_name" >
 			<intent-filter>
 				<action android:name="android.intent.action.MAIN" />
 				<category android:name="android.intent.category.LAUNCHER" />
 			</intent-filter>
 		</activity>
+		<activity
+			android:name=".android.HomeScreenActivity"
+			android:label="@string/app_name" >
+		</activity>
 		<activity
 		    android:name=".android.contact.ContactListActivity"
 		    android:label="@string/contact_list_title" >
diff --git a/briar-android/src/net/sf/briar/android/SplashScreenActivity.java b/briar-android/src/net/sf/briar/android/SplashScreenActivity.java
new file mode 100644
index 0000000000..70821a537a
--- /dev/null
+++ b/briar-android/src/net/sf/briar/android/SplashScreenActivity.java
@@ -0,0 +1,37 @@
+package net.sf.briar.android;
+
+import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
+import static android.content.Intent.FLAG_ACTIVITY_TASK_ON_HOME;
+import static android.view.Gravity.CENTER;
+import net.sf.briar.android.widgets.CommonLayoutParams;
+import roboguice.activity.RoboSplashActivity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+
+public class SplashScreenActivity extends RoboSplashActivity {
+
+	public SplashScreenActivity() {
+		super();
+		minDisplayMs = 0;
+	}
+
+	@Override
+	public void onCreate(Bundle state) {
+		super.onCreate(null);
+		LinearLayout layout = new LinearLayout(this);
+		layout.setLayoutParams(CommonLayoutParams.MATCH_MATCH);
+		layout.setGravity(CENTER);
+		ProgressBar spinner = new ProgressBar(this);
+		spinner.setIndeterminate(true);
+		layout.addView(spinner);
+		setContentView(layout);
+	}
+
+	protected void startNextActivity() {
+		Intent i = new Intent(this, HomeScreenActivity.class);
+		i.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME);
+		startActivity(i);
+	}
+}
-- 
GitLab