/**
  * @param activity the context of the activity
  * @brief methods for showing the soft keyboard by forced
  */
 public static void showSoftKeyboard(Activity activity) {
   if (activity.getCurrentFocus() != null) {
     InputMethodManager inputMethodManager =
         (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
     inputMethodManager.showSoftInput(activity.getCurrentFocus(), 0);
   }
 }
示例#2
1
    @Override
    public void handleMessage(Message msg) {
      Context context = getContext();
      if (context == null) {
        Log.e(TAG, "error handling message, getContext() returned null");
        return;
      }
      switch (msg.arg1) {
        case COMMAND_CHANGE_TITLE:
          if (context instanceof Activity) {
            ((Activity) context).setTitle((String) msg.obj);
          } else {
            Log.e(TAG, "error handling message, getContext() returned no Activity");
          }
          break;
        case COMMAND_TEXTEDIT_HIDE:
          if (mTextEdit != null) {
            mTextEdit.setVisibility(View.GONE);

            InputMethodManager imm =
                (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
          }
          break;

        default:
          if ((context instanceof SDLActivity)
              && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) {
            Log.e(TAG, "error handling message, command is " + msg.arg1);
          }
      }
    }
示例#3
0
 public void showSoftKeyboard(View view) {
   if (view.requestFocus()) {
     InputMethodManager imm =
         (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
     imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
   }
 }
示例#4
0
  /**
   * Adding new task
   *
   * @param view
   */
  @SuppressLint("SimpleDateFormat")
  public void onClick(View view) {

    switch (view.getId()) {
      case R.id.button_add:
        Task task = new Task();
        EditText text = (EditText) findViewById(R.id.edit_text_task);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
        task.setText(text.getText().toString());
        task.setCreatedDate(sdf.format(new Date()));
        task.setUpdatedDate(sdf.format(new Date()));
        task.setArchived(false);
        task.setChecked(false);
        System.out.println(user.getName());
        task.setUsername(user.getName());

        long id = table.tasks.create(task);
        task.setId(id);

        this.tasks.add(task);
        text.setText("");
        text.clearFocus();
        InputMethodManager inputManager =
            (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(
            this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

        break;
    }
  }
示例#5
0
 public static void hideSoftKeyboard(Activity activity) {
   InputMethodManager inputMethodManager =
       (InputMethodManager)
           activity.getApplicationContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
   inputMethodManager.hideSoftInputFromWindow(
       activity.getWindow().getDecorView().getRootView().getWindowToken(), 0);
 }
 public void enableHousenumberView() {
   inputNotes.setCursorVisible(false);
   cursorVisible = false;
   InputMethodManager imm =
       (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
   imm.hideSoftInputFromWindow(inputNotes.getWindowToken(), 0);
 }
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
      // TODO Auto-generated method stub
      DiemPhoBien d1 = (DiemPhoBien) parent.getAdapter().getItem(position);

      // MainActivity.fragmentManager
      // .beginTransaction()
      // .setCustomAnimations(R.animator.slide_in_from_right,
      // R.animator.slide_out_to_left)
      // .replace(
      // R.id.frame_container,
      // new BustDetailFragment(b.getName(), b.getNumber(),
      // b.getTime(), b.getFreq(), b.getGo(), b
      // .getBack(), "BusList", isSearch))
      // .commit();
      if (!isKeyboardOpen) {
        GoogleAnalytic.sendActiontracker(
            MainActivity.mTracker,
            "Danh sách điểm phổ biến Screen",
            "View Diem_Pho_Bien Item",
            "Diem_Pho_Bien Item: " + d1.getName());
        textSearch.setText("");
        d.clear();
        d.add(d1);
        adapter.notifyDataSetChanged();
      }
      InputMethodManager imm =
          (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(textSearch.getWindowToken(), 0);
      isKeyboardOpen = false;
    }
示例#8
0
  /*
   * onKeyDown
   */
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (boundKeyCodes.contains(keyCode)) {
      if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        sendJavascriptEvent("volumedownbutton");
        return true;
      } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        sendJavascriptEvent("volumeupbutton");
        return true;
      } else {
        return super.onKeyDown(keyCode, event);
      }
    } else if (keyCode == KeyEvent.KEYCODE_BACK) {
      return !(this.startOfHistory()) || isButtonPlumbedToJs(KeyEvent.KEYCODE_BACK);

    } else if (keyCode == KeyEvent.KEYCODE_MENU) {
      // How did we get here?  Is there a childView?
      View childView = this.getFocusedChild();
      if (childView != null) {
        // Make sure we close the keyboard if it's present
        InputMethodManager imm =
            (InputMethodManager)
                cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(childView.getWindowToken(), 0);
        cordova.getActivity().openOptionsMenu();
        return true;
      } else {
        return super.onKeyDown(keyCode, event);
      }
    }
    return super.onKeyDown(keyCode, event);
  }
示例#9
0
 public void hideSoftwareKeyboard() {
   if (softwareKeyboardIsVisible) {
     InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
     imm.toggleSoftInput(0, 0);
   }
   softwareKeyboardIsVisible = false;
 }
示例#10
0
        public void run() {

          if (!isAuthenticated) {
            txtUsername.setEnabled(true);
            txtPassword.setEnabled(true);
            //                cbRem.setEnabled (true);
            btnSign.setEnabled(true);
            progressDialog.dismiss();
            new AlertDialog.Builder(LoginActivity.this)
                .setMessage("Login failed. Please try again.")
                .setNeutralButton(
                    "OK",
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                      }
                    })
                .show();
          } else {
            InputMethodManager imm =
                (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(txtPassword.getWindowToken(), 0);
            Intent loginIntent = new Intent(LoginActivity.this, HomeActivity.class);
            //                Intent loginIntent = new Intent (LoginActivity.this,
            //                        MessagesListActivity.class);
            LoginActivity.this.startActivity(loginIntent);
          }
        }
示例#11
0
  // check if soft keyboard is open
  public static void softKeyboardIsOpen(Solo solo) throws Exception {

    InputMethodManager imm =
        (InputMethodManager)
            solo.getCurrentActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    junit.framework.Assert.assertTrue("Keyboard is inactive.", imm.isActive());
  }
 public void hideSoftKeyboard() {
   if (getCurrentFocus() != null) {
     InputMethodManager inputMethodManager =
         (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
     inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
   }
 }
 /**
  * Hide soft keyboard (if no hardware keyboard).
  *
  * @param context the context
  * @param view the focused view
  */
 public static void hideKeyboard(Activity context, View view) {
   InputMethodManager imm =
       (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
   if (imm != null) {
     imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
   }
 }
 /**
  * Show soft keyboard (if no hardware keyboard).
  *
  * @param context the context
  * @param view the focused view
  */
 public static void showKeyboard(Activity context, View view) {
   InputMethodManager imm =
       (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
   if (imm != null) {
     imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
   }
 }
示例#15
0
 private void hideSoftKeyboard() {
   View view = Register.this.getCurrentFocus();
   if (view != null) {
     InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
     imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
   }
 }
示例#16
0
 public void onClickBtn(View v) throws IOException {
   String searchTxt = edit.getText().toString();
   searchTxt.trim();
   View view = this.getCurrentFocus();
   if (view != null) {
     InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
     imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
   }
   if (!searchTxt.isEmpty()) {
     String temp = searchTxt;
     if (searchTxt.contains(" ")) {
       temp = searchTxt.replace(" ", "+");
     }
     searchTerm = temp;
     progress.show();
     SearchOnDailyMotion(temp, 1);
     searchOnYoutube(temp);
     SearchOnVimeo(temp);
     pageCount = 1;
     ShowMore = true;
     searchResults.clear();
   } else {
     Toast.makeText(context, "Please Enter Something", Toast.LENGTH_SHORT).show();
   }
 }
示例#17
0
 @Override
 public void onClick(View arg0) {
   // TODO Auto-generated method stub
   switch (arg0.getId()) {
     case R.id.bGo:
       String theWebsite = url.getText().toString();
       ourBrow.loadUrl(theWebsite);
       // Hiding the keyboard after using EditText
       InputMethodManager imm =
           (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
       imm.hideSoftInputFromWindow(url.getWindowToken(), 0);
       break;
     case R.id.bBack:
       if (ourBrow.canGoBack()) ourBrow.goBack();
       break;
     case R.id.bForward:
       if (ourBrow.canGoForward()) ourBrow.goForward();
       break;
     case R.id.bRefresh:
       ourBrow.reload();
       break;
     case R.id.bHistory:
       ourBrow.clearHistory();
       break;
   }
 }
 /**
  * @param activity the context of the activity
  * @brief methods for hiding the soft keyboard by forced
  */
 public static void hideSoftKeyboard(Activity activity) {
   if (activity.getCurrentFocus() != null) {
     InputMethodManager inputMethodManager =
         (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
     inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
   }
 }
 // 统计处理点击
 @OnClick({
   R.id.topic_image,
   R.id.topic_add_layout,
   R.id.base_ll_right_btns,
   R.id.topic_category_text_view
 })
 private void clickEvent(View view) {
   switch (view.getId()) {
       // 头像点击
     case R.id.topic_image:
       showChoiceImageAlert();
       break;
       // 选择类型
     case R.id.topic_category_text_view:
       choiceCategory();
       break;
     case R.id.topic_add_layout:
       InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
       imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
       break;
     case R.id.base_ll_right_btns:
       // 完成
       createNewGroupFinish();
       break;
     default:
       break;
   }
 }
示例#20
0
 /**
  * @param show
  * @param InputMethodManagerFlags 0 for regular (good for regular hide). or can use something like
  *     InputMethodManager.SHOW_FORCED or InputMethodManager.SHOW_IMPLICIT
  */
 public void hideShowKeyboard(boolean show, int InputMethodManagerFlags) {
   if (inputMethodManager == null) inputMethodManager = superTextActivity.getInputMethodManager();
   if (show) inputMethodManager.showSoftInput(autoCompleteTextView, InputMethodManagerFlags);
   else
     inputMethodManager.hideSoftInputFromWindow(
         autoCompleteTextView.getWindowToken(), InputMethodManagerFlags);
 }
示例#21
0
  /** *** CHECK FOR EMPTY FIELDS **** */
  private void checkEmpty() {

    /* HIDE THE KEYBOARD */
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(edtDishName.getWindowToken(), 0);

    /** GET THE REQUIRED DATA * */
    MEAL_NAME = edtDishName.getText().toString();
    MEAL_DESCRIPTION = edtDishDescription.getText().toString();
    MEAL_PRICE = edtDishPrice.getText().toString();

    if (MEAL_NAME.length() == 0) {
      inputDishName.setError("Menu / Dish name cannot be empty!");
      edtDishName.requestFocus();
    } else if (MEAL_DESCRIPTION.length() == 0) {
      inputDishDescription.setError("Please provide the Menu / Dish Description");
      edtDishDescription.requestFocus();
    } else if (MEAL_PRICE.length() == 0) {
      inputDishPrice.setError("The Menu / Dish needs to have a Price");
      edtDishPrice.requestFocus();
    } else {
      /* REMOVE THE ERRORS (IF SHOWN) */
      inputDishName.setErrorEnabled(false);
      inputDishDescription.setErrorEnabled(false);
      inputDishPrice.setErrorEnabled(false);

      /* CHECK FOR UNIQUE MENU / DISH NAME */
      new checkUniqueDishName().execute();
    }
  }
    public void handleLetterPress(
        KeyEvent event, int keyCode, Device.DeviceType mDeviceType, IBinder windowToken) {
      if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) {
        // ---Done/Enter button was pressed---
        InputMethodManager keyboard =
            (InputMethodManager)
                ApplicationContext.getInstance().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (keyboard != null) {
          try {
            keyboard.hideSoftInputFromWindow(windowToken, 0);
          } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage(
                "KeyBindings", "KeyEventHandlers.handleLetterPress", e);
            Crashlytics.setString("KeyBindings", "KeyEventHandlers.handleLetterPress");
            Crashlytics.logException(e);

            if (ApplicationContext.DEBUG_MODE) e.printStackTrace();
          }
        }
      } else if (event.getKeyCode() != KeyEvent.KEYCODE_MENU) {
        if (!SearchFragmentTab.ENGLISH_KBD_BACKSPACE) {
          if (mDeviceType == Device.DeviceType.Google_TV) {
            // *---Goog TV custom keys mappings!---
            handleGoogTvKeyPress(event, keyCode);
          } else {
            handleNonGoogTvKeyPress(event, keyCode);
          }
        } else {
          SearchFragmentTab.ENGLISH_KBD_BACKSPACE = false;
        }
      }
    }
示例#23
0
 // 隐藏虚拟键盘
 public static void HideKeyboard(View v) {
   InputMethodManager imm =
       (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
   if (imm.isActive()) {
     imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
   }
 }
 private void hideSoftInput(View v) {
   InputMethodManager manager =
       (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
   if (manager != null) {
     manager.hideSoftInputFromWindow(v.getWindowToken(), 0);
   }
 }
示例#25
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.btn_title_bar_back:
       finish();
       break;
     case R.id.btn_send:
       send();
       break;
     case R.id.ll_input_root:
     case R.id.et_forward_content:
       faceKeyboard.setImageResource(R.drawable.happy_face);
       faceGrid.setVisibility(View.GONE);
       inputMethodManager.showSoftInput(replyContent, InputMethodManager.SHOW_IMPLICIT);
       break;
     case R.id.btn_face_keyboard:
       if (faceGrid.getVisibility() == View.GONE) { // 先关闭输入法,再打开表情面板
         faceKeyboard.setImageResource(R.drawable.keyboard);
         inputMethodManager.hideSoftInputFromWindow(
             getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
         faceGrid.setVisibility(View.VISIBLE);
       } else { // 先关闭面板,再打开输入法
         faceKeyboard.setImageResource(R.drawable.happy_face);
         faceGrid.setVisibility(View.GONE);
         inputMethodManager.showSoftInput(replyContent, InputMethodManager.SHOW_IMPLICIT);
       }
       break;
   }
 }
示例#26
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search);

    // TODO: create layout
    mHistoryAdapter = new SearchHistoryAdapter(this);
    mResultAdapter = new SearchResultAdapter(this);

    mSearchText = (EditText) findViewById(R.id.search_text);
    mSearchText.setOnEditorActionListener(searchTextListener);
    mSearchText.addTextChangedListener(searchTextWatcher);

    final Intent queryIntent = getIntent();
    final String queryAction = queryIntent.getAction();
    if (Intent.ACTION_SEARCH.equals(queryAction)) {
      String query = queryIntent.getStringExtra(SearchManager.QUERY);
      mSearchText.setText(query);
      mSearchText.setSelection(query.length());
    } else {
      InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.showSoftInput(mSearchText, InputMethodManager.RESULT_SHOWN);
      showSearchHistory();
    }

    mSearchText.requestFocus();
  }
示例#27
0
  @SuppressWarnings("deprecation") // InputMethodSubtype.getLocale() deprecated in API 24
  private void recordKeyboardLocaleUma() {
    InputMethodManager imm =
        (InputMethodManager) mAppContext.getSystemService(Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> ims = imm.getEnabledInputMethodList();
    ArrayList<String> uniqueLanguages = new ArrayList<>();
    for (InputMethodInfo method : ims) {
      List<InputMethodSubtype> submethods = imm.getEnabledInputMethodSubtypeList(method, true);
      for (InputMethodSubtype submethod : submethods) {
        if (submethod.getMode().equals("keyboard")) {
          String language = submethod.getLocale().split("_")[0];
          if (!uniqueLanguages.contains(language)) {
            uniqueLanguages.add(language);
          }
        }
      }
    }
    RecordHistogram.recordCountHistogram("InputMethod.ActiveCount", uniqueLanguages.size());

    InputMethodSubtype currentSubtype = imm.getCurrentInputMethodSubtype();
    Locale systemLocale = Locale.getDefault();
    if (currentSubtype != null && currentSubtype.getLocale() != null && systemLocale != null) {
      String keyboardLanguage = currentSubtype.getLocale().split("_")[0];
      boolean match = systemLocale.getLanguage().equalsIgnoreCase(keyboardLanguage);
      RecordHistogram.recordBooleanHistogram("InputMethod.MatchesSystemLanguage", match);
    }
  }
示例#28
0
 public void toggleInput() {
   if (context != null) {
     InputMethodManager imm =
         (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
     imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
   }
 }
示例#29
0
 @Override
 public void setFocus(Context context) {
   // Hide the soft keyboard if it's showing.
   InputMethodManager inputManager =
       (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
   inputManager.hideSoftInputFromWindow(this.getWindowToken(), 0);
 }
示例#30
0
  private void updateGoButton(String text) {
    if (text.length() == 0) {
      mGoButton.setVisibility(View.GONE);
      return;
    }

    mGoButton.setVisibility(View.VISIBLE);

    int imageResource = R.drawable.ic_awesomebar_go;
    int imeAction = EditorInfo.IME_ACTION_GO;
    if (isSearchUrl(text)) {
      imageResource = R.drawable.ic_awesomebar_search;
      imeAction = EditorInfo.IME_ACTION_SEARCH;
    }
    mGoButton.setImageResource(imageResource);

    int actionBits = mText.getImeOptions() & EditorInfo.IME_MASK_ACTION;
    if (actionBits != imeAction) {
      InputMethodManager imm =
          (InputMethodManager) mText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
      int optionBits = mText.getImeOptions() & ~EditorInfo.IME_MASK_ACTION;
      mText.setImeOptions(optionBits | imeAction);
      imm.restartInput(mText);
    }
  }