diff --git a/OpenKeychain/src/main/AndroidManifest.xml b/OpenKeychain/src/main/AndroidManifest.xml index 0ac1f0312..6236ed94f 100644 --- a/OpenKeychain/src/main/AndroidManifest.xml +++ b/OpenKeychain/src/main/AndroidManifest.xml @@ -102,6 +102,10 @@ android:name=".ui.EditKeyActivity" android:configChanges="orientation|screenSize|keyboardHidden|keyboard" android:label="@string/title_edit_key" /> + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.net.Uri; +import android.os.Bundle; +import android.support.v7.app.ActionBarActivity; +import android.view.View; +import android.widget.ImageView; + +import com.devspark.appmsg.AppMsg; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.ActionBarHelper; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.util.Log; +import org.sufficientlysecure.keychain.util.QrCodeUtils; + +public class QrCodeActivity extends ActionBarActivity { + + private ImageView mFingerprintQrCode; + + private static final int QR_CODE_SIZE = 1000; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Inflate a "Done" custom action bar + ActionBarHelper.setOneButtonView(getSupportActionBar(), + R.string.btn_okay, R.drawable.ic_action_done, + new View.OnClickListener() { + @Override + public void onClick(View v) { + // "Done" + finish(); + } + } + ); + + setContentView(R.layout.qr_code_activity); + + Uri dataUri = getIntent().getData(); + if (dataUri == null) { + Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + finish(); + return; + } + + mFingerprintQrCode = (ImageView) findViewById(R.id.qr_code_image); + + mFingerprintQrCode.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + + ProviderHelper providerHelper = new ProviderHelper(this); + try { + byte[] blob = (byte[]) providerHelper.getGenericData( + KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri), + KeychainContract.KeyRings.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); + if (blob == null) { + Log.e(Constants.TAG, "key not found!"); + AppMsg.makeText(this, R.string.error_key_not_found, AppMsg.STYLE_ALERT).show(); + finish(); + } + + String fingerprint = PgpKeyHelper.convertFingerprintToHex(blob); + String qrCodeContent = Constants.FINGERPRINT_SCHEME + ":" + fingerprint; + mFingerprintQrCode.setImageBitmap(QrCodeUtils.getQRCodeBitmap(qrCodeContent, QR_CODE_SIZE)); + } catch (ProviderHelper.NotFoundException e) { + Log.e(Constants.TAG, "key not found!", e); + AppMsg.makeText(this, R.string.error_key_not_found, AppMsg.STYLE_ALERT).show(); + finish(); + } + } + + @Override + protected void onResume() { + super.onResume(); + + // custom activity transition to get zoom in effect + this.overridePendingTransition(R.anim.zoom_enter, android.R.anim.fade_out); + } + + @Override + protected void onPause() { + super.onPause(); + + // custom activity transition to get zoom out effect + this.overridePendingTransition(0, R.anim.zoom_exit); + } + +} \ No newline at end of file diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java index 46cd7e25b..0027ebbfe 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java @@ -19,7 +19,6 @@ package org.sufficientlysecure.keychain.ui; import android.annotation.TargetApi; import android.content.Intent; -import android.content.res.Resources; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.Color; @@ -53,7 +52,6 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.dialog.ShareNfcDialogFragment; -import org.sufficientlysecure.keychain.ui.dialog.ShareQrCodeDialogFragment; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.QrCodeUtils; @@ -214,8 +212,11 @@ public class ViewKeyShareFragment extends LoaderFragment implements } private void showQrCodeDialog() { - ShareQrCodeDialogFragment dialog = ShareQrCodeDialogFragment.newInstance(mDataUri); - dialog.show(ViewKeyShareFragment.this.getActivity().getSupportFragmentManager(), "shareQrCodeDialog"); +// ShareQrCodeDialogFragment dialog = ShareQrCodeDialogFragment.newInstance(mDataUri); +// dialog.show(ViewKeyShareFragment.this.getActivity().getSupportFragmentManager(), "shareQrCodeDialog"); + Intent qrCodeIntent = new Intent(getActivity(), QrCodeActivity.class); + qrCodeIntent.setData(mDataUri); + startActivity(qrCodeIntent); } private void showNfcHelpDialog() { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java deleted file mode 100644 index 24608784b..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2012-2014 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.ui.dialog; - -import android.app.Activity; -import android.app.Dialog; -import android.net.Uri; -import android.os.Bundle; -import android.support.v4.app.DialogFragment; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.ImageView; -import android.widget.TextView; - -import com.devspark.appmsg.AppMsg; - -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; -import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.util.Log; -import org.sufficientlysecure.keychain.util.QrCodeUtils; - -public class ShareQrCodeDialogFragment extends DialogFragment { - private static final String ARG_KEY_URI = "uri"; - - private ImageView mImage; - private TextView mText; - - private static final int QR_CODE_SIZE = 1000; - - /** - * Creates new instance of this dialog fragment - */ - public static ShareQrCodeDialogFragment newInstance(Uri dataUri) { - ShareQrCodeDialogFragment frag = new ShareQrCodeDialogFragment(); - Bundle args = new Bundle(); - args.putParcelable(ARG_KEY_URI, dataUri); - - frag.setArguments(args); - - return frag; - } - - /** - * Creates dialog - */ - @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { - final Activity activity = getActivity(); - - Uri dataUri = getArguments().getParcelable(ARG_KEY_URI); - - CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(getActivity()); - alert.setTitle(R.string.share_qr_code_dialog_title); - - LayoutInflater inflater = activity.getLayoutInflater(); - View view = inflater.inflate(R.layout.share_qr_code_dialog, null); - alert.setView(view); - - mImage = (ImageView) view.findViewById(R.id.share_qr_code_dialog_image); - mText = (TextView) view.findViewById(R.id.share_qr_code_dialog_text); - - ProviderHelper providerHelper = new ProviderHelper(getActivity()); - String content; - try { - alert.setPositiveButton(R.string.btn_okay, null); - - byte[] blob = (byte[]) providerHelper.getGenericData( - KeyRings.buildUnifiedKeyRingUri(dataUri), - KeyRings.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); - if (blob == null) { - Log.e(Constants.TAG, "key not found!"); - AppMsg.makeText(getActivity(), R.string.error_key_not_found, AppMsg.STYLE_ALERT).show(); - return null; - } - - String fingerprint = PgpKeyHelper.convertFingerprintToHex(blob); - mText.setText(getString(R.string.share_qr_code_dialog_fingerprint_text) + " " + fingerprint); - content = Constants.FINGERPRINT_SCHEME + ":" + fingerprint; - setQrCode(content); - } catch (ProviderHelper.NotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); - AppMsg.makeText(getActivity(), R.string.error_key_not_found, AppMsg.STYLE_ALERT).show(); - return null; - } - - return alert.show(); - } - - private void setQrCode(String data) { - mImage.setImageBitmap(QrCodeUtils.getQRCodeBitmap(data, QR_CODE_SIZE)); - } - -} diff --git a/OpenKeychain/src/main/res/anim/zoom_enter.xml b/OpenKeychain/src/main/res/anim/zoom_enter.xml new file mode 100644 index 000000000..2b95cfba6 --- /dev/null +++ b/OpenKeychain/src/main/res/anim/zoom_enter.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/anim/zoom_exit.xml b/OpenKeychain/src/main/res/anim/zoom_exit.xml new file mode 100644 index 000000000..772375739 --- /dev/null +++ b/OpenKeychain/src/main/res/anim/zoom_exit.xml @@ -0,0 +1,17 @@ + + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/qr_code_activity.xml b/OpenKeychain/src/main/res/layout/qr_code_activity.xml new file mode 100644 index 000000000..57c869db6 --- /dev/null +++ b/OpenKeychain/src/main/res/layout/qr_code_activity.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/share_qr_code_dialog.xml b/OpenKeychain/src/main/res/layout/share_qr_code_dialog.xml deleted file mode 100644 index 0b58ae72f..000000000 --- a/OpenKeychain/src/main/res/layout/share_qr_code_dialog.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - \ No newline at end of file