X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/dc8c32fb3f7033d6fdfa7e1b64eaa77884da678a..2d8300d8347267c1e4e12f8d7518fdc6205dd795:/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..668f134d 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,12 +50,40 @@ public class LandingActivity extends FragmentActivity implements OnClickListener super.onCreate(savedInstanceState); setContentView(R.layout.main); + // Fill the grid view of the landing screen with icons + GridView landingScreenItems = (GridView) findViewById(R.id.homeScreenGrid); + landingScreenItems.setAdapter(new LandingScreenAdapter(this)); + landingScreenItems.setOnItemClickListener(this); + // Check, if there are ownCloud accounts if(!accountsAreSetup()){ showDialog(DIALOG_SETUP_ACCOUNT); + } else { + // Start device tracking service + Intent locationServiceIntent = new Intent(); + locationServiceIntent.setAction("eu.alefzero.owncloud.location.LocationLauncher"); + sendBroadcast(locationServiceIntent); } } + + @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 protected Dialog onCreateDialog(int id) { @@ -70,7 +105,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 +121,23 @@ 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 { + // TODO: Implement all of this and make this text go away ;-) + 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 +150,6 @@ public class LandingActivity extends FragmentActivity implements OnClickListener .getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE); return accounts.length > 0; } - + }