Android: Allow users to interact with switches in settings

This commit is contained in:
Charles Lombardo 2022-12-20 20:27:43 -05:00
parent ea19909fd4
commit cf8537576e
2 changed files with 9 additions and 5 deletions

View File

@ -33,6 +33,15 @@ public final class SwitchSettingViewHolder extends SettingViewHolder
mBinding.settingSwitch.setChecked(mItem.isChecked(getAdapter().getSettings()));
mBinding.settingSwitch.setEnabled(mItem.isEditable());
mBinding.settingSwitch.setOnCheckedChangeListener((buttonView, isChecked) ->
{
getAdapter().onBooleanClick(mItem, mBinding.settingSwitch.isChecked());
setStyle(mBinding.textSettingName, mItem);
});
setStyle(mBinding.textSettingName, mItem);
}
@ -46,10 +55,6 @@ public final class SwitchSettingViewHolder extends SettingViewHolder
}
mBinding.settingSwitch.toggle();
getAdapter().onBooleanClick(mItem, mBinding.settingSwitch.isChecked());
setStyle(mBinding.textSettingName, mItem);
}
@Nullable @Override

View File

@ -44,7 +44,6 @@
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="24dp"
android:clickable="false"
android:focusable="false"
android:minHeight="0dp"
android:minWidth="0dp" />