mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Always show the SIM on the footer of a multi-SIM device, even if one SIM is disabled.
This commit is contained in:
parent
8cf2654c5b
commit
d1b8e77fdc
@ -106,7 +106,7 @@ public class ConversationItemFooter extends LinearLayout {
|
|||||||
private void presentSimInfo(@NonNull MessageRecord messageRecord) {
|
private void presentSimInfo(@NonNull MessageRecord messageRecord) {
|
||||||
SubscriptionManagerCompat subscriptionManager = new SubscriptionManagerCompat(getContext());
|
SubscriptionManagerCompat subscriptionManager = new SubscriptionManagerCompat(getContext());
|
||||||
|
|
||||||
if (messageRecord.isPush() || messageRecord.getSubscriptionId() == -1 || !Permissions.hasAll(getContext(), Manifest.permission.READ_PHONE_STATE) || subscriptionManager.getActiveAndReadySubscriptionInfos().size() < 2) {
|
if (messageRecord.isPush() || messageRecord.getSubscriptionId() == -1 || !Permissions.hasAll(getContext(), Manifest.permission.READ_PHONE_STATE) || !subscriptionManager.isMultiSim()) {
|
||||||
simView.setVisibility(View.GONE);
|
simView.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
Optional<SubscriptionInfoCompat> subscriptionInfo = subscriptionManager.getActiveSubscriptionInfo(messageRecord.getSubscriptionId());
|
Optional<SubscriptionInfoCompat> subscriptionInfo = subscriptionManager.getActiveSubscriptionInfo(messageRecord.getSubscriptionId());
|
||||||
|
@ -59,16 +59,9 @@ public final class SubscriptionManagerCompat {
|
|||||||
|
|
||||||
@RequiresApi(api = 22)
|
@RequiresApi(api = 22)
|
||||||
private @NonNull Map<Integer, SubscriptionInfoCompat> getActiveSubscriptionInfoMap(boolean excludeUnreadySubscriptions) {
|
private @NonNull Map<Integer, SubscriptionInfoCompat> getActiveSubscriptionInfoMap(boolean excludeUnreadySubscriptions) {
|
||||||
SubscriptionManager subscriptionManager = ServiceUtil.getSubscriptionManager(context);
|
List<SubscriptionInfo> subscriptionInfos = getActiveSubscriptionInfoList();
|
||||||
|
|
||||||
if (subscriptionManager == null) {
|
if (subscriptionInfos.isEmpty()) {
|
||||||
Log.w(TAG, "Missing SubscriptionManager.");
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<SubscriptionInfo> subscriptionInfos = subscriptionManager.getActiveSubscriptionInfoList();
|
|
||||||
|
|
||||||
if (subscriptionInfos == null || subscriptionInfos.isEmpty()) {
|
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +81,28 @@ public final class SubscriptionManagerCompat {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMultiSim() {
|
||||||
|
if (Build.VERSION.SDK_INT < 22) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return getActiveSubscriptionInfoList().size() >= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = 22)
|
||||||
|
private @NonNull List<SubscriptionInfo> getActiveSubscriptionInfoList() {
|
||||||
|
SubscriptionManager subscriptionManager = ServiceUtil.getSubscriptionManager(context);
|
||||||
|
|
||||||
|
if (subscriptionManager == null) {
|
||||||
|
Log.w(TAG, "Missing SubscriptionManager.");
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<SubscriptionInfo> list = subscriptionManager.getActiveSubscriptionInfoList();
|
||||||
|
|
||||||
|
return list != null? list : Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
@RequiresApi(api = 22)
|
@RequiresApi(api = 22)
|
||||||
private Map<SubscriptionInfo, CharSequence> getDescriptionsFor(@NonNull Collection<SubscriptionInfo> subscriptions) {
|
private Map<SubscriptionInfo, CharSequence> getDescriptionsFor(@NonNull Collection<SubscriptionInfo> subscriptions) {
|
||||||
Map<SubscriptionInfo, CharSequence> descriptions;
|
Map<SubscriptionInfo, CharSequence> descriptions;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user