Fix expiry dialog, reorder layouts
This commit is contained in:
@@ -137,12 +137,10 @@ public class AddSubkeyDialogFragment extends DialogFragment {
|
||||
}
|
||||
});
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
|
||||
// date picker works based on default time zone
|
||||
Calendar minDateCal = Calendar.getInstance(TimeZone.getDefault());
|
||||
minDateCal.add(Calendar.DAY_OF_YEAR, 1); // at least one day after creation (today)
|
||||
mExpiryDatePicker.setMinDate(minDateCal.getTime().getTime());
|
||||
}
|
||||
// date picker works based on default time zone
|
||||
Calendar minDateCal = Calendar.getInstance(TimeZone.getDefault());
|
||||
minDateCal.add(Calendar.DAY_OF_YEAR, 1); // at least one day after creation (today)
|
||||
mExpiryDatePicker.setMinDate(minDateCal.getTime().getTime());
|
||||
|
||||
{
|
||||
ArrayList<Choice<Algorithm>> choices = new ArrayList<>();
|
||||
@@ -283,7 +281,7 @@ public class AddSubkeyDialogFragment extends DialogFragment {
|
||||
// For EC keys, add a curve
|
||||
if (algorithm == Algorithm.ECDH || algorithm == Algorithm.ECDSA) {
|
||||
curve = ((Choice<Curve>) mCurveSpinner.getSelectedItem()).getId();
|
||||
// Otherwise, get a keysize
|
||||
// Otherwise, get a keysize
|
||||
} else {
|
||||
keySize = getProperKeyLength(algorithm, getSelectedKeyLength());
|
||||
}
|
||||
|
||||
@@ -25,11 +25,14 @@ import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.os.RemoteException;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
@@ -97,62 +100,65 @@ public class EditSubkeyExpiryDialogFragment extends DialogFragment {
|
||||
|
||||
final CheckBox noExpiry = (CheckBox) view.findViewById(R.id.edit_subkey_expiry_no_expiry);
|
||||
final DatePicker datePicker = (DatePicker) view.findViewById(R.id.edit_subkey_expiry_date_picker);
|
||||
final TextView currentExpiry = (TextView) view.findViewById(R.id.edit_subkey_expiry_current_expiry);
|
||||
final LinearLayout expiryLayout = (LinearLayout) view.findViewById(R.id.edit_subkey_expiry_layout);
|
||||
|
||||
noExpiry.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
datePicker.setVisibility(View.GONE);
|
||||
expiryLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
datePicker.setVisibility(View.VISIBLE);
|
||||
expiryLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// init date picker with default selected date
|
||||
if (expiry == 0L) {
|
||||
noExpiry.setChecked(true);
|
||||
datePicker.setVisibility(View.GONE);
|
||||
expiryLayout.setVisibility(View.GONE);
|
||||
|
||||
Calendar todayCal = Calendar.getInstance(TimeZone.getDefault());
|
||||
if (creationCal.after(todayCal)) {
|
||||
// Note: This is just for the rare cases where creation is _after_ today
|
||||
|
||||
// set it to creation date +1 day (don't set it to creationCal, it would break crash
|
||||
// datePicker.setMinDate() execution with IllegalArgumentException
|
||||
Calendar creationCalPlusOne = (Calendar) creationCal.clone();
|
||||
creationCalPlusOne.add(Calendar.DAY_OF_YEAR, 1);
|
||||
datePicker.init(
|
||||
creationCalPlusOne.get(Calendar.YEAR),
|
||||
creationCalPlusOne.get(Calendar.MONTH),
|
||||
creationCalPlusOne.get(Calendar.DAY_OF_MONTH),
|
||||
null
|
||||
);
|
||||
|
||||
} else {
|
||||
// normally, just init with today
|
||||
datePicker.init(
|
||||
todayCal.get(Calendar.YEAR),
|
||||
todayCal.get(Calendar.MONTH),
|
||||
todayCal.get(Calendar.DAY_OF_MONTH),
|
||||
null
|
||||
);
|
||||
}
|
||||
currentExpiry.setText(R.string.btn_no_date);
|
||||
} else {
|
||||
noExpiry.setChecked(false);
|
||||
datePicker.setVisibility(View.VISIBLE);
|
||||
expiryLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
// set date picker to current expiry
|
||||
// convert from UTC to time zone of device
|
||||
Calendar expiryCalTimeZone = (Calendar) expiryCal.clone();
|
||||
expiryCalTimeZone.setTimeZone(TimeZone.getDefault());
|
||||
currentExpiry.setText(DateFormat.getDateFormat(
|
||||
getActivity()).format(expiryCalTimeZone.getTime()));
|
||||
}
|
||||
|
||||
// date picker works based on default time zone
|
||||
Calendar todayCal = Calendar.getInstance(TimeZone.getDefault());
|
||||
if (creationCal.after(todayCal)) {
|
||||
// NOTE: This is just for the rare cases where creation is _after_ today
|
||||
// Min Date: Creation date + 1 day
|
||||
|
||||
Calendar creationCalPlusOne = (Calendar) creationCal.clone();
|
||||
creationCalPlusOne.add(Calendar.DAY_OF_YEAR, 1);
|
||||
datePicker.setMinDate(creationCalPlusOne.getTime().getTime());
|
||||
datePicker.init(
|
||||
expiryCal.get(Calendar.YEAR),
|
||||
expiryCal.get(Calendar.MONTH),
|
||||
expiryCal.get(Calendar.DAY_OF_MONTH),
|
||||
creationCalPlusOne.get(Calendar.YEAR),
|
||||
creationCalPlusOne.get(Calendar.MONTH),
|
||||
creationCalPlusOne.get(Calendar.DAY_OF_MONTH),
|
||||
null
|
||||
);
|
||||
} else {
|
||||
// Min Date: today + 1 day
|
||||
|
||||
// at least one day after creation (today)
|
||||
todayCal.add(Calendar.DAY_OF_YEAR, 1);
|
||||
datePicker.setMinDate(todayCal.getTime().getTime());
|
||||
datePicker.init(
|
||||
todayCal.get(Calendar.YEAR),
|
||||
todayCal.get(Calendar.MONTH),
|
||||
todayCal.get(Calendar.DAY_OF_MONTH),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
datePicker.setMinDate(creationCal.getTime().getTime());
|
||||
|
||||
alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
@@ -92,7 +92,6 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi
|
||||
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);
|
||||
|
||||
alert.setTitle(title);
|
||||
alert.setMessage(R.string.enter_passphrase_twice);
|
||||
|
||||
LayoutInflater inflater = activity.getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.passphrase_repeat_dialog, null);
|
||||
|
||||
Reference in New Issue
Block a user