Merge branch 'master' of github.com:open-keychain/open-keychain

This commit is contained in:
Dominik Schürmann 2014-05-08 18:44:58 +02:00
commit c2b75e3d2e
12 changed files with 63 additions and 28 deletions

View File

@ -59,6 +59,7 @@ import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder;
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment;
import org.sufficientlysecure.keychain.ui.widget.Editor;
@ -504,7 +505,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
int curID = 0;
for (String userID : userIDs) {
if (userID.equals("") && (!userID.equals(originalIDs.get(curID)) || newIDs.get(curID))) {
AlertDialog.Builder alert = new AlertDialog.Builder(
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(
EditKeyActivity.this);
alert.setIcon(R.drawable.ic_dialog_alert_holo_light);
@ -527,7 +528,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
}
);
alert.setCancelable(false);
alert.create().show();
alert.show();
return;
}
curID++;
@ -617,7 +618,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
private void cancelClicked() {
if (needsSaving()) { //ask if we want to save
AlertDialog.Builder alert = new AlertDialog.Builder(
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(
EditKeyActivity.this);
alert.setIcon(R.drawable.ic_dialog_alert_holo_light);
@ -640,7 +641,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
}
});
alert.setCancelable(false);
alert.create().show();
alert.show();
} else {
setResult(RESULT_CANCELED);
finish();

View File

@ -38,7 +38,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import com.beardedhen.androidbootstrap.BootstrapButton;
import com.devspark.appmsg.AppMsg;
import org.sufficientlysecure.keychain.Constants;

View File

@ -17,7 +17,6 @@
package org.sufficientlysecure.keychain.ui.dialog;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@ -50,7 +49,7 @@ public class BadImportKeyDialogFragment extends DialogFragment {
final FragmentActivity activity = getActivity();
final int badImport = getArguments().getInt(ARG_BAD_IMPORT);
AlertDialog.Builder alert = new AlertDialog.Builder(activity);
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);
alert.setIcon(R.drawable.ic_dialog_alert_holo_light);
alert.setTitle(R.string.warning);
alert.setMessage(activity.getResources()
@ -63,6 +62,6 @@ public class BadImportKeyDialogFragment extends DialogFragment {
});
alert.setCancelable(true);
return alert.create();
return alert.show();
}
}

View File

@ -83,7 +83,7 @@ public class CreateKeyDialogFragment extends DialogFragment {
final int childCount = getArguments().getInt(ARG_EDITOR_CHILD_COUNT);
mInflater = context.getLayoutInflater();
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
CustomAlertDialogBuilder dialog = new CustomAlertDialogBuilder(context);
View view = mInflater.inflate(R.layout.create_key_dialog, null);
dialog.setView(view);
@ -146,7 +146,7 @@ public class CreateKeyDialogFragment extends DialogFragment {
}
});
final AlertDialog alertDialog = dialog.create();
final AlertDialog alertDialog = dialog.show();
mCustomKeyEditText.addTextChangedListener(new TextWatcher() {
@Override

View File

@ -0,0 +1,40 @@
package org.sufficientlysecure.keychain.ui.dialog;
import android.app.Activity;
import android.app.AlertDialog;
import android.view.View;
import android.widget.TextView;
import org.sufficientlysecure.keychain.R;
/** This class extends AlertDiaog.Builder, styling the header using emphasis color.
* Note that this class is a huge hack, because dialog boxes aren't easily stylable.
* Also, the dialog NEEDS to be called with show() directly, not create(), otherwise
* the order of internal operations will lead to a crash!
*/
public class CustomAlertDialogBuilder extends AlertDialog.Builder {
public CustomAlertDialogBuilder(Activity activity) {
super(activity);
}
@Override
public AlertDialog show() {
AlertDialog dialog = super.show();
int dividerId = dialog.getContext().getResources().getIdentifier("android:id/titleDivider", null, null);
View divider = dialog.findViewById(dividerId);
if (divider != null) {
divider.setBackgroundColor(dialog.getContext().getResources().getColor(R.color.emphasis));
}
int textViewId = dialog.getContext().getResources().getIdentifier("android:id/alertTitle", null, null);
TextView tv = (TextView) dialog.findViewById(textViewId);
if (tv != null) {
tv.setTextColor(dialog.getContext().getResources().getColor(R.color.emphasis));
}
return dialog;
}
}

View File

@ -17,7 +17,6 @@
package org.sufficientlysecure.keychain.ui.dialog;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
@ -59,7 +58,7 @@ public class DeleteFileDialogFragment extends DialogFragment {
final String deleteFile = getArguments().getString(ARG_DELETE_FILE);
AlertDialog.Builder alert = new AlertDialog.Builder(activity);
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);
alert.setIcon(R.drawable.ic_dialog_alert_holo_light);
@ -120,6 +119,6 @@ public class DeleteFileDialogFragment extends DialogFragment {
});
alert.setCancelable(true);
return alert.create();
return alert.show();
}
}

View File

@ -17,7 +17,6 @@
package org.sufficientlysecure.keychain.ui.dialog;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@ -73,7 +72,7 @@ public class DeleteKeyDialogFragment extends DialogFragment {
final long[] masterKeyIds = getArguments().getLongArray(ARG_DELETE_MASTER_KEY_IDS);
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(activity);
// Setup custom View to display in AlertDialog
LayoutInflater inflater = activity.getLayoutInflater();
@ -144,7 +143,7 @@ public class DeleteKeyDialogFragment extends DialogFragment {
}
});
return builder.create();
return builder.show();
}
/**

View File

@ -97,7 +97,7 @@ public class FileDialogFragment extends DialogFragment {
LayoutInflater inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
AlertDialog.Builder alert = new AlertDialog.Builder(activity);
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);
alert.setTitle(title);
View view = inflater.inflate(R.layout.file_dialog, null);
@ -157,7 +157,7 @@ public class FileDialogFragment extends DialogFragment {
dismiss();
}
});
return alert.create();
return alert.show();
}
/**

View File

@ -135,7 +135,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
final long secretKeyId = getArguments().getLong(ARG_SECRET_KEY_ID);
mMessenger = getArguments().getParcelable(ARG_MESSENGER);
AlertDialog.Builder alert = new AlertDialog.Builder(activity);
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);
alert.setTitle(R.string.title_authentication);
@ -262,7 +262,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
});
mCanKB = true;
return alert.create();
return alert.show();
}
@Override

View File

@ -81,7 +81,7 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi
int title = getArguments().getInt(ARG_TITLE);
mMessenger = getArguments().getParcelable(ARG_MESSENGER);
AlertDialog.Builder alert = new AlertDialog.Builder(activity);
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);
alert.setTitle(title);
alert.setMessage(R.string.enter_passphrase_twice);
@ -135,7 +135,7 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi
}
});
return alert.create();
return alert.show();
}
@Override

View File

@ -18,7 +18,6 @@
package org.sufficientlysecure.keychain.ui.dialog;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
@ -51,7 +50,7 @@ public class ShareNfcDialogFragment extends DialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
final FragmentActivity activity = getActivity();
AlertDialog.Builder alert = new AlertDialog.Builder(activity);
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);
alert.setTitle(R.string.share_nfc_dialog);
alert.setCancelable(true);
@ -93,6 +92,6 @@ public class ShareNfcDialogFragment extends DialogFragment {
}
}
return alert.create();
return alert.show();
}
}

View File

@ -18,7 +18,6 @@
package org.sufficientlysecure.keychain.ui.dialog;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.net.Uri;
import android.os.Bundle;
@ -68,7 +67,7 @@ public class ShareQrCodeDialogFragment extends DialogFragment {
Uri dataUri = getArguments().getParcelable(ARG_KEY_URI);
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(getActivity());
alert.setTitle(R.string.share_qr_code_dialog_title);
LayoutInflater inflater = activity.getLayoutInflater();
@ -102,7 +101,7 @@ public class ShareQrCodeDialogFragment extends DialogFragment {
return null;
}
return alert.create();
return alert.show();
}
private void setQrCode(String data) {