Barnaby James | 092c62f | 2014-08-08 21:01:01 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2014 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 com.android.settings; |
| 18 | |
| 19 | import android.app.Activity; |
| 20 | import android.content.Intent; |
| 21 | import android.os.Bundle; |
| 22 | import android.util.Log; |
| 23 | |
| 24 | /** |
| 25 | * Activity for modifying a setting using the Voice Interaction API. This activity |
| 26 | * MUST only modify the setting if the intent was sent using |
| 27 | * {@link android.service.voice.VoiceInteractionSession#startVoiceActivity startVoiceActivity}. |
| 28 | */ |
| 29 | abstract public class VoiceSettingsActivity extends Activity { |
| 30 | |
| 31 | private static final String TAG = "VoiceSettingsActivity"; |
| 32 | |
| 33 | @Override |
| 34 | public void onCreate(Bundle savedInstanceState) { |
| 35 | super.onCreate(savedInstanceState); |
| 36 | |
| 37 | if (isVoiceInteraction()) { |
| 38 | // Only permit if this is a voice interaction. |
| 39 | onVoiceSettingInteraction(getIntent()); |
| 40 | } else { |
| 41 | Log.v(TAG, "Cannot modify settings without voice interaction"); |
| 42 | } |
| 43 | finish(); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Modify the setting as a voice interaction. The activity will finish |
| 48 | * after this method is called. |
| 49 | */ |
| 50 | abstract protected void onVoiceSettingInteraction(Intent intent); |
| 51 | } |