Skip to content

Commit

Permalink
Add dismiss soft keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
billthefarmer committed Dec 9, 2017
1 parent a8e16c4 commit 6b1d9cc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/org/billthefarmer/editor/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ScrollView;
Expand Down Expand Up @@ -278,6 +279,20 @@ public void onTextChanged (CharSequence s,
int count) {}
});

textView.setOnFocusChangeListener(new View.OnFocusChangeListener()
{
// onFocusChange
@Override
public void onFocusChange (View v, boolean hasFocus)
{
// Hide keyboard
InputMethodManager imm = (InputMethodManager)
getSystemService(INPUT_METHOD_SERVICE);
if (!hasFocus)
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
});

textView.setOnLongClickListener(new View.OnLongClickListener()
{
// onLongClick
Expand Down Expand Up @@ -672,6 +687,7 @@ private void viewClicked(MenuItem item)
{
// Set read only
textView.setRawInputType(InputType.TYPE_NULL);
textView.clearFocus();

// Update boolean
edit = false;
Expand Down Expand Up @@ -1355,6 +1371,7 @@ public void run()

// Set read only
textView.setRawInputType(InputType.TYPE_NULL);
textView.clearFocus();

// Update boolean
edit = false;
Expand Down

0 comments on commit 6b1d9cc

Please sign in to comment.