summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornebkat <nebkat@teamhacksung.org>2012-12-23 11:57:11 +0000
committernebkat <nebkat@teamhacksung.org>2012-12-23 12:16:02 +0000
commit10a908a32cab20d5fc0ee944a3b34b98a9648f68 (patch)
treee0780a7b9dc7ed2dc36719ff538955fb1c0c4b48
parenta8d6d217e05240f4108227c0f19f3a9bfd1fc73a (diff)
downloadandroid_packages_apps_Trebuchet-10a908a32cab20d5fc0ee944a3b34b98a9648f68.tar.gz
android_packages_apps_Trebuchet-10a908a32cab20d5fc0ee944a3b34b98a9648f68.tar.bz2
android_packages_apps_Trebuchet-10a908a32cab20d5fc0ee944a3b34b98a9648f68.zip
Workspace: Shortcut renaming
Change-Id: I67e7441b3d6ba4eba70936c2fbdc9d854b706948
-rw-r--r--res/drawable-hdpi/ic_launcher_edit_active_holo.pngbin0 -> 3112 bytes
-rw-r--r--res/drawable-hdpi/ic_launcher_edit_normal_holo.pngbin0 -> 1767 bytes
-rw-r--r--res/drawable-mdpi/ic_launcher_edit_active_holo.pngbin0 -> 1721 bytes
-rw-r--r--res/drawable-mdpi/ic_launcher_edit_normal_holo.pngbin0 -> 999 bytes
-rw-r--r--res/drawable-xhdpi/ic_launcher_edit_active_holo.pngbin0 -> 4340 bytes
-rw-r--r--res/drawable-xhdpi/ic_launcher_edit_normal_holo.pngbin0 -> 4130 bytes
-rw-r--r--res/drawable/edit_target_selector.xml24
-rw-r--r--res/layout/dialog_edit.xml31
-rw-r--r--res/layout/drop_target_bar.xml11
-rw-r--r--res/values/colors.xml1
-rw-r--r--res/values/strings.xml2
-rw-r--r--src/com/cyanogenmod/trebuchet/BubbleTextView.java12
-rw-r--r--src/com/cyanogenmod/trebuchet/EditDropTarget.java124
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java28
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherModel.java14
-rw-r--r--src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java6
-rw-r--r--src/com/cyanogenmod/trebuchet/ShortcutInfo.java20
-rw-r--r--src/com/cyanogenmod/trebuchet/Workspace.java4
18 files changed, 267 insertions, 10 deletions
diff --git a/res/drawable-hdpi/ic_launcher_edit_active_holo.png b/res/drawable-hdpi/ic_launcher_edit_active_holo.png
new file mode 100644
index 000000000..7efd048d5
--- /dev/null
+++ b/res/drawable-hdpi/ic_launcher_edit_active_holo.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_launcher_edit_normal_holo.png b/res/drawable-hdpi/ic_launcher_edit_normal_holo.png
new file mode 100644
index 000000000..6d2071d32
--- /dev/null
+++ b/res/drawable-hdpi/ic_launcher_edit_normal_holo.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_launcher_edit_active_holo.png b/res/drawable-mdpi/ic_launcher_edit_active_holo.png
new file mode 100644
index 000000000..54e971689
--- /dev/null
+++ b/res/drawable-mdpi/ic_launcher_edit_active_holo.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_launcher_edit_normal_holo.png b/res/drawable-mdpi/ic_launcher_edit_normal_holo.png
new file mode 100644
index 000000000..d70376b92
--- /dev/null
+++ b/res/drawable-mdpi/ic_launcher_edit_normal_holo.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_launcher_edit_active_holo.png b/res/drawable-xhdpi/ic_launcher_edit_active_holo.png
new file mode 100644
index 000000000..d9adc90ee
--- /dev/null
+++ b/res/drawable-xhdpi/ic_launcher_edit_active_holo.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_launcher_edit_normal_holo.png b/res/drawable-xhdpi/ic_launcher_edit_normal_holo.png
new file mode 100644
index 000000000..9315f0f10
--- /dev/null
+++ b/res/drawable-xhdpi/ic_launcher_edit_normal_holo.png
Binary files differ
diff --git a/res/drawable/edit_target_selector.xml b/res/drawable/edit_target_selector.xml
new file mode 100644
index 000000000..3a70300f6
--- /dev/null
+++ b/res/drawable/edit_target_selector.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2011, 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.
+*/
+-->
+
+<transition xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:drawable="@drawable/ic_launcher_edit_normal_holo" />
+ <item android:drawable="@drawable/ic_launcher_edit_active_holo" />
+</transition> \ No newline at end of file
diff --git a/res/layout/dialog_edit.xml b/res/layout/dialog_edit.xml
new file mode 100644
index 000000000..40dfd62cd
--- /dev/null
+++ b/res/layout/dialog_edit.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:layout_height="wrap_content"
+ android:paddingBottom="5dp"
+ android:paddingLeft="8dp"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
+ <ImageButton
+ android:padding="5dp"
+ android:layout_width="@android:dimen/app_icon_size"
+ style="?android:attr/borderlessButtonStyle"
+ android:id="@+id/dialog_edit_icon"
+ android:layout_height="@android:dimen/app_icon_size" />
+ <View
+ android:layout_width="2dp"
+ android:layout_height="match_parent"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:layout_marginRight="5dp"
+ android:layout_marginLeft="5dp"
+ android:background="@android:drawable/divider_horizontal_dark" />
+ <EditText
+ android:layout_width="match_parent"
+ android:gravity="left|center_vertical"
+ android:paddingLeft="5dp"
+ android:layout_height="wrap_content"
+ android:id="@+id/dialog_edit_text" />
+</LinearLayout> \ No newline at end of file
diff --git a/res/layout/drop_target_bar.xml b/res/layout/drop_target_bar.xml
index dbd1a295d..8951b3f57 100644
--- a/res/layout/drop_target_bar.xml
+++ b/res/layout/drop_target_bar.xml
@@ -36,4 +36,15 @@
android:text="@string/info_target_label"
android:drawableLeft="@drawable/info_target_selector" />
</FrameLayout>
+ <FrameLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@style/DropTargetButtonContainer"
+ android:layout_weight="1">
+ <!-- Edit target -->
+ <com.cyanogenmod.trebuchet.EditDropTarget
+ style="@style/DropTargetButton"
+ android:id="@+id/edit_target_text"
+ android:text="@string/edit_target_label"
+ android:drawableLeft="@drawable/edit_target_selector" />
+ </FrameLayout>
</merge> \ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index c2e1e7b4d..d792f5e14 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -22,6 +22,7 @@
over the delete target or the info target -->
<color name="delete_target_hover_tint">#DAFF0000</color>
<color name="info_target_hover_tint">#DA0099CC</color>
+ <color name="edit_target_hover_tint">#DACCCC00</color>
<color name="bubble_dark_background">#20000000</color>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 30d410716..a182d65cf 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -127,6 +127,8 @@ s -->
<string name="delete_target_uninstall_label">Uninstall</string>
<!-- Label for the info icon. [CHAR_LIMIT=30] -->
<string name="info_target_label">App info</string>
+ <!-- Label for the info icon. [CHAR_LIMIT=30] -->
+ <string name="edit_target_label">Edit</string>
<!-- Accessibility: Search button -->
<string name="accessibility_search_button">Search</string>
diff --git a/src/com/cyanogenmod/trebuchet/BubbleTextView.java b/src/com/cyanogenmod/trebuchet/BubbleTextView.java
index 739440bdc..4c94bc97b 100644
--- a/src/com/cyanogenmod/trebuchet/BubbleTextView.java
+++ b/src/com/cyanogenmod/trebuchet/BubbleTextView.java
@@ -33,7 +33,7 @@ import android.widget.TextView;
* because we want to make the bubble taller than the text and TextView's clip is
* too aggressive.
*/
-public class BubbleTextView extends TextView {
+public class BubbleTextView extends TextView implements ShortcutInfo.ShortcutListener {
static final float CORNER_RADIUS = 4.0f;
static final float SHADOW_LARGE_RADIUS = 4.0f;
static final float SHADOW_SMALL_RADIUS = 1.75f;
@@ -98,6 +98,7 @@ public class BubbleTextView extends TextView {
null, null);
setText(info.title);
setTag(info);
+ info.setListener(this);
}
@Override
@@ -161,6 +162,15 @@ public class BubbleTextView extends TextView {
super.drawableStateChanged();
}
+ @Override
+ public void onTitleChanged(CharSequence title) {
+ if (mTextVisible) {
+ setText(title);
+ } else {
+ mVisibleText = title;
+ }
+ }
+
/**
* Draw this BubbleTextView into the given Canvas.
*
diff --git a/src/com/cyanogenmod/trebuchet/EditDropTarget.java b/src/com/cyanogenmod/trebuchet/EditDropTarget.java
new file mode 100644
index 000000000..7089ef4b6
--- /dev/null
+++ b/src/com/cyanogenmod/trebuchet/EditDropTarget.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2011 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.cyanogenmod.trebuchet;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.res.ColorStateList;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.graphics.drawable.TransitionDrawable;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.cyanogenmod.trebuchet.R;
+
+public class EditDropTarget extends ButtonDropTarget {
+
+ private ColorStateList mOriginalTextColor;
+ private TransitionDrawable mDrawable;
+
+ public EditDropTarget(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public EditDropTarget(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+
+ mOriginalTextColor = getTextColors();
+
+ // Get the hover color
+ Resources r = getResources();
+ mHoverColor = r.getColor(R.color.edit_target_hover_tint);
+ mDrawable = (TransitionDrawable) getCurrentDrawable();
+ mDrawable.setCrossFadeEnabled(true);
+
+ // Remove the text in the Phone UI in landscape
+ int orientation = getResources().getConfiguration().orientation;
+ if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ if (!LauncherApplication.isScreenLarge()) {
+ setText("");
+ }
+ }
+ }
+
+ private boolean isDragSourceWorkspaceOrFolder(DragSource source) {
+ return (source instanceof Workspace) || (source instanceof Folder);
+ }
+ private boolean isWorkspaceOrFolderApplication(DragSource source, Object info) {
+ return isDragSourceWorkspaceOrFolder(source) && (info instanceof ShortcutInfo);
+ }
+
+ @Override
+ public boolean acceptDrop(DragObject d) {
+ // acceptDrop is called just before onDrop. We do the work here, rather than
+ // in onDrop, because it allows us to reject the drop (by returning false)
+ // so that the object being dragged isn't removed from the drag source.
+ if (d.dragInfo instanceof ShortcutInfo) {
+ mLauncher.updateShortcut((ShortcutInfo) d.dragInfo);
+ } else if (d.dragInfo instanceof Folder) {
+ //
+ }
+
+ // There is no post-drop animation, so clean up the DragView now
+ d.deferDragViewCleanupPostAnimation = false;
+ return false;
+ }
+
+ @Override
+ public void onDragStart(DragSource source, Object info, int dragAction) {
+ boolean isVisible = true;
+
+ // Hide this button unless we are dragging something from AllApps
+ if (!isWorkspaceOrFolderApplication(source, info)) {
+ isVisible = false;
+ }
+
+ mActive = isVisible;
+ mDrawable.resetTransition();
+ setTextColor(mOriginalTextColor);
+ ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE);
+ }
+
+ @Override
+ public void onDragEnd() {
+ super.onDragEnd();
+ mActive = false;
+ }
+
+ public void onDragEnter(DragObject d) {
+ super.onDragEnter(d);
+
+ mDrawable.startTransition(mTransitionDuration);
+ setTextColor(mHoverColor);
+ }
+
+ public void onDragExit(DragObject d) {
+ super.onDragExit(d);
+
+ if (!d.dragComplete) {
+ mDrawable.resetTransition();
+ setTextColor(mOriginalTextColor);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java
index 3450db6bf..e43029d2f 100644
--- a/src/com/cyanogenmod/trebuchet/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -29,6 +29,7 @@ import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityOptions;
+import android.app.AlertDialog;
import android.app.SearchManager;
import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetManager;
@@ -39,6 +40,7 @@ import android.content.ComponentCallbacks2;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
@@ -89,6 +91,7 @@ import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.inputmethod.InputMethodManager;
import android.widget.Advanceable;
+import android.widget.EditText;
import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.TextView;
@@ -983,6 +986,31 @@ public final class Launcher extends Activity
}
/**
+ * Starts shortcut rename dialog.
+ *
+ * @param info The shortcut to be edited
+ */
+ void updateShortcut(final ShortcutInfo info) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ View layout = mInflater.inflate(R.layout.dialog_edit, null);
+ ImageView icon = (ImageView) layout.findViewById(R.id.dialog_edit_icon);
+ icon.setImageBitmap(info.getIcon(mIconCache));
+ final EditText title = (EditText) layout.findViewById(R.id.dialog_edit_text);
+ title.setText(info.title);
+ builder.setView(layout)
+ .setTitle(info.title)
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ info.setTitle(title.getText());
+ LauncherModel.updateItemInDatabase(Launcher.this, info);
+ }
+ })
+ .setNegativeButton(android.R.string.cancel, null);
+ builder.show();
+ }
+
+ /**
* Creates a view representing a shortcut.
*
* @param info The data structure describing the shortcut.
diff --git a/src/com/cyanogenmod/trebuchet/LauncherModel.java b/src/com/cyanogenmod/trebuchet/LauncherModel.java
index 39281d5e7..8fd446c9e 100644
--- a/src/com/cyanogenmod/trebuchet/LauncherModel.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherModel.java
@@ -2153,8 +2153,14 @@ public class LauncherModel extends BroadcastReceiver {
}
info.setIcon(icon);
+ // from the db
+ if (info.title == null) {
+ if (c != null) {
+ info.title = c.getString(titleIndex);
+ }
+ }
// from the resource
- if (resolveInfo != null) {
+ if (info.title == null && resolveInfo != null) {
ComponentName key = LauncherModel.getComponentNameFromResolveInfo(resolveInfo);
if (labelCache != null && labelCache.containsKey(key)) {
info.title = labelCache.get(key);
@@ -2165,12 +2171,6 @@ public class LauncherModel extends BroadcastReceiver {
}
}
}
- // from the db
- if (info.title == null) {
- if (c != null) {
- info.title = c.getString(titleIndex);
- }
- }
// fall back to the class name of the activity
if (info.title == null) {
info.title = componentName.getClassName();
diff --git a/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java b/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java
index 1f6335fdf..075adae53 100644
--- a/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java
+++ b/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java
@@ -51,6 +51,7 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
private View mDropTargetBar;
private ButtonDropTarget mInfoDropTarget;
private ButtonDropTarget mDeleteDropTarget;
+ private ButtonDropTarget mEditDropTarget;
private int mBarHeight;
private boolean mDeferOnDragEnd = false;
@@ -71,11 +72,14 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
dragController.addDragListener(this);
dragController.addDragListener(mInfoDropTarget);
dragController.addDragListener(mDeleteDropTarget);
+ dragController.addDragListener(mEditDropTarget);
dragController.addDropTarget(mInfoDropTarget);
dragController.addDropTarget(mDeleteDropTarget);
+ dragController.addDropTarget(mEditDropTarget);
dragController.setFlingToDeleteDropTarget(mDeleteDropTarget);
mInfoDropTarget.setLauncher(launcher);
mDeleteDropTarget.setLauncher(launcher);
+ mEditDropTarget.setLauncher(launcher);
}
private void prepareStartAnimation(View v) {
@@ -105,10 +109,12 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
mDropTargetBar = findViewById(R.id.drag_target_bar);
mInfoDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.info_target_text);
mDeleteDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.delete_target_text);
+ mEditDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.edit_target_text);
mBarHeight = getResources().getDimensionPixelSize(R.dimen.qsb_bar_height);
mInfoDropTarget.setSearchDropTargetBar(this);
mDeleteDropTarget.setSearchDropTargetBar(this);
+ mEditDropTarget.setSearchDropTargetBar(this);
mEnableDropDownDropTargets =
getResources().getBoolean(R.bool.config_useDropTargetDownTransition);
diff --git a/src/com/cyanogenmod/trebuchet/ShortcutInfo.java b/src/com/cyanogenmod/trebuchet/ShortcutInfo.java
index cce432d7a..3c1f98557 100644
--- a/src/com/cyanogenmod/trebuchet/ShortcutInfo.java
+++ b/src/com/cyanogenmod/trebuchet/ShortcutInfo.java
@@ -57,6 +57,11 @@ class ShortcutInfo extends ItemInfo {
*/
private Bitmap mIcon;
+ /**
+ * Title change listener
+ */
+ private ShortcutListener mListener;
+
ShortcutInfo() {
itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
}
@@ -119,6 +124,17 @@ class ShortcutInfo extends ItemInfo {
itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_APPLICATION;
}
+ public void setTitle(CharSequence title) {
+ this.title = title;
+ if (mListener != null) {
+ mListener.onTitleChanged(title);
+ }
+ }
+
+ void setListener(ShortcutListener listener) {
+ mListener = listener;
+ }
+
@Override
void onAddToDatabase(ContentValues values) {
super.onAddToDatabase(values);
@@ -164,5 +180,9 @@ class ShortcutInfo extends ItemInfo {
+ " customIcon=" + info.customIcon);
}
}
+
+ interface ShortcutListener {
+ public void onTitleChanged(CharSequence title);
+ }
}
diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java
index 3fc4ddf31..4219e2bfa 100644
--- a/src/com/cyanogenmod/trebuchet/Workspace.java
+++ b/src/com/cyanogenmod/trebuchet/Workspace.java
@@ -4048,8 +4048,8 @@ public class Workspace extends SmoothPagedView
}
cellLayout.onDropChild(mDragInfo.cell);
}
- if (d.cancelled && mDragInfo.cell != null) {
- mDragInfo.cell.setVisibility(VISIBLE);
+ if (mDragInfo.cell != null) {
+ mDragInfo.cell.setVisibility(VISIBLE);
}
mDragOutline = null;
mDragInfo = null;