Search in sources :

Example 96 with FragmentActivity

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));
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView) Test(org.junit.Test)

Example 97 with FragmentActivity

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);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) PreferenceScreen(androidx.preference.PreferenceScreen) Bundle(android.os.Bundle) ShadowUserManager(com.android.settings.testutils.shadow.ShadowUserManager) UserManager(android.os.UserManager) Before(org.junit.Before)

Example 98 with FragmentActivity

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();
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity)

Example 99 with FragmentActivity

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();
            }
        });
    }
}
Also used : Group(androidx.constraintlayout.widget.Group) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) AvatarImageView(org.thoughtcrime.securesms.components.AvatarImageView) SpannableString(android.text.SpannableString) BadgeImageView(org.thoughtcrime.securesms.badges.BadgeImageView) View(android.view.View) AvatarImageView(org.thoughtcrime.securesms.components.AvatarImageView) MoneyView(org.thoughtcrime.securesms.payments.MoneyView) TextView(android.widget.TextView) BadgeImageView(org.thoughtcrime.securesms.badges.BadgeImageView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) FragmentActivity(androidx.fragment.app.FragmentActivity) Payment(org.thoughtcrime.securesms.payments.Payment) MoneyView(org.thoughtcrime.securesms.payments.MoneyView) TextView(android.widget.TextView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) Toolbar(androidx.appcompat.widget.Toolbar)

Example 100 with FragmentActivity

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));
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity)

Aggregations

FragmentActivity (androidx.fragment.app.FragmentActivity)181 Test (org.junit.Test)71 Intent (android.content.Intent)25 Bundle (android.os.Bundle)19 View (android.view.View)11 Config (org.robolectric.annotation.Config)11 TextView (android.widget.TextView)10 Before (org.junit.Before)10 BroadcastReceiver (android.content.BroadcastReceiver)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 Resources (android.content.res.Resources)7 Fragment (androidx.fragment.app.Fragment)7 FragmentManager (androidx.fragment.app.FragmentManager)7 Activity (android.app.Activity)6 IntentFilter (android.content.IntentFilter)6 UserHandle (android.os.UserHandle)6 Preference (androidx.preference.Preference)6 SwitchPreference (androidx.preference.SwitchPreference)6 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)6 Tile (com.android.settingslib.drawer.Tile)6