summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2010-07-10 01:05:18 (GMT)
committerMichael Jurka <mikejurka@google.com>2010-07-10 02:18:12 (GMT)
commit946ad470c72a3caa7568d11836c182b7f84d840d (patch)
treeeae2f6c352f4e22d3269b14460ba1d1c8e3ed524 /src
parent0e26059548e429e5d1c973bebe4c561bead2926f (diff)
downloadandroid_packages_apps_Trebuchet-946ad470c72a3caa7568d11836c182b7f84d840d.zip
android_packages_apps_Trebuchet-946ad470c72a3caa7568d11836c182b7f84d840d.tar.gz
android_packages_apps_Trebuchet-946ad470c72a3caa7568d11836c182b7f84d840d.tar.bz2
Fixing runtime error on non-xlarge devices
Previous commit made Launcher a subclass of TabActivity, but there is no TabHost in non-xlarge layouts; Launcher now subclasses from Activity and no longer assumes that there must be a TabHost Change-Id: I496496a602e43768d79113c7090435119cb4e5e5
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/Launcher.java65
1 files changed, 42 insertions, 23 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index e413a70..03066c1 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -19,11 +19,11 @@ package com.android.launcher2;
import com.android.common.Search;
import com.android.launcher.R;
+import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.SearchManager;
import android.app.StatusBarManager;
-import android.app.TabActivity;
import android.app.WallpaperManager;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
@@ -74,7 +74,6 @@ import android.view.View.OnLongClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager;
-import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -94,7 +93,7 @@ import java.util.List;
/**
* Default launcher application.
*/
-public final class Launcher extends TabActivity
+public final class Launcher extends Activity
implements View.OnClickListener, OnLongClickListener, LauncherModel.Callbacks,
AllAppsView.Watcher, View.OnTouchListener {
static final String TAG = "Launcher";
@@ -247,23 +246,25 @@ public final class Launcher extends TabActivity
checkForLocaleChange();
setWallpaperDimension();
setContentView(R.layout.launcher);
-
- mHomeCustomizationDrawer = getTabHost();
-
- String widgetsLabel = getString(R.string.widgets_tab_label);
- mHomeCustomizationDrawer.addTab(mHomeCustomizationDrawer.newTabSpec("widgets")
- .setIndicator(widgetsLabel).setContent(R.id.widget_chooser));
- String foldersLabel = getString(R.string.folders_tab_label);
- mHomeCustomizationDrawer.addTab(mHomeCustomizationDrawer.newTabSpec("folders")
- .setIndicator(foldersLabel).setContent(R.id.folder_chooser));
- String shortcutsLabel = getString(R.string.shortcuts_tab_label);
- mHomeCustomizationDrawer.addTab(mHomeCustomizationDrawer.newTabSpec("shortcuts")
- .setIndicator(shortcutsLabel).setContent(R.id.shortcut_chooser));
- String wallpapersLabel = getString(R.string.wallpapers_tab_label);
- mHomeCustomizationDrawer.addTab(mHomeCustomizationDrawer.newTabSpec("wallpapers")
- .setIndicator(wallpapersLabel).setContent(R.id.wallpaperstab));
-
- mHomeCustomizationDrawer.setCurrentTab(0);
+ mHomeCustomizationDrawer = (TabHost) findViewById(com.android.internal.R.id.tabhost);
+ if (mHomeCustomizationDrawer != null) {
+ mHomeCustomizationDrawer.setup();
+
+ String widgetsLabel = getString(R.string.widgets_tab_label);
+ mHomeCustomizationDrawer.addTab(mHomeCustomizationDrawer.newTabSpec("widgets")
+ .setIndicator(widgetsLabel).setContent(R.id.widget_chooser));
+ String foldersLabel = getString(R.string.folders_tab_label);
+ mHomeCustomizationDrawer.addTab(mHomeCustomizationDrawer.newTabSpec("folders")
+ .setIndicator(foldersLabel).setContent(R.id.folder_chooser));
+ String shortcutsLabel = getString(R.string.shortcuts_tab_label);
+ mHomeCustomizationDrawer.addTab(mHomeCustomizationDrawer.newTabSpec("shortcuts")
+ .setIndicator(shortcutsLabel).setContent(R.id.shortcut_chooser));
+ String wallpapersLabel = getString(R.string.wallpapers_tab_label);
+ mHomeCustomizationDrawer.addTab(mHomeCustomizationDrawer.newTabSpec("wallpapers")
+ .setIndicator(wallpapersLabel).setContent(R.id.wallpaperstab));
+
+ mHomeCustomizationDrawer.setCurrentTab(0);
+ }
setupViews();
registerContentObservers();
@@ -758,7 +759,11 @@ public final class Launcher extends TabActivity
mWorkspace = (Workspace) dragLayer.findViewById(R.id.workspace);
final Workspace workspace = mWorkspace;
workspace.setHapticFeedbackEnabled(false);
- workspace.setOnInterceptTouchListener(this);
+
+ // We only intercept touch events to dismiss the home customization drawer; if it doesn't
+ // exist, then no need to do this
+ if (mHomeCustomizationDrawer != null)
+ workspace.setOnInterceptTouchListener(this);
DeleteZone deleteZone = (DeleteZone) dragLayer.findViewById(R.id.delete_zone);
mDeleteZone = deleteZone;
@@ -1040,6 +1045,13 @@ public final class Launcher extends TabActivity
protected void onRestoreInstanceState(Bundle savedInstanceState) {
// Do not call super here
mSavedInstanceState = savedInstanceState;
+
+ if (mHomeCustomizationDrawer != null) {
+ String cur = savedInstanceState.getString("currentTab");
+ if (cur != null) {
+ mHomeCustomizationDrawer.setCurrentTabByTag(cur);
+ }
+ }
}
@Override
@@ -1083,6 +1095,13 @@ public final class Launcher extends TabActivity
outState.putBoolean(RUNTIME_STATE_PENDING_FOLDER_RENAME, true);
outState.putLong(RUNTIME_STATE_PENDING_FOLDER_RENAME_ID, mFolderInfo.id);
}
+
+ if (mHomeCustomizationDrawer != null) {
+ String currentTabTag = mHomeCustomizationDrawer.getCurrentTabTag();
+ if (currentTabTag != null) {
+ outState.putString("currentTab", currentTabTag);
+ }
+ }
}
@Override
@@ -1556,7 +1575,7 @@ public final class Launcher extends TabActivity
public boolean onTouch(View v, MotionEvent event) {
// this is being forwarded from mWorkspace;
// clicking anywhere on the workspace causes the drawer to slide down
- if (mHomeCustomizationDrawer.getVisibility() == View.VISIBLE) {
+ if (mHomeCustomizationDrawer != null && mHomeCustomizationDrawer.getVisibility() == View.VISIBLE) {
Animation slideDownAnimation = AnimationUtils.loadAnimation(this, R.anim.home_customization_drawer_slide_down);
slideDownAnimation.setAnimationListener(new SlideDownFinishedListener(mHomeCustomizationDrawer));
mHomeCustomizationDrawer.startAnimation(slideDownAnimation);
@@ -1573,7 +1592,7 @@ public final class Launcher extends TabActivity
public void onClickAddButton(View v) {
// Animate the widget chooser up from the bottom of the screen
- if (mHomeCustomizationDrawer.getVisibility() == View.GONE) {
+ if (mHomeCustomizationDrawer != null && mHomeCustomizationDrawer.getVisibility() == View.GONE) {
mHomeCustomizationDrawer.setVisibility(View.VISIBLE);
mHomeCustomizationDrawer.startAnimation(AnimationUtils.loadAnimation(this, R.anim.home_customization_drawer_slide_up));
}