mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Hide the soft keyboard after entering invitation/confirmation codes.
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
package net.sf.briar.android.invitation;
|
||||
|
||||
import static android.content.Context.INPUT_METHOD_SERVICE;
|
||||
import static android.text.InputType.TYPE_CLASS_NUMBER;
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
import static android.view.inputmethod.InputMethodManager.HIDE_IMPLICIT_ONLY;
|
||||
import static net.sf.briar.api.plugins.InvitationConstants.MAX_CODE;
|
||||
import net.sf.briar.R;
|
||||
import android.content.Context;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -81,7 +84,10 @@ OnEditorActionListener, OnClickListener {
|
||||
return false;
|
||||
}
|
||||
if(remoteCode < 0 || remoteCode > MAX_CODE) return false;
|
||||
listener.codeEntered(remoteCode);
|
||||
// Hide the soft keyboard
|
||||
Object o = getContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||
((InputMethodManager) o).toggleSoftInput(HIDE_IMPLICIT_ONLY, 0);
|
||||
listener.codeEntered(remoteCode);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ import android.widget.TextView.OnEditorActionListener;
|
||||
public class ContactAddedView extends AddContactView implements OnClickListener,
|
||||
OnEditorActionListener {
|
||||
|
||||
private Button done = null;
|
||||
|
||||
ContactAddedView(Context ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
@@ -46,14 +44,15 @@ OnEditorActionListener {
|
||||
enterNickname.setText(R.string.enter_nickname);
|
||||
addView(enterNickname);
|
||||
|
||||
final Button addAnother = new Button(ctx);
|
||||
innerLayout = new LinearLayout(ctx);
|
||||
innerLayout.setOrientation(HORIZONTAL);
|
||||
innerLayout.setGravity(CENTER);
|
||||
|
||||
final Button done = new Button(ctx);
|
||||
this.done = done;
|
||||
EditText nicknameEntry = new EditText(ctx) {
|
||||
@Override
|
||||
protected void onTextChanged(CharSequence text, int start,
|
||||
int lengthBefore, int lengthAfter) {
|
||||
addAnother.setEnabled(text.length() > 0);
|
||||
done.setEnabled(text.length() > 0);
|
||||
}
|
||||
};
|
||||
@@ -61,16 +60,7 @@ OnEditorActionListener {
|
||||
nicknameEntry.setMaxEms(20);
|
||||
nicknameEntry.setMaxLines(1);
|
||||
nicknameEntry.setOnEditorActionListener(this);
|
||||
addView(nicknameEntry);
|
||||
|
||||
innerLayout = new LinearLayout(ctx);
|
||||
innerLayout.setOrientation(HORIZONTAL);
|
||||
innerLayout.setGravity(CENTER);
|
||||
|
||||
addAnother.setText(R.string.add_another_contact_button);
|
||||
addAnother.setEnabled(false);
|
||||
addAnother.setOnClickListener(this);
|
||||
innerLayout.addView(addAnother);
|
||||
innerLayout.addView(nicknameEntry);
|
||||
|
||||
done.setText(R.string.done_button);
|
||||
done.setEnabled(false);
|
||||
@@ -85,7 +75,6 @@ OnEditorActionListener {
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
if(view == done) container.finish(); // Done
|
||||
else container.reset(new NetworkSetupView(container)); // Add another
|
||||
container.finish(); // Done
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user