summaryrefslogtreecommitdiffstats
path: root/tests/DpiTest
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:45 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:45 -0800
commitd83a98f4ce9cfa908f5c54bbd70f03eec07e7553 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /tests/DpiTest
parent076357b8567458d4b6dfdcf839ef751634cd2bfb (diff)
downloadframeworks_base-d83a98f4ce9cfa908f5c54bbd70f03eec07e7553.zip
frameworks_base-d83a98f4ce9cfa908f5c54bbd70f03eec07e7553.tar.gz
frameworks_base-d83a98f4ce9cfa908f5c54bbd70f03eec07e7553.tar.bz2
auto import from //depot/cupcake/@135843
Diffstat (limited to 'tests/DpiTest')
-rw-r--r--tests/DpiTest/Android.mk10
-rw-r--r--tests/DpiTest/AndroidManifest.xml28
-rw-r--r--tests/DpiTest/res/drawable-120dpi/logo120dpi.pngbin5178 -> 0 bytes
-rw-r--r--tests/DpiTest/res/drawable-240dpi/logo240dpi.pngbin13388 -> 0 bytes
-rw-r--r--tests/DpiTest/res/drawable/logo160dpi.pngbin8114 -> 0 bytes
-rw-r--r--tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java167
6 files changed, 0 insertions, 205 deletions
diff --git a/tests/DpiTest/Android.mk b/tests/DpiTest/Android.mk
deleted file mode 100644
index 3596c39..0000000
--- a/tests/DpiTest/Android.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := DensityTest
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/DpiTest/AndroidManifest.xml b/tests/DpiTest/AndroidManifest.xml
deleted file mode 100644
index f71cff2..0000000
--- a/tests/DpiTest/AndroidManifest.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?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.dpi">
- <application android:label="DpiTest">
- <activity android:name="DpiTestActivity" android:label="DpiTest">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/DpiTest/res/drawable-120dpi/logo120dpi.png b/tests/DpiTest/res/drawable-120dpi/logo120dpi.png
deleted file mode 100644
index 46bbd5b..0000000
--- a/tests/DpiTest/res/drawable-120dpi/logo120dpi.png
+++ /dev/null
Binary files differ
diff --git a/tests/DpiTest/res/drawable-240dpi/logo240dpi.png b/tests/DpiTest/res/drawable-240dpi/logo240dpi.png
deleted file mode 100644
index 4d717a8..0000000
--- a/tests/DpiTest/res/drawable-240dpi/logo240dpi.png
+++ /dev/null
Binary files differ
diff --git a/tests/DpiTest/res/drawable/logo160dpi.png b/tests/DpiTest/res/drawable/logo160dpi.png
deleted file mode 100644
index c23b2ce..0000000
--- a/tests/DpiTest/res/drawable/logo160dpi.png
+++ /dev/null
Binary files differ
diff --git a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java
deleted file mode 100644
index 3759622..0000000
--- a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * 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.
- */
-
-package com.google.android.test.dpi;
-
-import android.app.Activity;
-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.LinearLayout;
-import android.widget.TextView;
-import android.widget.ScrollView;
-import android.view.View;
-import android.content.Context;
-
-public class DpiTestActivity extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- LinearLayout root = new LinearLayout(this);
- root.setOrientation(LinearLayout.VERTICAL);
-
- LinearLayout layout = new LinearLayout(this);
- addBitmapDrawable(layout, R.drawable.logo120dpi, true);
- addBitmapDrawable(layout, R.drawable.logo160dpi, true);
- addBitmapDrawable(layout, R.drawable.logo240dpi, true);
- addLabelToRoot(root, "Prescaled bitmap in drawable");
- addChildToRoot(root, layout);
-
- layout = new LinearLayout(this);
- addBitmapDrawable(layout, R.drawable.logo120dpi, false);
- addBitmapDrawable(layout, R.drawable.logo160dpi, false);
- addBitmapDrawable(layout, R.drawable.logo240dpi, false);
- addLabelToRoot(root, "Autoscaled bitmap in drawable");
- addChildToRoot(root, layout);
-
- layout = new LinearLayout(this);
- addResourceDrawable(layout, R.drawable.logo120dpi);
- addResourceDrawable(layout, R.drawable.logo160dpi);
- addResourceDrawable(layout, R.drawable.logo240dpi);
- addLabelToRoot(root, "Prescaled resource drawable");
- addChildToRoot(root, layout);
-
- layout = new LinearLayout(this);
- addCanvasBitmap(layout, R.drawable.logo120dpi, true);
- addCanvasBitmap(layout, R.drawable.logo160dpi, true);
- addCanvasBitmap(layout, R.drawable.logo240dpi, true);
- addLabelToRoot(root, "Prescaled bitmap");
- addChildToRoot(root, layout);
-
- layout = new LinearLayout(this);
- addCanvasBitmap(layout, R.drawable.logo120dpi, false);
- addCanvasBitmap(layout, R.drawable.logo160dpi, false);
- addCanvasBitmap(layout, R.drawable.logo240dpi, false);
- addLabelToRoot(root, "Autoscaled bitmap");
- addChildToRoot(root, layout);
-
- setContentView(scrollWrap(root));
- }
-
- private View scrollWrap(View view) {
- ScrollView scroller = new ScrollView(this);
- scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.FILL_PARENT,
- ScrollView.LayoutParams.FILL_PARENT));
- return scroller;
- }
-
- private void addLabelToRoot(LinearLayout root, String text) {
- TextView label = new TextView(this);
- label.setText(text);
- root.addView(label, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
- LinearLayout.LayoutParams.WRAP_CONTENT));
- }
-
- private void addChildToRoot(LinearLayout root, LinearLayout layout) {
- root.addView(layout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
- LinearLayout.LayoutParams.WRAP_CONTENT));
- }
-
- private void addBitmapDrawable(LinearLayout layout, int resource, boolean scale) {
- Bitmap bitmap;
- bitmap = loadAndPrintDpi(resource, scale);
-
- View view = new View(this);
-
- final BitmapDrawable d = new BitmapDrawable(bitmap);
- if (!scale) d.setDensityScale(getResources().getDisplayMetrics());
- view.setBackgroundDrawable(d);
-
- view.setLayoutParams(new LinearLayout.LayoutParams(d.getIntrinsicWidth(),
- d.getIntrinsicHeight()));
- layout.addView(view);
- }
-
- private void addResourceDrawable(LinearLayout layout, int resource) {
- View view = new View(this);
-
- final Drawable d = getResources().getDrawable(resource);
- view.setBackgroundDrawable(d);
-
- view.setLayoutParams(new LinearLayout.LayoutParams(d.getIntrinsicWidth(),
- d.getIntrinsicHeight()));
- layout.addView(view);
- }
-
- private void addCanvasBitmap(LinearLayout layout, int resource, boolean scale) {
- Bitmap bitmap;
- bitmap = loadAndPrintDpi(resource, scale);
-
- ScaledBitmapView view = new ScaledBitmapView(this, bitmap);
-
- view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT));
- layout.addView(view);
- }
-
- private Bitmap loadAndPrintDpi(int id, boolean scale) {
- Bitmap bitmap;
- if (scale) {
- bitmap = BitmapFactory.decodeResource(getResources(), id);
- } else {
- BitmapFactory.Options opts = new BitmapFactory.Options();
- opts.inScaled = false;
- bitmap = BitmapFactory.decodeResource(getResources(), id, opts);
- }
- return bitmap;
- }
-
- private class ScaledBitmapView extends View {
- private Bitmap mBitmap;
-
- public ScaledBitmapView(Context context, Bitmap bitmap) {
- super(context);
- mBitmap = bitmap;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- setMeasuredDimension(mBitmap.getScaledWidth(), mBitmap.getScaledHeight());
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
-
- canvas.drawBitmap(mBitmap, 0.0f, 0.0f, null);
- }
- }
-}