Skip to content
Snippets Groups Projects
Commit fe74f765 authored by akwizgran's avatar akwizgran
Browse files

Hide the soft keyboard after entering invitation/confirmation codes.

parent 52989770
No related branches found
No related tags found
No related merge requests found
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
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment