Search in sources :

Example 1 with SubscriptionInfoCompat

use of org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat in project Signal-Android by signalapp.

the class MmsConfigManager method loadMmsConfig.

@NonNull
private static MmsConfig loadMmsConfig(Context context, int subscriptionId) {
    Optional<SubscriptionInfoCompat> subscriptionInfo = new SubscriptionManagerCompat(context).getActiveSubscriptionInfo(subscriptionId);
    if (subscriptionInfo.isPresent()) {
        SubscriptionInfoCompat subscriptionInfoCompat = subscriptionInfo.get();
        Configuration configuration = context.getResources().getConfiguration();
        configuration.mcc = subscriptionInfoCompat.getMcc();
        configuration.mnc = subscriptionInfoCompat.getMnc();
        Context subContext = context.createConfigurationContext(configuration);
        return new MmsConfig(subContext, subscriptionId);
    }
    return new MmsConfig(context, subscriptionId);
}
Also used : Context(android.content.Context) SubscriptionManagerCompat(org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat) MmsConfig(com.android.mms.service_alt.MmsConfig) Configuration(android.content.res.Configuration) SubscriptionInfoCompat(org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat) NonNull(androidx.annotation.NonNull)

Example 2 with SubscriptionInfoCompat

use of org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat in project Signal-Android by WhisperSystems.

the class ConversationItem method setSimInfo.

private void setSimInfo(MessageRecord messageRecord) {
    SubscriptionManagerCompat subscriptionManager = new SubscriptionManagerCompat(context);
    if (messageRecord.getSubscriptionId() == -1 || subscriptionManager.getActiveSubscriptionInfoList().size() < 2) {
        simInfoText.setVisibility(View.GONE);
    } else {
        Optional<SubscriptionInfoCompat> subscriptionInfo = subscriptionManager.getActiveSubscriptionInfo(messageRecord.getSubscriptionId());
        if (subscriptionInfo.isPresent() && messageRecord.isOutgoing()) {
            simInfoText.setText(getContext().getString(R.string.ConversationItem_from_s, subscriptionInfo.get().getDisplayName()));
            simInfoText.setVisibility(View.VISIBLE);
        } else if (subscriptionInfo.isPresent()) {
            simInfoText.setText(getContext().getString(R.string.ConversationItem_to_s, subscriptionInfo.get().getDisplayName()));
            simInfoText.setVisibility(View.VISIBLE);
        } else {
            simInfoText.setVisibility(View.GONE);
        }
    }
}
Also used : SubscriptionManagerCompat(org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat) SubscriptionInfoCompat(org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat)

Example 3 with SubscriptionInfoCompat

use of org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat in project Signal-Android by signalapp.

the class ConversationItem method setSimInfo.

private void setSimInfo(MessageRecord messageRecord) {
    SubscriptionManagerCompat subscriptionManager = new SubscriptionManagerCompat(context);
    if (messageRecord.getSubscriptionId() == -1 || !Permissions.hasAll(context, Manifest.permission.READ_PHONE_STATE) || subscriptionManager.getActiveSubscriptionInfoList().size() < 2) {
        simInfoText.setVisibility(View.GONE);
    } else {
        Optional<SubscriptionInfoCompat> subscriptionInfo = subscriptionManager.getActiveSubscriptionInfo(messageRecord.getSubscriptionId());
        if (subscriptionInfo.isPresent() && messageRecord.isOutgoing()) {
            simInfoText.setText(getContext().getString(R.string.ConversationItem_from_s, subscriptionInfo.get().getDisplayName()));
            simInfoText.setVisibility(View.VISIBLE);
        } else if (subscriptionInfo.isPresent()) {
            simInfoText.setText(getContext().getString(R.string.ConversationItem_to_s, subscriptionInfo.get().getDisplayName()));
            simInfoText.setVisibility(View.VISIBLE);
        } else {
            simInfoText.setVisibility(View.GONE);
        }
    }
}
Also used : SubscriptionManagerCompat(org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat) SubscriptionInfoCompat(org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat)

Example 4 with SubscriptionInfoCompat

use of org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat in project Signal-Android by WhisperSystems.

the class TransportOptions method getTransportOptionsForSimCards.

@NonNull
private List<TransportOption> getTransportOptionsForSimCards(@NonNull String text, @NonNull String composeHint, @NonNull CharacterCalculator characterCalculator) {
    List<TransportOption> results = new LinkedList<>();
    SubscriptionManagerCompat subscriptionManager = new SubscriptionManagerCompat(context);
    Collection<SubscriptionInfoCompat> subscriptions;
    if (Permissions.hasAll(context, Manifest.permission.READ_PHONE_STATE)) {
        subscriptions = subscriptionManager.getActiveAndReadySubscriptionInfos();
    } else {
        subscriptions = Collections.emptyList();
    }
    if (subscriptions.size() < 2) {
        results.add(new TransportOption(Type.SMS, R.drawable.ic_send_unlock_24, context.getResources().getColor(R.color.core_grey_50), text, composeHint, characterCalculator));
    } else {
        for (SubscriptionInfoCompat subscriptionInfo : subscriptions) {
            results.add(new TransportOption(Type.SMS, R.drawable.ic_send_unlock_24, context.getResources().getColor(R.color.core_grey_50), text, composeHint, characterCalculator, Optional.of(subscriptionInfo.getDisplayName()), Optional.of(subscriptionInfo.getSubscriptionId())));
        }
    }
    return results;
}
Also used : SubscriptionManagerCompat(org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat) SubscriptionInfoCompat(org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat) LinkedList(java.util.LinkedList) NonNull(androidx.annotation.NonNull)

Example 5 with SubscriptionInfoCompat

use of org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat in project Signal-Android by WhisperSystems.

the class ConversationItemFooter method presentSimInfo.

private void presentSimInfo(@NonNull MessageRecord messageRecord) {
    SubscriptionManagerCompat subscriptionManager = new SubscriptionManagerCompat(getContext());
    if (messageRecord.isPush() || messageRecord.getSubscriptionId() == -1 || !Permissions.hasAll(getContext(), Manifest.permission.READ_PHONE_STATE) || !subscriptionManager.isMultiSim()) {
        simView.setVisibility(View.GONE);
    } else {
        Optional<SubscriptionInfoCompat> subscriptionInfo = subscriptionManager.getActiveSubscriptionInfo(messageRecord.getSubscriptionId());
        if (subscriptionInfo.isPresent() && messageRecord.isOutgoing()) {
            simView.setText(getContext().getString(R.string.ConversationItem_from_s, subscriptionInfo.get().getDisplayName()));
            simView.setVisibility(View.VISIBLE);
        } else if (subscriptionInfo.isPresent()) {
            simView.setText(getContext().getString(R.string.ConversationItem_to_s, subscriptionInfo.get().getDisplayName()));
            simView.setVisibility(View.VISIBLE);
        } else {
            simView.setVisibility(View.GONE);
        }
    }
}
Also used : SubscriptionManagerCompat(org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat) SubscriptionInfoCompat(org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat)

Aggregations

SubscriptionInfoCompat (org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat)8 SubscriptionManagerCompat (org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat)8 NonNull (androidx.annotation.NonNull)4 Context (android.content.Context)2 Configuration (android.content.res.Configuration)2 MmsConfig (com.android.mms.service_alt.MmsConfig)2 LinkedList (java.util.LinkedList)2