- Activity activity = getActivity();
- if (activity != null) activity.finish();
- });
-
- profileName.requestFocus();
- }
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.profile_detail, container, false);
-
- profileName = rootView.findViewById(R.id.profile_name);
- profileNameLayout = rootView.findViewById(R.id.profile_name_layout);
- url = rootView.findViewById(R.id.url);
- urlLayout = rootView.findViewById(R.id.url_layout);
- postingPermitted = rootView.findViewById(R.id.profile_permit_posting);
- authParams = rootView.findViewById(R.id.auth_params);
- useAuthentication = rootView.findViewById(R.id.enable_http_auth);
- userName = rootView.findViewById(R.id.auth_user_name);
- userNameLayout = rootView.findViewById(R.id.auth_user_name_layout);
- password = rootView.findViewById(R.id.password);
- passwordLayout = rootView.findViewById(R.id.password_layout);
- colorSpinner = rootView.findViewById(R.id.colorSpinner);
-
- ArrayAdapter<CharSequence> adapter = ColorListAdapter
- .createFromResource(rootView.getContext(), R.array.profile_colors,
- R.layout.color_selector_item);
-// Log.d("profiles", String.format("color count: %s", adapter.getCount()));
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- colorSpinner.setAdapter(adapter);
- colorSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
-
- }
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- final int primaryColor;
- final int degrees =
- Integer.valueOf((String) (parent.getAdapter().getItem(position)));
- if (degrees < 0) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- if (getActivity() != null) primaryColor = getResources()
- .getColor(R.color.colorPrimary, getActivity().getTheme());
- else primaryColor = Colors.getPrimaryColorForHue(Colors.DEFAULT_HUE_DEG);
- }
- else {
- primaryColor = getResources().getColor(R.color.colorPrimary);
- }
- }
- else primaryColor = Colors.getPrimaryColorForHue(degrees);
-
- if (colorSpinner != null) {
- colorSpinner.setBackgroundColor(primaryColor);
-// for (int i = 0; i < colorSpinner.getChildCount(); i++) {
-// View v = colorSpinner.getChildAt(i);
-//
-// if (v instanceof TextView) {
-// ((TextView) v).setTextColor(Color.TRANSPARENT);
-// }
-// }
- }
- }
- });
+ 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);