summaryrefslogtreecommitdiff
path: root/tests/DpiTest/src
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-07-17 11:13:48 -0700
committerDianne Hackborn <hackbod@google.com>2009-07-17 16:59:08 -0700
commita53b828635fce8b6b2d3e3377d74d72070056623 (patch)
tree42f4ba9bbf7d8656a4761d6fe5dcd4976cf19369 /tests/DpiTest/src
parent09a903ab5b8d940605783ae4ee591c0f090a31d1 (diff)
Add "nodpi" density, and expose a bunch of density-related APIs.
Also update the DpiTest app to use nodpi images, and try to have a mode where it turns off compatibility though it's not quite working.
Diffstat (limited to 'tests/DpiTest/src')
-rw-r--r--tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java37
-rw-r--r--tests/DpiTest/src/com/google/android/test/dpi/DpiTestNoCompatActivity.java23
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java
index 5a9f3f548c7d..9169025035af 100644
--- a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java
+++ b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java
@@ -28,8 +28,38 @@ import android.widget.TextView;
import android.widget.ScrollView;
import android.view.View;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.CompatibilityInfo;
public class DpiTestActivity extends Activity {
+ public DpiTestActivity() {
+ super();
+ init(false);
+ }
+
+ public DpiTestActivity(boolean noCompat) {
+ super();
+ init(noCompat);
+ }
+
+ public void init(boolean noCompat) {
+ try {
+ ApplicationInfo ai = getPackageManager().getApplicationInfo(
+ "com.google.android.test.dpi",
+ PackageManager.GET_SUPPORTS_DENSITIES);
+ if (noCompat) {
+ ai.flags |= ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS
+ | ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS
+ | ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS;
+ ai.supportsDensities = new int[] { ApplicationInfo.ANY_DENSITY };
+ }
+ getResources().setCompatibilityInfo(new CompatibilityInfo(ai));
+ } catch (PackageManager.NameNotFoundException e) {
+ throw new RuntimeException("ouch", e);
+ }
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -73,6 +103,13 @@ public class DpiTestActivity extends Activity {
addLabelToRoot(root, "Autoscaled bitmap");
addChildToRoot(root, layout);
+ layout = new LinearLayout(this);
+ addResourceDrawable(layout, R.drawable.logonodpi120);
+ addResourceDrawable(layout, R.drawable.logonodpi160);
+ addResourceDrawable(layout, R.drawable.logonodpi240);
+ addLabelToRoot(root, "No-dpi resource drawable");
+ addChildToRoot(root, layout);
+
setContentView(scrollWrap(root));
}
diff --git a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestNoCompatActivity.java b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestNoCompatActivity.java
new file mode 100644
index 000000000000..4d25e083e039
--- /dev/null
+++ b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestNoCompatActivity.java
@@ -0,0 +1,23 @@
+/*
+ * 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;
+
+public class DpiTestNoCompatActivity extends DpiTestActivity {
+ public DpiTestNoCompatActivity() {
+ super(true);
+ }
+}