List of usage examples for android.view.inputmethod InputMethodManager isFullscreenMode
public boolean isFullscreenMode()
From source file:org.cocos2dx.lib.TextInputWraper.java
private Boolean isFullScreenEdit() { InputMethodManager imm = (InputMethodManager) mMainView.getTextField().getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); return imm.isFullscreenMode(); }
From source file:org.mozilla.gecko.AwesomeBar.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(LOGTAG, "creating awesomebar"); mResolver = Tabs.getInstance().getContentResolver(); setContentView(R.layout.awesomebar); if (Build.VERSION.SDK_INT >= 11) { RelativeLayout actionBarLayout = (RelativeLayout) GeckoActionBar.getCustomView(this); mGoButton = (ImageButton) actionBarLayout.findViewById(R.id.awesomebar_button); mText = (AwesomeBarEditText) actionBarLayout.findViewById(R.id.awesomebar_text); } else {// w ww.ja v a 2 s .c om mGoButton = (ImageButton) findViewById(R.id.awesomebar_button); mText = (AwesomeBarEditText) findViewById(R.id.awesomebar_text); } TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs); tabWidget.setDividerDrawable(null); mAwesomeTabs = (AwesomeBarTabs) findViewById(R.id.awesomebar_tabs); mAwesomeTabs.setOnUrlOpenListener(new AwesomeBarTabs.OnUrlOpenListener() { public void onUrlOpen(String url) { openUrlAndFinish(url); } public void onSearch(String engine) { openSearchAndFinish(mText.getText().toString(), engine); } }); mGoButton.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { openUserEnteredAndFinish(mText.getText().toString()); } }); Resources resources = getResources(); int padding[] = { mText.getPaddingLeft(), mText.getPaddingTop(), mText.getPaddingRight(), mText.getPaddingBottom() }; GeckoStateListDrawable states = new GeckoStateListDrawable(); states.initializeFilter(GeckoApp.mBrowserToolbar.getHighlightColor()); states.addState(new int[] { android.R.attr.state_focused }, resources.getDrawable(R.drawable.address_bar_url_pressed)); states.addState(new int[] { android.R.attr.state_pressed }, resources.getDrawable(R.drawable.address_bar_url_pressed)); states.addState(new int[] {}, resources.getDrawable(R.drawable.address_bar_url_default)); mText.setBackgroundDrawable(states); mText.setPadding(padding[0], padding[1], padding[2], padding[3]); Intent intent = getIntent(); String currentUrl = intent.getStringExtra(CURRENT_URL_KEY); mType = intent.getStringExtra(TYPE_KEY); if (currentUrl != null) { mText.setText(currentUrl); mText.selectAll(); } mText.setOnKeyPreImeListener(new AwesomeBarEditText.OnKeyPreImeListener() { public boolean onKeyPreIme(View v, int keyCode, KeyEvent event) { // We only want to process one event per tap if (event.getAction() != KeyEvent.ACTION_DOWN) return false; if (keyCode == KeyEvent.KEYCODE_ENTER) { openUserEnteredAndFinish(mText.getText().toString()); return true; } // If input method is in fullscreen mode, we want to dismiss // it instead of closing awesomebar straight away. InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (keyCode == KeyEvent.KEYCODE_BACK && !imm.isFullscreenMode()) { // Let mAwesomeTabs try to handle the back press, since we may be in a // bookmarks sub-folder. if (mAwesomeTabs.onBackPressed()) return true; // If mAwesomeTabs.onBackPressed() returned false, we didn't move up // a folder level, so just exit the activity. cancelAndFinish(); return true; } return false; } }); mText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { // do nothing } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // do nothing } public void onTextChanged(CharSequence s, int start, int before, int count) { String text = s.toString(); mAwesomeTabs.filter(text); updateGoButton(text); } }); mText.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { if (event.getAction() != KeyEvent.ACTION_DOWN) return true; openUserEnteredAndFinish(mText.getText().toString()); return true; } else { return false; } } }); mText.setOnFocusChangeListener(new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } } }); registerForContextMenu(mAwesomeTabs.findViewById(R.id.all_pages_list)); registerForContextMenu(mAwesomeTabs.findViewById(R.id.bookmarks_list)); registerForContextMenu(mAwesomeTabs.findViewById(R.id.history_list)); GeckoAppShell.registerGeckoEventListener("SearchEngines:Data", this); GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:Get", null)); }
From source file:org.mozilla.gecko.GeckoApp.java
public void handleMessage(String event, JSONObject message) { Log.i(LOGTAG, "Got message: " + event); try {// w ww . j a va 2s. com if (event.equals("Menu:Add")) { ExtraMenuItem item = new ExtraMenuItem(); item.label = message.getString("name"); item.id = message.getInt("id"); try { // icon is optional item.icon = message.getString("icon"); } catch (Exception ex) { } sExtraMenuItems.add(item); } else if (event.equals("Menu:Remove")) { // remove it from the menu and from our vector Iterator<ExtraMenuItem> i = sExtraMenuItems.iterator(); int id = message.getInt("id"); while (i.hasNext()) { ExtraMenuItem item = i.next(); if (item.id == id) { sExtraMenuItems.remove(item); if (sMenu == null) return; MenuItem menu = sMenu.findItem(id); if (menu != null) sMenu.removeItem(id); } } } else if (event.equals("Toast:Show")) { final String msg = message.getString("message"); final String duration = message.getString("duration"); handleShowToast(msg, duration); } else if (event.equals("DOMContentLoaded")) { final int tabId = message.getInt("tabID"); final String uri = message.getString("uri"); final String title = message.getString("title"); handleContentLoaded(tabId, uri, title); Log.i(LOGTAG, "URI - " + uri + ", title - " + title); } else if (event.equals("DOMTitleChanged")) { final int tabId = message.getInt("tabID"); final String title = message.getString("title"); handleTitleChanged(tabId, title); Log.i(LOGTAG, "title - " + title); } else if (event.equals("DOMLinkAdded")) { final int tabId = message.getInt("tabID"); final String rel = message.getString("rel"); final String href = message.getString("href"); Log.i(LOGTAG, "link rel - " + rel + ", href - " + href); handleLinkAdded(tabId, rel, href); } else if (event.equals("DOMWindowClose")) { final int tabId = message.getInt("tabID"); handleWindowClose(tabId); } else if (event.equals("log")) { // generic log listener final String msg = message.getString("msg"); Log.i(LOGTAG, "Log: " + msg); } else if (event.equals("Content:LocationChange")) { final int tabId = message.getInt("tabID"); final String uri = message.getString("uri"); final String documentURI = message.getString("documentURI"); final String contentType = message.getString("contentType"); Log.i(LOGTAG, "URI - " + uri); handleLocationChange(tabId, uri, documentURI, contentType); } else if (event.equals("Content:SecurityChange")) { final int tabId = message.getInt("tabID"); final String mode = message.getString("mode"); Log.i(LOGTAG, "Security Mode - " + mode); handleSecurityChange(tabId, mode); } else if (event.equals("Content:StateChange")) { final int tabId = message.getInt("tabID"); int state = message.getInt("state"); Log.i(LOGTAG, "State - " + state); if ((state & GeckoAppShell.WPL_STATE_IS_NETWORK) != 0) { if ((state & GeckoAppShell.WPL_STATE_START) != 0) { Log.i(LOGTAG, "Got a document start"); final boolean showProgress = message.getBoolean("showProgress"); handleDocumentStart(tabId, showProgress); } else if ((state & GeckoAppShell.WPL_STATE_STOP) != 0) { Log.i(LOGTAG, "Got a document stop"); handleDocumentStop(tabId); } } } else if (event.equals("Content:LoadError")) { final int tabId = message.getInt("tabID"); final String uri = message.getString("uri"); final String title = message.getString("title"); handleLoadError(tabId, uri, title); } else if (event.equals("onCameraCapture")) { //GeckoApp.mAppContext.doCameraCapture(message.getString("path")); doCameraCapture(); } else if (event.equals("Doorhanger:Add")) { handleDoorHanger(message); } else if (event.equals("Doorhanger:Remove")) { handleDoorHangerRemove(message); } else if (event.equals("Gecko:Ready")) { sIsGeckoReady = true; mMainHandler.post(new Runnable() { public void run() { if (sMenu != null) sMenu.findItem(R.id.settings).setEnabled(true); } }); setLaunchState(LaunchState.GeckoRunning); GeckoAppShell.sendPendingEventsToGecko(); connectGeckoLayerClient(); } else if (event.equals("ToggleChrome:Hide")) { mMainHandler.post(new Runnable() { public void run() { mBrowserToolbar.hide(); } }); } else if (event.equals("ToggleChrome:Show")) { mMainHandler.post(new Runnable() { public void run() { mBrowserToolbar.show(); } }); } else if (event.equals("DOMFullScreen:Start")) { mDOMFullScreen = true; } else if (event.equals("DOMFullScreen:Stop")) { mDOMFullScreen = false; } else if (event.equals("FormAssist:AutoComplete")) { final JSONArray suggestions = message.getJSONArray("suggestions"); if (suggestions.length() == 0) { mMainHandler.post(new Runnable() { public void run() { mAutoCompletePopup.hide(); } }); } else { final JSONArray rect = message.getJSONArray("rect"); final double zoom = message.getDouble("zoom"); mMainHandler.post(new Runnable() { public void run() { // Don't show autocomplete popup when using fullscreen VKB InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); if (!imm.isFullscreenMode()) mAutoCompletePopup.show(suggestions, rect, zoom); } }); } } else if (event.equals("Permissions:Data")) { String host = message.getString("host"); JSONArray permissions = message.getJSONArray("permissions"); showSiteSettingsDialog(host, permissions); } else if (event.equals("Downloads:Done")) { String displayName = message.getString("displayName"); String path = message.getString("path"); String mimeType = message.getString("mimeType"); int size = message.getInt("size"); handleDownloadDone(displayName, path, mimeType, size); } else if (event.equals("CharEncoding:Data")) { final JSONArray charsets = message.getJSONArray("charsets"); int selected = message.getInt("selected"); final int len = charsets.length(); final String[] titleArray = new String[len]; for (int i = 0; i < len; i++) { JSONObject charset = charsets.getJSONObject(i); titleArray[i] = charset.getString("title"); } final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); dialogBuilder.setSingleChoiceItems(titleArray, selected, new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { JSONObject charset = charsets.getJSONObject(which); GeckoAppShell.sendEventToGecko( GeckoEvent.createBroadcastEvent("CharEncoding:Set", charset.getString("code"))); dialog.dismiss(); } catch (JSONException e) { Log.e(LOGTAG, "error parsing json", e); } } }); dialogBuilder.setNegativeButton(R.string.button_cancel, new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); mMainHandler.post(new Runnable() { public void run() { dialogBuilder.show(); } }); } else if (event.equals("CharEncoding:State")) { final boolean visible = message.getString("visible").equals("true"); GeckoPreferences.setCharEncodingState(visible); if (sMenu != null) { mMainHandler.post(new Runnable() { public void run() { sMenu.findItem(R.id.char_encoding).setVisible(visible); } }); } } else if (event.equals("Update:Restart")) { doRestart("org.mozilla.gecko.restart_update"); } else if (event.equals("Tab:HasTouchListener")) { int tabId = message.getInt("tabID"); Tab tab = Tabs.getInstance().getTab(tabId); tab.setHasTouchListeners(true); if (Tabs.getInstance().isSelectedTab(tab)) { mMainHandler.post(new Runnable() { public void run() { mLayerController.setWaitForTouchListeners(true); } }); } } else if (event.equals("Session:StatePurged")) { if (mAboutHomeContent != null) { mMainHandler.post(new Runnable() { public void run() { mAboutHomeContent.setLastTabsVisibility(false); } }); } } else if (event.equals("Bookmark:Insert")) { final String url = message.getString("url"); final String title = message.getString("title"); mMainHandler.post(new Runnable() { public void run() { Toast.makeText(GeckoApp.mAppContext, R.string.bookmark_added, Toast.LENGTH_SHORT).show(); GeckoAppShell.getHandler().post(new Runnable() { public void run() { BrowserDB.addBookmark(GeckoApp.mAppContext.getContentResolver(), title, url); } }); } }); } } catch (Exception e) { Log.e(LOGTAG, "Exception handling message \"" + event + "\":", e); } }
From source file:com.android.launcher2.Launcher.java
private boolean acceptFilter() { final InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); return !inputManager.isFullscreenMode(); }
From source file:com.android.mms.ui.ComposeMessageActivity.java
private void initRecipientsEditor() { if (isRecipientsEditorVisible()) { return;// www. j a va 2 s.c om } // Must grab the recipients before the view is made visible because getRecipients() // returns empty recipients when the editor is visible. ContactList recipients = getRecipients(); ViewStub stub = (ViewStub) findViewById(R.id.recipients_editor_stub); if (stub != null) { View stubView = stub.inflate(); mRecipientsEditor = (RecipientsEditor) stubView.findViewById(R.id.recipients_editor); mRecipientsPicker = (ImageButton) stubView.findViewById(R.id.recipients_picker); mRecipientsSelector = (ImageButton) stubView.findViewById(R.id.recipients_selector); mRecipientsSelector.setVisibility(View.VISIBLE); } else { mRecipientsEditor = (RecipientsEditor) findViewById(R.id.recipients_editor); mRecipientsEditor.setVisibility(View.VISIBLE); mRecipientsPicker = (ImageButton) findViewById(R.id.recipients_picker); mRecipientsSelector = (ImageButton) findViewById(R.id.recipients_selector); mRecipientsSelector.setVisibility(View.VISIBLE); } mRecipientsPicker.setOnClickListener(this); mRecipientsSelector.setOnClickListener(this); mRecipientsEditor.setAdapter(new ChipsRecipientAdapter(this)); mRecipientsEditor.populate(recipients); mRecipientsEditor.setOnCreateContextMenuListener(mRecipientsMenuCreateListener); mRecipientsEditor.addTextChangedListener(mRecipientsWatcher); // TODO : Remove the max length limitation due to the multiple phone picker is added and the // user is able to select a large number of recipients from the Contacts. The coming // potential issue is that it is hard for user to edit a recipient from hundred of // recipients in the editor box. We may redesign the editor box UI for this use case. // mRecipientsEditor.setFilters(new InputFilter[] { // new InputFilter.LengthFilter(RECIPIENTS_MAX_LENGTH) }); mRecipientsEditor.setOnSelectChipRunnable(new Runnable() { @Override public void run() { // After the user selects an item in the pop-up contacts list, move the // focus to the text editor if there is only one recipient. This helps // the common case of selecting one recipient and then typing a message, // but avoids annoying a user who is trying to add five recipients and // keeps having focus stolen away. if (mRecipientsEditor.getRecipientCount() == 1) { // if we're in extract mode then don't request focus final InputMethodManager inputManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); if (inputManager == null || !inputManager.isFullscreenMode()) { mTextEditor.requestFocus(); } } } }); mRecipientsEditor.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { RecipientsEditor editor = (RecipientsEditor) v; ContactList contacts = editor.constructContactsFromInput(false); updateTitle(contacts); } } }); PhoneNumberFormatter.setPhoneNumberFormattingTextWatcher(this, mRecipientsEditor); mTopPanel.setVisibility(View.VISIBLE); }