change default settings for the "Close changeset" switch

This commit is contained in:
Skalii 2020-12-29 11:49:02 +02:00
parent e8b2d9be05
commit e43367b8c0

View file

@ -72,20 +72,13 @@ public class SendPoiBottomSheetFragment extends MenuBottomSheetDialogFragment {
String userNameOpenID = settings.USER_NAME.get(); String userNameOpenID = settings.USER_NAME.get();
String userName = isLoginOAuth(settings) ? userNameOAuth : userNameOpenID; String userName = isLoginOAuth(settings) ? userNameOAuth : userNameOpenID;
accountName.setText(userName); accountName.setText(userName);
closeChangeSet.setBackgroundResource(isNightMode ? R.drawable.layout_bg_dark : R.drawable.layout_bg);
final int paddingSmall = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small); final int paddingSmall = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
closeChangeSet.setPadding(paddingSmall, 0, paddingSmall, 0); closeChangeSet.setChecked(true);
setCloseChangeSet(isNightMode, paddingSmall);
closeChangeSet.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { closeChangeSet.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isNightMode) { setCloseChangeSet(isNightMode, paddingSmall);
closeChangeSet.setBackgroundResource(
isChecked ? R.drawable.layout_bg_dark_solid : R.drawable.layout_bg_dark);
} else {
closeChangeSet.setBackgroundResource(
isChecked ? R.drawable.layout_bg_solid : R.drawable.layout_bg);
}
closeChangeSet.setPadding(paddingSmall, 0, paddingSmall, 0);
} }
}); });
LinearLayout account = sendOsmPoiView.findViewById(R.id.account_container); LinearLayout account = sendOsmPoiView.findViewById(R.id.account_container);
@ -254,5 +247,16 @@ public class SendPoiBottomSheetFragment extends MenuBottomSheetDialogFragment {
} }
return comment; return comment;
} }
private void setCloseChangeSet(boolean isNightMode, int paddingSmall) {
if (isNightMode) {
closeChangeSet.setBackgroundResource(
closeChangeSet.isChecked() ? R.drawable.layout_bg_dark_solid : R.drawable.layout_bg_dark);
} else {
closeChangeSet.setBackgroundResource(
closeChangeSet.isChecked() ? R.drawable.layout_bg_solid : R.drawable.layout_bg);
}
closeChangeSet.setPadding(paddingSmall, 0, paddingSmall, 0);
}
} }