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

Commit 40f95d33 authored by Sergey Nikolaienkov's avatar Sergey Nikolaienkov
Browse files

Fix VolumeDialog position and appearance on TVs

Create layout-land-television/volume_dialog.xml layout file that
describes layout for VolumeDialog on TVs. (layout-television does not
work since the orientation dimension seems to have priority over form
factor dimension). The new layout file is a copy of
layout-land/volume_dialog.xml but does not contain ringer and
settings_container.
Also adding volume_dialog_gravity integer value which specifies position
of the volume dialog on the screen. The default position
(values/integer.xml) - RIGHT|CENTER_VERTICAL, TV specific position
(values-television) - BOTTOM|CENTER_HORIZONTAL.

Exempt-From-Owner-Approval: TV Branch
Change-Id: Ie73b59f0b25b6cc9f16e24cfd48d38c401647017
Bug: 146436981
Bug: 146188087
Test: make SystemUI
Test: change volume and see Volume dialog at the bottom & center of the
screen, see it does not have bell and setting icons
(cherry picked from commit 7269e9e32f7a2af5590cbe0ff8673ed8608d58e7)
parent d1789c60
Loading
Loading
Loading
Loading
+101 −0
Original line number Original line Diff line number Diff line
<!--
  ~ Copyright (C) 2020 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
  -->
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:sysui="http://schemas.android.com/apk/res-auto"
    android:id="@+id/volume_dialog_container"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent"
    android:theme="@style/qs_theme">

    <FrameLayout
        android:id="@+id/volume_dialog"
        android:minWidth="@dimen/volume_dialog_panel_width"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:background="@android:color/transparent"
        android:paddingRight="@dimen/volume_dialog_panel_transparent_padding_right"
        android:paddingTop="@dimen/volume_dialog_panel_transparent_padding"
        android:paddingBottom="@dimen/volume_dialog_panel_transparent_padding"
        android:paddingLeft="@dimen/volume_dialog_panel_transparent_padding"
        android:clipToPadding="false">

        <LinearLayout
            android:id="@+id/main"
            android:layout_width="wrap_content"
            android:minWidth="@dimen/volume_dialog_panel_width"
            android:layout_height="wrap_content"
            android:layout_marginTop="68dp"
            android:layout_gravity="right"
            android:orientation="vertical"
            android:translationZ="@dimen/volume_dialog_elevation"
            android:clipChildren="false"
            android:clipToPadding="false"
            android:background="@drawable/rounded_bg_full">

            <LinearLayout
                android:id="@+id/volume_dialog_rows"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:minWidth="@dimen/volume_dialog_panel_width"
                android:gravity="center"
                android:orientation="horizontal"
                android:paddingRight="@dimen/volume_dialog_stream_padding"
                android:paddingLeft="@dimen/volume_dialog_stream_padding">
                <!-- volume rows added and removed here! :-) -->
            </LinearLayout>

        </LinearLayout>

        <FrameLayout
            android:id="@+id/odi_captions"
            android:layout_width="@dimen/volume_dialog_caption_size"
            android:layout_height="@dimen/volume_dialog_caption_size"
            android:layout_marginRight="68dp"
            android:layout_gravity="right"
            android:clipToPadding="false"
            android:translationZ="@dimen/volume_dialog_elevation"
            android:background="@drawable/rounded_bg_full">

            <com.android.systemui.volume.CaptionsToggleImageButton
                android:id="@+id/odi_captions_icon"
                android:src="@drawable/ic_volume_odi_captions_disabled"
                style="@style/VolumeButtons"
                android:background="@drawable/rounded_ripple"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:tint="@color/caption_tint_color_selector"
                android:layout_gravity="center"
                android:soundEffectsEnabled="false"
                sysui:optedOut="false"/>

        </FrameLayout>

        <ViewStub
            android:id="@+id/odi_captions_tooltip_stub"
            android:inflatedId="@+id/odi_captions_tooltip_view"
            android:layout="@layout/volume_tool_tip_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="@dimen/volume_tool_tip_right_margin"
            android:layout_marginTop="@dimen/volume_tool_tip_top_margin"
            android:layout_gravity="right"/>

    </FrameLayout>

</FrameLayout>
 No newline at end of file
+22 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2020 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
  -->
<resources>
    <!-- The position of the volume dialog on the screen.
         See com.android.systemui.volume.VolumeDialogImpl.
         Value 81 corresponds to BOTTOM|CENTER_HORIZONTAL. -->
    <integer name="volume_dialog_gravity">81</integer>
</resources>
 No newline at end of file
+4 −0
Original line number Original line Diff line number Diff line
@@ -40,4 +40,8 @@


    <integer name="magnification_default_scale">2</integer>
    <integer name="magnification_default_scale">2</integer>


    <!-- The position of the volume dialog on the screen.
         See com.android.systemui.volume.VolumeDialogImpl.
         Value 21 corresponds to RIGHT|CENTER_VERTICAL. -->
    <integer name="volume_dialog_gravity">21</integer>
</resources>
</resources>
 No newline at end of file
+2 −3
Original line number Original line Diff line number Diff line
@@ -65,7 +65,6 @@ import android.util.Log;
import android.util.Slog;
import android.util.Slog;
import android.util.SparseBooleanArray;
import android.util.SparseBooleanArray;
import android.view.ContextThemeWrapper;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View;
import android.view.View.AccessibilityDelegate;
import android.view.View.AccessibilityDelegate;
@@ -224,7 +223,7 @@ public class VolumeDialogImpl implements VolumeDialog,
        lp.format = PixelFormat.TRANSLUCENT;
        lp.format = PixelFormat.TRANSLUCENT;
        lp.setTitle(VolumeDialogImpl.class.getSimpleName());
        lp.setTitle(VolumeDialogImpl.class.getSimpleName());
        lp.windowAnimations = -1;
        lp.windowAnimations = -1;
        lp.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;
        lp.gravity = mContext.getResources().getInteger(R.integer.volume_dialog_gravity);
        mWindow.setAttributes(lp);
        mWindow.setAttributes(lp);
        mWindow.setLayout(WRAP_CONTENT, WRAP_CONTENT);
        mWindow.setLayout(WRAP_CONTENT, WRAP_CONTENT);


@@ -825,7 +824,7 @@ public class VolumeDialogImpl implements VolumeDialog,
    }
    }


    protected void updateRingerH() {
    protected void updateRingerH() {
        if (mState != null) {
        if (mRinger != null && mState != null) {
            final StreamState ss = mState.states.get(AudioManager.STREAM_RING);
            final StreamState ss = mState.states.get(AudioManager.STREAM_RING);
            if (ss == null) {
            if (ss == null) {
                return;
                return;