summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/Launcher.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher2/Launcher.java')
-rw-r--r--src/com/android/launcher2/Launcher.java141
1 files changed, 98 insertions, 43 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 38085e029..9999e0fe3 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -61,11 +61,11 @@ import android.os.Handler;
import android.os.Message;
import android.os.StrictMode;
import android.os.SystemClock;
-import android.os.SystemProperties;
import android.provider.Settings;
import android.speech.RecognizerIntent;
import android.text.Selection;
import android.text.SpannableStringBuilder;
+import android.text.TextUtils;
import android.text.method.TextKeyListener;
import android.util.Log;
import android.view.Display;
@@ -99,6 +99,7 @@ import com.android.launcher2.DropTarget.DragObject;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileDescriptor;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
@@ -116,7 +117,7 @@ import java.util.Set;
*/
public final class Launcher extends Activity
implements View.OnClickListener, OnLongClickListener, LauncherModel.Callbacks,
- AllAppsView.Watcher, View.OnTouchListener {
+ View.OnTouchListener {
static final String TAG = "Launcher";
static final boolean LOGD = false;
@@ -145,7 +146,8 @@ public final class Launcher extends Activity
static final int DEFAULT_SCREEN = 2;
private static final String PREFERENCES = "launcher.preferences";
- static final String FORCE_ENABLE_ROTATION_PROPERTY = "launcher.force_enable_rotation";
+ static final String FORCE_ENABLE_ROTATION_PROPERTY = "debug.force_enable_rotation";
+ static final String DUMP_STATE_PROPERTY = "debug.dumpstate";
// The Intent extra that defines whether to ignore the launch animation
static final String INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION =
@@ -317,6 +319,20 @@ public final class Launcher extends Activity
int cellY;
}
+
+ private boolean doesFileExist(String filename) {
+ FileInputStream fis = null;
+ try {
+ fis = openFileInput(filename);
+ fis.close();
+ return true;
+ } catch (java.io.FileNotFoundException e) {
+ return false;
+ } catch (java.io.IOException e) {
+ return true;
+ }
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
if (DEBUG_STRICT_MODE) {
@@ -371,7 +387,7 @@ public final class Launcher extends Activity
// Update customization drawer _after_ restoring the states
if (mAppsCustomizeContent != null) {
- mAppsCustomizeContent.onPackagesUpdated(true);
+ mAppsCustomizeContent.onPackagesUpdated();
}
if (PROFILE_STARTUP) {
@@ -935,7 +951,6 @@ public final class Launcher extends Activity
findViewById(R.id.apps_customize_pane);
mAppsCustomizeContent = (AppsCustomizePagedView)
mAppsCustomizeTabHost.findViewById(R.id.apps_customize_pane_content);
- mAppsCustomizeTabHost.setup(this);
mAppsCustomizeContent.setup(this, dragController);
// Get the all apps button
@@ -1494,7 +1509,7 @@ public final class Launcher extends Activity
mWorkspace = null;
mDragController = null;
- ValueAnimator.clearAllAnimations();
+ LauncherAnimUtils.onDestroyActivity();
}
public DragController getDragController() {
@@ -1527,10 +1542,48 @@ public final class Launcher extends Activity
}
Rect sourceBounds = mSearchDropTargetBar.getSearchBarBounds();
+ startGlobalSearch(initialQuery, selectInitialQuery,
+ appSearchData, sourceBounds);
+ }
+
+ /**
+ * Starts the global search activity. This code is a copied from SearchManager
+ */
+ public void startGlobalSearch(String initialQuery,
+ boolean selectInitialQuery, Bundle appSearchData, Rect sourceBounds) {
final SearchManager searchManager =
- (SearchManager) getSystemService(Context.SEARCH_SERVICE);
- searchManager.startSearch(initialQuery, selectInitialQuery, getComponentName(),
- appSearchData, globalSearch, sourceBounds);
+ (SearchManager) getSystemService(Context.SEARCH_SERVICE);
+ ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity();
+ if (globalSearchActivity == null) {
+ Log.w(TAG, "No global search activity found.");
+ return;
+ }
+ Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setComponent(globalSearchActivity);
+ // Make sure that we have a Bundle to put source in
+ if (appSearchData == null) {
+ appSearchData = new Bundle();
+ } else {
+ appSearchData = new Bundle(appSearchData);
+ }
+ // Set source to package name of app that starts global search, if not set already.
+ if (!appSearchData.containsKey("source")) {
+ appSearchData.putString("source", getPackageName());
+ }
+ intent.putExtra(SearchManager.APP_DATA, appSearchData);
+ if (!TextUtils.isEmpty(initialQuery)) {
+ intent.putExtra(SearchManager.QUERY, initialQuery);
+ }
+ if (selectInitialQuery) {
+ intent.putExtra(SearchManager.EXTRA_SELECT_QUERY, selectInitialQuery);
+ }
+ intent.setSourceBounds(sourceBounds);
+ try {
+ startActivity(intent);
+ } catch (ActivityNotFoundException ex) {
+ Log.e(TAG, "Global search activity not found: " + globalSearchActivity);
+ }
}
@Override
@@ -1788,7 +1841,7 @@ public final class Launcher extends Activity
case KeyEvent.KEYCODE_HOME:
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
- if (SystemProperties.getInt("debug.launcher2.dumpstate", 0) != 0) {
+ if (doesFileExist(DUMP_STATE_PROPERTY)) {
dumpState();
return true;
}
@@ -2031,7 +2084,7 @@ public final class Launcher extends Activity
}
private void handleFolderClick(FolderIcon folderIcon) {
- final FolderInfo info = folderIcon.mInfo;
+ final FolderInfo info = folderIcon.getFolderInfo();
Folder openFolder = mWorkspace.getFolderForTag(info);
// If the folder info reports that the associated folder is open, then verify that
@@ -2042,7 +2095,7 @@ public final class Launcher extends Activity
info.opened = false;
}
- if (!info.opened) {
+ if (!info.opened && !folderIcon.getFolder().isDestroyed()) {
// Close any open folder
closeFolder();
// Open the requested folder
@@ -2099,9 +2152,9 @@ public final class Launcher extends Activity
mFolderIconCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
fi.draw(mFolderIconCanvas);
mFolderIconImageView.setImageBitmap(mFolderIconBitmap);
- if (fi.mFolder != null) {
- mFolderIconImageView.setPivotX(fi.mFolder.getPivotXForIconAnimation());
- mFolderIconImageView.setPivotY(fi.mFolder.getPivotYForIconAnimation());
+ if (fi.getFolder() != null) {
+ mFolderIconImageView.setPivotX(fi.getFolder().getPivotXForIconAnimation());
+ mFolderIconImageView.setPivotY(fi.getFolder().getPivotYForIconAnimation());
}
// Just in case this image view is still in the drag layer from a previous animation,
// we remove it and re-add it.
@@ -2109,8 +2162,8 @@ public final class Launcher extends Activity
mDragLayer.removeView(mFolderIconImageView);
}
mDragLayer.addView(mFolderIconImageView, lp);
- if (fi.mFolder != null) {
- fi.mFolder.bringToFront();
+ if (fi.getFolder() != null) {
+ fi.getFolder().bringToFront();
}
}
@@ -2131,7 +2184,7 @@ public final class Launcher extends Activity
copyFolderIconToImage(fi);
fi.setVisibility(View.INVISIBLE);
- ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(mFolderIconImageView, alpha,
+ ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(mFolderIconImageView, alpha,
scaleX, scaleY);
oa.setDuration(getResources().getInteger(R.integer.config_folderAnimDuration));
oa.start();
@@ -2148,7 +2201,7 @@ public final class Launcher extends Activity
// We remove and re-draw the FolderIcon in-case it has changed
mDragLayer.removeView(mFolderIconImageView);
copyFolderIconToImage(fi);
- ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(mFolderIconImageView, alpha,
+ ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(mFolderIconImageView, alpha,
scaleX, scaleY);
oa.setDuration(getResources().getInteger(R.integer.config_folderAnimDuration));
oa.addListener(new AnimatorListenerAdapter() {
@@ -2173,7 +2226,7 @@ public final class Launcher extends Activity
* @param folderInfo The FolderInfo describing the folder to open.
*/
public void openFolder(FolderIcon folderIcon) {
- Folder folder = folderIcon.mFolder;
+ Folder folder = folderIcon.getFolder();
FolderInfo info = folder.mInfo;
info.opened = true;
@@ -2290,13 +2343,6 @@ public final class Launcher extends Activity
return mHotseat.isAllAppsButtonRank(rank);
}
- // AllAppsView.Watcher
- public void zoomed(float zoom) {
- if (zoom == 1.0f) {
- mWorkspace.setVisibility(View.GONE);
- }
- }
-
/**
* Helper method for the cameraZoomIn/cameraZoomOut animations
* @param view The view being animated
@@ -2449,7 +2495,7 @@ public final class Launcher extends Activity
// toView should appear right at the end of the workspace shrink
// animation
- mStateAnimation = new AnimatorSet();
+ mStateAnimation = LauncherAnimUtils.createAnimatorSet();
mStateAnimation.play(scaleAnim).after(startDelay);
mStateAnimation.play(alphaAnim).after(startDelay);
@@ -2624,7 +2670,7 @@ public final class Launcher extends Activity
}
});
- mStateAnimation = new AnimatorSet();
+ mStateAnimation = LauncherAnimUtils.createAnimatorSet();
dispatchOnLauncherTransitionPrepare(fromView, animated, true);
dispatchOnLauncherTransitionPrepare(toView, animated, true);
@@ -2808,9 +2854,9 @@ public final class Launcher extends Activity
mDividerAnimator = null;
}
if (animated) {
- mDividerAnimator = new AnimatorSet();
- mDividerAnimator.playTogether(ObjectAnimator.ofFloat(mQsbDivider, "alpha", 1f),
- ObjectAnimator.ofFloat(mDockDivider, "alpha", 1f));
+ mDividerAnimator = LauncherAnimUtils.createAnimatorSet();
+ mDividerAnimator.playTogether(LauncherAnimUtils.ofFloat(mQsbDivider, "alpha", 1f),
+ LauncherAnimUtils.ofFloat(mDockDivider, "alpha", 1f));
mDividerAnimator.setDuration(mSearchDropTargetBar.getTransitionInDuration());
mDividerAnimator.start();
}
@@ -3385,7 +3431,7 @@ public final class Launcher extends Activity
* @param immediate whether to run the animation or show the results immediately
*/
private void runNewAppsAnimation(boolean immediate) {
- AnimatorSet anim = new AnimatorSet();
+ AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
Collection<Animator> bounceAnims = new ArrayList<Animator>();
// Order these new views spatially so that they animate in order
@@ -3409,7 +3455,7 @@ public final class Launcher extends Activity
} else {
for (int i = 0; i < mNewShortcutAnimateViews.size(); ++i) {
View v = mNewShortcutAnimateViews.get(i);
- ValueAnimator bounceAnim = ObjectAnimator.ofPropertyValuesHolder(v,
+ ValueAnimator bounceAnim = LauncherAnimUtils.ofPropertyValuesHolder(v,
PropertyValuesHolder.ofFloat("alpha", 1f),
PropertyValuesHolder.ofFloat("scaleX", 1f),
PropertyValuesHolder.ofFloat("scaleY", 1f));
@@ -3514,17 +3560,17 @@ public final class Launcher extends Activity
*
* Implementation of the method from LauncherModel.Callbacks.
*/
- public void bindAppsRemoved(ArrayList<ApplicationInfo> apps, boolean permanent) {
+ public void bindAppsRemoved(ArrayList<String> packageNames, boolean permanent) {
if (permanent) {
- mWorkspace.removeItems(apps);
+ mWorkspace.removeItems(packageNames);
}
if (mAppsCustomizeContent != null) {
- mAppsCustomizeContent.removeApps(apps);
+ mAppsCustomizeContent.removeApps(packageNames);
}
// Notify the drag controller
- mDragController.onAppsRemoved(apps, this);
+ mDragController.onAppsRemoved(packageNames, this);
}
/**
@@ -3532,7 +3578,7 @@ public final class Launcher extends Activity
*/
public void bindPackagesUpdated() {
if (mAppsCustomizeContent != null) {
- mAppsCustomizeContent.onPackagesUpdated(false);
+ mAppsCustomizeContent.onPackagesUpdated();
}
}
@@ -3569,8 +3615,7 @@ public final class Launcher extends Activity
}
public boolean isRotationEnabled() {
- boolean forceEnableRotation = "true".equalsIgnoreCase(SystemProperties.get(
- FORCE_ENABLE_ROTATION_PROPERTY, "false"));
+ boolean forceEnableRotation = doesFileExist(FORCE_ENABLE_ROTATION_PROPERTY);
boolean enableRotation = forceEnableRotation ||
getResources().getBoolean(R.bool.allow_rotation);
return enableRotation;
@@ -3608,7 +3653,6 @@ public final class Launcher extends Activity
cling.init(this, positionData);
cling.setVisibility(View.VISIBLE);
cling.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- cling.requestAccessibilityFocus();
if (animate) {
cling.buildLayer();
cling.setAlpha(0f);
@@ -3626,7 +3670,7 @@ public final class Launcher extends Activity
}
private void dismissCling(final Cling cling, final String flag, int duration) {
if (cling != null) {
- ObjectAnimator anim = ObjectAnimator.ofFloat(cling, "alpha", 0f);
+ ObjectAnimator anim = LauncherAnimUtils.ofFloat(cling, "alpha", 0f);
anim.setDuration(duration);
anim.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
@@ -3746,6 +3790,17 @@ public final class Launcher extends Activity
writer.println(" " + sDumpLogs.get(i));
}
}
+
+ public static void dumpDebugLogsToConsole() {
+ Log.d(TAG, "");
+ Log.d(TAG, "*********************");
+ Log.d(TAG, "Launcher debug logs: ");
+ for (int i = 0; i < sDumpLogs.size(); i++) {
+ Log.d(TAG, " " + sDumpLogs.get(i));
+ }
+ Log.d(TAG, "*********************");
+ Log.d(TAG, "");
+ }
}
interface LauncherTransitionable {