142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy/*
242f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy * Copyright (C) 2011 The Android Open Source Project
342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy *
442f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy * Licensed under the Apache License, Version 2.0 (the "License");
542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy * you may not use this file except in compliance with the License.
642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy * You may obtain a copy of the License at
742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy *
842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy *      http://www.apache.org/licenses/LICENSE-2.0
942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy *
1042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy * Unless required by applicable law or agreed to in writing, software
1142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy * distributed under the License is distributed on an "AS IS" BASIS,
1242f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy * See the License for the specific language governing permissions and
1442f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy * limitations under the License.
1542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy */
1642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy
1742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guypackage com.android.test.hwui;
1842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy
1942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guyimport android.app.Activity;
2042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guyimport android.content.Context;
2142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guyimport android.content.res.Resources;
2242f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guyimport android.os.Bundle;
2342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guyimport android.util.DisplayMetrics;
2442f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guyimport android.view.View;
2542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guyimport android.view.ViewGroup;
2642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guyimport android.widget.ArrayAdapter;
2742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guyimport android.widget.ListView;
2842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guyimport android.widget.TextView;
2942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy
3042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy@SuppressWarnings({"UnusedDeclaration"})
3142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guypublic class ViewLayersActivity3 extends Activity {
3242f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    @Override
3342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    protected void onCreate(Bundle savedInstanceState) {
3442f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        super.onCreate(savedInstanceState);
3542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy
3642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        setContentView(R.layout.view_layers_3);
3742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy
3842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        setupList(R.id.list1);
3942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    }
4042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy
4142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    private void setupList(int listId) {
4242f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        final ListView list = (ListView) findViewById(listId);
4342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        list.setAdapter(new SimpleListAdapter(this));
4442f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        list.setLayerType(View.LAYER_TYPE_HARDWARE, null);
4542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        ((View) list.getParent()).setLayerType(View.LAYER_TYPE_HARDWARE, null);
4642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    }
4742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy
4842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    private static class SimpleListAdapter extends ArrayAdapter<String> {
4942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        public SimpleListAdapter(Context context) {
5042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            super(context, android.R.layout.simple_list_item_1, DATA_LIST);
5142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        }
5242f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy
5342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        @Override
5442f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        public View getView(int position, View convertView, ViewGroup parent) {
5542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            TextView v = (TextView) super.getView(position, convertView, parent);
5642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            final Resources r = getContext().getResources();
5742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            final DisplayMetrics metrics = r.getDisplayMetrics();
5842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            v.setCompoundDrawablePadding((int) (6 * metrics.density + 0.5f));
5942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            v.setCompoundDrawablesWithIntrinsicBounds(r.getDrawable(R.drawable.icon),
6042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy                    null, null, null);
6142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            return v;
6242f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        }
6342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    }
6442f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy
6542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    private static final String[] DATA_LIST = {
6642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra",
6742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina",
6842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan",
6942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium",
7042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia",
7142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil",
7242f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "British Indian Ocean Territory", "British Virgin Islands", "Brunei", "Bulgaria",
7342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Burkina Faso", "Burundi", "Cote d'Ivoire", "Cambodia", "Cameroon", "Canada", "Cape Verde",
7442f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Cayman Islands", "Central African Republic", "Chad", "Chile", "China",
7542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo",
7642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Cook Islands", "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czech Republic",
7742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominica", "Dominican Republic",
7842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea",
7942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Estonia", "Ethiopia", "Faeroe Islands", "Falkland Islands", "Fiji", "Finland",
8042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Former Yugoslav Republic of Macedonia", "France", "French Guiana", "French Polynesia",
8142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "French Southern Territories", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar",
8242f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau",
8342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary",
8442f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica",
8542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos",
8642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg",
8742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Macau", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands",
8842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova",
8942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia",
9042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand",
9142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "Northern Marianas",
9242f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru",
9342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar",
9442f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Reunion", "Romania", "Russia", "Rwanda", "Sqo Tome and Principe", "Saint Helena",
9542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Saint Kitts and Nevis", "Saint Lucia", "Saint Pierre and Miquelon",
9642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Saudi Arabia", "Senegal",
9742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands",
9842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea",
9942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden",
10042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Bahamas",
10142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "The Gambia", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey",
10242f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Virgin Islands", "Uganda",
10342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Ukraine", "United Arab Emirates", "United Kingdom",
10442f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan",
10542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis and Futuna", "Western Sahara",
10642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy            "Yemen", "Yugoslavia", "Zambia", "Zimbabwe"
10742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    };
10842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy}
109