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
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
\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
.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE); \r
return accounts.length > 0;\r
}\r
- \r
\r
+ \r
}\r