/* * Copyright (C) 2015 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.android.talkback.tutorial.exercise; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; import com.android.talkback.contextmenu.MenuActionInterceptor; import com.android.talkback.contextmenu.MenuTransformer; import com.android.talkback.tutorial.TutorialLessonPage; import com.android.utils.AccessibilityEventListener; public abstract class Exercise implements AccessibilityEventListener { private ExerciseCallback mCallback; protected TutorialLessonPage mPage; public void setTutorialLessonPage(TutorialLessonPage page) { mPage = page; } public abstract View getContentView(LayoutInflater inflater, ViewGroup parent); public void onAccessibilityEvent(AccessibilityEvent event) {} public void onAction(Context context, String action) {} public void onInitialized(Context context) {} public void clear() {} public void setExerciseCallBack(ExerciseCallback callback) { mCallback = callback; } public boolean needScrollableContainer() { return false; } protected boolean notifyExerciseCompleted(boolean autoSwitchLesson, int completeMessageResId) { if (mCallback == null) { return false; } mCallback.onExerciseCompleted(autoSwitchLesson, completeMessageResId); return true; } public interface ExerciseCallback { public void onExerciseCompleted(boolean autoSwitchLesson, int completeMessageResId); } public MenuTransformer getContextMenuTransformer() { return null; } public MenuActionInterceptor getContextMenuActionInterceptor() { return null; } }