mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-05 00:35:08 -05:00
use XML layout for pass phrase dialogs as well now, doing away with awkward manual padding, important for Android 1.5 compatibility
This commit is contained in:
parent
29ea6f2f6f
commit
09ad7df83d
22
res/layout/pass_phrase.xml
Normal file
22
res/layout/pass_phrase.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="5dip"
|
||||||
|
android:paddingRight="5dip">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/pass_phrase"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textPassword"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/pass_phrase_again"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textPassword"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -23,9 +23,12 @@ import org.bouncycastle2.openpgp.PGPSecretKey;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.method.PasswordTransformationMethod;
|
import android.text.method.PasswordTransformationMethod;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
import android.view.ViewGroup.LayoutParams;
|
import android.view.ViewGroup.LayoutParams;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@ -56,19 +59,14 @@ public class AskForSecretKeyPassPhrase {
|
|||||||
alert.setMessage("Pass phrase for " + userId);
|
alert.setMessage("Pass phrase for " + userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
final EditText input = new EditText(context);
|
LayoutInflater inflater =
|
||||||
input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
input.setTransformationMethod(new PasswordTransformationMethod());
|
View view = inflater.inflate(R.layout.pass_phrase, null);
|
||||||
// 5dip padding
|
final EditText input = (EditText) view.findViewById(R.id.pass_phrase);
|
||||||
int padding = (int) (10 * context.getResources().getDisplayMetrics().densityDpi / 160);
|
final EditText inputNotUsed = (EditText) view.findViewById(R.id.pass_phrase_again);
|
||||||
LinearLayout layout = new LinearLayout(context);
|
inputNotUsed.setVisibility(View.GONE);
|
||||||
layout.setPadding(padding, 0, padding, 0);
|
|
||||||
layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
|
alert.setView(view);
|
||||||
LayoutParams.WRAP_CONTENT));
|
|
||||||
input.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
|
|
||||||
LayoutParams.WRAP_CONTENT));
|
|
||||||
layout.addView(input);
|
|
||||||
alert.setView(layout);
|
|
||||||
|
|
||||||
final PassPhraseCallbackInterface cb = callback;
|
final PassPhraseCallbackInterface cb = callback;
|
||||||
final Activity activity = context;
|
final Activity activity = context;
|
||||||
|
@ -158,30 +158,13 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener {
|
|||||||
}
|
}
|
||||||
alert.setMessage("Enter the pass phrase twice.");
|
alert.setMessage("Enter the pass phrase twice.");
|
||||||
|
|
||||||
final EditText input1 = new EditText(this);
|
LayoutInflater inflater =
|
||||||
final EditText input2 = new EditText(this);
|
(LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
input1.setText("");
|
View view = inflater.inflate(R.layout.pass_phrase, null);
|
||||||
input2.setText("");
|
final EditText input1 = (EditText) view.findViewById(R.id.pass_phrase);
|
||||||
input1.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
final EditText input2 = (EditText) view.findViewById(R.id.pass_phrase_again);
|
||||||
input2.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
|
||||||
input1.setTransformationMethod(new PasswordTransformationMethod());
|
|
||||||
input2.setTransformationMethod(new PasswordTransformationMethod());
|
|
||||||
|
|
||||||
// 5dip padding
|
alert.setView(view);
|
||||||
int padding = (int) (10 * getResources().getDisplayMetrics().densityDpi / 160);
|
|
||||||
LinearLayout layout = new LinearLayout(this);
|
|
||||||
layout.setOrientation(LinearLayout.VERTICAL);
|
|
||||||
layout.setPadding(padding, 0, padding, 0);
|
|
||||||
layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
|
|
||||||
LayoutParams.WRAP_CONTENT));
|
|
||||||
input1.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
|
|
||||||
LayoutParams.WRAP_CONTENT));
|
|
||||||
input2.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
|
|
||||||
LayoutParams.WRAP_CONTENT));
|
|
||||||
layout.addView(input1);
|
|
||||||
layout.addView(input2);
|
|
||||||
|
|
||||||
alert.setView(layout);
|
|
||||||
|
|
||||||
alert.setPositiveButton(android.R.string.ok,
|
alert.setPositiveButton(android.R.string.ok,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
Loading…
Reference in New Issue
Block a user