diff --git a/res/drawable/shortcut_selector.xml b/res/drawable/shortcut_selector.xml
index 884bccffea..8059f00867 100644
--- a/res/drawable/shortcut_selector.xml
+++ b/res/drawable/shortcut_selector.xml
@@ -19,7 +19,7 @@
-->
-
-
+
+
diff --git a/res/layout-xlarge-land/all_apps_tabbed.xml b/res/layout-xlarge-land/all_apps_tabbed.xml
index eb506d16f9..bb30c11a04 100644
--- a/res/layout-xlarge-land/all_apps_tabbed.xml
+++ b/res/layout-xlarge-land/all_apps_tabbed.xml
@@ -31,12 +31,36 @@
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:tabStripEnabled="false" />
-
+ android:layout_centerVertical="true">
+
+
+
+
\ No newline at end of file
+ style="@style/WorkspaceIcon.Landscape" />
diff --git a/res/layout-xlarge-land/customization_drawer.xml b/res/layout-xlarge-land/customization_drawer.xml
index 304aaf70a8..3fff2b094c 100644
--- a/res/layout-xlarge-land/customization_drawer.xml
+++ b/res/layout-xlarge-land/customization_drawer.xml
@@ -19,7 +19,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
- launcher:wallpaperCellSpanX="4"
+ launcher:wallpaperCellSpanX="3"
launcher:widgetCellCountX="16"
launcher:cellCountX="8"
launcher:cellCountY="3"
diff --git a/res/layout-xlarge-land/launcher.xml b/res/layout-xlarge-land/launcher.xml
index 0fc954b18e..7b66d7c22f 100644
--- a/res/layout-xlarge-land/launcher.xml
+++ b/res/layout-xlarge-land/launcher.xml
@@ -125,7 +125,13 @@
android:layout_toLeftOf="@id/configure_button"
android:layout_marginLeft="@dimen/toolbar_button_spacing"
android:layout_marginRight="@dimen/toolbar_button_spacing"
- android:textSize="18dp"
+ android:textColor="#CCFFFFFF"
+ android:textSize="18sp"
+
+ android:shadowColor="#A0000000"
+ android:shadowDx="0.0"
+ android:shadowDy="0.0"
+ android:shadowRadius="2.0"
android:onClick="onClickAllAppsButton"
android:focusable="true"
diff --git a/res/layout-xlarge-port/all_apps_tabbed.xml b/res/layout-xlarge-port/all_apps_tabbed.xml
index 038a9a0397..557163432b 100644
--- a/res/layout-xlarge-port/all_apps_tabbed.xml
+++ b/res/layout-xlarge-port/all_apps_tabbed.xml
@@ -31,12 +31,36 @@
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:tabStripEnabled="false" />
-
+ android:layout_centerVertical="true">
+
+
+
+
diff --git a/res/layout-xlarge/customize_paged_view_wallpaper.xml b/res/layout-xlarge/customize_paged_view_wallpaper.xml
index 6cf248ad2a..e3be86d87a 100644
--- a/res/layout-xlarge/customize_paged_view_wallpaper.xml
+++ b/res/layout-xlarge/customize_paged_view_wallpaper.xml
@@ -13,8 +13,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
+ android:orientation="vertical"
+
+ launcher:blurColor="#FF6B8CF0"
+ launcher:outlineColor="#FF8CD2FF">
-
+
diff --git a/res/layout-xlarge/customize_paged_view_widget.xml b/res/layout-xlarge/customize_paged_view_widget.xml
index deeeb3d52c..3b95ebc661 100644
--- a/res/layout-xlarge/customize_paged_view_widget.xml
+++ b/res/layout-xlarge/customize_paged_view_widget.xml
@@ -13,20 +13,21 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
+ launcher:blurColor="#FF6B8CF0"
+ launcher:outlineColor="#FF8CD2FF">
-
+
diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml
index 3a47deaa96..3b3ed4374d 100644
--- a/res/values-cs/strings.xml
+++ b/res/values-cs/strings.xml
@@ -39,8 +39,7 @@
"Stažené"
"Nenalezeny žádné hry."
"Žádné stažené aplikace."
-
-
+ "Na tuto plochu nelze položku přetáhnout"
"Název složky"
diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml
index c898d67415..444f5025ba 100644
--- a/res/values-da/strings.xml
+++ b/res/values-da/strings.xml
@@ -39,8 +39,7 @@
"Downloadet"
"Ingen spil."
"Ingen hentede programmer."
-
-
+ "Kunne ikke slippe elementet på denne startskærm"
"Mappenavn"
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
index 8ae01014a7..485cfc8bca 100644
--- a/res/values-de/strings.xml
+++ b/res/values-de/strings.xml
@@ -39,8 +39,7 @@
"Heruntergeladen"
"Keine Spiele gefunden."
"Keine heruntergeladenen Apps"
-
-
+ "Element wurde nicht auf Startbildschirm abgelegt."
"Ordnername"
diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml
index 442a5d5b87..d6884995f6 100644
--- a/res/values-el/strings.xml
+++ b/res/values-el/strings.xml
@@ -39,8 +39,7 @@
"Η λήψη ολοκληρώθηκε"
"Δεν βρέθηκαν παιχνίδια."
"Δεν βρέθηκαν ληφθ. εφαρμ."
-
-
+ "Δεν έγινε η απόθ. του στοιχείου στην αρχική οθόνη"
"Όνομα φακέλου"
diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml
index ed7a0f2146..a1632c144b 100644
--- a/res/values-es-rUS/strings.xml
+++ b/res/values-es-rUS/strings.xml
@@ -39,8 +39,7 @@
"Descargado"
"No se encontraron juegos."
"No se encontraron apps."
-
-
+ "No se pudo colocar el elemento en esta pantalla principal"
"Nombre de carpeta"
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml
index b173de0b6d..f9ed9bb3e7 100644
--- a/res/values-es/strings.xml
+++ b/res/values-es/strings.xml
@@ -39,8 +39,7 @@
"Descargadas"
"No hay juegos."
"Sin aplicaciones descarg."
-
-
+ "No se puede soltar el elemento en este escritorio."
"Nombre de carpeta"
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index 0b9e81688b..831f759695 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -39,8 +39,7 @@
"Téléchargées"
"Aucun jeu n\'a été trouvé."
"Pas d\'application téléchargée"
-
-
+ "Impossible de déposer l\'élément sur l\'écran d\'accueil."
"Nom du dossier"
diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml
index 1763f55d1b..e8c6476371 100644
--- a/res/values-it/strings.xml
+++ b/res/values-it/strings.xml
@@ -39,8 +39,7 @@
"Scaricate"
"Nessun gioco trovato."
"Nessuna appl. scaricata"
-
-
+ "Impossibile rilasciare elemento in schermata Home"
"Nome cartella"
diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml
index 776e8add8c..48fb10c8d7 100644
--- a/res/values-ja/strings.xml
+++ b/res/values-ja/strings.xml
@@ -39,8 +39,7 @@
"ダウンロード済み"
"ゲームなし"
"ダウンロードアプリなし"
-
-
+ "このホーム画面にアイテムをドロップできませんでした"
"フォルダ名"
diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml
index d1bab2a5d7..161b31c2e9 100644
--- a/res/values-ko/strings.xml
+++ b/res/values-ko/strings.xml
@@ -39,8 +39,7 @@
"다운로드앱"
"게임이 없습니다."
"다운로드한 애플리케이션이 없습니다."
-
-
+ "홈 화면에 항목을 드롭할 수 없습니다."
"폴더 이름"
diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml
index e83ce4504d..bf8ed3050a 100644
--- a/res/values-nb/strings.xml
+++ b/res/values-nb/strings.xml
@@ -39,8 +39,7 @@
"Nedlastet"
"Finner ingen spill."
"Finner ingen nedl.prog."
-
-
+ "Kunne ikke slippe elementet på denne startskjermen"
"Mappenavn"
diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml
index 541dbc85ad..506d6ed858 100644
--- a/res/values-nl/strings.xml
+++ b/res/values-nl/strings.xml
@@ -39,8 +39,7 @@
"Gedownload"
"Geen games gevonden."
"Geen gedownl. apps gevond."
-
-
+ "Kan item niet neerzetten op dit startscherm"
"Mapnaam"
diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml
index d5c8fef379..594785db11 100644
--- a/res/values-pl/strings.xml
+++ b/res/values-pl/strings.xml
@@ -39,8 +39,7 @@
"Pobrane"
"Nie znaleziono gier."
"Brak pobranych aplikacji."
-
-
+ "Nie można upuścić elementu na ekranie głównym"
"Nazwa folderu"
diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml
index 12b65c9222..ab054e8972 100644
--- a/res/values-pt-rPT/strings.xml
+++ b/res/values-pt-rPT/strings.xml
@@ -39,8 +39,7 @@
"Transferidas"
"Sem jogos."
"Sem aplic. transferidas."
-
-
+ "Não foi possível largar o item neste ecrã inicial"
"Nome da pasta"
diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml
index fd2f12a513..4c132bcd2d 100644
--- a/res/values-pt/strings.xml
+++ b/res/values-pt/strings.xml
@@ -39,8 +39,7 @@
"Download concluído"
"Nenhum jogo encontrado."
"Nenhum aplic. encontrado."
-
-
+ "Não foi possível soltar o item nesta tela inicial"
"Nome da pasta"
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml
index 9abc657c32..4b2844a254 100644
--- a/res/values-ru/strings.xml
+++ b/res/values-ru/strings.xml
@@ -39,8 +39,7 @@
"Загруженные"
"Игр не найдено."
"Нет загруженных приложений."
-
-
+ "Не удается скопировать элемент на главный экран"
"Название папки"
diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml
index 8a00147e4c..7c914cb123 100644
--- a/res/values-sv/strings.xml
+++ b/res/values-sv/strings.xml
@@ -39,8 +39,7 @@
"Hämtade"
"Inga spel hittades."
"Inga hämtade appar."
-
-
+ "Objektet kunde inte släppas på den här startsidan"
"Mappnamn"
diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml
index 2da3997c19..5810c479e0 100644
--- a/res/values-tr/strings.xml
+++ b/res/values-tr/strings.xml
@@ -39,8 +39,7 @@
"İndirilenler"
"Oyun bulunamadı."
"İndirilmş uyg bulunamadı."
-
-
+ "Öğe bu ana ekrana bırakılamadı"
"Klasör adı"
diff --git a/res/values-xlarge/config.xml b/res/values-xlarge/config.xml
index 3654753284..55a96f6e91 100644
--- a/res/values-xlarge/config.xml
+++ b/res/values-xlarge/config.xml
@@ -26,8 +26,8 @@
- 350
- 350
+ 100
+ 100
50dip
- 10dip
- 20dip
+ 20dip
170dp
diff --git a/res/values-xlarge/styles.xml b/res/values-xlarge/styles.xml
index 5198d3048c..7208d979f1 100644
--- a/res/values-xlarge/styles.xml
+++ b/res/values-xlarge/styles.xml
@@ -31,12 +31,13 @@
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 6f1ace78b9..a94b6a78eb 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -39,8 +39,7 @@
"已下载"
"未找到游戏。"
"未找到已下载的应用程序。"
-
-
+ "无法将该项放到主屏幕上"
"文件夹名称"
diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml
index 430858477a..bb5309a42c 100644
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/strings.xml
@@ -39,8 +39,7 @@
"下載內容"
"找不到遊戲。"
"找不到已下載的應用程式。"
-
-
+ "無法將項目拖放至主螢幕上"
"資料夾名稱"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 975548e9ce..853d49e153 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -74,6 +74,15 @@
+
+
+
+
+
+
+
+
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 3e964c4ca7..57f8bfc220 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -20,7 +20,7 @@
#FF191919
#EB191919
- #B2191919
+ #20000000
#A5FF0000
#FCCC
diff --git a/res/values/styles.xml b/res/values/styles.xml
index c867d3854b..3305299708 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -38,7 +38,7 @@
- 13dip
- true
- marquee
- - #FF000000
+ - #B0000000
- 2.0
- #FFF
- center_horizontal
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index 4ca5b474e2..ecdb7b3f01 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -24,12 +24,8 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
-import android.view.ActionMode;
import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.Checkable;
import android.widget.TextView;
@@ -42,7 +38,7 @@ import com.android.launcher.R;
*/
public class AllAppsPagedView extends PagedView
implements AllAppsView, View.OnClickListener, View.OnLongClickListener, DragSource,
- DropTarget, ActionMode.Callback {
+ DropTarget {
private static final String TAG = "AllAppsPagedView";
private static final boolean DEBUG = false;
@@ -69,11 +65,6 @@ public class AllAppsPagedView extends PagedView
private final LayoutInflater mInflater;
- private ViewGroup mOrigInfoButtonParent;
- private LayoutParams mOrigInfoButtonLayoutParams;
-
- private ViewGroup mOrigDeleteZoneParent;
- private LayoutParams mOrigDeleteZoneLayoutParams;
public AllAppsPagedView(Context context) {
this(context, null);
@@ -207,6 +198,47 @@ public class AllAppsPagedView extends PagedView
}
}
+ private void setupDragMode() {
+ mLauncher.getWorkspace().shrinkToBottomVisible();
+
+ ApplicationInfoDropTarget infoButton =
+ (ApplicationInfoDropTarget) mLauncher.findViewById(R.id.info_button);
+ infoButton.setDragAndDropEnabled(false);
+ DeleteZone deleteZone = (DeleteZone) mLauncher.findViewById(R.id.delete_zone);
+ deleteZone.setDragAndDropEnabled(false);
+
+ ApplicationInfoDropTarget allAppsInfoButton =
+ (ApplicationInfoDropTarget) mLauncher.findViewById(R.id.all_apps_info_target);
+ allAppsInfoButton.setDragAndDropEnabled(true);
+ DeleteZone allAppsDeleteZone = (DeleteZone)
+ mLauncher.findViewById(R.id.all_apps_delete_zone);
+ allAppsDeleteZone.setDragAndDropEnabled(true);
+ }
+
+ private void tearDownDragMode() {
+ post(new Runnable() {
+ // Once the drag operation has fully completed, hence the post, we want to disable the
+ // deleteZone and the appInfoButton in all apps, and re-enable the instance which
+ // live in the workspace
+ public void run() {
+ ApplicationInfoDropTarget infoButton =
+ (ApplicationInfoDropTarget) mLauncher.findViewById(R.id.info_button);
+ infoButton.setDragAndDropEnabled(true);
+ DeleteZone deleteZone = (DeleteZone) mLauncher.findViewById(R.id.delete_zone);
+ deleteZone.setDragAndDropEnabled(true);
+
+ ApplicationInfoDropTarget allAppsInfoButton =
+ (ApplicationInfoDropTarget) mLauncher.findViewById(R.id.all_apps_info_target);
+ allAppsInfoButton.setDragAndDropEnabled(false);
+ DeleteZone allAppsDeleteZone =
+ (DeleteZone) mLauncher.findViewById(R.id.all_apps_delete_zone);
+ allAppsDeleteZone.setDragAndDropEnabled(false);
+ }
+ });
+ resetCheckedGrandchildren();
+ mDragController.removeDropTarget(this);
+ }
+
@Override
public boolean onLongClick(View v) {
if (!v.isInTouchMode()) {
@@ -223,10 +255,8 @@ public class AllAppsPagedView extends PagedView
c.toggle();
}
- // Start choice mode AFTER the item is selected
- if (isChoiceMode(CHOICE_MODE_NONE)) {
- startChoiceMode(CHOICE_MODE_SINGLE, this);
- }
+ // Start drag mode after the item is selected
+ setupDragMode();
ApplicationInfo app = (ApplicationInfo) v.getTag();
app = new ApplicationInfo(app);
@@ -246,6 +276,7 @@ public class AllAppsPagedView extends PagedView
if (target != this) {
endChoiceMode();
}
+ tearDownDragMode();
mLauncher.getWorkspace().onDragStopped();
}
@@ -467,83 +498,6 @@ public class AllAppsPagedView extends PagedView
new PagedViewCellLayout.LayoutParams(0, 0, 2, 1));
}
}
- @Override
- public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
- mode.setTitle(R.string.cab_app_selection_text);
-
- // Until the workspace has a selection mode and the CAB supports drag-and-drop, we
- // take a hybrid approach: grab the views from the workspace and stuff them into the CAB.
- // When the action mode is done, restore the views to their original place in the toolbar.
-
- ApplicationInfoDropTarget infoButton =
- (ApplicationInfoDropTarget) mLauncher.findViewById(R.id.info_button);
- mOrigInfoButtonParent = (ViewGroup) infoButton.getParent();
- mOrigInfoButtonLayoutParams = infoButton.getLayoutParams();
- mOrigInfoButtonParent.removeView(infoButton);
- infoButton.setManageVisibility(false);
- infoButton.setVisibility(View.VISIBLE);
- infoButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- final ApplicationInfo appInfo = (ApplicationInfo) getChosenItem();
- mLauncher.startApplicationDetailsActivity(appInfo.componentName);
- }
- });
-
- DeleteZone deleteZone = (DeleteZone) mLauncher.findViewById(R.id.delete_zone);
- mOrigDeleteZoneParent = (ViewGroup) deleteZone.getParent();
- mOrigDeleteZoneLayoutParams = deleteZone.getLayoutParams();
- mOrigDeleteZoneParent.removeView(deleteZone);
- deleteZone.setManageVisibility(false);
- deleteZone.setVisibility(View.VISIBLE);
- deleteZone.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- final ApplicationInfo appInfo = (ApplicationInfo) getChosenItem();
- mLauncher.startApplicationUninstallActivity(appInfo);
- }
- });
-
- menu.add(0, MENU_DELETE_APP, 0, R.string.cab_menu_delete_app).setActionView(deleteZone);
- menu.add(0, MENU_APP_INFO, 0, R.string.cab_menu_app_info).setActionView(infoButton);
-
- mLauncher.getWorkspace().shrinkToBottomVisible();
-
- return true;
- }
-
- @Override
- public boolean onCreateActionMode(ActionMode mode, Menu menu) {
- mDragController.addDropTarget(this);
- return true;
- }
-
- @Override
- public void onDestroyActionMode(ActionMode mode) {
- final Menu menu = mode.getMenu();
-
- // Re-parent the drop targets into the toolbar, and restore their layout params
-
- ApplicationInfoDropTarget infoButton =
- (ApplicationInfoDropTarget) menu.findItem(MENU_APP_INFO).getActionView();
- ((ViewGroup) infoButton.getParent()).removeView(infoButton);
- mOrigInfoButtonParent.addView(infoButton, mOrigInfoButtonLayoutParams);
- infoButton.setVisibility(View.GONE);
- infoButton.setManageVisibility(true);
-
- DeleteZone deleteZone = (DeleteZone) menu.findItem(MENU_DELETE_APP).getActionView();
- ((ViewGroup) deleteZone.getParent()).removeView(deleteZone);
- mOrigDeleteZoneParent.addView(deleteZone, mOrigDeleteZoneLayoutParams);
- deleteZone.setVisibility(View.GONE);
- deleteZone.setManageVisibility(true);
-
- mDragController.removeDropTarget(this);
- endChoiceMode();
- }
-
- @Override
- public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
- // This is never called. Because we use setActionView(), we handle our own click events.
- return false;
- }
/*
* We don't actually use AllAppsPagedView as a drop target... it's only used to intercept a drop
diff --git a/src/com/android/launcher2/ApplicationInfoDropTarget.java b/src/com/android/launcher2/ApplicationInfoDropTarget.java
index c2922ab377..849d2b5862 100644
--- a/src/com/android/launcher2/ApplicationInfoDropTarget.java
+++ b/src/com/android/launcher2/ApplicationInfoDropTarget.java
@@ -16,8 +16,6 @@
package com.android.launcher2;
-import com.android.launcher.R;
-
import android.content.ComponentName;
import android.content.Context;
import android.graphics.Paint;
@@ -28,6 +26,8 @@ import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
+import com.android.launcher.R;
+
/**
* Implements a DropTarget which allows applications to be dropped on it,
* in order to launch the application info for that app.
@@ -41,7 +41,7 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
* This is generally the case, but it will be set to false when this is part of the
* Contextual Action Bar.
*/
- private boolean mManageVisibility = true;
+ private boolean mDragAndDropEnabled = true;
/** The view that this view should appear in the place of. */
private View mHandle = null;
@@ -69,6 +69,7 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
// 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 home screen.
+ if (getVisibility() != VISIBLE) return false;
ComponentName componentName = null;
if (dragInfo instanceof ApplicationInfo) {
@@ -87,6 +88,7 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
DragView dragView, Object dragInfo) {
+ if (!mDragAndDropEnabled) return;
dragView.setPaint(mPaint);
}
@@ -96,18 +98,20 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
DragView dragView, Object dragInfo) {
+ if (!mDragAndDropEnabled) return;
dragView.setPaint(null);
}
public void onDragStart(DragSource source, Object info, int dragAction) {
- if (info != null) {
+ if (info != null && mDragAndDropEnabled) {
final int itemType = ((ItemInfo)info).itemType;
mActive = (itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION);
- if (mManageVisibility) {
- // Only show the info icon when an application is selected
- if (mActive) {
- setVisibility(VISIBLE);
- }
+
+ // Only show the info icon when an application is selected
+ if (mActive) {
+ setVisibility(VISIBLE);
+ }
+ if (mHandle != null) {
mHandle.setVisibility(INVISIBLE);
}
}
@@ -118,11 +122,13 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
}
public void onDragEnd() {
+ if (!mDragAndDropEnabled) return;
+
if (mActive) {
mActive = false;
}
- if (mManageVisibility) {
- setVisibility(GONE);
+ setVisibility(GONE);
+ if (mHandle != null) {
mHandle.setVisibility(VISIBLE);
}
}
@@ -131,16 +137,10 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
public void getHitRect(Rect outRect) {
super.getHitRect(outRect);
if (LauncherApplication.isScreenXLarge()) {
- // TODO: This is a temporary hack. mManageVisiblity = false when you're in CAB mode.
- // In that case, this icon is more tightly spaced next to the delete icon so we want
- // it to have a smaller drag region. When the new drag&drop system comes in, we'll
- // dispatch the drag/drop by calculating what target you're overlapping
- final int minPadding = R.dimen.delete_zone_min_padding;
- final int maxPadding = R.dimen.delete_zone_max_padding;
+ final int padding = R.dimen.delete_zone_padding;
final int outerDragPadding =
getResources().getDimensionPixelSize(R.dimen.delete_zone_size);
- final int innerDragPadding = getResources().getDimensionPixelSize(
- mManageVisibility ? maxPadding : minPadding);
+ final int innerDragPadding = getResources().getDimensionPixelSize(padding);
outRect.top -= outerDragPadding;
outRect.left -= innerDragPadding;
outRect.bottom += outerDragPadding;
@@ -156,8 +156,8 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
mHandle = view;
}
- void setManageVisibility(boolean value) {
- mManageVisibility = value;
+ void setDragAndDropEnabled(boolean enabled) {
+ mDragAndDropEnabled = enabled;
}
@Override
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index f4a3d4499a..89a6303b41 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -16,14 +16,17 @@
package com.android.launcher2;
-import android.widget.TextView;
import android.content.Context;
-import android.util.AttributeSet;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.text.Layout;
+import android.util.AttributeSet;
+import android.view.View.MeasureSpec;
import com.android.launcher.R;
@@ -32,13 +35,16 @@ import com.android.launcher.R;
* because we want to make the bubble taller than the text and TextView's clip is
* too aggressive.
*/
-public class BubbleTextView extends TextView {
- static final float CORNER_RADIUS = 8.0f;
- static final float PADDING_H = 5.0f;
- static final float PADDING_V = 1.0f;
+public class BubbleTextView extends CacheableTextView {
+ static final float CORNER_RADIUS = 4.0f;
+ static final float PADDING_H = 8.0f;
+ static final float PADDING_V = 3.0f;
+
+ private int mAppCellWidth;
private final RectF mRect = new RectF();
private Paint mPaint;
+ private float mBubbleColorAlpha;
private int mPrevAlpha = -1;
private boolean mBackgroundSizeChanged;
@@ -63,20 +69,43 @@ public class BubbleTextView extends TextView {
}
private void init() {
- setFocusable(true);
mBackground = getBackground();
+ setFocusable(true);
setBackgroundDrawable(null);
+ final Resources res = getContext().getResources();
+ int bubbleColor = res.getColor(R.color.bubble_dark_background);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
- mPaint.setColor(getContext().getResources().getColor(R.color.bubble_dark_background));
+ mPaint.setColor(bubbleColor);
+ mBubbleColorAlpha = Color.alpha(bubbleColor) / 255.0f;
+ mAppCellWidth = (int) res.getDimension(R.dimen.app_icon_size);
- final float scale = getContext().getResources().getDisplayMetrics().density;
+ final float scale = res.getDisplayMetrics().density;
mCornerRadius = CORNER_RADIUS * scale;
mPaddingH = PADDING_H * scale;
//noinspection PointlessArithmeticExpression
mPaddingV = PADDING_V * scale;
}
+ protected int getVerticalPadding() {
+ return (int) PADDING_V;
+ }
+ protected int getHorizontalPadding() {
+ return (int) PADDING_H;
+ }
+
+ public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache) {
+ Bitmap b = info.getIcon(iconCache);
+
+ setCompoundDrawablesWithIntrinsicBounds(null,
+ new FastBitmapDrawable(b),
+ null, null);
+ setText(info.title);
+ buildAndEnableCache();
+ setTag(info);
+
+ }
+
@Override
protected boolean setFrame(int left, int top, int right, int bottom) {
if (mLeft != left || mRight != right || mTop != top || mBottom != bottom) {
@@ -120,37 +149,53 @@ public class BubbleTextView extends TextView {
}
}
+ // Draw the hotdog bubble
final Layout layout = getLayout();
- final RectF rect = mRect;
- final int left = getCompoundPaddingLeft();
- final int top = getExtendedPaddingTop();
+ final int offset = getExtendedPaddingTop();
+ final int paddingLeft = getPaddingLeft();
+ final int paddingRight = getPaddingRight();
+ final float left = layout.getLineLeft(0) + paddingLeft;
+ final float right = Math.min(layout.getLineRight(0) + paddingRight,
+ left + getWidth() - paddingLeft - paddingRight);
+ mRect.set(left - mPaddingH, offset + (int) layout.getLineTop(0) - mPaddingV,
+ right + mPaddingH, offset + (int) layout.getLineBottom(0) + mPaddingV);
- rect.set(left + layout.getLineLeft(0) - mPaddingH,
- top + layout.getLineTop(0) - mPaddingV,
- Math.min(left + layout.getLineRight(0) + mPaddingH, mScrollX + mRight - mLeft),
- top + layout.getLineBottom(0) + mPaddingV);
- canvas.drawRoundRect(rect, mCornerRadius, mCornerRadius, mPaint);
+ canvas.drawRoundRect(mRect, mCornerRadius, mCornerRadius, mPaint);
super.draw(canvas);
}
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ if (w > 0 && h > 0) {
+ // Temporary Workaround: We need to set padding to compress the text so that we can draw
+ // a hotdog around it. Currently, the background images prevent us from applying the
+ // padding in XML, so we are doing this programmatically
+ int d = w - mAppCellWidth;
+ int pL = d - (d / 2);
+ int pR = d - pL;
+ setPadding(pL, getPaddingTop(), pR, getPaddingBottom());
+ }
+ super.onSizeChanged(w, h, oldw, oldh);
+ }
+
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
- mBackground.setCallback(this);
+ if (mBackground != null) mBackground.setCallback(this);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
- mBackground.setCallback(null);
+ if (mBackground != null) mBackground.setCallback(null);
}
@Override
protected boolean onSetAlpha(int alpha) {
if (mPrevAlpha != alpha) {
mPrevAlpha = alpha;
- mPaint.setAlpha(alpha);
+ mPaint.setAlpha((int) (alpha * mBubbleColorAlpha));
super.onSetAlpha(alpha);
}
return true;
diff --git a/src/com/android/launcher2/CacheableTextView.java b/src/com/android/launcher2/CacheableTextView.java
new file mode 100644
index 0000000000..084810eaea
--- /dev/null
+++ b/src/com/android/launcher2/CacheableTextView.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2010 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.launcher2;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Bitmap.Config;
+import android.text.Layout;
+import android.util.AttributeSet;
+import android.widget.TextView;
+
+/*
+ * This class is a bit of a hack, designed to speed up long text labels in Launcher. It caches the
+ * text in a TextView to a bitmap and then just draws that Bitmap instead afterward, speeding up
+ * rendering. Marquee scrolling is not currently supported.
+ *
+ */
+public class CacheableTextView extends TextView {
+ private Bitmap mCache;
+ private final Paint mCachePaint = new Paint();
+ private final Canvas mCacheCanvas = new Canvas();
+
+ private int mPrevAlpha = -1;
+ private boolean mIsBuildingCache;
+ boolean mWaitingToGenerateCache;
+ float mTextCacheLeft;
+ float mTextCacheTop;
+ float mTextCacheScrollX;
+ float mRectLeft, mRectTop;
+ private float mPaddingH = 0;
+ private float mPaddingV = 0;
+
+ public CacheableTextView(Context context) {
+ super(context);
+ }
+
+ public CacheableTextView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public CacheableTextView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ protected int getVerticalPadding() {
+ return 0;
+ }
+ protected int getHorizontalPadding() {
+ return 0;
+ }
+
+ public void buildAndEnableCache() {
+ if (getLayout() == null) {
+ mWaitingToGenerateCache = true;
+ return;
+ }
+
+ final Layout layout = getLayout();
+ final int left = getCompoundPaddingLeft();
+ final int top = getExtendedPaddingTop();
+ final float prevAlpha = getAlpha();
+
+ int vPadding = getVerticalPadding();
+ int hPadding = getHorizontalPadding();
+
+ mTextCacheLeft = layout.getLineLeft(0) - hPadding;
+ mTextCacheTop = top + layout.getLineTop(0) - mPaddingV - vPadding;
+
+ mRectLeft = mScrollX + getLeft();
+ mRectTop = 0;
+ mTextCacheScrollX = mScrollX;
+
+ final float textCacheRight =
+ Math.min(left + layout.getLineRight(0) + mPaddingH, mScrollX + mRight - mLeft) + hPadding;
+ final float textCacheBottom = top + layout.getLineBottom(0) + mPaddingV + vPadding;
+
+ mCache = Bitmap.createBitmap((int) (textCacheRight - mTextCacheLeft),
+ (int) (textCacheBottom - mTextCacheTop), Config.ARGB_8888);
+ mCacheCanvas.setBitmap(mCache);
+ mCacheCanvas.translate(-mTextCacheLeft, -mTextCacheTop);
+
+ mIsBuildingCache = true;
+ setAlpha(1.0f);
+ draw(mCacheCanvas);
+ setAlpha(prevAlpha);
+ mIsBuildingCache = false;
+
+ // A hack-- we set the text to be one space (we don't make it empty just to avoid any
+ // potential issues with text measurement, like line height, etc.) so that the text view
+ // doesn't draw it anymore, since it's been cached. We have to manually rebuild
+ // the cache whenever the text is changed (which is never in Launcher)
+ setText(" ");
+ }
+
+ public void draw(Canvas canvas) {
+ if (mWaitingToGenerateCache && !mIsBuildingCache) {
+ buildAndEnableCache();
+ mWaitingToGenerateCache = false;
+ }
+ if (mCache != null) {
+ canvas.drawBitmap(mCache, mTextCacheLeft - mTextCacheScrollX + mScrollX,
+ mTextCacheTop, mCachePaint);
+ }
+ super.draw(canvas);
+ }
+
+ @Override
+ protected boolean onSetAlpha(int alpha) {
+ if (mPrevAlpha != alpha) {
+ mPrevAlpha = alpha;
+ mCachePaint.setAlpha(alpha);
+ super.onSetAlpha(alpha);
+ }
+ return true;
+ }
+}
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index b48d4ab492..50ec64b4d5 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -569,7 +569,7 @@ public class CustomizePagedView extends PagedView
* This method will extract the preview image specified by the wallpaper source provider (if it
* exists) otherwise, it will try to generate a default image preview.
*/
- private Drawable getWallpaperPreview(ResolveInfo info) {
+ private FastBitmapDrawable getWallpaperPreview(ResolveInfo info) {
// To be implemented later: resolving the up-to-date wallpaper thumbnail
final int minDim = mWorkspaceWidgetLayout.estimateCellWidth(1);
@@ -597,7 +597,7 @@ public class CustomizePagedView extends PagedView
// if we can't find the icon, then just don't draw it
}
- Drawable drawable = new FastBitmapDrawable(bitmap);
+ FastBitmapDrawable drawable = new FastBitmapDrawable(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
return drawable;
}
@@ -607,10 +607,11 @@ public class CustomizePagedView extends PagedView
* otherwise, it will try to generate a default image preview with the widget's package icon.
* @return the drawable that will be used and sized in the ImageView to represent the widget
*/
- private Drawable getWidgetPreview(AppWidgetProviderInfo info) {
+ private FastBitmapDrawable getWidgetPreview(AppWidgetProviderInfo info) {
final PackageManager packageManager = mPackageManager;
String packageName = info.provider.getPackageName();
Drawable drawable = null;
+ FastBitmapDrawable newDrawable = null;
if (info.previewImage != 0) {
drawable = packageManager.getDrawable(packageName, info.previewImage, null);
if (drawable == null) {
@@ -649,7 +650,7 @@ public class CustomizePagedView extends PagedView
// if we can't find the icon, then just don't draw it
}
- drawable = new FastBitmapDrawable(bitmap);
+ newDrawable = new FastBitmapDrawable(bitmap);
} else {
// Scale down the preview if necessary
final float imageWidth = drawable.getIntrinsicWidth();
@@ -672,10 +673,11 @@ public class CustomizePagedView extends PagedView
final Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
renderDrawableToBitmap(drawable, bitmap, 0, 0, width, height);
- drawable = new FastBitmapDrawable(bitmap);
+ newDrawable = new FastBitmapDrawable(bitmap);
}
- drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
- return drawable;
+ newDrawable.setBounds(0, 0, newDrawable.getIntrinsicWidth(),
+ newDrawable.getIntrinsicHeight());
+ return newDrawable;
}
private void setupPage(PagedViewCellLayout layout) {
@@ -720,28 +722,18 @@ public class CustomizePagedView extends PagedView
for (int i = 0; i < count; ++i) {
final AppWidgetProviderInfo info = (AppWidgetProviderInfo) list.get(i);
final PendingAddWidgetInfo createItemInfo = new PendingAddWidgetInfo(info, null, null);
+ final int[] cellSpans = CellLayout.rectToCell(getResources(), info.minWidth,
+ info.minHeight, null);
+ final FastBitmapDrawable icon = getWidgetPreview(info);
- LinearLayout l = (LinearLayout) mInflater.inflate(
+ PagedViewWidget l = (PagedViewWidget) mInflater.inflate(
R.layout.customize_paged_view_widget, layout, false);
+ l.applyFromAppWidgetProviderInfo(info, icon, mMaxWidgetWidth, cellSpans);
l.setTag(createItemInfo);
l.setOnClickListener(this);
l.setOnTouchListener(this);
l.setOnLongClickListener(this);
- final Drawable icon = getWidgetPreview(info);
-
- int[] spans = CellLayout.rectToCell(getResources(), info.minWidth, info.minHeight, null);
- final int hSpan = spans[0];
- final int vSpan = spans[1];
-
- ImageView image = (ImageView) l.findViewById(R.id.widget_preview);
- image.setMaxWidth(mMaxWidgetWidth);
- image.setImageDrawable(icon);
- TextView name = (TextView) l.findViewById(R.id.widget_name);
- name.setText(info.label);
- TextView dims = (TextView) l.findViewById(R.id.widget_dims);
- dims.setText(mContext.getString(R.string.widget_dims_format, hSpan, vSpan));
-
layout.addView(l);
}
}
@@ -775,20 +767,14 @@ public class CustomizePagedView extends PagedView
final int endIndex = Math.min(count, startIndex + numItemsPerPage);
for (int i = startIndex; i < endIndex; ++i) {
final ResolveInfo info = mWallpaperList.get(i);
+ final FastBitmapDrawable icon = getWallpaperPreview(info);
- LinearLayout l = (LinearLayout) mInflater.inflate(
+ PagedViewWidget l = (PagedViewWidget) mInflater.inflate(
R.layout.customize_paged_view_wallpaper, layout, false);
+ l.applyFromWallpaperInfo(info, mPackageManager, icon, mMaxWidgetWidth);
l.setTag(info);
l.setOnClickListener(this);
- final Drawable icon = getWallpaperPreview(info);
-
- ImageView image = (ImageView) l.findViewById(R.id.wallpaper_preview);
- image.setMaxWidth(mMaxWidgetWidth);
- image.setImageDrawable(icon);
- TextView name = (TextView) l.findViewById(R.id.wallpaper_name);
- name.setText(info.loadLabel(mPackageManager));
-
layout.addView(l);
}
}
diff --git a/src/com/android/launcher2/DeleteZone.java b/src/com/android/launcher2/DeleteZone.java
index be651b273d..33f384f0de 100644
--- a/src/com/android/launcher2/DeleteZone.java
+++ b/src/com/android/launcher2/DeleteZone.java
@@ -16,8 +16,6 @@
package com.android.launcher2;
-import com.android.launcher.R;
-
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Paint;
@@ -35,6 +33,8 @@ import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
+import com.android.launcher.R;
+
public class DeleteZone extends ImageView implements DropTarget, DragController.DragListener {
private static final int ORIENTATION_HORIZONTAL = 1;
private static final int TRANSITION_DURATION = 250;
@@ -50,7 +50,7 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
* This is generally the case, but it will be set to false when this is part of the
* Contextual Action Bar.
*/
- private boolean mManageVisibility = true;
+ private boolean mDragAndDropEnabled = true;
private AnimationSet mInAnimation;
private AnimationSet mOutAnimation;
@@ -81,7 +81,6 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DeleteZone, defStyle, 0);
mOrientation = a.getInt(R.styleable.DeleteZone_direction, ORIENTATION_HORIZONTAL);
a.recycle();
-
}
@Override
@@ -97,6 +96,8 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
DragView dragView, Object dragInfo) {
+ if (!mDragAndDropEnabled) return;
+
final ItemInfo item = (ItemInfo) dragInfo;
// On x-large screens, you can uninstall an app by dragging from all apps
@@ -142,6 +143,7 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
DragView dragView, Object dragInfo) {
+ if (!mDragAndDropEnabled) return;
mTransition.reverseTransition(TRANSITION_DURATION);
dragView.setPaint(mTrashPaint);
}
@@ -152,13 +154,14 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
DragView dragView, Object dragInfo) {
+ if (!mDragAndDropEnabled) return;
mTransition.reverseTransition(TRANSITION_DURATION);
dragView.setPaint(null);
}
public void onDragStart(DragSource source, Object info, int dragAction) {
final ItemInfo item = (ItemInfo) info;
- if (item != null) {
+ if (item != null && mDragAndDropEnabled) {
mTrashMode = true;
getHitRect(mRegion);
mRegionF.set(mRegion);
@@ -175,26 +178,25 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
// Make sure the icon is set to the default drawable, not the hover drawable
mTransition.resetTransition();
- if (mManageVisibility) {
- createAnimations();
- startAnimation(mInAnimation);
+ createAnimations();
+ startAnimation(mInAnimation);
+ if (mHandle != null) {
mHandle.startAnimation(mHandleOutAnimation);
- setVisibility(VISIBLE);
}
+ setVisibility(VISIBLE);
}
}
public void onDragEnd() {
- if (mTrashMode) {
+ if (mTrashMode && mDragAndDropEnabled) {
mTrashMode = false;
mDragController.setDeleteRegion(null);
if (mOutAnimation != null) startAnimation(mOutAnimation);
- if (mHandleInAnimation != null) mHandle.startAnimation(mHandleInAnimation);
-
- if (mManageVisibility) {
- setVisibility(GONE);
+ if (mHandleInAnimation != null && mHandle != null) {
+ mHandle.startAnimation(mHandleInAnimation);
}
+ setVisibility(GONE);
}
}
@@ -210,12 +212,10 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
// In that case, this icon is more tightly spaced next to the delete icon so we want
// it to have a smaller drag region. When the new drag&drop system comes in, we'll
// dispatch the drag/drop by calculating what target you're overlapping
- final int minPadding = R.dimen.delete_zone_min_padding;
- final int maxPadding = R.dimen.delete_zone_max_padding;
+ final int padding = R.dimen.delete_zone_padding;
final int outerDragPadding =
getResources().getDimensionPixelSize(R.dimen.delete_zone_size);
- final int innerDragPadding = getResources().getDimensionPixelSize(
- mManageVisibility ? maxPadding : minPadding);
+ final int innerDragPadding = getResources().getDimensionPixelSize(padding);
outRect.top -= outerDragPadding;
outRect.left -= innerDragPadding;
outRect.bottom += outerDragPadding;
@@ -290,8 +290,8 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
mHandle = view;
}
- void setManageVisibility(boolean value) {
- mManageVisibility = value;
+ void setDragAndDropEnabled(boolean enabled) {
+ mDragAndDropEnabled = enabled;
}
private static class FastTranslateAnimation extends TranslateAnimation {
diff --git a/src/com/android/launcher2/FastBitmapDrawable.java b/src/com/android/launcher2/FastBitmapDrawable.java
index 1aa8b35221..a45329467e 100644
--- a/src/com/android/launcher2/FastBitmapDrawable.java
+++ b/src/com/android/launcher2/FastBitmapDrawable.java
@@ -26,11 +26,13 @@ import android.graphics.drawable.Drawable;
class FastBitmapDrawable extends Drawable {
private Bitmap mBitmap;
+ private int mAlpha;
private int mWidth;
private int mHeight;
private final Paint mPaint = new Paint();
FastBitmapDrawable(Bitmap b) {
+ mAlpha = 255;
mBitmap = b;
if (b != null) {
mWidth = mBitmap.getWidth();
@@ -53,9 +55,14 @@ class FastBitmapDrawable extends Drawable {
@Override
public void setAlpha(int alpha) {
+ mAlpha = alpha;
mPaint.setAlpha(alpha);
}
+ public int getAlpha() {
+ return mAlpha;
+ }
+
@Override
public void setColorFilter(ColorFilter cf) {
}
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 033ccc3d44..8a8ef595fd 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -59,6 +59,7 @@ import android.content.res.TypedArray;
import android.database.ContentObserver;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -90,8 +91,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.View.OnLongClickListener;
-import android.view.animation.AccelerateInterpolator;
-import android.view.animation.DecelerateInterpolator;
import android.view.inputmethod.InputMethodManager;
import android.widget.Advanceable;
import android.widget.EditText;
@@ -960,6 +959,29 @@ public final class Launcher extends Activity
deleteZone.setHandle(findViewById(deleteZoneHandleId));
dragController.addDragListener(deleteZone);
+ DeleteZone allAppsDeleteZone = (DeleteZone) findViewById(R.id.all_apps_delete_zone);
+ if (allAppsDeleteZone != null) {
+ allAppsDeleteZone.setLauncher(this);
+ allAppsDeleteZone.setDragController(dragController);
+ allAppsDeleteZone.setDragAndDropEnabled(false);
+ dragController.addDragListener(allAppsDeleteZone);
+ dragController.addDropTarget(allAppsDeleteZone);
+ }
+
+ ApplicationInfoDropTarget allAppsInfoTarget = (ApplicationInfoDropTarget)
+ findViewById(R.id.all_apps_info_target);
+ if (allAppsInfoTarget != null) {
+ allAppsInfoTarget.setLauncher(this);
+ dragController.addDragListener(allAppsInfoTarget);
+ allAppsInfoTarget.setDragColor(getResources().getColor(R.color.app_info_filter));
+ allAppsInfoTarget.setDragAndDropEnabled(false);
+ View marketButton = findViewById(R.id.market_button);
+ if (marketButton != null) {
+ marketButton.setBackgroundColor(Color.RED);
+ allAppsInfoTarget.setHandle(marketButton);
+ }
+ }
+
ApplicationInfoDropTarget infoButton = (ApplicationInfoDropTarget)findViewById(R.id.info_button);
if (infoButton != null) {
infoButton.setLauncher(this);
@@ -978,6 +1000,12 @@ public final class Launcher extends Activity
if (infoButton != null) {
dragController.addDropTarget(infoButton);
}
+ if (allAppsInfoTarget != null) {
+ dragController.addDropTarget(allAppsInfoTarget);
+ }
+ if (allAppsDeleteZone != null) {
+ dragController.addDropTarget(allAppsDeleteZone);
+ }
}
@SuppressWarnings({"UnusedDeclaration"})
@@ -1038,17 +1066,9 @@ public final class Launcher extends Activity
* @return A View inflated from layoutResId.
*/
View createShortcut(int layoutResId, ViewGroup parent, ShortcutInfo info) {
- TextView favorite = (TextView) mInflater.inflate(layoutResId, parent, false);
-
- Bitmap b = info.getIcon(mIconCache);
-
- favorite.setCompoundDrawablesWithIntrinsicBounds(null,
- new FastBitmapDrawable(b),
- null, null);
- favorite.setText(info.title);
- favorite.setTag(info);
+ BubbleTextView favorite = (BubbleTextView) mInflater.inflate(layoutResId, parent, false);
+ favorite.applyFromShortcutInfo(info, mIconCache);
favorite.setOnClickListener(this);
-
return favorite;
}
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index d24eef4c81..31cfb5b21e 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -566,9 +566,15 @@ public abstract class PagedView extends ViewGroup {
rightScreen = Math.min(getChildCount() - 1, rightScreen);
final long drawingTime = getDrawingTime();
+ // Clip to the bounds
+ canvas.save();
+ canvas.clipRect(mScrollX, mScrollY, mScrollX + mRight - mLeft,
+ mScrollY + mBottom - mTop);
+
for (int i = leftScreen; i <= rightScreen; i++) {
drawChild(canvas, getChildAt(i), drawingTime);
}
+ canvas.restore();
}
}
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index b9b9b377e3..0e72598e9f 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -39,7 +39,7 @@ import com.android.launcher2.PagedView.PagedViewIconCache;
* An icon on a PagedView, specifically for items in the launcher's paged view (with compound
* drawables on the top).
*/
-public class PagedViewIcon extends TextView implements Checkable {
+public class PagedViewIcon extends CacheableTextView implements Checkable {
private static final String TAG = "PagedViewIcon";
// holographic outline
@@ -52,7 +52,7 @@ public class PagedViewIcon extends TextView implements Checkable {
private Object mIconCacheKey;
private PagedViewIconCache mIconCache;
- private int mAlpha = -1;
+ private int mAlpha;
private int mHolographicAlpha;
private boolean mIsChecked;
@@ -104,12 +104,13 @@ public class PagedViewIcon extends TextView implements Checkable {
public PagedViewIcon(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedViewIcon, defStyle, 0);
+ mAlpha = 255;
mHoloBlurColor = a.getColor(R.styleable.PagedViewIcon_blurColor, 0);
mHoloOutlineColor = a.getColor(R.styleable.PagedViewIcon_outlineColor, 0);
mCheckedBlurColor = a.getColor(R.styleable.PagedViewIcon_checkedBlurColor, 0);
mCheckedOutlineColor = a.getColor(R.styleable.PagedViewIcon_checkedOutlineColor, 0);
-
a.recycle();
if (sHolographicOutlineHelper == null) {
@@ -138,6 +139,7 @@ public class PagedViewIcon extends TextView implements Checkable {
mIcon = info.iconBitmap;
setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
setText(info.title);
+ buildAndEnableCache();
setTag(info);
queueHolographicOutlineCreation();
@@ -153,6 +155,7 @@ public class PagedViewIcon extends TextView implements Checkable {
modelIconCache.getFullResIcon(info, packageManager), mContext);
setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
setText(info.loadLabel(packageManager));
+ buildAndEnableCache();
setTag(info);
queueHolographicOutlineCreation();
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
new file mode 100644
index 0000000000..40e507bb3d
--- /dev/null
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright (C) 2010 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.launcher2;
+
+import android.appwidget.AppWidgetProviderInfo;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.res.TypedArray;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.drawable.Drawable;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Message;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.android.launcher.R;
+import com.android.launcher2.PagedView.PagedViewIconCache;
+
+/**
+ * The linear layout used strictly for the widget/wallpaper tab of the customization tray
+ */
+public class PagedViewWidget extends LinearLayout {
+ static final String TAG = "PagedViewWidgetLayout";
+
+ private final Paint mPaint = new Paint();
+ private static HolographicOutlineHelper sHolographicOutlineHelper;
+ private Bitmap mHolographicOutline;
+ private final Canvas mHolographicOutlineCanvas = new Canvas();
+ private FastBitmapDrawable mPreview;
+
+ private int mAlpha = 255;
+ private int mHolographicAlpha;
+
+ // Highlight colors
+ private int mHoloBlurColor;
+ private int mHoloOutlineColor;
+
+ private static final HandlerThread sWorkerThread = new HandlerThread("pagedviewwidget-helper");
+ static {
+ sWorkerThread.start();
+ }
+
+ private static final int MESSAGE_CREATE_HOLOGRAPHIC_OUTLINE = 1;
+
+ private static final Handler sWorker = new Handler(sWorkerThread.getLooper()) {
+ private DeferredHandler mHandler = new DeferredHandler();
+ public void handleMessage(Message msg) {
+ final PagedViewWidget widget = (PagedViewWidget) msg.obj;
+ final int prevAlpha = widget.mPreview.getAlpha();
+ final Bitmap outline = Bitmap.createBitmap(widget.getWidth(), widget.getHeight(),
+ Bitmap.Config.ARGB_8888);
+
+ widget.mHolographicOutlineCanvas.setBitmap(outline);
+ widget.mHolographicOutlineCanvas.save();
+ widget.mHolographicOutlineCanvas.translate(widget.mPaddingLeft, widget.mPaddingTop);
+ widget.mPreview.setAlpha(255);
+ widget.mPreview.draw(widget.mHolographicOutlineCanvas);
+ widget.mPreview.setAlpha(prevAlpha);
+ widget.mHolographicOutlineCanvas.restore();
+
+ sHolographicOutlineHelper.applyExpensiveOutlineWithBlur(outline,
+ widget.mHolographicOutlineCanvas, widget.mHoloBlurColor,
+ widget.mHoloOutlineColor);
+
+ mHandler.post(new Runnable() {
+ public void run() {
+ widget.mHolographicOutline = outline;
+ widget.invalidate();
+ }
+ });
+ }
+ };
+
+ public PagedViewWidget(Context context) {
+ this(context, null);
+ }
+
+ public PagedViewWidget(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public PagedViewWidget(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedViewWidget,
+ defStyle, 0);
+ mHoloBlurColor = a.getColor(R.styleable.PagedViewWidget_blurColor, 0);
+ mHoloOutlineColor = a.getColor(R.styleable.PagedViewWidget_outlineColor, 0);
+ a.recycle();
+
+ if (sHolographicOutlineHelper == null) {
+ sHolographicOutlineHelper = new HolographicOutlineHelper();
+ }
+
+ setFocusable(true);
+ setWillNotDraw(false);
+ setClipToPadding(false);
+ }
+
+ private void queueHolographicOutlineCreation() {
+ // Generate the outline in the background
+ if (mHolographicOutline == null) {
+ Message m = sWorker.obtainMessage(MESSAGE_CREATE_HOLOGRAPHIC_OUTLINE);
+ m.obj = this;
+ sWorker.sendMessage(m);
+ }
+ }
+
+ public void applyFromAppWidgetProviderInfo(AppWidgetProviderInfo info,
+ FastBitmapDrawable preview, int maxWidth, int[] cellSpan) {
+ final ImageView image = (ImageView) findViewById(R.id.widget_preview);
+ image.setMaxWidth(maxWidth);
+ image.setImageDrawable(preview);
+ final TextView name = (TextView) findViewById(R.id.widget_name);
+ name.setText(info.label);
+ final TextView dims = (TextView) findViewById(R.id.widget_dims);
+ dims.setText(mContext.getString(R.string.widget_dims_format, cellSpan[0], cellSpan[1]));
+ mPreview = preview;
+ }
+
+ public void applyFromWallpaperInfo(ResolveInfo info, PackageManager packageManager,
+ FastBitmapDrawable preview, int maxWidth) {
+ ImageView image = (ImageView) findViewById(R.id.wallpaper_preview);
+ image.setMaxWidth(maxWidth);
+ image.setImageDrawable(preview);
+ TextView name = (TextView) findViewById(R.id.wallpaper_name);
+ name.setText(info.loadLabel(packageManager));
+ mPreview = preview;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ // We eat up the touch events here, since the PagedView (which uses the same swiping
+ // touch code as Workspace previously) uses onInterceptTouchEvent() to determine when
+ // the user is scrolling between pages. This means that if the pages themselves don't
+ // handle touch events, it gets forwarded up to PagedView itself, and it's own
+ // onTouchEvent() handling will prevent further intercept touch events from being called
+ // (it's the same view in that case). This is not ideal, but to prevent more changes,
+ // we just always mark the touch event as handled.
+ return super.onTouchEvent(event) || true;
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ if (mAlpha > 0) {
+ super.onDraw(canvas);
+ }
+
+ // draw any blended overlays
+ if (mHolographicOutline != null && mHolographicAlpha > 0) {
+ mPaint.setAlpha(mHolographicAlpha);
+ canvas.drawBitmap(mHolographicOutline, 0, 0, mPaint);
+ }
+ }
+
+ @Override
+ protected boolean onSetAlpha(int alpha) {
+ return true;
+ }
+
+ @Override
+ public void setAlpha(float alpha) {
+ final float viewAlpha = sHolographicOutlineHelper.viewAlphaInterpolator(alpha);
+ final float holographicAlpha = sHolographicOutlineHelper.highlightAlphaInterpolator(alpha);
+ int newViewAlpha = (int) (viewAlpha * 255);
+ int newHolographicAlpha = (int) (holographicAlpha * 255);
+ if ((mAlpha != newViewAlpha) || (mHolographicAlpha != newHolographicAlpha)) {
+ mAlpha = newViewAlpha;
+ mHolographicAlpha = newHolographicAlpha;
+ setChildrenAlpha(viewAlpha);
+ super.setAlpha(viewAlpha);
+ }
+ }
+
+ private void setChildrenAlpha(float alpha) {
+ final int childCount = getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ getChildAt(i).setAlpha(alpha);
+ }
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ if (w > 0 && h > 0) {
+ queueHolographicOutlineCreation();
+ }
+
+ super.onSizeChanged(w, h, oldw, oldh);
+ }
+
+ @Override
+ public void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ sWorker.removeMessages(MESSAGE_CREATE_HOLOGRAPHIC_OUTLINE, this);
+ }
+}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index f866b22dfc..b12d357f4b 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1281,9 +1281,14 @@ public class Workspace extends SmoothPagedView
v.getDrawingRect(clipRect);
// For a TextView, adjust the clip rect so that we don't include the text label
- if (v instanceof TextView) {
+ if (v instanceof BubbleTextView) {
+ final BubbleTextView tv = (BubbleTextView) v;
+ clipRect.bottom = tv.getExtendedPaddingTop() - (int) BubbleTextView.PADDING_V +
+ tv.getLayout().getLineTop(0);
+ } else if (v instanceof TextView) {
final TextView tv = (TextView) v;
- clipRect.bottom = clipRect.top + tv.getCompoundPaddingTop() - 1;
+ clipRect.bottom = tv.getExtendedPaddingTop() - tv.getCompoundDrawablePadding() +
+ tv.getLayout().getLineTop(0);
}
// Draw the View into the bitmap.