use of androidx.constraintlayout.widget.Group in project Signal-Android by WhisperSystems.
the class DeviceTransferSetupFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Group progressGroup = view.findViewById(R.id.device_transfer_setup_fragment_progress_group);
Group errorGroup = view.findViewById(R.id.device_transfer_setup_fragment_error_group);
View verifyGroup = view.findViewById(R.id.device_transfer_setup_fragment_verify);
View waitingGroup = view.findViewById(R.id.device_transfer_setup_fragment_waiting);
View troubleshooting = view.findViewById(R.id.device_transfer_setup_fragment_troubleshooting);
TextView status = view.findViewById(R.id.device_transfer_setup_fragment_status);
TextView error = view.findViewById(R.id.device_transfer_setup_fragment_error);
MaterialButton errorResolve = view.findViewById(R.id.device_transfer_setup_fragment_error_resolve);
TextView sasNumber = view.findViewById(R.id.device_transfer_setup_fragment_sas_verify_code);
MaterialButton verifyNo = view.findViewById(R.id.device_transfer_setup_fragment_sas_verify_no);
MaterialButton verifyYes = view.findViewById(R.id.device_transfer_setup_fragment_sas_verify_yes);
viewModel = ViewModelProviders.of(this).get(DeviceTransferSetupViewModel.class);
viewModel.getState().observe(getViewLifecycleOwner(), state -> {
SetupStep step = state.getCurrentSetupStep();
progressGroup.setVisibility(step.isProgress() ? View.VISIBLE : View.GONE);
errorGroup.setVisibility(step.isError() ? View.VISIBLE : View.GONE);
verifyGroup.setVisibility(step == SetupStep.VERIFY ? View.VISIBLE : View.GONE);
waitingGroup.setVisibility(step == SetupStep.WAITING_FOR_OTHER_TO_VERIFY ? View.VISIBLE : View.GONE);
troubleshooting.setVisibility(step == SetupStep.TROUBLESHOOTING ? View.VISIBLE : View.GONE);
Log.i(TAG, "Handling step: " + step.name());
switch(step) {
case INITIAL:
status.setText("");
case PERMISSIONS_CHECK:
requestLocationPermission();
break;
case PERMISSIONS_DENIED:
error.setText(getErrorTextForStep(step));
errorResolve.setText(R.string.DeviceTransferSetup__grant_location_permission);
errorResolve.setOnClickListener(v -> viewModel.checkPermissions());
break;
case LOCATION_CHECK:
verifyLocationEnabled();
break;
case LOCATION_DISABLED:
error.setText(getErrorTextForStep(step));
errorResolve.setText(R.string.DeviceTransferSetup__turn_on_location_services);
errorResolve.setOnClickListener(v -> openLocationServices());
break;
case WIFI_CHECK:
verifyWifiEnabled();
break;
case WIFI_DISABLED:
error.setText(getErrorTextForStep(step));
errorResolve.setText(R.string.DeviceTransferSetup__turn_on_wifi);
errorResolve.setOnClickListener(v -> openWifiSettings());
break;
case WIFI_DIRECT_CHECK:
verifyWifiDirectAvailable();
break;
case WIFI_DIRECT_UNAVAILABLE:
error.setText(getErrorTextForStep(step));
errorResolve.setText(getErrorResolveButtonTextForStep(step));
errorResolve.setOnClickListener(v -> navigateWhenWifiDirectUnavailable());
break;
case START:
status.setText(getStatusTextForStep(SetupStep.SETTING_UP, false));
startTransfer();
break;
case SETTING_UP:
status.setText(getStatusTextForStep(step, false));
startTakingTooLong(() -> status.setText(getStatusTextForStep(step, true)), PREPARE_TAKING_TOO_LONG_TIME);
break;
case WAITING:
status.setText(getStatusTextForStep(step, false));
cancelTakingTooLong();
startTakingTooLong(() -> {
DeviceToDeviceTransferService.stop(requireContext());
viewModel.onWaitingTookTooLong();
}, WAITING_TAKING_TOO_LONG_TIME);
break;
case VERIFY:
cancelTakingTooLong();
sasNumber.setText(String.format(Locale.US, "%07d", state.getAuthenticationCode()));
// noinspection CodeBlock2Expr
verifyNo.setOnClickListener(v -> {
new AlertDialog.Builder(requireContext()).setTitle(R.string.DeviceTransferSetup__the_numbers_do_not_match).setMessage(R.string.DeviceTransferSetup__if_the_numbers_on_your_devices_do_not_match_its_possible_you_connected_to_the_wrong_device).setPositiveButton(R.string.DeviceTransferSetup__stop_transfer, (d, w) -> {
EventBus.getDefault().unregister(this);
DeviceToDeviceTransferService.setAuthenticationCodeVerified(requireContext(), false);
DeviceToDeviceTransferService.stop(requireContext());
EventBus.getDefault().removeStickyEvent(TransferStatus.class);
navigateAwayFromTransfer();
}).setNegativeButton(android.R.string.cancel, null).show();
});
verifyYes.setOnClickListener(v -> {
DeviceToDeviceTransferService.setAuthenticationCodeVerified(requireContext(), true);
viewModel.onVerified();
});
break;
case WAITING_FOR_OTHER_TO_VERIFY:
break;
case CONNECTED:
Log.d(TAG, "Connected! isNotShutdown: " + viewModel.isNotShutdown());
if (viewModel.isNotShutdown()) {
navigateToTransferConnected();
}
break;
case TROUBLESHOOTING:
TextView title = troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_title);
title.setText(getStatusTextForStep(step, false));
int gapWidth = ViewUtil.dpToPx(12);
TextView step1 = troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_step1);
step1.setText(SpanUtil.bullet(getString(R.string.DeviceTransferSetup__make_sure_the_following_permissions_are_enabled), gapWidth));
TextView step2 = troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_step2);
step2.setMovementMethod(LinkMovementMethod.getInstance());
step2.setText(SpanUtil.clickSubstring(requireContext(), SpanUtil.bullet(getString(R.string.DeviceTransferSetup__on_the_wifi_direct_screen_remove_all_remembered_groups_and_unlink_any_invited_or_connected_devices), gapWidth), getString(R.string.DeviceTransferSetup__wifi_direct_screen), v -> openWifiDirectSettings()));
TextView step3 = troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_step3);
step3.setText(SpanUtil.bullet(getString(R.string.DeviceTransferSetup__try_turning_wifi_off_and_on_on_both_devices), gapWidth));
TextView step4 = troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_step4);
step4.setText(SpanUtil.bullet(getString(R.string.DeviceTransferSetup__make_sure_both_devices_are_in_transfer_mode), gapWidth));
troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_location_permission).setOnClickListener(v -> openApplicationSystemSettings());
troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_location_services).setOnClickListener(v -> openLocationServices());
troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_wifi).setOnClickListener(v -> openWifiSettings());
troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_go_to_support).setOnClickListener(v -> gotoSupport());
troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_try_again).setOnClickListener(v -> viewModel.checkPermissions());
break;
case ERROR:
error.setText(getErrorTextForStep(step));
errorResolve.setText(R.string.DeviceTransferSetup__retry);
errorResolve.setOnClickListener(v -> viewModel.checkPermissions());
DeviceToDeviceTransferService.stop(requireContext());
cancelTakingTooLong();
new AlertDialog.Builder(requireContext()).setTitle(R.string.DeviceTransferSetup__error_connecting).setMessage(getStatusTextForStep(step, false)).setPositiveButton(R.string.DeviceTransferSetup__retry, (d, w) -> viewModel.checkPermissions()).setNegativeButton(android.R.string.cancel, (d, w) -> {
EventBus.getDefault().unregister(this);
EventBus.getDefault().removeStickyEvent(TransferStatus.class);
navigateAwayFromTransfer();
}).setNeutralButton(R.string.DeviceTransferSetup__submit_debug_logs, (d, w) -> {
EventBus.getDefault().unregister(this);
EventBus.getDefault().removeStickyEvent(TransferStatus.class);
navigateAwayFromTransfer();
startActivity(new Intent(requireContext(), SubmitDebugLogActivity.class));
}).setCancelable(false).show();
break;
}
});
}
use of androidx.constraintlayout.widget.Group in project Signal-Android by signalapp.
the class DeviceTransferSetupFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Group progressGroup = view.findViewById(R.id.device_transfer_setup_fragment_progress_group);
Group errorGroup = view.findViewById(R.id.device_transfer_setup_fragment_error_group);
View verifyGroup = view.findViewById(R.id.device_transfer_setup_fragment_verify);
View waitingGroup = view.findViewById(R.id.device_transfer_setup_fragment_waiting);
View troubleshooting = view.findViewById(R.id.device_transfer_setup_fragment_troubleshooting);
TextView status = view.findViewById(R.id.device_transfer_setup_fragment_status);
TextView error = view.findViewById(R.id.device_transfer_setup_fragment_error);
MaterialButton errorResolve = view.findViewById(R.id.device_transfer_setup_fragment_error_resolve);
TextView sasNumber = view.findViewById(R.id.device_transfer_setup_fragment_sas_verify_code);
MaterialButton verifyNo = view.findViewById(R.id.device_transfer_setup_fragment_sas_verify_no);
MaterialButton verifyYes = view.findViewById(R.id.device_transfer_setup_fragment_sas_verify_yes);
viewModel = ViewModelProviders.of(this).get(DeviceTransferSetupViewModel.class);
viewModel.getState().observe(getViewLifecycleOwner(), state -> {
SetupStep step = state.getCurrentSetupStep();
progressGroup.setVisibility(step.isProgress() ? View.VISIBLE : View.GONE);
errorGroup.setVisibility(step.isError() ? View.VISIBLE : View.GONE);
verifyGroup.setVisibility(step == SetupStep.VERIFY ? View.VISIBLE : View.GONE);
waitingGroup.setVisibility(step == SetupStep.WAITING_FOR_OTHER_TO_VERIFY ? View.VISIBLE : View.GONE);
troubleshooting.setVisibility(step == SetupStep.TROUBLESHOOTING ? View.VISIBLE : View.GONE);
Log.i(TAG, "Handling step: " + step.name());
switch(step) {
case INITIAL:
status.setText("");
case PERMISSIONS_CHECK:
requestLocationPermission();
break;
case PERMISSIONS_DENIED:
error.setText(getErrorTextForStep(step));
errorResolve.setText(R.string.DeviceTransferSetup__grant_location_permission);
errorResolve.setOnClickListener(v -> viewModel.checkPermissions());
break;
case LOCATION_CHECK:
verifyLocationEnabled();
break;
case LOCATION_DISABLED:
error.setText(getErrorTextForStep(step));
errorResolve.setText(R.string.DeviceTransferSetup__turn_on_location_services);
errorResolve.setOnClickListener(v -> openLocationServices());
break;
case WIFI_CHECK:
verifyWifiEnabled();
break;
case WIFI_DISABLED:
error.setText(getErrorTextForStep(step));
errorResolve.setText(R.string.DeviceTransferSetup__turn_on_wifi);
errorResolve.setOnClickListener(v -> openWifiSettings());
break;
case WIFI_DIRECT_CHECK:
verifyWifiDirectAvailable();
break;
case WIFI_DIRECT_UNAVAILABLE:
error.setText(getErrorTextForStep(step));
errorResolve.setText(getErrorResolveButtonTextForStep(step));
errorResolve.setOnClickListener(v -> navigateWhenWifiDirectUnavailable());
break;
case START:
status.setText(getStatusTextForStep(SetupStep.SETTING_UP, false));
startTransfer();
break;
case SETTING_UP:
status.setText(getStatusTextForStep(step, false));
startTakingTooLong(() -> status.setText(getStatusTextForStep(step, true)), PREPARE_TAKING_TOO_LONG_TIME);
break;
case WAITING:
status.setText(getStatusTextForStep(step, false));
cancelTakingTooLong();
startTakingTooLong(() -> {
DeviceToDeviceTransferService.stop(requireContext());
viewModel.onWaitingTookTooLong();
}, WAITING_TAKING_TOO_LONG_TIME);
break;
case VERIFY:
cancelTakingTooLong();
sasNumber.setText(String.format(Locale.US, "%07d", state.getAuthenticationCode()));
// noinspection CodeBlock2Expr
verifyNo.setOnClickListener(v -> {
new AlertDialog.Builder(requireContext()).setTitle(R.string.DeviceTransferSetup__the_numbers_do_not_match).setMessage(R.string.DeviceTransferSetup__if_the_numbers_on_your_devices_do_not_match_its_possible_you_connected_to_the_wrong_device).setPositiveButton(R.string.DeviceTransferSetup__stop_transfer, (d, w) -> {
EventBus.getDefault().unregister(this);
DeviceToDeviceTransferService.setAuthenticationCodeVerified(requireContext(), false);
DeviceToDeviceTransferService.stop(requireContext());
EventBus.getDefault().removeStickyEvent(TransferStatus.class);
navigateAwayFromTransfer();
}).setNegativeButton(android.R.string.cancel, null).show();
});
verifyYes.setOnClickListener(v -> {
DeviceToDeviceTransferService.setAuthenticationCodeVerified(requireContext(), true);
viewModel.onVerified();
});
break;
case WAITING_FOR_OTHER_TO_VERIFY:
break;
case CONNECTED:
Log.d(TAG, "Connected! isNotShutdown: " + viewModel.isNotShutdown());
if (viewModel.isNotShutdown()) {
navigateToTransferConnected();
}
break;
case TROUBLESHOOTING:
TextView title = troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_title);
title.setText(getStatusTextForStep(step, false));
int gapWidth = ViewUtil.dpToPx(12);
TextView step1 = troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_step1);
step1.setText(SpanUtil.bullet(getString(R.string.DeviceTransferSetup__make_sure_the_following_permissions_are_enabled), gapWidth));
TextView step2 = troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_step2);
step2.setMovementMethod(LinkMovementMethod.getInstance());
step2.setText(SpanUtil.clickSubstring(requireContext(), SpanUtil.bullet(getString(R.string.DeviceTransferSetup__on_the_wifi_direct_screen_remove_all_remembered_groups_and_unlink_any_invited_or_connected_devices), gapWidth), getString(R.string.DeviceTransferSetup__wifi_direct_screen), v -> openWifiDirectSettings()));
TextView step3 = troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_step3);
step3.setText(SpanUtil.bullet(getString(R.string.DeviceTransferSetup__try_turning_wifi_off_and_on_on_both_devices), gapWidth));
TextView step4 = troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_step4);
step4.setText(SpanUtil.bullet(getString(R.string.DeviceTransferSetup__make_sure_both_devices_are_in_transfer_mode), gapWidth));
troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_location_permission).setOnClickListener(v -> openApplicationSystemSettings());
troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_location_services).setOnClickListener(v -> openLocationServices());
troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_wifi).setOnClickListener(v -> openWifiSettings());
troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_go_to_support).setOnClickListener(v -> gotoSupport());
troubleshooting.findViewById(R.id.device_transfer_setup_fragment_troubleshooting_try_again).setOnClickListener(v -> viewModel.checkPermissions());
break;
case ERROR:
error.setText(getErrorTextForStep(step));
errorResolve.setText(R.string.DeviceTransferSetup__retry);
errorResolve.setOnClickListener(v -> viewModel.checkPermissions());
DeviceToDeviceTransferService.stop(requireContext());
cancelTakingTooLong();
new AlertDialog.Builder(requireContext()).setTitle(R.string.DeviceTransferSetup__error_connecting).setMessage(getStatusTextForStep(step, false)).setPositiveButton(R.string.DeviceTransferSetup__retry, (d, w) -> viewModel.checkPermissions()).setNegativeButton(android.R.string.cancel, (d, w) -> {
EventBus.getDefault().unregister(this);
EventBus.getDefault().removeStickyEvent(TransferStatus.class);
navigateAwayFromTransfer();
}).setNeutralButton(R.string.DeviceTransferSetup__submit_debug_logs, (d, w) -> {
EventBus.getDefault().unregister(this);
EventBus.getDefault().removeStickyEvent(TransferStatus.class);
navigateAwayFromTransfer();
startActivity(new Intent(requireContext(), SubmitDebugLogActivity.class));
}).setCancelable(false).show();
break;
}
});
}
use of androidx.constraintlayout.widget.Group in project Signal-Android by signalapp.
the class PaymentDetailsFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Toolbar toolbar = view.findViewById(R.id.payments_details_toolbar);
toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(v).popBackStack());
PaymentDetailsParcelable details = PaymentDetailsFragmentArgs.fromBundle(requireArguments()).getPaymentDetails();
AvatarImageView avatar = view.findViewById(R.id.payments_details_avatar);
BadgeImageView badge = view.findViewById(R.id.payments_details_badge);
TextView contactFromTo = view.findViewById(R.id.payments_details_contact_to_from);
MoneyView amount = view.findViewById(R.id.payments_details_amount);
TextView note = view.findViewById(R.id.payments_details_note);
TextView status = view.findViewById(R.id.payments_details_status);
View sentByHeader = view.findViewById(R.id.payments_details_sent_by_header);
TextView sentBy = view.findViewById(R.id.payments_details_sent_by);
LearnMoreTextView transactionInfo = view.findViewById(R.id.payments_details_info);
TextView sentTo = view.findViewById(R.id.payments_details_sent_to_header);
MoneyView sentToAmount = view.findViewById(R.id.payments_details_sent_to_amount);
View sentFeeHeader = view.findViewById(R.id.payments_details_sent_fee_header);
MoneyView sentFeeAmount = view.findViewById(R.id.payments_details_sent_fee_amount);
Group sentViews = view.findViewById(R.id.payments_details_sent_views);
View blockHeader = view.findViewById(R.id.payments_details_block_header);
TextView blockNumber = view.findViewById(R.id.payments_details_block);
if (details.hasPayment()) {
Payment payment = details.requirePayment();
avatar.disableQuickContact();
avatar.setImageResource(R.drawable.ic_mobilecoin_avatar_24);
contactFromTo.setText(getContactFromToTextFromDirection(payment.getDirection()));
amount.setMoney(payment.getAmountPlusFeeWithDirection());
note.setVisibility(View.GONE);
status.setText(getStatusFromPayment(payment));
sentByHeader.setVisibility(View.GONE);
sentBy.setVisibility(View.GONE);
transactionInfo.setLearnMoreVisible(true);
transactionInfo.setText(R.string.PaymentsDetailsFragment__information);
transactionInfo.setLink(getString(R.string.PaymentsDetailsFragment__learn_more__information));
sentTo.setVisibility(View.GONE);
sentToAmount.setVisibility(View.GONE);
blockHeader.setVisibility(View.VISIBLE);
blockNumber.setVisibility(View.VISIBLE);
blockNumber.setText(String.valueOf(payment.getBlockIndex()));
if (payment.getDirection() == Direction.SENT) {
sentFeeAmount.setMoney(payment.getFee());
sentFeeHeader.setVisibility(View.VISIBLE);
sentFeeAmount.setVisibility(View.VISIBLE);
}
} else {
PaymentsDetailsViewModel viewModel = ViewModelProviders.of(this, new PaymentsDetailsViewModel.Factory(details.requireUuid())).get(PaymentsDetailsViewModel.class);
viewModel.getViewState().observe(getViewLifecycleOwner(), state -> {
if (state.getRecipient().getId().isUnknown() || state.getPayment().isDefrag()) {
avatar.disableQuickContact();
avatar.setImageResource(R.drawable.ic_mobilecoin_avatar_24);
} else {
avatar.setRecipient(state.getRecipient(), true);
badge.setBadgeFromRecipient(state.getRecipient());
}
contactFromTo.setText(describeToOrFrom(state));
if (state.getPayment().getState() == State.FAILED) {
amount.setTextColor(ContextCompat.getColor(requireContext(), R.color.signal_text_primary_disabled));
amount.setMoney(state.getPayment().getAmountPlusFeeWithDirection(), false);
transactionInfo.setVisibility(View.GONE);
} else {
amount.setMoney(state.getPayment().getAmountPlusFeeWithDirection());
if (state.getPayment().isDefrag()) {
transactionInfo.setLearnMoreVisible(true);
transactionInfo.setText(R.string.PaymentsDetailsFragment__coin_cleanup_information);
transactionInfo.setLink(getString(R.string.PaymentsDetailsFragment__learn_more__cleanup_fee));
} else {
transactionInfo.setLearnMoreVisible(true);
transactionInfo.setText(R.string.PaymentsDetailsFragment__information);
transactionInfo.setLink(getString(R.string.PaymentsDetailsFragment__learn_more__information));
}
transactionInfo.setVisibility(View.VISIBLE);
}
String trimmedNote = state.getPayment().getNote().trim();
note.setText(trimmedNote);
note.setVisibility(TextUtils.isEmpty(trimmedNote) ? View.GONE : View.VISIBLE);
status.setText(describeStatus(state.getPayment()));
sentBy.setText(describeSentBy(state));
if (state.getPayment().getDirection().isReceived()) {
sentToAmount.setMoney(Money.MobileCoin.ZERO);
sentFeeAmount.setMoney(Money.MobileCoin.ZERO);
sentViews.setVisibility(View.GONE);
} else {
sentTo.setText(describeSentTo(state, state.getPayment()));
sentToAmount.setMoney(state.getPayment().getAmount());
sentFeeAmount.setMoney(state.getPayment().getFee());
sentViews.setVisibility(View.VISIBLE);
}
});
viewModel.getPaymentExists().observe(getViewLifecycleOwner(), exists -> {
if (!exists) {
Log.w(TAG, "Failed to find payment detail");
FragmentActivity fragmentActivity = requireActivity();
fragmentActivity.onBackPressed();
Toast.makeText(fragmentActivity, R.string.PaymentsDetailsFragment__no_details_available, Toast.LENGTH_SHORT).show();
}
});
}
}
use of androidx.constraintlayout.widget.Group in project Signal-Android by WhisperSystems.
the class PaymentDetailsFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Toolbar toolbar = view.findViewById(R.id.payments_details_toolbar);
toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(v).popBackStack());
PaymentDetailsParcelable details = PaymentDetailsFragmentArgs.fromBundle(requireArguments()).getPaymentDetails();
AvatarImageView avatar = view.findViewById(R.id.payments_details_avatar);
BadgeImageView badge = view.findViewById(R.id.payments_details_badge);
TextView contactFromTo = view.findViewById(R.id.payments_details_contact_to_from);
MoneyView amount = view.findViewById(R.id.payments_details_amount);
TextView note = view.findViewById(R.id.payments_details_note);
TextView status = view.findViewById(R.id.payments_details_status);
View sentByHeader = view.findViewById(R.id.payments_details_sent_by_header);
TextView sentBy = view.findViewById(R.id.payments_details_sent_by);
LearnMoreTextView transactionInfo = view.findViewById(R.id.payments_details_info);
TextView sentTo = view.findViewById(R.id.payments_details_sent_to_header);
MoneyView sentToAmount = view.findViewById(R.id.payments_details_sent_to_amount);
View sentFeeHeader = view.findViewById(R.id.payments_details_sent_fee_header);
MoneyView sentFeeAmount = view.findViewById(R.id.payments_details_sent_fee_amount);
Group sentViews = view.findViewById(R.id.payments_details_sent_views);
View blockHeader = view.findViewById(R.id.payments_details_block_header);
TextView blockNumber = view.findViewById(R.id.payments_details_block);
if (details.hasPayment()) {
Payment payment = details.requirePayment();
avatar.disableQuickContact();
avatar.setImageResource(R.drawable.ic_mobilecoin_avatar_24);
contactFromTo.setText(getContactFromToTextFromDirection(payment.getDirection()));
amount.setMoney(payment.getAmountPlusFeeWithDirection());
note.setVisibility(View.GONE);
status.setText(getStatusFromPayment(payment));
sentByHeader.setVisibility(View.GONE);
sentBy.setVisibility(View.GONE);
transactionInfo.setLearnMoreVisible(true);
transactionInfo.setText(R.string.PaymentsDetailsFragment__information);
transactionInfo.setLink(getString(R.string.PaymentsDetailsFragment__learn_more__information));
sentTo.setVisibility(View.GONE);
sentToAmount.setVisibility(View.GONE);
blockHeader.setVisibility(View.VISIBLE);
blockNumber.setVisibility(View.VISIBLE);
blockNumber.setText(String.valueOf(payment.getBlockIndex()));
if (payment.getDirection() == Direction.SENT) {
sentFeeAmount.setMoney(payment.getFee());
sentFeeHeader.setVisibility(View.VISIBLE);
sentFeeAmount.setVisibility(View.VISIBLE);
}
} else {
PaymentsDetailsViewModel viewModel = ViewModelProviders.of(this, new PaymentsDetailsViewModel.Factory(details.requireUuid())).get(PaymentsDetailsViewModel.class);
viewModel.getViewState().observe(getViewLifecycleOwner(), state -> {
if (state.getRecipient().getId().isUnknown() || state.getPayment().isDefrag()) {
avatar.disableQuickContact();
avatar.setImageResource(R.drawable.ic_mobilecoin_avatar_24);
} else {
avatar.setRecipient(state.getRecipient(), true);
badge.setBadgeFromRecipient(state.getRecipient());
}
contactFromTo.setText(describeToOrFrom(state));
if (state.getPayment().getState() == State.FAILED) {
amount.setTextColor(ContextCompat.getColor(requireContext(), R.color.signal_text_primary_disabled));
amount.setMoney(state.getPayment().getAmountPlusFeeWithDirection(), false);
transactionInfo.setVisibility(View.GONE);
} else {
amount.setMoney(state.getPayment().getAmountPlusFeeWithDirection());
if (state.getPayment().isDefrag()) {
transactionInfo.setLearnMoreVisible(true);
transactionInfo.setText(R.string.PaymentsDetailsFragment__coin_cleanup_information);
transactionInfo.setLink(getString(R.string.PaymentsDetailsFragment__learn_more__cleanup_fee));
} else {
transactionInfo.setLearnMoreVisible(true);
transactionInfo.setText(R.string.PaymentsDetailsFragment__information);
transactionInfo.setLink(getString(R.string.PaymentsDetailsFragment__learn_more__information));
}
transactionInfo.setVisibility(View.VISIBLE);
}
String trimmedNote = state.getPayment().getNote().trim();
note.setText(trimmedNote);
note.setVisibility(TextUtils.isEmpty(trimmedNote) ? View.GONE : View.VISIBLE);
status.setText(describeStatus(state.getPayment()));
sentBy.setText(describeSentBy(state));
if (state.getPayment().getDirection().isReceived()) {
sentToAmount.setMoney(Money.MobileCoin.ZERO);
sentFeeAmount.setMoney(Money.MobileCoin.ZERO);
sentViews.setVisibility(View.GONE);
} else {
sentTo.setText(describeSentTo(state, state.getPayment()));
sentToAmount.setMoney(state.getPayment().getAmount());
sentFeeAmount.setMoney(state.getPayment().getFee());
sentViews.setVisibility(View.VISIBLE);
}
});
viewModel.getPaymentExists().observe(getViewLifecycleOwner(), exists -> {
if (!exists) {
Log.w(TAG, "Failed to find payment detail");
FragmentActivity fragmentActivity = requireActivity();
fragmentActivity.onBackPressed();
Toast.makeText(fragmentActivity, R.string.PaymentsDetailsFragment__no_details_available, Toast.LENGTH_SHORT).show();
}
});
}
}
use of androidx.constraintlayout.widget.Group in project Signal-Android by WhisperSystems.
the class MessageRequestsBottomView method setActiveInactiveGroups.
private void setActiveInactiveGroups(@NonNull Group activeGroup, @NonNull Group... inActiveGroups) {
int initialVisibility = this.activeGroup != null ? this.activeGroup.getVisibility() : VISIBLE;
this.activeGroup = activeGroup;
for (Group inactive : inActiveGroups) {
inactive.setVisibility(GONE);
}
activeGroup.setVisibility(initialVisibility);
}
Aggregations