PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/talkback_preics/src/com/google/android/marvin/talkback/formatter/tv/LauncherButtonFormatter.java

http://eyes-free.googlecode.com/
Java | 52 lines | 25 code | 6 blank | 21 comment | 5 complexity | 09ea292a8f794976ac7e7dee16ef0c49 MD5 | raw file
 1/*
 2 * Copyright (C) 2010 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
17package com.google.android.marvin.talkback.formatter.tv;
18
19import com.google.android.marvin.talkback.Formatter;
20import com.google.android.marvin.talkback.Utterance;
21
22import android.content.Context;
23import android.view.accessibility.AccessibilityEvent;
24
25import java.util.List;
26
27/**
28 * Formatter that returns an utterance to announce a button in the Launcher
29 * application.
30 *
31 * @author svetoslavganov@google.com (Svetoslav R. Ganov)
32 */
33public final class LauncherButtonFormatter implements Formatter {
34
35    @Override
36    public void format(AccessibilityEvent event, Context context, Utterance utterance,
37            Object args) {
38        CharSequence contentDescription = event.getContentDescription();
39        if (contentDescription != null) {
40            utterance.getText().append(contentDescription);
41            return;
42        }
43        List<CharSequence> eventText = event.getText();
44        if (eventText.isEmpty()) {
45            return;
46        }
47        CharSequence text = eventText.get(0);
48        if (text != null) {
49            utterance.getText().append(text);
50        }
51    }
52}