OSDN Git Service

Implement "show received files" preference item.
authorJake Hamby <jhamby@google.com>
Wed, 26 Jan 2011 03:56:58 +0000 (19:56 -0800)
committerJake Hamby <jhamby@google.com>
Wed, 26 Jan 2011 18:51:32 +0000 (10:51 -0800)
Add handler to send an intent to the Bluetooth OPP app to show the
list of received files to the user.

Bug: 3167219
Change-Id: I59e18559a0c35add7f1be56a5f040dae4dccc7f1

src/com/android/settings/bluetooth/BluetoothSettings.java

index 2893ce3..c1fda6b 100644 (file)
@@ -18,7 +18,10 @@ package com.android.settings.bluetooth;
 
 import android.app.Activity;
 import android.bluetooth.BluetoothDevice;
+import android.content.Intent;
 import android.preference.CheckBoxPreference;
+import android.preference.Preference;
+import android.preference.PreferenceScreen;
 import android.util.Log;
 import android.view.View;
 
@@ -36,11 +39,16 @@ public class BluetoothSettings extends DeviceListPreferenceFragment
     private static final String KEY_BT_CHECKBOX = "bt_checkbox";
     private static final String KEY_BT_DISCOVERABLE = "bt_discoverable";
     private static final String KEY_BT_NAME = "bt_name";
+    private static final String KEY_BT_SHOW_RECEIVED = "bt_show_received_files";
 
     private BluetoothEnabler mEnabler;
     private BluetoothDiscoverableEnabler mDiscoverableEnabler;
     private BluetoothNamePreference mNamePreference;
 
+    /* Private intent to show the list of received files */
+    private static final String BTOPP_ACTION_OPEN_RECEIVED_FILES =
+            "android.btopp.intent.action.OPEN_RECEIVED_FILES";
+
     void addPreferencesForActivity(Activity activity) {
         addPreferencesFromResource(R.xml.bluetooth_settings);
 
@@ -75,6 +83,18 @@ public class BluetoothSettings extends DeviceListPreferenceFragment
         mEnabler.pause();
     }
 
+    @Override
+    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
+            Preference preference) {
+        if (KEY_BT_SHOW_RECEIVED.equals(preference.getKey())) {
+            Intent intent = new Intent(BTOPP_ACTION_OPEN_RECEIVED_FILES);
+            getActivity().sendBroadcast(intent);
+            return true;
+        }
+
+        return super.onPreferenceTreeClick(preferenceScreen, preference);
+    }
+
     public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice,
             int bondState) {
         if (bondState == BluetoothDevice.BOND_BONDED) {