mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 15:23:00 +00:00 
			
		
		
		
	Merge pull request #3043 from Stypox/unhook-save-restore
Save and restore whether pitch and tempo are unhooked or not
This commit is contained in:
		| @@ -7,6 +7,8 @@ import androidx.annotation.NonNull; | |||||||
| import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||||
| import androidx.fragment.app.DialogFragment; | import androidx.fragment.app.DialogFragment; | ||||||
| import androidx.appcompat.app.AlertDialog; | import androidx.appcompat.app.AlertDialog; | ||||||
|  |  | ||||||
|  | import android.preference.PreferenceManager; | ||||||
| import android.util.Log; | import android.util.Log; | ||||||
| import android.view.View; | import android.view.View; | ||||||
| import android.widget.CheckBox; | import android.widget.CheckBox; | ||||||
| @@ -219,13 +221,23 @@ public class PlaybackParameterDialog extends DialogFragment { | |||||||
|     private void setupHookingControl(@NonNull View rootView) { |     private void setupHookingControl(@NonNull View rootView) { | ||||||
|         unhookingCheckbox = rootView.findViewById(R.id.unhookCheckbox); |         unhookingCheckbox = rootView.findViewById(R.id.unhookCheckbox); | ||||||
|         if (unhookingCheckbox != null) { |         if (unhookingCheckbox != null) { | ||||||
|             unhookingCheckbox.setChecked(pitch != tempo); |             // restore whether pitch and tempo are unhooked or not | ||||||
|  |             unhookingCheckbox.setChecked(PreferenceManager.getDefaultSharedPreferences(getContext()) | ||||||
|  |                     .getBoolean(getString(R.string.playback_unhook_key), true)); | ||||||
|  |  | ||||||
|             unhookingCheckbox.setOnCheckedChangeListener((compoundButton, isChecked) -> { |             unhookingCheckbox.setOnCheckedChangeListener((compoundButton, isChecked) -> { | ||||||
|                 if (isChecked) return; |                 // save whether pitch and tempo are unhooked or not | ||||||
|                 // When unchecked, slide back to the minimum of current tempo or pitch |                 PreferenceManager.getDefaultSharedPreferences(getContext()) | ||||||
|  |                         .edit() | ||||||
|  |                         .putBoolean(getString(R.string.playback_unhook_key), isChecked) | ||||||
|  |                         .apply(); | ||||||
|  |  | ||||||
|  |                 if (!isChecked) { | ||||||
|  |                     // when unchecked, slide back to the minimum of current tempo or pitch | ||||||
|                     final double minimum = Math.min(getCurrentPitch(), getCurrentTempo()); |                     final double minimum = Math.min(getCurrentPitch(), getCurrentTempo()); | ||||||
|                     setSliders(minimum); |                     setSliders(minimum); | ||||||
|                     setCurrentPlaybackParameters(); |                     setCurrentPlaybackParameters(); | ||||||
|  |                 } | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -175,6 +175,7 @@ | |||||||
|     <string name="main_page_content_key" translatable="false">main_page_content</string> |     <string name="main_page_content_key" translatable="false">main_page_content</string> | ||||||
|     <string name="enable_playback_resume_key" translatable="false">enable_playback_resume</string> |     <string name="enable_playback_resume_key" translatable="false">enable_playback_resume</string> | ||||||
|     <string name="enable_playback_state_lists_key" translatable="false">enable_playback_state_lists</string> |     <string name="enable_playback_state_lists_key" translatable="false">enable_playback_state_lists</string> | ||||||
|  |     <string name="playback_unhook_key" translatable="false">playback_unhook_key</string> | ||||||
|  |  | ||||||
|     <string name="app_language_key" translatable="false">app_language_key</string> |     <string name="app_language_key" translatable="false">app_language_key</string> | ||||||
|     <string name="enable_lock_screen_video_thumbnail_key" translatable="false">enable_lock_screen_video_thumbnail</string> |     <string name="enable_lock_screen_video_thumbnail_key" translatable="false">enable_lock_screen_video_thumbnail</string> | ||||||
|   | |||||||
| @@ -492,7 +492,7 @@ | |||||||
|     <string name="playback_speed_control">Playback Speed Controls</string> |     <string name="playback_speed_control">Playback Speed Controls</string> | ||||||
|     <string name="playback_tempo">Tempo</string> |     <string name="playback_tempo">Tempo</string> | ||||||
|     <string name="playback_pitch">Pitch</string> |     <string name="playback_pitch">Pitch</string> | ||||||
|     <string name="unhook_checkbox">Unlink (may cause distortion)</string> |     <string name="unhook_checkbox">Unhook (may cause distortion)</string> | ||||||
|     <string name="skip_silence_checkbox">Fast-forward during silence</string> |     <string name="skip_silence_checkbox">Fast-forward during silence</string> | ||||||
|     <string name="playback_step">Step</string> |     <string name="playback_step">Step</string> | ||||||
|     <string name="playback_reset">Reset</string> |     <string name="playback_reset">Reset</string> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tobias Groza
					Tobias Groza