mirror of https://github.com/FongMi/TV.git
parent
49921153a1
commit
c3fbc726fa
@ -1,65 +0,0 @@ |
||||
package com.fongmi.android.tv.ui.custom; |
||||
|
||||
import android.app.Activity; |
||||
import android.app.PendingIntent; |
||||
import android.app.PictureInPictureParams; |
||||
import android.app.RemoteAction; |
||||
import android.content.Intent; |
||||
import android.graphics.Rect; |
||||
import android.graphics.drawable.Icon; |
||||
import android.os.Build; |
||||
import android.util.Rational; |
||||
import android.view.View; |
||||
|
||||
import com.fongmi.android.tv.utils.Utils; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class Pip { |
||||
|
||||
public static final String ACTION_MEDIA_CONTROL = "media_control"; |
||||
public static final String EXTRA_CONTROL_TYPE = "control_type"; |
||||
|
||||
public static final int CONTROL_TYPE_PREV = 1; |
||||
public static final int CONTROL_TYPE_NEXT = 2; |
||||
public static final int CONTROL_TYPE_PLAY = 3; |
||||
public static final int CONTROL_TYPE_PAUSE = 4; |
||||
|
||||
private PictureInPictureParams.Builder builder; |
||||
|
||||
public Pip() { |
||||
if (!Utils.hasPIP()) return; |
||||
this.builder = new PictureInPictureParams.Builder(); |
||||
} |
||||
|
||||
public void update(Activity activity, View view) { |
||||
if (!Utils.hasPIP()) return; |
||||
Rect sourceRectHint = new Rect(); |
||||
view.getGlobalVisibleRect(sourceRectHint); |
||||
builder.setSourceRectHint(sourceRectHint); |
||||
activity.setPictureInPictureParams(builder.build()); |
||||
} |
||||
|
||||
public void update(Activity activity, boolean play) { |
||||
if (!Utils.hasPIP()) return; |
||||
List<RemoteAction> actions = new ArrayList<>(); |
||||
int icon = play ? com.google.android.exoplayer2.ui.R.drawable.exo_icon_pause : com.google.android.exoplayer2.ui.R.drawable.exo_icon_play; |
||||
actions.add(new RemoteAction(Icon.createWithResource(activity, com.google.android.exoplayer2.ui.R.drawable.exo_icon_previous), "", "", PendingIntent.getBroadcast(activity, CONTROL_TYPE_PREV, new Intent(ACTION_MEDIA_CONTROL).putExtra(EXTRA_CONTROL_TYPE, CONTROL_TYPE_PREV), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE))); |
||||
actions.add(new RemoteAction(Icon.createWithResource(activity, icon), "", "", PendingIntent.getBroadcast(activity, play ? CONTROL_TYPE_PAUSE : CONTROL_TYPE_PLAY, new Intent(ACTION_MEDIA_CONTROL).putExtra(EXTRA_CONTROL_TYPE, play ? CONTROL_TYPE_PAUSE : CONTROL_TYPE_PLAY), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE))); |
||||
actions.add(new RemoteAction(Icon.createWithResource(activity, com.google.android.exoplayer2.ui.R.drawable.exo_icon_next), "", "", PendingIntent.getBroadcast(activity, CONTROL_TYPE_NEXT, new Intent(ACTION_MEDIA_CONTROL).putExtra(EXTRA_CONTROL_TYPE, CONTROL_TYPE_NEXT), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE))); |
||||
activity.setPictureInPictureParams(builder.setActions(actions).build()); |
||||
} |
||||
|
||||
public void enter(Activity activity, boolean four) { |
||||
try { |
||||
if (!Utils.hasPIP() || activity.isInPictureInPictureMode()) return; |
||||
builder.setAspectRatio(new Rational(four ? 4 : 16, four ? 3 : 9)); |
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) builder.setAutoEnterEnabled(true); |
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) builder.setSeamlessResizeEnabled(true); |
||||
activity.enterPictureInPictureMode(builder.build()); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,10 @@ |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:width="24dp" |
||||
android:height="24dp" |
||||
android:tint="@color/grey_500" |
||||
android:viewportWidth="24" |
||||
android:viewportHeight="24"> |
||||
<path |
||||
android:fillColor="@android:color/white" |
||||
android:pathData="M20,6h-8l-1.41,-1.41C10.21,4.21 9.7,4 9.17,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,8c0,-1.1 -0.9,-2 -2,-2zM19,18L5,18c-0.55,0 -1,-0.45 -1,-1L4,9c0,-0.55 0.45,-1 1,-1h14c0.55,0 1,0.45 1,1v8c0,0.55 -0.45,1 -1,1z" /> |
||||
</vector> |
||||
@ -0,0 +1,55 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="?android:attr/listPreferredItemHeight" |
||||
android:background="?android:attr/selectableItemBackground" |
||||
android:gravity="center_vertical" |
||||
android:orientation="horizontal" |
||||
android:paddingStart="16dp" |
||||
android:paddingEnd="16dp"> |
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView |
||||
android:id="@+id/image" |
||||
android:layout_width="40dp" |
||||
android:layout_height="40dp" |
||||
android:layout_marginEnd="12dp" |
||||
android:scaleType="fitCenter" |
||||
app:shapeAppearanceOverlay="@style/Vod.Grid" |
||||
tools:src="@drawable/ic_img_error" /> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:gravity="center_vertical" |
||||
android:orientation="vertical"> |
||||
|
||||
<TextView |
||||
android:id="@+id/name" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:shadowColor="@color/grey_200" |
||||
android:shadowDx="1" |
||||
android:shadowDy="1" |
||||
android:shadowRadius="0.5" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
tools:text="蜘蛛人" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/remark" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:shadowColor="@color/grey_200" |
||||
android:shadowDx="1" |
||||
android:shadowDy="1" |
||||
android:shadowRadius="0.5" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="12sp" |
||||
tools:text="1080p" /> |
||||
|
||||
</LinearLayout> |
||||
</LinearLayout> |
||||
@ -0,0 +1,236 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical" |
||||
android:padding="16dp"> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:text="倍速" |
||||
android:textColor="@color/black" |
||||
android:textSize="16sp" /> |
||||
|
||||
<com.google.android.material.slider.Slider |
||||
android:id="@+id/speed" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:backgroundTint="@color/accent" |
||||
android:stepSize="0.25" |
||||
android:valueFrom="1" |
||||
android:valueTo="5" |
||||
app:haloColor="@color/blue_500" |
||||
app:thumbColor="@color/blue_500" |
||||
app:tickColor="@color/transparent" |
||||
app:trackColorActive="@color/blue_500" |
||||
app:trackColorInactive="@color/blue_50" /> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginBottom="8dp" |
||||
android:text="縮放" |
||||
android:textColor="@color/black" |
||||
android:textSize="16sp" /> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="horizontal"> |
||||
|
||||
<TextView |
||||
android:id="@+id/scale_0" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="8dp" |
||||
android:background="@drawable/selector_accent" |
||||
android:foreground="?android:attr/selectableItemBackground" |
||||
android:gravity="center" |
||||
android:tag="0" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
tools:text="預設" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/scale_1" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="8dp" |
||||
android:background="@drawable/selector_accent" |
||||
android:foreground="?android:attr/selectableItemBackground" |
||||
android:gravity="center" |
||||
android:tag="1" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
tools:text="16:9" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/scale_2" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="8dp" |
||||
android:background="@drawable/selector_accent" |
||||
android:foreground="?android:attr/selectableItemBackground" |
||||
android:gravity="center" |
||||
android:tag="2" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
tools:text="4:3" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/scale_3" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="8dp" |
||||
android:background="@drawable/selector_accent" |
||||
android:foreground="?android:attr/selectableItemBackground" |
||||
android:gravity="center" |
||||
android:tag="3" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
tools:text="填充" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/scale_4" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:background="@drawable/selector_accent" |
||||
android:foreground="?android:attr/selectableItemBackground" |
||||
android:gravity="center" |
||||
android:tag="4" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
tools:text="裁剪" /> |
||||
|
||||
</LinearLayout> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginBottom="8dp" |
||||
android:text="播放" |
||||
android:textColor="@color/black" |
||||
android:textSize="16sp" /> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="horizontal"> |
||||
|
||||
<TextView |
||||
android:id="@+id/player" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="8dp" |
||||
android:background="@drawable/selector_accent" |
||||
android:foreground="?android:attr/selectableItemBackground" |
||||
android:gravity="center" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
tools:text="EXO" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/decode" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="8dp" |
||||
android:background="@drawable/selector_accent" |
||||
android:foreground="?android:attr/selectableItemBackground" |
||||
android:gravity="center" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
tools:text="硬解" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/opening" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="8dp" |
||||
android:background="@drawable/selector_accent" |
||||
android:foreground="?android:attr/selectableItemBackground" |
||||
android:gravity="center" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
tools:text="片頭" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/ending" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="0dp" |
||||
android:background="@drawable/selector_accent" |
||||
android:foreground="?android:attr/selectableItemBackground" |
||||
android:gravity="center" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
tools:text="片尾" /> |
||||
|
||||
</LinearLayout> |
||||
|
||||
<TextView |
||||
android:id="@+id/track" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginBottom="8dp" |
||||
android:text="軌道" |
||||
android:textColor="@color/black" |
||||
android:textSize="16sp" |
||||
android:visibility="gone" |
||||
tools:visibility="visible" /> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="horizontal"> |
||||
|
||||
<TextView |
||||
android:id="@+id/text" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="8dp" |
||||
android:background="@drawable/selector_accent" |
||||
android:foreground="?android:attr/selectableItemBackground" |
||||
android:gravity="center" |
||||
android:tag="3" |
||||
android:text="@string/play_track_text" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
android:visibility="gone" |
||||
tools:visibility="visible" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/audio" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="8dp" |
||||
android:background="@drawable/selector_accent" |
||||
android:foreground="?android:attr/selectableItemBackground" |
||||
android:gravity="center" |
||||
android:tag="1" |
||||
android:text="@string/play_track_audio" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
android:visibility="gone" |
||||
tools:visibility="visible" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/video" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:background="@drawable/selector_accent" |
||||
android:foreground="?android:attr/selectableItemBackground" |
||||
android:gravity="center" |
||||
android:tag="2" |
||||
android:text="@string/play_track_video" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
android:visibility="gone" |
||||
tools:visibility="visible" /> |
||||
|
||||
</LinearLayout> |
||||
</LinearLayout> |
||||
Loading…
Reference in new issue