diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-08-20 19:31:38 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-08-20 20:34:42 -0700 |
commit | 3be63c09309b21c01b535271625d4c39045690e5 (patch) | |
tree | 5bc349f6c916ddb80bf852fa68de11cdfe3cfadf /core/java/android | |
parent | e13ec26e6cab65831eefbd7b3c7aeee9ea714c91 (diff) | |
download | frameworks_base-3be63c09309b21c01b535271625d4c39045690e5.zip frameworks_base-3be63c09309b21c01b535271625d4c39045690e5.tar.gz frameworks_base-3be63c09309b21c01b535271625d4c39045690e5.tar.bz2 |
Infrastructure for supporting wallpaper previews.
Various things that will allow us to show previews of wallpapers.
Also some fixes to animations across wallpapers.
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/app/Activity.java | 21 | ||||
-rw-r--r-- | core/java/android/app/Dialog.java | 6 | ||||
-rw-r--r-- | core/java/android/app/LauncherActivity.java | 34 | ||||
-rw-r--r-- | core/java/android/service/wallpaper/IWallpaperService.aidl | 3 | ||||
-rw-r--r-- | core/java/android/service/wallpaper/WallpaperService.java | 25 | ||||
-rw-r--r-- | core/java/android/view/Window.java | 19 |
6 files changed, 90 insertions, 18 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 10e6299..80d7285 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -1930,11 +1930,32 @@ public class Activity extends ContextThemeWrapper * * @see #hasWindowFocus() * @see #onResume + * @see View#onWindowFocusChanged(boolean) */ public void onWindowFocusChanged(boolean hasFocus) { } /** + * Called when the main window associated with the activity has been + * attached to the window manager. + * See {@link View#onAttachedToWindow() View.onAttachedToWindow()} + * for more information. + * @see View#onAttachedToWindow + */ + public void onAttachedToWindow() { + } + + /** + * Called when the main window associated with the activity has been + * detached from the window manager. + * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()} + * for more information. + * @see View#onDetachedFromWindow + */ + public void onDetachedFromWindow() { + } + + /** * Returns true if this activity's <em>main</em> window currently has window focus. * Note that this is not the same as the view itself having focus. * diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java index 9432755..35d1004 100644 --- a/core/java/android/app/Dialog.java +++ b/core/java/android/app/Dialog.java @@ -576,6 +576,12 @@ public class Dialog implements DialogInterface, Window.Callback, public void onWindowFocusChanged(boolean hasFocus) { } + public void onAttachedToWindow() { + } + + public void onDetachedFromWindow() { + } + /** * Called to process key events. You can override this to intercept all * key events before they are dispatched to the window. Be sure to call diff --git a/core/java/android/app/LauncherActivity.java b/core/java/android/app/LauncherActivity.java index d788c43..a83f4e8 100644 --- a/core/java/android/app/LauncherActivity.java +++ b/core/java/android/app/LauncherActivity.java @@ -18,6 +18,7 @@ package android.app; import android.content.Context; import android.content.Intent; +import android.content.pm.ComponentInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; @@ -70,13 +71,15 @@ public abstract class LauncherActivity extends ListActivity { ListItem(PackageManager pm, ResolveInfo resolveInfo, IconResizer resizer) { this.resolveInfo = resolveInfo; label = resolveInfo.loadLabel(pm); - if (label == null && resolveInfo.activityInfo != null) { + ComponentInfo ci = resolveInfo.activityInfo; + if (ci == null) ci = resolveInfo.serviceInfo; + if (label == null && ci != null) { label = resolveInfo.activityInfo.name; } icon = resizer.createIconThumbnail(resolveInfo.loadIcon(pm)); - packageName = resolveInfo.activityInfo.applicationInfo.packageName; - className = resolveInfo.activityInfo.name; + packageName = ci.applicationInfo.packageName; + className = ci.name; } public ListItem() { @@ -325,8 +328,7 @@ public abstract class LauncherActivity extends ListActivity { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setProgressBarIndeterminateVisibility(true); - setContentView(com.android.internal.R.layout.activity_list); - + onSetContentView(); mIntent = new Intent(getTargetIntent()); mIntent.setComponent(null); @@ -338,10 +340,17 @@ public abstract class LauncherActivity extends ListActivity { setProgressBarIndeterminateVisibility(false); } + /** + * Override to call setContentView() with your own content view to + * customize the list layout. + */ + protected void onSetContentView() { + setContentView(com.android.internal.R.layout.activity_list); + } + @Override protected void onListItemClick(ListView l, View v, int position, long id) { - Intent intent = ((ActivityAdapter)mAdapter).intentForPosition(position); - + Intent intent = intentForPosition(position); startActivity(intent); } @@ -374,12 +383,19 @@ public abstract class LauncherActivity extends ListActivity { } /** + * Perform query on package manager for list items. The default + * implementation queries for activities. + */ + protected List<ResolveInfo> onQueryPackageManager(Intent queryIntent) { + return mPackageManager.queryIntentActivities(queryIntent, /* no flags */ 0); + } + + /** * Perform the query to determine which results to show and return a list of them. */ public List<ListItem> makeListItems() { // Load all matching activities and sort correctly - List<ResolveInfo> list = mPackageManager.queryIntentActivities(mIntent, - /* no flags */ 0); + List<ResolveInfo> list = onQueryPackageManager(mIntent); Collections.sort(list, new ResolveInfo.DisplayNameComparator(mPackageManager)); IconResizer resizer = new IconResizer(); diff --git a/core/java/android/service/wallpaper/IWallpaperService.aidl b/core/java/android/service/wallpaper/IWallpaperService.aidl index eb58c3b..bc7a1d7 100644 --- a/core/java/android/service/wallpaper/IWallpaperService.aidl +++ b/core/java/android/service/wallpaper/IWallpaperService.aidl @@ -23,5 +23,6 @@ import android.service.wallpaper.IWallpaperConnection; */ oneway interface IWallpaperService { void attach(IWallpaperConnection connection, - IBinder windowToken, int reqWidth, int reqHeight); + IBinder windowToken, int windowType, boolean isPreview, + int reqWidth, int reqHeight); } diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 5bb07f3..629e97e 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -212,6 +212,15 @@ public abstract class WallpaperService extends Service { } /** + * Returns true if this engine is running in preview mode -- that is, + * it is being shown to the user before they select it as the actual + * wallpaper. + */ + public boolean isPreview() { + return mIWallpaperEngine.mIsPreview; + } + + /** * Control whether this wallpaper will receive raw touch events * from the window manager as the user interacts with the window * that is currently displaying the wallpaper. By default they @@ -332,7 +341,7 @@ public abstract class WallpaperService extends Service { mLayout.token = mWindowToken; if (!mCreated) { - mLayout.type = WindowManager.LayoutParams.TYPE_WALLPAPER; + mLayout.type = mIWallpaperEngine.mWindowType; mLayout.gravity = Gravity.LEFT|Gravity.TOP; mSession.add(mWindow, mLayout, View.VISIBLE, mContentInsets); } @@ -465,6 +474,8 @@ public abstract class WallpaperService extends Service { final IWallpaperConnection mConnection; final IBinder mWindowToken; + final int mWindowType; + final boolean mIsPreview; int mReqWidth; int mReqHeight; @@ -472,10 +483,12 @@ public abstract class WallpaperService extends Service { IWallpaperEngineWrapper(WallpaperService context, IWallpaperConnection conn, IBinder windowToken, - int reqWidth, int reqHeight) { + int windowType, boolean isPreview, int reqWidth, int reqHeight) { mCaller = new HandlerCaller(context, this); mConnection = conn; mWindowToken = windowToken; + mWindowType = windowType; + mIsPreview = isPreview; mReqWidth = reqWidth; mReqHeight = reqHeight; @@ -567,10 +580,10 @@ public abstract class WallpaperService extends Service { mTarget = context; } - public void attach(IWallpaperConnection conn, - IBinder windowToken, int reqWidth, int reqHeight) { - new IWallpaperEngineWrapper( - mTarget, conn, windowToken, reqWidth, reqHeight); + public void attach(IWallpaperConnection conn, IBinder windowToken, + int windowType, boolean isPreview, int reqWidth, int reqHeight) { + new IWallpaperEngineWrapper(mTarget, conn, windowToken, + windowType, isPreview, reqWidth, reqHeight); } } diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index 02e0515..1932765 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -237,7 +237,6 @@ public abstract class Window { /** * This is called whenever the current window attributes change. * - */ public void onWindowAttributesChanged(WindowManager.LayoutParams attrs); @@ -252,13 +251,29 @@ public abstract class Window { public void onContentChanged(); /** - * This hook is called whenever the window focus changes. + * This hook is called whenever the window focus changes. See + * {@link View#onWindowFocusChanged(boolean) + * View.onWindowFocusChanged(boolean)} for more information. * * @param hasFocus Whether the window now has focus. */ public void onWindowFocusChanged(boolean hasFocus); /** + * Called when the window has been attached to the window manager. + * See {@link View#onAttachedToWindow() View.onAttachedToWindow()} + * for more information. + */ + public void onAttachedToWindow(); + + /** + * Called when the window has been attached to the window manager. + * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()} + * for more information. + */ + public void onDetachedFromWindow(); + + /** * Called when a panel is being closed. If another logical subsequent * panel is being opened (and this panel is being closed to make room for the subsequent * panel), this method will NOT be called. |