mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 14:19:53 +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;
|
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.text.InputType.TYPE_CLASS_NUMBER;
|
||||||
import static android.view.Gravity.CENTER;
|
import static android.view.Gravity.CENTER;
|
||||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
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 static net.sf.briar.api.plugins.InvitationConstants.MAX_CODE;
|
||||||
import net.sf.briar.R;
|
import net.sf.briar.R;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@@ -81,7 +84,10 @@ OnEditorActionListener, OnClickListener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(remoteCode < 0 || remoteCode > MAX_CODE) 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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ import android.widget.TextView.OnEditorActionListener;
|
|||||||
public class ContactAddedView extends AddContactView implements OnClickListener,
|
public class ContactAddedView extends AddContactView implements OnClickListener,
|
||||||
OnEditorActionListener {
|
OnEditorActionListener {
|
||||||
|
|
||||||
private Button done = null;
|
|
||||||
|
|
||||||
ContactAddedView(Context ctx) {
|
ContactAddedView(Context ctx) {
|
||||||
super(ctx);
|
super(ctx);
|
||||||
}
|
}
|
||||||
@@ -46,14 +44,15 @@ OnEditorActionListener {
|
|||||||
enterNickname.setText(R.string.enter_nickname);
|
enterNickname.setText(R.string.enter_nickname);
|
||||||
addView(enterNickname);
|
addView(enterNickname);
|
||||||
|
|
||||||
final Button addAnother = new Button(ctx);
|
innerLayout = new LinearLayout(ctx);
|
||||||
|
innerLayout.setOrientation(HORIZONTAL);
|
||||||
|
innerLayout.setGravity(CENTER);
|
||||||
|
|
||||||
final Button done = new Button(ctx);
|
final Button done = new Button(ctx);
|
||||||
this.done = done;
|
|
||||||
EditText nicknameEntry = new EditText(ctx) {
|
EditText nicknameEntry = new EditText(ctx) {
|
||||||
@Override
|
@Override
|
||||||
protected void onTextChanged(CharSequence text, int start,
|
protected void onTextChanged(CharSequence text, int start,
|
||||||
int lengthBefore, int lengthAfter) {
|
int lengthBefore, int lengthAfter) {
|
||||||
addAnother.setEnabled(text.length() > 0);
|
|
||||||
done.setEnabled(text.length() > 0);
|
done.setEnabled(text.length() > 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -61,16 +60,7 @@ OnEditorActionListener {
|
|||||||
nicknameEntry.setMaxEms(20);
|
nicknameEntry.setMaxEms(20);
|
||||||
nicknameEntry.setMaxLines(1);
|
nicknameEntry.setMaxLines(1);
|
||||||
nicknameEntry.setOnEditorActionListener(this);
|
nicknameEntry.setOnEditorActionListener(this);
|
||||||
addView(nicknameEntry);
|
innerLayout.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);
|
|
||||||
|
|
||||||
done.setText(R.string.done_button);
|
done.setText(R.string.done_button);
|
||||||
done.setEnabled(false);
|
done.setEnabled(false);
|
||||||
@@ -85,7 +75,6 @@ OnEditorActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if(view == done) container.finish(); // Done
|
container.finish(); // Done
|
||||||
else container.reset(new NetworkSetupView(container)); // Add another
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user