Search in sources :

Example 1 with ConstraintLayout

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);
}
Also used : LinearLayout(android.widget.LinearLayout) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout)

Example 2 with ConstraintLayout

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;
}
Also used : ImageButton(android.widget.ImageButton) Spinner(android.widget.Spinner) LayoutInflater(android.view.LayoutInflater) LinearLayout(android.widget.LinearLayout) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout)

Example 3 with ConstraintLayout

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);
}
Also used : Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) AppCompatResources(androidx.appcompat.content.res.AppCompatResources) DecimalFormatSymbols(java.text.DecimalFormatSymbols) EmojiTextView(org.thoughtcrime.securesms.components.emoji.EmojiTextView) TransitionManager(androidx.transition.TransitionManager) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) HashMap(java.util.HashMap) Currency(java.util.Currency) DrawableCompat(androidx.core.graphics.drawable.DrawableCompat) Drawable(android.graphics.drawable.Drawable) R(org.thoughtcrime.securesms.R) FiatMoneyUtil(org.thoughtcrime.securesms.payments.FiatMoneyUtil) SafeNavigation(org.thoughtcrime.securesms.util.navigation.SafeNavigation) FormatterOptions(org.whispersystems.signalservice.api.payments.FormatterOptions) Map(java.util.Map) View(android.view.View) RecipientHasNotEnabledPaymentsDialog(org.thoughtcrime.securesms.payments.preferences.RecipientHasNotEnabledPaymentsDialog) ContextCompat(androidx.core.content.ContextCompat) ViewModelProvider(androidx.lifecycle.ViewModelProvider) NavDirections(androidx.navigation.NavDirections) MoneyView(org.thoughtcrime.securesms.payments.MoneyView) TextUtils(android.text.TextUtils) SpanUtil(org.thoughtcrime.securesms.util.SpanUtil) CommunicationActions(org.thoughtcrime.securesms.util.CommunicationActions) ConstraintSet(androidx.constraintlayout.widget.ConstraintSet) AlertDialog(android.app.AlertDialog) Objects(java.util.Objects) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout) Toolbar(androidx.appcompat.widget.Toolbar) Navigation(androidx.navigation.Navigation) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) Money(org.whispersystems.signalservice.api.payments.Money) EmojiTextView(org.thoughtcrime.securesms.components.emoji.EmojiTextView) TextView(android.widget.TextView) EmojiTextView(org.thoughtcrime.securesms.components.emoji.EmojiTextView) View(android.view.View) MoneyView(org.thoughtcrime.securesms.payments.MoneyView) TextView(android.widget.TextView) Toolbar(androidx.appcompat.widget.Toolbar) ViewModelProvider(androidx.lifecycle.ViewModelProvider) NavDirections(androidx.navigation.NavDirections)

Example 4 with ConstraintLayout

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);
}
Also used : FragmentManager(android.app.FragmentManager) RecurrencePickerDialog(com.android.calendar.recurrencepicker.RecurrencePickerDialog) Bundle(android.os.Bundle) LinearLayout(android.widget.LinearLayout) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout)

Example 5 with ConstraintLayout

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;
}
Also used : Spinner(android.widget.Spinner) ReminderEntry(com.android.calendar.CalendarEventModel.ReminderEntry) ArrayList(java.util.ArrayList) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout)

Aggregations

ConstraintLayout (androidx.constraintlayout.widget.ConstraintLayout)12 TextView (android.widget.TextView)5 View (android.view.View)4 LinearLayout (android.widget.LinearLayout)4 Bundle (android.os.Bundle)3 ImageView (android.widget.ImageView)3 Toolbar (androidx.appcompat.widget.Toolbar)3 ConstraintSet (androidx.constraintlayout.widget.ConstraintSet)3 ViewModelProvider (androidx.lifecycle.ViewModelProvider)3 AlertDialog (android.app.AlertDialog)2 Drawable (android.graphics.drawable.Drawable)2 TextUtils (android.text.TextUtils)2 LayoutInflater (android.view.LayoutInflater)2 Spinner (android.widget.Spinner)2 NonNull (androidx.annotation.NonNull)2 Nullable (androidx.annotation.Nullable)2 AppCompatResources (androidx.appcompat.content.res.AppCompatResources)2 ContextCompat (androidx.core.content.ContextCompat)2 DrawableCompat (androidx.core.graphics.drawable.DrawableCompat)2 NavDirections (androidx.navigation.NavDirections)2