Changing long-press-on-workspace behaviour to show Applications & Widgets.
- Disabling tap-on-widgets-to-add in favour of long press Change-Id: Ia82143b74216a968ab11890cba83a01c4ab72a06
This commit is contained in:
parent
ed4c1f1ead
commit
55b6550e37
|
@ -18,7 +18,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:textAppearance="?android:attr/textAppearanceLargeInverse"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:gravity="center_vertical"
|
||||
android:drawablePadding="14dip"
|
||||
android:paddingLeft="15dip"
|
||||
|
|
|
@ -74,6 +74,10 @@
|
|||
<!-- Tile of the tab for applications that were downloaded from market [CHAR_LIMIT=24] -->
|
||||
<string name="all_apps_tab_downloaded">My apps</string>
|
||||
|
||||
<!-- AppsCustomize pane -->
|
||||
<!-- Message to tell the user to long-press on a widget to add it [CHAR_LIMIT=50] -->
|
||||
<string name="long_press_widget_to_add">Long-press to pick up a widget</string>
|
||||
|
||||
<!-- All Apps pane -->
|
||||
<!-- Message to show when there are no games [CHAR_LIMIT=25] -->
|
||||
<string name="all_apps_no_games">No games found.</string>
|
||||
|
|
|
@ -40,6 +40,7 @@ public class AddAdapter extends BaseAdapter {
|
|||
|
||||
public static final int ITEM_SHORTCUT = 0;
|
||||
public static final int ITEM_APPWIDGET = 1;
|
||||
public static final int ITEM_APPLICATION = 2;
|
||||
public static final int ITEM_WALLPAPER = 3;
|
||||
|
||||
/**
|
||||
|
@ -69,8 +70,8 @@ public class AddAdapter extends BaseAdapter {
|
|||
// Create default actions
|
||||
Resources res = launcher.getResources();
|
||||
|
||||
mItems.add(new ListItem(res, R.string.group_shortcuts,
|
||||
R.drawable.ic_launcher_shortcut, ITEM_SHORTCUT));
|
||||
mItems.add(new ListItem(res, R.string.group_applications,
|
||||
R.drawable.ic_launcher_application, ITEM_APPLICATION));
|
||||
|
||||
mItems.add(new ListItem(res, R.string.group_widgets,
|
||||
R.drawable.ic_launcher_appwidget, ITEM_APPWIDGET));
|
||||
|
|
|
@ -25,8 +25,10 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.app.WallpaperManager;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.appwidget.AppWidgetProviderInfo;
|
||||
|
@ -53,10 +55,12 @@ import android.util.Xml;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.launcher.R;
|
||||
|
||||
|
@ -341,31 +345,21 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
|||
});
|
||||
}
|
||||
} else {
|
||||
// Add the widget to the current workspace screen
|
||||
Workspace w = mLauncher.getWorkspace();
|
||||
int currentWorkspaceScreen = mLauncher.getCurrentWorkspaceScreen();
|
||||
final CellLayout cl = (CellLayout) w.getChildAt(currentWorkspaceScreen);
|
||||
final View dragView = v.findViewById(R.id.widget_preview);
|
||||
final ItemInfo itemInfo = (ItemInfo) v.getTag();
|
||||
animateClickFeedback(v, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
cl.calculateSpans(itemInfo);
|
||||
if (cl.findCellForSpan(null, itemInfo.spanX, itemInfo.spanY)) {
|
||||
if (LauncherApplication.isScreenLarge()) {
|
||||
animateItemOntoScreen(dragView, cl, itemInfo);
|
||||
} else {
|
||||
mLauncher.addExternalItemToScreen(itemInfo, cl);
|
||||
itemInfo.dropPos = null;
|
||||
}
|
||||
// Let the user know that they have to long press to add a widget
|
||||
Toast.makeText(getContext(), R.string.long_press_widget_to_add,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
// Hide the pane so we can see the workspace we dropped on
|
||||
mLauncher.showWorkspace(true);
|
||||
} else {
|
||||
mLauncher.showOutOfSpaceMessage();
|
||||
}
|
||||
}
|
||||
});
|
||||
// Create a little animation to show that the widget can move
|
||||
float offsetY = getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);
|
||||
final ImageView p = (ImageView) v.findViewById(R.id.widget_preview);
|
||||
AnimatorSet bounce = new AnimatorSet();
|
||||
ValueAnimator tyuAnim = ObjectAnimator.ofFloat(p, "translationY", offsetY);
|
||||
tyuAnim.setDuration(125);
|
||||
ValueAnimator tydAnim = ObjectAnimator.ofFloat(p, "translationY", 0f);
|
||||
tydAnim.setDuration(100);
|
||||
bounce.play(tyuAnim).before(tydAnim);
|
||||
bounce.setInterpolator(new AccelerateInterpolator());
|
||||
bounce.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,13 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
|||
mLayoutInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
void selectAppsTab() {
|
||||
setCurrentTabByTag(APPS_TAB_TAG);
|
||||
}
|
||||
void selectWidgetsTab() {
|
||||
setCurrentTabByTag(WIDGETS_TAB_TAG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the tab host and create all necessary tabs.
|
||||
*/
|
||||
|
|
|
@ -2230,11 +2230,7 @@ public final class Launcher extends Activity
|
|||
mWorkspace.setAllowLongPress(false);
|
||||
mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
|
||||
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
|
||||
if (LauncherApplication.isScreenLarge()) {
|
||||
addItems();
|
||||
} else {
|
||||
startWallpaper();
|
||||
}
|
||||
addItems();
|
||||
} else {
|
||||
if (!(itemUnderLongClick instanceof Folder)) {
|
||||
// User long pressed on an item
|
||||
|
@ -2970,9 +2966,8 @@ public final class Launcher extends Activity
|
|||
// Change the state *after* we've called all the transition code
|
||||
mState = State.ALL_APPS;
|
||||
} else {
|
||||
View appsCustomizePane = findViewById(R.id.apps_customize_pane);
|
||||
cameraZoomOut(State.APPS_CUSTOMIZE, animated, false);
|
||||
appsCustomizePane.requestFocus();
|
||||
mAppsCustomizeTabHost.requestFocus();
|
||||
|
||||
// Change the state *after* we've called all the transition code
|
||||
mState = State.APPS_CUSTOMIZE;
|
||||
|
@ -3242,12 +3237,11 @@ public final class Launcher extends Activity
|
|||
Dialog createDialog() {
|
||||
mAdapter = new AddAdapter(Launcher.this);
|
||||
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(Launcher.this);
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(Launcher.this,
|
||||
AlertDialog.THEME_HOLO_DARK);
|
||||
builder.setTitle(getString(R.string.menu_item_add_item));
|
||||
builder.setAdapter(mAdapter, this);
|
||||
|
||||
builder.setInverseBackgroundForced(true);
|
||||
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.setOnCancelListener(this);
|
||||
dialog.setOnDismissListener(this);
|
||||
|
@ -3262,6 +3256,8 @@ public final class Launcher extends Activity
|
|||
}
|
||||
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
mWaitingForResult = false;
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
|
@ -3279,22 +3275,26 @@ public final class Launcher extends Activity
|
|||
Resources res = getResources();
|
||||
cleanup();
|
||||
|
||||
switch (which) {
|
||||
AddAdapter.ListItem item = (AddAdapter.ListItem) mAdapter.getItem(which);
|
||||
switch (item.actionTag) {
|
||||
case AddAdapter.ITEM_SHORTCUT: {
|
||||
pickShortcut();
|
||||
break;
|
||||
}
|
||||
|
||||
case AddAdapter.ITEM_APPWIDGET: {
|
||||
int appWidgetId = Launcher.this.mAppWidgetHost.allocateAppWidgetId();
|
||||
|
||||
Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK);
|
||||
pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||
// start the pick activity
|
||||
startActivityForResult(pickIntent, REQUEST_PICK_APPWIDGET);
|
||||
case AddAdapter.ITEM_APPLICATION: {
|
||||
if (mAppsCustomizeTabHost != null) {
|
||||
mAppsCustomizeTabHost.selectAppsTab();
|
||||
}
|
||||
showAllApps(true);
|
||||
break;
|
||||
}
|
||||
case AddAdapter.ITEM_APPWIDGET: {
|
||||
if (mAppsCustomizeTabHost != null) {
|
||||
mAppsCustomizeTabHost.selectWidgetsTab();
|
||||
}
|
||||
showAllApps(true);
|
||||
break;
|
||||
}
|
||||
|
||||
case AddAdapter.ITEM_WALLPAPER: {
|
||||
startWallpaper();
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue