Fix limit data usage dialog body not being translated.

- need to pass the resource id instead of the text when building the
dialog in order for it to react to language change.
- also remove the unnecessary set/get the body message in the dialog
creation since the msg id can be used directly.

Change-Id: I399dcda54961fac457fc5f0fad9082f2c1e1a2b2
Fixes: 77897157
Test: run i18nscreenshots
This commit is contained in:
Doris Ling
2018-04-19 16:35:28 -07:00
parent dbe38b09cf
commit 689bb2c27c

View File

@@ -402,7 +402,6 @@ public class BillingCycleSettings extends DataUsageBase implements
*/
public static class ConfirmLimitFragment extends InstrumentedDialogFragment implements
DialogInterface.OnClickListener {
private static final String EXTRA_MESSAGE = "message";
@VisibleForTesting static final String EXTRA_LIMIT_BYTES = "limitBytes";
public static final float FLOAT = 1.2f;
@@ -414,16 +413,13 @@ public class BillingCycleSettings extends DataUsageBase implements
if (policy == null) return;
final Resources res = parent.getResources();
final CharSequence message;
final long minLimitBytes = (long) (policy.warningBytes * FLOAT);
final long limitBytes;
// TODO: customize default limits based on network template
message = res.getString(R.string.data_usage_limit_dialog_mobile);
limitBytes = Math.max(5 * GIB_IN_BYTES, minLimitBytes);
final Bundle args = new Bundle();
args.putCharSequence(EXTRA_MESSAGE, message);
args.putLong(EXTRA_LIMIT_BYTES, limitBytes);
final ConfirmLimitFragment dialog = new ConfirmLimitFragment();
@@ -441,11 +437,9 @@ public class BillingCycleSettings extends DataUsageBase implements
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
final CharSequence message = getArguments().getCharSequence(EXTRA_MESSAGE);
return new AlertDialog.Builder(context)
.setTitle(R.string.data_usage_limit_dialog_title)
.setMessage(message)
.setMessage(R.string.data_usage_limit_dialog_mobile)
.setPositiveButton(android.R.string.ok, this)
.setNegativeButton(android.R.string.cancel, null)
.create();