X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/dc8c32fb3f7033d6fdfa7e1b64eaa77884da678a..a7a68eba53bb1067138f271e13c80d03fd55a3ed:/src/eu/alefzero/owncloud/ui/activity/LandingActivity.java diff --git a/src/eu/alefzero/owncloud/ui/activity/LandingActivity.java b/src/eu/alefzero/owncloud/ui/activity/LandingActivity.java index b8f18781..a12a31c3 100644 --- a/src/eu/alefzero/owncloud/ui/activity/LandingActivity.java +++ b/src/eu/alefzero/owncloud/ui/activity/LandingActivity.java @@ -17,24 +17,31 @@ */ package eu.alefzero.owncloud.ui.activity; +import com.actionbarsherlock.app.SherlockFragmentActivity; + import android.accounts.Account; import android.accounts.AccountManager; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; -import android.content.Intent; import android.content.DialogInterface.OnClickListener; +import android.content.Intent; import android.os.Bundle; -import android.support.v4.app.FragmentActivity; +import android.view.View; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.GridView; +import android.widget.Toast; import eu.alefzero.owncloud.R; import eu.alefzero.owncloud.authenticator.AccountAuthenticator; +import eu.alefzero.owncloud.ui.adapter.LandingScreenAdapter; /** * This activity is used as a landing page when the user first opens this app. * @author Lennart Rosam * */ -public class LandingActivity extends FragmentActivity implements OnClickListener { +public class LandingActivity extends SherlockFragmentActivity implements OnClickListener, OnItemClickListener { public static final int DIALOG_SETUP_ACCOUNT = 1; @@ -43,11 +50,36 @@ public class LandingActivity extends FragmentActivity implements OnClickListener super.onCreate(savedInstanceState); setContentView(R.layout.main); + // Fill the grid view that is only available in portrait mode + GridView landingScreenItems = (GridView) findViewById(R.id.homeScreenGrid); + if(landingScreenItems != null){ + landingScreenItems.setAdapter(new LandingScreenAdapter(this)); + landingScreenItems.setOnItemClickListener(this); + } + + // Check, if there are ownCloud accounts + if(!accountsAreSetup()){ + showDialog(DIALOG_SETUP_ACCOUNT); + } + + } + + @Override + protected void onRestart() { + super.onRestart(); // Check, if there are ownCloud accounts if(!accountsAreSetup()){ showDialog(DIALOG_SETUP_ACCOUNT); } + } + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + // Check, if there are ownCloud accounts + if(!accountsAreSetup()){ + showDialog(DIALOG_SETUP_ACCOUNT); + } } @Override @@ -70,7 +102,6 @@ public class LandingActivity extends FragmentActivity implements OnClickListener return dialog; } - @Override public void onClick(DialogInterface dialog, int which) { // In any case - we won't need it anymore dialog.dismiss(); @@ -87,6 +118,22 @@ public class LandingActivity extends FragmentActivity implements OnClickListener } + @Override + /** + * Start an activity based on the selection + * the user made + */ + public void onItemClick(AdapterView parent, View view, int position, long id) { + Intent intent; + intent = (Intent) parent.getAdapter().getItem(position); + if(intent != null ){ + startActivity(intent); + } else { + Toast toast = Toast.makeText(this, "Not yet implemented!", Toast.LENGTH_SHORT); + toast.show(); + } + } + /** * Checks, whether or not there are any ownCloud accounts * setup. @@ -99,6 +146,6 @@ public class LandingActivity extends FragmentActivity implements OnClickListener .getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE); return accounts.length > 0; } - + }