Home | History | Annotate | Download | only in bluetooth
      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 
     17 package com.android.settings.bluetooth;
     18 
     19 import android.app.AlertDialog;
     20 import android.app.Dialog;
     21 import android.app.DialogFragment;
     22 import android.bluetooth.BluetoothAdapter;
     23 import android.content.BroadcastReceiver;
     24 import android.content.Context;
     25 import android.content.DialogInterface;
     26 import android.content.Intent;
     27 import android.content.IntentFilter;
     28 import android.os.Bundle;
     29 import android.text.Editable;
     30 import android.text.InputFilter;
     31 import android.text.TextWatcher;
     32 import android.util.Log;
     33 import android.view.LayoutInflater;
     34 import android.view.View;
     35 import android.widget.Button;
     36 import android.widget.EditText;
     37 
     38 import com.android.internal.app.AlertController;
     39 import com.android.settings.R;
     40 
     41 /**
     42  * Dialog fragment for setting the discoverability timeout.
     43  */
     44 public final class BluetoothVisibilityTimeoutFragment extends DialogFragment
     45         implements DialogInterface.OnClickListener {
     46 
     47     private final BluetoothDiscoverableEnabler mDiscoverableEnabler;
     48 
     49     public BluetoothVisibilityTimeoutFragment() {
     50         mDiscoverableEnabler = LocalBluetoothManager.getInstance(getActivity())
     51                 .getDiscoverableEnabler();
     52     }
     53 
     54     @Override
     55     public Dialog onCreateDialog(Bundle savedInstanceState) {
     56         return new AlertDialog.Builder(getActivity())
     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