-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10122 from TeamNewPipe/fix/media-tunneling
Disable media tunneling by default on known unsupported devices
- Loading branch information
Showing
8 changed files
with
252 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/src/main/java/org/schabi/newpipe/settings/ExoPlayerSettingsFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,45 @@ | ||
package org.schabi.newpipe.settings; | ||
|
||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
|
||
import androidx.annotation.Nullable; | ||
import androidx.preference.Preference; | ||
import androidx.preference.PreferenceManager; | ||
import androidx.preference.SwitchPreferenceCompat; | ||
|
||
import org.schabi.newpipe.R; | ||
|
||
public class ExoPlayerSettingsFragment extends BasePreferenceFragment { | ||
|
||
@Override | ||
public void onCreatePreferences(@Nullable final Bundle savedInstanceState, | ||
@Nullable final String rootKey) { | ||
addPreferencesFromResourceRegistry(); | ||
|
||
final String disabledMediaTunnelingAutomaticallyKey = | ||
getString(R.string.disabled_media_tunneling_automatically_key); | ||
final SwitchPreferenceCompat disableMediaTunnelingPref = | ||
(SwitchPreferenceCompat) requirePreference(R.string.disable_media_tunneling_key); | ||
final SharedPreferences prefs = PreferenceManager | ||
.getDefaultSharedPreferences(requireContext()); | ||
final boolean mediaTunnelingAutomaticallyDisabled = | ||
prefs.getInt(disabledMediaTunnelingAutomaticallyKey, -1) == 1; | ||
final String summaryText = getString(R.string.disable_media_tunneling_summary); | ||
disableMediaTunnelingPref.setSummary(mediaTunnelingAutomaticallyDisabled | ||
? summaryText + " " + getString(R.string.disable_media_tunneling_automatic_info) | ||
: summaryText); | ||
|
||
disableMediaTunnelingPref.setOnPreferenceChangeListener((Preference p, Object enabled) -> { | ||
if (Boolean.FALSE.equals(enabled)) { | ||
PreferenceManager.getDefaultSharedPreferences(requireContext()) | ||
.edit() | ||
.putInt(disabledMediaTunnelingAutomaticallyKey, 0) | ||
.apply(); | ||
// the info text might have been shown before | ||
p.setSummary(R.string.disable_media_tunneling_summary); | ||
} | ||
return true; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.