+ url = context.findViewById(R.id.url);
+ hookTextChangeSyncRoutine(url, model::setUrl);
+ model.observeUrl(viewLifecycleOwner, u -> {
+ if (!Misc.equalStrings(u, url.getText()))
+ url.setText(u);
+ });
+
+ urlLayout = context.findViewById(R.id.url_layout);
+
+ defaultCommodityLayout = context.findViewById(R.id.default_commodity_layout);
+ defaultCommodityLayout.setOnClickListener(v -> {
+ CurrencySelectorFragment cpf = CurrencySelectorFragment.newInstance(
+ CurrencySelectorFragment.DEFAULT_COLUMN_COUNT, false);
+ cpf.setOnCurrencySelectedListener(model::setDefaultCommodity);
+ final AppCompatActivity activity = (AppCompatActivity) v.getContext();
+ cpf.show(activity.getSupportFragmentManager(), "currency-selector");
+ });
+
+ Switch showCommodityByDefault = context.findViewById(R.id.profile_show_commodity);
+ showCommodityByDefault.setOnCheckedChangeListener(
+ (buttonView, isChecked) -> model.setShowCommodityByDefault(isChecked));
+ model.observeShowCommodityByDefault(viewLifecycleOwner, showCommodityByDefault::setChecked);
+
+ View postingSubItems = context.findViewById(R.id.posting_sub_items);
+
+ Switch postingPermitted = context.findViewById(R.id.profile_permit_posting);
+ model.observePostingPermitted(viewLifecycleOwner, isChecked -> {
+ postingPermitted.setChecked(isChecked);
+ postingSubItems.setVisibility(isChecked ? View.VISIBLE : View.GONE);
+ });
+ 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);
+ futureDatesText = context.findViewById(R.id.future_dates_text);
+ context.findViewById(R.id.future_dates_layout)
+ .setOnClickListener(v -> {
+ MenuInflater mi = new MenuInflater(context);
+ PopupMenu menu = new PopupMenu(context, v);
+ menu.inflate(R.menu.future_dates);
+ menu.setOnMenuItemClickListener(item -> {
+ model.setFutureDates(futureDatesSettingFromMenuItemId(item.getItemId()));
+ return true;
+ });
+ menu.show();
+ });
+ model.observeFutureDates(viewLifecycleOwner,
+ v -> futureDatesText.setText(v.getText(getResources())));
+
+ apiVersionText = context.findViewById(R.id.api_version_text);
+ model.observeApiVersion(viewLifecycleOwner, apiVer -> {
+ apiVersionText.setText(apiVer.getDescription(getResources()));
+ });
+ context.findViewById(R.id.api_version_layout)
+ .setOnClickListener(v -> {
+ MenuInflater mi = new MenuInflater(context);
+ PopupMenu menu = new PopupMenu(context, v);
+ menu.inflate(R.menu.api_version);
+ menu.setOnMenuItemClickListener(item -> {
+ SendTransactionTask.API apiVer;
+ switch (item.getItemId()) {
+ case R.id.api_version_menu_html:
+ apiVer = SendTransactionTask.API.html;
+ break;
+ case R.id.api_version_menu_post_1_14:
+ apiVer = SendTransactionTask.API.post_1_14;
+ break;
+ case R.id.api_version_menu_pre_1_15:
+ apiVer = SendTransactionTask.API.pre_1_15;
+ break;
+ case R.id.api_version_menu_auto:
+ default:
+ apiVer = SendTransactionTask.API.auto;
+ }
+ model.setApiVersion(apiVer);
+ apiVersionText.setText(apiVer.getDescription(getResources()));
+ return true;
+ });
+ menu.show();
+ });
+ authParams = context.findViewById(R.id.auth_params);
+
+ useAuthentication = context.findViewById(R.id.enable_http_auth);