Example usage for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS

List of usage examples for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS.

Prototype

int HIDE_NOT_ALWAYS

To view the source code for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS.

Click Source Link

Document

Flag for #hideSoftInputFromWindow and InputMethodService#requestShowSelf(int) to indicate that the soft input window should normally be hidden, unless it was originally shown with #SHOW_FORCED .

Usage

From source file:it.reyboz.bustorino.ActivityMain.java

private void hideKeyboard() {
    View view = getCurrentFocus();
    if (view != null) {
        ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
                .hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }/*  w w w.j  av a2s  .com*/
}

From source file:ca.ramnansingh.randy.ibmwatsonspeechqa.AudioRecordTest.java

/**
 * Play TTS Audio data/*from  w w w. j  a  v  a 2 s . c  om*/
 *
 * @param view
 */
public void playTTS(View view) throws JSONException {

    TextToSpeech.sharedInstance().setVoice(fragmentTabTTS.getSelectedVoice());
    Log.d(TAG, fragmentTabTTS.getSelectedVoice());

    //Get text from text box
    textTTS = (TextView) fragmentTabTTS.mView.findViewById(R.id.prompt);
    String ttsText = textTTS.getText().toString();
    Log.d(TAG, ttsText);
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(textTTS.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

    //Call the sdk function
    TextToSpeech.sharedInstance().synthesize(ttsText);
}

From source file:nl.thehyve.transmartclient.MainActivity.java

private void hideKeyboard() {
    View view = getCurrentFocus();
    if (view != null) {
        ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
                .hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }//from  ww w  .jav a  2 s. c  o  m
}

From source file:com.nutsuser.ridersdomain.activities.LiveforDream.java

private void hideKeyboard() {
    // Check if no view has focus:
    View view = this.getCurrentFocus();
    if (view != null) {
        InputMethodManager inputManager = (InputMethodManager) this
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }//w  w w  .  j  av a2 s.c  o m
}

From source file:com.maskyn.fileeditorpro.activity.MainActivity.java

private void closeKeyBoard() throws NullPointerException {
    // Central system API to the overall input method framework (IMF) architecture
    InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    // Base interface for a remotable object
    IBinder windowToken = getCurrentFocus().getWindowToken();

    // Hide type//from w  w  w  .  j a  va2 s.c o m
    int hideType = InputMethodManager.HIDE_NOT_ALWAYS;

    // Hide the KeyBoard
    inputManager.hideSoftInputFromWindow(windowToken, hideType);
}

From source file:com.zertinteractive.wallpaper.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.e(LOG_TAG, "onCreate()");
    setContentView(R.layout.activity_main);
    context = this;
    checkPermission();/*ww w. ja  v  a2s.c om*/
    DetailActivity.setContext(this);
    initDownloadComponents();
    downloadTestImage();
    initSearchGridView();

    progressBar = (ProgressBar) findViewById(R.id.progressBarImageSearch);
    progressBar.setVisibility(View.GONE);

    searchQueryButton = (ImageView) findViewById(R.id.search_query_ok);
    searchQueryButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            in.hideSoftInputFromWindow(searchKey.getApplicationWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
            searchActionMethod();
        }
    });

    searchKey = (EditText) findViewById(R.id.search_key);
    searchKey.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            //                if (event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
            //                    InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            //                    in.hideSoftInputFromWindow(searchKey.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            //                    Log.e("SEARCH", searchKey.getText().toString());
            //                }
            searchActionMethod();
            return false;
        }
    });

    searchQueryClear = (ImageView) findViewById(R.id.search_query_clear);
    searchQueryClear.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            searchKey.setText("");
        }
    });

    // Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in
    // values/strings.xml.
    mAdView = (AdView) findViewById(R.id.adView);
    mAdView.setVisibility(View.GONE);

    //        mAdView.setScaleX(1.3f);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();

    // Start loading the ad in sthe background.
    mAdView.loadAd(adRequest);
    mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mAdView.setVisibility(View.VISIBLE);
        }
    });

    //        AdView mAdView = (AdView) findViewById(R.id.adView);
    //        AdRequest adRequest = new AdRequest.Builder().build();
    //        mAdView.loadAd(adRequest);

    initWallpaperLists();
    initRecyclerView(GRIDVIEW_COLUMN);
    initSearchView();
    initFab();
    initToolbar();
    setupDrawerLayout();
    setCategorySutter(false);
    categorySutterChange(1200);
    //        setNotification();

    setupWindowAnimations();

    reminderCount = 0;

    timerTasks = new TimerTasks(context);

    timerTasks.startTimerTask();

    currentWallpaperCategory = WallpaperCategory.ALL;
    DetailActivity.checkDir();

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        setRecyclerAdapter(recyclerView, 0);
        currentWallpaperCategory = WallpaperCategory.ALL;
    }

    LinearLayout categoryHappyWallpaper = (LinearLayout) findViewById(R.id.category_happy);
    LinearLayout categorySadWallpaper = (LinearLayout) findViewById(R.id.category_sad);
    LinearLayout categorySurpriseWallpaper = (LinearLayout) findViewById(R.id.category_surprise);
    LinearLayout categoryAngryWallpaper = (LinearLayout) findViewById(R.id.category_angry);
    LinearLayout categoryFunnyWallpaper = (LinearLayout) findViewById(R.id.category_funny);
    LinearLayout categoryAmazedWallpaper = (LinearLayout) findViewById(R.id.category_amazed);
    categoryHappyWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 1);
            currentWallpaperCategory = WallpaperCategory.HAPPY;
        }
    });
    categorySadWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 2);
            currentWallpaperCategory = WallpaperCategory.SAD;
        }
    });
    categorySurpriseWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 3);
            currentWallpaperCategory = WallpaperCategory.SURPRISE;
        }
    });
    categoryAngryWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 4);
            currentWallpaperCategory = WallpaperCategory.ANGRY;
        }
    });
    categoryFunnyWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 5);
            currentWallpaperCategory = WallpaperCategory.FUNNY;
        }
    });
    categoryAmazedWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 6);
            currentWallpaperCategory = WallpaperCategory.AMAZED;
        }
    });

    ImageView category_daily = (ImageView) findViewById(R.id.category_daily);
    ImageView category_featured = (ImageView) findViewById(R.id.category_featured);
    ImageView category_favourite = (ImageView) findViewById(R.id.category_favourite);
    category_daily.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 7);
            currentWallpaperCategory = WallpaperCategory.DAILY;
        }
    });
    category_featured.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 8);
            currentWallpaperCategory = WallpaperCategory.FEATURED;
        }
    });
    category_favourite.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 9);
            currentWallpaperCategory = WallpaperCategory.FAVOURITE;
        }
    });

    LinearLayout categoryWallpaper = (LinearLayout) findViewById(R.id.categoryButtonArrow);
    LinearLayout categoryAllWallpaper = (LinearLayout) findViewById(R.id.categoryWallpaper);
    LinearLayout kidsyWallpaperAction = (LinearLayout) findViewById(R.id.kidsyWallpaperAction);
    LinearLayout keepCalmWallpaperAction = (LinearLayout) findViewById(R.id.keepCalmWallpaperAction);
    LinearLayout romanticWallpaperAction = (LinearLayout) findViewById(R.id.romanticWallpaperAction);
    LinearLayout materialWallpaperAction = (LinearLayout) findViewById(R.id.materialWallpaperAction);
    categoryAllWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 0);
            currentWallpaperCategory = WallpaperCategory.ALL;
        }
    });
    categoryWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            categorySutterChange(600);
            //                YoYo.with(Techniques.RotateAntiClockWise)
            //                        .duration(300)
            //                        .interpolate(new AccelerateDecelerateInterpolator())
            //                        .withListener(new Animator.AnimatorListener() {
            //                            @Override
            //                            public void onAnimationStart(Animator animation) {
            //
            //                            }
            //
            //                            @Override
            //                            public void onAnimationEnd(Animator animation) {
            //
            //                            }
            //
            //                            @Override
            //                            public void onAnimationCancel(Animator animation) {
            //                                Toast.makeText(MainActivity.this, "canceled", Toast.LENGTH_SHORT).show();
            //                            }
            //
            //                            @Override
            //                            public void onAnimationRepeat(Animator animation) {
            //
            //                            }
            //                        })
            //                        .playOn(findViewById(R.id.categoryButtonArrow));
        }
    });
    kidsyWallpaperAction.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openUri(PLAY_STORE_URL);
        }
    });
    keepCalmWallpaperAction.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openUri(PLAY_STORE_URL);
        }
    });
    romanticWallpaperAction.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openUri(PLAY_STORE_URL);
        }
    });
    materialWallpaperAction.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openUri(PLAY_STORE_URL);
        }
    });

    //        Button button = (Button) findViewById(R.id.testButton);
    //        button.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Roboto-LightItalic.ttf");
    //                SnackbarManager.show(
    //                        SnackBar.with(MainActivity.this)
    //                                .text("Something has been done")
    //                                .actionLabel("Undo")
    //                                .margin(15, 15)
    //                                .backgroundDrawable(R.drawable.custom_shape)
    //                                .actionLabelTypeface(tf)
    //                                .actionListener(new ActionClickListener() {
    //                                    @Override
    //                                    public void onActionClicked(SnackBar snackBar) {
    //                                        Toast.makeText(MainActivity.this,
    //                                                "Action undone",
    //                                                Toast.LENGTH_SHORT).show();
    //                                    }
    //                                }));
    //            }
    //        });

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window w = getWindow();
        w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    } else {
        // do something for lower version
    }

    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (dy > 0 && isSearchOn && !isSearchAnimationRunning) {
                isSearchOn = false;
                isSearchAnimationRunning = true;
                YoYo.with(Techniques.ZoomOutPosition).duration(500)
                        .interpolate(new AccelerateDecelerateInterpolator())
                        .withListener(new Animator.AnimatorListener() {
                            @Override
                            public void onAnimationStart(Animator animation) {

                            }

                            @Override
                            public void onAnimationEnd(Animator animation) {
                                fabSearchWallpaper.setVisibility(View.GONE);
                                isSearchAnimationRunning = false;
                            }

                            @Override
                            public void onAnimationCancel(Animator animation) {
                                Toast.makeText(MainActivity.this, "canceled", Toast.LENGTH_SHORT).show();
                            }

                            @Override
                            public void onAnimationRepeat(Animator animation) {

                            }
                        }).playOn(findViewById(R.id.fab_search_wallpaper));
            } else if (dy < 0 && !isSearchOn && !isSearchAnimationRunning) {
                isSearchOn = true;
                isSearchAnimationRunning = true;
                fabSearchWallpaper.setVisibility(View.VISIBLE);
                YoYo.with(Techniques.ZoomInPosition).duration(500)
                        .interpolate(new AccelerateDecelerateInterpolator())
                        .withListener(new Animator.AnimatorListener() {
                            @Override
                            public void onAnimationStart(Animator animation) {

                            }

                            @Override
                            public void onAnimationEnd(Animator animation) {
                                isSearchAnimationRunning = false;
                            }

                            @Override
                            public void onAnimationCancel(Animator animation) {
                                Toast.makeText(MainActivity.this, "canceled", Toast.LENGTH_SHORT).show();
                            }

                            @Override
                            public void onAnimationRepeat(Animator animation) {

                            }
                        }).playOn(findViewById(R.id.fab_search_wallpaper));
            }
        }
    });

}

From source file:org.csware.ee.utils.Tools.java

/**
 * ??//from  w  ww .  j a  va 2 s  .c om
 * ??,??
 */
public static void toggleInput(Context context) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:edu.cmu.cylab.starslinger.view.MessagesFragment.java

@Override
public void onPause() {
    super.onPause();

    // if soft input open, close it...
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    View focus = getActivity().getCurrentFocus();
    if (focus != null) {
        imm.hideSoftInputFromWindow(focus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }//from   ww w  . j  a va2  s  .c om

    // save draft when view is lost
    doSave(mEditTextMessage.getText().toString(), mRecip != null);
}

From source file:org.onebusaway.android.util.UIUtils.java

/**
 * Open the soft keyboard//from  ww  w.  j ava  2  s. c  om
 */
public static void openKeyboard(Context context) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:com.jins_meme.bridge.MainActivity.java

void transitToFragment(Fragment next) {
    setUIPaused(false);/*from ww w .  j  ava2 s . c om*/
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(mainLayout.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

    FragmentManager manager = getSupportFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    transaction.setCustomAnimations(R.anim.config_in, android.R.anim.fade_out, android.R.anim.fade_in,
            R.anim.config_out2);
    transaction.replace(R.id.container, next);
    transaction.addToBackStack(null);
    transaction.commit();
}