Example usage for android.view.inputmethod InputMethodManager SHOW_IMPLICIT

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

Introduction

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

Prototype

int SHOW_IMPLICIT

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

Click Source Link

Document

Flag for #showSoftInput to indicate that this is an implicit request to show the input window, not as the result of a direct request by the user.

Usage

From source file:io.imoji.sdk.editor.fragment.TagImojiFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    //show keyboard
    mInputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    mInputMethodManager.showSoftInput(mTaggerEt, InputMethodManager.SHOW_IMPLICIT);

    mBitmapRetainerFragment = (ImojiEditorFragment.BitmapRetainerFragment) getFragmentManager()
            .findFragmentByTag(ImojiEditorFragment.BitmapRetainerFragment.FRAGMENT_TAG);
    if (mBitmapRetainerFragment == null || mBitmapRetainerFragment.mTrimmedBitmap == null) {
        getFragmentManager().popBackStack();
        return;/*from  w w w  . j av  a 2  s  .c o  m*/
    }

    final Bitmap imojiBitmap = mBitmapRetainerFragment.mTrimmedBitmap;
    getView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {

            if (Build.VERSION.SDK_INT >= 16) {
                getView().getViewTreeObserver().removeOnGlobalLayoutListener(this);
            } else {
                getView().getViewTreeObserver().removeGlobalOnLayoutListener(this);
            }

            final int width = mImojiIv.getWidth();
            final int height = mImojiIv.getHeight();

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                new OutlineAsyncTask(imojiBitmap, width, height, TagImojiFragment.this)
                        .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            } else {
                new OutlineAsyncTask(imojiBitmap, width, height, TagImojiFragment.this).execute();
            }
        }
    });
}

From source file:com.king.base.util.SystemUtils.java

/**
 * /*  w w  w .j a v  a  2 s . com*/
 *
 * @param context
 * @param v
 */
public static void showInputMethod(Context context, EditText v) {
    v.requestFocus();
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);
}

From source file:com.infigent.stocksense.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    startService(new Intent(this, BackGround.class));
    // setSlidingActionBarEnabled(true);
    Intent n = getIntent();//from  w w  w.  j  a v  a2s. c  o m
    if (getIntent() != null) {
        Bundle bundle = n.getExtras();
        if (bundle != null) {
            Log.e("ARG", "EXIST");
            if (bundle.containsKey("eq")) {
                Log.e("EQ", "EXIST");
                if (bundle.getBoolean("eq")) {
                    Log.e("eq", "true");
                    Bundle data = new Bundle();
                    Fragment4 eq = new Fragment4();
                    mContent = eq;
                    data.putString("q", bundle.getString("q"));
                    data.putString("type", bundle.getString("type"));
                    data.putString("name", bundle.getString("name"));
                    data.putString("f", gId());
                    eq.setArguments(data);
                    switchContent(eq);
                }
            }
        }
    }

    if (savedInstanceState != null)
        mContent = getSupportFragmentManager().getFragment(savedInstanceState, "mContent");
    if (mContent == null)
        mContent = new Fragment1();

    ScrollView scrollView = new ScrollView(this);
    LinearLayout l = new LinearLayout(this);
    TextView one = new TextView(this);
    one.setText(getResources().getString(R.string.intro));
    one.setPadding(0, 0, 0, 20);
    TextView two = new TextView(this);
    two.setText("Limited License");
    two.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView three = new TextView(this);
    three.setText(getResources().getString(R.string.l1));
    TextView four = new TextView(this);
    four.setText(getResources().getString(R.string.l2));
    four.setPadding(0, 0, 0, 20);
    TextView five = new TextView(this);
    five.setText("Disclaimer");
    five.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView six = new TextView(this);
    six.setText(getResources().getString(R.string.disclaimer1));
    TextView seven = new TextView(this);
    seven.setText(getResources().getString(R.string.disclaimer2));
    TextView eight = new TextView(this);
    eight.setText(getResources().getString(R.string.disclaimer3));
    eight.setPadding(0, 0, 0, 20);
    TextView nine = new TextView(this);
    nine.setText("Liability For Our Services");
    nine.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView ten = new TextView(this);
    ten.setText(getResources().getString(R.string.liability1));
    TextView eleven = new TextView(this);
    eleven.setText(getResources().getString(R.string.liability2));
    eleven.setPadding(0, 0, 0, 20);
    TextView twelve = new TextView(this);
    twelve.setText("Maintenance And Support");
    twelve.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView thirteen = new TextView(this);
    thirteen.setText(getResources().getString(R.string.ms));
    thirteen.setPadding(0, 0, 0, 20);
    TextView fourteen = new TextView(this);
    fourteen.setText("Links To Third Party Website");
    fourteen.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView fifteen = new TextView(this);
    fifteen.setText(getResources().getString(R.string.p3));
    l.addView(one);
    l.addView(two);
    l.addView(three);
    l.addView(four);
    l.addView(five);
    l.addView(six);
    l.addView(seven);
    l.addView(eight);
    l.addView(nine);
    l.addView(ten);
    l.addView(eleven);
    l.addView(twelve);
    l.addView(thirteen);
    l.addView(fourteen);
    l.addView(fifteen);
    one.setTextColor(getResources().getColor(R.color.White));
    two.setTextColor(getResources().getColor(R.color.White));
    three.setTextColor(getResources().getColor(R.color.White));
    four.setTextColor(getResources().getColor(R.color.White));
    five.setTextColor(getResources().getColor(R.color.White));
    six.setTextColor(getResources().getColor(R.color.White));
    seven.setTextColor(getResources().getColor(R.color.White));
    eight.setTextColor(getResources().getColor(R.color.White));
    nine.setTextColor(getResources().getColor(R.color.White));
    ten.setTextColor(getResources().getColor(R.color.White));
    eleven.setTextColor(getResources().getColor(R.color.White));
    twelve.setTextColor(getResources().getColor(R.color.White));
    thirteen.setTextColor(getResources().getColor(R.color.White));
    fourteen.setTextColor(getResources().getColor(R.color.White));
    fifteen.setTextColor(getResources().getColor(R.color.White));
    l.setOrientation(LinearLayout.VERTICAL);
    l.setBackgroundColor(getResources().getColor(R.color.bg));
    l.setPadding(10, 10, 10, 10);
    scrollView.addView(l);
    boolean firstboot = getSharedPreferences("BOOT_PREF", MODE_PRIVATE).getBoolean("firstboot", true);
    if (firstboot) {

        LayoutInflater inflater = getLayoutInflater();
        View vvv = inflater.inflate(R.layout.alerttitle, null);
        AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("Terms of Service")
                .setView(scrollView).setCustomTitle(vvv)
                .setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();

                        getSharedPreferences("BOOT_PREF", MODE_PRIVATE).edit().putBoolean("firstboot", false)
                                .commit();
                    }
                }).setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Close the activity as they have declined the EULA
                        MainActivity.this.finish();
                    }

                }).setCancelable(false);
        builder.create().show();
    }
    ime = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    ActionBar actionBar = getSupportActionBar();
    getSupportActionBar().setCustomView(R.layout.search);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    sb = (ImageButton) actionBar.getCustomView().findViewById(R.id.sb);
    title = (TextView) actionBar.getCustomView().findViewById(R.id.title);
    sb.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // only will trigger it if no physical keyboard is open
            search.setVisibility(View.VISIBLE);
            search.requestFocus();
            ime.showSoftInput(search, InputMethodManager.SHOW_IMPLICIT);
            search.setSelection(search.getText().length());
            sb.setVisibility(View.GONE);
            title.setVisibility(View.GONE);

        }
    });

    search = (AutoCompleteTextView) actionBar.getCustomView().findViewById(R.id.et);
    search.setThreshold(2);
    search.setAdapter(new SuggestionsAdapter(this, search.getText().toString()));
    search.setSelectAllOnFocus(true);
    search.clearFocus();

    search.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View arg1, int pos, long id) {
            String term = parent.getItemAtPosition(pos).toString();
            String[] lines = term.split("\\r?\\n");
            String name = lines[0];
            String code = lines[1].substring(lines[1].indexOf(":") + 1, lines[1].length()).trim();
            String type = lines[1].substring(0, lines[1].indexOf(":"));
            Log.d("DATA", name + " " + type + ":" + code);
            search.setText("");
            if (isNetworkAvailable()) {
                if (term.replace(" ", "") != null) {
                    Bundle data = new Bundle();
                    data.putString("q", code);
                    data.putString("type", type);
                    data.putString("name", name);
                    data.putString("f", gId());
                    Fragment4 eq = new Fragment4();
                    eq.setArguments(data);
                    Log.d("C", gId() + " frag");
                    mContent = eq;
                    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, eq).commit();
                    getSlidingMenu().showContent();
                    search.setVisibility(View.GONE);
                    sb.setVisibility(View.VISIBLE);
                    title.setVisibility(View.VISIBLE);
                    ime.hideSoftInputFromWindow(search.getApplicationWindowToken(), 0);
                } else {
                    Toast.makeText(getApplicationContext(), "Enter a search term!", Toast.LENGTH_LONG).show();
                }
            } else
                Toast.makeText(getApplicationContext(), "Internet not available", Toast.LENGTH_LONG).show();
        }
    });

    search.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

            return false;
        }
    });

    // set the Above View
    setContentView(R.layout.content_frame);
    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit();
    AdView mAdView;
    mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    // set the Behind View
    setBehindContentView(R.layout.menu_frame);
    getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame, new SampleListFragment()).commit();
}

From source file:io.demiseq.jetreader.activities.MainActivity.java

protected void toggleSearch(boolean reset) {
    if (reset) {//from   w  ww.  j av  a  2 s .c om
        // hide search box and show search icon
        searchBox.setText("");
        searchBox.setVisibility(View.GONE);
        toggle_btn.setVisible(true);
        // hide the keyboard
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(searchBox.getWindowToken(), 0);
    } else {
        // hide search icon and show search box
        toggle_btn.setVisible(false);
        searchBox.setVisibility(View.VISIBLE);
        searchBox.requestFocus();
        // show the keyboard
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(searchBox, InputMethodManager.SHOW_IMPLICIT);
    }
}

From source file:com.notepadlite.NoteEditFragment.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override/*from  w w w .j  a  va 2  s  .c o m*/
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // Set values
    setRetainInstance(true);
    setHasOptionsMenu(true);

    // Show the Up button in the action bar.
    ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Animate elevation change
    if (getActivity() instanceof MainActivity
            && getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large")
            && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        LinearLayout noteViewEdit = (LinearLayout) getActivity().findViewById(R.id.noteViewEdit);
        LinearLayout noteList = (LinearLayout) getActivity().findViewById(R.id.noteList);

        noteList.animate().z(0f);
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
            noteViewEdit.animate()
                    .z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation_land));
        else
            noteViewEdit.animate().z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation));
    }

    // Set up content view
    noteContents = (EditText) getActivity().findViewById(R.id.editText1);

    // Apply theme
    SharedPreferences pref = getActivity().getSharedPreferences(getActivity().getPackageName() + "_preferences",
            Context.MODE_PRIVATE);
    ScrollView scrollView = (ScrollView) getActivity().findViewById(R.id.scrollView1);
    String theme = pref.getString("theme", "light-sans");

    if (theme.contains("light")) {
        noteContents.setTextColor(getResources().getColor(R.color.text_color_primary));
        noteContents.setBackgroundColor(getResources().getColor(R.color.window_background));
        scrollView.setBackgroundColor(getResources().getColor(R.color.window_background));
    }

    if (theme.contains("dark")) {
        noteContents.setTextColor(getResources().getColor(R.color.text_color_primary_dark));
        noteContents.setBackgroundColor(getResources().getColor(R.color.window_background_dark));
        scrollView.setBackgroundColor(getResources().getColor(R.color.window_background_dark));
    }

    if (theme.contains("sans"))
        noteContents.setTypeface(Typeface.SANS_SERIF);

    if (theme.contains("serif"))
        noteContents.setTypeface(Typeface.SERIF);

    if (theme.contains("monospace"))
        noteContents.setTypeface(Typeface.MONOSPACE);

    switch (pref.getString("font_size", "normal")) {
    case "smallest":
        noteContents.setTextSize(12);
        break;
    case "small":
        noteContents.setTextSize(14);
        break;
    case "normal":
        noteContents.setTextSize(16);
        break;
    case "large":
        noteContents.setTextSize(18);
        break;
    case "largest":
        noteContents.setTextSize(20);
        break;
    }

    // Get filename
    try {
        if (!getArguments().getString("filename").equals("new")) {
            filename = getArguments().getString("filename");
            if (!filename.equals("draft"))
                isSavedNote = true;
        }
    } catch (NullPointerException e) {
        filename = "new";
    }

    // Load note from existing file
    if (isSavedNote) {
        try {
            contentsOnLoad = listener.loadNote(filename);
        } catch (IOException e) {
            showToast(R.string.error_loading_note);
            finish(null);
        }

        // Set TextView contents
        length = contentsOnLoad.length();
        noteContents.setText(contentsOnLoad);
        noteContents.setSelection(length, length);
    } else if (filename.equals("draft")) {
        SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
        String draftContents = sharedPref.getString("draft-contents", null);
        length = draftContents.length();
        noteContents.setText(draftContents);
        noteContents.setSelection(length, length);
    }

    // Show soft keyboard
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(noteContents, InputMethodManager.SHOW_IMPLICIT);

}

From source file:com.rong.library.widget.mapsearchbar.MapSearchBar.java

@Override
public void onFocusChange(View v, boolean hasFocus) {
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    if (hasFocus) {
        if (!focusCameFromHistory)
            imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);
        focusCameFromHistory = false;/* w w w.  jav a  2  s .c  o m*/

        isSearchEditFocused = true;
        if (adapter.getItemCount() > 0 && !suggestionsVisible)
            animateSuggestionList(0, getSuggestionHeight());

    } else {
        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

        isSearchEditFocused = false;
        if (suggestionsVisible)
            animateSuggestionList(-1, 0);
    }
}

From source file:com.anjalimacwan.fragment.NoteEditFragment.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override/*from  w  w  w.  j  a  v a 2  s .co  m*/
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // Set values
    setRetainInstance(true);
    setHasOptionsMenu(true);

    // Show the Up button in the action bar.
    ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Animate elevation change
    if (getActivity() instanceof MainActivity
            && getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large")
            && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        LinearLayout noteViewEdit = (LinearLayout) getActivity().findViewById(R.id.noteViewEdit);
        LinearLayout noteList = (LinearLayout) getActivity().findViewById(R.id.noteList);

        noteList.animate().z(0f);
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
            noteViewEdit.animate()
                    .z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation_land));
        else
            noteViewEdit.animate().z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation));
    }

    // Set up content view
    noteContents = (EditText) getActivity().findViewById(R.id.editText1);

    // Apply theme
    SharedPreferences pref = getActivity().getSharedPreferences(getActivity().getPackageName() + "_preferences",
            Context.MODE_PRIVATE);
    ScrollView scrollView = (ScrollView) getActivity().findViewById(R.id.scrollView1);
    String theme = pref.getString("theme", "light-sans");

    if (theme.contains("light")) {
        noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary));
        noteContents.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background));
        scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background));
    }

    if (theme.contains("dark")) {
        noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary_dark));
        noteContents.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark));
        scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark));
    }

    if (theme.contains("sans"))
        noteContents.setTypeface(Typeface.SANS_SERIF);

    if (theme.contains("serif"))
        noteContents.setTypeface(Typeface.SERIF);

    if (theme.contains("monospace"))
        noteContents.setTypeface(Typeface.MONOSPACE);

    switch (pref.getString("font_size", "normal")) {
    case "smallest":
        noteContents.setTextSize(12);
        break;
    case "small":
        noteContents.setTextSize(14);
        break;
    case "normal":
        noteContents.setTextSize(16);
        break;
    case "large":
        noteContents.setTextSize(18);
        break;
    case "largest":
        noteContents.setTextSize(20);
        break;
    }

    // Get filename
    try {
        if (!getArguments().getString("filename").equals("new")) {
            filename = getArguments().getString("filename");
            if (!filename.equals("draft"))
                isSavedNote = true;
        }
    } catch (NullPointerException e) {
        filename = "new";
    }

    // Load note from existing file
    if (isSavedNote) {
        try {
            contentsOnLoad = listener.loadNote(filename);
        } catch (IOException e) {
            showToast(R.string.error_loading_note);
            finish(null);
        }

        // Set TextView contents
        length = contentsOnLoad.length();
        noteContents.setText(contentsOnLoad);

        if (!pref.getBoolean("direct_edit", false))
            noteContents.setSelection(length, length);
    } else if (filename.equals("draft")) {
        SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
        String draftContents = sharedPref.getString("draft-contents", null);
        length = draftContents.length();
        noteContents.setText(draftContents);

        if (!pref.getBoolean("direct_edit", false))
            noteContents.setSelection(length, length);
    }

    // Show soft keyboard
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(noteContents, InputMethodManager.SHOW_IMPLICIT);

}

From source file:com.farmerbb.notepad.fragment.NoteEditFragment.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override//w w w.  j av  a  2 s .co m
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // Set values
    setRetainInstance(true);
    setHasOptionsMenu(true);

    // Show the Up button in the action bar.
    ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Animate elevation change
    if (getActivity() instanceof MainActivity
            && getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large")
            && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        LinearLayout noteViewEdit = getActivity().findViewById(R.id.noteViewEdit);
        LinearLayout noteList = getActivity().findViewById(R.id.noteList);

        noteList.animate().z(0f);
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
            noteViewEdit.animate()
                    .z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation_land));
        else
            noteViewEdit.animate().z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation));
    }

    // Set up content view
    noteContents = getActivity().findViewById(R.id.editText1);

    // Apply theme
    SharedPreferences pref = getActivity().getSharedPreferences(getActivity().getPackageName() + "_preferences",
            Context.MODE_PRIVATE);
    ScrollView scrollView = getActivity().findViewById(R.id.scrollView1);
    String theme = pref.getString("theme", "light-sans");

    if (theme.contains("light")) {
        noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary));
        noteContents.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background));
        scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background));
    }

    if (theme.contains("dark")) {
        noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary_dark));
        noteContents.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark));
        scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark));
    }

    if (theme.contains("sans"))
        noteContents.setTypeface(Typeface.SANS_SERIF);

    if (theme.contains("serif"))
        noteContents.setTypeface(Typeface.SERIF);

    if (theme.contains("monospace"))
        noteContents.setTypeface(Typeface.MONOSPACE);

    switch (pref.getString("font_size", "normal")) {
    case "smallest":
        noteContents.setTextSize(12);
        break;
    case "small":
        noteContents.setTextSize(14);
        break;
    case "normal":
        noteContents.setTextSize(16);
        break;
    case "large":
        noteContents.setTextSize(18);
        break;
    case "largest":
        noteContents.setTextSize(20);
        break;
    }

    // Get filename
    try {
        if (!getArguments().getString("filename").equals("new")) {
            filename = getArguments().getString("filename");
            if (!filename.equals("draft"))
                isSavedNote = true;
        }
    } catch (NullPointerException e) {
        filename = "new";
    }

    // Load note from existing file
    if (isSavedNote) {
        try {
            contentsOnLoad = listener.loadNote(filename);
        } catch (IOException e) {
            showToast(R.string.error_loading_note);
            finish(null);
        }

        // Set TextView contents
        length = contentsOnLoad.length();
        noteContents.setText(contentsOnLoad);

        if (!pref.getBoolean("direct_edit", false))
            noteContents.setSelection(length, length);
    } else if (filename.equals("draft")) {
        SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
        String draftContents = sharedPref.getString("draft-contents", null);
        length = draftContents.length();
        noteContents.setText(draftContents);

        if (!pref.getBoolean("direct_edit", false))
            noteContents.setSelection(length, length);
    }

    // Show soft keyboard
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(noteContents, InputMethodManager.SHOW_IMPLICIT);

}

From source file:com.quicklookbusy.narwhalNotifier.AccountEditor.java

/**
 * Shows the virtual keyboard//from w w w  .ja  v  a 2 s .  c o m
 * 
 * @param et
 *            Text field to have focus
 */
private void showKeyboard(EditText et) {
    InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    // only will trigger it if no physical keyboard is open
    mgr.showSoftInput(et, InputMethodManager.SHOW_IMPLICIT);
}

From source file:mbullington.dialogue.activity.ConversationActivity.java

@OnClick(R.id.input)
public void onClickInput(View v) {
    InputMethodManager input = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    input.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);
}