+ FloatingActionButton fab = context.findViewById(R.id.fab);
+ fab.setOnClickListener(v -> onSaveFabClicked());
+ profileName = context.findViewById(R.id.profile_name);
+ profileNameLayout = context.findViewById(R.id.profile_name_layout);
+ url = context.findViewById(R.id.url);
+ urlLayout = context.findViewById(R.id.url_layout);
+ postingPermitted = context.findViewById(R.id.profile_permit_posting);
+ 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 -> {
+ switch (item.getItemId()) {
+ case R.id.menu_future_dates_30:
+ futureDates = MobileLedgerProfile.FutureDates.OneMonth;
+ break;
+ case R.id.menu_future_dates_60:
+ futureDates = MobileLedgerProfile.FutureDates.TwoMonths;
+ break;
+ case R.id.menu_future_dates_90:
+ futureDates = MobileLedgerProfile.FutureDates.ThreeMonths;
+ break;
+ case R.id.menu_future_dates_180:
+ futureDates = MobileLedgerProfile.FutureDates.SixMonths;
+ break;
+ case R.id.menu_future_dates_365:
+ futureDates = MobileLedgerProfile.FutureDates.OneYear;
+ break;
+ case R.id.menu_future_dates_all:
+ futureDates = MobileLedgerProfile.FutureDates.All;
+ break;
+ default:
+ futureDates = MobileLedgerProfile.FutureDates.None;
+ }
+ futureDatesText.setText(futureDates.getText(getResources()));
+ return true;
+ });
+ menu.show();
+ });
+ apiVersionText = context.findViewById(R.id.api_version_text);
+ 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 -> {
+ switch (item.getItemId()) {
+ case R.id.api_version_menu_html:
+ apiVersion = SendTransactionTask.API.html;
+ break;
+ case R.id.api_version_menu_post_1_14:
+ apiVersion = SendTransactionTask.API.post_1_14;
+ break;
+ case R.id.api_version_menu_pre_1_15:
+ apiVersion = SendTransactionTask.API.pre_1_15;
+ break;
+ case R.id.api_version_menu_auto:
+ default:
+ apiVersion = SendTransactionTask.API.auto;
+ }
+ apiVersionText.setText(apiVersion.getDescription(getResources()));
+ return true;
+ });
+ menu.show();
+ });
+ authParams = context.findViewById(R.id.auth_params);
+ useAuthentication = context.findViewById(R.id.enable_http_auth);
+ userName = context.findViewById(R.id.auth_user_name);
+ userNameLayout = context.findViewById(R.id.auth_user_name_layout);
+ password = context.findViewById(R.id.password);
+ passwordLayout = context.findViewById(R.id.password_layout);
+ huePickerView = context.findViewById(R.id.btn_pick_ring_color);
+ preferredAccountsFilter = context.findViewById(R.id.preferred_accounts_filter_filter);
+ preferredAccountsFilterLayout =
+ context.findViewById(R.id.preferred_accounts_accounts_filter_layout);
+ insecureWarningText = context.findViewById(R.id.insecure_scheme_text);
+
+ useAuthentication.setOnCheckedChangeListener((buttonView, isChecked) -> {
+ debug("profiles", isChecked ? "auth enabled " : "auth disabled");
+ authParams.setVisibility(isChecked ? View.VISIBLE : View.GONE);
+ if (isChecked)
+ userName.requestFocus();
+ checkInsecureSchemeWithAuth();
+ });
+
+ postingPermitted.setOnCheckedChangeListener(((buttonView, isChecked) -> {
+ preferredAccountsFilterLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE);
+ futureDatesLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE);
+ }));
+
+ hookClearErrorOnFocusListener(profileName, profileNameLayout);
+ hookClearErrorOnFocusListener(url, urlLayout);
+ hookClearErrorOnFocusListener(userName, userNameLayout);
+ hookClearErrorOnFocusListener(password, passwordLayout);
+
+ int profileThemeId;
+ if (mProfile != null) {
+ profileName.setText(mProfile.getName());
+ postingPermitted.setChecked(mProfile.isPostingPermitted());
+ futureDates = mProfile.getFutureDates();
+ futureDatesText.setText(futureDates.getText(getResources()));
+ apiVersion = mProfile.getApiVersion();
+ apiVersionText.setText(apiVersion.getDescription(getResources()));
+ url.setText(mProfile.getUrl());
+ useAuthentication.setChecked(mProfile.isAuthEnabled());
+ authParams.setVisibility(mProfile.isAuthEnabled() ? View.VISIBLE : View.GONE);
+ userName.setText(mProfile.isAuthEnabled() ? mProfile.getAuthUserName() : "");
+ password.setText(mProfile.isAuthEnabled() ? mProfile.getAuthPassword() : "");
+ preferredAccountsFilter.setText(mProfile.getPreferredAccountsFilter());
+ profileThemeId = mProfile.getThemeId();
+ }
+ else {
+ profileName.setText("");
+ url.setText(HTTPS_URL_START);
+ postingPermitted.setChecked(true);
+ futureDates = MobileLedgerProfile.FutureDates.None;
+ futureDatesText.setText(futureDates.getText(getResources()));
+ apiVersion = SendTransactionTask.API.auto;
+ apiVersionText.setText(apiVersion.getDescription(getResources()));
+ useAuthentication.setChecked(false);
+ authParams.setVisibility(View.GONE);
+ userName.setText("");
+ password.setText("");
+ preferredAccountsFilter.setText(null);
+ profileThemeId = -1;
+ }
+
+ checkInsecureSchemeWithAuth();
+
+ url.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+ }
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+