Always show the keyboard when asked for it

and maintain keyboard state when hiding view.
This commit is contained in:
Torsten Grote
2016-10-06 10:41:32 -03:00
parent 3ea36bbd40
commit 154e02723f
6 changed files with 27 additions and 20 deletions

View File

@@ -3,6 +3,7 @@ package org.briarproject.android.forum;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
@@ -90,7 +91,6 @@ public class ForumActivity extends BriarActivity implements
recyclerView.setLayoutManager(linearLayoutManager);
forumAdapter = new NestedForumAdapter(this, this, linearLayoutManager);
recyclerView.setAdapter(forumAdapter);
recyclerView.setEmptyText(R.string.no_forum_posts);
forumController.loadForum(groupId,
new UiResultExceptionHandler<List<ForumEntry>, DbException>(
@@ -182,7 +182,7 @@ public class ForumActivity extends BriarActivity implements
}
}
private void showTextInput(ForumEntry replyEntry) {
private void showTextInput(@Nullable ForumEntry replyEntry) {
// An animation here would be an overkill because of the keyboard
// popping up.
// only clear the text when the input container was not visible
@@ -190,7 +190,6 @@ public class ForumActivity extends BriarActivity implements
textInput.setVisibility(VISIBLE);
textInput.setText("");
}
textInput.requestFocus();
textInput.showSoftKeyboard();
textInput.setHint(replyEntry == null ? R.string.forum_new_message_hint :
R.string.forum_message_reply_hint);

View File

@@ -153,7 +153,7 @@ public class NestedForumAdapter
}
}
void setReplyEntry(ForumEntry entry) {
void setReplyEntry(@Nullable ForumEntry entry) {
if (replyEntry != null) {
notifyItemChanged(getVisiblePos(replyEntry));
}
@@ -386,7 +386,7 @@ public class NestedForumAdapter
* elements if sEntry is null. If sEntry is not visible a NO_POSITION is
* returned.
*/
private int getVisiblePos(ForumEntry sEntry) {
private int getVisiblePos(@Nullable ForumEntry sEntry) {
int visibleCounter = 0;
int levelLimit = UNDEFINED;
for (ForumEntry fEntry : forumEntries) {
@@ -414,14 +414,14 @@ public class NestedForumAdapter
static class NestedForumHolder extends RecyclerView.ViewHolder {
final TextView textView, lvlText, repliesText;
final AuthorView author;
final View[] lvls;
final View chevron, replyButton;
final ViewGroup cell;
final View topDivider;
private final TextView textView, lvlText, repliesText;
private final AuthorView author;
private final View[] lvls;
private final View chevron, replyButton;
private final ViewGroup cell;
private final View topDivider;
NestedForumHolder(View v) {
private NestedForumHolder(View v) {
super(v);
textView = (TextView) v.findViewById(R.id.text);