- Video speed UI improvements

This commit is contained in:
Stefan Schueller 2018-12-26 16:15:34 +01:00
parent de52e1d9d5
commit a98ae31d35
3 changed files with 146 additions and 54 deletions

View File

@ -7,7 +7,7 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.mikepenz.iconics.Iconics;
import net.schueller.peertube.R; import net.schueller.peertube.R;
import net.schueller.peertube.service.VideoPlayerService; import net.schueller.peertube.service.VideoPlayerService;
@ -17,6 +17,11 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment {
private static VideoPlayerService videoPlayerService; private static VideoPlayerService videoPlayerService;
private TextView speed05Icon;
private TextView speed10Icon;
private TextView speed15Icon;
private TextView speed20Icon;
public static VideoOptionsFragment newInstance(VideoPlayerService mService) { public static VideoOptionsFragment newInstance(VideoPlayerService mService) {
videoPlayerService = mService; videoPlayerService = mService;
return new VideoOptionsFragment(); return new VideoOptionsFragment();
@ -31,21 +36,43 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment {
View view = inflater.inflate(R.layout.bottom_sheet_video_options_fragment, container, View view = inflater.inflate(R.layout.bottom_sheet_video_options_fragment, container,
false); 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 speed05 = view.findViewById(R.id.video_speed05);
TextView speed10 = view.findViewById(R.id.video_speed10); TextView speed10 = view.findViewById(R.id.video_speed10);
TextView speed15 = view.findViewById(R.id.video_speed15); TextView speed15 = view.findViewById(R.id.video_speed15);
TextView speed20 = view.findViewById(R.id.video_speed20); TextView speed20 = view.findViewById(R.id.video_speed20);
//Playback speed controls // Default
speed05.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(0.5f)); setVideoSpeed(1.0f, speed10Icon);
speed10.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(1.0f));
speed15.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(1.5f)); // Attach the listener
speed20.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(2.0f)); 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; 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();
}
} }

View File

@ -6,60 +6,122 @@
android:background="@color/videoBackgroundColor" android:background="@color/videoBackgroundColor"
android:orientation="vertical"> android:orientation="vertical">
<TextView <LinearLayout
android:id="@+id/video_speed05" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="56dp" android:orientation="horizontal">
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="16sp"
android:text="@string/video_speed_05" <TextView
android:textAllCaps="false" 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 <TextView
android:id="@+id/video_speed10" 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" </LinearLayout>
android:layout_height="56dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="16sp"
android:textAllCaps="false" <LinearLayout
android:text="@string/video_speed_10" android:layout_width="match_parent"
/> android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView <TextView
android:id="@+id/video_speed15" android:id="@+id/video_speed10_icon"
android:layout_width="wrap_content" android:layout_width="32dp"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" android:gravity="center|start"
android:gravity="center" android:textAllCaps="false"
android:textColor="#ffffff" android:textColor="#ffffff"
android:textSize="16sp" android:textSize="12sp" />
android:text="@string/video_speed_15" <TextView
android:textAllCaps="false" /> android:id="@+id/video_speed10"
<TextView android:layout_width="match_parent"
android:id="@+id/video_speed20" android:layout_height="56dp"
android:layout_width="wrap_content" android:layout_marginStart="8dp"
android:layout_height="56dp" android:layout_marginEnd="16dp"
android:layout_marginStart="16dp" android:gravity="center|start"
android:layout_marginEnd="16dp" android:text="@string/video_speed_10"
android:gravity="center" android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="16sp"
android:text="@string/video_speed_20" android:textColor="#ffffff"
android:textAllCaps="false" /> 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> </LinearLayout>

View File

@ -89,4 +89,7 @@
<string name="video_speed_15">1.5x</string> <string name="video_speed_15">1.5x</string>
<string name="video_speed_20">2x</string> <string name="video_speed_20">2x</string>
<string name="video_speed_active_icon">{faw-check}</string>
</resources> </resources>