From baaf0fec8894513768f0ba3406a9dfe2d7ad2775 Mon Sep 17 00:00:00 2001 From: Sean Leonard Date: Thu, 7 Feb 2013 01:36:14 -0700 Subject: Change in Dashboard to startActivityForResult() ConfigurationWizard --- src/se/leap/leapclient/ConfigurationWizard.java | 6 ++++-- src/se/leap/leapclient/Dashboard.java | 20 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java index 6a7bd10c..f759b37e 100644 --- a/src/se/leap/leapclient/ConfigurationWizard.java +++ b/src/se/leap/leapclient/ConfigurationWizard.java @@ -118,8 +118,10 @@ public class ConfigurationWizard extends Activity } } - Intent dashboardIntent = new Intent(this, Dashboard.class); - startActivity(dashboardIntent); + // FIXME!! We're going to have more Fragments and listeners, flow control? + // TODO There is no testing done to know if we're okay... + setResult(RESULT_OK); + finish(); } } diff --git a/src/se/leap/leapclient/Dashboard.java b/src/se/leap/leapclient/Dashboard.java index b6110aac..dce99b1e 100644 --- a/src/se/leap/leapclient/Dashboard.java +++ b/src/se/leap/leapclient/Dashboard.java @@ -18,6 +18,8 @@ import android.widget.TextView; public class Dashboard extends Activity { + protected static final int CONFIGURE_LEAP = 0; + private static SharedPreferences preferences; private static Provider provider; @@ -34,11 +36,25 @@ public class Dashboard extends Activity { // Check if we have preferences, run configuration wizard if not // TODO We should do a better check for config that this! if (!preferences.contains("provider") ) - startActivity(new Intent(this, ProviderListActivity.class)); + startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP); else buildDashboard(); } - + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data){ + if ( requestCode == CONFIGURE_LEAP ) { + if ( resultCode == RESULT_OK ){ + // Configuration done, get our preferences again + preferences = getSharedPreferences(ConfigHelper.PREFERENCES_KEY,MODE_PRIVATE); + + buildDashboard(); + } else { + // Something went wrong... TODO figure out what + // TODO Error dialog + } + } + } private void buildDashboard() { // Get our provider -- cgit v1.2.3