List of usage examples for android.app Notification setLatestEventInfo
@Deprecated public void setLatestEventInfo(Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent)
From source file:com.ubuntuone.android.files.service.UpDownService.java
public void onQuotaExceeded() { // Cancel all transfers. TransferUtils.setUploadsState(getContentResolver(), TransferState.FAILED); // Cancel retry alarm. Alarms.unregisterRetryFailedAlarm(); String title = "Insufficient storage space"; String text = "Select to buy more storage"; // Notify the user, suggest storage upgrade. Notification notification = new NotificationCompat.Builder(this).setOngoing(false).setTicker(title) .setSmallIcon(R.drawable.stat_u1_logo).setOnlyAlertOnce(true).setAutoCancel(true).getNotification(); final Intent intent = new Intent(UpDownService.this, PreferencesActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(PreferencesActivity.PURCHASE_STORAGE_SCREEN, 1); final PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), REQUEST_PURCHASE_SCREEN, intent, 0);/*w w w.ja v a2s.c om*/ notification.setLatestEventInfo(UpDownService.this, title, text, pi); notificationManager.notify(R.id.stat_quota_exceeded_id, notification); hasQuotaExceeded = true; }
From source file:com.ubuntuone.android.files.service.UpDownService.java
public void notifyRoamingSoAutoUploadDisabled() { final String title = "Roaming, Auto Upload disabled"; final String text = "To enable, change your settings."; Notification notification = new NotificationCompat.Builder(this).setOngoing(false) .setTicker("Roaming, Auto Upload disabled").setSmallIcon(R.drawable.stat_sys_upload_anim0) .setOnlyAlertOnce(true).setAutoCancel(true).getNotification(); final Intent intent = new Intent(UpDownService.this, PreferencesActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(PreferencesActivity.AUTOUPLOAD_SCREEN, 1); final PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), REQUEST_AUTOUPLOAD_SCREEN, intent, 0);// w w w . ja v a2s. c o m notification.setLatestEventInfo(UpDownService.this, title, text, pi); notificationManager.notify(R.id.stat_roaming_autoupload_off_id, notification); }
From source file:com.sdk.download.providers.downloads.DownloadNotification.java
private void updateCompletedNotification(Collection<DownloadInfo> downloads) { for (DownloadInfo download : downloads) { if (!isCompleteAndVisible(download)) { continue; }// w w w. jav a 2 s.c o m // Add the notifications Notification n = new Notification(); n.icon = android.R.drawable.stat_sys_download_done; n.flags |= Notification.FLAG_AUTO_CANCEL; long id = download.mId; String title = download.mTitle; if (title == null || title.length() == 0) { title = mContext.getResources().getString(R.string.zuimeia_sdk_download_download_unknown_title); } Uri contentUri = ContentUris.withAppendedId(Downloads.getAllDownloadsContentURI(mContext), id); String caption; Intent intent; if (Downloads.isStatusError(download.mStatus)) { caption = mContext.getResources() .getString(R.string.zuimeia_sdk_download_notification_download_failed); intent = new Intent(Constants.ACTION_LIST); } else { caption = mContext.getResources() .getString(R.string.zuimeia_sdk_download_notification_download_complete); if (download.mDestination == Downloads.DESTINATION_EXTERNAL) { intent = new Intent(Constants.ACTION_OPEN); } else { intent = new Intent(Constants.ACTION_LIST); } } intent.setClassName(mContext.getPackageName(), DownloadReceiver.class.getName()); intent.setData(contentUri); n.when = download.mLastMod; n.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast(mContext, 0, intent, 0)); intent = new Intent(Constants.ACTION_HIDE); intent.setClassName(mContext.getPackageName(), DownloadReceiver.class.getName()); intent.setData(contentUri); // n.deleteIntent = PendingIntent.getBroadcast(mContext, 0, intent, // 0); //notification?? mSystemFacade.postNotification(download.mId, n); } }
From source file:com.concentriclivers.mms.com.android.mms.transaction.MessagingNotification.java
private static void notifyFailed(Context context, boolean isDownload, long threadId, boolean noisy) { // TODO factor out common code for creating notifications boolean enabled = MessagingPreferenceActivity.getNotificationEnabled(context); if (!enabled) { return;/*from w w w . j a va2 s. c om*/ } // Strategy: // a. If there is a single failure notification, tapping on the notification goes // to the compose view. // b. If there are two failure it stays in the thread view. Selecting one undelivered // thread will dismiss one undelivered notification but will still display the // notification.If you select the 2nd undelivered one it will dismiss the notification. long[] msgThreadId = { 0, 1 }; // Dummy initial values, just to initialize the memory int totalFailedCount = getUndeliveredMessageCount(context, msgThreadId); if (totalFailedCount == 0 && !isDownload) { return; } // The getUndeliveredMessageCount method puts a non-zero value in msgThreadId[1] if all // failures are from the same thread. // If isDownload is true, we're dealing with 1 specific failure; therefore "all failed" are // indeed in the same thread since there's only 1. boolean allFailedInSameThread = (msgThreadId[1] != 0) || isDownload; Intent failedIntent; Notification notification = new Notification(); String title; String description; if (totalFailedCount > 1) { description = context.getString(R.string.notification_failed_multiple, Integer.toString(totalFailedCount)); title = context.getString(R.string.notification_failed_multiple_title); } else { title = isDownload ? context.getString(R.string.message_download_failed_title) : context.getString(R.string.message_send_failed_title); description = context.getString(R.string.message_failed_body); } TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context); if (allFailedInSameThread) { failedIntent = new Intent(context, ComposeMessageActivity.class); if (isDownload) { // When isDownload is true, the valid threadId is passed into this function. failedIntent.putExtra("failed_download_flag", true); } else { threadId = msgThreadId[0]; failedIntent.putExtra("undelivered_flag", true); } failedIntent.putExtra("thread_id", threadId); taskStackBuilder.addParentStack(ComposeMessageActivity.class); } else { failedIntent = new Intent(context, ConversationList.class); } taskStackBuilder.addNextIntent(failedIntent); notification.icon = R.drawable.stat_notify_sms_failed; notification.tickerText = title; notification.setLatestEventInfo(context, title, description, taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)); if (noisy) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); boolean vibrate = sp.getBoolean(MessagingPreferenceActivity.NOTIFICATION_VIBRATE, false /* don't vibrate by default */); if (vibrate) { notification.defaults |= Notification.DEFAULT_VIBRATE; } String ringtoneStr = sp.getString(MessagingPreferenceActivity.NOTIFICATION_RINGTONE, null); notification.sound = TextUtils.isEmpty(ringtoneStr) ? null : Uri.parse(ringtoneStr); } NotificationManager notificationMgr = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if (isDownload) { notificationMgr.notify(DOWNLOAD_FAILED_NOTIFICATION_ID, notification); } else { notificationMgr.notify(MESSAGE_FAILED_NOTIFICATION_ID, notification); } }
From source file:kr.co.bettersoft.checkmileage.activities.GCMIntentService.java
/** * generateNotification//from w ww.ja v a2s. co m * Issues a notification to inform the user that server has sent a message. * @param context * @param message * @return */ private void generateNotification(Context context, String message) { int icon = R.drawable.ic_stat_gcm; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); // sdf String title = context.getString(R.string.app_name); String mileageUpdateStr = context.getString(R.string.mileage_noti); Intent notificationIntent; /* * MILEAGE : ? ?? ? ???. * MARKETING : ?? ? ?. * Check Mileage ?. : test .. * * <string name="gcm_new_msgkkk"> </string> */ String new_msg = " "; if (message.equals(new_msg)) { Log.d(TAG, "new msg - test"); notificationIntent = new Intent(context, DummyActivity.class); // notificationIntent.putExtra("RunMode", "TEST"); // ?? ? . ?? .. ? .. notificationIntent.putExtra("RunMode", "MILEAGE"); // // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK // | Intent.FLAG_ACTIVITY_CLEAR_TOP // | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); // }else if(message.contains("MILEAGE")){ // }else if(message.contains(mileageUpdateStr)){ // ?? ?. () } else if (message.equals(mileageUpdateStr)) { // ?? ?. (). Log.d(TAG, "update mileage"); MyMileagePageActivity.searched = false; // notificationIntent = new Intent(context, MainActivity.class); // ? ? ?.. notificationIntent = new Intent(context, DummyActivity.class); notificationIntent.putExtra("RunMode", "MILEAGE"); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK // | Intent.FLAG_ACTIVITY_CLEAR_TOP // | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); } else if (message.equals("MARKETING")) { Log.d(TAG, "noti event push"); // notificationIntent = new Intent(context, MainActivity.class); // ? ? ? ? .. notificationIntent = new Intent(context, DummyActivity.class); notificationIntent.putExtra("RunMode", "MARKETING"); notificationIntent.putExtra("MESSAGE", "New Event"); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK // | Intent.FLAG_ACTIVITY_CLEAR_TOP // | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); } else { // ?. Log.d(TAG, "noti event push"); // notificationIntent = new Intent(context, MainActivity.class); // ? ? ? ? .. notificationIntent = new Intent(context, DummyActivity.class); notificationIntent.putExtra("RunMode", "MARKETING"); notificationIntent.putExtra("MESSAGE", message); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK // | Intent.FLAG_ACTIVITY_CLEAR_TOP // | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); } }
From source file:org.restcomm.app.qoslib.Services.Intents.IntentHandler.java
private void postSurvey(int surveyid) { int icon = 0; int customIcon = (owner.getResources().getInteger(R.integer.CUSTOM_NOTIFIER)); if (customIcon == 0) icon = R.drawable.ic_stat_mmcactive; else// w w w.j av a 2 s . c o m icon = R.drawable.ic_stat_notification_icon; if (surveyid > 0) { int curr_id = PreferenceManager.getDefaultSharedPreferences(owner).getInt("surveyid", 0); if (curr_id == surveyid) return; //resultIntent.putExtra("id", surveyid); requestQuestions(surveyid); } else { //default survey id = 1 //resultIntent.putExtra("id",1); requestQuestions(1); } String message = owner.getString(R.string.survey_notification); NotificationManager notificationManager = (NotificationManager) owner .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, System.currentTimeMillis()); notification.flags |= Notification.FLAG_AUTO_CANCEL; Intent notificationIntent = new Intent(); notificationIntent.setComponent( new ComponentName(owner.getPackageName(), "com.cortxt.app.mmcui.Activities.SatisfactionSurvey")); notificationIntent.putExtra("id", surveyid); notificationIntent.setData((Uri.parse("foobar://" + SystemClock.elapsedRealtime()))); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); int MMC_SURVEY_NOTIFICATION = 8011; PendingIntent pendingIntent = PendingIntent.getActivity(owner, MMC_SURVEY_NOTIFICATION + surveyid, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(owner, message, message, pendingIntent); notificationManager.notify(MMC_SURVEY_NOTIFICATION, notification); }
From source file:org.mariotaku.harmony.MusicPlaybackService.java
private void startSleepTimer(long milliseconds, boolean gentle) { Calendar now = Calendar.getInstance(); mCurrentTimestamp = now.getTimeInMillis(); mStopTimestamp = mCurrentTimestamp + milliseconds; int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM; format_flags |= DateUtils.FORMAT_SHOW_TIME; String time = DateUtils.formatDateTime(this, mStopTimestamp, format_flags); CharSequence contentTitle = getString(R.string.sleep_timer_enabled); CharSequence contentText = getString(R.string.notification_sleep_timer, time); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(), 0); Notification notification = new Notification(R.drawable.ic_stat_playback, null, 0); notification.flags = Notification.FLAG_ONGOING_EVENT; notification.icon = R.drawable.ic_stat_sleeptimer; notification.setLatestEventInfo(this, contentTitle, contentText, contentIntent); mGentleSleepTimer = gentle;/*from www . ja va 2 s .co m*/ mNotificationManager.notify(ID_NOTIFICATION_SLEEPTIMER, notification); mSleepTimerHandler.sendEmptyMessageDelayed(START_SLEEP_TIMER, milliseconds); final int nmin = (int) milliseconds / 60 / 1000; Toast.makeText(this, getResources().getQuantityString(R.plurals.NNNminutes_notif, nmin, nmin), Toast.LENGTH_SHORT).show(); }
From source file:com.android.mms.transaction.MessagingNotification.java
private static void notifyFailed(Context context, boolean isDownload, long threadId, boolean noisy) { // TODO factor out common code for creating notifications boolean enabled = MessagingPreferenceActivity.getNotificationEnabled(context); if (!enabled) { return;/* www. j a v a2s. c om*/ } // Strategy: // a. If there is a single failure notification, tapping on the notification goes // to the compose view. // b. If there are two failure it stays in the thread view. Selecting one undelivered // thread will dismiss one undelivered notification but will still display the // notification.If you select the 2nd undelivered one it will dismiss the notification. int totalFailedCount = getUndeliveredMessageCount(context); Intent failedIntent; Notification notification = new Notification(); String title; String description; if (totalFailedCount > 1) { description = context.getString(R.string.notification_failed_multiple, Integer.toString(totalFailedCount)); title = context.getString(R.string.notification_failed_multiple_title); } else { title = isDownload ? context.getString(R.string.message_download_failed_title) : context.getString(R.string.message_send_failed_title); description = context.getString(R.string.message_failed_body); } TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context); // Get failed intent by folder mode or conversation mode. if (MessageUtils.isMailboxMode()) { failedIntent = getFailedIntentFromFolderMode(context, totalFailedCount, isDownload); if (failedIntent == null) { return; } else if (isDownload) { // When isDownload is true, the valid threadId is passed into this function. failedIntent.putExtra(FAILED_DOWNLOAD_FLAG, true); } else { failedIntent.putExtra(UNDELIVERED_FLAG, true); } } else { failedIntent = getFailedIntentFromConversationMode(context, isDownload, threadId); } taskStackBuilder.addNextIntent(failedIntent); notification.icon = R.drawable.stat_notify_sms_failed; notification.tickerText = title; notification.setLatestEventInfo(context, title, description, taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)); if (noisy) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); boolean vibrate = sp.getBoolean(MessagingPreferenceActivity.NOTIFICATION_VIBRATE, false /* don't vibrate by default */); if (vibrate) { notification.defaults |= Notification.DEFAULT_VIBRATE; } String ringtoneStr = sp.getString(MessagingPreferenceActivity.NOTIFICATION_RINGTONE, null); notification.sound = TextUtils.isEmpty(ringtoneStr) ? null : Uri.parse(ringtoneStr); } NotificationManager notificationMgr = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if (isDownload) { notificationMgr.notify(DOWNLOAD_FAILED_NOTIFICATION_ID, notification); } else { notificationMgr.notify(MESSAGE_FAILED_NOTIFICATION_ID, notification); } }
From source file:de.tudresden.inf.rn.mobilis.mxa.XMPPRemoteService.java
/** * @author Tobias Rho// www. j a va 2 s . co m */ private void showConnectionNotification() { if (RUN_IN_FOREGROUND) { Notification note = new NotificationCompat.Builder(this) .setContentTitle(getString(R.string.sb_txt_title)) .setContentText(getString(R.string.sb_txt_text)).setSmallIcon(R.drawable.stat_notify_chat) .build(); Intent i = new Intent(this, MainActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0); note.setLatestEventInfo(this, getString(R.string.sb_txt_title), getString(R.string.sb_txt_text), pi); note.flags |= Notification.FLAG_NO_CLEAR; startForeground(NOTIFICATION_ID, note); } else { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification status = new Notification(R.drawable.stat_notify_chat, getString(R.string.sb_txt_text), System.currentTimeMillis()); status.setLatestEventInfo(XMPPRemoteService.this, getString(R.string.sb_txt_title), getString(R.string.sb_txt_text), PendingIntent.getActivity(XMPPRemoteService.this, 0, new Intent(ConstMXA.INTENT_SERVICEMONITOR), 0)); status.flags |= Notification.FLAG_ONGOING_EVENT; status.icon = R.drawable.stat_notify_chat; nm.notify(XMPPSERVICE_STATUS, status); } }
From source file:keyboard.ecloga.com.eclogakeyboard.EclogaKeyboard.java
@Override public void onKey(int primaryCode, int[] keyCodes) { final InputConnection ic = getCurrentInputConnection(); playClick();/* w w w .j a v a 2 s. c o m*/ printChar = true; if (primaryCode != 126 && primaryCode != -5 && primaryCode != -1 && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_1 && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_2 && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_3 && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_4 && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_5) { keyPressCounter++; if (keyPressCounter > 100 && keyPressCounter <= 1000 && keypresscounter1.equals("false")) { NotificationManager notif = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard", System.currentTimeMillis()); PendingIntent pending = PendingIntent.getActivity(this, 0, new Intent(this, Home.class), 0); notify.setLatestEventInfo(getApplicationContext(), "Warming up!", "Type more than 100 characters", pending); notif.notify(0, notify); Preferences.setDefaults("keypresscounter1", "true", getApplicationContext()); } else if (keyPressCounter > 10000 && keyPressCounter <= 10000 && keypresscounter2.equals("false")) { NotificationManager notif = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard", System.currentTimeMillis()); PendingIntent pending = PendingIntent.getActivity(this, 0, new Intent(this, Home.class), 0); notify.setLatestEventInfo(getApplicationContext(), "Keep it up!", "Type more than 1000 characters", pending); notif.notify(0, notify); Preferences.setDefaults("keypresscounter2", "true", getApplicationContext()); } else if (keyPressCounter > 10000 && keypresscounter3.equals("false")) { NotificationManager notif = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard", System.currentTimeMillis()); PendingIntent pending = PendingIntent.getActivity(this, 0, new Intent(this, Home.class), 0); notify.setLatestEventInfo(getApplicationContext(), "Typing master!", "Type more than 10000 characters", pending); notif.notify(0, notify); Preferences.setDefaults("keypresscounter3", "true", getApplicationContext()); } Preferences.setDefaults("keypresses", String.valueOf(keyPressCounter), getApplicationContext()); } switch (primaryCode) { case 58: ic.commitText(":", 1); if (autoSpacing) { ic.commitText(" ", 1); } break; case 59: ic.commitText(";", 1); if (autoSpacing) { ic.commitText(" ", 1); } break; case 33: ic.commitText("!", 1); if (autoSpacing) { ic.commitText(" ", 1); } if (autoCapitalize) { caps = true; keyboard.setShifted(caps); kv.invalidateAllKeys(); printChar = false; } break; case 63: ic.commitText("?", 1); if (autoSpacing) { ic.commitText(" ", 1); } if (autoCapitalize) { caps = true; keyboard.setShifted(caps); kv.invalidateAllKeys(); printChar = false; } break; case -5: if (lang.equals("seclang")) { if (orient.equals("portrait")) { keyboard = prilang; } else if (orient.equals("landscape")) { keyboard = prilang_landscape; } kv.setKeyboard(keyboard); kv.invalidateAllKeys(); lang = "prilang"; } else if (lang.equals("prilang")) { if (orient.equals("portrait")) { keyboard = seclang; } else if (orient.equals("landscape")) { keyboard = seclang_landscape; } kv.setKeyboard(keyboard); kv.invalidateAllKeys(); lang = "seclang"; } break; case 32: ic.commitText(" ", 1); if (autoCapitalize) { if (String.valueOf(ic.getTextBeforeCursor(2, 0)).equals(". ")) { caps = true; keyboard.setShifted(caps); kv.invalidateAllKeys(); printChar = false; } } break; case 126: ic.deleteSurroundingText(1, 0); if (autoCapitalize) { if (String.valueOf(ic.getTextBeforeCursor(1, 0)).equals(".") || String.valueOf(ic.getTextBeforeCursor(2, 0)).equals(". ") || String.valueOf(ic.getTextBeforeCursor(2, 0)).equals("")) { caps = true; keyboard.setShifted(caps); kv.invalidateAllKeys(); printChar = false; } } break; case 44: ic.commitText(",", 1); if (autoSpacing) { ic.commitText(" ", 1); } break; case 46: ic.commitText(".", 1); if (autoSpacing) { ic.commitText(" ", 1); } if (autoCapitalize) { caps = true; keyboard.setShifted(caps); kv.invalidateAllKeys(); printChar = false; } break; case -1: ic.performEditorAction(EditorInfo.IME_ACTION_GO); break; case EmojiKeyboardView.KEYCODE_EMOJI_1: keyboard = new Keyboard(this, R.xml.emoji_a1); kv.setKeyboard(keyboard); kv.invalidateAllKeys(); emoji = 1; eScreen = 1; break; case EmojiKeyboardView.KEYCODE_EMOJI_2: keyboard = new Keyboard(this, R.xml.emoji_b1); kv.setKeyboard(keyboard); kv.invalidateAllKeys(); emoji = 2; eScreen = 1; break; case EmojiKeyboardView.KEYCODE_EMOJI_3: keyboard = new Keyboard(this, R.xml.emoji_c1); kv.setKeyboard(keyboard); kv.invalidateAllKeys(); emoji = 3; eScreen = 1; break; case EmojiKeyboardView.KEYCODE_EMOJI_4: keyboard = new Keyboard(this, R.xml.emoji_d1); kv.setKeyboard(keyboard); kv.invalidateAllKeys(); emoji = 4; eScreen = 1; break; case EmojiKeyboardView.KEYCODE_EMOJI_5: keyboard = new Keyboard(this, R.xml.emoji_e1); kv.setKeyboard(keyboard); kv.invalidateAllKeys(); emoji = 5; eScreen = 1; break; default: char code = (char) primaryCode; if (allCaps) { if (Character.isLetter(code) && capsLock) { code = Character.toLowerCase(code); } else if (Character.isLetter(code) && !capsLock) { code = Character.toUpperCase(code); } } else { if (Character.isLetter(code) && caps) { code = Character.toUpperCase(code); } } String character = String.valueOf(code); ic.commitText(character, 1); } if (printedDifferent) { ic.deleteSurroundingText(1, 0); } if (printedDot) { ic.deleteSurroundingText(1, 0); if (autoCapitalize) { caps = true; keyboard.setShifted(caps); kv.invalidateAllKeys(); printChar = false; } } if (doubleUp == 2) { capsChange(); } else { changeCaps(); } }