mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Always show the keyboard when asked for it
and maintain keyboard state when hiding view.
This commit is contained in:
@@ -11,7 +11,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
app:scrollToEnd="false"/>
|
||||
app:scrollToEnd="false"
|
||||
app:emptyText="@string/no_forum_posts"/>
|
||||
|
||||
<org.briarproject.android.view.TextInputView
|
||||
android:id="@+id/text_input_container"
|
||||
|
||||
@@ -96,11 +96,6 @@ public abstract class BaseActivity extends AppCompatActivity
|
||||
});
|
||||
}
|
||||
|
||||
public void showSoftKeyboardForced(View view) {
|
||||
Object o = getSystemService(INPUT_METHOD_SERVICE);
|
||||
((InputMethodManager) o).showSoftInput(view, SHOW_FORCED);
|
||||
}
|
||||
|
||||
public void showSoftKeyboard(View view) {
|
||||
Object o = getSystemService(INPUT_METHOD_SERVICE);
|
||||
((InputMethodManager) o).showSoftInput(view, SHOW_IMPLICIT);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
|
||||
import static android.content.Context.INPUT_METHOD_SERVICE;
|
||||
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
|
||||
import static android.view.KeyEvent.KEYCODE_BACK;
|
||||
import static android.view.inputmethod.InputMethodManager.SHOW_FORCED;
|
||||
|
||||
@UiThread
|
||||
public class TextInputView extends KeyboardAwareLinearLayout
|
||||
@@ -107,6 +108,14 @@ public class TextInputView extends KeyboardAwareLinearLayout
|
||||
ui.emojiDrawer.setEmojiEventListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibility(int visibility) {
|
||||
if (visibility == GONE && isKeyboardOpen()) {
|
||||
onKeyboardClose();
|
||||
}
|
||||
super.setVisibility(visibility);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyEvent(KeyEvent keyEvent) {
|
||||
ui.editText.dispatchKeyEvent(keyEvent);
|
||||
@@ -169,8 +178,10 @@ public class TextInputView extends KeyboardAwareLinearLayout
|
||||
@Override
|
||||
public void run() {
|
||||
ui.editText.requestFocus();
|
||||
Object o = getContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||
((InputMethodManager) o).showSoftInput(ui.editText, 0);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getContext()
|
||||
.getSystemService(INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(ui.editText, SHOW_FORCED);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ public class KeyboardAwareLinearLayout extends LinearLayout {
|
||||
public KeyboardAwareLinearLayout(Context context,
|
||||
@Nullable AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
rotation = getDeviceRotation();
|
||||
final int statusBarRes = getResources()
|
||||
.getIdentifier("status_bar_height", "dimen", "android");
|
||||
minKeyboardSize =
|
||||
|
||||
Reference in New Issue
Block a user