- Video speed UI improvements
This commit is contained in:
parent
de52e1d9d5
commit
a98ae31d35
|
@ -7,7 +7,7 @@ import android.view.ViewGroup;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
import com.mikepenz.iconics.Iconics;
|
||||
import net.schueller.peertube.R;
|
||||
import net.schueller.peertube.service.VideoPlayerService;
|
||||
|
||||
|
@ -17,6 +17,11 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment {
|
|||
|
||||
private static VideoPlayerService videoPlayerService;
|
||||
|
||||
private TextView speed05Icon;
|
||||
private TextView speed10Icon;
|
||||
private TextView speed15Icon;
|
||||
private TextView speed20Icon;
|
||||
|
||||
public static VideoOptionsFragment newInstance(VideoPlayerService mService) {
|
||||
videoPlayerService = mService;
|
||||
return new VideoOptionsFragment();
|
||||
|
@ -31,21 +36,43 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment {
|
|||
View view = inflater.inflate(R.layout.bottom_sheet_video_options_fragment, container,
|
||||
false);
|
||||
|
||||
// get the views and attach the listener
|
||||
// Icons
|
||||
speed05Icon = view.findViewById(R.id.video_speed05_icon);
|
||||
speed10Icon = view.findViewById(R.id.video_speed10_icon);
|
||||
speed15Icon = view.findViewById(R.id.video_speed15_icon);
|
||||
speed20Icon = view.findViewById(R.id.video_speed20_icon);
|
||||
|
||||
//Playback speed buttons
|
||||
// Buttons
|
||||
TextView speed05 = view.findViewById(R.id.video_speed05);
|
||||
TextView speed10 = view.findViewById(R.id.video_speed10);
|
||||
TextView speed15 = view.findViewById(R.id.video_speed15);
|
||||
TextView speed20 = view.findViewById(R.id.video_speed20);
|
||||
|
||||
//Playback speed controls
|
||||
speed05.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(0.5f));
|
||||
speed10.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(1.0f));
|
||||
speed15.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(1.5f));
|
||||
speed20.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(2.0f));
|
||||
// Default
|
||||
setVideoSpeed(1.0f, speed10Icon);
|
||||
|
||||
// Attach the listener
|
||||
speed05.setOnClickListener(v -> setVideoSpeed(0.5f, speed05Icon));
|
||||
speed10.setOnClickListener(v -> setVideoSpeed(1.0f, speed10Icon));
|
||||
speed15.setOnClickListener(v -> setVideoSpeed(1.5f, speed15Icon));
|
||||
speed20.setOnClickListener(v -> setVideoSpeed(2.0f, speed20Icon));
|
||||
|
||||
return view;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void setVideoSpeed(Float speed, TextView icon) {
|
||||
|
||||
speed05Icon.setText("");
|
||||
speed10Icon.setText("");
|
||||
speed15Icon.setText("");
|
||||
speed20Icon.setText("");
|
||||
|
||||
videoPlayerService.setPlayBackSpeed(speed);
|
||||
|
||||
icon.setText(R.string.video_speed_active_icon);
|
||||
new Iconics.IconicsBuilder().ctx(getContext()).on(icon).build();
|
||||
}
|
||||
|
||||
}
|
|
@ -6,60 +6,122 @@
|
|||
android:background="@color/videoBackgroundColor"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/video_speed05"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="16sp"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
android:text="@string/video_speed_05"
|
||||
android:textAllCaps="false"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/video_speed05_icon"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:gravity="center|start"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/video_speed10"
|
||||
<TextView
|
||||
android:id="@+id/video_speed05"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center|start"
|
||||
android:text="@string/video_speed_05"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="16sp" />
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="16sp"
|
||||
</LinearLayout>
|
||||
|
||||
android:textAllCaps="false"
|
||||
android:text="@string/video_speed_10"
|
||||
/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/video_speed15"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="16sp"
|
||||
<TextView
|
||||
android:id="@+id/video_speed10_icon"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:gravity="center|start"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="12sp" />
|
||||
|
||||
android:text="@string/video_speed_15"
|
||||
android:textAllCaps="false" />
|
||||
<TextView
|
||||
android:id="@+id/video_speed10"
|
||||
|
||||
<TextView
|
||||
android:id="@+id/video_speed20"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="16sp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center|start"
|
||||
android:text="@string/video_speed_10"
|
||||
android:textAllCaps="false"
|
||||
|
||||
android:text="@string/video_speed_20"
|
||||
android:textAllCaps="false" />
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/video_speed15_icon"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:gravity="center|start"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/video_speed15"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center|start"
|
||||
android:text="@string/video_speed_15"
|
||||
android:textAllCaps="false"
|
||||
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/video_speed20_icon"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:gravity="center|start"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/video_speed20"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center|start"
|
||||
android:text="@string/video_speed_20"
|
||||
android:textAllCaps="false"
|
||||
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -89,4 +89,7 @@
|
|||
<string name="video_speed_15">1.5x</string>
|
||||
<string name="video_speed_20">2x</string>
|
||||
|
||||
|
||||
<string name="video_speed_active_icon">{faw-check}</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue