Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
KnollFrank committed Dec 18, 2024
1 parent 4714d3e commit 894ebef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,11 @@ public void onApplyPreferenceChange(String prefId, boolean applyToAllProfiles, O
public boolean onPreferenceClick(Preference preference) {
{
final Optional<SearchablePreferenceDialog> preferenceDialog =
createPreferenceDialog(
preference,
this);
this
.createPreferenceDialog(
preference,
this)
.map(SearchablePreferenceDialogFragmentHolder::searchablePreferenceDialogFragment);
if (preferenceDialog.isPresent()) {
show(preferenceDialog.get());
return true;
Expand Down Expand Up @@ -484,15 +486,17 @@ public boolean showPreferenceFragment(final PreferenceFragmentCompat preferenceF
return Optional.empty();
}

private Optional<SearchablePreferenceDialog> createPreferenceDialog(final Preference preference,
final GeneralProfileSettingsFragment target) {
private Optional<SearchablePreferenceDialogFragmentHolder<?>> createPreferenceDialog(
final Preference preference,
final GeneralProfileSettingsFragment target) {
if (settings.PRECISE_DISTANCE_NUMBERS.getId().equals(preference.getKey())) {
return Optional.of(
DistanceDuringNavigationBottomSheet.createInstance(
preference,
target,
getSelectedAppMode(),
false));
SearchablePreferenceDialogFragmentHolder.of(
DistanceDuringNavigationBottomSheet.createInstance(
preference,
target,
getSelectedAppMode(),
false)));
}
return Optional.empty();
}
Expand All @@ -508,10 +512,11 @@ private void show(final SearchablePreferenceDialog dialog) {
public Optional<PreferenceDialogAndSearchableInfoByPreferenceDialogProvider<?>> getPreferenceDialogAndSearchableInfoByPreferenceDialogProvider(final Preference preference) {
return this
.createPreferenceDialog(preference, null)
.map(preferenceDialog ->
.map(SearchablePreferenceDialogFragmentHolder::searchablePreferenceDialogFragment)
.map(searchablePreferenceDialog ->
new PreferenceDialogAndSearchableInfoByPreferenceDialogProvider<>(
(Fragment) preferenceDialog,
_preferenceDialog -> preferenceDialog.getSearchableInfo()));
searchablePreferenceDialog,
_preferenceDialog -> searchablePreferenceDialog.getSearchableInfo()));
}

private void updateDialogControllerCallbacks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public static Iterable<Object[]> data() {
{"ResetProfilePrefsBottomSheet: description", searchQuery(R.string.reset_all_profile_settings_descr)},
{"ResetProfilePrefsBottomSheet: reset_confirmation_descr", searchQuery("Tapping Reset discards all your changes")},

{"GeneralProfileSettingsFragment", searchQuery(R.string.distance_during_navigation)}

// FK-TODO: enable development plugin for these two test cases
// {"LocationInterpolationBottomSheet: title", Either.ofLeft(R.string.location_interpolation_percent)},
// {"LocationInterpolationBottomSheet: description", Either.ofLeft(R.string.location_interpolation_percent_desc)}
Expand Down

0 comments on commit 894ebef

Please sign in to comment.