diff options
author | Dianne Hackborn <hackbod@google.com> | 2011-04-08 18:28:14 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-04-08 18:28:14 -0700 |
commit | bcbab3684349353ee8cab30b556001824d0e7ccf (patch) | |
tree | cd5699f89c052a71e8ebad1cc4fbbb256c5c0883 /tests | |
parent | 0741b1ae22ecb5f6ac449bf85ef06e05c8d8f438 (diff) | |
parent | f26fd99a7c2f554b0297760bb66336473c7db61f (diff) | |
download | frameworks_base-bcbab3684349353ee8cab30b556001824d0e7ccf.zip frameworks_base-bcbab3684349353ee8cab30b556001824d0e7ccf.tar.gz frameworks_base-bcbab3684349353ee8cab30b556001824d0e7ccf.tar.bz2 |
Merge "Rework thumbnails in activity manager."
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ActivityTests/Android.mk | 11 | ||||
-rw-r--r-- | tests/ActivityTests/AndroidManifest.xml | 29 | ||||
-rw-r--r-- | tests/ActivityTests/res/values/strings.xml | 19 | ||||
-rw-r--r-- | tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java | 99 |
4 files changed, 158 insertions, 0 deletions
diff --git a/tests/ActivityTests/Android.mk b/tests/ActivityTests/Android.mk new file mode 100644 index 0000000..f3c6b5a --- /dev/null +++ b/tests/ActivityTests/Android.mk @@ -0,0 +1,11 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_PACKAGE_NAME := ActivityTest + +LOCAL_MODULE_TAGS := tests +LOCAL_CERTIFICATE := platform + +include $(BUILD_PACKAGE) diff --git a/tests/ActivityTests/AndroidManifest.xml b/tests/ActivityTests/AndroidManifest.xml new file mode 100644 index 0000000..6fa27ed --- /dev/null +++ b/tests/ActivityTests/AndroidManifest.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2008 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. +--> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.google.android.test.activity"> + <uses-permission android:name="android.permission.GET_TASKS" /> + <uses-permission android:name="android.permission.READ_FRAME_BUFFER" /> + <application android:label="ActivityTest"> + <activity android:name="ActivityTestMain"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> +</manifest> diff --git a/tests/ActivityTests/res/values/strings.xml b/tests/ActivityTests/res/values/strings.xml new file mode 100644 index 0000000..71705cb --- /dev/null +++ b/tests/ActivityTests/res/values/strings.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 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. +--> + +<resources> + <string name="act_title">DpiTest: Unknown Screen</string> +</resources> diff --git a/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java new file mode 100644 index 0000000..8c5c35a --- /dev/null +++ b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.android.test.activity; + +import java.util.ArrayList; +import java.util.List; + +import android.app.Activity; +import android.app.ActivityManager; +import android.app.ActivityThread; +import android.app.Application; +import android.os.Bundle; +import android.graphics.BitmapFactory; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.ScrollView; +import android.view.LayoutInflater; +import android.view.View; +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.res.CompatibilityInfo; +import android.util.DisplayMetrics; +import android.util.Log; + +public class ActivityTestMain extends Activity { + private void addThumbnail(LinearLayout container, Bitmap bm) { + ImageView iv = new ImageView(this); + if (bm != null) { + iv.setImageBitmap(bm); + } + iv.setBackgroundResource(android.R.drawable.gallery_thumb); + int w = getResources().getDimensionPixelSize(android.R.dimen.thumbnail_width); + int h = getResources().getDimensionPixelSize(android.R.dimen.thumbnail_height); + container.addView(iv, new LinearLayout.LayoutParams(w, h)); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + ActivityManager am = (ActivityManager)getSystemService(ACTIVITY_SERVICE); + + LinearLayout top = new LinearLayout(this); + top.setOrientation(LinearLayout.VERTICAL); + + List<ActivityManager.RecentTaskInfo> recents = am.getRecentTasks(10, + ActivityManager.RECENT_WITH_EXCLUDED); + if (recents != null) { + for (int i=0; i<recents.size(); i++) { + ActivityManager.RecentTaskInfo r = recents.get(i); + ActivityManager.TaskThumbnails tt = r != null + ? am.getTaskThumbnails(r.persistentId) : null; + TextView tv = new TextView(this); + tv.setText(r.baseIntent.getComponent().flattenToShortString()); + top.addView(tv, new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.WRAP_CONTENT, + LinearLayout.LayoutParams.WRAP_CONTENT)); + LinearLayout item = new LinearLayout(this); + item.setOrientation(LinearLayout.HORIZONTAL); + addThumbnail(item, tt != null ? tt.mainThumbnail : null); + for (int j=0; j<tt.numSubThumbbails; j++) { + addThumbnail(item, tt.getSubThumbnail(j)); + } + top.addView(item, new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.WRAP_CONTENT, + LinearLayout.LayoutParams.WRAP_CONTENT)); + } + } + + setContentView(scrollWrap(top)); + } + + private View scrollWrap(View view) { + ScrollView scroller = new ScrollView(this); + scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT, + ScrollView.LayoutParams.MATCH_PARENT)); + return scroller; + } +} |