diff options
Diffstat (limited to 'org_apg/src')
35 files changed, 590 insertions, 359 deletions
diff --git a/org_apg/src/org/apg/ApgService.java b/org_apg/src/org/apg/ApgService.java index 82e85371d..2d41f88ae 100644 --- a/org_apg/src/org/apg/ApgService.java +++ b/org_apg/src/org/apg/ApgService.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg; import java.io.ByteArrayInputStream; diff --git a/org_apg/src/org/apg/CachedPassPhrase.java b/org_apg/src/org/apg/CachedPassPhrase.java index 2d67a300d..857136b8c 100644 --- a/org_apg/src/org/apg/CachedPassPhrase.java +++ b/org_apg/src/org/apg/CachedPassPhrase.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg; public class CachedPassPhrase { diff --git a/org_apg/src/org/apg/DataDestination.java b/org_apg/src/org/apg/DataDestination.java index 509670e69..99e40e3ed 100644 --- a/org_apg/src/org/apg/DataDestination.java +++ b/org_apg/src/org/apg/DataDestination.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg; import java.io.ByteArrayOutputStream; diff --git a/org_apg/src/org/apg/DataSource.java b/org_apg/src/org/apg/DataSource.java index 340afa9f8..89afd2150 100644 --- a/org_apg/src/org/apg/DataSource.java +++ b/org_apg/src/org/apg/DataSource.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg; import java.io.ByteArrayInputStream; diff --git a/org_apg/src/org/apg/FileDialog.java b/org_apg/src/org/apg/FileDialog.java index 6ad498b90..d8956d978 100644 --- a/org_apg/src/org/apg/FileDialog.java +++ b/org_apg/src/org/apg/FileDialog.java @@ -37,8 +37,6 @@ public class FileDialog { private static ImageButton mBrowse; private static CheckBox mCheckBox; private static Activity mActivity; - private static String mFileManagerTitle; - private static String mFileManagerButton; private static int mRequestCode; public static interface OnClickListener { @@ -70,8 +68,6 @@ public class FileDialog { openFile(); } }); - mFileManagerTitle = fileManagerTitle; - mFileManagerButton = fileManagerButton; mRequestCode = requestCode; mCheckBox = (CheckBox) view.findViewById(R.id.checkbox); if (checkboxText == null) { @@ -121,7 +117,7 @@ public class FileDialog { intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setData(Uri.parse("file://" + filename)); - intent.setType("*/*"); + intent.setType("text/plain"); // only .asc or .gpg files try { mActivity.startActivityForResult(intent, mRequestCode); diff --git a/org_apg/src/org/apg/HkpKeyServer.java b/org_apg/src/org/apg/HkpKeyServer.java index 294a60cb2..cd6a31ed4 100644 --- a/org_apg/src/org/apg/HkpKeyServer.java +++ b/org_apg/src/org/apg/HkpKeyServer.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg; import java.io.ByteArrayOutputStream; diff --git a/org_apg/src/org/apg/InputData.java b/org_apg/src/org/apg/InputData.java index ae5b51fe4..e82b4a555 100644 --- a/org_apg/src/org/apg/InputData.java +++ b/org_apg/src/org/apg/InputData.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg; import java.io.InputStream; diff --git a/org_apg/src/org/apg/KeyServer.java b/org_apg/src/org/apg/KeyServer.java index 32158454f..c928b3f82 100644 --- a/org_apg/src/org/apg/KeyServer.java +++ b/org_apg/src/org/apg/KeyServer.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg; import java.io.Serializable; diff --git a/org_apg/src/org/apg/PausableThread.java b/org_apg/src/org/apg/PausableThread.java index 87258d36c..2fc3737d7 100644 --- a/org_apg/src/org/apg/PausableThread.java +++ b/org_apg/src/org/apg/PausableThread.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg; public class PausableThread extends Thread { diff --git a/org_apg/src/org/apg/PositionAwareInputStream.java b/org_apg/src/org/apg/PositionAwareInputStream.java index c59459670..41ec7618d 100644 --- a/org_apg/src/org/apg/PositionAwareInputStream.java +++ b/org_apg/src/org/apg/PositionAwareInputStream.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg; import java.io.IOException; diff --git a/org_apg/src/org/apg/Preferences.java b/org_apg/src/org/apg/Preferences.java index f4800e064..60d9db8e8 100644 --- a/org_apg/src/org/apg/Preferences.java +++ b/org_apg/src/org/apg/Preferences.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg; import org.spongycastle.bcpg.HashAlgorithmTags; diff --git a/org_apg/src/org/apg/Service.java b/org_apg/src/org/apg/Service.java index 24c4daa11..58677b737 100644 --- a/org_apg/src/org/apg/Service.java +++ b/org_apg/src/org/apg/Service.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg; import android.content.Intent; diff --git a/org_apg/src/org/apg/provider/ApgServiceBlobDatabase.java b/org_apg/src/org/apg/provider/ApgServiceBlobDatabase.java index 70b9cd64f..2dab048a3 100644 --- a/org_apg/src/org/apg/provider/ApgServiceBlobDatabase.java +++ b/org_apg/src/org/apg/provider/ApgServiceBlobDatabase.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg.provider; import org.apg.ApgService; diff --git a/org_apg/src/org/apg/provider/ApgServiceBlobProvider.java b/org_apg/src/org/apg/provider/ApgServiceBlobProvider.java index 0c314d771..72f70a590 100644 --- a/org_apg/src/org/apg/provider/ApgServiceBlobProvider.java +++ b/org_apg/src/org/apg/provider/ApgServiceBlobProvider.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg.provider; import org.apg.ApgService; diff --git a/org_apg/src/org/apg/provider/Database.java b/org_apg/src/org/apg/provider/Database.java index bbfd400cf..a41df2ced 100644 --- a/org_apg/src/org/apg/provider/Database.java +++ b/org_apg/src/org/apg/provider/Database.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg.provider; import org.apg.Apg; diff --git a/org_apg/src/org/apg/ui/AboutActivity.java b/org_apg/src/org/apg/ui/AboutActivity.java index 308a1e06e..e9a97d370 100644 --- a/org_apg/src/org/apg/ui/AboutActivity.java +++ b/org_apg/src/org/apg/ui/AboutActivity.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg.ui; import org.apg.Constants; diff --git a/org_apg/src/org/apg/ui/BaseActivity.java b/org_apg/src/org/apg/ui/BaseActivity.java index 3f0f7a027..43c5c0bfe 100644 --- a/org_apg/src/org/apg/ui/BaseActivity.java +++ b/org_apg/src/org/apg/ui/BaseActivity.java @@ -19,7 +19,6 @@ package org.apg.ui; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.util.Locale; import org.apg.Apg; import org.apg.AskForSecretKeyPassPhrase; @@ -33,24 +32,18 @@ import org.apg.R; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.SherlockActivity; -import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; -import android.content.Context; import android.content.DialogInterface; import android.content.Intent; -import android.content.res.Configuration; import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.Message; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.TextView; import android.widget.Toast; public class BaseActivity extends SherlockActivity implements Runnable, ProgressDialogUpdater, diff --git a/org_apg/src/org/apg/ui/DecryptActivity.java b/org_apg/src/org/apg/ui/DecryptActivity.java index cb58dfb09..2809a31d5 100644 --- a/org_apg/src/org/apg/ui/DecryptActivity.java +++ b/org_apg/src/org/apg/ui/DecryptActivity.java @@ -31,6 +31,9 @@ import org.spongycastle.openpgp.PGPException; import org.spongycastle.openpgp.PGPPublicKeyRing; import org.apg.R; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; + import android.app.AlertDialog; import android.app.Dialog; import android.content.ActivityNotFoundException; @@ -43,7 +46,6 @@ import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.AnimationUtils; -import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.ImageButton; @@ -85,8 +87,13 @@ public class DecryptActivity extends BaseActivity { private ImageView mSourcePrevious = null; private ImageView mSourceNext = null; - private Button mDecryptButton = null; - private Button mReplyButton = null; + // private Button mDecryptButton = null; + // private Button mReplyButton = null; + + private boolean mDecryptEnabled = true; + private String mDecryptString = ""; + private boolean mReplyEnabled = true; + private String mReplyString = ""; private int mDecryptTarget; @@ -107,6 +114,25 @@ public class DecryptActivity extends BaseActivity { private long mUnknownSignatureKeyId = 0; @Override + public boolean onCreateOptionsMenu(Menu menu) { + + if (mDecryptEnabled) { + menu.add(1, Id.menu.option.encrypt_to_clipboard, 0, mDecryptString) + // .setIcon(R.drawable.ic_menu_encrypt) + .setShowAsAction( + MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); + } + if (mReplyEnabled) { + menu.add(1, Id.menu.option.encrypt, 1, mReplyString) + // .setIcon(R.drawable.ic_menu_decrypt) + .setShowAsAction( + MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); + } + + return true; + } + + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.decrypt); @@ -145,8 +171,8 @@ public class DecryptActivity extends BaseActivity { mSourceLabel.setOnClickListener(nextSourceClickListener); mMessage = (EditText) findViewById(R.id.message); - mDecryptButton = (Button) findViewById(R.id.btn_decrypt); - mReplyButton = (Button) findViewById(R.id.btn_reply); + // mDecryptButton = (Button) findViewById(R.id.btn_decrypt); + // mReplyButton = (Button) findViewById(R.id.btn_reply); mSignatureLayout = (LinearLayout) findViewById(R.id.signature); mSignatureStatusImage = (ImageView) findViewById(R.id.ic_signature_status); mUserId = (TextView) findViewById(R.id.mainUserId); @@ -230,7 +256,8 @@ public class DecryptActivity extends BaseActivity { // replace non breakable spaces textData = textData.replaceAll("\\xa0", " "); mMessage.setText(textData); - mDecryptButton.setText(R.string.btn_verify); + mDecryptString = getString(R.string.btn_verify); + // mDecryptButton.setText(R.string.btn_verify); } else { Log.d(Constants.TAG, "Nothing matched!"); } @@ -276,7 +303,9 @@ public class DecryptActivity extends BaseActivity { // replace non breakable spaces data = data.replaceAll("\\xa0", " "); mMessage.setText(data); - mDecryptButton.setText(R.string.btn_verify); + mDecryptString = getString(R.string.btn_verify); + + // mDecryptButton.setText(R.string.btn_verify); } } } @@ -319,18 +348,20 @@ public class DecryptActivity extends BaseActivity { } }); - mDecryptButton.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - decryptClicked(); - } - }); - - mReplyButton.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - replyClicked(); - } - }); - mReplyButton.setVisibility(View.INVISIBLE); + // mDecryptButton.setOnClickListener(new OnClickListener() { + // public void onClick(View v) { + // decryptClicked(); + // } + // }); + // + // mReplyButton.setOnClickListener(new OnClickListener() { + // public void onClick(View v) { + // replyClicked(); + // } + // }); + // mReplyButton.setVisibility(View.INVISIBLE); + + mReplyEnabled = false; if (mReturnResult) { mSourcePrevious.setClickable(false); @@ -349,7 +380,8 @@ public class DecryptActivity extends BaseActivity { if (mSource.getCurrentView().getId() == R.id.sourceMessage && (mMessage.getText().length() > 0 || mData != null || mContentUri != null)) { - mDecryptButton.performClick(); + // mDecryptButton.performClick(); + decryptClicked(); } } @@ -384,13 +416,16 @@ public class DecryptActivity extends BaseActivity { switch (mSource.getCurrentView().getId()) { case R.id.sourceFile: { mSourceLabel.setText(R.string.label_file); - mDecryptButton.setText(R.string.btn_decrypt); + // mDecryptButton.setText(R.string.btn_decrypt); + mDecryptString = getString(R.string.btn_decrypt); break; } case R.id.sourceMessage: { mSourceLabel.setText(R.string.label_message); - mDecryptButton.setText(R.string.btn_decrypt); + // mDecryptButton.setText(R.string.btn_decrypt); + mDecryptString = getString(R.string.btn_decrypt); + break; } @@ -598,7 +633,8 @@ public class DecryptActivity extends BaseActivity { removeDialog(Id.dialog.decrypting); mSignatureKeyId = 0; mSignatureLayout.setVisibility(View.GONE); - mReplyButton.setVisibility(View.INVISIBLE); + // mReplyButton.setVisibility(View.INVISIBLE); + mReplyEnabled = false; String error = data.getString(Apg.EXTRA_ERROR); if (error != null) { @@ -621,7 +657,8 @@ public class DecryptActivity extends BaseActivity { String decryptedMessage = data.getString(Apg.EXTRA_DECRYPTED_MESSAGE); mMessage.setText(decryptedMessage); mMessage.setHorizontallyScrolling(false); - mReplyButton.setVisibility(View.VISIBLE); + // mReplyButton.setVisibility(View.VISIBLE); + mReplyEnabled = false; break; } diff --git a/org_apg/src/org/apg/ui/EditKeyActivity.java b/org_apg/src/org/apg/ui/EditKeyActivity.java index d61260814..1c60688d5 100644 --- a/org_apg/src/org/apg/ui/EditKeyActivity.java +++ b/org_apg/src/org/apg/ui/EditKeyActivity.java @@ -59,9 +59,6 @@ public class EditKeyActivity extends BaseActivity { private SectionView mUserIds; private SectionView mKeys; - // private Button mSaveButton; - // private Button mDiscardButton; - private String mCurrentPassPhrase = null; private String mNewPassPhrase = null; @@ -162,10 +159,6 @@ public class EditKeyActivity extends BaseActivity { } updatePassPhraseButtonText(); - - // Toast.makeText(this, - // getString(R.string.warningMessage, getString(R.string.keyEditingIsBeta)), - // Toast.LENGTH_LONG).show(); } private long getMasterKeyId() { @@ -180,15 +173,6 @@ public class EditKeyActivity extends BaseActivity { || (mNewPassPhrase != null && !mNewPassPhrase.equals("")); } - // @Override - // public boolean onCreateOptionsMenu(Menu menu) { - // menu.add(0, Id.menu.option.preferences, 0, R.string.menu_preferences).setIcon( - // android.R.drawable.ic_menu_preferences); - // menu.add(0, Id.menu.option.about, 1, R.string.menu_about).setIcon( - // android.R.drawable.ic_menu_info_details); - // return true; - // } - @Override protected Dialog onCreateDialog(int id) { switch (id) { @@ -245,15 +229,6 @@ public class EditKeyActivity extends BaseActivity { } } - // public void onClick(View v) { - // if (v == mSaveButton) { - // // TODO: some warning - // saveClicked(); - // } else if (v == mDiscardButton) { - // finish(); - // } - // } - private void saveClicked() { if (!havePassPhrase()) { Toast.makeText(this, R.string.setAPassPhrase, Toast.LENGTH_SHORT).show(); diff --git a/org_apg/src/org/apg/ui/EncryptActivity.java b/org_apg/src/org/apg/ui/EncryptActivity.java index 1f0c39fe5..a4194d778 100644 --- a/org_apg/src/org/apg/ui/EncryptActivity.java +++ b/org_apg/src/org/apg/ui/EncryptActivity.java @@ -76,10 +76,9 @@ public class EncryptActivity extends BaseActivity { private boolean mReturnResult = false; private EditText mMessage = null; private Button mSelectKeysButton = null; -// private Button mEncryptButton = null; + private boolean mEncryptEnabled = false; private String mEncryptString = ""; -// private Button mEncryptToClipboardButton = null; private boolean mEncryptToClipboardEnabled = false; private String mEncryptToClipboardString = ""; @@ -126,12 +125,15 @@ public class EncryptActivity extends BaseActivity { if (mEncryptToClipboardEnabled) { menu.add(1, Id.menu.option.encrypt_to_clipboard, 0, mEncryptToClipboardString) + // .setIcon(R.drawable.ic_menu_encrypt) .setShowAsAction( MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); } if (mEncryptEnabled) { - menu.add(1, Id.menu.option.encrypt, 1, mEncryptString).setShowAsAction( - MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); + menu.add(1, Id.menu.option.encrypt, 1, mEncryptString) + // .setIcon(R.drawable.ic_menu_decrypt) + .setShowAsAction( + MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); } return true; @@ -231,8 +233,8 @@ public class EncryptActivity extends BaseActivity { mMessage = (EditText) findViewById(R.id.message); mSelectKeysButton = (Button) findViewById(R.id.btn_selectEncryptKeys); -// mEncryptButton = (Button) findViewById(R.id.btn_encrypt); -// mEncryptToClipboardButton = (Button) findViewById(R.id.btn_encryptToClipboard); + // mEncryptButton = (Button) findViewById(R.id.btn_encrypt); + // mEncryptToClipboardButton = (Button) findViewById(R.id.btn_encryptToClipboard); mSign = (CheckBox) findViewById(R.id.sign); mMainUserId = (TextView) findViewById(R.id.mainUserId); mMainUserIdRest = (TextView) findViewById(R.id.mainUserIdRest); @@ -286,18 +288,6 @@ public class EncryptActivity extends BaseActivity { } }); -// mEncryptToClipboardButton.setOnClickListener(new OnClickListener() { -// public void onClick(View v) { -// encryptToClipboardClicked(); -// } -// }); - -// mEncryptButton.setOnClickListener(new OnClickListener() { -// public void onClick(View v) { -// encryptClicked(); -// } -// }); - mSelectKeysButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { selectPublicKeys(); @@ -502,81 +492,50 @@ public class EncryptActivity extends BaseActivity { mSourceLabel.setText(R.string.label_message); if (mReturnResult) { mEncryptToClipboardEnabled = false; - // mEncryptToClipboardButton.setVisibility(View.INVISIBLE); } else { mEncryptToClipboardEnabled = true; - // mEncryptToClipboardButton.setVisibility(View.VISIBLE); } if (mMode.getCurrentView().getId() == R.id.modeSymmetric) { if (mReturnResult) { mEncryptString = getString(R.string.btn_encrypt); - // mEncryptButton.setText(R.string.btn_encrypt); } else { mEncryptString = getString(R.string.btn_encryptAndEmail); - - // mEncryptButton.setText(R.string.btn_encryptAndEmail); } mEncryptEnabled = true; mEncryptToClipboardString = getString(R.string.btn_encryptToClipboard); mEncryptToClipboardEnabled = true; - - // mEncryptButton.setEnabled(true); - // mEncryptToClipboardButton.setText(R.string.btn_encryptToClipboard); - // mEncryptToClipboardButton.setEnabled(true); } else { if (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0) { if (getSecretKeyId() == 0) { if (mReturnResult) { mEncryptString = getString(R.string.btn_encrypt); - // mEncryptButton.setText(R.string.btn_encrypt); } else { mEncryptString = getString(R.string.btn_encryptAndEmail); - - // mEncryptButton.setText(R.string.btn_encryptAndEmail); } mEncryptEnabled = false; mEncryptToClipboardString = getString(R.string.btn_encryptToClipboard); mEncryptToClipboardEnabled = false; - - // mEncryptButton.setEnabled(false); - // mEncryptToClipboardButton.setText(R.string.btn_encryptToClipboard); - // mEncryptToClipboardButton.setEnabled(false); } else { if (mReturnResult) { mEncryptString = getString(R.string.btn_sign); - - // mEncryptButton.setText(R.string.btn_sign); } else { mEncryptString = getString(R.string.btn_signAndEmail); - - // mEncryptButton.setText(R.string.btn_signAndEmail); } mEncryptEnabled = true; mEncryptToClipboardString = getString(R.string.btn_signToClipboard); mEncryptToClipboardEnabled = true; - - // mEncryptButton.setEnabled(true); - // mEncryptToClipboardButton.setText(R.string.btn_signToClipboard); - // mEncryptToClipboardButton.setEnabled(true); } } else { if (mReturnResult) { mEncryptString = getString(R.string.btn_encrypt); - - // mEncryptButton.setText(R.string.btn_encrypt); } else { mEncryptString = getString(R.string.btn_encryptAndEmail); - - // mEncryptButton.setText(R.string.btn_encryptAndEmail); } mEncryptEnabled = true; mEncryptToClipboardString = getString(R.string.btn_encryptToClipboard); mEncryptToClipboardEnabled = true; - // mEncryptButton.setEnabled(true); - // mEncryptToClipboardButton.setText(R.string.btn_encryptToClipboard); - // mEncryptToClipboardButton.setEnabled(true); } } break; diff --git a/org_apg/src/org/apg/ui/GeneralActivity.java b/org_apg/src/org/apg/ui/GeneralActivity.java index d70694630..e165dd140 100644 --- a/org_apg/src/org/apg/ui/GeneralActivity.java +++ b/org_apg/src/org/apg/ui/GeneralActivity.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg.ui; import java.io.ByteArrayInputStream; diff --git a/org_apg/src/org/apg/ui/ImportFromQRCodeActivity.java b/org_apg/src/org/apg/ui/ImportFromQRCodeActivity.java index 593c841df..27e2be621 100644 --- a/org_apg/src/org/apg/ui/ImportFromQRCodeActivity.java +++ b/org_apg/src/org/apg/ui/ImportFromQRCodeActivity.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg.ui; import java.io.ByteArrayInputStream; diff --git a/org_apg/src/org/apg/ui/SendKeyActivity.java b/org_apg/src/org/apg/ui/KeyServerExportActivity.java index c44e87469..999c45b16 100644 --- a/org_apg/src/org/apg/ui/SendKeyActivity.java +++ b/org_apg/src/org/apg/ui/KeyServerExportActivity.java @@ -1,15 +1,30 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg.ui; import org.apg.Apg; import org.apg.Constants; import org.apg.HkpKeyServer; import org.apg.Id; -import org.apg.Constants.extras; -import org.apg.Id.message; import org.spongycastle.openpgp.PGPKeyRing; import org.spongycastle.openpgp.PGPPublicKeyRing; import org.apg.R; +import com.actionbarsherlock.view.MenuItem; + +import android.content.Intent; import android.os.Bundle; import android.os.Message; import android.view.View; @@ -24,12 +39,27 @@ import android.widget.Toast; * * Sends the selected public key to a key server */ -public class SendKeyActivity extends BaseActivity { +public class KeyServerExportActivity extends BaseActivity { private Button export; private Spinner keyServer; @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + + case android.R.id.home: + startActivity(new Intent(this, PublicKeyListActivity.class)); + return true; + + default: + break; + + } + return false; + } + + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -38,7 +68,8 @@ public class SendKeyActivity extends BaseActivity { export = (Button) findViewById(R.id.btn_export_to_server); keyServer = (Spinner) findViewById(R.id.keyServer); - ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mPreferences.getKeyServers()); + ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, mPreferences.getKeyServers()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); keyServer.setAdapter(adapter); if (adapter.getCount() > 0) { @@ -90,7 +121,8 @@ public class SendKeyActivity extends BaseActivity { Bundle data = msg.getData(); String error = data.getString(Apg.EXTRA_ERROR); if (error != null) { - Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT) + .show(); return; } diff --git a/org_apg/src/org/apg/ui/KeyServerQueryActivity.java b/org_apg/src/org/apg/ui/KeyServerQueryActivity.java index 606acb575..cc65769de 100644 --- a/org_apg/src/org/apg/ui/KeyServerQueryActivity.java +++ b/org_apg/src/org/apg/ui/KeyServerQueryActivity.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg.ui; import java.util.List; @@ -13,6 +27,8 @@ import org.apg.KeyServer.QueryException; import org.apg.KeyServer.TooManyResponses; import org.apg.R; +import com.actionbarsherlock.view.MenuItem; + import android.app.Activity; import android.app.Dialog; import android.app.ProgressDialog; @@ -51,6 +67,21 @@ public class KeyServerQueryActivity extends BaseActivity { private volatile String mKeyData; @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + + case android.R.id.home: + startActivity(new Intent(this, PublicKeyListActivity.class)); + return true; + + default: + break; + + } + return false; + } + + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -63,10 +94,8 @@ public class KeyServerQueryActivity extends BaseActivity { mList.setAdapter(mAdapter); mKeyServer = (Spinner) findViewById(R.id.keyServer); - ArrayAdapter<String> adapter = - new ArrayAdapter<String>(this, - android.R.layout.simple_spinner_item, - mPreferences.getKeyServers()); + ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, mPreferences.getKeyServers()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mKeyServer.setAdapter(adapter); if (adapter.getCount() > 0) { @@ -89,8 +118,8 @@ public class KeyServerQueryActivity extends BaseActivity { }); Intent intent = getIntent(); - if (Apg.Intent.LOOK_UP_KEY_ID.equals(intent.getAction()) || - Apg.Intent.LOOK_UP_KEY_ID_AND_RETURN.equals(intent.getAction())) { + if (Apg.Intent.LOOK_UP_KEY_ID.equals(intent.getAction()) + || Apg.Intent.LOOK_UP_KEY_ID_AND_RETURN.equals(intent.getAction())) { long keyId = intent.getLongExtra(Apg.EXTRA_KEY_ID, 0); if (keyId != 0) { String query = "0x" + Apg.keyToHex(keyId); @@ -116,10 +145,10 @@ public class KeyServerQueryActivity extends BaseActivity { } @Override - protected Dialog onCreateDialog(int id) { + protected Dialog onCreateDialog(int id) { ProgressDialog progress = (ProgressDialog) super.onCreateDialog(id); progress.setMessage(this.getString(R.string.progress_queryingServer, - (String)mKeyServer.getSelectedItem())); + (String) mKeyServer.getSelectedItem())); return progress; } @@ -130,7 +159,7 @@ public class KeyServerQueryActivity extends BaseActivity { Message msg = new Message(); try { - HkpKeyServer server = new HkpKeyServer((String)mKeyServer.getSelectedItem()); + HkpKeyServer server = new HkpKeyServer((String) mKeyServer.getSelectedItem()); if (mQueryType == Id.keyserver.search) { mSearchResult = server.search(mQueryString); } else if (mQueryType == Id.keyserver.get) { @@ -163,13 +192,15 @@ public class KeyServerQueryActivity extends BaseActivity { Bundle data = msg.getData(); String error = data.getString(Apg.EXTRA_ERROR); if (error != null) { - Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT) + .show(); return; } if (mQueryType == Id.keyserver.search) { if (mSearchResult != null) { - Toast.makeText(this, getString(R.string.keysFound, mSearchResult.size()), Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.keysFound, mSearchResult.size()), + Toast.LENGTH_SHORT).show(); mAdapter.setKeys(mSearchResult); } } else if (mQueryType == Id.keyserver.get) { @@ -284,7 +315,8 @@ public class KeyServerQueryActivity extends BaseActivity { sep.setBackgroundResource(android.R.drawable.divider_horizontal_dark); ll.addView(sep); } - TextView uidView = (TextView) mInflater.inflate(R.layout.key_server_query_result_user_id, null); + TextView uidView = (TextView) mInflater.inflate( + R.layout.key_server_query_result_user_id, null); uidView.setText(uid); ll.addView(uidView); second = false; diff --git a/org_apg/src/org/apg/ui/MainActivity.java b/org_apg/src/org/apg/ui/MainActivity.java index d92cd7e07..e096f477a 100644 --- a/org_apg/src/org/apg/ui/MainActivity.java +++ b/org_apg/src/org/apg/ui/MainActivity.java @@ -17,8 +17,6 @@ package org.apg.ui; import java.security.Security; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.apg.Apg; import org.apg.Id; @@ -26,26 +24,16 @@ import org.spongycastle.jce.provider.BouncyCastleProvider; import org.apg.R; import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.SherlockActivity; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; -import android.app.AlertDialog; import android.app.Dialog; -import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; -import android.text.util.Linkify; -import android.text.util.Linkify.TransformFilter; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; -import android.view.LayoutInflater; import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; import android.widget.TextView; -import android.widget.Toast; public class MainActivity extends BaseActivity { static { @@ -184,10 +172,10 @@ public class MainActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, Id.menu.option.preferences, 0, R.string.menu_preferences) - .setIcon(R.drawable.ic_menu_settings_holo_light) + .setIcon(R.drawable.ic_menu_settings) + .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); + menu.add(0, Id.menu.option.about, 1, R.string.menu_about).setIcon(R.drawable.ic_menu_about) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); - menu.add(0, Id.menu.option.about, 1, R.string.menu_about).setShowAsAction( - MenuItem.SHOW_AS_ACTION_IF_ROOM); return true; } @@ -211,53 +199,6 @@ public class MainActivity extends BaseActivity { return false; } - // @Override - // public boolean onCreateOptionsMenu(Menu menu) { - // menu.add(2, Id.menu.option.preferences, 3, R.string.menu_preferences).setIcon( - // android.R.drawable.ic_menu_preferences); - // menu.add(2, Id.menu.option.key_server, 4, R.string.menu_keyServer).setIcon( - // android.R.drawable.ic_menu_search); - // menu.add(3, Id.menu.option.about, 5, R.string.menu_about).setIcon( - // android.R.drawable.ic_menu_info_details); - // menu.add(3, Id.menu.option.help, 6, R.string.menu_help).setIcon( - // android.R.drawable.ic_menu_help); - // return true; - // } - // - // @Override - // public boolean onOptionsItemSelected(MenuItem item) { - // switch (item.getItemId()) { - // case Id.menu.option.create: { - // showDialog(Id.dialog.new_account); - // return true; - // } - // - // case Id.menu.option.manage_public_keys: { - // startActivity(new Intent(this, PublicKeyListActivity.class)); - // return true; - // } - // - // case Id.menu.option.manage_secret_keys: { - // startActivity(new Intent(this, SecretKeyListActivity.class)); - // return true; - // } - // - // case Id.menu.option.help: { - // showDialog(Id.dialog.help); - // return true; - // } - // - // case Id.menu.option.key_server: { - // startActivity(new Intent(this, KeyServerQueryActivity.class)); - // return true; - // } - // - // default: { - // return super.onOptionsItemSelected(item); - // } - // } - // } - @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); diff --git a/org_apg/src/org/apg/ui/PreferencesActivity.java b/org_apg/src/org/apg/ui/PreferencesActivity.java index 0679ee5d0..2e2c8fa29 100644 --- a/org_apg/src/org/apg/ui/PreferencesActivity.java +++ b/org_apg/src/org/apg/ui/PreferencesActivity.java @@ -20,10 +20,6 @@ import org.apg.Apg; import org.apg.Constants; import org.apg.Id; import org.apg.Preferences; -import org.apg.Constants.pref; -import org.apg.Id.choice; -import org.apg.Id.request; -import org.apg.Id.choice.compression; import org.apg.ui.widget.IntegerListPreference; import org.spongycastle.bcpg.HashAlgorithmTags; import org.spongycastle.openpgp.PGPEncryptedData; @@ -36,17 +32,11 @@ import com.actionbarsherlock.view.MenuItem; import android.content.Intent; import android.os.Bundle; import android.preference.CheckBoxPreference; -import android.preference.ListPreference; import android.preference.Preference; -import android.preference.PreferenceActivity; import android.preference.PreferenceScreen; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Vector; public class PreferencesActivity extends SherlockPreferenceActivity { - private ListPreference mLanguage = null; private IntegerListPreference mPassPhraseCacheTtl = null; private IntegerListPreference mEncryptionAlgorithm = null; private IntegerListPreference mHashAlgorithm = null; diff --git a/org_apg/src/org/apg/ui/PublicKeyListActivity.java b/org_apg/src/org/apg/ui/PublicKeyListActivity.java index f91683748..e963a2029 100644 --- a/org_apg/src/org/apg/ui/PublicKeyListActivity.java +++ b/org_apg/src/org/apg/ui/PublicKeyListActivity.java @@ -19,15 +19,9 @@ package org.apg.ui; import org.apg.Apg; import org.apg.Constants; import org.apg.Id; -import org.apg.Constants.path; -import org.apg.Id.menu; -import org.apg.Id.request; -import org.apg.Id.type; -import org.apg.Id.menu.option; import org.spongycastle.openpgp.PGPPublicKeyRing; import org.apg.R; -import com.actionbarsherlock.ActionBarSherlock; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; @@ -50,15 +44,13 @@ public class PublicKeyListActivity extends KeyListActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(1, Id.menu.option.search, 0, R.string.menu_search) - .setIcon(R.drawable.ic_menu_search_holo_light) - .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + .setIcon(R.drawable.ic_menu_search).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menu.add(1, Id.menu.option.scanQRCode, 1, R.string.menu_scanQRCode) - // .setIcon(R.drawable.ic_suggestions_add) + .setIcon(R.drawable.ic_menu_scan_qrcode) .setShowAsAction( MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); - menu.add(1, Id.menu.option.key_server, 2, R.string.menu_keyServer) - .setIcon(R.drawable.ic_menu_find_holo_light) + .setIcon(R.drawable.ic_menu_search_list) .setShowAsAction( MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); menu.add(0, Id.menu.option.import_keys, 3, R.string.menu_importKeys) @@ -145,7 +137,7 @@ public class PublicKeyListActivity extends KeyListActivity { mSelectedItem = groupPosition; final int keyRingId = mListAdapter.getKeyRingId(groupPosition); - Intent intent = new Intent(this, SendKeyActivity.class); + Intent intent = new Intent(this, KeyServerExportActivity.class); intent.setAction(Apg.Intent.EXPORT_KEY_TO_SERVER); intent.putExtra(Apg.EXTRA_KEY_ID, keyRingId); startActivityForResult(intent, Id.request.export_to_server); diff --git a/org_apg/src/org/apg/ui/SecretKeyListActivity.java b/org_apg/src/org/apg/ui/SecretKeyListActivity.java index 95436565d..5359aec8f 100644 --- a/org_apg/src/org/apg/ui/SecretKeyListActivity.java +++ b/org_apg/src/org/apg/ui/SecretKeyListActivity.java @@ -20,12 +20,6 @@ import org.apg.Apg; import org.apg.AskForSecretKeyPassPhrase; import org.apg.Constants; import org.apg.Id; -import org.apg.Constants.path; -import org.apg.Id.dialog; -import org.apg.Id.menu; -import org.apg.Id.message; -import org.apg.Id.type; -import org.apg.Id.menu.option; import org.apg.R; import com.actionbarsherlock.view.Menu; @@ -55,10 +49,10 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(3, Id.menu.option.search, 0, R.string.menu_search) - .setIcon(R.drawable.ic_menu_search_holo_light) + .setIcon(R.drawable.ic_menu_search_list) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menu.add(1, Id.menu.option.create, 1, R.string.menu_createKey) - .setIcon(R.drawable.ic_suggestions_add) + // .setIcon(R.drawable.ic_suggestions_add) .setShowAsAction( MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); menu.add(0, Id.menu.option.import_keys, 2, R.string.menu_importKeys) diff --git a/org_apg/src/org/apg/ui/SelectPublicKeyListActivity.java b/org_apg/src/org/apg/ui/SelectPublicKeyListActivity.java index 9fbf6586c..4b2c39875 100644 --- a/org_apg/src/org/apg/ui/SelectPublicKeyListActivity.java +++ b/org_apg/src/org/apg/ui/SelectPublicKeyListActivity.java @@ -20,11 +20,8 @@ import java.util.Vector; import org.apg.Apg; import org.apg.Id; -import org.apg.Id.menu; -import org.apg.Id.menu.option; import org.apg.R; - import com.actionbarsherlock.view.Menu; import android.app.SearchManager; @@ -167,8 +164,8 @@ public class SelectPublicKeyListActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { - menu.add(0, Id.menu.option.search, 0, R.string.menu_search) - .setIcon(android.R.drawable.ic_menu_search); + menu.add(0, Id.menu.option.search, 0, R.string.menu_search).setIcon( + android.R.drawable.ic_menu_search); return true; } } diff --git a/org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java b/org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java index b2f49f74a..93844601b 100644 --- a/org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java +++ b/org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java @@ -20,7 +20,6 @@ import java.util.Date; import org.apg.Apg; import org.apg.Id; -import org.apg.Id.database; import org.apg.provider.KeyRings; import org.apg.provider.Keys; import org.apg.provider.UserIds; @@ -48,25 +47,23 @@ public class SelectPublicKeyListAdapter extends BaseAdapter { protected String mSearchString; protected Activity mActivity; - public SelectPublicKeyListAdapter(Activity activity, ListView parent, - String searchString, long selectedKeyIds[]) { + public SelectPublicKeyListAdapter(Activity activity, ListView parent, String searchString, + long selectedKeyIds[]) { mSearchString = searchString; mActivity = activity; mParent = parent; - mDatabase = Apg.getDatabase().db(); - mInflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + mDatabase = Apg.getDatabase().db(); + mInflater = (LayoutInflater) parent.getContext().getSystemService( + Context.LAYOUT_INFLATER_SERVICE); long now = new Date().getTime() / 1000; SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); - qb.setTables(KeyRings.TABLE_NAME + " INNER JOIN " + Keys.TABLE_NAME + " ON " + - "(" + KeyRings.TABLE_NAME + "." + KeyRings._ID + " = " + - Keys.TABLE_NAME + "." + Keys.KEY_RING_ID + " AND " + - Keys.TABLE_NAME + "." + Keys.IS_MASTER_KEY + " = '1'" + - ") " + - " INNER JOIN " + UserIds.TABLE_NAME + " ON " + - "(" + Keys.TABLE_NAME + "." + Keys._ID + " = " + - UserIds.TABLE_NAME + "." + UserIds.KEY_ID + " AND " + - UserIds.TABLE_NAME + "." + UserIds.RANK + " = '0') "); + qb.setTables(KeyRings.TABLE_NAME + " INNER JOIN " + Keys.TABLE_NAME + " ON " + "(" + + KeyRings.TABLE_NAME + "." + KeyRings._ID + " = " + Keys.TABLE_NAME + "." + + Keys.KEY_RING_ID + " AND " + Keys.TABLE_NAME + "." + Keys.IS_MASTER_KEY + + " = '1'" + ") " + " INNER JOIN " + UserIds.TABLE_NAME + " ON " + "(" + + Keys.TABLE_NAME + "." + Keys._ID + " = " + UserIds.TABLE_NAME + "." + + UserIds.KEY_ID + " AND " + UserIds.TABLE_NAME + "." + UserIds.RANK + " = '0') "); String inIdList = null; @@ -83,10 +80,9 @@ public class SelectPublicKeyListAdapter extends BaseAdapter { if (searchString != null && searchString.trim().length() > 0) { String[] chunks = searchString.trim().split(" +"); - qb.appendWhere("(EXISTS (SELECT tmp." + UserIds._ID + " FROM " + - UserIds.TABLE_NAME + " AS tmp WHERE " + - "tmp." + UserIds.KEY_ID + " = " + - Keys.TABLE_NAME + "." + Keys._ID); + qb.appendWhere("(EXISTS (SELECT tmp." + UserIds._ID + " FROM " + UserIds.TABLE_NAME + + " AS tmp WHERE " + "tmp." + UserIds.KEY_ID + " = " + Keys.TABLE_NAME + "." + + Keys._ID); for (int i = 0; i < chunks.length; ++i) { qb.appendWhere(" AND tmp." + UserIds.USER_ID + " LIKE "); qb.appendWhereEscapeString("%" + chunks[i] + "%"); @@ -103,28 +99,22 @@ public class SelectPublicKeyListAdapter extends BaseAdapter { orderBy = inIdList + " DESC, " + orderBy; } - mCursor = qb.query(mDatabase, - new String[] { - KeyRings.TABLE_NAME + "." + KeyRings._ID, // 0 - KeyRings.TABLE_NAME + "." + KeyRings.MASTER_KEY_ID, // 1 - UserIds.TABLE_NAME + "." + UserIds.USER_ID, // 2 - "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Keys.TABLE_NAME + " AS tmp WHERE " + - "tmp." + Keys.KEY_RING_ID + " = " + - KeyRings.TABLE_NAME + "." + KeyRings._ID + " AND " + - "tmp." + Keys.IS_REVOKED + " = '0' AND " + - "tmp." + Keys.CAN_ENCRYPT + " = '1')", // 3 - "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Keys.TABLE_NAME + " AS tmp WHERE " + - "tmp." + Keys.KEY_RING_ID + " = " + - KeyRings.TABLE_NAME + "." + KeyRings._ID + " AND " + - "tmp." + Keys.IS_REVOKED + " = '0' AND " + - "tmp." + Keys.CAN_ENCRYPT + " = '1' AND " + - "tmp." + Keys.CREATION + " <= '" + now + "' AND " + - "(tmp." + Keys.EXPIRY + " IS NULL OR " + - "tmp." + Keys.EXPIRY + " >= '" + now + "'))", // 4 - }, - KeyRings.TABLE_NAME + "." + KeyRings.TYPE + " = ?", - new String[] { "" + Id.database.type_public }, - null, null, orderBy); + mCursor = qb.query(mDatabase, new String[] { + KeyRings.TABLE_NAME + "." + KeyRings._ID, // 0 + KeyRings.TABLE_NAME + "." + KeyRings.MASTER_KEY_ID, // 1 + UserIds.TABLE_NAME + "." + UserIds.USER_ID, // 2 + "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Keys.TABLE_NAME + " AS tmp WHERE " + + "tmp." + Keys.KEY_RING_ID + " = " + KeyRings.TABLE_NAME + "." + + KeyRings._ID + " AND " + "tmp." + Keys.IS_REVOKED + " = '0' AND " + + "tmp." + Keys.CAN_ENCRYPT + " = '1')", // 3 + "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Keys.TABLE_NAME + " AS tmp WHERE " + + "tmp." + Keys.KEY_RING_ID + " = " + KeyRings.TABLE_NAME + "." + + KeyRings._ID + " AND " + "tmp." + Keys.IS_REVOKED + " = '0' AND " + + "tmp." + Keys.CAN_ENCRYPT + " = '1' AND " + "tmp." + Keys.CREATION + + " <= '" + now + "' AND " + "(tmp." + Keys.EXPIRY + " IS NULL OR " + + "tmp." + Keys.EXPIRY + " >= '" + now + "'))", // 4 + }, KeyRings.TABLE_NAME + "." + KeyRings.TYPE + " = ?", new String[] { "" + + Id.database.type_public }, null, null, orderBy); activity.startManagingCursor(mCursor); } diff --git a/org_apg/src/org/apg/ui/SelectSecretKeyListActivity.java b/org_apg/src/org/apg/ui/SelectSecretKeyListActivity.java index 1f70f4b04..50f855ebc 100644 --- a/org_apg/src/org/apg/ui/SelectSecretKeyListActivity.java +++ b/org_apg/src/org/apg/ui/SelectSecretKeyListActivity.java @@ -18,11 +18,8 @@ package org.apg.ui; import org.apg.Apg; import org.apg.Id; -import org.apg.Id.menu; -import org.apg.Id.menu.option; import org.apg.R; - import com.actionbarsherlock.view.Menu; import android.app.SearchManager; @@ -59,7 +56,7 @@ public class SelectSecretKeyListActivity extends BaseActivity { public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { Intent data = new Intent(); data.putExtra(Apg.EXTRA_KEY_ID, id); - data.putExtra(Apg.EXTRA_USER_ID, (String)mList.getItemAtPosition(position)); + data.putExtra(Apg.EXTRA_USER_ID, (String) mList.getItemAtPosition(position)); setResult(RESULT_OK, data); finish(); } @@ -110,8 +107,8 @@ public class SelectSecretKeyListActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { - menu.add(0, Id.menu.option.search, 0, R.string.menu_search) - .setIcon(android.R.drawable.ic_menu_search); + menu.add(0, Id.menu.option.search, 0, R.string.menu_search).setIcon( + android.R.drawable.ic_menu_search); return true; } } diff --git a/org_apg/src/org/apg/ui/SelectSecretKeyListAdapter.java b/org_apg/src/org/apg/ui/SelectSecretKeyListAdapter.java index 1a7734245..3c0b803eb 100644 --- a/org_apg/src/org/apg/ui/SelectSecretKeyListAdapter.java +++ b/org_apg/src/org/apg/ui/SelectSecretKeyListAdapter.java @@ -1,10 +1,23 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg.ui; import java.util.Date; import org.apg.Apg; import org.apg.Id; -import org.apg.Id.database; import org.apg.provider.KeyRings; import org.apg.provider.Keys; import org.apg.provider.UserIds; @@ -35,26 +48,23 @@ public class SelectSecretKeyListAdapter extends BaseAdapter { mActivity = activity; mParent = parent; - mDatabase = Apg.getDatabase().db(); - mInflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + mDatabase = Apg.getDatabase().db(); + mInflater = (LayoutInflater) parent.getContext().getSystemService( + Context.LAYOUT_INFLATER_SERVICE); long now = new Date().getTime() / 1000; SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); - qb.setTables(KeyRings.TABLE_NAME + " INNER JOIN " + Keys.TABLE_NAME + " ON " + - "(" + KeyRings.TABLE_NAME + "." + KeyRings._ID + " = " + - Keys.TABLE_NAME + "." + Keys.KEY_RING_ID + " AND " + - Keys.TABLE_NAME + "." + Keys.IS_MASTER_KEY + " = '1'" + - ") " + - " INNER JOIN " + UserIds.TABLE_NAME + " ON " + - "(" + Keys.TABLE_NAME + "." + Keys._ID + " = " + - UserIds.TABLE_NAME + "." + UserIds.KEY_ID + " AND " + - UserIds.TABLE_NAME + "." + UserIds.RANK + " = '0') "); + qb.setTables(KeyRings.TABLE_NAME + " INNER JOIN " + Keys.TABLE_NAME + " ON " + "(" + + KeyRings.TABLE_NAME + "." + KeyRings._ID + " = " + Keys.TABLE_NAME + "." + + Keys.KEY_RING_ID + " AND " + Keys.TABLE_NAME + "." + Keys.IS_MASTER_KEY + + " = '1'" + ") " + " INNER JOIN " + UserIds.TABLE_NAME + " ON " + "(" + + Keys.TABLE_NAME + "." + Keys._ID + " = " + UserIds.TABLE_NAME + "." + + UserIds.KEY_ID + " AND " + UserIds.TABLE_NAME + "." + UserIds.RANK + " = '0') "); if (searchString != null && searchString.trim().length() > 0) { String[] chunks = searchString.trim().split(" +"); - qb.appendWhere("EXISTS (SELECT tmp." + UserIds._ID + " FROM " + - UserIds.TABLE_NAME + " AS tmp WHERE " + - "tmp." + UserIds.KEY_ID + " = " + - Keys.TABLE_NAME + "." + Keys._ID); + qb.appendWhere("EXISTS (SELECT tmp." + UserIds._ID + " FROM " + UserIds.TABLE_NAME + + " AS tmp WHERE " + "tmp." + UserIds.KEY_ID + " = " + Keys.TABLE_NAME + "." + + Keys._ID); for (int i = 0; i < chunks.length; ++i) { qb.appendWhere(" AND tmp." + UserIds.USER_ID + " LIKE "); qb.appendWhereEscapeString("%" + chunks[i] + "%"); @@ -62,28 +72,23 @@ public class SelectSecretKeyListAdapter extends BaseAdapter { qb.appendWhere(")"); } - mCursor = qb.query(mDatabase, - new String[] { - KeyRings.TABLE_NAME + "." + KeyRings._ID, // 0 - KeyRings.TABLE_NAME + "." + KeyRings.MASTER_KEY_ID, // 1 - UserIds.TABLE_NAME + "." + UserIds.USER_ID, // 2 - "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Keys.TABLE_NAME + " AS tmp WHERE " + - "tmp." + Keys.KEY_RING_ID + " = " + - KeyRings.TABLE_NAME + "." + KeyRings._ID + " AND " + - "tmp." + Keys.IS_REVOKED + " = '0' AND " + - "tmp." + Keys.CAN_SIGN + " = '1')", // 3, - "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Keys.TABLE_NAME + " AS tmp WHERE " + - "tmp." + Keys.KEY_RING_ID + " = " + - KeyRings.TABLE_NAME + "." + KeyRings._ID + " AND " + - "tmp." + Keys.IS_REVOKED + " = '0' AND " + - "tmp." + Keys.CAN_SIGN + " = '1' AND " + - "tmp." + Keys.CREATION + " <= '" + now + "' AND " + - "(tmp." + Keys.EXPIRY + " IS NULL OR " + - "tmp." + Keys.EXPIRY + " >= '" + now + "'))", // 4 - }, - KeyRings.TABLE_NAME + "." + KeyRings.TYPE + " = ?", - new String[] { "" + Id.database.type_secret }, - null, null, UserIds.TABLE_NAME + "." + UserIds.USER_ID + " ASC"); + mCursor = qb.query(mDatabase, new String[] { + KeyRings.TABLE_NAME + "." + KeyRings._ID, // 0 + KeyRings.TABLE_NAME + "." + KeyRings.MASTER_KEY_ID, // 1 + UserIds.TABLE_NAME + "." + UserIds.USER_ID, // 2 + "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Keys.TABLE_NAME + " AS tmp WHERE " + + "tmp." + Keys.KEY_RING_ID + " = " + KeyRings.TABLE_NAME + "." + + KeyRings._ID + " AND " + "tmp." + Keys.IS_REVOKED + " = '0' AND " + + "tmp." + Keys.CAN_SIGN + " = '1')", // 3, + "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Keys.TABLE_NAME + " AS tmp WHERE " + + "tmp." + Keys.KEY_RING_ID + " = " + KeyRings.TABLE_NAME + "." + + KeyRings._ID + " AND " + "tmp." + Keys.IS_REVOKED + " = '0' AND " + + "tmp." + Keys.CAN_SIGN + " = '1' AND " + "tmp." + Keys.CREATION + " <= '" + + now + "' AND " + "(tmp." + Keys.EXPIRY + " IS NULL OR " + "tmp." + + Keys.EXPIRY + " >= '" + now + "'))", // 4 + }, KeyRings.TABLE_NAME + "." + KeyRings.TYPE + " = ?", new String[] { "" + + Id.database.type_secret }, null, null, UserIds.TABLE_NAME + "." + UserIds.USER_ID + + " ASC"); activity.startManagingCursor(mCursor); } diff --git a/org_apg/src/org/apg/ui/SignKeyActivity.java b/org_apg/src/org/apg/ui/SignKeyActivity.java index ab145c921..012118cac 100644 --- a/org_apg/src/org/apg/ui/SignKeyActivity.java +++ b/org_apg/src/org/apg/ui/SignKeyActivity.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg.ui; import java.security.NoSuchAlgorithmException; @@ -9,11 +23,6 @@ import org.apg.Apg; import org.apg.Constants; import org.apg.HkpKeyServer; import org.apg.Id; -import org.apg.Constants.extras; -import org.apg.Id.dialog; -import org.apg.Id.message; -import org.apg.Id.request; -import org.apg.Id.return_value; import org.spongycastle.jce.provider.BouncyCastleProvider; import org.spongycastle.openpgp.PGPException; import org.spongycastle.openpgp.PGPPrivateKey; @@ -27,6 +36,8 @@ import org.spongycastle.openpgp.PGPSignatureSubpacketVector; import org.spongycastle.openpgp.PGPUtil; import org.apg.R; +import com.actionbarsherlock.view.MenuItem; + import android.content.Intent; import android.os.Bundle; import android.os.Message; @@ -51,7 +62,22 @@ public class SignKeyActivity extends BaseActivity { private long pubKeyId = 0; private long masterKeyId = 0; - + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + + case android.R.id.home: + startActivity(new Intent(this, PublicKeyListActivity.class)); + return true; + + default: + break; + + } + return false; + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -60,7 +86,8 @@ public class SignKeyActivity extends BaseActivity { setContentView(R.layout.sign_key_layout); final Spinner keyServer = (Spinner) findViewById(R.id.keyServer); - ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mPreferences.getKeyServers()); + ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, mPreferences.getKeyServers()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); keyServer.setAdapter(adapter); @@ -94,12 +121,13 @@ public class SignKeyActivity extends BaseActivity { } } }); - + pubKeyId = getIntent().getLongExtra(Apg.EXTRA_KEY_ID, 0); if (pubKeyId == 0) { finish(); // nothing to do if we dont know what key to sign } else { - // kick off the SecretKey selection activity so the user chooses which key to sign with first + // kick off the SecretKey selection activity so the user chooses which key to sign with + // first Intent intent = new Intent(this, SelectSecretKeyListActivity.class); startActivityForResult(intent, Id.request.secret_keys); } @@ -113,7 +141,7 @@ public class SignKeyActivity extends BaseActivity { if (pubring != null) { // if we have already signed this key, dont bother doing it again boolean alreadySigned = false; - + @SuppressWarnings("unchecked") Iterator<PGPSignature> itr = pubring.getPublicKey(pubKeyId).getSignatures(); while (itr.hasNext()) { @@ -123,7 +151,7 @@ public class SignKeyActivity extends BaseActivity { break; } } - + if (!alreadySigned) { /* * get the user's passphrase for this key (if required) @@ -131,7 +159,8 @@ public class SignKeyActivity extends BaseActivity { String passphrase = Apg.getCachedPassPhrase(masterKeyId); if (passphrase == null) { showDialog(Id.dialog.pass_phrase); - return; // bail out; need to wait until the user has entered the passphrase before trying again + return; // bail out; need to wait until the user has entered the passphrase + // before trying again } else { startSigning(); } @@ -142,27 +171,27 @@ public class SignKeyActivity extends BaseActivity { status.putString(Apg.EXTRA_ERROR, "Key has already been signed"); status.putInt(Constants.extras.STATUS, Id.message.done); - + msg.setData(status); sendMessage(msg); - + setResult(Id.return_value.error); finish(); } } } - + @Override public long getSecretKeyId() { return masterKeyId; } - + @Override public void passPhraseCallback(long keyId, String passPhrase) { super.passPhraseCallback(keyId, passPhrase); startSigning(); } - + /** * kicks off the actual signing process on a background thread */ @@ -170,7 +199,7 @@ public class SignKeyActivity extends BaseActivity { showDialog(Id.dialog.signing); startThread(); } - + @Override public void run() { final Bundle status = new Bundle(); @@ -182,36 +211,39 @@ public class SignKeyActivity extends BaseActivity { status.putString(Apg.EXTRA_ERROR, "Unable to obtain passphrase"); } else { PGPPublicKeyRing pubring = Apg.getPublicKeyRing(pubKeyId); - + /* * sign the incoming key */ PGPSecretKey secretKey = Apg.getSecretKey(masterKeyId); - PGPPrivateKey signingKey = secretKey.extractPrivateKey(passphrase.toCharArray(), BouncyCastleProvider.PROVIDER_NAME); - PGPSignatureGenerator sGen = new PGPSignatureGenerator(secretKey.getPublicKey().getAlgorithm(), PGPUtil.SHA256, BouncyCastleProvider.PROVIDER_NAME); + PGPPrivateKey signingKey = secretKey.extractPrivateKey(passphrase.toCharArray(), + BouncyCastleProvider.PROVIDER_NAME); + PGPSignatureGenerator sGen = new PGPSignatureGenerator(secretKey.getPublicKey() + .getAlgorithm(), PGPUtil.SHA256, BouncyCastleProvider.PROVIDER_NAME); sGen.initSign(PGPSignature.DIRECT_KEY, signingKey); - + PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator(); - + PGPSignatureSubpacketVector packetVector = spGen.generate(); sGen.setHashedSubpackets(packetVector); - - PGPPublicKey signedKey = PGPPublicKey.addCertification(pubring.getPublicKey(pubKeyId), sGen.generate()); + + PGPPublicKey signedKey = PGPPublicKey.addCertification( + pubring.getPublicKey(pubKeyId), sGen.generate()); pubring = PGPPublicKeyRing.insertPublicKey(pubring, signedKey); - + // check if we need to send the key to the server or not CheckBox sendKey = (CheckBox) findViewById(R.id.sendKey); if (sendKey.isChecked()) { Spinner keyServer = (Spinner) findViewById(R.id.keyServer); HkpKeyServer server = new HkpKeyServer((String) keyServer.getSelectedItem()); - + /* * upload the newly signed key to the key server */ - + Apg.uploadKeyRingToServer(server, pubring); } - + // store the signed key in our local cache int retval = Apg.storeKeyRingInCache(pubring); if (retval != Id.return_value.ok && retval != Id.return_value.updated) { @@ -239,52 +271,53 @@ public class SignKeyActivity extends BaseActivity { status.putInt(Constants.extras.STATUS, Id.message.done); return; } - + status.putInt(Constants.extras.STATUS, Id.message.done); - + msg.setData(status); sendMessage(msg); - + if (status.containsKey(Apg.EXTRA_ERROR)) { setResult(Id.return_value.error); } else { setResult(Id.return_value.ok); } - + finish(); } - + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { - case Id.request.secret_keys: { - if (resultCode == RESULT_OK) { - masterKeyId = data.getLongExtra(Apg.EXTRA_KEY_ID, 0); - - // re-enable the sign button so the user can initiate the sign process - Button sign = (Button) findViewById(R.id.sign); - sign.setEnabled(true); - } - - break; - } - - default: { - super.onActivityResult(requestCode, resultCode, data); + case Id.request.secret_keys: { + if (resultCode == RESULT_OK) { + masterKeyId = data.getLongExtra(Apg.EXTRA_KEY_ID, 0); + + // re-enable the sign button so the user can initiate the sign process + Button sign = (Button) findViewById(R.id.sign); + sign.setEnabled(true); } + + break; + } + + default: { + super.onActivityResult(requestCode, resultCode, data); + } } } - + @Override public void doneCallback(Message msg) { super.doneCallback(msg); - + removeDialog(Id.dialog.signing); Bundle data = msg.getData(); String error = data.getString(Apg.EXTRA_ERROR); if (error != null) { - Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT) + .show(); return; } diff --git a/org_apg/src/org/apg/util/ApgConInterface.java b/org_apg/src/org/apg/util/ApgConInterface.java index 2b66164f1..54d6af9b8 100644 --- a/org_apg/src/org/apg/util/ApgConInterface.java +++ b/org_apg/src/org/apg/util/ApgConInterface.java @@ -1,3 +1,17 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg.util; public interface ApgConInterface { diff --git a/org_apg/src/org/apg/util/Compatibility.java b/org_apg/src/org/apg/util/Compatibility.java index 10b3c7f6b..03053335b 100644 --- a/org_apg/src/org/apg/util/Compatibility.java +++ b/org_apg/src/org/apg/util/Compatibility.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apg.util; import java.lang.reflect.Method; |