From 0e320b21ad4b8d6efa1c08cea64f3be4343517b4 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Fri, 9 Jan 2009 17:51:25 -0800 Subject: [PATCH] auto import from //branches/cupcake/...@125939 --- res/drawable/ic_menu_gallery.png | Bin 2379 -> 0 bytes res/drawable/ic_menu_notifications.png | Bin 1771 -> 0 bytes res/drawable/ic_menu_preferences.png | Bin 2144 -> 0 bytes res/layout/widget_search.xml | 1 + res/values-fr/strings.xml | 46 ++++++ res/values-it/strings.xml | 46 ++++++ res/values-zh-rCN/strings.xml | 46 ++++++ src/com/android/launcher/HandleView.java | 2 +- src/com/android/launcher/Launcher.java | 163 +++++++++++++------- src/com/android/launcher/LauncherModel.java | 26 +++- 10 files changed, 265 insertions(+), 65 deletions(-) delete mode 100644 res/drawable/ic_menu_gallery.png delete mode 100644 res/drawable/ic_menu_notifications.png delete mode 100755 res/drawable/ic_menu_preferences.png create mode 100644 res/values-fr/strings.xml create mode 100644 res/values-it/strings.xml create mode 100644 res/values-zh-rCN/strings.xml diff --git a/res/drawable/ic_menu_gallery.png b/res/drawable/ic_menu_gallery.png deleted file mode 100644 index f61bbd8bae606d2f108f3e093fa1fbf4b61204c0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2379 zcmV-R3AFZ!P)+Zl| zI+2zhv`W;)Fjw2!bY*kH`bYi8U@ff7p@S|VV{I7Q;$=|GV1zKnD1*^p>OvcMj)uq*6gy=L%d$w*CbveYI|Ac0oKWzf7K4hx1-=>h zK_1}pK{;S6)*3aj>+8D+-1+BUc>W8DRn`nZLdJj=h`@AoCz|od@B_ookn(5#Jaab$ zv>@mm5GVy@Z^d&5fHM591mOe z-;)+?+kOY%{w4jkDc?)9^?kW*xg`nahyrXA+D+rX9)A{+3?qbP=^agF>^@#yifpkeL zWnJiI0qt5{Mp-b)jVLr3E+zvm0+3L~H5JXb3!aqoa!CT0+#XAXIo$#G%=KCzp-zmJ zq5wnt1ez%WZX+yUvadGiC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SqBufNqA^;H9ty7VA(8(RIba-A05x|&T zyLSDI1!u^L(p;DoWJ^oSm)Eaf{}@jA2AviCfp|MS%#laxXcXi2TMK3NLco;QIFN#7BDu>c?g zyYz$?nIA?RK&KwJX4<|_J;^D)G!t3=8?st7YpSXSdb}Yw#ZVQ+v z4yc6&LDJBhgYs#8ICoNs)4Rtxw84tp+jAmxBuL^bDNc8%dKR1xG5CG zUe<>y^mmy4Wu83nXhaE5r$l`B78e&k<=7a}$lMn@oz6ClpMaXkbK$~;Z@C}lQOfk` z(|Iz{o@g_lHUOSbtXQ#PRcmYOM$q7OR+Jhoyx12UlBXDfICJzaTD0g3M4TftXU_DH zGE{^Fe7C5mXsi6V5ghJsWct^dEbTLreiYLuTcDz%Vu%K7YikX8vX?EJU2|G>4B0E2 zKcO$B@sUq`FVmZd_|O+5|6@5LKv*Kaxf$9VLG2hPG~5<=VLr2t0vHAGq5$|yfB^u# Wx+&S-3)D^k0000 + + "Accueil" + "Dossier" + "Sélectionner l\'arrière-plan à partir de" + "Configurer l\'arrière-plan" + "Galerie des arrière-plans" + "L\'application n\'est pas installée sur votre téléphone." + + + "Renommer le dossier" + "OK" + "Annuler" + + + "Application" + "Raccourci" + + + "Widget" + "Arrière-plan" + "Dossier" + "Horloge" + "Cadre d\'image" + "Rechercher" + "Plus d\'espace libre sur l\'écran Accueil." + "Ajouter" + "Arrière-plan" + "Rechercher" + "Notifications" + "Paramètres" + "installer des raccourcis" + "Permet à une application d\'ajouter des raccourcis sans l\'intervention de l\'utilisateur." + "désinstaller les raccourcis" + "Permet à une application de supprimer les raccourcis sans l\'intervention de l\'utilisateur." + + + + + + + + + "Recherche Google" + diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml new file mode 100644 index 0000000000..d94a156035 --- /dev/null +++ b/res/values-it/strings.xml @@ -0,0 +1,46 @@ + + + "Home" + "Cartella" + "Seleziona sfondo da" + "Imposta sfondo" + "Galleria sfondi" + "Applicazione non installata sul telefono." + + + "Rinomina cartella" + "OK" + "Annulla" + + + "Applicazione" + "Collegamento" + + + "Widget" + "Sfondo" + "Cartella" + "Orologio" + "Cornice immagini" + "Ricerca" + "Spazio nella schermata Home esaurito." + "Aggiungi" + "Sfondo" + "Cerca" + "Notifiche" + "Impostazioni" + "aggiungere collegamenti" + "Consente a un\'applicazione di aggiungere collegamenti automaticamente." + "eliminare collegamenti" + "Consente a un\'applicazione di rimuovere collegamenti automaticamente." + + + + + + + + + "Ricerca Google" + diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml new file mode 100644 index 0000000000..7657890c94 --- /dev/null +++ b/res/values-zh-rCN/strings.xml @@ -0,0 +1,46 @@ + + + "主页" + "文件夹" + "选择壁纸" + "设置壁纸" + "壁纸图库" + "您的手机上没有安装应用程序。" + + + "重命名文件夹" + "确定" + "取消" + + + "应用程序" + "快捷键" + + + "小工具" + "壁纸" + "文件夹" + "时钟" + "相框" + "搜索" + "该“主页”屏幕上没有多余空间。" + "添加" + "壁纸" + "搜索" + "通知" + "设置" + "安装快捷键" + "允许应用程序在没有用户介入的情况下添加快捷键。" + "卸载快捷键" + "允许应用程序在没有用户介入的情况下删除快捷键。" + + + + + + + + + "Google 搜索" + diff --git a/src/com/android/launcher/HandleView.java b/src/com/android/launcher/HandleView.java index 437d559b71..9afe41cacc 100644 --- a/src/com/android/launcher/HandleView.java +++ b/src/com/android/launcher/HandleView.java @@ -49,7 +49,7 @@ public class HandleView extends ImageView { @Override public View focusSearch(int direction) { View newFocus = super.focusSearch(direction); - if (newFocus == null) { + if (newFocus == null && mLauncher.isDrawerDown()) { final Workspace workspace = mLauncher.getWorkspace(); workspace.dispatchUnhandledMove(null, direction); return (mOrientation == ORIENTATION_HORIZONTAL && direction == FOCUS_DOWN) ? diff --git a/src/com/android/launcher/Launcher.java b/src/com/android/launcher/Launcher.java index 928f4caecd..01001c0177 100644 --- a/src/com/android/launcher/Launcher.java +++ b/src/com/android/launcher/Launcher.java @@ -45,6 +45,7 @@ import android.os.IBinder; import android.os.Parcelable; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.Message; import android.provider.*; import android.telephony.PhoneNumberUtils; import android.text.Selection; @@ -260,7 +261,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On private void startLoaders() { sModel.loadApplications(true, this, mLocaleChanged); - sModel.loadUserItems(!mLocaleChanged, this, mLocaleChanged); + sModel.loadUserItems(!mLocaleChanged, this, mLocaleChanged, true); mRestoring = false; } @@ -812,13 +813,13 @@ public final class Launcher extends Activity implements View.OnClickListener, On .setIcon(android.R.drawable.ic_menu_add) .setAlphabeticShortcut('A'); menu.add(0, MENU_WALLPAPER_SETTINGS, 0, R.string.menu_wallpaper) - .setIcon(R.drawable.ic_menu_gallery) + .setIcon(android.R.drawable.ic_menu_gallery) .setAlphabeticShortcut('W'); menu.add(0, MENU_SEARCH, 0, R.string.menu_search) .setIcon(android.R.drawable.ic_search_category_default) .setAlphabeticShortcut(SearchManager.MENU_KEY); menu.add(0, MENU_NOTIFICATIONS, 0, R.string.menu_notifications) - .setIcon(R.drawable.ic_menu_notifications) + .setIcon(android.R.drawable.ic_menu_notifications) .setAlphabeticShortcut('N'); final Intent settings = new Intent(android.provider.Settings.ACTION_SETTINGS); @@ -826,7 +827,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); menu.add(0, MENU_SETTINGS, 0, R.string.menu_settings) - .setIcon(R.drawable.ic_menu_preferences).setAlphabeticShortcut('P') + .setIcon(android.R.drawable.ic_menu_preferences).setAlphabeticShortcut('P') .setIntent(settings); return true; @@ -1111,7 +1112,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On private void onFavoritesChanged() { mDesktopLocked = true; mDrawer.lock(); - sModel.loadUserItems(false, this, false); + sModel.loadUserItems(false, this, false, false); } void onDesktopItemsLoaded() { @@ -1119,7 +1120,80 @@ public final class Launcher extends Activity implements View.OnClickListener, On bindDesktopItems(); mAllAppsGrid.setAdapter(Launcher.getModel().getApplicationsAdapter()); + } + /** + * Refreshes the shortcuts shown on the workspace. + */ + private void bindDesktopItems() { + final ArrayList shortcuts = sModel.getDesktopItems(); + if (shortcuts == null) { + return; + } + + final Workspace workspace = mWorkspace; + int count = workspace.getChildCount(); + for (int i = 0; i < count; i++) { + ((ViewGroup) workspace.getChildAt(i)).removeAllViewsInLayout(); + } + + count = shortcuts.size(); + + final DesktopItemsBinder binder = new DesktopItemsBinder(this, shortcuts); + binder.obtainMessage(DesktopItemsBinder.MESSAGE_BIND_ITEMS, 0, count).sendToTarget(); + } + + private void bindItems(Launcher.DesktopItemsBinder binder, + ArrayList shortcuts, int start, int count) { + + final Workspace workspace = mWorkspace; + final boolean desktopLocked = mDesktopLocked; + + final int end = Math.min(start + DesktopItemsBinder.ITEMS_COUNT, count); + int i = start; + + for ( ; i < end; i++) { + final ItemInfo item = shortcuts.get(i); + switch (item.itemType) { + case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: + case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: + final View shortcut = createShortcut((ApplicationInfo) item); + workspace.addInScreen(shortcut, item.screen, item.cellX, item.cellY, 1, 1, + !desktopLocked); + break; + case LauncherSettings.Favorites.ITEM_TYPE_USER_FOLDER: + final FolderIcon newFolder = FolderIcon.fromXml(R.layout.folder_icon, this, + (ViewGroup) workspace.getChildAt(workspace.getCurrentScreen()), + (UserFolderInfo) item); + workspace.addInScreen(newFolder, item.screen, item.cellX, item.cellY, 1, 1, + !desktopLocked); + break; + case LauncherSettings.Favorites.ITEM_TYPE_LIVE_FOLDER: + final FolderIcon newLiveFolder = LiveFolderIcon.fromXml( + R.layout.live_folder_icon, this, + (ViewGroup) workspace.getChildAt(workspace.getCurrentScreen()), + (LiveFolderInfo) item); + workspace.addInScreen(newLiveFolder, item.screen, item.cellX, item.cellY, 1, 1, + !desktopLocked); + break; + default: + final Widget widget = (Widget) item; + final View view = createWidget(mInflater, widget); + view.setTag(widget); + workspace.addWidget(view, widget, !desktopLocked); + } + } + + workspace.requestLayout(); + + if (end >= count) { + finishBindDesktopItems(); + } else { + binder.obtainMessage(DesktopItemsBinder.MESSAGE_BIND_ITEMS, i, count).sendToTarget(); + } + } + + private void finishBindDesktopItems() { if (mSavedState != null) { mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus(); @@ -1152,57 +1226,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On mDrawer.unlock(); } - /** - * Refreshes the shortcuts shown on the workspace. - */ - private void bindDesktopItems() { - final ArrayList shortcuts = sModel.getDesktopItems(); - if (shortcuts == null) { - return; - } - - final Workspace workspace = mWorkspace; - int count = workspace.getChildCount(); - for (int i = 0; i < count; i++) { - ((ViewGroup) workspace.getChildAt(i)).removeAllViewsInLayout(); - } - - count = shortcuts.size(); - for (int i = 0; i < count; i++) { - final ItemInfo item = shortcuts.get(i); - switch (item.itemType) { - case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: - case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: - final View shortcut = createShortcut((ApplicationInfo) item); - workspace.addInScreen(shortcut, item.screen, item.cellX, item.cellY, 1, 1, - !mDesktopLocked); - break; - case LauncherSettings.Favorites.ITEM_TYPE_USER_FOLDER: - final FolderIcon newFolder = FolderIcon.fromXml(R.layout.folder_icon, this, - (ViewGroup) mWorkspace.getChildAt(mWorkspace.getCurrentScreen()), - ((UserFolderInfo) item)); - workspace.addInScreen(newFolder, item.screen, item.cellX, item.cellY, 1, 1, - !mDesktopLocked); - break; - case LauncherSettings.Favorites.ITEM_TYPE_LIVE_FOLDER: - final FolderIcon newLiveFolder = LiveFolderIcon.fromXml( - R.layout.live_folder_icon, this, - (ViewGroup) mWorkspace.getChildAt(mWorkspace.getCurrentScreen()), - ((LiveFolderInfo) item)); - workspace.addInScreen(newLiveFolder, item.screen, item.cellX, item.cellY, 1, 1, - !mDesktopLocked); - break; - default: - final Widget widget = (Widget)item; - final View view = createWidget(mInflater, widget); - view.setTag(widget); - workspace.addWidget(view, widget, !mDesktopLocked); - } - } - - workspace.requestLayout(); - } - private View createWidget(LayoutInflater inflater, Widget widget) { final Workspace workspace = mWorkspace; final int screen = workspace.getCurrentScreen(); @@ -1456,7 +1479,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On if (mDesktopLocked) { mDrawer.lock(); - sModel.loadUserItems(false, Launcher.this, false); + sModel.loadUserItems(false, Launcher.this, false, false); } else { final FolderIcon folderIcon = (FolderIcon) mWorkspace.getViewForTag(mFolderInfo); @@ -1466,7 +1489,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On } else { mDesktopLocked = true; mDrawer.lock(); - sModel.loadUserItems(false, Launcher.this, false); + sModel.loadUserItems(false, Launcher.this, false, false); } } } @@ -1635,4 +1658,28 @@ public final class Launcher extends Activity implements View.OnClickListener, On public void onScrollEnded() { } } + + private static class DesktopItemsBinder extends Handler { + static final int MESSAGE_BIND_ITEMS = 0x1; + // Number of items to bind in every pass + static final int ITEMS_COUNT = 6; + + private final ArrayList mShortcuts; + private final WeakReference mLauncher; + + DesktopItemsBinder(Launcher launcher, ArrayList shortcuts) { + mLauncher = new WeakReference(launcher); + mShortcuts = shortcuts; + } + + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MESSAGE_BIND_ITEMS: + Launcher launcher = mLauncher.get(); + if (launcher != null) launcher.bindItems(this, mShortcuts, msg.arg1, msg.arg2); + break; + } + } + } } diff --git a/src/com/android/launcher/LauncherModel.java b/src/com/android/launcher/LauncherModel.java index 0ef2a806b7..314a502d4e 100644 --- a/src/com/android/launcher/LauncherModel.java +++ b/src/com/android/launcher/LauncherModel.java @@ -28,9 +28,9 @@ import android.content.res.Resources; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; -import android.graphics.drawable.BitmapDrawable; import android.net.Uri; import android.util.Log; +import android.os.Process; import java.util.ArrayList; import java.util.Collections; @@ -45,7 +45,6 @@ import java.net.URISyntaxException; * Maintains in-memory state of the Launcher. It is expected that there should be only one * LauncherModel object held in a static. Also provide APIs for updating the database state * for the Launcher - * */ public class LauncherModel { private static final int UI_NOTIFICATION_RATE = 4; @@ -104,6 +103,13 @@ public class LauncherModel { } mApplicationsLoaded = false; + + if (!isLaunching) { + startApplicationsLoader(launcher); + } + } + + private void startApplicationsLoader(Launcher launcher) { mApplicationsLoader = new ApplicationsLoader(launcher); mLoader = new Thread(mApplicationsLoader, "Applications Loader"); mLoader.start(); @@ -130,6 +136,8 @@ public class LauncherModel { public void run() { mRunning = true; + android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); + Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); @@ -221,8 +229,11 @@ public class LauncherModel { * Loads all of the items on the desktop, in folders, or in the dock. * These can be apps, shortcuts or widgets */ - void loadUserItems(boolean isLaunching, Launcher launcher, boolean localeChanged) { + void loadUserItems(boolean isLaunching, Launcher launcher, boolean localeChanged, + boolean loadApplications) { + if (isLaunching && mDesktopItems != null && mDesktopItemsLoaded) { + if (loadApplications) startApplicationsLoader(launcher); // We have already loaded our data from the DB launcher.onDesktopItemsLoaded(); return; @@ -240,7 +251,7 @@ public class LauncherModel { } mDesktopItemsLoaded = false; - mDesktopItemsLoader = new DesktopItemsLoader(launcher, localeChanged); + mDesktopItemsLoader = new DesktopItemsLoader(launcher, localeChanged, loadApplications); mDesktopLoader = new Thread(mDesktopItemsLoader, "Desktop Items Loader"); mDesktopLoader.start(); } @@ -317,9 +328,11 @@ public class LauncherModel { private volatile boolean mRunning; private final WeakReference mLauncher; - private boolean mLocaleChanged; + private final boolean mLocaleChanged; + private final boolean mLoadApplications; - DesktopItemsLoader(Launcher launcher, boolean localeChanged) { + DesktopItemsLoader(Launcher launcher, boolean localeChanged, boolean loadApplications) { + mLoadApplications = loadApplications; mLauncher = new WeakReference(launcher); mLocaleChanged = localeChanged; } @@ -532,6 +545,7 @@ public class LauncherModel { launcher.onDesktopItemsLoaded(); } }); + if (mLoadApplications) startApplicationsLoader(launcher); } if (!mStopped) {