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

Commit b17d7c45 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Bluetooth: Add Manifest configure to fix settings crash issue."

parents e8a9d3dc bf51c8b4
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -375,6 +375,12 @@
                       android:value="com.android.settings.ApnSettings" />
        </activity>

        <activity android:name=".SubSettings$BluetoothSubSettings"
                android:taskAffinity="com.android.settings"
                android:configChanges="orientation|keyboardHidden|screenSize"
                android:parentActivityName="Settings">
        </activity>

        <activity android:name="Settings$BluetoothSettingsActivity"
                android:label="@string/bluetooth_settings_title"
                android:taskAffinity="">
+8 −0
Original line number Diff line number Diff line
@@ -210,6 +210,14 @@
    <integer name="bluetooth_name_length">32</integer>
    <dimen name="bluetooth_pairing_padding">20dp</dimen>

    <!-- Bluetooth ActionBar -->
    <dimen name="bluetooth_landscape_title_textsize">14px</dimen>
    <dimen name="bluetooth_portrait_title_textsize">20px</dimen>
    <dimen name="bluetooth_landscape_actionbar_height">46px</dimen>
    <dimen name="bluetooth_portrait_actionbar_height">56px</dimen>
    <dimen name="bluetooth_landscape_switchbar_height">46px</dimen>
    <dimen name="bluetooth_portrait_switchbar_height">56px</dimen>

    <!-- WiFi Preferences -->
    <dimen name="wifi_divider_height">1px</dimen>
    <dimen name="wifi_preference_badge_padding">8dip</dimen>
+1 −0
Original line number Diff line number Diff line
@@ -35,4 +35,5 @@ public class SubSettings extends SettingsActivity {
        Log.d("SubSettings", "Launching fragment " + fragmentName);
        return true;
    }
    public static class BluetoothSubSettings extends SubSettings { /* empty */ }
}
+7 −1
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ import com.android.settings.UserAdapter.UserDetails;
import com.android.settings.dashboard.DashboardTile;
import com.android.settings.drawable.CircleFramedDrawable;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settings.bluetooth.BluetoothSettings;

import java.io.IOException;
import java.io.InputStream;
@@ -717,7 +718,12 @@ public final class Utils {
            Bundle args, String titleResPackageName, int titleResId, CharSequence title,
            boolean isShortcut) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        if (BluetoothSettings.class.getName().equals(fragmentName)) {
            intent.setClass(context, SubSettings.BluetoothSubSettings.class);
            intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
         } else {
             intent.setClass(context, SubSettings.class);
         }
        intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, fragmentName);
        intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
        intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RES_PACKAGE_NAME,
+60 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.settings.bluetooth;

import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;

import android.app.ActionBar;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
@@ -25,6 +27,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.Preference;
@@ -34,13 +37,17 @@ import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.text.Spannable;
import android.text.style.TextAppearanceSpan;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.TextView;
import android.widget.Toolbar;

import com.android.internal.logging.MetricsLogger;
import com.android.settings.LinkifyUtils;
@@ -145,6 +152,59 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
        mBluetoothEnabler.setupSwitchBar();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Activity activity = getActivity();
        float titleTextSize;
        int actionBarHeight;
        int switchBarHeight;
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            titleTextSize = activity.getResources().getDimensionPixelSize(
                    R.dimen.bluetooth_landscape_title_textsize);
            switchBarHeight = activity.getResources().getDimensionPixelSize(
                    R.dimen.bluetooth_landscape_switchbar_height);
            actionBarHeight = activity.getResources().getDimensionPixelSize(
                    R.dimen.bluetooth_landscape_actionbar_height);
        } else {
            titleTextSize = activity.getResources().getDimensionPixelSize(
                    R.dimen.bluetooth_portrait_title_textsize);
            switchBarHeight = activity.getResources().getDimensionPixelSize(
                    R.dimen.bluetooth_portrait_switchbar_height);
            actionBarHeight = activity.getResources().getDimensionPixelSize(
                    R.dimen.bluetooth_portrait_switchbar_height);
        }
        resetBarSize(titleTextSize, actionBarHeight, switchBarHeight);
    }

    private void resetBarSize(float titleTextSize, int actionBarHeight, int switchBarHeight) {
        Activity activity = getActivity();
        DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
        int titleId = Resources.getSystem().getIdentifier("action_bar", "id", "android");
        Toolbar toolbar = (Toolbar) activity.getWindow().findViewById(titleId);
        TextView title = null;
        if (toolbar != null) {
            LayoutParams layoutParams = toolbar.getLayoutParams();
            layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                    actionBarHeight, displayMetrics);
            for (int i = 0; i < toolbar.getChildCount(); ++i) {
                if (toolbar.getChildAt(i) instanceof TextView) {
                    title = (TextView) toolbar.getChildAt(i);
                }
                Toolbar.LayoutParams childLayoutParams = (Toolbar.LayoutParams) toolbar.getChildAt(
                        i).getLayoutParams();
                childLayoutParams.gravity = Gravity.CENTER_VERTICAL;
            }
        }
        if (title != null)
            title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, titleTextSize);
        if (mSwitchBar != null) {
            LayoutParams layoutParams = mSwitchBar.getLayoutParams();
            layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                    switchBarHeight, displayMetrics);
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();