+ context.findViewById(R.id.default_commodity_layout)
+ .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");
+ });
+
+ SwitchMaterial 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);
+
+ SwitchMaterial 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)));
+
+ SwitchMaterial showCommentsByDefault = context.findViewById(R.id.profile_show_comments);
+ model.observeShowCommentsByDefault(viewLifecycleOwner, showCommentsByDefault::setChecked);
+ showCommentsByDefault.setOnCheckedChangeListener(
+ ((buttonView, isChecked) -> model.setShowCommentsByDefault(isChecked)));
+
+ defaultCommodity = context.findViewById(R.id.default_commodity_text);
+
+ 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_label)
+ .setOnClickListener(this::chooseAPIVersion);
+ context.findViewById(R.id.api_version_text)
+ .setOnClickListener(this::chooseAPIVersion);
+
+ context.findViewById(R.id.server_version_label)
+ .setOnClickListener(v -> model.triggerVersionDetection());
+ TextView detectedServerVersion = context.findViewById(R.id.detected_server_version_text);
+ model.observeDetectedVersion(viewLifecycleOwner, ver -> {
+ if (ver == null)
+ detectedServerVersion.setText(context.getResources()
+ .getString(
+ R.string.server_version_unknown_label));
+ else if (ver.isPre_1_20_1())
+ detectedServerVersion.setText(context.getResources()
+ .getString(
+ R.string.detected_server_pre_1_20_1));
+ else
+ detectedServerVersion.setText(ver.toString());
+ });
+ detectedServerVersion.setOnClickListener(v -> model.triggerVersionDetection());
+ final View detectButton = context.findViewById(R.id.server_version_detect_button);
+ detectButton.setOnClickListener(v -> model.triggerVersionDetection());
+ model.observeDetectingHledgerVersion(viewLifecycleOwner, running -> {
+ detectButton.setVisibility(running ? View.VISIBLE : View.INVISIBLE);
+ });
+
+ authParams = context.findViewById(R.id.auth_params);
+
+ useAuthentication = context.findViewById(R.id.enable_http_auth);