[Settings] Fix RTL issue of Calls and SMS
Screenshot: https://screenshot.googleplex.com/9BqEh99vz7xp2g4.png Bug: 189300799 Test: make Change-Id: I022253efbe0ea25f11d5ac6c2b3b0fcd1d9f54aa
This commit is contained in:
@@ -24,6 +24,7 @@ import android.telephony.ServiceState;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
@@ -44,12 +45,14 @@ public class NetworkProviderCallsSmsController extends AbstractPreferenceControl
|
||||
|
||||
private static final String TAG = "NetworkProviderCallsSmsController";
|
||||
private static final String KEY = "calls_and_sms";
|
||||
private static final String RTL_MARK = "\u200F";
|
||||
|
||||
private UserManager mUserManager;
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private SubscriptionsChangeListener mSubscriptionsChangeListener;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private RestrictedPreference mPreference;
|
||||
private boolean mIsRtlMode;
|
||||
|
||||
/**
|
||||
* The summary text and click behavior of the "Calls & SMS" item on the
|
||||
@@ -61,6 +64,8 @@ public class NetworkProviderCallsSmsController extends AbstractPreferenceControl
|
||||
mUserManager = context.getSystemService(UserManager.class);
|
||||
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
||||
mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
|
||||
mIsRtlMode = context.getResources().getConfiguration().getLayoutDirection()
|
||||
== View.LAYOUT_DIRECTION_RTL;
|
||||
if (lifecycle != null) {
|
||||
mSubscriptionsChangeListener = new SubscriptionsChangeListener(context, this);
|
||||
lifecycle.addObserver(this);
|
||||
@@ -121,6 +126,10 @@ public class NetworkProviderCallsSmsController extends AbstractPreferenceControl
|
||||
if (subInfo != subs.get(subs.size() - 1)) {
|
||||
summary.append(", ");
|
||||
}
|
||||
|
||||
if (mIsRtlMode) {
|
||||
summary.insert(0, RTL_MARK).insert(summary.length(), RTL_MARK);
|
||||
}
|
||||
}
|
||||
return summary;
|
||||
}
|
||||
@@ -152,12 +161,12 @@ public class NetworkProviderCallsSmsController extends AbstractPreferenceControl
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected int getDefaultVoiceSubscriptionId(){
|
||||
protected int getDefaultVoiceSubscriptionId() {
|
||||
return SubscriptionManager.getDefaultVoiceSubscriptionId();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected int getDefaultSmsSubscriptionId(){
|
||||
protected int getDefaultSmsSubscriptionId() {
|
||||
return SubscriptionManager.getDefaultSmsSubscriptionId();
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@ public class CallsDefaultSubscriptionController extends DefaultSubscriptionContr
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
if (Utils.isProviderModelEnabled(mContext)) {
|
||||
return MobileNetworkUtils.getPreferredStatus(mContext, mManager, true);
|
||||
return MobileNetworkUtils.getPreferredStatus(isRtlMode(), mContext, mManager, true);
|
||||
} else {
|
||||
return super.getSummary();
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import android.telecom.PhoneAccountHandle;
|
||||
import android.telecom.TelecomManager;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
@@ -62,11 +63,14 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere
|
||||
private static final ComponentName PSTN_CONNECTION_SERVICE_COMPONENT =
|
||||
new ComponentName("com.android.phone",
|
||||
"com.android.services.telephony.TelephonyConnectionService");
|
||||
private boolean mIsRtlMode;
|
||||
|
||||
public DefaultSubscriptionController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mManager = context.getSystemService(SubscriptionManager.class);
|
||||
mChangeListener = new SubscriptionsChangeListener(context, this);
|
||||
mIsRtlMode = context.getResources().getConfiguration().getLayoutDirection()
|
||||
== View.LAYOUT_DIRECTION_RTL;
|
||||
}
|
||||
|
||||
public void init(Lifecycle lifecycle) {
|
||||
@@ -285,4 +289,8 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere
|
||||
refreshSummary(mPreference);
|
||||
}
|
||||
}
|
||||
|
||||
boolean isRtlMode() {
|
||||
return mIsRtlMode;
|
||||
}
|
||||
}
|
||||
|
@@ -99,6 +99,7 @@ public class MobileNetworkUtils {
|
||||
"esim.enable_esim_system_ui_by_default";
|
||||
private static final String LEGACY_ACTION_CONFIGURE_PHONE_ACCOUNT =
|
||||
"android.telecom.action.CONNECTION_SERVICE_CONFIGURE";
|
||||
private static final String RTL_MARK = "\u200F";
|
||||
|
||||
// The following constants are used to draw signal icon.
|
||||
public static final int NO_CELL_DATA_TYPE_ICON = 0;
|
||||
@@ -921,7 +922,7 @@ public class MobileNetworkUtils {
|
||||
/**
|
||||
* Returns preferred status of Calls & SMS separately when Provider Model is enabled.
|
||||
*/
|
||||
public static CharSequence getPreferredStatus(Context context,
|
||||
public static CharSequence getPreferredStatus(boolean isRtlMode, Context context,
|
||||
SubscriptionManager subscriptionManager, boolean isPreferredCallStatus) {
|
||||
final List<SubscriptionInfo> subs = SubscriptionUtil.getActiveSubscriptions(
|
||||
subscriptionManager);
|
||||
@@ -955,6 +956,10 @@ public class MobileNetworkUtils {
|
||||
if (subInfo != subs.get(subs.size() - 1)) {
|
||||
summary.append(", ");
|
||||
}
|
||||
|
||||
if (isRtlMode) {
|
||||
summary.insert(0, RTL_MARK).insert(summary.length(), RTL_MARK);
|
||||
}
|
||||
}
|
||||
return summary;
|
||||
} else {
|
||||
|
@@ -62,7 +62,7 @@ public class SmsDefaultSubscriptionController extends DefaultSubscriptionControl
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
if (Utils.isProviderModelEnabled(mContext)) {
|
||||
return MobileNetworkUtils.getPreferredStatus(mContext, mManager, false);
|
||||
return MobileNetworkUtils.getPreferredStatus(isRtlMode(), mContext, mManager, false);
|
||||
} else {
|
||||
return super.getSummary();
|
||||
}
|
||||
|
Reference in New Issue
Block a user