Merge "Revise strings as per string UX review" am: 110d7ff721
Change-Id: I523fe708d2ff6cacafec362c05e227ae5dda07c8
This commit is contained in:
@@ -23,6 +23,7 @@ import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.ims.ImsManager;
|
||||
import android.telephony.ims.ImsRcsManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
@@ -39,9 +40,11 @@ public class ContactDiscoveryDialogFragment extends InstrumentedDialogFragment
|
||||
implements DialogInterface.OnClickListener {
|
||||
|
||||
private static final String SUB_ID_KEY = "sub_id_key";
|
||||
private static final String CARRIER_NAME_KEY = "carrier_name_key";
|
||||
private static final String DIALOG_TAG = "discovery_dialog:";
|
||||
|
||||
private int mSubId;
|
||||
private CharSequence mCarrierName;
|
||||
private ImsManager mImsManager;
|
||||
|
||||
/**
|
||||
@@ -50,10 +53,11 @@ public class ContactDiscoveryDialogFragment extends InstrumentedDialogFragment
|
||||
* @param subId The subscription ID to associate with this Dialog.
|
||||
* @return a new instance of ContactDiscoveryDialogFragment.
|
||||
*/
|
||||
public static ContactDiscoveryDialogFragment newInstance(int subId) {
|
||||
public static ContactDiscoveryDialogFragment newInstance(int subId, CharSequence carrierName) {
|
||||
final ContactDiscoveryDialogFragment dialogFragment = new ContactDiscoveryDialogFragment();
|
||||
final Bundle args = new Bundle();
|
||||
args.putInt(SUB_ID_KEY, subId);
|
||||
args.putCharSequence(CARRIER_NAME_KEY, carrierName);
|
||||
dialogFragment.setArguments(args);
|
||||
|
||||
return dialogFragment;
|
||||
@@ -64,18 +68,30 @@ public class ContactDiscoveryDialogFragment extends InstrumentedDialogFragment
|
||||
super.onAttach(context);
|
||||
final Bundle args = getArguments();
|
||||
mSubId = args.getInt(SUB_ID_KEY);
|
||||
mCarrierName = args.getCharSequence(CARRIER_NAME_KEY);
|
||||
mImsManager = getImsManager(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
final int title = R.string.contact_discovery_opt_in_dialog_title;
|
||||
int message = R.string.contact_discovery_opt_in_dialog_message;
|
||||
builder.setMessage(getResources().getString(message))
|
||||
CharSequence title;
|
||||
CharSequence message;
|
||||
if (!TextUtils.isEmpty(mCarrierName)) {
|
||||
title = getContext().getString(
|
||||
R.string.contact_discovery_opt_in_dialog_title, mCarrierName);
|
||||
message = getContext().getString(
|
||||
R.string.contact_discovery_opt_in_dialog_message, mCarrierName);
|
||||
} else {
|
||||
title = getContext().getString(
|
||||
R.string.contact_discovery_opt_in_dialog_title_no_carrier_defined);
|
||||
message = getContext().getString(
|
||||
R.string.contact_discovery_opt_in_dialog_message_no_carrier_defined);
|
||||
}
|
||||
builder.setMessage(message)
|
||||
.setTitle(title)
|
||||
.setIconAttribute(android.R.attr.alertDialogIcon)
|
||||
.setPositiveButton(android.R.string.ok, this)
|
||||
.setPositiveButton(R.string.confirmation_turn_on, this)
|
||||
.setNegativeButton(android.R.string.cancel, this);
|
||||
return builder.create();
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ import android.net.Uri;
|
||||
import android.os.PersistableBundle;
|
||||
import android.provider.Telephony;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.ims.ImsManager;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -34,6 +35,8 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.network.SubscriptionUtil;
|
||||
|
||||
|
||||
/**
|
||||
* Controller for the "Contact Discovery" option present in MobileNetworkSettings.
|
||||
@@ -130,7 +133,19 @@ public class ContactDiscoveryPreferenceController extends TelephonyTogglePrefere
|
||||
|
||||
private void showContentDiscoveryDialog() {
|
||||
ContactDiscoveryDialogFragment dialog = ContactDiscoveryDialogFragment.newInstance(
|
||||
mSubId);
|
||||
mSubId, getCarrierDisplayName(preference.getContext()));
|
||||
dialog.show(mFragmentManager, ContactDiscoveryDialogFragment.getFragmentTag(mSubId));
|
||||
}
|
||||
|
||||
private CharSequence getCarrierDisplayName(Context context) {
|
||||
CharSequence result = "";
|
||||
|
||||
for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(context)) {
|
||||
if (mSubId == info.getSubscriptionId()) {
|
||||
result = info.getDisplayName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -205,22 +205,32 @@ public class MobileNetworkActivity extends SettingsBaseActivity {
|
||||
final Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
final int subId = intent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL);
|
||||
if (subId != SUB_ID_NULL) {
|
||||
for (SubscriptionInfo subscription :
|
||||
SubscriptionUtil.getAvailableSubscriptions(this)) {
|
||||
if (subscription.getSubscriptionId() == subId) {
|
||||
return subscription;
|
||||
}
|
||||
}
|
||||
}
|
||||
SubscriptionInfo info = getSubscriptionInfo(subId);
|
||||
if (info != null) return info;
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(mSubscriptionInfos)) {
|
||||
return null;
|
||||
}
|
||||
return mSubscriptionInfos.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the subscription associated with a given subscription ID or null if none can be
|
||||
* found.
|
||||
*/
|
||||
SubscriptionInfo getSubscriptionInfo(int subId) {
|
||||
if (subId == SUB_ID_NULL) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (SubscriptionInfo subscription : SubscriptionUtil.getAvailableSubscriptions(this)) {
|
||||
if (subscription.getSubscriptionId() == subId) {
|
||||
return subscription;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current subId to display.
|
||||
*/
|
||||
@@ -340,6 +350,11 @@ public class MobileNetworkActivity extends SettingsBaseActivity {
|
||||
}
|
||||
|
||||
private void maybeShowContactDiscoveryDialog(int subId) {
|
||||
SubscriptionInfo info = getSubscriptionInfo(subId);
|
||||
CharSequence carrierName = "";
|
||||
if (info != null) {
|
||||
carrierName = info.getDisplayName();
|
||||
}
|
||||
// If this activity was launched using ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN, show the
|
||||
// associated dialog only if the opt-in has not been granted yet.
|
||||
boolean showOptInDialog = doesIntentContainOptInAction(getIntent())
|
||||
@@ -350,7 +365,7 @@ public class MobileNetworkActivity extends SettingsBaseActivity {
|
||||
ContactDiscoveryDialogFragment fragment = getContactDiscoveryFragment(subId);
|
||||
if (showOptInDialog) {
|
||||
if (fragment == null) {
|
||||
fragment = ContactDiscoveryDialogFragment.newInstance(subId);
|
||||
fragment = ContactDiscoveryDialogFragment.newInstance(subId, carrierName);
|
||||
}
|
||||
// Only try to show the dialog if it has not already been added, otherwise we may
|
||||
// accidentally add it multiple times, causing multiple dialogs.
|
||||
|
Reference in New Issue
Block a user