import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
-import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.Switch;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Objects;
-import static net.ktnx.mobileledger.utils.Colors.profileThemeId;
import static net.ktnx.mobileledger.utils.Logger.debug;
/**
* fragment (e.g. upon screen orientation changes).
*/
public ProfileDetailFragment() {
+ super(R.layout.profile_detail);
}
@Override
public void onCreateOptionsMenu(@NotNull Menu menu, @NotNull MenuInflater inflater) {
postingPermitted.setOnCheckedChangeListener(
((buttonView, isChecked) -> model.setPostingPermitted(isChecked)));
+ Switch showCommentsByDefault = context.findViewById(R.id.profile_show_comments);
+ model.observeShowCommentsByDefault(viewLifecycleOwner, isChecked -> {
+ showCommentsByDefault.setChecked(isChecked);
+ });
+ showCommentsByDefault.setOnCheckedChangeListener(
+ ((buttonView, isChecked) -> model.setShowCommentsByDefault(isChecked)));
+
defaultCommodity = context.findViewById(R.id.default_commodity_text);
futureDatesLayout = context.findViewById(R.id.future_dates_layout);
});
huePickerView.setOnClickListener(v -> {
- HueRingDialog d = new HueRingDialog(
- Objects.requireNonNull(ProfileDetailFragment.this.getContext()), profileThemeId,
+ HueRingDialog d = new HueRingDialog(ProfileDetailFragment.this.requireContext(),
+ model.initialThemeHue,
(Integer) v.getTag());
d.show();
d.setColorSelectedListener(model::setThemeId);
}
@NotNull
private ProfileDetailModel getModel() {
- return new ViewModelProvider(this).get(ProfileDetailModel.class);
+ return new ViewModelProvider(requireActivity()).get(ProfileDetailModel.class);
}
private void onSaveFabClicked() {
if (!checkValidity())
if (activity != null)
activity.finish();
}
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
-
- return inflater.inflate(R.layout.profile_detail, container, false);
- }
private boolean checkUrlValidity() {
boolean valid = true;
private void setDefaultCommodity(@NonNull @NotNull String name) {
defaultCommoditySet = true;
defaultCommodity.setText(name);
- defaultCommodity.setTypeface(defaultCommodity.getTypeface(), Typeface.BOLD);
+ defaultCommodity.setTypeface(Typeface.DEFAULT);
}
interface TextChangeSyncProc {
void onTextChanged(String text);