diff options
| author | Matadeen Mishra <matade@codeaurora.org> | 2015-10-01 17:30:16 +0530 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-10-08 05:22:46 -0700 |
| commit | bf51c8b4d63658986ff6c43befb38dfcb0ea3a2d (patch) | |
| tree | a62ede432af7a712e5d7a1cffc5fe3d1e21754f1 /src/com/android/settings/bluetooth | |
| parent | 584a7b64ad7468ae8f790d9d24cbf373dc869d38 (diff) | |
| download | packages_apps_Settings-bf51c8b4d63658986ff6c43befb38dfcb0ea3a2d.tar.gz packages_apps_Settings-bf51c8b4d63658986ff6c43befb38dfcb0ea3a2d.tar.bz2 packages_apps_Settings-bf51c8b4d63658986ff6c43befb38dfcb0ea3a2d.zip | |
Bluetooth: Add Manifest configure to fix settings crash issue.
Settings is crashed when press back key after rotating screen when
Bluetooth profile activity is opened. Add manifest configure to
enable screen orientation feature.
Settings: Change the text size of title when rotate screen
The text size of bluetooth settings' title is not changed when
rotate the screen.
According to the configuration, change the text size of title.
Change-Id: I3f08d0dd8181ffc8999ed29ac31dcc19a7dd56e9
CRs-Fixed: 917010
Diffstat (limited to 'src/com/android/settings/bluetooth')
| -rw-r--r-- | src/com/android/settings/bluetooth/BluetoothSettings.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index 2663e0777..ab5cf2696 100644 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -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; @@ -146,6 +153,59 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem } @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(); |
