diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/SystemUI/res/drawable-xlarge-mdpi/app_icon.png | bin | 0 -> 5167 bytes | |||
-rw-r--r-- | packages/SystemUI/res/layout-xlarge/sysbar_panel_recent.xml | 30 | ||||
-rw-r--r-- | packages/SystemUI/res/layout-xlarge/sysbar_panel_recent_item.xml | 59 | ||||
-rw-r--r-- | packages/SystemUI/res/values/strings.xml | 3 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java | 190 |
5 files changed, 218 insertions, 64 deletions
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/app_icon.png b/packages/SystemUI/res/drawable-xlarge-mdpi/app_icon.png Binary files differnew file mode 100644 index 0000000..50a8ac8 --- /dev/null +++ b/packages/SystemUI/res/drawable-xlarge-mdpi/app_icon.png diff --git a/packages/SystemUI/res/layout-xlarge/sysbar_panel_recent.xml b/packages/SystemUI/res/layout-xlarge/sysbar_panel_recent.xml index 2f9e0d7..ac038a7 100644 --- a/packages/SystemUI/res/layout-xlarge/sysbar_panel_recent.xml +++ b/packages/SystemUI/res/layout-xlarge/sysbar_panel_recent.xml @@ -25,25 +25,29 @@ android:background="@drawable/sysbar_panel_recents_bg" android:orientation="vertical"> + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/recent_tasks_app_label" + android:textSize="22dip" + android:drawableLeft="@drawable/app_icon" + android:layout_margin="10dip" + /> + <TextView android:id="@+id/recents_no_recents" android:layout_width="match_parent" android:layout_height="match_parent" android:text="@string/recent_tasks_empty" + android:textSize="22dip" android:gravity="center_horizontal|center_vertical" - android:visibility="gone"> + android:visibility="gone" + android:layout_margin="10dip"> </TextView> - <HorizontalScrollView android:id="@+id/scroll_view" - android:layout_width="match_parent" - android:layout_height="wrap_content"> - - <LinearLayout android:id="@+id/recents_container" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:gravity="right" - android:orientation="horizontal" - /> - - </HorizontalScrollView> + <LinearLayout android:id="@+id/recents_container" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical" + /> </com.android.systemui.statusbar.tablet.RecentAppsPanel> diff --git a/packages/SystemUI/res/layout-xlarge/sysbar_panel_recent_item.xml b/packages/SystemUI/res/layout-xlarge/sysbar_panel_recent_item.xml new file mode 100644 index 0000000..b1997b8 --- /dev/null +++ b/packages/SystemUI/res/layout-xlarge/sysbar_panel_recent_item.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* apps/common/assets/default/default/skins/StatusBar.xml +** +** Copyright 2006, 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. +*/ +--> + +<!-- android:background="@drawable/status_bar_closed_default_background" --> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:orientation="horizontal" + android:layout_margin="10dip"> + + <ImageView android:id="@+id/app_thumbnail" + android:layout_width="88dip" + android:layout_height="56dip" + android:layout_margin="10dip" + android:background="#80808080"> + </ImageView> + + <LinearLayout + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:orientation="horizontal" + android:layout_marginTop="10dip" + android:layout_marginBottom="10dip" + android:layout_marginRight="10dip"> + + <ImageView android:id="@+id/app_icon" + android:layout_width="23dip" + android:layout_height="23dip" + android:gravity="bottom" + android:layout_margin="5dip" + /> + + <TextView android:id="@+id/app_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="22dip" + /> + + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 6384db5..a65de37 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -80,6 +80,9 @@ <!-- Recent Tasks dialog: message when there are no recent applications [CHAR LIMIT=NONE]--> <string name="recent_tasks_empty">No recent applications.</string> + <!-- Recent apps label. Shown as title on recent apps panel --> + <string name="recent_tasks_app_label">Apps</string> + <!-- Rotation lock toast text: shown when rotation lock is turned off (and the screen will auto-rotate based on the accelerometer). [CHAR LIMIT=NONE]--> <string name="toast_rotation_free">Screen will rotate automatically.</string> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java index 6797958..1831eda 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java @@ -20,45 +20,75 @@ import java.util.ArrayList; import java.util.List; import android.app.ActivityManager; -import android.bluetooth.BluetoothAdapter; +import android.app.IThumbnailReceiver; +import android.app.ActivityManager.RunningTaskInfo; import android.content.Context; import android.content.Intent; -import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.content.res.TypedArray; import android.graphics.Bitmap; +import android.graphics.Matrix; import android.graphics.drawable.Drawable; -import android.media.AudioManager; -import android.net.wifi.WifiManager; +import android.os.RemoteException; import android.util.AttributeSet; import android.util.Log; import android.view.View; -import android.view.ViewGroup; import android.view.View.OnClickListener; -import android.widget.BaseAdapter; -import android.widget.Gallery; -import android.widget.HorizontalScrollView; -import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; -import android.widget.Toast; import com.android.systemui.R; public class RecentAppsPanel extends LinearLayout implements StatusBarPanel, OnClickListener { private static final String TAG = "RecentAppsPanel"; private static final boolean DEBUG = TabletStatusBarService.DEBUG; - private static final int MAX_RECENT_TASKS = 20; - private static final float ITEM_WIDTH = 75; - private static final float ITEM_HEIGHT = 75; + private static final int DISPLAY_TASKS = 4; // number of recent tasks to display + private static final int MAX_TASKS = 2 * DISPLAY_TASKS; // give some slack for non-apps + private static final boolean DBG = true; private TabletStatusBarService mBar; private TextView mNoRecents; private LinearLayout mRecentsContainer; - private float mDensity; - private HorizontalScrollView mScrollView; + private ArrayList<ActivityDescription> mActivityDescriptions; + + static class ActivityDescription { + int id; + Bitmap thumbnail; // generated by Activity.onCreateThumbnail() + Drawable icon; // application package icon + String label; // application package label + CharSequence description; // generated by Activity.onCreateDescription() + Intent intent; // launch intent for application + Matrix matrix; // arbitrary rotation matrix to correct orientation + int position; // position in list + + public ActivityDescription(Bitmap _thumbnail, + Drawable _icon, String _label, String _desc, Intent _intent, int _id, int _pos) + { + thumbnail = _thumbnail; + icon = _icon; + label = _label; + description = _desc; + intent = _intent; + id = _id; + position = _pos; + } + }; + + private final IThumbnailReceiver mThumbnailReceiver = new IThumbnailReceiver.Stub() { + + public void finished() throws RemoteException { + } + + public void newThumbnail(final int id, final Bitmap bitmap, CharSequence description) + throws RemoteException { + ActivityDescription info = findActivityDescription(id); + if (info != null) { + info.thumbnail = bitmap; + info.description = description; + } + } + }; public boolean isInContentArea(int x, int y) { final int l = getPaddingLeft(); @@ -78,7 +108,6 @@ public class RecentAppsPanel extends LinearLayout implements StatusBarPanel, OnC public RecentAppsPanel(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - mDensity = getResources().getDisplayMetrics().density; } @Override @@ -86,8 +115,6 @@ public class RecentAppsPanel extends LinearLayout implements StatusBarPanel, OnC super.onFinishInflate(); mNoRecents = (TextView) findViewById(R.id.recents_no_recents); mRecentsContainer = (LinearLayout) findViewById(R.id.recents_container); - mScrollView = (HorizontalScrollView) findViewById(R.id.scroll_view); - mScrollView.setHorizontalFadingEdgeEnabled(true); } @Override @@ -95,63 +122,124 @@ public class RecentAppsPanel extends LinearLayout implements StatusBarPanel, OnC super.onVisibilityChanged(changedView, visibility); Log.v(TAG, "onVisibilityChanged(" + changedView + ", " + visibility + ")"); if (visibility == View.VISIBLE && changedView == this) { - refreshIcons(); + refreshApplicationList(); mRecentsContainer.setScrollbarFadingEnabled(true); mRecentsContainer.scrollTo(0, 0); } } - private void refreshIcons() { - mRecentsContainer.removeAllViews(); - final Context context = getContext(); - final PackageManager pm = context.getPackageManager(); + private ArrayList<ActivityDescription> getRecentTasks() { + ArrayList<ActivityDescription> activityDescriptions = new ArrayList<ActivityDescription>(); + final PackageManager pm = mContext.getPackageManager(); final ActivityManager am = (ActivityManager) - context.getSystemService(Context.ACTIVITY_SERVICE); + mContext.getSystemService(Context.ACTIVITY_SERVICE); + final List<ActivityManager.RecentTaskInfo> recentTasks = - am.getRecentTasks(MAX_RECENT_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE); + am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE); - ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN) - .addCategory(Intent.CATEGORY_HOME) - .resolveActivityInfo(pm, 0); + ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME) + .resolveActivityInfo(pm, 0); int numTasks = recentTasks.size(); - final int width = (int) (mDensity * ITEM_WIDTH + 0.5f); - final int height = (int) (mDensity * ITEM_HEIGHT + 0.5f); - ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(width, height); - for (int i = 0; i < numTasks; ++i) { - final ActivityManager.RecentTaskInfo info = recentTasks.get(i); - - Intent intent = new Intent(info.baseIntent); - if (info.origActivity != null) { - intent.setComponent(info.origActivity); + for (int i = 0, index = 0; i < numTasks && (index < MAX_TASKS); ++i) { + final ActivityManager.RecentTaskInfo recentInfo = recentTasks.get(i); + + Intent intent = new Intent(recentInfo.baseIntent); + if (recentInfo.origActivity != null) { + intent.setComponent(recentInfo.origActivity); } - // Exclude home activity. + // Skip the current home activity. if (homeInfo != null && homeInfo.packageName.equals(intent.getComponent().getPackageName()) && homeInfo.name.equals(intent.getComponent().getClassName())) { - continue; + continue; } intent.setFlags((intent.getFlags()&~Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) | Intent.FLAG_ACTIVITY_NEW_TASK); final ResolveInfo resolveInfo = pm.resolveActivity(intent, 0); if (resolveInfo != null) { - final ActivityInfo activityInfo = resolveInfo.activityInfo; - final String title = activityInfo.loadLabel(pm).toString(); - Drawable icon = activityInfo.loadIcon(pm); - + final ActivityInfo info = resolveInfo.activityInfo; + final String title = info.loadLabel(pm).toString(); + Drawable icon = info.loadIcon(pm); + int id = recentTasks.get(i).id; if (title != null && title.length() > 0 && icon != null) { - ImageView imageView = new ImageView(mContext); - imageView.setScaleType(ImageView.ScaleType.FIT_XY); - imageView.setLayoutParams(layoutParams); - imageView.setOnClickListener(this); - imageView.setTag(intent); - imageView.setImageDrawable(icon); - mRecentsContainer.addView(imageView); + Log.v(TAG, "creating activity desc for id=" + id + ", label=" + title); + ActivityDescription item = new ActivityDescription( + null, icon, title, null, intent, id, index); + activityDescriptions.add(item); + ++index; + } else { + if (DBG) Log.v(TAG, "SKIPPING item " + id); } } } + return activityDescriptions; + } + + ActivityDescription findActivityDescription(int id) + { + ActivityDescription desc = null; + for (int i = 0; i < mActivityDescriptions.size(); i++) { + ActivityDescription item = mActivityDescriptions.get(i); + if (item != null && item.id == id) { + desc = item; + break; + } + } + return desc; + } + + private void getThumbnails(ArrayList<ActivityDescription> tasks) { + ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); + List<RunningTaskInfo> runningTasks = am.getRunningTasks(MAX_TASKS, 0, mThumbnailReceiver); + for (RunningTaskInfo r : runningTasks) { + // Find the activity description associted with the given id + ActivityDescription desc = findActivityDescription(r.id); + if (desc != null) { + if (r.thumbnail != null) { + desc.thumbnail = r.thumbnail; + desc.description = r.description; + } else { + if (DBG) Log.v(TAG, "*** RUNNING THUMBNAIL WAS NULL ***"); + } + } else { + if (DBG) Log.v(TAG, "Couldn't find ActivityDesc for id=" + r.id); + } + } + } + + private void refreshApplicationList() { + mActivityDescriptions = getRecentTasks(); + getThumbnails(mActivityDescriptions); + updateUiElements(); + } + + private void updateUiElements() { + mRecentsContainer.removeAllViews(); + final int first = 0; + final int last = Math.min(mActivityDescriptions.size(), DISPLAY_TASKS) - 1; + for (int i = last; i >= first; i--) { + ActivityDescription activityDescription = mActivityDescriptions.get(i); + View view = View.inflate(mContext, R.layout.sysbar_panel_recent_item, null); + ImageView appThumbnail = (ImageView) view.findViewById(R.id.app_thumbnail); + ImageView appIcon = (ImageView) view.findViewById(R.id.app_icon); + TextView appDescription = (TextView) view.findViewById(R.id.app_label); + if (activityDescription.thumbnail != null) { + Log.v(TAG, "thumbnail res = " + activityDescription.thumbnail.getWidth() + + "x" + activityDescription.thumbnail.getHeight()); + } else { + Log.v(TAG, "thumbnail for " + activityDescription.label + " was null"); + } + appThumbnail.setImageBitmap(activityDescription.thumbnail); + appIcon.setImageDrawable(activityDescription.icon); + appDescription.setText(activityDescription.label); + view.setOnClickListener(this); + view.setTag(activityDescription.intent); + Log.v(TAG, "Adding task: " + activityDescription.label); + mRecentsContainer.addView(view); + } int views = mRecentsContainer.getChildCount(); mNoRecents.setVisibility(views == 0 ? View.VISIBLE : View.GONE); |