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

Commit 303c3300 authored by Fan Zhang's avatar Fan Zhang Committed by android-build-merger
Browse files

Merge "UI refresh on bluetooth list page" into oc-dr1-dev

am: c0ca0846

Change-Id: I92846eec6bcbb67862b8ad1cf6447623a2dc3ab0
parents d1b51162 c0ca0846
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -14,20 +14,20 @@
     limitations under the License.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingStart="20dp"
    android:paddingEnd="20dp"
    android:paddingTop="16dp"
    android:paddingBottom="12dp"
    >
    android:paddingBottom="12dp">

    <EditText
        android:id="@+id/edittext"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textCapSentences"
        android:maxLength="50"
        android:singleLine="true"
    />
        android:singleLine="true" />
</LinearLayout>
+15 −9
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

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

    <Preference
@@ -26,11 +25,18 @@
        android:key="paired_devices"
        android:title="@string/bluetooth_paired_device_title" />

    <com.android.settings.DividerPreference
    <PreferenceCategory>

        <Preference
            android:key="bt_rename_device"
            android:title="@string/bluetooth_device_name"
            android:summary="@string/summary_placeholder" />

        <Preference
            android:key="bt_received_files"
        android:title="@string/bluetooth_show_received_files"
        settings:allowDividerAbove="true"
        settings:allowDividerBelow="true"/>
            android:title="@string/bluetooth_show_received_files" />

    </PreferenceCategory>

    <com.android.settingslib.widget.FooterPreference />

+10 −23
Original line number Diff line number Diff line
@@ -16,12 +16,12 @@

package com.android.settings.bluetooth;

import android.app.Fragment;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.Spannable;
@@ -30,7 +30,6 @@ import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
@@ -48,15 +47,15 @@ public class BluetoothDeviceNamePreferenceController extends PreferenceControlle
    private static final String TAG = "BluetoothNamePrefCtrl";

    public static final String KEY_DEVICE_NAME = "device_name";
    private int mAccentColor;
    private Fragment mFragment;

    private final int mAccentColor;

    private LocalBluetoothManager mLocalManager;
    private LocalBluetoothAdapter mLocalAdapter;
    private Preference mPreference;

    public BluetoothDeviceNamePreferenceController(Context context, Fragment fragment,
            Lifecycle lifecycle) {
        this(context, fragment, (LocalBluetoothAdapter) null);
    public BluetoothDeviceNamePreferenceController(Context context, Lifecycle lifecycle) {
        this(context, (LocalBluetoothAdapter) null);

        mLocalManager = Utils.getLocalBtManager(context);
        if (mLocalManager == null) {
@@ -68,17 +67,16 @@ public class BluetoothDeviceNamePreferenceController extends PreferenceControlle
    }

    @VisibleForTesting
    BluetoothDeviceNamePreferenceController(Context context, Fragment fragment,
            LocalBluetoothAdapter localAdapter) {
    BluetoothDeviceNamePreferenceController(Context context, LocalBluetoothAdapter localAdapter) {
        super(context);
        mAccentColor = com.android.settingslib.Utils.getColorAccent(context);
        mFragment = fragment;
        mLocalAdapter = localAdapter;
    }

    @Override
    public void displayPreference(PreferenceScreen screen) {
        mPreference = screen.findPreference(KEY_DEVICE_NAME);
        super.displayPreference(screen);
    }

    @Override
@@ -107,17 +105,6 @@ public class BluetoothDeviceNamePreferenceController extends PreferenceControlle
        updateDeviceName(preference, mLocalAdapter.getName());
    }

    @Override
    public boolean handlePreferenceTreeClick(Preference preference) {
        if (KEY_DEVICE_NAME.equals(preference.getKey())) {
            LocalDeviceNameDialogFragment.newInstance()
                    .show(mFragment.getFragmentManager(), LocalDeviceNameDialogFragment.TAG);
            return true;
        }

        return false;
    }

    /**
     * Create preference to show bluetooth device name
     *
@@ -140,7 +127,7 @@ public class BluetoothDeviceNamePreferenceController extends PreferenceControlle
     * @param preference to set the summary for
     * @param deviceName bluetooth device name to show in the summary
     */
    public void updateDeviceName(final Preference preference, final String deviceName) {
    protected void updateDeviceName(final Preference preference, final String deviceName) {
        if (deviceName == null) {
            // TODO: show error message in preference subtitle
            return;
+67 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.app.Fragment;
import android.content.Context;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;

import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
import com.android.settingslib.core.lifecycle.Lifecycle;

public class BluetoothDeviceRenamePreferenceController extends
        BluetoothDeviceNamePreferenceController {

    public static final String PREF_KEY = "bt_rename_device";

    private final Fragment mFragment;

    public BluetoothDeviceRenamePreferenceController(Context context, Fragment fragment,
            Lifecycle lifecycle) {
        super(context, lifecycle);
        mFragment = fragment;
    }

    @VisibleForTesting
    BluetoothDeviceRenamePreferenceController(Context context, Fragment fragment,
            LocalBluetoothAdapter localAdapter) {
        super(context, localAdapter);
        mFragment = fragment;
    }

    @Override
    public String getPreferenceKey() {
        return PREF_KEY;
    }

    @Override
    protected void updateDeviceName(final Preference preference, final String deviceName) {
        preference.setSummary(deviceName);
    }

    @Override
    public boolean handlePreferenceTreeClick(Preference preference) {
        if (PREF_KEY.equals(preference.getKey())) {
            LocalDeviceNameDialogFragment.newInstance()
                    .show(mFragment.getFragmentManager(), LocalDeviceNameDialogFragment.TAG);
            return true;
        }

        return false;
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.res.Configuration;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -111,6 +112,9 @@ abstract class BluetoothNameDialogFragment extends InstrumentedDialogFragment
                new Utf8ByteLengthFilter(BLUETOOTH_NAME_MAX_LENGTH_BYTES)
        });
        mDeviceNameView.setText(deviceName);    // set initial value before adding listener
        if (!TextUtils.isEmpty(deviceName)) {
            mDeviceNameView.setSelection(deviceName.length());
        }
        mDeviceNameView.addTextChangedListener(this);
        mDeviceNameView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
Loading