use of androidx.fragment.app.FragmentActivity in project android_packages_apps_Settings by omnirom.
the class EntityHeaderControllerTest method bindButton_noAppInfo_shouldNotAttachClickListener.
@Test
public void bindButton_noAppInfo_shouldNotAttachClickListener() {
final View appLinks = mLayoutInflater.inflate(R.layout.settings_entity_header, null);
final FragmentActivity activity = mock(FragmentActivity.class);
when(mFragment.getActivity()).thenReturn(activity);
mController = EntityHeaderController.newInstance(mActivity, mFragment, appLinks);
mController.setPackageName(null).setHasAppInfoLink(true).setButtonActions(EntityHeaderController.ActionType.ACTION_NONE, EntityHeaderController.ActionType.ACTION_NONE);
mController.done(mActivity);
assertThat(appLinks.findViewById(android.R.id.button1).getVisibility()).isEqualTo(View.GONE);
assertThat(appLinks.findViewById(android.R.id.button2).getVisibility()).isEqualTo(View.GONE);
appLinks.findViewById(R.id.entity_header_content).performClick();
verify(mFragment, never()).getActivity();
verify(activity, never()).startActivity(any(Intent.class));
}
use of androidx.fragment.app.FragmentActivity in project android_packages_apps_Settings by omnirom.
the class UserDetailsSettingsTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mActivity = spy(ActivityController.of(new FragmentActivity()).get());
mContext = spy(RuntimeEnvironment.application);
mUserCapabilities = UserCapabilities.create(mContext);
mUserCapabilities.mUserSwitcherEnabled = true;
mFragment = spy(new UserDetailsSettings());
mArguments = new Bundle();
UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
mUserManager = Shadow.extract(userManager);
doReturn(mTelephonyManager).when(mActivity).getSystemService(Context.TELEPHONY_SERVICE);
ReflectionHelpers.setField(mFragment, "mUserManager", userManager);
ReflectionHelpers.setField(mFragment, "mUserCaps", mUserCapabilities);
ReflectionHelpers.setField(mFragment, "mMetricsFeatureProvider", mMetricsFeatureProvider);
doReturn(mActivity).when(mFragment).getActivity();
doReturn(mActivity).when(mFragment).getContext();
doReturn(mock(PreferenceScreen.class)).when(mFragment).getPreferenceScreen();
doReturn(mSwitchUserPref).when(mFragment).findPreference(KEY_SWITCH_USER);
doReturn(mPhonePref).when(mFragment).findPreference(KEY_ENABLE_TELEPHONY);
doReturn(mRemoveUserPref).when(mFragment).findPreference(KEY_REMOVE_USER);
doReturn(mAppAndContentAccessPref).when(mFragment).findPreference(KEY_APP_AND_CONTENT_ACCESS);
}
use of androidx.fragment.app.FragmentActivity in project Signal-Android by WhisperSystems.
the class MediaOverviewPageFragment method enterMultiSelect.
private void enterMultiSelect() {
FragmentActivity activity = requireActivity();
actionMode = ((AppCompatActivity) activity).startSupportActionMode(actionModeCallback);
((MediaOverviewActivity) activity).onEnterMultiSelect();
ViewUtil.animateIn(bottomActionBar, bottomActionBar.getEnterAnimation());
updateMultiSelect();
}
use of androidx.fragment.app.FragmentActivity 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.fragment.app.FragmentActivity in project Signal-Android by WhisperSystems.
the class StoragePreferenceFragment method onResume.
@Override
public void onResume() {
super.onResume();
updateToolbarTitle(R.string.preferences__storage);
FragmentActivity activity = requireActivity();
ApplicationPreferencesViewModel viewModel = ApplicationPreferencesViewModel.getApplicationPreferencesViewModel(activity);
viewModel.refreshStorageBreakdown(activity.getApplicationContext());
keepMessages.setSummary(SignalStore.settings().getKeepMessagesDuration().getStringResource());
trimLength.setSummary(SignalStore.settings().isTrimByLengthEnabled() ? getString(R.string.preferences_storage__s_messages, NumberFormat.getInstance().format(SignalStore.settings().getThreadTrimLength())) : getString(R.string.preferences_storage__none));
}
Aggregations