cleaned up code

This commit is contained in:
Adithya Abraham Philip 2015-03-06 22:25:35 +05:30
parent f12f6b540d
commit 1de528fc85
3 changed files with 38 additions and 52 deletions

View File

@ -20,8 +20,6 @@ package org.sufficientlysecure.keychain.ui;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -29,28 +27,23 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.FragAction;
import org.sufficientlysecure.keychain.ui.widget.EmailEditText;
import org.sufficientlysecure.keychain.ui.widget.PasswordEditText;
import org.sufficientlysecure.keychain.ui.widget.PassphraseEditText;
import org.sufficientlysecure.keychain.ui.widget.passwordstrengthindicator.PasswordStrengthView;
import org.sufficientlysecure.keychain.util.ContactHelper;
public class CreateKeyInputFragment extends Fragment {
public static final String ARG_NAME = "name";
public static final String ARG_EMAIL = "email";
CreateKeyActivity mCreateKeyActivity;
AutoCompleteTextView mNameEdit;
EmailEditText mEmailEdit;
PassphraseEditText mPassphraseEdit;
EditText mPassphraseEditAgain;
View mCreateButton;
public static final String ARG_NAME = "name";
public static final String ARG_EMAIL = "email";
/**
* Creates new instance of this fragment
*/
@ -66,6 +59,40 @@ public class CreateKeyInputFragment extends Fragment {
return frag;
}
/**
* Checks if text of given EditText is not empty. If it is empty an error is
* set and the EditText gets the focus.
*
* @param context
* @param editText
* @return true if EditText is not empty
*/
private static boolean isEditTextNotEmpty(Context context, EditText editText) {
boolean output = true;
if (editText.getText().toString().length() == 0) {
editText.setError(context.getString(R.string.create_key_empty));
editText.requestFocus();
output = false;
} else {
editText.setError(null);
}
return output;
}
private static boolean areEditTextsEqual(Context context, EditText editText1, EditText editText2) {
boolean output = true;
if (!editText1.getText().toString().equals(editText2.getText().toString())) {
editText2.setError(context.getString(R.string.create_key_passphrases_not_equal));
editText2.requestFocus();
output = false;
} else {
editText2.setError(null);
}
return output;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.create_key_input_fragment, container, false);
@ -156,38 +183,4 @@ public class CreateKeyInputFragment extends Fragment {
inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
/**
* Checks if text of given EditText is not empty. If it is empty an error is
* set and the EditText gets the focus.
*
* @param context
* @param editText
* @return true if EditText is not empty
*/
private static boolean isEditTextNotEmpty(Context context, EditText editText) {
boolean output = true;
if (editText.getText().toString().length() == 0) {
editText.setError(context.getString(R.string.create_key_empty));
editText.requestFocus();
output = false;
} else {
editText.setError(null);
}
return output;
}
private static boolean areEditTextsEqual(Context context, EditText editText1, EditText editText2) {
boolean output = true;
if (!editText1.getText().toString().equals(editText2.getText().toString())) {
editText2.setError(context.getString(R.string.create_key_passphrases_not_equal));
editText2.requestFocus();
output = false;
} else {
editText2.setError(null);
}
return output;
}
}

View File

@ -33,19 +33,11 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.*;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.ui.widget.PassphraseEditText;
import org.sufficientlysecure.keychain.ui.widget.PasswordEditText;
import org.sufficientlysecure.keychain.ui.widget.passwordstrengthindicator.PasswordStrengthView;
import org.sufficientlysecure.keychain.util.Log;
public class SetPassphraseDialogFragment extends DialogFragment implements OnEditorActionListener {

View File

@ -29,6 +29,7 @@
android:layout_marginBottom="8dp"
android:imeOptions="actionNext"
android:hint="@string/label_passphrase"
android:inputType="textPassword"
android:ems="10"
android:layout_gravity="center_horizontal" />