mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -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.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.text.InputType;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
@ -56,19 +59,14 @@ public class AskForSecretKeyPassPhrase {
|
||||
alert.setMessage("Pass phrase for " + userId);
|
||||
}
|
||||
|
||||
final EditText input = new EditText(context);
|
||||
input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
input.setTransformationMethod(new PasswordTransformationMethod());
|
||||
// 5dip padding
|
||||
int padding = (int) (10 * context.getResources().getDisplayMetrics().densityDpi / 160);
|
||||
LinearLayout layout = new LinearLayout(context);
|
||||
layout.setPadding(padding, 0, padding, 0);
|
||||
layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
|
||||
LayoutParams.WRAP_CONTENT));
|
||||
input.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
|
||||
LayoutParams.WRAP_CONTENT));
|
||||
layout.addView(input);
|
||||
alert.setView(layout);
|
||||
LayoutInflater inflater =
|
||||
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View view = inflater.inflate(R.layout.pass_phrase, null);
|
||||
final EditText input = (EditText) view.findViewById(R.id.pass_phrase);
|
||||
final EditText inputNotUsed = (EditText) view.findViewById(R.id.pass_phrase_again);
|
||||
inputNotUsed.setVisibility(View.GONE);
|
||||
|
||||
alert.setView(view);
|
||||
|
||||
final PassPhraseCallbackInterface cb = callback;
|
||||
final Activity activity = context;
|
||||
|
@ -158,30 +158,13 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener {
|
||||
}
|
||||
alert.setMessage("Enter the pass phrase twice.");
|
||||
|
||||
final EditText input1 = new EditText(this);
|
||||
final EditText input2 = new EditText(this);
|
||||
input1.setText("");
|
||||
input2.setText("");
|
||||
input1.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
input2.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
input1.setTransformationMethod(new PasswordTransformationMethod());
|
||||
input2.setTransformationMethod(new PasswordTransformationMethod());
|
||||
LayoutInflater inflater =
|
||||
(LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View view = inflater.inflate(R.layout.pass_phrase, null);
|
||||
final EditText input1 = (EditText) view.findViewById(R.id.pass_phrase);
|
||||
final EditText input2 = (EditText) view.findViewById(R.id.pass_phrase_again);
|
||||
|
||||
// 5dip padding
|
||||
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.setView(view);
|
||||
|
||||
alert.setPositiveButton(android.R.string.ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
Loading…
Reference in New Issue
Block a user