BluetoothVisibilityTimeoutFragment.java revision ca9812a8521fcc483e821fd5a88ec421de0b8f66
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
17package com.android.settings.bluetooth;
18
19import android.app.AlertDialog;
20import android.app.Dialog;
21import android.app.DialogFragment;
22import android.bluetooth.BluetoothAdapter;
23import android.content.BroadcastReceiver;
24import android.content.Context;
25import android.content.DialogInterface;
26import android.content.Intent;
27import android.content.IntentFilter;
28import android.os.Bundle;
29import android.text.Editable;
30import android.text.InputFilter;
31import android.text.TextWatcher;
32import android.util.Log;
33import android.view.LayoutInflater;
34import android.view.View;
35import android.widget.Button;
36import android.widget.EditText;
37
38import com.android.internal.app.AlertController;
39import com.android.settings.R;
40
41/**
42 * Dialog fragment for setting the discoverability timeout.
43 */
44final class BluetoothVisibilityTimeoutFragment extends DialogFragment
45        implements DialogInterface.OnClickListener {
46
47    private final BluetoothDiscoverableEnabler mDiscoverableEnabler;
48
49    public BluetoothVisibilityTimeoutFragment(BluetoothDiscoverableEnabler enabler) {
50        mDiscoverableEnabler = enabler;
51    }
52
53    @Override
54    public Dialog onCreateDialog(Bundle savedInstanceState) {
55        return new AlertDialog.Builder(getActivity())
56                .setIcon(android.R.drawable.ic_dialog_info)
57                .setTitle(R.string.bluetooth_visibility_timeout)
58                .setSingleChoiceItems(R.array.bluetooth_visibility_timeout_entries,
59                        mDiscoverableEnabler.getDiscoverableTimeoutIndex(), this)
60                .setNegativeButton(android.R.string.cancel, null)
61                .create();
62    }
63
64    public void onClick(DialogInterface dialog, int which) {
65        mDiscoverableEnabler.setDiscoverableTimeout(which);
66        dismiss();
67    }
68}
69