summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher/GesturesActivity.java475
-rw-r--r--src/com/android/launcher/GesturesConstants.java27
-rw-r--r--src/com/android/launcher/GesturesPanel.java69
-rw-r--r--src/com/android/launcher/Launcher.java434
4 files changed, 4 insertions, 1001 deletions
diff --git a/src/com/android/launcher/GesturesActivity.java b/src/com/android/launcher/GesturesActivity.java
deleted file mode 100644
index 5c67a1efe..000000000
--- a/src/com/android/launcher/GesturesActivity.java
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher;
-
-import android.app.ListActivity;
-import android.app.Dialog;
-import android.app.AlertDialog;
-import android.os.Bundle;
-import android.os.AsyncTask;
-import android.widget.ArrayAdapter;
-import android.widget.TextView;
-import android.widget.AdapterView;
-import android.widget.Toast;
-import android.widget.EditText;
-import android.widget.BaseAdapter;
-import android.widget.CheckBox;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.content.res.Resources;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.LayoutInflater;
-import android.view.ContextMenu;
-import android.view.MenuItem;
-import android.gesture.GestureLibrary;
-import android.gesture.Gesture;
-import android.graphics.Bitmap;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.BitmapDrawable;
-import android.text.TextUtils;
-import android.database.DataSetObserver;
-
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Collections;
-import java.util.Map;
-
-public class GesturesActivity extends ListActivity implements AdapterView.OnItemClickListener {
- private static final int MENU_ID_RENAME = 1;
- private static final int MENU_ID_REMOVE = 2;
-
- private static final int DIALOG_RENAME_GESTURE = 1;
-
- // Type: long (id)
- private static final String GESTURES_INFO_ID = "gestures.info_id";
-
- private final Comparator<ApplicationInfo> mSorter =
- new LauncherModel.ApplicationInfoComparator();
-
- private GesturesAdapter mAdapter;
- private GestureLibrary mStore;
- private GesturesLoadTask mTask;
-
- private Dialog mRenameDialog;
- private EditText mInput;
- private ApplicationInfo mCurrentRenameInfo;
- private SharedPreferences mPreferences;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.gestures_settings);
-
- mAdapter = new GesturesAdapter(this);
- setListAdapter(new GesturesSettingsAdapter(mAdapter));
- getListView().setOnItemClickListener(this);
-
- mStore = Launcher.getGestureLibrary(this);
- mTask = (GesturesLoadTask) new GesturesLoadTask().execute();
-
- registerForContextMenu(getListView());
-
- mPreferences = getSharedPreferences(GesturesConstants.PREFERENCES_NAME, MODE_PRIVATE);
- }
-
- @SuppressWarnings({ "UnusedDeclaration" })
- public void back(View v) {
- finish();
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
-
- if (mTask != null && mTask.getStatus() != GesturesLoadTask.Status.FINISHED) {
- mTask.cancel(true);
- mTask = null;
- }
-
- cleanupRenameDialog();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
-
- if (mCurrentRenameInfo != null) {
- outState.putLong(GESTURES_INFO_ID, mCurrentRenameInfo.id);
- }
- }
-
- @Override
- protected void onRestoreInstanceState(Bundle state) {
- super.onRestoreInstanceState(state);
-
- long id = state.getLong(GESTURES_INFO_ID, -1);
- if (id != -1) {
- mCurrentRenameInfo = Launcher.getModel().queryGesture(this, String.valueOf(id));
- }
- }
-
- @Override
- public void onCreateContextMenu(ContextMenu menu, View v,
- ContextMenu.ContextMenuInfo menuInfo) {
-
- super.onCreateContextMenu(menu, v, menuInfo);
-
- AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
- if (info.position > 2) {
- menu.setHeaderTitle(((TextView) info.targetView).getText());
-
- menu.add(0, MENU_ID_RENAME, 0, R.string.gestures_rename);
- menu.add(0, MENU_ID_REMOVE, 0, R.string.gestures_delete);
- }
- }
-
- @Override
- public boolean onContextItemSelected(MenuItem item) {
- final AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo)
- item.getMenuInfo();
- final ApplicationInfo info = (ApplicationInfo) menuInfo.targetView.getTag();
-
- switch (item.getItemId()) {
- case MENU_ID_RENAME:
- renameGesture(info);
- return true;
- case MENU_ID_REMOVE:
- deleteGesture(info);
- return true;
- }
-
- return super.onContextItemSelected(item);
- }
-
- private void renameGesture(ApplicationInfo info) {
- mCurrentRenameInfo = info;
- showDialog(DIALOG_RENAME_GESTURE);
- }
-
- @Override
- protected Dialog onCreateDialog(int id) {
- if (id == DIALOG_RENAME_GESTURE) {
- return createRenameDialog();
- }
- return super.onCreateDialog(id);
- }
-
- @Override
- protected void onPrepareDialog(int id, Dialog dialog) {
- super.onPrepareDialog(id, dialog);
- if (id == DIALOG_RENAME_GESTURE && mCurrentRenameInfo != null) {
- mInput.setText(mCurrentRenameInfo.title);
- }
- }
-
- private Dialog createRenameDialog() {
- final View layout = View.inflate(this, R.layout.rename_folder, null);
- mInput = (EditText) layout.findViewById(R.id.folder_name);
- ((TextView) layout.findViewById(R.id.label)).setText(R.string.gestures_rename_label);
-
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setIcon(0);
- builder.setTitle(getString(R.string.gestures_rename_title));
- builder.setCancelable(true);
- builder.setOnCancelListener(new Dialog.OnCancelListener() {
- public void onCancel(DialogInterface dialog) {
- cleanupRenameDialog();
- }
- });
- builder.setNegativeButton(getString(R.string.cancel_action),
- new Dialog.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- cleanupRenameDialog();
- }
- }
- );
- builder.setPositiveButton(getString(R.string.rename_action),
- new Dialog.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- changeGestureName();
- }
- }
- );
- builder.setView(layout);
- return builder.create();
- }
-
- private void changeGestureName() {
- final String name = mInput.getText().toString();
- if (!TextUtils.isEmpty(name)) {
- final ApplicationInfo renameInfo = mCurrentRenameInfo;
- final GesturesActivity.GesturesAdapter adapter = mAdapter;
- final int count = adapter.getCount();
-
- // Simple linear search, there should not be enough items to warrant
- // a more sophisticated search
- for (int i = 0; i < count; i++) {
- final ApplicationInfo info = adapter.getItem(i);
- if (info.id == renameInfo.id) {
- info.title = mInput.getText();
- LauncherModel.updateGestureInDatabase(this, info);
- break;
- }
- }
-
- adapter.notifyDataSetChanged();
- }
- mCurrentRenameInfo = null;
- }
-
- private void cleanupRenameDialog() {
- if (mRenameDialog != null) {
- mRenameDialog.dismiss();
- mRenameDialog = null;
- }
- mCurrentRenameInfo = null;
- }
-
- private void deleteGesture(ApplicationInfo info) {
- mStore.removeEntry(String.valueOf(info.id));
- // TODO: On a thread?
- mStore.save();
-
- final GesturesActivity.GesturesAdapter adapter = mAdapter;
- adapter.setNotifyOnChange(false);
- adapter.remove(info);
- adapter.sort(mSorter);
- adapter.notifyDataSetChanged();
-
- LauncherModel.deleteGestureFromDatabase(this, info);
-
- Toast.makeText(this, R.string.gestures_delete_success, Toast.LENGTH_SHORT).show();
- }
-
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- if (position == 1) {
- final CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);
- checkBox.toggle();
- mPreferences.edit().putBoolean(GesturesConstants.PREFERENCES_HOME_KEY,
- checkBox.isChecked()).commit();
- }
- }
-
- private class GesturesLoadTask extends AsyncTask<Void, ApplicationInfo, Boolean> {
- private int mThumbnailSize;
- private int mThumbnailInset;
- private int mPathColor;
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
-
- final Resources resources = getResources();
- mPathColor = resources.getColor(R.color.gesture_color);
- mThumbnailInset = (int) resources.getDimension(R.dimen.gesture_thumbnail_inset);
- mThumbnailSize = (int) resources.getDimension(R.dimen.gesture_thumbnail_size);
- }
-
- protected Boolean doInBackground(Void... params) {
- if (isCancelled()) return Boolean.FALSE;
-
- final GestureLibrary store = mStore;
-
- if (store.load()) {
- final LauncherModel model = Launcher.getModel();
-
- for (String name : store.getGestureEntries()) {
- if (isCancelled()) break;
-
- final Gesture gesture = store.getGestures(name).get(0);
- final Bitmap bitmap = gesture.toBitmap(mThumbnailSize, mThumbnailSize,
- mThumbnailInset, mPathColor);
- final ApplicationInfo info = model.queryGesture(GesturesActivity.this, name);
-
- mAdapter.addBitmap(info.id, bitmap);
- publishProgress(info);
- }
-
- return Boolean.TRUE;
- }
-
- return Boolean.FALSE;
- }
-
- @Override
- protected void onProgressUpdate(ApplicationInfo... values) {
- super.onProgressUpdate(values);
-
- final GesturesActivity.GesturesAdapter adapter = mAdapter;
- adapter.setNotifyOnChange(false);
-
- for (ApplicationInfo info : values) {
- adapter.add(info);
- }
-
- adapter.sort(mSorter);
- adapter.notifyDataSetChanged();
- }
- }
-
- private class GesturesAdapter extends ArrayAdapter<ApplicationInfo> {
- private final LayoutInflater mInflater;
- private final Map<Long, Drawable> mThumbnails = Collections.synchronizedMap(
- new HashMap<Long, Drawable>());
-
- public GesturesAdapter(Context context) {
- super(context, 0);
- mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- }
-
- void addBitmap(Long id, Bitmap bitmap) {
- mThumbnails.put(id, new BitmapDrawable(bitmap));
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- if (convertView == null) {
- convertView = mInflater.inflate(R.layout.gestures_settings_item, parent, false);
- }
-
- final ApplicationInfo info = getItem(position);
- final TextView label = (TextView) convertView;
-
- label.setTag(info);
- label.setText(info.title);
- label.setCompoundDrawablesWithIntrinsicBounds(info.icon, null,
- mThumbnails.get(info.id), null);
-
- return convertView;
- }
- }
-
- private class GesturesSettingsAdapter extends BaseAdapter {
- private static final int FIXED_CHILDREN_COUNT = 3;
-
- private static final int VIEW_TYPE_SEPARATOR = 0;
- private static final int VIEW_TYPE_CHECKBOX = 1;
-
- private final GesturesAdapter mAdapter;
- private final LayoutInflater mInflater;
-
- public GesturesSettingsAdapter(GesturesAdapter adapter) {
- mAdapter = adapter;
- mInflater = adapter.mInflater;
- adapter.registerDataSetObserver(new DataSetObserver() {
- @Override
- public void onChanged() {
- notifyDataSetChanged();
- }
-
- @Override
- public void onInvalidated() {
- notifyDataSetInvalidated();
- }
- });
- }
-
- public int getCount() {
- return FIXED_CHILDREN_COUNT + mAdapter.getCount();
- }
-
- public Object getItem(int position) {
- if (position < FIXED_CHILDREN_COUNT) {
- return String.valueOf(position);
- }
- return mAdapter.getItem(position - FIXED_CHILDREN_COUNT);
- }
-
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public int getItemViewType(int position) {
- if (position < FIXED_CHILDREN_COUNT) {
- switch (position) {
- case 0:
- case 2:
- return VIEW_TYPE_SEPARATOR;
- case 1:
- return VIEW_TYPE_CHECKBOX;
- }
- }
- return 2 + super.getItemViewType(position);
- }
-
- @Override
- public int getViewTypeCount() {
- return 2 + mAdapter.getViewTypeCount();
- }
-
- @Override
- public boolean areAllItemsEnabled() {
- return false;
- }
-
- @Override
- public boolean isEnabled(int position) {
- return position != 0 && position != 2;
- }
-
- public View getView(int position, View convertView, ViewGroup parent) {
- if (position < FIXED_CHILDREN_COUNT) {
- // NOTE: Don't bother with ViewHolders here, we only have 3 items and
- // the list is likely to not be very long
- switch (position) {
- case 0:
- convertView = createHeader(convertView, parent,
- R.string.gestures_group_settings);
- break;
- case 1:
- convertView = createSetting(convertView, parent,
- R.string.gestures_preference_hotkey_title,
- R.string.gestures_preference_hotkey_summary);
- break;
- case 2:
- convertView = createHeader(convertView, parent,
- R.string.gestures_group_gestures);
- break;
- }
- return convertView;
- }
- return mAdapter.getView(position - FIXED_CHILDREN_COUNT, convertView, parent);
- }
-
- private View createSetting(View convertView, ViewGroup parent,
- int title, int summary) {
-
- if (convertView == null) {
- convertView = mInflater.inflate(R.layout.list_checkbox_2lines, parent, false);
- }
-
- ((TextView) convertView.findViewById(R.id.title)).setText(title);
- ((TextView) convertView.findViewById(R.id.summary)).setText(summary);
- ((CheckBox) convertView.findViewById(R.id.checkbox)).setChecked(
- mPreferences.getBoolean(GesturesConstants.PREFERENCES_HOME_KEY, false));
-
- return convertView;
- }
-
- private View createHeader(View convertView, ViewGroup parent, int text) {
- if (convertView == null) {
- convertView = mInflater.inflate(R.layout.list_category, parent, false);
- }
- ((TextView) convertView).setText(text);
- return convertView;
- }
- }
-}
diff --git a/src/com/android/launcher/GesturesConstants.java b/src/com/android/launcher/GesturesConstants.java
deleted file mode 100644
index 93a1f10ba..000000000
--- a/src/com/android/launcher/GesturesConstants.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher;
-
-interface GesturesConstants {
- final double PREDICTION_THRESHOLD = 1.0;
- final String STORE_NAME = "gestures";
- final long MATCH_DELAY = 370;
- final float LENGTH_THRESHOLD = 120.0f;
- int PATH_SAMPLE_COUNT = 10;
- String PREFERENCES_NAME = "gestures";
- String PREFERENCES_HOME_KEY = "gestures.home";
-}
diff --git a/src/com/android/launcher/GesturesPanel.java b/src/com/android/launcher/GesturesPanel.java
deleted file mode 100644
index c0fce472e..000000000
--- a/src/com/android/launcher/GesturesPanel.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher;
-
-import android.widget.LinearLayout;
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.KeyEvent;
-
-public class GesturesPanel extends LinearLayout {
- public GesturesPanel(Context context) {
- super(context);
- }
-
- public GesturesPanel(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- public boolean isOpaque() {
- return true;
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- final int keyCode = event.getKeyCode();
-
- switch (keyCode) {
- case KeyEvent.KEYCODE_VOLUME_UP:
- case KeyEvent.KEYCODE_VOLUME_DOWN:
- case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
- case KeyEvent.KEYCODE_MUTE:
- case KeyEvent.KEYCODE_HEADSETHOOK:
- case KeyEvent.KEYCODE_MEDIA_STOP:
- case KeyEvent.KEYCODE_MEDIA_NEXT:
- case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
- case KeyEvent.KEYCODE_MEDIA_REWIND:
- case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
- case KeyEvent.KEYCODE_CAMERA:
- case KeyEvent.KEYCODE_CALL:
- case KeyEvent.KEYCODE_SEARCH:
- return ((Launcher) mContext).getWorkspace().getRootView().dispatchKeyEvent(event);
- }
-
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- if (event.getAction() == KeyEvent.ACTION_DOWN) {
- ((Launcher) mContext).hideGesturesPanel();
- return true;
- }
- } else {
- return super.dispatchKeyEvent(event);
- }
- return false;
- }
-}
diff --git a/src/com/android/launcher/Launcher.java b/src/com/android/launcher/Launcher.java
index 25ad4e575..3fd141d5a 100644
--- a/src/com/android/launcher/Launcher.java
+++ b/src/com/android/launcher/Launcher.java
@@ -32,7 +32,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.SharedPreferences;
import android.content.Intent.ShortcutIconResource;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
@@ -67,8 +66,6 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
-import android.view.MotionEvent;
-import android.view.Gravity;
import android.view.View.OnLongClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
@@ -76,16 +73,8 @@ import android.widget.GridView;
import android.widget.SlidingDrawer;
import android.widget.TextView;
import android.widget.Toast;
-import android.widget.ImageView;
-import android.widget.PopupWindow;
-import android.widget.Button;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
-import android.gesture.GestureOverlayView;
-import android.gesture.GestureLibraries;
-import android.gesture.GestureLibrary;
-import android.gesture.Gesture;
-import android.gesture.Prediction;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -106,9 +95,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
private static final boolean PROFILE_DRAWER = false;
private static final boolean PROFILE_ROTATE = false;
private static final boolean DEBUG_USER_INTERFACE = false;
- private static final boolean DEBUG_GESTURES = false;
-
- private static final boolean CONFIG_GESTURES_IMMEDIATE_MODE = true;
private static final int WALLPAPER_SCREENS_SPAN = 2;
@@ -117,8 +103,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On
private static final int MENU_WALLPAPER_SETTINGS = MENU_ADD + 1;
private static final int MENU_SEARCH = MENU_WALLPAPER_SETTINGS + 1;
private static final int MENU_NOTIFICATIONS = MENU_SEARCH + 1;
- private static final int MENU_GESTURES = MENU_NOTIFICATIONS + 1;
- private static final int MENU_SETTINGS = MENU_GESTURES + 1;
+ private static final int MENU_SETTINGS = MENU_NOTIFICATIONS + 1;
private static final int REQUEST_CREATE_SHORTCUT = 1;
private static final int REQUEST_CREATE_LIVE_FOLDER = 4;
@@ -127,9 +112,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
private static final int REQUEST_PICK_SHORTCUT = 7;
private static final int REQUEST_PICK_LIVE_FOLDER = 8;
private static final int REQUEST_PICK_APPWIDGET = 9;
- private static final int REQUEST_PICK_GESTURE_ACTION = 10;
- private static final int REQUEST_CREATE_GESTURE_ACTION = 11;
- private static final int REQUEST_CREATE_GESTURE_APPLICATION_ACTION = 12;
static final String EXTRA_SHORTCUT_DUPLICATE = "duplicate";
@@ -172,12 +154,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
private static final String RUNTIME_STATE_PENDING_FOLDER_RENAME = "launcher.rename_folder";
// Type: long
private static final String RUNTIME_STATE_PENDING_FOLDER_RENAME_ID = "launcher.rename_folder_id";
- // Type: Gesture (Parcelable)
- private static final String RUNTIME_STATE_PENDING_GESTURE = "launcher.gesture";
- // Type: boolean
- private static final String RUNTIME_STATE_GESTURES_PANEL = "launcher.gesture_panel_showing";
- // Type: Gesture (Parcelable)
- private static final String RUNTIME_STATE_GESTURES_PANEL_GESTURE = "launcher.gesture_panel_gesture";
private static final LauncherModel sModel = new LauncherModel();
@@ -188,8 +164,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
private static WallpaperIntentReceiver sWallpaperReceiver;
- private static GestureLibrary sLibrary;
-
private final BroadcastReceiver mApplicationsReceiver = new ApplicationsIntentReceiver();
private final ContentObserver mObserver = new FavoritesChangeObserver();
@@ -230,24 +204,11 @@ public final class Launcher extends Activity implements View.OnClickListener, On
private DesktopBinder mBinder;
- private View mGesturesPanel;
- private GestureOverlayView mGesturesOverlay;
- private ImageView mGesturesAdd;
- private PopupWindow mGesturesWindow;
- private Launcher.GesturesProcessor mGesturesProcessor;
- private Gesture mCurrentGesture;
- private GesturesAction mGesturesAction;
- private boolean mHideGesturesPanel;
- private TextView mGesturesPrompt;
- private Button mGesturesSend;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mInflater = getLayoutInflater();
- getGestureLibrary(this);
-
mAppWidgetManager = AppWidgetManager.getInstance(this);
mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID);
@@ -405,11 +366,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On
// For example, the user would PICK_SHORTCUT for "Music playlist", and we
// launch over to the Music app to actually CREATE_SHORTCUT.
- if (resultCode == RESULT_OK && (mAddItemCellInfo != null ||
- ((requestCode == REQUEST_PICK_GESTURE_ACTION ||
- requestCode == REQUEST_CREATE_GESTURE_ACTION ||
- requestCode == REQUEST_CREATE_GESTURE_APPLICATION_ACTION) && mCurrentGesture != null))) {
-
+ if (resultCode == RESULT_OK && mAddItemCellInfo != null) {
switch (requestCode) {
case REQUEST_PICK_APPLICATION:
completeAddApplication(this, data, mAddItemCellInfo, !mDesktopLocked);
@@ -432,16 +389,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
case REQUEST_CREATE_APPWIDGET:
completeAddAppWidget(data, mAddItemCellInfo, !mDesktopLocked);
break;
- case REQUEST_PICK_GESTURE_ACTION:
- processShortcut(data, REQUEST_CREATE_GESTURE_APPLICATION_ACTION,
- REQUEST_CREATE_GESTURE_ACTION);
- break;
- case REQUEST_CREATE_GESTURE_ACTION:
- completeCreateGesture(data, true);
- break;
- case REQUEST_CREATE_GESTURE_APPLICATION_ACTION:
- completeCreateGesture(data, false);
- break;
}
} else if (requestCode == REQUEST_PICK_APPWIDGET &&
resultCode == RESULT_CANCELED && data != null) {
@@ -486,23 +433,10 @@ public final class Launcher extends Activity implements View.OnClickListener, On
@Override
protected void onPause() {
super.onPause();
- if (mGesturesWindow != null) {
- mGesturesWindow.setAnimationStyle(0);
- mGesturesWindow.update();
- }
closeDrawer(false);
}
@Override
- protected void onStop() {
- super.onStop();
- if (mHideGesturesPanel) {
- mHideGesturesPanel = false;
- hideGesturesPanel();
- }
- }
-
- @Override
public Object onRetainNonConfigurationInstance() {
// Flag any binder to stop early before switching
if (mBinder != null) {
@@ -589,31 +523,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
mFolderInfo = sModel.getFolderById(this, id);
mRestoring = true;
}
-
- mCurrentGesture = (Gesture) savedState.get(RUNTIME_STATE_PENDING_GESTURE);
-
- boolean gesturesShowing = savedState.getBoolean(RUNTIME_STATE_GESTURES_PANEL, false);
- if (gesturesShowing) {
- if (mCurrentGesture == null) {
- mCurrentGesture = (Gesture) savedState.get(RUNTIME_STATE_GESTURES_PANEL_GESTURE);
- }
- final Gesture gesture = mCurrentGesture;
- mWorkspace.post(new Runnable() {
- public void run() {
- showGesturesPanel(false);
- if (gesture != null && mWorkspace.getParent() != null) {
- mGesturesProcessor.matchGesture(gesture);
- mWorkspace.post(new Runnable() {
- public void run() {
- if (gesture != null && mWorkspace.getParent() != null) {
- mGesturesOverlay.setGesture(gesture);
- }
- }
- });
- }
- }
- });
- }
}
/**
@@ -661,72 +570,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
dragLayer.setIgnoredDropTarget(grid);
dragLayer.setDragScoller(workspace);
dragLayer.setDragListener(deleteZone);
-
- mGesturesPanel = mInflater.inflate(R.layout.gestures, mDragLayer, false);
- final View gesturesPanel = mGesturesPanel;
-
- mGesturesAction = new GesturesAction();
-
- mGesturesPrompt = (TextView) gesturesPanel.findViewById(R.id.gestures_prompt);
- mGesturesSend = (Button) gesturesPanel.findViewById(R.id.gestures_action);
- mGesturesSend.setOnClickListener(mGesturesAction);
-
- mGesturesAdd = (ImageView) gesturesPanel.findViewById(R.id.gestures_add);
- final ImageView gesturesAdd = mGesturesAdd;
- gesturesAdd.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- createGesture();
- }
- });
-
- gesturesPanel.findViewById(R.id.gestures_list).setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- startActivity(new Intent(Launcher.this, GesturesActivity.class));
- }
- });
-
- mGesturesOverlay = (GestureOverlayView) gesturesPanel.findViewById(R.id.gestures_overlay);
- mGesturesProcessor = new GesturesProcessor();
-
- final GestureOverlayView overlay = mGesturesOverlay;
- overlay.addOnGestureListener(mGesturesProcessor);
- }
-
- private void createGesture() {
- if (!mWaitingForResult) {
- mCurrentGesture = mGesturesOverlay.getGesture();
- mWaitingForResult = true;
- pickShortcut(REQUEST_PICK_GESTURE_ACTION, R.string.title_select_shortcut);
- }
- }
-
- private void completeCreateGesture(Intent data, boolean isShortcut) {
- ApplicationInfo info;
-
- if (isShortcut) {
- info = infoFromShortcutIntent(this, data);
- } else {
- info = infoFromApplicationIntent(this, data);
- }
-
- boolean success = false;
- if (info != null) {
- info.isGesture = true;
-
- if (LauncherModel.addGestureToDatabase(this, info, false)) {
- mGesturesProcessor.addGesture(String.valueOf(info.id), mCurrentGesture);
- mGesturesProcessor.update(info, mCurrentGesture);
- Toast.makeText(this, getString(R.string.gestures_created, info.title),
- Toast.LENGTH_SHORT).show();
- success = true;
- }
- }
-
- if (!success) {
- Toast.makeText(this, getString(R.string.gestures_failed), Toast.LENGTH_SHORT).show();
- }
-
- mCurrentGesture = null;
}
/**
@@ -977,32 +820,8 @@ public final class Launcher extends Activity implements View.OnClickListener, On
if ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) !=
Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) {
- // TODO: This really should not be done here every time
- final SharedPreferences preferences =
- getSharedPreferences(GesturesConstants.PREFERENCES_NAME, MODE_PRIVATE);
- final boolean homeKey = preferences.getBoolean(
- GesturesConstants.PREFERENCES_HOME_KEY, false);
-
- if (!homeKey) {
- if (!mWorkspace.isDefaultScreenShowing()) {
- mWorkspace.moveToDefaultScreen();
- }
-
- if (mGesturesWindow == null || mGesturesWindow.isShowing()) {
- hideGesturesPanel();
- }
- } else {
- if (mGesturesPanel != null && mDragLayer.getWindowVisibility() == View.VISIBLE
- && (mDragLayer.hasWindowFocus() || (mGesturesWindow != null
- && mGesturesWindow.isShowing()))) {
-
- SearchManager searchManager =
- (SearchManager) getSystemService(Context.SEARCH_SERVICE);
-
- if (!searchManager.isVisible()) {
- onHomeKeyPressed();
- }
- }
+ if (!mWorkspace.isDefaultScreenShowing()) {
+ mWorkspace.moveToDefaultScreen();
}
closeDrawer();
@@ -1019,83 +838,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
}
}
- private void onHomeKeyPressed() {
- if (mGesturesWindow == null || !mGesturesWindow.isShowing()) {
- showGesturesPanel();
- } else {
- hideGesturesPanel();
- }
- }
-
- private void showGesturesPanel() {
- showGesturesPanel(true);
- }
-
- private void showGesturesPanel(boolean animate) {
- resetGesturesPrompt();
-
- mGesturesAdd.setVisibility(View.GONE);
-
- mGesturesOverlay.clear(false);
-
- PopupWindow window;
- if (mGesturesWindow == null) {
- mGesturesWindow = new PopupWindow(this);
- window = mGesturesWindow;
- window.setFocusable(true);
- window.setTouchable(true);
- window.setBackgroundDrawable(getResources().getDrawable(
- android.R.drawable.screen_background_dark));
- window.setContentView(mGesturesPanel);
- } else {
- window = mGesturesWindow;
- }
- window.setAnimationStyle(animate ? com.android.internal.R.style.Animation_Toast : 0);
-
- final int[] xy = new int[2];
- final DragLayer dragLayer = mDragLayer;
- dragLayer.getLocationOnScreen(xy);
-
- window.setWidth(dragLayer.getWidth());
- window.setHeight(dragLayer.getHeight() - 1);
- window.showAtLocation(dragLayer, Gravity.TOP | Gravity.LEFT, xy[0], xy[1] + 1);
- }
-
- private void resetGesturesPrompt() {
- mGesturesAction.intent = null;
- mGesturesPrompt.setText(R.string.gestures_instructions);
- mGesturesPrompt.setVisibility(View.VISIBLE);
- mGesturesSend.setVisibility(View.GONE);
- }
-
- private void setGestureUnknown() {
- mGesturesAction.intent = null;
- mGesturesPrompt.setText(R.string.gestures_unknown);
- mGesturesPrompt.setVisibility(View.VISIBLE);
- mGesturesSend.setVisibility(View.GONE);
- }
-
- private void setGestureAction(Drawable icon, CharSequence title) {
- mGesturesPrompt.setVisibility(View.GONE);
- mGesturesSend.setVisibility(View.VISIBLE);
- mGesturesSend.setText(title);
- mGesturesSend.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
- }
-
- void hideGesturesPanel() {
- hideGesturesPanel(true);
- }
-
- void hideGesturesPanel(boolean animate) {
- if (mGesturesWindow != null) {
- final PopupWindow popupWindow = mGesturesWindow;
- popupWindow.setAnimationStyle(animate ?
- com.android.internal.R.style.Animation_Toast : 0);
- popupWindow.update();
- popupWindow.dismiss();
- }
- }
-
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
// Do not call super here
@@ -1146,21 +888,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
outState.putBoolean(RUNTIME_STATE_PENDING_FOLDER_RENAME, true);
outState.putLong(RUNTIME_STATE_PENDING_FOLDER_RENAME_ID, mFolderInfo.id);
}
-
- if (mCurrentGesture != null && mWaitingForResult) {
- outState.putParcelable(RUNTIME_STATE_PENDING_GESTURE, mCurrentGesture);
- }
-
- if (mGesturesWindow != null && mGesturesWindow.isShowing()) {
- outState.putBoolean(RUNTIME_STATE_GESTURES_PANEL, true);
-
- if (mCurrentGesture == null || !mWaitingForResult) {
- final Gesture gesture = mGesturesOverlay.getGesture();
- if (gesture != null) {
- outState.putParcelable(RUNTIME_STATE_GESTURES_PANEL_GESTURE, gesture);
- }
- }
- }
}
@Override
@@ -1177,7 +904,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
TextKeyListener.getInstance().release();
- hideGesturesPanel(false);
mAllAppsGrid.clearTextFilter();
mAllAppsGrid.setAdapter(null);
sModel.unbind();
@@ -1280,11 +1006,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
.setIcon(com.android.internal.R.drawable.ic_menu_notifications)
.setAlphabeticShortcut('N');
- // TODO: Remove
- menu.add(0, MENU_GESTURES, 0, R.string.menu_gestures)
- .setIcon(com.android.internal.R.drawable.ic_menu_compose)
- .setAlphabeticShortcut('G');
-
final Intent settings = new Intent(android.provider.Settings.ACTION_SETTINGS);
settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
@@ -1321,9 +1042,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
case MENU_NOTIFICATIONS:
showNotifications();
return true;
- case MENU_GESTURES:
- showGesturesPanel();
- return true;
}
return super.onOptionsItemSelected(item);
@@ -1852,7 +1570,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
}
void startActivitySafely(Intent intent) {
- mHideGesturesPanel = true;
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
startActivity(intent);
@@ -1979,14 +1696,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
return sModel;
}
- static GestureLibrary getGestureLibrary(Context context) {
- if (sLibrary == null) {
- // The context is not kept by the library so it's safe to do this
- sLibrary = GestureLibraries.fromPrivateFile(context, GesturesConstants.STORE_NAME);
- }
- return sLibrary;
- }
-
void closeAllApplications() {
mDrawer.close();
}
@@ -2511,139 +2220,4 @@ public final class Launcher extends Activity implements View.OnClickListener, On
}
}
}
-
- private class GesturesProcessor implements GestureOverlayView.OnGestureListener {
-
- private final GestureMatcher mMatcher = new GestureMatcher();
-
- GesturesProcessor() {
- // TODO: Maybe the load should happen on a background thread?
- sLibrary.load();
- }
-
- public void onGestureStarted(GestureOverlayView overlay, MotionEvent event) {
- //noinspection PointlessBooleanExpression,ConstantConditions
- if (!CONFIG_GESTURES_IMMEDIATE_MODE) {
- overlay.removeCallbacks(mMatcher);
- resetGesturesPrompt();
- }
-
- mGesturesAdd.setVisibility(View.GONE);
- }
-
- public void onGesture(GestureOverlayView overlay, MotionEvent event) {
- }
-
- public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
- if (CONFIG_GESTURES_IMMEDIATE_MODE) {
- mMatcher.gesture = overlay.getGesture();
- if (mMatcher.gesture.getLength() < GesturesConstants.LENGTH_THRESHOLD) {
- overlay.clear(false);
- if (mGesturesAction.intent != null) {
- mGesturesAction.intent = null;
- setGestureAction(null, getString(R.string.gestures_unknown));
- }
- } else {
- mMatcher.run();
- }
- } else {
- overlay.removeCallbacks(mMatcher);
-
- mMatcher.gesture = overlay.getGesture();
- if (mMatcher.gesture.getLength() < GesturesConstants.LENGTH_THRESHOLD) {
- overlay.clear(false);
- if (mGesturesAction.intent != null) {
- mGesturesAction.intent = null;
- setGestureAction(null, getString(R.string.gestures_unknown));
- }
- } else {
- overlay.postDelayed(mMatcher, GesturesConstants.MATCH_DELAY);
- }
- }
- }
-
- void matchGesture(Gesture gesture) {
- mGesturesAdd.setVisibility(View.VISIBLE);
-
- if (gesture != null) {
- final ArrayList<Prediction> predictions = sLibrary.recognize(gesture);
-
- if (DEBUG_GESTURES) {
- for (Prediction p : predictions) {
- d(LOG_TAG, String.format("name=%s, score=%f", p.name, p.score));
- }
- }
-
- boolean match = false;
- if (predictions.size() > 0) {
- final Prediction prediction = predictions.get(0);
- if (prediction.score > GesturesConstants.PREDICTION_THRESHOLD) {
- match = true;
-
- ApplicationInfo info = sModel.queryGesture(Launcher.this, prediction.name);
- if (info != null) {
- updatePrompt(info);
- }
- }
- }
-
- if (!match){
- mGesturesAction.intent = null;
- setGestureUnknown();
- }
- }
- }
-
- private void updatePrompt(ApplicationInfo info) {
- // TODO: BRING BACK
- if (mGesturesAction.intent != null &&
- info.intent.toUri(0).equals(mGesturesAction.intent.toUri(0)) &&
- info.title.equals(mGesturesSend.getText())) {
- return;
- }
-
- setGestureAction(info.icon, info.title);
-
- mGesturesAction.intent = info.intent;
- }
-
- public void onGestureCancelled(GestureOverlayView overlay, MotionEvent event) {
- //noinspection PointlessBooleanExpression,ConstantConditions
- if (!CONFIG_GESTURES_IMMEDIATE_MODE) {
- overlay.removeCallbacks(mMatcher);
- }
- }
-
- void addGesture(String name, Gesture gesture) {
- sLibrary.addGesture(name, gesture);
- // TODO: On a background thread?
- sLibrary.save();
- }
-
- void update(ApplicationInfo info, Gesture gesture) {
- mGesturesOverlay.setGesture(gesture);
- updatePrompt(info);
- }
-
- class GestureMatcher implements Runnable {
- Gesture gesture;
-
- public void run() {
- if (gesture != null) {
- matchGesture(gesture);
- }
- }
- }
- }
-
- private class GesturesAction implements View.OnClickListener {
- Intent intent;
-
- public void onClick(View v) {
- if (intent != null) {
- startActivitySafely(intent);
- }
- }
- }
}
-