Home | History | Annotate | Download | only in accessibility
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
      5  * use this file except in compliance with the License. You may obtain a copy of
      6  * 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, WITHOUT
     12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     13  * License for the specific language governing permissions and limitations under
     14  * the License.
     15  */
     16 
     17 package com.example.android.apis.accessibility;
     18 
     19 import com.example.android.apis.R;
     20 
     21 import android.app.ListActivity;
     22 import android.content.Intent;
     23 import android.os.Bundle;
     24 import android.provider.Settings;
     25 import android.view.View;
     26 import android.widget.ImageButton;
     27 
     28 /** Starts up the task list that will interact with the AccessibilityService sample. */
     29 public class TaskListActivity extends ListActivity {
     30 
     31     /** An intent for launching the system settings. */
     32     private static final Intent sSettingsIntent =
     33         new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
     34 
     35     /** Called when the activity is first created. */
     36     @Override
     37     public void onCreate(Bundle savedInstanceState) {
     38         super.onCreate(savedInstanceState);
     39         setContentView(R.layout.tasklist_main);
     40 
     41         // Hard-coded hand-waving here.
     42         boolean[] checkboxes = {true, true, false, true, false, false, false};
     43         String[] labels = {"Take out Trash", "Do Laundry",
     44                            "Conquer World", "Nap", "Do Taxes",
     45                            "Abolish IRS", "Tea with Aunt Sharon" };
     46 
     47         TaskAdapter myAdapter = new TaskAdapter(this, labels, checkboxes);
     48         this.setListAdapter(myAdapter);
     49 
     50         // Add a shortcut to the accessibility settings.
     51         ImageButton button = (ImageButton) findViewById(R.id.button);
     52         button.setOnClickListener(new View.OnClickListener() {
     53             @Override
     54             public void onClick(View v) {
     55                 startActivity(sSettingsIntent);
     56             }
     57         });
     58     }
     59 }
     60