Skip to content

Commit

Permalink
Show disabled preference if the device is running Android < 7.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Sep 11, 2022
1 parent 1fbed27 commit 99d477b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,20 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro

updateSeekOptions();

final var popupConfig = findPreference(getString(R.string.popup_configuration_key));
if (popupConfig != null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
// PiP was introduced in Android Nougat.
popupConfig.setVisible(false);
} else if (!requireContext().getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) {
// PiP is disabled on Android Go devices, so disable the popup setting on those
// devices.
final boolean isPipUnavailable = Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|| !requireContext().getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);

// Disable PiP configuration if the device is running Android < 7.0 or Android Go.
if (isPipUnavailable) {
final ListPreference popupConfig =
findPreference(getString(R.string.popup_configuration_key));
if (popupConfig != null) {
popupConfig.setEnabled(false);
popupConfig.setSummary(getString(R.string.pip_unavailable));
// If the Android version is >= 7.0, then PiP is disabled when this point is
// reached.
popupConfig.setSummary(Build.VERSION.SDK_INT < Build.VERSION_CODES.N
? R.string.pip_unavailable : R.string.pip_disabled);
}
}
}
Expand Down Expand Up @@ -99,8 +102,7 @@ private void updateSeekOptions() {
}
}

final ListPreference durations = findPreference(
getString(R.string.seek_duration_key));
final ListPreference durations = findPreference(getString(R.string.seek_duration_key));
durations.setEntryValues(displayedDurationValues.toArray(new CharSequence[0]));
durations.setEntries(displayedDescriptionValues.toArray(new CharSequence[0]));
final int selectedDuration = Integer.parseInt(durations.getValue());
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,8 @@
<string name="popup_mode">Popup mode</string>
<string name="pip">Picture-in-picture</string>
<string name="legacy">Original</string>
<string name="pip_unavailable">Not configurable on Android Go devices</string>
<string name="pip_unavailable">Not configurable on Android versions below 7.0</string>
<string name="pip_disabled">Not configurable on Android Go devices</string>
<!-- Seekbar Preview Thumbnail-->
<string name="seekbar_preview_thumbnail_title">Seekbar thumbnail preview</string>
<string name="high_quality_larger">High quality (larger)</string>
Expand Down

0 comments on commit 99d477b

Please sign in to comment.