diff options
| -rw-r--r-- | app/src/main/java/mygram/droid/SetupActivity.java | 11 | ||||
| -rw-r--r-- | app/src/main/java/mygram/droid/Ui.java | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/app/src/main/java/mygram/droid/SetupActivity.java b/app/src/main/java/mygram/droid/SetupActivity.java index 3f33d76..79686e6 100644 --- a/app/src/main/java/mygram/droid/SetupActivity.java +++ b/app/src/main/java/mygram/droid/SetupActivity.java @@ -18,6 +18,7 @@ import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.text.InputType; +import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; @@ -61,7 +62,8 @@ public final class SetupActivity extends Activity { t.setPadding(p * 2, p, p * 2, p); Ui.focusable(t); t.setOnClickListener(v -> choose(e.getKey())); - box.addView(t); + box.addView(t, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, + LinearLayout.LayoutParams.WRAP_CONTENT)); // full width the zoom clips the text } actions(); box.getChildAt(1).requestFocus(); @@ -106,7 +108,7 @@ public final class SetupActivity extends Activity { reset("Viewer password for " + base); EditText pw = Ui.field(this, "Password", Ui.password()); box.addView(pw); - box.addView(Ui.iconButton(this, R.drawable.ic_check, "Log in", v -> { + View login = Ui.iconButton(this, R.drawable.ic_check, "Log in", v -> { String s = pw.getText().toString(); Api.async(() -> { Api.login(base, s); @@ -114,7 +116,10 @@ public final class SetupActivity extends Activity { }, ok -> save(base, s), e -> Toast.makeText(this, e instanceof Api.HttpError && ((Api.HttpError) e).code == 401 ? "Wrong password" : e.getMessage(), Toast.LENGTH_LONG).show()); - })); + }); + box.addView(login); + // The keyboard's done key logs in; the D-pad cannot leave the keyboard. + pw.setOnEditorActionListener((v, action, event) -> login.performClick()); pw.requestFocus(); } diff --git a/app/src/main/java/mygram/droid/Ui.java b/app/src/main/java/mygram/droid/Ui.java index 852fe54..757b7fe 100644 --- a/app/src/main/java/mygram/droid/Ui.java +++ b/app/src/main/java/mygram/droid/Ui.java @@ -72,11 +72,13 @@ final class Ui { static EditText field(Context c, String hint, int inputType) { EditText e = new EditText(c); e.setHint(hint); + // setSingleLine() resets the input type's transformation, unmasking + // passwords; it must come first. + e.setSingleLine(true); e.setInputType(inputType); e.setTextColor(Color.WHITE); e.setHintTextColor(Color.GRAY); e.setMinWidth(dp(c, 400)); - e.setSingleLine(true); return e; } |
