Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0af0c46 authored by Wei Wang's avatar Wei Wang Committed by Android (Google) Code Review
Browse files

Merge "BLE peripheral mode (4/4): Settings change for advertising preference."

parents d45cf417 eb56b9cc
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1268,6 +1268,8 @@
            <intent-filter>
                <action android:name="android.bluetooth.adapter.action.REQUEST_DISCOVERABLE" />
                <action android:name="android.bluetooth.adapter.action.REQUEST_ENABLE" />
                <action android:name="android.bluetooth.adapter.action.START_ADVERTISING" />
                <action android:name="android.bluetooth.adapter.action.STOP_ADVERTISING" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
+46 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:paddingStart="6dip"
    android:paddingEnd="6dip"
    android:layout_width="match_parent" android:layout_height="wrap_content"
    android:scrollbars="vertical" >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView android:id="@+id/bluetooth_broadcasting_explaination"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dip"
                android:gravity="top"
                android:text="@string/bluetooth_broadcasting_explaination"
                android:textAppearance="?android:attr/textAppearanceMedium"
            />
        </LinearLayout>

    </ScrollView>

</LinearLayout>
+14 −15
Original line number Diff line number Diff line
@@ -226,13 +226,13 @@
    <!-- Used as setting title (for checkbox) on second screen after selecting Bluetooth settings -->
    <string name="bluetooth">Bluetooth</string>
    <!-- Bluetooth settings screen, summary after selecting Discoverable check box [CHAR LIMIT=50] -->
    <string name="bluetooth_is_discoverable">Visible to all nearby Bluetooth devices (<xliff:g id="discoverable_time_period">%1$s</xliff:g>)</string>
    <string name="bluetooth_is_discoverable">Accepting pairing requests (<xliff:g id="discoverable_time_period">%1$s</xliff:g>)</string>
    <!-- Bluetooth settings screen, summary when Discoverable duration is set to "forever" [CHAR LIMIT=50] -->
    <string name="bluetooth_is_discoverable_always">Visible to all nearby Bluetooth devices</string>
    <string name="bluetooth_is_discoverable_always">Accepting pairing requests</string>
    <!-- Bluetooth settings screen, summary text when not discoverable and no paired devices [CHAR LIMIT=50] -->
    <string name="bluetooth_not_visible_to_other_devices">Not visible to other Bluetooth devices</string>
    <string name="bluetooth_not_visible_to_other_devices">Not accepting pairing requests</string>
    <!-- Bluetooth settings screen, summary text when not discoverable with paired devices [CHAR LIMIT=50] -->
    <string name="bluetooth_only_visible_to_paired_devices">Only visible to paired devices</string>
    <string name="bluetooth_only_visible_to_paired_devices">Not accepting pairing requests</string>
    <!-- Bluetooth settings screen, option name to pick discoverability timeout duration (a list dialog comes up) -->
    <string name="bluetooth_visibility_timeout">Visibility timeout</string>
    <!-- Bluetooth settings screen, check box label whether or not to allow
@@ -267,6 +267,11 @@

    <!-- Bluetooth broadcasting settings, option to enable/disable broadcasting -->
    <string name="bluetooth_broadcasting">Broadcasting</string>
    <!-- Enabled state of bluetooth broadcasting -->
    <string name="bluetooth_broadcasting_state_on">On</string>
    <!-- Disabled state of bluetooth broadcasting -->
    <string name="bluetooth_broadcasting_state_off">Off</string>

    <!-- Bluetooth settings.  Dialog title to disable a single profile of a device. [CHAR LIMIT=40] -->
    <string name="bluetooth_disable_profile_title">Disable profile?</string>
    <!-- Bluetooth settings.  Message for disabling a profile of a bluetooth device. [CHAR LIMIT=NONE] -->
@@ -325,22 +330,16 @@
    <string name="bluetooth_ask_lasting_discovery" product="tablet">An app wants to make your tablet visible to other Bluetooth devices. You can change this later in Bluetooth settings.</string>
    <string name="bluetooth_ask_lasting_discovery" product="default">An app wants to make your phone visible to other Bluetooth devices. You can change this later in Bluetooth settings.</string>

    <!-- Strings for asking to the user whether to allow an app to enable bluetooth and discovery mode -->
    <string name="bluetooth_ask_enablement_and_lasting_discovery" product="tablet">An app wants to turn on Bluetooth and make your tablet visible to other devices. You can change this later in Bluetooth settings.</string>
    <string name="bluetooth_ask_enablement_and_lasting_discovery" product="default">An app wants to turn on Bluetooth and make your phone visible to other devices. You can change this later in Bluetooth settings.</string>

    <!-- Strings for asking to the user whether to allow an app to start broadcasting -->
    <string name="bluetooth_ask_start_broadcast" product="default"><xliff:g id="app_name">%1$s</xliff:g> wants to turn on Bluetooth broadcasting to communicate with other devices nearby. You can change this later in Bluetooth settings.</string>
    <!-- Strings for asking to the user whether to allow an app to enable bluetooth and start broadcasting -->
    <string name="bluetooth_ask_enablement_and_start_broadcast" product="default"><xliff:g id="app_name">%1$s</xliff:g> wants to turn on Bluetooth and Bluetooth broadcasting to communicate with otherdevices nearby. You can change this later in Bluetooth settings.</string>
    <!-- Strings for bluetooth broadcasting explanation -->
    <string name="bluetooth_broadcasting_explaination" product="default">When this feature is turned on, your phone can communicate with other devices nearby.\n\nBroadcasting uses low-power Bluetooth signals.</string>

    <!-- Strings for asking to the user whether to allow an app to enable bluetooth and discovery mode -->
    <string name="bluetooth_ask_enablement_and_discovery" product="tablet">An app wants to turn on Bluetooth and make your tablet visible to other devices for <xliff:g id="timeout">%1$d</xliff:g> seconds.</string>
    <!-- Strings for asking to the user whether to allow an app to enable bluetooth and discovery mode -->
    <string name="bluetooth_ask_enablement_and_discovery" product="default">An app wants to turn on Bluetooth and make your phone visible to other devices for <xliff:g id="timeout">%1$d</xliff:g> seconds.</string>

    <!-- Strings for asking to the user whether to allow an app to enable bluetooth and discovery mode -->
    <string name="bluetooth_ask_enablement_and_lasting_discovery" product="tablet">An app wants to turn on Bluetooth and make your tablet visible to other devices. You can change this later in Bluetooth settings.</string>
    <string name="bluetooth_ask_enablement_and_lasting_discovery" product="default">An app wants to turn on Bluetooth and make your phone visible to other devices. You can change this later in Bluetooth settings.</string>

    <!-- Strings for msg to display to user while bluetooth is turning on [CHAR LIMIT=60] -->
    <string name="bluetooth_turning_on">"Turning Bluetooth on\u2026"</string>

+34 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<PreferenceScreen
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:title="@string/bluetooth_broadcasting">

    <Preference
            android:key="rename_device"
            android:title="@string/bluetooth_rename_device" />

    <Preference
            android:key="visibility_timeout"
            android:title="@string/bluetooth_visibility_timeout"/>

    <PreferenceScreen
            android:fragment="com.android.settings.bluetooth.BluetoothAdvertisingFragment"
            android:key="broadcasting"
            android:title="@string/bluetooth_broadcasting"/>

</PreferenceScreen>
+47 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.bluetooth;

import android.content.Context;
import android.preference.PreferenceScreen;

import com.android.settings.R;

/**
 * BluetoothAdvertisingEnabler helps manager change of bluetooth advertising preferences.
 */
final class BluetoothAdvertisingEnabler {

    private final Context mContext;
    private final PreferenceScreen mBluetoothAdvertisingPreference;

    public BluetoothAdvertisingEnabler(Context context, PreferenceScreen bluetoothBroadcast) {
        mContext = context;
        mBluetoothAdvertisingPreference = bluetoothBroadcast;
    }

    public void resume() {
        boolean isBroadcastingEnable = LocalBluetoothPreferences.isAdvertisingEnabled(mContext);
        handleAdvertisingStateChange(isBroadcastingEnable);
    }

    private void handleAdvertisingStateChange(boolean isBroadcastingEnable) {
        mBluetoothAdvertisingPreference.setSummary(isBroadcastingEnable ?
                R.string.bluetooth_broadcasting_state_on :
                    R.string.bluetooth_broadcasting_state_off);
    }
}
Loading