Show progress bar in ActionBar while loading cached CA certificates
authorTobias Brunner <tobias@strongswan.org>
Tue, 7 Aug 2012 12:00:16 +0000 (14:00 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 13 Aug 2012 09:00:25 +0000 (11:00 +0200)
src/frontends/android/src/org/strongswan/android/ui/MainActivity.java

index d2a7eec..063d7a9 100644 (file)
@@ -24,6 +24,7 @@ import android.app.Activity;
 import android.content.Intent;
 import android.net.VpnService;
 import android.os.Bundle;
+import android.view.Window;
 
 public class MainActivity extends Activity
 {
@@ -31,6 +32,7 @@ public class MainActivity extends Activity
        public void onCreate(Bundle savedInstanceState)
        {
                super.onCreate(savedInstanceState);
+               requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
                setContentView(R.layout.main);
                startVpnService();
 
@@ -38,11 +40,19 @@ public class MainActivity extends Activity
                bar.setDisplayShowTitleEnabled(false);
 
                /* load CA certificates in a background thread */
+               setProgressBarIndeterminateVisibility(true);
                new Thread(new Runnable() {
                        @Override
                        public void run()
                        {
                                TrustedCertificateManager.getInstance().load();
+                               runOnUiThread(new Runnable() {
+                                       @Override
+                                       public void run()
+                                       {
+                                               setProgressBarIndeterminateVisibility(false);
+                                       }
+                               });
                        }
                }).start();
        }