summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authora.derendyaev <a.derendyaev@magdv.com>2018-12-19 21:57:45 +0800
committeralk3pInjection <webmaster@raspii.tech>2022-05-07 00:20:58 +0800
commit6b9de78b42a440143c87e27acf85704b24a3fd01 (patch)
treeac504988947cf3eb1e10009b61dd71bac1971c0c /packages
parent0e4ee09469f6452b576cea4e0ce8f57529d6c2d4 (diff)
SystemUI: allow devices override audio panel location
Some devices have volume buttons on left side and it not fancy if volume panel will be at right side. You can override panel location using overlay for SystemUI: <!-- Allow devices override audio panel location to the left side --> <bool name="config_audioPanelOnLeftSide">true</bool> Change-Id: If41456f71ffd18466166e7b4120ff34d9e6f5a46
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/res/layout-land/volume_dialog.xml12
-rw-r--r--packages/SystemUI/res/layout/volume_dialog.xml11
-rw-r--r--packages/SystemUI/res/values/ice_config.xml3
-rw-r--r--packages/SystemUI/res/values/ice_dimens.xml3
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java33
5 files changed, 41 insertions, 21 deletions
diff --git a/packages/SystemUI/res/layout-land/volume_dialog.xml b/packages/SystemUI/res/layout-land/volume_dialog.xml
index f1cda277f045..3ad96880e67f 100644
--- a/packages/SystemUI/res/layout-land/volume_dialog.xml
+++ b/packages/SystemUI/res/layout-land/volume_dialog.xml
@@ -20,8 +20,6 @@
android:id="@+id/volume_dialog_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:gravity="right"
- android:layout_gravity="right"
android:background="@android:color/transparent"
android:theme="@style/volume_dialog_theme">
@@ -30,9 +28,8 @@
android:id="@+id/volume_dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:gravity="right"
- android:layout_gravity="right"
- android:layout_marginRight="@dimen/volume_dialog_panel_transparent_padding_right"
+ android:paddingLeft="@dimen/volume_dialog_panel_transparent_padding_left"
+ android:paddingRight="@dimen/volume_dialog_panel_transparent_padding_right"
android:orientation="vertical"
android:clipToPadding="false"
android:clipChildren="false">
@@ -43,8 +40,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:clipChildren="false"
- android:gravity="right">
+ android:clipChildren="false">
<include layout="@layout/volume_ringer_drawer" />
@@ -150,4 +146,4 @@
android:layout_gravity="bottom | right"
android:layout_marginRight="@dimen/volume_tool_tip_right_margin"/>
-</FrameLayout> \ No newline at end of file
+</FrameLayout>
diff --git a/packages/SystemUI/res/layout/volume_dialog.xml b/packages/SystemUI/res/layout/volume_dialog.xml
index 51718d9af054..02944ec4094e 100644
--- a/packages/SystemUI/res/layout/volume_dialog.xml
+++ b/packages/SystemUI/res/layout/volume_dialog.xml
@@ -20,8 +20,6 @@
android:id="@+id/volume_dialog_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:gravity="right"
- android:layout_gravity="right"
android:clipToPadding="false"
android:theme="@style/volume_dialog_theme">
@@ -30,9 +28,8 @@
android:id="@+id/volume_dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:gravity="right"
- android:layout_gravity="right"
- android:layout_marginRight="@dimen/volume_dialog_panel_transparent_padding_right"
+ android:paddingLeft="@dimen/volume_dialog_panel_transparent_padding_left"
+ android:paddingRight="@dimen/volume_dialog_panel_transparent_padding_right"
android:orientation="vertical"
android:clipToPadding="false"
android:clipChildren="false">
@@ -73,7 +70,6 @@
<include layout="@layout/volume_dnd_icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginRight="@dimen/volume_dialog_stream_padding"
android:layout_marginTop="6dp"/>
</FrameLayout>
@@ -146,7 +142,6 @@
android:layout="@layout/volume_tool_tip_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="bottom | right"
android:layout_marginRight="@dimen/volume_tool_tip_right_margin"/>
-</FrameLayout> \ No newline at end of file
+</FrameLayout>
diff --git a/packages/SystemUI/res/values/ice_config.xml b/packages/SystemUI/res/values/ice_config.xml
index 227a568dbeca..63141cabe4f9 100644
--- a/packages/SystemUI/res/values/ice_config.xml
+++ b/packages/SystemUI/res/values/ice_config.xml
@@ -25,4 +25,7 @@
<!-- Udfps HBM provider class name -->
<string name="config_udfpsHbmProviderComponent">com.android.systemui.biometrics.DummyUdfpsHbmProvider</string>
+
+ <!-- Allow devices override audio panel location to the left side -->
+ <bool name="config_audioPanelOnLeftSide">false</bool>
</resources>
diff --git a/packages/SystemUI/res/values/ice_dimens.xml b/packages/SystemUI/res/values/ice_dimens.xml
index f81dc4ae7797..59368978decd 100644
--- a/packages/SystemUI/res/values/ice_dimens.xml
+++ b/packages/SystemUI/res/values/ice_dimens.xml
@@ -39,4 +39,7 @@
<dimen name="tri_state_up_bottom_right_radius">0.0dip</dimen>
<dimen name="tri_state_up_top_left_radius">24.0dip</dimen>
<dimen name="tri_state_up_top_right_radius">24.0dip</dimen>
+
+ <!-- Volume panel -->
+ <dimen name="volume_dialog_panel_transparent_padding_left">8dp</dimen>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
index 58f74a0d2a02..86328482c1af 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
@@ -258,6 +258,7 @@ public class VolumeDialogImpl implements VolumeDialog,
private final boolean mUseBackgroundBlur;
private Consumer<Boolean> mCrossWindowBlurEnabledListener;
private BackgroundBlurDrawable mDialogRowsViewBackground;
+ private boolean mLeftVolumeRocker;
public VolumeDialogImpl(
Context context,
@@ -290,6 +291,8 @@ public class VolumeDialogImpl implements VolumeDialog,
mContext.getResources().getInteger(R.integer.config_dialogHideAnimationDurationMs);
mUseBackgroundBlur =
mContext.getResources().getBoolean(R.bool.config_volumeDialogUseBackgroundBlur);
+ mLeftVolumeRocker =
+ mContext.getResources().getBoolean(R.bool.config_audioPanelOnLeftSide);
if (mUseBackgroundBlur) {
final int dialogRowsViewColorAboveBlur = mContext.getColor(
@@ -404,7 +407,11 @@ public class VolumeDialogImpl implements VolumeDialog,
lp.format = PixelFormat.TRANSLUCENT;
lp.setTitle(VolumeDialogImpl.class.getSimpleName());
lp.windowAnimations = -1;
- lp.gravity = mContext.getResources().getInteger(R.integer.volume_dialog_gravity);
+ if (!isAudioPanelOnLeftSide() || isLandscape()) {
+ lp.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;
+ } else {
+ lp.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
+ }
mWindow.setAttributes(lp);
mWindow.setLayout(WRAP_CONTENT, WRAP_CONTENT);
@@ -415,7 +422,8 @@ public class VolumeDialogImpl implements VolumeDialog,
mDialog.setOnShowListener(dialog -> {
mDialogView.getViewTreeObserver().addOnComputeInternalInsetsListener(this);
if (!shouldSlideInVolumeTray()) {
- mDialogView.setTranslationX(mDialogView.getWidth() / 2.0f);
+ mDialogView.setTranslationX(
+ (mDialogView.getWidth() / 2.0f) * (isAudioPanelOnLeftSide() ? -1 : 1));
}
mDialogView.setAlpha(0);
mDialogView.animate()
@@ -643,7 +651,11 @@ public class VolumeDialogImpl implements VolumeDialog,
if (D.BUG) Slog.d(TAG, "Adding row for stream " + stream);
VolumeRow row = new VolumeRow();
initRow(row, stream, iconRes, iconMuteRes, important, defaultStream);
- mDialogRowsView.addView(row.view);
+ if (!isAudioPanelOnLeftSide() || isLandscape()) {
+ mDialogRowsView.addView(row.view, 0);
+ } else {
+ mDialogRowsView.addView(row.view);
+ }
mRows.add(row);
}
@@ -653,7 +665,11 @@ public class VolumeDialogImpl implements VolumeDialog,
final VolumeRow row = mRows.get(i);
initRow(row, row.stream, row.iconRes, row.iconMuteRes, row.important,
row.defaultStream);
- mDialogRowsView.addView(row.view);
+ if (!isAudioPanelOnLeftSide() || isLandscape()) {
+ mDialogRowsView.addView(row.view, 0);
+ } else {
+ mDialogRowsView.addView(row.view);
+ }
updateVolumeRowH(row);
}
}
@@ -1339,7 +1355,10 @@ public class VolumeDialogImpl implements VolumeDialog,
hideRingerDrawer();
}, 50));
- if (!shouldSlideInVolumeTray()) animator.translationX(mDialogView.getWidth() / 2.0f);
+ if (!shouldSlideInVolumeTray()) {
+ animator.translationX(
+ (mDialogView.getWidth() / 2.0f) * (isAudioPanelOnLeftSide() ? -1 : 1));
+ }
animator.start();
checkODICaptionsTooltip(true);
mController.notifyVisible(false);
@@ -2214,6 +2233,10 @@ public class VolumeDialogImpl implements VolumeDialog,
}
}
+ private boolean isAudioPanelOnLeftSide() {
+ return mLeftVolumeRocker;
+ }
+
private static class VolumeRow {
private View view;
private TextView header;