Skip to content

Commit

Permalink
Merge pull request #1202 from k9mail/compose-fixes
Browse files Browse the repository at this point in the history
Compose fixes
  • Loading branch information
cketti committed Mar 22, 2016
2 parents cd37bf7 + 89e78e0 commit b586522
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.app.LoaderManager.LoaderCallbacks;
import android.content.Context;
import android.content.Loader;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
Expand Down Expand Up @@ -195,6 +196,22 @@ protected void onDetachedFromWindow() {
attachedToWindow = false;
}

@Override
public void onFocusChanged(boolean hasFocus, int direction, Rect previous) {
super.onFocusChanged(hasFocus, direction, previous);
if (hasFocus) {
displayKeyboard();
}
}

private void displayKeyboard() {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) {
return;
}
imm.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT);
}

@Override
public void showDropDown() {
boolean cursorIsValid = adapter != null;
Expand Down Expand Up @@ -343,7 +360,13 @@ public void onLoaderReset(Loader<List<Recipient>> loader) {
}

public boolean hasUncompletedText() {
return !TextUtils.isEmpty(currentCompletionText());
String currentCompletionText = currentCompletionText();
return !TextUtils.isEmpty(currentCompletionText) && !isPlaceholderText(currentCompletionText);
}

static private boolean isPlaceholderText(String currentCompletionText) {
// TODO string matching here is sort of a hack, but it's somewhat reliable and the info isn't easily available
return currentCompletionText.startsWith("+") && currentCompletionText.substring(1).matches("[0-9]+");
}

@Override
Expand Down

0 comments on commit b586522

Please sign in to comment.