ims.settings
Class DeviceListPreference

java.lang.Object
  extended by android.preference.Preference
      extended by android.preference.DialogPreference
          extended by android.preference.ListPreference
              extended by ims.settings.DeviceListPreference
All Implemented Interfaces:
android.content.DialogInterface.OnClickListener, android.content.DialogInterface.OnDismissListener, android.preference.PreferenceManager.OnActivityDestroyListener, java.lang.Comparable<android.preference.Preference>

public class DeviceListPreference
extends android.preference.ListPreference

Represents the device list preference from the settings fragment, which shows the paired devices that the user can choose one to connect with the phone.

Copyright © 2014 by Daniela Blum

This file is part of GPSChildFinder.
GPSChildFinder is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses.

Author:
Daniela Blum

Nested Class Summary
 
Nested classes/interfaces inherited from class android.preference.Preference
android.preference.Preference.BaseSavedState, android.preference.Preference.OnPreferenceChangeListener, android.preference.Preference.OnPreferenceClickListener
 
Field Summary
 
Fields inherited from class android.preference.Preference
DEFAULT_ORDER
 
Constructor Summary
DeviceListPreference(android.content.Context context)
          Constructor.
DeviceListPreference(android.content.Context context, android.util.AttributeSet attrs)
          Constructor.
 
Method Summary
 void dismiss()
          Wrapper method to dismiss the dialog and remove the SettingsFragment if necessary.
 android.app.Activity getActivity()
           
 void init()
          Initializes this preference.
 void initDeviceList()
          Initializes the list of the Bluetooth Devices, which are paired with the mobile phone.
 void onPrepareDialogBuilder(android.app.AlertDialog.Builder builder)
          Prepares the dialog builder to be shown when the preference is clicked.
 void setActivity(android.app.Activity currentActivity)
           
 void setSummary()
          Setup of the summary text.
 void show()
          Wrapper method to show the dialog.
 
Methods inherited from class android.preference.ListPreference
findIndexOfValue, getEntries, getEntry, getEntryValues, getSummary, getValue, setEntries, setEntries, setEntryValues, setEntryValues, setSummary, setValue, setValueIndex
 
Methods inherited from class android.preference.DialogPreference
getDialog, getDialogIcon, getDialogLayoutResource, getDialogMessage, getDialogTitle, getNegativeButtonText, getPositiveButtonText, onActivityDestroy, onClick, onDismiss, setDialogIcon, setDialogIcon, setDialogLayoutResource, setDialogMessage, setDialogMessage, setDialogTitle, setDialogTitle, setNegativeButtonText, setNegativeButtonText, setPositiveButtonText, setPositiveButtonText
 
Methods inherited from class android.preference.Preference
compareTo, getContext, getDependency, getEditor, getExtras, getFragment, getIcon, getIntent, getKey, getLayoutResource, getOnPreferenceChangeListener, getOnPreferenceClickListener, getOrder, getPreferenceManager, getSharedPreferences, getShouldDisableView, getTitle, getTitleRes, getView, getWidgetLayoutResource, hasKey, isEnabled, isPersistent, isSelectable, notifyDependencyChange, onDependencyChanged, onParentChanged, peekExtras, restoreHierarchyState, saveHierarchyState, setDefaultValue, setDependency, setEnabled, setFragment, setIcon, setIcon, setIntent, setKey, setLayoutResource, setOnPreferenceChangeListener, setOnPreferenceClickListener, setOrder, setPersistent, setSelectable, setShouldDisableView, setSummary, setTitle, setTitle, setWidgetLayoutResource, shouldCommit, shouldDisableDependents, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DeviceListPreference

public DeviceListPreference(android.content.Context context)
Constructor.
Initializes this preference.

Parameters:
context - preference's context

DeviceListPreference

public DeviceListPreference(android.content.Context context,
                            android.util.AttributeSet attrs)
Constructor.
Initializes this preference.

Parameters:
context - preference's context
attrs - list of attributes
Method Detail

init

public void init()
Initializes this preference. The summary is set and the first initialization of the list of the paired devices is made.
As well, the OnPreferenceClickListener is set, which handles click events on the preference and more important, the OnPreferenceChangeListener is set, which calls a new BluetoothConnectThread when another device is selected.


setSummary

public void setSummary()
Setup of the summary text. If a device is successfully connected, the name is shown.


onPrepareDialogBuilder

public void onPrepareDialogBuilder(android.app.AlertDialog.Builder builder)
Prepares the dialog builder to be shown when the preference is clicked. The list of with the phone paired devices is shown and two buttons are initialized. The neutral button redirects to the settings menu of the phone to add a new Bluetooth device to the list.

Overrides:
onPrepareDialogBuilder in class android.preference.ListPreference

setActivity

public void setActivity(android.app.Activity currentActivity)
Parameters:
currentActivity - to set

getActivity

public android.app.Activity getActivity()
Returns:
currentActivity to get

initDeviceList

public void initDeviceList()
Initializes the list of the Bluetooth Devices, which are paired with the mobile phone.


show

public void show()
Wrapper method to show the dialog.


dismiss

public void dismiss()
Wrapper method to dismiss the dialog and remove the SettingsFragment if necessary.