/**
 * Copyright 2009 Joe LaPenna
 */

package com.joelapenna.foursquared;

import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.Window;
import android.widget.TabHost;
import android.widget.Toast;

/**
 * @author Joe LaPenna (joe@joelapenna.com)
 */
public class MainActivity extends TabActivity {
    public static final String TAG = "MainActivity";
    public static final boolean DEBUG = FoursquaredSettings.DEBUG;

    private TabHost mTabHost;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Don't start the main activity if we don't have credentials
        if (!((Foursquared)getApplication()).getFoursquare().hasCredentials()) {
            setVisible(false);
            Intent intent = new Intent(this, LoginActivity.class);
            intent.setAction(Intent.ACTION_MAIN);
            startActivityForResult(intent, LoginActivity.ACTIVITY_REQUEST_LOGIN);
            return;
        }

        // Otherwise, resume as normal.

        if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            Toast.makeText(this, "Please insert an SD card before using Foursquared",
                    Toast.LENGTH_LONG).show();
            finish();
            return;
        }

        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setContentView(R.layout.main_activity);
        initTabHost();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == Activity.RESULT_OK) {
            startActivity(new Intent(this, MainActivity.class));
        }
        finish();
    }

    private void initTabHost() {
        if (mTabHost != null) {
            throw new IllegalStateException("Trying to intialize already initializd TabHost");
        }
        mTabHost = getTabHost();

        // Places tab
        mTabHost.addTab(mTabHost.newTabSpec("places")
        // Map Tab
                .setIndicator("", getResources().getDrawable(R.drawable.places_tab)) // the tab icon
                .setContent(new Intent(this, NearbyVenuesActivity.class)) // The contained activity
                );

        // Friends tab
        mTabHost.addTab(mTabHost.newTabSpec("friends")
        // Map Tab
                .setIndicator("", getResources().getDrawable(R.drawable.friends_tab)) // the tab
                // icon
                .setContent(new Intent(this, FriendsActivity.class)) // The contained activity
                );
        mTabHost.setCurrentTab(0);
    }
}

@@ -157,24 +157,62 @@
 ent.Intent;%0A
+import android.content.res.Resources;%0A
 import andro
@@ -260,33 +260,8 @@
 nt;%0A
-import android.util.Log;%0A
 impo
@@ -1995,32 +1995,80 @@
 st%22);%0A        %7D%0A
+%0A        Resources resources = getResources();%0A%0A
         mTabHost
@@ -2160,35 +2160,19 @@
 places%22)
-%0A        // Map Tab
+ //
 %0A       
@@ -2186,35 +2186,99 @@
   .setIndicator(
-%22%22,
+resources.getString(R.string.nearby_label),%0A                       
  getResources().
@@ -2530,27 +2530,11 @@
 ds%22)
-%0A        // Map Tab
+ //
 %0A   
@@ -2564,11 +2564,77 @@
 tor(
-%22%22,
+resources.getString(R.string.checkins_label),%0A                       
  get

use strings.xml for tab names in MainActivity.