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

Commit d6239b92 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Add a scrubber to keyguard; layout tweaks" into klp-dev

parents 8990e28b f8895248
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13356,6 +13356,7 @@ package android.media {
    ctor public RemoteController(android.content.Context, android.os.Looper) throws java.lang.IllegalArgumentException;
    method public int clearArtworkConfiguration();
    method public android.media.RemoteController.MetadataEditor editMetadata();
    method public long getEstimatedMediaPosition();
    method public int seekTo(long);
    method public int sendMediaKeyEvent(android.view.KeyEvent);
    method public int setArtworkConfiguration(int, int);
+1 −1
Original line number Diff line number Diff line
@@ -1674,7 +1674,7 @@ public class RemoteControlClient
     * @return true during any form of playback, false if it's not playing anything while in this
     *     playback state
     */
    private static boolean playbackPositionShouldMove(int playstate) {
    static boolean playbackPositionShouldMove(int playstate) {
        switch(playstate) {
            case PLAYSTATE_STOPPED:
            case PLAYSTATE_PAUSED:
+66 −4
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.media;

import android.Manifest;
import android.app.ActivityManager;
import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException;
import android.content.Context;
@@ -30,6 +31,8 @@ import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;

@@ -59,6 +62,7 @@ public final class RemoteController
    private final RcDisplay mRcd;
    private final Context mContext;
    private final AudioManager mAudioManager;
    private final int mMaxBitmapDimension;
    private MetadataEditor mMetadataEditor;

    /**
@@ -110,6 +114,13 @@ public final class RemoteController
        mContext = context;
        mRcd = new RcDisplay();
        mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);

        if (ActivityManager.isLowRamDeviceStatic()) {
            mMaxBitmapDimension = MAX_BITMAP_DIMENSION;
        } else {
            final DisplayMetrics dm = context.getResources().getDisplayMetrics();
            mMaxBitmapDimension = Math.max(dm.widthPixels, dm.heightPixels);
        }
    }


@@ -142,7 +153,7 @@ public final class RemoteController
         * @param state one of the playback states authorized
         *     in {@link RemoteControlClient#setPlaybackState(int)}.
         * @param stateChangeTimeMs the system time at which the state change was reported,
         *     expressed in ms.
         *     expressed in ms. Based on {@link android.os.SystemClock.elapsedRealtime()}.
         * @param currentPosMs a positive value for the current media playback position expressed
         *     in ms, a negative value if the position is temporarily unknown.
         * @param speed  a value expressed as a ratio of 1x playback: 1.0f is normal playback,
@@ -200,6 +211,50 @@ public final class RemoteController
        }
    }

    /**
     * @hide
     */
    public String getRemoteControlClientPackageName() {
        return mClientPendingIntentCurrent != null ?
                mClientPendingIntentCurrent.getCreatorPackage() : null;
    }

    /**
     * Return the estimated playback position of the current media track or a negative value
     * if not available.
     *
     * <p>The value returned is estimated by the current process and may not be perfect.
     * The time returned by this method is calculated from the last state change time based
     * on the current play position at that time and the last known playback speed.
     * An application may call {@link #setSynchronizationMode(int)} to apply
     * a synchronization policy that will periodically re-sync the estimated position
     * with the RemoteControlClient.</p>
     *
     * @return the current estimated playback position in milliseconds or a negative value
     *         if not available
     *
     * @see OnClientUpdateListener#onClientPlaybackStateUpdate(int, long, long, float)
     */
    public long getEstimatedMediaPosition() {
        if (mLastPlaybackInfo != null) {
            if (!RemoteControlClient.playbackPositionShouldMove(mLastPlaybackInfo.mState)) {
                return mLastPlaybackInfo.mCurrentPosMs;
            }

            // Take the current position at the time of state change and estimate.
            final long thenPos = mLastPlaybackInfo.mCurrentPosMs;
            if (thenPos < 0) {
                return -1;
            }

            final long now = SystemClock.elapsedRealtime();
            final long then = mLastPlaybackInfo.mStateChangeTimeMs;
            final long sinceThen = now - then;
            final long scaledSinceThen = (long) (sinceThen * mLastPlaybackInfo.mSpeed);
            return thenPos + scaledSinceThen;
        }
        return -1;
    }

    /**
     * Send a simulated key event for a media button to be received by the current client.
@@ -301,8 +356,8 @@ public final class RemoteController
        synchronized (mInfoLock) {
            if (wantBitmap) {
                if ((width > 0) && (height > 0)) {
                    if (width > MAX_BITMAP_DIMENSION) { width = MAX_BITMAP_DIMENSION; }
                    if (height > MAX_BITMAP_DIMENSION) { height = MAX_BITMAP_DIMENSION; }
                    if (width > mMaxBitmapDimension) { width = mMaxBitmapDimension; }
                    if (height > mMaxBitmapDimension) { height = mMaxBitmapDimension; }
                    mArtworkWidth = width;
                    mArtworkHeight = height;
                } else {
@@ -415,7 +470,13 @@ public final class RemoteController
        protected MetadataEditor(Bundle metadata, long editableKeys) {
            mEditorMetadata = metadata;
            mEditableKeys = editableKeys;
            mEditorArtwork = null;

            mEditorArtwork = (Bitmap) metadata.getParcelable(
                    String.valueOf(MediaMetadataEditor.BITMAP_KEY_ARTWORK));
            if (mEditorArtwork != null) {
                cleanupBitmapFromBundle(MediaMetadataEditor.BITMAP_KEY_ARTWORK);
            }

            mMetadataChanged = true;
            mArtworkChanged = true;
            mApplied = false;
@@ -706,6 +767,7 @@ public final class RemoteController
                    // existing metadata, merge existing and new
                    mMetadataEditor.mEditorMetadata.putAll(metadata);
                }

                mMetadataEditor.putBitmap(MediaMetadataEditor.BITMAP_KEY_ARTWORK,
                        (Bitmap)metadata.getParcelable(
                                String.valueOf(MediaMetadataEditor.BITMAP_KEY_ARTWORK)));
+131 −32
Original line number Diff line number Diff line
@@ -22,34 +22,133 @@
    android:gravity="center_horizontal"
    android:id="@+id/keyguard_transport_control">

    <!-- Use ImageView for its cropping features; otherwise could be android:background -->
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:gravity="center">
        <ImageView
        android:id="@+id/albumart"
            android:id="@+id/badge"
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:scaleType="fitCenter" />
        <FrameLayout
            android:id="@+id/info_container"
            android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="fill"
        android:scaleType="centerCrop"
        android:adjustViewBounds="false"
        android:contentDescription="@string/keygaurd_accessibility_media_controls" />


            android:layout_height="wrap_content">
            <LinearLayout
                android:id="@+id/metadata_container"
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
        android:layout_gravity="bottom">
                android:layout_gravity="center">
                <TextView
                    android:id="@+id/title"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
            android:layout_marginTop="8dip"
                    android:layout_marginStart="16dip"
                    android:layout_marginEnd="16dip"
                    android:gravity="center_horizontal"
                    android:singleLine="true"
            android:ellipsize="end"
            android:textAppearance="?android:attr/textAppearanceMedium"
        />
                    android:ellipsize="marquee"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:fontFamily="sans-serif-light" />
                <TextView
                    android:id="@+id/artist_album"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="16dip"
                    android:layout_marginEnd="16dip"
                    android:gravity="center_horizontal"
                    android:singleLine="true"
                    android:ellipsize="marquee"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:textColor="?android:attr/textColorSecondary" />
            </LinearLayout>
            <RelativeLayout
                android:id="@+id/transient_seek"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:visibility="invisible">
                <SeekBar
                    android:id="@+id/transient_seek_bar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
                <TextView
                    android:id="@+id/transient_seek_time_elapsed"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentStart="true"
                    android:layout_below="@id/transient_seek_bar"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:textSize="12dp" />
                <TextView
                    android:id="@+id/transient_seek_time_remaining"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentEnd="true"
                    android:layout_below="@id/transient_seek_bar"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:textSize="12dp" />
            </RelativeLayout>
            <LinearLayout
                android:id="@+id/transient_rating"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:visibility="invisible">
                <RatingBar
                    android:id="@+id/transient_rating_bar_stars"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
                <LinearLayout
                    android:id="@+id/transient_rating_thumbs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">
                    <FrameLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1">
                        <ImageButton
                            android:id="@+id/btn_thumbs_up"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:src="@drawable/ic_media_previous"
                            android:background="?android:attr/selectableItemBackground"
                            android:minWidth="48dp"
                            android:minHeight="48dp"
                            android:contentDescription="@string/keyguard_accessibility_transport_thumbs_up_description"/>
                    </FrameLayout>
                    <FrameLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1">
                        <ImageButton
                            android:id="@+id/btn_thumbs_down"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:src="@drawable/ic_media_next"
                            android:background="?android:attr/selectableItemBackground"
                            android:minWidth="48dp"
                            android:minHeight="48dp"
                            android:contentDescription="@string/keyguard_accessibility_transport_thumbs_down_description"/>
                    </FrameLayout>
                </LinearLayout>
                <ToggleButton
                    android:id="@+id/transient_rating_heart"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:visibility="invisible"
                    android:minWidth="48dp"
                    android:minHeight="48dp"
                    android:contentDescription="@string/keyguard_accessibility_transport_heart_description" />
            </LinearLayout>
        </FrameLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
@@ -59,45 +158,45 @@
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1">
                <ImageView
                <ImageButton
                    android:id="@+id/btn_prev"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:src="@drawable/ic_media_previous"
                    android:clickable="true"
                    android:background="?android:attr/selectableItemBackground"
                    android:padding="10dip"
                    android:minWidth="48dp"
                    android:minHeight="48dp"
                    android:contentDescription="@string/keyguard_accessibility_transport_prev_description"/>
            </FrameLayout>
            <FrameLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1">
                <ImageView
                <ImageButton
                    android:id="@+id/btn_play"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:clickable="true"
                    android:src="@drawable/ic_media_play"
                    android:background="?android:attr/selectableItemBackground"
                    android:padding="10dip"
                    android:minWidth="48dp"
                    android:minHeight="48dp"
                    android:contentDescription="@string/keyguard_accessibility_transport_play_description"/>
            </FrameLayout>
            <FrameLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1">
                <ImageView
                <ImageButton
                    android:id="@+id/btn_next"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:clickable="true"
                    android:src="@drawable/ic_media_next"
                    android:background="?android:attr/selectableItemBackground"
                    android:padding="10dip"
                    android:minWidth="48dp"
                    android:minHeight="48dp"
                    android:contentDescription="@string/keyguard_accessibility_transport_next_description"/>
            </FrameLayout>
        </LinearLayout>
+7 −0
Original line number Diff line number Diff line
@@ -152,6 +152,13 @@
    <string name="keyguard_accessibility_transport_play_description">Play button</string>
    <!-- Shown on transport control of lockscreen. Pressing button pauses playback -->
    <string name="keyguard_accessibility_transport_stop_description">Stop button</string>
    <!-- Shown on transport control of lockscreen. Pressing button rates the track as "thumbs up." -->
    <string name="keyguard_accessibility_transport_thumbs_up_description">Thumbs up</string>
    <!-- Shown on transport control of lockscreen. Pressing button rates the track as "thumbs down." -->
    <string name="keyguard_accessibility_transport_thumbs_down_description">Thumbs down</string>
    <!-- Shown on transport control of lockscreen. Pressing button toggles the "heart" rating. -->
    <string name="keyguard_accessibility_transport_heart_description">Heart</string>


    <!-- Accessibility description for when the device prompts the user to dismiss keyguard
         in order to complete an action. This will be followed by a message about the current
Loading