Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.theme.cts;
     18 
     19 import com.android.cts.stub.R;
     20 
     21 import android.app.Activity;
     22 import android.content.Intent;
     23 import android.content.pm.ActivityInfo;
     24 import android.os.Bundle;
     25 import android.view.View;
     26 import android.widget.AdapterView;
     27 import android.widget.ListView;
     28 import android.widget.AdapterView.OnItemClickListener;
     29 
     30 /**
     31  * This activity exists solely for debugging purposes. It allows the manual
     32  * verifier to select which theme to test.
     33  */
     34 public class ThemeSelectorActivity extends Activity {
     35     private ThemeInfo[] mThemes;
     36     private int mOrientation;
     37     /**
     38      * Called with the activity is first created.
     39      */
     40     @Override
     41     public void onCreate(Bundle savedInstanceState) {
     42         super.onCreate(savedInstanceState);
     43         setContentView(R.layout.themetestlistactivity);
     44 
     45         ListView lv = (ListView) findViewById(R.id.tests_list);
     46 
     47         mThemes = ThemeTests.getThemes();
     48         lv.setAdapter(new ThemesAdapter(this, mThemes));
     49 
     50         lv.setOnItemClickListener(mTestClickedListener);
     51 
     52         mOrientation = getIntent().getIntExtra(ThemeTests.EXTRA_ORIENTATION,
     53                 ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
     54     }
     55 
     56     private OnItemClickListener mTestClickedListener = new OnItemClickListener() {
     57         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
     58             Intent intent = new Intent(ThemeSelectorActivity.this, TestListActivity.class);
     59             ThemeInfo theme = mThemes[position];
     60             intent.putExtra(ThemeTests.EXTRA_THEME_ID, theme.getResourceId());
     61             intent.putExtra(ThemeTests.EXTRA_THEME_NAME, theme.getThemeName());
     62             intent.putExtra(ThemeTests.EXTRA_ORIENTATION, mOrientation);
     63             startActivity(intent);
     64         }
     65     };
     66 }
     67