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

Commit 1a01d129 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Update TV to show custom actions." into oc-dev

parents 7a4cf16c b6de872e
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -22,24 +22,24 @@

    <com.android.systemui.pip.tv.PipControlButtonView
        android:id="@+id/full_button"
        android:layout_width="100dp"
        android:layout_width="@dimen/picture_in_picture_button_width"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_fullscreen_white_24dp"
        android:text="@string/pip_fullscreen" />

    <com.android.systemui.pip.tv.PipControlButtonView
        android:id="@+id/close_button"
        android:layout_width="100dp"
        android:layout_width="@dimen/picture_in_picture_button_width"
        android:layout_height="wrap_content"
        android:layout_marginStart="-50dp"
        android:layout_marginStart="@dimen/picture_in_picture_button_start_margin"
        android:src="@drawable/ic_close_white"
        android:text="@string/pip_close" />

    <com.android.systemui.pip.tv.PipControlButtonView
        android:id="@+id/play_pause_button"
        android:layout_width="100dp"
        android:layout_width="@dimen/picture_in_picture_button_width"
        android:layout_height="wrap_content"
        android:layout_marginStart="-50dp"
        android:layout_marginStart="@dimen/picture_in_picture_button_start_margin"
        android:src="@drawable/ic_pause_white"
        android:text="@string/pip_pause"
        android:visibility="gone" />
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 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.
*/
-->
<com.android.systemui.pip.tv.PipControlButtonView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="@dimen/picture_in_picture_button_width"
    android:layout_height="wrap_content"
    android:layout_marginStart="@dimen/picture_in_picture_button_start_margin" />
+4 −0
Original line number Diff line number Diff line
@@ -24,4 +24,8 @@
    <fraction name="battery_subpixel_smoothing_right">10%</fraction>

    <dimen name="battery_margin_bottom">1px</dimen>

    <!-- The dimensions to user for picture-in-picture action buttons. -->
    <dimen name="picture_in_picture_button_width">100dp</dimen>
    <dimen name="picture_in_picture_button_start_margin">-50dp</dimen>
</resources>
+9 −7
Original line number Diff line number Diff line
@@ -427,11 +427,7 @@ public class PipMenuActivity extends Activity {
        } else {
            actionsContainer.setVisibility(View.VISIBLE);
            if (mActionsGroup != null) {
                // Hide extra views
                for (int i = mActions.size(); i < mActionsGroup.getChildCount(); i++) {
                    mActionsGroup.getChildAt(i).setVisibility(View.GONE);
                }
                // Add needed views
                // Ensure we have as many buttons as actions
                final LayoutInflater inflater = LayoutInflater.from(this);
                while (mActionsGroup.getChildCount() < mActions.size()) {
                    final ImageView actionView = (ImageView) inflater.inflate(
@@ -439,6 +435,13 @@ public class PipMenuActivity extends Activity {
                    mActionsGroup.addView(actionView);
                }

                // Update the visibility of all views
                for (int i = 0; i < mActionsGroup.getChildCount(); i++) {
                    mActionsGroup.getChildAt(i).setVisibility(i < mActions.size()
                            ? View.VISIBLE
                            : View.GONE);
                }

                // Recreate the layout
                final boolean isLandscapePip = stackBounds != null &&
                        (stackBounds.width() > stackBounds.height());
@@ -460,10 +463,9 @@ public class PipMenuActivity extends Activity {
                                Log.w(TAG, "Failed to send action", e);
                            }
                        });
                    } else {
                        actionView.setAlpha(DISABLED_ACTION_ALPHA);
                    }
                    actionView.setEnabled(action.isEnabled());
                    actionView.setAlpha(action.isEnabled() ? 1f : DISABLED_ACTION_ALPHA);

                    // Update the margin between actions
                    LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)
+24 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@@ -33,6 +34,7 @@ import com.android.systemui.R;
 * A view containing PIP controls including fullscreen, close, and media controls.
 */
public class PipControlButtonView extends RelativeLayout {

    private OnFocusChangeListener mFocusChangeListener;
    private ImageView mIconImageView;
    ImageView mButtonImageView;
@@ -121,20 +123,39 @@ public class PipControlButtonView extends RelativeLayout {
        mFocusChangeListener = listener;
    }

    /**
     * Sets the drawable for the button with the given drawable.
     */
    public void setImageDrawable(Drawable d) {
        mIconImageView.setImageDrawable(d);
    }

    /**
     * Sets the drawable for the button with the given resource id.
     */
    public void setImageResource(int resId) {
        if (resId != 0) {
            mIconImageView.setImageResource(resId);
        }
    }

    /**
     * Sets the text for description the with the given string.
     */
    public void setText(CharSequence text) {
        mButtonImageView.setContentDescription(text);
        mDescriptionTextView.setText(text);
    }

    /**
     * Sets the text for description the with the given resource id.
     */
    public void setText(int resId) {
        if (resId != 0) {
            mButtonImageView.setContentDescription(getContext().getString(resId));
            mDescriptionTextView.setText(resId);
        }
    }

    private static void cancelAnimator(Animator animator) {
        if (animator.isStarted()) {
Loading