use of android.icu.text.MessageFormat in project j2objc by google.
the class TestMessageFormat method TestEquals.
@Test
public void TestEquals() {
MessageFormat x = new MessageFormat("There are {0} files on {1}");
MessageFormat y = new MessageFormat("There are {0} files on {1}");
if (!x.equals(y)) {
errln("First test (operator ==): Failed!");
}
}
use of android.icu.text.MessageFormat in project android_packages_apps_Settings by omnirom.
the class ZenModeBypassingAppsPreferenceController method updateAppsBypassingDndSummaryText.
@VisibleForTesting
void updateAppsBypassingDndSummaryText(List<ApplicationsState.AppEntry> apps) {
switch(getZenMode()) {
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
// users cannot change their DND settings when an app puts the device total
// silence or alarms only (both deprecated) modes
mPreference.setEnabled(false);
mSummary = mContext.getResources().getString(R.string.zen_mode_bypassing_apps_subtext_none);
return;
default:
mPreference.setEnabled(true);
}
if (apps == null) {
return;
}
Set<String> appsBypassingDnd = new ArraySet<>();
for (ApplicationsState.AppEntry entry : apps) {
String pkg = entry.info.packageName;
for (NotificationChannel channel : mNotificationBackend.getNotificationChannelsBypassingDnd(pkg, entry.info.uid).getList()) {
if (!TextUtils.isEmpty(channel.getConversationId()) && !channel.isDemoted()) {
// conversation channels that bypass dnd will be shown on the People page
continue;
}
appsBypassingDnd.add(BidiFormatter.getInstance().unicodeWrap(entry.label));
continue;
}
}
final int numAppsBypassingDnd = appsBypassingDnd.size();
String[] appsBypassingDndArr = appsBypassingDnd.toArray(new String[numAppsBypassingDnd]);
MessageFormat msgFormat = new MessageFormat(mContext.getString(R.string.zen_mode_bypassing_apps_subtext), Locale.getDefault());
Map<String, Object> args = new HashMap<>();
args.put("count", numAppsBypassingDnd);
if (numAppsBypassingDnd >= 1) {
args.put("app_1", appsBypassingDndArr[0]);
if (numAppsBypassingDnd >= 2) {
args.put("app_2", appsBypassingDndArr[1]);
if (numAppsBypassingDnd == 3) {
args.put("app_3", appsBypassingDndArr[2]);
}
}
}
mSummary = msgFormat.format(args);
refreshSummary(mPreference);
}
use of android.icu.text.MessageFormat in project android_packages_apps_Settings by omnirom.
the class ZenModeDurationPreferenceController method getSummary.
@Override
public CharSequence getSummary() {
String summary;
int zenDuration = getZenDuration();
if (zenDuration < 0) {
summary = mContext.getString(R.string.zen_mode_duration_summary_always_prompt);
} else if (zenDuration == 0) {
summary = mContext.getString(R.string.zen_mode_duration_summary_forever);
} else {
if (zenDuration >= 60) {
MessageFormat msgFormat = new MessageFormat(mContext.getString(R.string.zen_mode_duration_summary_time_hours), Locale.getDefault());
Map<String, Object> msgArgs = new HashMap<>();
msgArgs.put("count", zenDuration / 60);
summary = msgFormat.format(msgArgs);
} else {
MessageFormat msgFormat = new MessageFormat(mContext.getString(R.string.zen_mode_duration_summary_time_minutes), Locale.getDefault());
Map<String, Object> msgArgs = new HashMap<>();
msgArgs.put("count", zenDuration);
summary = msgFormat.format(msgArgs);
}
}
return summary;
}
use of android.icu.text.MessageFormat in project android_packages_apps_Settings by omnirom.
the class ZenModeBackend method getContactsNumberSummary.
String getContactsNumberSummary(Context context) {
MessageFormat msgFormat = new MessageFormat(mContext.getString(R.string.zen_mode_contacts_count), Locale.getDefault());
Map<String, Object> args = new HashMap<>();
args.put("count", queryAllContactsData().getCount());
return msgFormat.format(args);
}
use of android.icu.text.MessageFormat in project android_packages_apps_Settings by omnirom.
the class ChooseSimActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.choose_sim_activity);
Intent intent = getIntent();
mHasPsim = intent.getBooleanExtra(KEY_HAS_PSIM, false);
mNoPsimContinueToSettings = intent.getBooleanExtra(KEY_NO_PSIM_CONTINUE_TO_SETTINGS, false);
updateSubscriptions();
if (mEmbeddedSubscriptions.size() == 0) {
Log.e(TAG, "Unable to find available eSIM subscriptions.");
finish();
return;
}
if (savedInstanceState != null) {
mSelectedItemIndex = savedInstanceState.getInt(STATE_SELECTED_INDEX);
mIsSwitching = savedInstanceState.getBoolean(STATE_IS_SWITCHING);
}
GlifLayout layout = findViewById(R.id.glif_layout);
int subscriptionCount = mEmbeddedSubscriptions.size();
if (mHasPsim) {
// Choose a number to use
subscriptionCount++;
}
layout.setHeaderText(getString(R.string.choose_sim_title));
MessageFormat msgFormat = new MessageFormat(getString(R.string.choose_sim_text), Locale.getDefault());
Map<String, Object> arguments = new HashMap<>();
arguments.put("count", subscriptionCount);
layout.setDescriptionText(msgFormat.format(arguments));
displaySubscriptions();
mSwitchToRemovableSlotSidecar = SwitchToRemovableSlotSidecar.get(getFragmentManager());
mSwitchToEuiccSubscriptionSidecar = SwitchToEuiccSubscriptionSidecar.get(getFragmentManager());
}
Aggregations