Merge pull request #10483 from osmandapp/closechangeset_default_set

change default settings for the "Close changeset" switch
This commit is contained in:
Vitaliy 2020-12-29 12:23:27 +02:00 committed by GitHub
commit 249c419931
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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);
}
} }