mirror of
				https://github.com/recloudstream/cloudstream.git
				synced 2024-08-15 01:53:11 +00:00 
			
		
		
		
	speed UI
This commit is contained in:
		
							parent
							
								
									0f6dbb160f
								
							
						
					
					
						commit
						e59b26cb0e
					
				
					 4 changed files with 75 additions and 7 deletions
				
			
		|  | @ -799,6 +799,7 @@ class PlayerFragment : Fragment() { | |||
|                 Typeface.SANS_SERIF | ||||
|             ) | ||||
|         ) | ||||
|         subs.translationY = -10.toPx.toFloat() | ||||
| 
 | ||||
|         settingsManager = PreferenceManager.getDefaultSharedPreferences(activity) | ||||
|         swipeEnabled = settingsManager.getBoolean("swipe_enabled", true) | ||||
|  | @ -1116,9 +1117,41 @@ class PlayerFragment : Fragment() { | |||
|         playback_speed_btt.setOnClickListener { | ||||
|             lateinit var dialog: AlertDialog | ||||
|             // Lmao kind bad | ||||
|             val speedsText = arrayOf("0.5x", "0.75x", "1x", "1.25x", "1.5x", "1.75x", "2x") | ||||
|             val speedsNumbers = arrayOf(0.5f, 0.75f, 1f, 1.25f, 1.5f, 1.75f, 2f) | ||||
|             val builder = AlertDialog.Builder(requireContext(), R.style.AlertDialogCustom) | ||||
|             val speedsText = listOf("0.5x", "0.75x", "1x", "1.25x", "1.5x", "1.75x", "2x") | ||||
|             val speedsNumbers = listOf(0.5f, 0.75f, 1f, 1.25f, 1.5f, 1.75f, 2f) | ||||
|             val builder = | ||||
|                 AlertDialog.Builder(requireContext(), R.style.AlertDialogCustom).setView(R.layout.player_select_speed) | ||||
| 
 | ||||
|             val speedDialog = builder.create() | ||||
|             speedDialog.show() | ||||
| 
 | ||||
|             val speedList = speedDialog.findViewById<ListView>(R.id.sort_speed)!! | ||||
|             // val applyButton = speedDialog.findViewById<MaterialButton>(R.id.pick_source_apply)!! | ||||
|             // val cancelButton = speedDialog.findViewById<MaterialButton>(R.id.pick_source_cancel)!! | ||||
| 
 | ||||
|             val arrayAdapter = ArrayAdapter<String>(view.context, R.layout.sort_bottom_single_choice) | ||||
|             arrayAdapter.addAll(speedsText) | ||||
| 
 | ||||
|             speedList.adapter = arrayAdapter | ||||
|             speedList.choiceMode = AbsListView.CHOICE_MODE_SINGLE | ||||
| 
 | ||||
|             val speedIndex = speedsNumbers.indexOf(playbackSpeed) | ||||
| 
 | ||||
|             speedList.setSelection(speedIndex) | ||||
|             speedList.setItemChecked(speedIndex, true) | ||||
| 
 | ||||
|             speedList.setOnItemClickListener { _, _, which, _ -> | ||||
|                 playbackSpeed = speedsNumbers[which] | ||||
|                 requireContext().setKey(PLAYBACK_SPEED_KEY, playbackSpeed) | ||||
|                 val param = PlaybackParameters(playbackSpeed) | ||||
|                 exoPlayer.playbackParameters = param | ||||
|                 player_speed_text.text = "Speed (${playbackSpeed}x)".replace(".0x", "x") | ||||
| 
 | ||||
|                 speedDialog.dismiss() | ||||
|                 activity?.hideSystemUI() | ||||
|             } | ||||
| 
 | ||||
|             /* | ||||
|             builder.setTitle("Pick playback speed") | ||||
|             builder.setOnDismissListener { | ||||
|                 activity?.hideSystemUI() | ||||
|  | @ -1137,8 +1170,9 @@ class PlayerFragment : Fragment() { | |||
|                 dialog.dismiss() | ||||
|                 activity?.hideSystemUI() | ||||
|             } | ||||
| 
 | ||||
|             dialog = builder.create() | ||||
|             dialog.show() | ||||
|             dialog.show()*/ | ||||
|         } | ||||
| 
 | ||||
|         sources_btt.setOnClickListener { | ||||
|  |  | |||
							
								
								
									
										33
									
								
								app/src/main/res/layout/player_select_speed.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								app/src/main/res/layout/player_select_speed.xml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,33 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <LinearLayout | ||||
|         xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|         xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|         android:orientation="vertical" | ||||
|         android:layout_width="match_parent" | ||||
|         android:background="@null" | ||||
|         android:layout_height="match_parent"> | ||||
| 
 | ||||
|     <TextView | ||||
|             android:paddingStart="?android:attr/listPreferredItemPaddingStart" | ||||
|             android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" | ||||
|             android:layout_marginTop="20dp" | ||||
|             android:layout_marginBottom="10dp" | ||||
|             android:textStyle="bold" | ||||
|             android:text="@string/player_speed" | ||||
|             android:textSize="20sp" | ||||
|             android:textColor="?attr/textColor" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_rowWeight="1" | ||||
|             android:layout_height="wrap_content"> | ||||
|     </TextView> | ||||
|     <ListView | ||||
|             android:layout_marginTop="-10dp" | ||||
|             android:paddingTop="10dp" | ||||
|             android:id="@+id/sort_speed" | ||||
|             android:background="?attr/bitDarkerGrayBackground" | ||||
|             tools:listitem="@layout/sort_bottom_single_choice" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="match_parent" | ||||
|             android:layout_rowWeight="1" | ||||
|     /> | ||||
| </LinearLayout> | ||||
|  | @ -69,4 +69,5 @@ | |||
|     <string name="play_episode_toast">Play Episode</string> | ||||
|     <string name="sort_apply">Apply</string> | ||||
|     <string name="sort_cancel">Cancel</string> | ||||
|     <string name="player_speed">Player Speed</string> | ||||
| </resources> | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue