use of androidx.constraintlayout.widget.ConstraintLayout in project Etar-Calendar by Etar-Group.
the class EventInfoFragment method onClick.
@Override
public void onClick(View view) {
// This must be a click on one of the "remove reminder" buttons
ConstraintLayout reminderItem = (ConstraintLayout) view.getParent();
LinearLayout parent = (LinearLayout) reminderItem.getParent();
parent.removeView(reminderItem);
mReminderViews.remove(reminderItem);
mUserModifiedReminders = true;
EventViewUtils.updateAddReminderButton(mView, mReminderViews, mMaxReminders);
}
use of androidx.constraintlayout.widget.ConstraintLayout in project Etar-Calendar by Etar-Group.
the class EventViewUtils method addReminder.
/**
* Adds a reminder to the displayed list of reminders. The values/labels
* arrays must not change after calling here, or the spinners we created
* might index into the wrong entry. Returns true if successfully added
* reminder, false if no reminders can be added.
*
* onItemSelected allows a listener to be set for any changes to the
* spinners in the reminder. If a listener is set it will store the
* initial position of the spinner into the spinner's tag for comparison
* with any new position setting.
*/
public static boolean addReminder(Activity activity, View view, View.OnClickListener listener, ArrayList<ConstraintLayout> items, ArrayList<Integer> minuteValues, ArrayList<String> minuteLabels, ArrayList<Integer> methodValues, ArrayList<String> methodLabels, ReminderEntry newReminder, int maxReminders, OnItemSelectedListener onItemSelected) {
if (items.size() >= maxReminders) {
return false;
}
LayoutInflater inflater = activity.getLayoutInflater();
LinearLayout parent = (LinearLayout) view.findViewById(R.id.reminder_items_container);
ConstraintLayout reminderItem = (ConstraintLayout) inflater.inflate(R.layout.edit_reminder_item, null);
parent.addView(reminderItem);
ImageButton reminderRemoveButton;
reminderRemoveButton = (ImageButton) reminderItem.findViewById(R.id.reminder_remove);
reminderRemoveButton.setOnClickListener(listener);
/*
* The spinner has the default set of labels from the string resource file, but we
* want to drop in our custom set of labels because it may have additional entries.
*/
Spinner spinner = (Spinner) reminderItem.findViewById(R.id.reminder_minutes_value);
setReminderSpinnerLabels(activity, spinner, minuteLabels);
int index = findMinutesInReminderList(minuteValues, newReminder.getMinutes());
spinner.setSelection(index);
if (onItemSelected != null) {
spinner.setTag(index);
spinner.setOnItemSelectedListener(onItemSelected);
}
/*
* Configure the alert-method spinner. Methods not supported by the current Calendar
* will not be shown.
*/
spinner = (Spinner) reminderItem.findViewById(R.id.reminder_method_value);
setReminderSpinnerLabels(activity, spinner, methodLabels);
index = findMethodInReminderList(methodValues, newReminder.getMethod());
spinner.setSelection(index);
if (onItemSelected != null) {
spinner.setTag(index);
spinner.setOnItemSelectedListener(onItemSelected);
}
items.add(reminderItem);
return true;
}
use of androidx.constraintlayout.widget.ConstraintLayout in project Signal-Android by signalapp.
the class CreatePaymentFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Toolbar toolbar = view.findViewById(R.id.create_payment_fragment_toolbar);
toolbar.setNavigationOnClickListener(this::goBack);
CreatePaymentFragmentArgs arguments = CreatePaymentFragmentArgs.fromBundle(requireArguments());
CreatePaymentViewModel.Factory factory = new CreatePaymentViewModel.Factory(arguments.getPayee(), arguments.getNote());
CreatePaymentViewModel viewModel = new ViewModelProvider(Navigation.findNavController(view).getViewModelStoreOwner(R.id.payments_create), factory).get(CreatePaymentViewModel.class);
constraintLayout = view.findViewById(R.id.create_payment_fragment_amount_header);
request = view.findViewById(R.id.create_payment_fragment_request);
amount = view.findViewById(R.id.create_payment_fragment_amount);
exchange = view.findViewById(R.id.create_payment_fragment_exchange);
pay = view.findViewById(R.id.create_payment_fragment_pay);
balance = view.findViewById(R.id.create_payment_fragment_balance);
note = view.findViewById(R.id.create_payment_fragment_note);
addNote = view.findViewById(R.id.create_payment_fragment_add_note);
toggle = view.findViewById(R.id.create_payment_fragment_toggle);
TextView decimal = view.findViewById(R.id.create_payment_fragment_keyboard_decimal);
decimal.setText(String.valueOf(DecimalFormatSymbols.getInstance().getDecimalSeparator()));
View infoTapTarget = view.findViewById(R.id.create_payment_fragment_info_tap_region);
// noinspection CodeBlock2Expr
infoTapTarget.setOnClickListener(v -> {
new AlertDialog.Builder(requireContext()).setMessage(R.string.CreatePaymentFragment__conversions_are_just_estimates).setPositiveButton(android.R.string.ok, (dialog, which) -> dialog.dismiss()).setNegativeButton(R.string.LearnMoreTextView_learn_more, (dialog, which) -> {
dialog.dismiss();
CommunicationActions.openBrowserLink(requireContext(), getString(R.string.CreatePaymentFragment__learn_more__conversions));
}).show();
});
initializeInfoIcon();
note.setOnClickListener(v -> SafeNavigation.safeNavigate(Navigation.findNavController(v), R.id.action_createPaymentFragment_to_editPaymentNoteFragment));
addNote.setOnClickListener(v -> SafeNavigation.safeNavigate(Navigation.findNavController(v), R.id.action_createPaymentFragment_to_editPaymentNoteFragment));
pay.setOnClickListener(v -> {
NavDirections directions = CreatePaymentFragmentDirections.actionCreatePaymentFragmentToConfirmPaymentFragment(viewModel.getCreatePaymentDetails()).setFinishOnConfirm(arguments.getFinishOnConfirm());
SafeNavigation.safeNavigate(Navigation.findNavController(v), directions);
});
toggle.setOnClickListener(v -> viewModel.toggleMoneyInputTarget());
initializeConstraintSets();
initializeKeyboardButtons(view, viewModel);
viewModel.getInputState().observe(getViewLifecycleOwner(), inputState -> {
updateAmount(inputState);
updateExchange(inputState);
updateMoneyInputTarget(inputState.getInputTarget());
});
viewModel.getIsPaymentsSupportedByPayee().observe(getViewLifecycleOwner(), isSupported -> {
if (!isSupported)
RecipientHasNotEnabledPaymentsDialog.show(requireContext(), () -> goBack(requireView()));
});
viewModel.isValidAmount().observe(getViewLifecycleOwner(), this::updateRequestAmountButtons);
viewModel.getNote().observe(getViewLifecycleOwner(), this::updateNote);
viewModel.getSpendableBalance().observe(getViewLifecycleOwner(), this::updateBalance);
viewModel.getCanSendPayment().observe(getViewLifecycleOwner(), this::updatePayAmountButtons);
}
use of androidx.constraintlayout.widget.ConstraintLayout in project Etar-Calendar by Etar-Group.
the class EditEventView method onClick.
// This is called if the user clicks on one of the buttons: "Save",
// "Discard", or "Delete". This is also called if the user clicks
// on the "remove reminder" button.
@Override
public void onClick(View view) {
if (view == mRruleButton) {
Bundle b = new Bundle();
b.putLong(RecurrencePickerDialog.BUNDLE_START_TIME_MILLIS, mStartTime.toMillis(false));
b.putString(RecurrencePickerDialog.BUNDLE_TIME_ZONE, mStartTime.timezone);
// TODO may be more efficient to serialize and pass in EventRecurrence
b.putString(RecurrencePickerDialog.BUNDLE_RRULE, mRrule);
FragmentManager fm = mActivity.getFragmentManager();
RecurrencePickerDialog rpd = (RecurrencePickerDialog) fm.findFragmentByTag(FRAG_TAG_RECUR_PICKER);
if (rpd != null) {
rpd.dismiss();
}
rpd = new RecurrencePickerDialog();
rpd.setArguments(b);
rpd.setOnRecurrenceSetListener(EditEventView.this);
rpd.show(fm, FRAG_TAG_RECUR_PICKER);
return;
}
// This must be a click on one of the "remove reminder" buttons
ConstraintLayout reminderItem = (ConstraintLayout) view.getParent();
LinearLayout parent = (LinearLayout) reminderItem.getParent();
parent.removeView(reminderItem);
mReminderItems.remove(reminderItem);
updateRemindersVisibility(mReminderItems.size());
EventViewUtils.updateAddReminderButton(mView, mReminderItems, mModel.mCalendarMaxReminders);
}
use of androidx.constraintlayout.widget.ConstraintLayout in project Etar-Calendar by Etar-Group.
the class EventViewUtils method reminderItemsToReminders.
/**
* Extracts reminder minutes info from UI elements.
*
* @param reminderItems UI elements (layouts with spinners) that hold array indices.
* @param reminderMinuteValues Maps array index to time in minutes.
* @param reminderMethodValues Maps array index to alert method constant.
* @return Array with reminder data.
*/
public static ArrayList<ReminderEntry> reminderItemsToReminders(ArrayList<ConstraintLayout> reminderItems, ArrayList<Integer> reminderMinuteValues, ArrayList<Integer> reminderMethodValues) {
int len = reminderItems.size();
ArrayList<ReminderEntry> reminders = new ArrayList<ReminderEntry>(len);
for (int index = 0; index < len; index++) {
ConstraintLayout layout = reminderItems.get(index);
Spinner minuteSpinner = (Spinner) layout.findViewById(R.id.reminder_minutes_value);
Spinner methodSpinner = (Spinner) layout.findViewById(R.id.reminder_method_value);
int minutes = reminderMinuteValues.get(minuteSpinner.getSelectedItemPosition());
int method = reminderMethodValues.get(methodSpinner.getSelectedItemPosition());
reminders.add(ReminderEntry.valueOf(minutes, method));
}
return reminders;
}
Aggregations