List of usage examples for java.lang Character isLetter
public static boolean isLetter(int codePoint)
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. jav a2s . c om*/ 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(); } }
From source file:com.aengbee.android.leanback.ui.PlaybackOverlayCustomFragment.java
private boolean isAlphabet(int code) { return Character.isLetter(code); }
From source file:research.sg.edu.edapp.kb.KbSoftKeyboard.java
public void onKey(int primaryCode, int[] keyCodes) { /*String tap_file_name; String currentmood = "-99";/* w ww. ja v a 2s . c o m*/ boolean esm_event=false,esm_signal=false,esm_time=false; //SimpleDateFormat sdf = new SimpleDateFormat("yyyy:MM:dd__HH:mm:ss.SSS"); SimpleDateFormat sdf = new SimpleDateFormat(getResources().getString(R.string.time_format)); String currentDateandTime = sdf.format(new Date()); //boolean mood_rdy_to_record; //Store the timestamp in SharedPref //SharedPreferences prefs = getApplicationContext().getSharedPreferences(getResources().getString(R.string.sharedpref_file), Context.MODE_WORLD_READABLE); SharedPreferences prefs = getApplicationContext().getSharedPreferences(getApplicationContext().getResources().getString(R.string.sharedpref_file), Context.MODE_WORLD_READABLE); //currentDateandTime1=prefs.getString("TimeStamp", "No Data"); //System.out.println("[TimeStamp:"+currentDateandTime1+"]"); //SharedPreferences.Editor editor = prefs.edit(); SharedPreferences.Editor seditor =prefs.edit(); seditor.putString(getResources().getString(R.string.sharedpref_tstamp), currentDateandTime); seditor.putString(getResources().getString(R.string.sharedpref_last_app_name), getAppName()); seditor.putBoolean(getResources().getString(R.string.sharedpref_mood_rdy_to_record), true); //seditor.putString(getResources().getString(R.string.sharedpref_last_app_name), getAppName()); //editor.apply(); seditor.apply(); seditor.commit(); //System.out.println("Current Mood to Record:"+prefs.getBoolean(getResources().getString(R.string.sharedpref_mood_rdy_to_record),false)); //Retrieve current mood from sharedpref try { Context con = getApplicationContext().createPackageContext(getResources().getString(R.string.moodrecorder_pkg), Context.CONTEXT_IGNORE_SECURITY); SharedPreferences mood_pref = con.getSharedPreferences(getResources().getString(R.string.tap_mood_sharedpref_file), Context.MODE_MULTI_PROCESS); currentmood = mood_pref.getString(getResources().getString(R.string.sharedpref_current_mood), "-99"); esm_event = mood_pref.getBoolean(getResources().getString(R.string.sharedpref_esm_event),false); esm_signal = mood_pref.getBoolean(getResources().getString(R.string.sharedpref_esm_signal),false); esm_time = mood_pref.getBoolean(getResources().getString(R.string.sharedpref_esm_time),false); System.out.println("Current Mood:" + currentmood); } catch (Exception e) { e.printStackTrace(); }*/ SimpleDateFormat sdf = new SimpleDateFormat(getResources().getString(R.string.time_format)); String currentDateandTime = sdf.format(new Date()); ContentValues values = new ContentValues(); values.put(KbTouchEvent.TouchEntry.TE_APP_NAME, getAppName()); values.put(KbTouchEvent.TouchEntry.TE_TIMESTAMP, currentDateandTime); //values.put(TouchEvent.TouchEntry.TE_KEY, String.valueOf((char)primaryCode)); values.put(KbTouchEvent.TouchEntry.TE_KEY, primaryCode); Uri uri = getContentResolver().insert(KbContentProvider.CONTENT_URI, values); //End of retrieving current mood from sharedpref //currentDateandTime1=prefs.getString("TimeStamp", "No Data"); //System.out.println("[TimeStamp:"+currentDateandTime1+"]"); String keypress = String.valueOf((char) primaryCode); Log.d("Key Pressed", keypress); System.out.println("Ascii value:" + (int) keypress.charAt(0)); /*if(Character.va >=){ }*/ //System.out.println("Alternate way key pressed:"+Character.toChars(primaryCode)[0]); /*String string_t; //string_t = currentDateandTime+ " ----> " + "X = " + x_Coordinate + ", Y = "+y_Coordinate+ "\n"; //string_t = getAppName() + "," + currentDateandTime+ "," + keypress + "\n"; string_t = getAppName() + "," + currentDateandTime + "," + currentmood + "," + esm_event + "," + esm_signal + "," + esm_time + "\n"; //tap_file_name = imei_no + getResources().getString(R.string.tap_file_postfix); tap_file_name = imei_no + "_" + tap_ctr + getResources().getString(R.string.tap_file_postfix); File tap_file = new File(dataDir, tap_file_name); try{ //String SDCARD = Environment.getExternalStorageDirectory().getAbsolutePath(); //String FILENAME = "keylogger.txt"; //File outfile = new File(SDCARD+File.separator+FILENAME); FileOutputStream fos = new FileOutputStream(tap_file,true); fos.write(string_t.getBytes()); fos.close(); }catch(Exception e) { Log.d("EXCEPTION",e.getMessage()); } //Checks file size and move to ToBeUploaded folder int tap_file_size = Integer.parseInt(String.valueOf(tap_file.length() / 1024)); //mood_file_size = mood_file_size /4; int tap_file_size_threshold = Integer.parseInt(getResources().getString(R.string.tap_file_size_limit)); System.out.println("Tap File Size:" + tap_file_size + ", Tap File Threshold:" + tap_file_size_threshold ); if (tap_file_size > tap_file_size_threshold) { int ctr = Integer.parseInt(tap_ctr) + 1; tap_ctr=String.valueOf(ctr); tap_ctr=String.format("%06d", Integer.parseInt(tap_ctr)); //String.format("%05d", Integer.parseInt(mood_ctr)); move_file(tap_file_name); }*/ /********************************************************important edit edit 6****************************************/ InputConnection ic = getCurrentInputConnection(); // playClick(primaryCode) String suggested_string = ""; /***********************************************************check edit***********************************************/ if (isWordSeparator(primaryCode)) { // Handle separator if (mComposing.length() > 0) { commitTyped(getCurrentInputConnection()); swipe = ""; } sendKey(primaryCode); updateShiftKeyState(getCurrentInputEditorInfo()); } else if (primaryCode == Keyboard.KEYCODE_DELETE) { handleBackspace(); } else if (primaryCode == Keyboard.KEYCODE_SHIFT) { handleShift(); } else if (primaryCode == Keyboard.KEYCODE_CANCEL) { handleClose(); return; } else if (primaryCode == KbLatinKeyboardView.KEYCODE_OPTIONS) { // Show a menu or somethin' } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE && mInputView != null) { Keyboard current = mInputView.getKeyboard(); if (current == mSymbolsKeyboard || current == mSymbolsShiftedKeyboard) { current = mQwertyKeyboard; } else { current = mSymbolsKeyboard; } mInputView.setKeyboard(current); if (current == mSymbolsKeyboard) { current.setShifted(false); } } else { /****************************************************************8default handling******************************************/ char code = (char) primaryCode; if (swipe2.length() != 0 && code != swipe2.charAt(swipe2.length() - 1)) { swipe2 += "+" + code; } if (frequent_char == 0 || frequent_char == code || frequent_char == test.charAt(0)) test += ".*" + code; else test += ".*" + frequent_char + ".*" + code; Log.d("Pattern", test); if (Character.isLetter(code) && mCapsLock) { code = Character.toUpperCase(code); } if (swipe2.length() < 3) { ic.commitText(String.valueOf(code), 1); swipe = ""; swipe2 = ""; } else { suggested_string = strings_matched(test); suggested_string += " "; if (suggested_string.length() <= 1) { ic.commitText(String.valueOf(code), 1); } else ic.commitText(suggested_string, suggested_string.length()); //handleCharacter(primaryCode, keyCodes); } } }
From source file:org.python.pydev.core.docutils.StringUtils.java
/** * //Python 3.0 can use unicode identifiers. So, the letter construct deals with that... * TOKEN : * Python identifiers *//from w w w. j a va 2s . com * { * < NAME: <LETTER> ( <LETTER> | <DIGIT>)* > * | * < #LETTER: * [ * "a"-"z", * "A"-"Z", * "_", * "\u0080"-"\uffff" //Anything more than 128 is considered valid (unicode range) * * ] * > * } * @param param * @return */ public static boolean isPythonIdentifier(final String param) { final int len = param.length(); if (len == 0) { return false; } char c = param.charAt(0); if (!Character.isLetter(c) && c != '_' && c <= 128) { return false; } for (int i = 1; i < len; i++) { c = param.charAt(i); if ((!Character.isLetter(c) && !Character.isDigit(c) && c != '_') && (c <= 128)) { return false; } } return true; }
From source file:com.strathclyde.highlightingkeyboard.SoftKeyboardService.java
/** * Helper to determine if a given character code is alphabetic. *///from ww w.j ava2s . c o m private boolean isAlphabet(int code) { if (Character.isLetter(code)) { return true; } else { return false; } }
From source file:com.moviejukebox.model.Library.java
private static Index indexByTitle(Iterable<Movie> moviesList) { Index index = new Index(); for (Movie movie : moviesList) { if (!movie.isExtra() && (!removeTitleExplodeSet || !movie.isSetMaster())) { String title = movie.getStrippedTitleSort(); if (title.length() > 0) { Character firstCharacter = Character.toUpperCase(title.charAt(0)); if (!Character.isLetter(firstCharacter)) { index.addMovie("09", movie); movie.addIndex(INDEX_TITLE, "09"); } else if (charGroupEnglish && ((firstCharacter >= 'A' && firstCharacter <= 'Z') || (firstCharacter >= 'a' && firstCharacter <= 'z'))) { index.addMovie("AZ", movie); movie.addIndex(INDEX_TITLE, "AZ"); } else { String newChar = StringTools.characterMapReplacement(firstCharacter); index.addMovie(newChar, movie); movie.addIndex(INDEX_TITLE, newChar); }//www . j av a 2s . c o m } } } return index; }
From source file:xc.mst.services.normalization.NormalizationService.java
/** * Creates a new 035 field on the record based on the existing 001 and 003 fields * for example, if 001 = 12345 and 003 = NRU, the new 035 will be (NRU)12345. * * @param marcXml/* w w w . j a v a 2 s . c o m*/ * The original MARCXML record * @return The MARCXML record after performing this normalization step. */ private MarcXmlManager moveMarcOrgCode(MarcXmlManager marcXml) { if (LOG.isDebugEnabled()) LOG.debug("Entering MoveMarcOrgCode normalization step."); // Get the 001 and 003 control fields String control001 = marcXml.getField001(); String control003 = marcXml.getField003(); if (control001 == null) { addMessage(marcXml.getInputRecord(), 103, RecordMessage.INFO); // addMessage(marcXml.getInputRecord(), 103, RecordMessage.INFO, " - Cannot create 035 from 001."); } // If either control field didn't exist, we don't have to do anything if (control001 == null || control003 == null) { if (LOG.isDebugEnabled()) LOG.debug( "The record was missing either an 001 or an 003 control field, so we do not have to move the old marc organization code into a new 035 field."); return marcXml; } boolean moveAllOrgCodes = enabledSteps.getProperty(CONFIG_MOVE_ALL_MARC_ORG_CODES, "0").equals("1"); // Create the new 035 field if (moveAllOrgCodes || control003.equalsIgnoreCase(getOrganizationCode())) { String new035 = null; if (Character.isLetter(control001.charAt(0))) { int index = 0; StringBuffer s = new StringBuffer(); while (Character.isLetter(control001.charAt(index))) { s.append(control001.charAt(index)); index++; } String new003 = s.toString(); control001 = control001.substring(new003.length()); new035 = "(" + new003 + ")" + control001; } else { new035 = "(" + control003 + ")" + control001; } if (LOG.isDebugEnabled()) LOG.debug("Moving the record's organization code to a new 035 field with value " + new035 + "."); // Add the new 035 field marcXml.addMarcXmlField("035", new035); } return marcXml; }
From source file:org.hl7.fhir.tools.implementations.java.JavaResourceGenerator.java
private String cleanSpName(String code) { StringBuilder b = new StringBuilder(); for (char c : code.toCharArray()) if (Character.isLetter(c)) { b.append(c);/*from w ww. java2 s . c o m*/ } else if (c == '-') { b.append('_'); } return b.toString(); }
From source file:org.apache.openjpa.jdbc.meta.ReverseMappingTool.java
/** * Return true if the given string is all uppercase letters. *///from www .j a v a2 s. c o m private static boolean allUpperCase(String str) { for (int i = 0; i < str.length(); i++) { if (Character.isLetter(str.charAt(i)) && !Character.isUpperCase(str.charAt(i))) return false; } return true; }
From source file:com.anysoftkeyboard.AnySoftKeyboard.java
@Override protected boolean isSuggestionAffectingCharacter(int code) { return super.isSuggestionAffectingCharacter(code) || Character.isLetter((char) code); }