Started swapping our ActionBar in favor of ActionBarSherlock
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / ui / activity / LandingActivity.java
index 2080790..d4301d1 100644 (file)
@@ -22,19 +22,25 @@ import android.accounts.AccountManager;
 import android.app.AlertDialog;\r
 import android.app.Dialog;\r
 import android.content.DialogInterface;\r
-import android.content.Intent;\r
 import android.content.DialogInterface.OnClickListener;\r
+import android.content.Intent;\r
 import android.os.Bundle;\r
 import android.support.v4.app.FragmentActivity;\r
+import android.view.View;\r
+import android.widget.AdapterView;\r
+import android.widget.AdapterView.OnItemClickListener;\r
+import android.widget.GridView;\r
+import android.widget.Toast;\r
 import eu.alefzero.owncloud.R;\r
 import eu.alefzero.owncloud.authenticator.AccountAuthenticator;\r
+import eu.alefzero.owncloud.ui.adapter.LandingScreenAdapter;\r
 \r
 /**\r
  * This activity is used as a landing page when the user first opens this app.\r
  * @author Lennart Rosam\r
  * \r
  */\r
-public class LandingActivity extends FragmentActivity implements OnClickListener {\r
+public class LandingActivity extends FragmentActivity implements OnClickListener, OnItemClickListener {\r
 \r
        public static final int DIALOG_SETUP_ACCOUNT = 1;\r
        \r
@@ -43,6 +49,13 @@ public class LandingActivity extends FragmentActivity implements OnClickListener
                super.onCreate(savedInstanceState);\r
                setContentView(R.layout.main);\r
                \r
+               // Fill the grid view that is only available in portrait mode\r
+               GridView landingScreenItems = (GridView) findViewById(R.id.homeScreenGrid);\r
+               if(landingScreenItems != null){\r
+                       landingScreenItems.setAdapter(new LandingScreenAdapter(this));\r
+                       landingScreenItems.setOnItemClickListener(this);\r
+               }\r
+               \r
                // Check, if there are ownCloud accounts\r
                if(!accountsAreSetup()){\r
                        showDialog(DIALOG_SETUP_ACCOUNT);\r
@@ -86,6 +99,22 @@ public class LandingActivity extends FragmentActivity implements OnClickListener
                \r
        }\r
        \r
+       @Override\r
+       /**\r
+        * Start an activity based on the selection\r
+        * the user made\r
+        */\r
+       public void onItemClick(AdapterView<?> parent, View view, int position, long id) {\r
+               Intent intent;\r
+               intent = (Intent) parent.getAdapter().getItem(position);\r
+               if(intent != null ){\r
+                       startActivity(intent);\r
+               } else {\r
+                       Toast toast = Toast.makeText(this, "Not yet implemented!", Toast.LENGTH_SHORT);\r
+                       toast.show();\r
+               } \r
+       }\r
+       \r
        /**\r
         * Checks, whether or not there are any ownCloud accounts \r
         * setup. \r
@@ -98,6 +127,6 @@ public class LandingActivity extends FragmentActivity implements OnClickListener
                                .getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE); \r
                return accounts.length > 0;\r
        }\r
-       \r
 \r
+       \r
 }\r