summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Barksdale <amatus@amatus.name>2013-09-01 14:38:54 -0500
committerDavid Barksdale <amatus@amatus.name>2013-09-01 14:38:54 -0500
commitcae13d7a7968eb7fca68a6d4f7b4da7adf1f24f7 (patch)
tree5990eca8cfe227c52af5271434ec01075ceb05ed
parent263608cc0d6642d793cc650e0a544e09f3d6815e (diff)
Extend SplashActivity to launch any activity.
If authenticator_activity is started without launching the main activity, neko will not be initialized and on-ui throws an exception. So instead of starting authenticator_activity directly, ask SplashActivity to do it for us and initialize neko if it wasn't already. I'm probably abusing the Intent selector, but it seems to work.
-rw-r--r--src/clojure/io/cons/carddav_sync/authenticator.clj10
-rw-r--r--src/clojure/io/cons/carddav_sync/authenticator_activity.clj2
-rw-r--r--src/java/io/cons/carddav_sync/SplashActivity.java16
3 files changed, 18 insertions, 10 deletions
diff --git a/src/clojure/io/cons/carddav_sync/authenticator.clj b/src/clojure/io/cons/carddav_sync/authenticator.clj
index c8bd349..d158494 100644
--- a/src/clojure/io/cons/carddav_sync/authenticator.clj
+++ b/src/clojure/io/cons/carddav_sync/authenticator.clj
@@ -3,7 +3,9 @@
(:import android.accounts.AccountManager
android.content.Intent
android.os.Bundle
- io.cons.carddav_sync.authenticator_activity)
+ [io.cons.carddav_sync
+ authenticator_activity
+ SplashActivity])
(:gen-class
:extends android.accounts.AbstractAccountAuthenticator
:state context
@@ -16,10 +18,12 @@
(defn -addAccount
[this response accountType authTokenType requiredFeatures options]
(log-i "addAccount")
- (let [intent (Intent. (.context this) authenticator_activity)
+ (let [selector (Intent. (.context this) authenticator_activity)
+ intent (Intent. (.context this) SplashActivity)
bundle (Bundle.)]
- (.putExtra intent AccountManager/KEY_ACCOUNT_AUTHENTICATOR_RESPONSE
+ (.putExtra selector AccountManager/KEY_ACCOUNT_AUTHENTICATOR_RESPONSE
response)
+ (.setSelector intent selector)
(.putParcelable bundle AccountManager/KEY_INTENT intent)
bundle))
diff --git a/src/clojure/io/cons/carddav_sync/authenticator_activity.clj b/src/clojure/io/cons/carddav_sync/authenticator_activity.clj
index 4e23d63..1b3e496 100644
--- a/src/clojure/io/cons/carddav_sync/authenticator_activity.clj
+++ b/src/clojure/io/cons/carddav_sync/authenticator_activity.clj
@@ -12,4 +12,4 @@
(on-ui
(set-content-view! this
(make-ui [:linear-layout {}
- [:text-view {:text "Hello from Clojure!"}]]))))
+ [:text-view {:text "Authenticator"}]]))))
diff --git a/src/java/io/cons/carddav_sync/SplashActivity.java b/src/java/io/cons/carddav_sync/SplashActivity.java
index 9bdc24e..b6b2b84 100644
--- a/src/java/io/cons/carddav_sync/SplashActivity.java
+++ b/src/java/io/cons/carddav_sync/SplashActivity.java
@@ -23,12 +23,16 @@ public class SplashActivity extends Activity {
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
+ Intent selector = getIntent().getSelector();
+ if (selector == null) {
+ selector = new Intent("io.cons.carddav_sync.MAIN");
+ }
if (firstLaunch) {
firstLaunch = false;
setupSplash();
- loadClojure();
+ loadClojure(selector);
} else {
- proceed();
+ proceed(selector);
}
}
@@ -43,12 +47,12 @@ public class SplashActivity extends Activity {
circleView.startAnimation(rotation);
}
- public void proceed() {
- startActivity(new Intent("io.cons.carddav_sync.MAIN"));
+ public void proceed(final Intent selector) {
+ startActivity(selector);
finish();
}
- public void loadClojure() {
+ public void loadClojure(final Intent selector) {
new Thread(new Runnable(){
@Override
public void run() {
@@ -59,7 +63,7 @@ public class SplashActivity extends Activity {
Var INIT = RT.var("neko.application", "init-application");
INIT.invoke(SplashActivity.this.getApplication());
- proceed();
+ proceed(selector);
}
}).start();
}