Search in sources :

Example 11 with CardView

use of androidx.cardview.widget.CardView in project OneSignal-Android-SDK by OneSignal.

the class Dialog method createSendOutcomeAlertDialog.

public void createSendOutcomeAlertDialog(final String content) {
    final View sendOutcomeAlertDialogView = layoutInflater.inflate(R.layout.send_outcome_alert_dialog_layout, null, false);
    final CardView sendOutcomeDialogTitleCardView = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_card_view);
    final RelativeLayout sendOutcomeDialogTitleRelativeLayout = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_relative_layout);
    final TextView sendOutcomeDialogTitleTextView = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_text_view);
    final ImageView sendOutcomeDialogTitleArrowImageView = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_arrow_image_view);
    final RecyclerView sendOutcomeDialogSelectionRecyclerView = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_recycler_view);
    final LinearLayout sendOutcomeDialogSelectionContentLinearLayout = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_content_linear_layout);
    final TextInputLayout sendOutcomeDialogNameTextInputLayout = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_name_text_input_layout);
    final EditText sendOutcomeDialogNameEditText = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_name_edit_text);
    final TextInputLayout sendOutcomeDialogValueTextInputLayout = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_value_text_input_layout);
    final EditText sendOutcomeDialogValueEditText = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_value_edit_text);
    final ProgressBar sendOutcomeDialogProgressBar = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_progress_bar);
    sendOutcomeDialogNameTextInputLayout.setHint("Name");
    sendOutcomeDialogValueTextInputLayout.setHint("Value");
    sendOutcomeDialogTitleTextView.setText(content);
    font.applyFont(sendOutcomeDialogTitleTextView, font.saralaBold);
    font.applyFont(sendOutcomeDialogNameTextInputLayout, font.saralaBold);
    font.applyFont(sendOutcomeDialogValueTextInputLayout, font.saralaBold);
    sendOutcomeDialogTitleCardView.setCardElevation(8f);
    recyclerViewBuilder.setupRecyclerView(sendOutcomeDialogSelectionRecyclerView, 3, false, true);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
    sendOutcomeDialogSelectionRecyclerView.setLayoutManager(linearLayoutManager);
    EnumSelectionRecyclerViewAdapter enumSelectionRecyclerViewAdapter = new EnumSelectionRecyclerViewAdapter(context, OutcomeEvent.values(), new EnumSelectionCallback() {

        @Override
        public void onSelection(String title) {
            int nameVisibility = View.GONE;
            int valueVisibility = View.GONE;
            OutcomeEvent outcomeEvent = OutcomeEvent.enumFromTitleString(title);
            if (outcomeEvent == null) {
                Drawable arrow = context.getResources().getDrawable(R.drawable.ic_chevron_down_white_48dp);
                sendOutcomeDialogTitleArrowImageView.setImageDrawable(arrow);
                sendOutcomeDialogTitleCardView.setCardElevation(0f);
                sendOutcomeDialogSelectionRecyclerView.setVisibility(View.GONE);
                sendOutcomeDialogSelectionContentLinearLayout.setVisibility(View.GONE);
                sendOutcomeDialogNameEditText.setVisibility(nameVisibility);
                sendOutcomeDialogValueTextInputLayout.setVisibility(valueVisibility);
                return;
            }
            switch(outcomeEvent) {
                case OUTCOME:
                case UNIQUE_OUTCOME:
                    nameVisibility = View.VISIBLE;
                    break;
                case OUTCOME_WITH_VALUE:
                    nameVisibility = View.VISIBLE;
                    valueVisibility = View.VISIBLE;
                    break;
            }
            sendOutcomeDialogTitleTextView.setText(outcomeEvent.getTitle());
            Drawable arrow = context.getResources().getDrawable(R.drawable.ic_chevron_down_white_48dp);
            sendOutcomeDialogTitleArrowImageView.setImageDrawable(arrow);
            sendOutcomeDialogTitleCardView.setCardElevation(0f);
            sendOutcomeDialogSelectionRecyclerView.setVisibility(View.GONE);
            sendOutcomeDialogSelectionContentLinearLayout.setVisibility(View.VISIBLE);
            sendOutcomeDialogNameTextInputLayout.setVisibility(nameVisibility);
            sendOutcomeDialogNameEditText.setVisibility(nameVisibility);
            sendOutcomeDialogValueTextInputLayout.setVisibility(valueVisibility);
            sendOutcomeDialogValueEditText.setVisibility(valueVisibility);
        }
    });
    sendOutcomeDialogSelectionRecyclerView.setAdapter(enumSelectionRecyclerViewAdapter);
    sendOutcomeDialogTitleRelativeLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean showMenu = sendOutcomeDialogSelectionRecyclerView.getVisibility() == View.GONE;
            Drawable arrow = context.getResources().getDrawable(showMenu ? R.drawable.ic_chevron_up_white_48dp : R.drawable.ic_chevron_down_white_48dp);
            int menuVisibility = showMenu ? View.VISIBLE : View.GONE;
            int contentVisibility = showMenu ? View.GONE : View.VISIBLE;
            float shadow = showMenu ? 8f : 0f;
            sendOutcomeDialogTitleArrowImageView.setImageDrawable(arrow);
            sendOutcomeDialogTitleCardView.setCardElevation(shadow);
            sendOutcomeDialogSelectionRecyclerView.setVisibility(menuVisibility);
            sendOutcomeDialogSelectionContentLinearLayout.setVisibility(contentVisibility);
            int nameVisibility = View.GONE;
            int valueVisibility = View.GONE;
            String selectedTitle = sendOutcomeDialogTitleTextView.getText().toString();
            OutcomeEvent outcomeEvent = OutcomeEvent.enumFromTitleString(selectedTitle);
            if (outcomeEvent == null) {
                sendOutcomeDialogSelectionContentLinearLayout.setVisibility(View.GONE);
                return;
            }
            if (!showMenu) {
                switch(outcomeEvent) {
                    case OUTCOME:
                    case UNIQUE_OUTCOME:
                        nameVisibility = View.VISIBLE;
                        break;
                    case OUTCOME_WITH_VALUE:
                        nameVisibility = View.VISIBLE;
                        valueVisibility = View.VISIBLE;
                        break;
                }
            }
            sendOutcomeDialogSelectionContentLinearLayout.setVisibility(nameVisibility);
            sendOutcomeDialogNameEditText.setVisibility(nameVisibility);
            sendOutcomeDialogValueTextInputLayout.setVisibility(valueVisibility);
            sendOutcomeDialogValueEditText.setVisibility(valueVisibility);
        }
    });
    final CustomAlertDialogBuilder sendOutcomeAlertDialog = new CustomAlertDialogBuilder(context, sendOutcomeAlertDialogView);
    sendOutcomeAlertDialog.setView(sendOutcomeAlertDialogView);
    sendOutcomeAlertDialog.setIsCancelable(true);
    sendOutcomeAlertDialog.setCanceledOnTouchOutside(false);
    sendOutcomeAlertDialog.setPositiveButton(Text.BUTTON_SEND, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, int which) {
            toggleUpdateAlertDialogAttributes(true);
            String selectedTitle = sendOutcomeDialogTitleTextView.getText().toString();
            OutcomeEvent outcomeEvent = OutcomeEvent.enumFromTitleString(selectedTitle);
            if (outcomeEvent == null) {
                toaster.makeCustomViewToast("Please select an outcome type!", ToastType.ERROR);
                toggleUpdateAlertDialogAttributes(false);
                return;
            }
            String name = sendOutcomeDialogNameEditText.getText().toString().trim();
            String value = sendOutcomeDialogValueEditText.getText().toString().trim();
            if (name.isEmpty()) {
                toaster.makeCustomViewToast("Please enter an outcome name!", ToastType.ERROR);
                toggleUpdateAlertDialogAttributes(false);
                return;
            }
            switch(outcomeEvent) {
                case OUTCOME:
                    OneSignal.sendOutcome(name, new OneSignal.OutcomeCallback() {

                        @Override
                        public void onSuccess(@Nullable OSOutcomeEvent outcomeEvent) {
                            ((Activity) context).runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    toggleUpdateAlertDialogAttributes(false);
                                    dialog.dismiss();
                                }
                            });
                        }
                    });
                    break;
                case UNIQUE_OUTCOME:
                    OneSignal.sendUniqueOutcome(name, new OneSignal.OutcomeCallback() {

                        @Override
                        public void onSuccess(@Nullable OSOutcomeEvent outcomeEvent) {
                            ((Activity) context).runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    toggleUpdateAlertDialogAttributes(false);
                                    dialog.dismiss();
                                }
                            });
                        }
                    });
                    break;
                case OUTCOME_WITH_VALUE:
                    if (value.isEmpty()) {
                        toaster.makeCustomViewToast("Please enter an outcome value!", ToastType.ERROR);
                        toggleUpdateAlertDialogAttributes(false);
                        return;
                    }
                    OneSignal.sendOutcomeWithValue(name, Float.parseFloat(value), new OneSignal.OutcomeCallback() {

                        @Override
                        public void onSuccess(@Nullable OSOutcomeEvent outcomeEvent) {
                            ((Activity) context).runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    toggleUpdateAlertDialogAttributes(false);
                                    dialog.dismiss();
                                }
                            });
                        }
                    });
                    break;
            }
            InterfaceUtil.hideKeyboardFrom(context, sendOutcomeAlertDialogView);
        }

        private void toggleUpdateAlertDialogAttributes(boolean disableAttributes) {
            int progressVisibility = disableAttributes ? View.VISIBLE : View.GONE;
            sendOutcomeDialogProgressBar.setVisibility(progressVisibility);
            int buttonVisibility = disableAttributes ? View.GONE : View.VISIBLE;
            sendOutcomeAlertDialog.getPositiveButtonElement().setVisibility(buttonVisibility);
            sendOutcomeAlertDialog.getNegativeButtonElement().setVisibility(buttonVisibility);
            sendOutcomeAlertDialog.getPositiveButtonElement().setEnabled(!disableAttributes);
            sendOutcomeAlertDialog.getNegativeButtonElement().setEnabled(!disableAttributes);
            sendOutcomeAlertDialog.setIsCancelable(!disableAttributes);
        }
    }).setNegativeButton(Text.BUTTON_CANCEL, null);
    sendOutcomeAlertDialog.show();
}
Also used : OneSignal(com.onesignal.OneSignal) DialogInterface(android.content.DialogInterface) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) OutcomeEvent(com.onesignal.sdktest.type.OutcomeEvent) OSOutcomeEvent(com.onesignal.OSOutcomeEvent) TextView(android.widget.TextView) CustomAlertDialogBuilder(com.onesignal.sdktest.ui.CustomAlertDialogBuilder) ImageView(android.widget.ImageView) TextInputLayout(com.google.android.material.textfield.TextInputLayout) ProgressBar(android.widget.ProgressBar) EditText(android.widget.EditText) OSOutcomeEvent(com.onesignal.OSOutcomeEvent) CardView(androidx.cardview.widget.CardView) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CardView(androidx.cardview.widget.CardView) TextView(android.widget.TextView) EnumSelectionCallback(com.onesignal.sdktest.callback.EnumSelectionCallback) RelativeLayout(android.widget.RelativeLayout) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayout(android.widget.LinearLayout) EnumSelectionRecyclerViewAdapter(com.onesignal.sdktest.adapter.EnumSelectionRecyclerViewAdapter)

Example 12 with CardView

use of androidx.cardview.widget.CardView in project Signal-Android by WhisperSystems.

the class CallParticipantsLayout method update.

private void update(int index, int count, @NonNull CallParticipant participant) {
    View view = getChildAt(index);
    CardView cardView = view.findViewById(R.id.group_call_participant_card_wrapper);
    CallParticipantView callParticipantView = view.findViewById(R.id.group_call_participant);
    callParticipantView.setCallParticipant(participant);
    callParticipantView.setRenderInPip(shouldRenderInPip);
    layoutStrategy.setChildScaling(participant, callParticipantView, isPortrait, count);
    if (count > 1) {
        view.setPadding(MULTIPLE_PARTICIPANT_SPACING, MULTIPLE_PARTICIPANT_SPACING, MULTIPLE_PARTICIPANT_SPACING, MULTIPLE_PARTICIPANT_SPACING);
        cardView.setRadius(CORNER_RADIUS);
    } else {
        view.setPadding(0, 0, 0, 0);
        cardView.setRadius(0);
    }
    if (isIncomingRing) {
        callParticipantView.hideAvatar();
    } else {
        callParticipantView.showAvatar();
    }
    if (count > 2) {
        callParticipantView.useSmallAvatar();
    } else {
        callParticipantView.useLargeAvatar();
    }
    layoutStrategy.setChildLayoutParams(view, index, getChildCount());
}
Also used : CardView(androidx.cardview.widget.CardView) View(android.view.View) CardView(androidx.cardview.widget.CardView)

Example 13 with CardView

use of androidx.cardview.widget.CardView in project Signal-Android by WhisperSystems.

the class ConversationUpdateItem method present.

private void present(@NonNull ConversationMessage conversationMessage, @NonNull Optional<MessageRecord> nextMessageRecord, @NonNull Recipient conversationRecipient, boolean isMessageRequestAccepted) {
    Set<MultiselectPart> multiselectParts = conversationMessage.getMultiselectCollection().toSet();
    setSelected(!Sets.intersection(multiselectParts, batchSelected).isEmpty());
    if (conversationMessage.getMessageRecord().isGroupV1MigrationEvent() && (!nextMessageRecord.isPresent() || !nextMessageRecord.get().isGroupV1MigrationEvent())) {
        actionButton.setText(R.string.ConversationUpdateItem_learn_more);
        actionButton.setVisibility(VISIBLE);
        actionButton.setOnClickListener(v -> {
            if (batchSelected.isEmpty() && eventListener != null) {
                eventListener.onGroupMigrationLearnMoreClicked(conversationMessage.getMessageRecord().getGroupV1MigrationMembershipChanges());
            }
        });
    } else if (conversationMessage.getMessageRecord().isChatSessionRefresh() && (!nextMessageRecord.isPresent() || !nextMessageRecord.get().isChatSessionRefresh())) {
        actionButton.setText(R.string.ConversationUpdateItem_learn_more);
        actionButton.setVisibility(VISIBLE);
        actionButton.setOnClickListener(v -> {
            if (batchSelected.isEmpty() && eventListener != null) {
                eventListener.onChatSessionRefreshLearnMoreClicked();
            }
        });
    } else if (conversationMessage.getMessageRecord().isIdentityUpdate()) {
        actionButton.setText(R.string.ConversationUpdateItem_learn_more);
        actionButton.setVisibility(VISIBLE);
        actionButton.setOnClickListener(v -> {
            if (batchSelected.isEmpty() && eventListener != null) {
                eventListener.onSafetyNumberLearnMoreClicked(conversationMessage.getMessageRecord().getIndividualRecipient());
            }
        });
    } else if (conversationMessage.getMessageRecord().isGroupCall()) {
        UpdateDescription updateDescription = MessageRecord.getGroupCallUpdateDescription(getContext(), conversationMessage.getMessageRecord().getBody(), true);
        Collection<ServiceId> acis = updateDescription.getMentioned();
        int text = 0;
        if (Util.hasItems(acis)) {
            if (acis.contains(Recipient.self().requireServiceId())) {
                text = R.string.ConversationUpdateItem_return_to_call;
            } else if (GroupCallUpdateDetailsUtil.parse(conversationMessage.getMessageRecord().getBody()).getIsCallFull()) {
                text = R.string.ConversationUpdateItem_call_is_full;
            } else {
                text = R.string.ConversationUpdateItem_join_call;
            }
        }
        if (text != 0 && conversationRecipient.isGroup() && conversationRecipient.isActiveGroup()) {
            actionButton.setText(text);
            actionButton.setVisibility(VISIBLE);
            actionButton.setOnClickListener(v -> {
                if (batchSelected.isEmpty() && eventListener != null) {
                    eventListener.onJoinGroupCallClicked();
                }
            });
        } else {
            actionButton.setVisibility(GONE);
            actionButton.setOnClickListener(null);
        }
    } else if (conversationMessage.getMessageRecord().isSelfCreatedGroup()) {
        actionButton.setText(R.string.ConversationUpdateItem_invite_friends);
        actionButton.setVisibility(VISIBLE);
        actionButton.setOnClickListener(v -> {
            if (batchSelected.isEmpty() && eventListener != null) {
                eventListener.onInviteFriendsToGroupClicked(conversationRecipient.requireGroupId().requireV2());
            }
        });
    } else if ((conversationMessage.getMessageRecord().isMissedAudioCall() || conversationMessage.getMessageRecord().isMissedVideoCall()) && EnableCallNotificationSettingsDialog.shouldShow(getContext())) {
        actionButton.setVisibility(VISIBLE);
        actionButton.setText(R.string.ConversationUpdateItem_enable_call_notifications);
        actionButton.setOnClickListener(v -> {
            if (eventListener != null) {
                eventListener.onEnableCallNotificationsClicked();
            }
        });
    } else if (conversationMessage.getMessageRecord().isInMemoryMessageRecord() && ((InMemoryMessageRecord) conversationMessage.getMessageRecord()).showActionButton()) {
        InMemoryMessageRecord inMemoryMessageRecord = (InMemoryMessageRecord) conversationMessage.getMessageRecord();
        actionButton.setVisibility(VISIBLE);
        actionButton.setText(inMemoryMessageRecord.getActionButtonText());
        actionButton.setOnClickListener(v -> {
            if (eventListener != null) {
                eventListener.onInMemoryMessageClicked(inMemoryMessageRecord);
            }
        });
    } else if (conversationMessage.getMessageRecord().isGroupV2DescriptionUpdate()) {
        actionButton.setVisibility(VISIBLE);
        actionButton.setText(R.string.ConversationUpdateItem_view);
        actionButton.setOnClickListener(v -> {
            if (eventListener != null) {
                eventListener.onViewGroupDescriptionChange(conversationRecipient.getGroupId().orNull(), conversationMessage.getMessageRecord().getGroupV2DescriptionUpdate(), isMessageRequestAccepted);
            }
        });
    } else if (conversationMessage.getMessageRecord().isBadDecryptType() && (!nextMessageRecord.isPresent() || !nextMessageRecord.get().isBadDecryptType())) {
        actionButton.setText(R.string.ConversationUpdateItem_learn_more);
        actionButton.setVisibility(VISIBLE);
        actionButton.setOnClickListener(v -> {
            if (batchSelected.isEmpty() && eventListener != null) {
                eventListener.onBadDecryptLearnMoreClicked(conversationMessage.getMessageRecord().getRecipient().getId());
            }
        });
    } else if (conversationMessage.getMessageRecord().isChangeNumber() && conversationMessage.getMessageRecord().getIndividualRecipient().isSystemContact()) {
        actionButton.setText(R.string.ConversationUpdateItem_update_contact);
        actionButton.setVisibility(VISIBLE);
        actionButton.setOnClickListener(v -> {
            if (batchSelected.isEmpty() && eventListener != null) {
                eventListener.onChangeNumberUpdateContact(conversationMessage.getMessageRecord().getIndividualRecipient());
            }
        });
    } else {
        actionButton.setVisibility(GONE);
        actionButton.setOnClickListener(null);
    }
    if (conversationMessage.getMessageRecord().isBoostRequest()) {
        actionButton.setVisibility(GONE);
        CardView donateButton = donateButtonStub.get();
        TextView buttonText = donateButton.findViewById(R.id.conversation_update_donate_action_button);
        boolean isSustainer = SignalStore.donationsValues().isLikelyASustainer();
        donateButton.setVisibility(VISIBLE);
        donateButton.setOnClickListener(v -> {
            if (batchSelected.isEmpty() && eventListener != null) {
                eventListener.onDonateClicked();
            }
        });
        if (isSustainer) {
            buttonText.setText(R.string.ConversationUpdateItem_signal_boost);
            buttonText.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_boost_outline_16, 0, 0, 0);
        } else {
            buttonText.setText(R.string.ConversationUpdateItem_become_a_sustainer);
            buttonText.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0);
        }
        AutoRounder.autoSetCorners(donateButton, donateButton::setRadius);
    } else if (donateButtonStub.resolved()) {
        donateButtonStub.get().setVisibility(GONE);
    }
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) NonNull(androidx.annotation.NonNull) Spannable(android.text.Spannable) FrameLayout(android.widget.FrameLayout) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) R(org.thoughtcrime.securesms.R) MessageRecord(org.thoughtcrime.securesms.database.model.MessageRecord) ColorStateList(android.content.res.ColorStateList) AttributeSet(android.util.AttributeSet) Locale(java.util.Locale) View(android.view.View) Recipient(org.thoughtcrime.securesms.recipients.Recipient) BindableConversationItem(org.thoughtcrime.securesms.BindableConversationItem) LiveUpdateMessage(org.thoughtcrime.securesms.database.model.LiveUpdateMessage) ContextCompat(androidx.core.content.ContextCompat) CardView(androidx.cardview.widget.CardView) ACI(org.whispersystems.signalservice.api.push.ACI) Collection(java.util.Collection) Set(java.util.Set) ViewGroup(android.view.ViewGroup) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) Log(org.signal.core.util.logging.Log) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) IdentityRecord(org.thoughtcrime.securesms.database.model.IdentityRecord) DateUtils(org.thoughtcrime.securesms.util.DateUtils) GlideRequests(org.thoughtcrime.securesms.mms.GlideRequests) Projection(org.thoughtcrime.securesms.util.Projection) Context(android.content.Context) UpdateDescription(org.thoughtcrime.securesms.database.model.UpdateDescription) MultiselectPart(org.thoughtcrime.securesms.conversation.mutiselect.MultiselectPart) Util(org.thoughtcrime.securesms.util.Util) AutoRounder(org.thoughtcrime.securesms.util.views.AutoRounder) LifecycleOwner(androidx.lifecycle.LifecycleOwner) MaterialButton(com.google.android.material.button.MaterialButton) Colorizer(org.thoughtcrime.securesms.conversation.colors.Colorizer) VerifyIdentityActivity(org.thoughtcrime.securesms.verify.VerifyIdentityActivity) LiveData(androidx.lifecycle.LiveData) IdentityUtil(org.thoughtcrime.securesms.util.IdentityUtil) ListenableFuture(org.thoughtcrime.securesms.util.concurrent.ListenableFuture) LiveRecipient(org.thoughtcrime.securesms.recipients.LiveRecipient) Stub(org.thoughtcrime.securesms.util.views.Stub) SpannableString(android.text.SpannableString) InMemoryMessageRecord(org.thoughtcrime.securesms.database.model.InMemoryMessageRecord) Optional(org.whispersystems.libsignal.util.guava.Optional) ExecutionException(java.util.concurrent.ExecutionException) Observer(androidx.lifecycle.Observer) GroupCallUpdateDetailsUtil(org.thoughtcrime.securesms.database.model.GroupCallUpdateDetailsUtil) ThemeUtil(org.thoughtcrime.securesms.util.ThemeUtil) EnableCallNotificationSettingsDialog(org.thoughtcrime.securesms.conversation.ui.error.EnableCallNotificationSettingsDialog) ServiceId(org.whispersystems.signalservice.api.push.ServiceId) ProjectionList(org.thoughtcrime.securesms.util.ProjectionList) LiveDataUtil(org.thoughtcrime.securesms.util.livedata.LiveDataUtil) MultiselectPart(org.thoughtcrime.securesms.conversation.mutiselect.MultiselectPart) InMemoryMessageRecord(org.thoughtcrime.securesms.database.model.InMemoryMessageRecord) UpdateDescription(org.thoughtcrime.securesms.database.model.UpdateDescription) CardView(androidx.cardview.widget.CardView) Collection(java.util.Collection) TextView(android.widget.TextView)

Example 14 with CardView

use of androidx.cardview.widget.CardView in project RespawnIRC-Android by FranckRJ.

the class JVCTopicAdapter method setColorBackgroundOfThisItem.

private void setColorBackgroundOfThisItem(View backrgoundView, @ColorInt int colorValue) {
    if (backrgoundView instanceof CardView) {
        CardView currentBackgroundView = (CardView) backrgoundView;
        currentBackgroundView.setCardBackgroundColor(colorValue);
    } else {
        backrgoundView.setBackgroundColor(colorValue);
    }
}
Also used : CardView(androidx.cardview.widget.CardView)

Example 15 with CardView

use of androidx.cardview.widget.CardView in project bitcoin-wallet by bitcoin-wallet.

the class ExchangeRatesAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, final int position, final List<Object> payloads) {
    final boolean fullBind = payloads.isEmpty();
    final EnumSet<ChangeType> changes = EnumSet.noneOf(ChangeType.class);
    for (final Object payload : payloads) changes.addAll((EnumSet<ChangeType>) payload);
    final ListItem listItem = getItem(position);
    if (fullBind || changes.contains(ChangeType.SELECTION)) {
        final boolean isSelected = listItem.currencyCode.equals(selectedExchangeRateCode);
        holder.itemView.setSelected(isSelected);
        ((CardView) holder.itemView).setCardElevation(isSelected ? cardElevationSelected : 0);
        holder.contextBar.setVisibility(View.GONE);
        if (contextMenuCallback != null && isSelected) {
            final Menu menu = holder.contextBar.getMenu();
            menu.clear();
            contextMenuCallback.onInflateBlockContextMenu(menuInflater, menu);
            if (menu.hasVisibleItems()) {
                holder.contextBar.setVisibility(View.VISIBLE);
                holder.contextBar.setOnMenuItemClickListener(item -> contextMenuCallback.onClickBlockContextMenuItem(item, listItem.currencyCode));
            }
        }
    }
    if (fullBind || changes.contains(ChangeType.DEFAULT)) {
        holder.defaultView.setVisibility(listItem.isDefault ? View.VISIBLE : View.INVISIBLE);
    }
    if (fullBind || changes.contains(ChangeType.RATE)) {
        holder.rateView.setFormat(Constants.LOCAL_FORMAT.minDecimals(listItem.baseRateMinDecimals));
        holder.rateView.setAmount(listItem.baseRateAsFiat);
        holder.walletView.setFormat(Constants.LOCAL_FORMAT);
        if (listItem.balanceAsFiat != null) {
            holder.walletView.setAmount(listItem.balanceAsFiat);
            holder.walletView.setStrikeThru(!Constants.NETWORK_PARAMETERS.getId().equals(NetworkParameters.ID_MAINNET));
        } else {
            holder.walletView.setText("n/a");
            holder.walletView.setStrikeThru(false);
        }
    }
    if (fullBind) {
        holder.currencyCodeView.setText(listItem.currencyCode);
        final OnClickListener onClickListener = this.onClickListener;
        if (onClickListener != null)
            holder.itemView.setOnClickListener(v -> onClickListener.onExchangeRateClick(v, listItem.currencyCode));
    }
}
Also used : Context(android.content.Context) Coin(org.bitcoinj.core.Coin) Dimension(androidx.annotation.Dimension) MainThread(androidx.annotation.MainThread) Hashing(com.google.common.hash.Hashing) BlockchainState(de.schildbach.wallet.service.BlockchainState) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) NetworkParameters(org.bitcoinj.core.NetworkParameters) MenuInflater(android.view.MenuInflater) Toolbar(android.widget.Toolbar) Menu(android.view.Menu) View(android.view.View) R(de.schildbach.wallet.R) RecyclerView(androidx.recyclerview.widget.RecyclerView) Constants(de.schildbach.wallet.Constants) EnumSet(java.util.EnumSet) CardView(androidx.cardview.widget.CardView) ListAdapter(androidx.recyclerview.widget.ListAdapter) ExchangeRate(org.bitcoinj.utils.ExchangeRate) LayoutInflater(android.view.LayoutInflater) DiffUtil(androidx.recyclerview.widget.DiffUtil) Fiat(org.bitcoinj.utils.Fiat) ViewGroup(android.view.ViewGroup) ExchangeRateEntry(de.schildbach.wallet.exchangerate.ExchangeRateEntry) Objects(java.util.Objects) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) HashFunction(com.google.common.hash.HashFunction) EnumSet(java.util.EnumSet) CardView(androidx.cardview.widget.CardView) Menu(android.view.Menu)

Aggregations

CardView (androidx.cardview.widget.CardView)22 View (android.view.View)17 TextView (android.widget.TextView)13 ViewGroup (android.view.ViewGroup)7 ImageView (android.widget.ImageView)6 Context (android.content.Context)5 Nullable (androidx.annotation.Nullable)5 RecyclerView (androidx.recyclerview.widget.RecyclerView)5 Objects (java.util.Objects)5 NonNull (androidx.annotation.NonNull)3 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 ColorStateList (android.content.res.ColorStateList)2 Drawable (android.graphics.drawable.Drawable)2 Bundle (android.os.Bundle)2 Spannable (android.text.Spannable)2 SpannableString (android.text.SpannableString)2 AttributeSet (android.util.AttributeSet)2 LayoutInflater (android.view.LayoutInflater)2 Menu (android.view.Menu)2