aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-10-04 16:01:24 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-10-04 16:01:24 +0200
commitd004bf236bd51817adf5963a3f970acd4e5a243e (patch)
treea8ff39cd0a6ee74bddc888d7a1a65f3eaa84a5ca /OpenKeychain/src/main
parent0e0e3d8dd09deb2ff36d46ccceba08bb5c0967ce (diff)
downloadopen-keychain-d004bf236bd51817adf5963a3f970acd4e5a243e.tar.gz
open-keychain-d004bf236bd51817adf5963a3f970acd4e5a243e.tar.bz2
open-keychain-d004bf236bd51817adf5963a3f970acd4e5a243e.zip
improve CertifyResult, add custom notify
Diffstat (limited to 'OpenKeychain/src/main')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpCertifyOperation.java8
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/CertifyResult.java94
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java4
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResult.java1
-rw-r--r--OpenKeychain/src/main/res/values-cs/strings.xml2
-rw-r--r--OpenKeychain/src/main/res/values-de/strings.xml4
-rw-r--r--OpenKeychain/src/main/res/values-es/strings.xml4
-rw-r--r--OpenKeychain/src/main/res/values-fr/strings.xml4
-rw-r--r--OpenKeychain/src/main/res/values-it/strings.xml2
-rw-r--r--OpenKeychain/src/main/res/values-ja/strings.xml4
-rw-r--r--OpenKeychain/src/main/res/values-ru/strings.xml2
-rw-r--r--OpenKeychain/src/main/res/values-sl/strings.xml4
-rw-r--r--OpenKeychain/src/main/res/values-sr/strings.xml4
-rw-r--r--OpenKeychain/src/main/res/values-uk/strings.xml2
-rw-r--r--OpenKeychain/src/main/res/values/strings.xml27
15 files changed, 140 insertions, 26 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpCertifyOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpCertifyOperation.java
index ffa2181e1..3a29faec3 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpCertifyOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpCertifyOperation.java
@@ -1,7 +1,5 @@
package org.sufficientlysecure.keychain.pgp;
-import android.content.Context;
-
import org.spongycastle.openpgp.PGPException;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
@@ -10,7 +8,6 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
import org.sufficientlysecure.keychain.service.results.CertifyResult;
-import org.sufficientlysecure.keychain.service.results.EditKeyResult;
import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
import org.sufficientlysecure.keychain.service.results.OperationResult.OperationLog;
import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
@@ -141,6 +138,11 @@ public class PgpCertifyOperation {
}
+ if (certifyOk == 0) {
+ log.add(LogType.MSG_CRT_ERROR_NOTHING, 0);
+ return new CertifyResult(CertifyResult.RESULT_ERROR, log, certifyOk, certifyError);
+ }
+
log.add(LogType.MSG_CRT_SUCCESS, 0);
return new CertifyResult(CertifyResult.RESULT_OK, log, certifyOk, certifyError);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/CertifyResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/CertifyResult.java
index cf54238ec..49bc613bd 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/CertifyResult.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/CertifyResult.java
@@ -18,7 +18,21 @@
package org.sufficientlysecure.keychain.service.results;
+import android.app.Activity;
+import android.content.Intent;
import android.os.Parcel;
+import android.os.Parcelable;
+import android.view.View;
+
+import com.github.johnpersano.supertoasts.SuperCardToast;
+import com.github.johnpersano.supertoasts.SuperToast;
+import com.github.johnpersano.supertoasts.SuperToast.Duration;
+import com.github.johnpersano.supertoasts.util.OnClickWrapper;
+import com.github.johnpersano.supertoasts.util.Style;
+
+import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.ui.LogDisplayActivity;
+import org.sufficientlysecure.keychain.ui.LogDisplayFragment;
public class CertifyResult extends OperationResult {
@@ -37,11 +51,15 @@ public class CertifyResult extends OperationResult {
/** Construct from a parcel - trivial because we have no extra data. */
public CertifyResult(Parcel source) {
super(source);
+ mCertifyOk = source.readInt();
+ mCertifyError = source.readInt();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
+ dest.writeInt(mCertifyOk);
+ dest.writeInt(mCertifyError);
}
public static Creator<CertifyResult> CREATOR = new Creator<CertifyResult>() {
@@ -54,4 +72,80 @@ public class CertifyResult extends OperationResult {
}
};
+ public SuperCardToast createNotify(final Activity activity) {
+
+ int resultType = getResult();
+
+ String str;
+ int duration, color;
+
+ // Not an overall failure
+ if ((resultType & OperationResult.RESULT_ERROR) == 0) {
+ String withWarnings;
+
+ duration = Duration.EXTRA_LONG;
+ color = Style.GREEN;
+ withWarnings = "";
+
+ // Any warnings?
+ if ((resultType & ImportKeyResult.RESULT_WARNINGS) > 0) {
+ duration = 0;
+ color = Style.ORANGE;
+ withWarnings += activity.getString(R.string.with_warnings);
+ }
+ if ((resultType & ImportKeyResult.RESULT_CANCELLED) > 0) {
+ duration = 0;
+ color = Style.ORANGE;
+ withWarnings += activity.getString(R.string.with_cancelled);
+ }
+
+ // New and updated keys
+ str = activity.getResources().getQuantityString(
+ R.plurals.certify_keys_ok, mCertifyOk, mCertifyOk, withWarnings);
+ if (mCertifyError > 0) {
+ // definitely switch to warning-style message in this case!
+ duration = 0;
+ color = Style.RED;
+ str += " " + activity.getResources().getQuantityString(
+ R.plurals.certify_keys_with_errors, mCertifyError, mCertifyError);
+ }
+
+ } else {
+ duration = 0;
+ color = Style.RED;
+ str = activity.getResources().getQuantityString(R.plurals.certify_error,
+ mCertifyError, mCertifyError);
+ }
+
+ boolean button = getLog() != null && !getLog().isEmpty();
+ SuperCardToast toast = new SuperCardToast(activity,
+ button ? SuperToast.Type.BUTTON : SuperToast.Type.STANDARD,
+ Style.getStyle(color, SuperToast.Animations.POPUP));
+ toast.setText(str);
+ toast.setDuration(duration);
+ toast.setIndeterminate(duration == 0);
+ toast.setSwipeToDismiss(true);
+ // If we have a log and it's non-empty, show a View Log button
+ if (button) {
+ toast.setButtonIcon(R.drawable.ic_action_view_as_list,
+ activity.getResources().getString(R.string.view_log));
+ toast.setButtonTextColor(activity.getResources().getColor(R.color.black));
+ toast.setTextColor(activity.getResources().getColor(R.color.black));
+ toast.setOnClickWrapper(new OnClickWrapper("supercardtoast",
+ new SuperToast.OnClickListener() {
+ @Override
+ public void onClick(View view, Parcelable token) {
+ Intent intent = new Intent(
+ activity, LogDisplayActivity.class);
+ intent.putExtra(LogDisplayFragment.EXTRA_RESULT, CertifyResult.this);
+ activity.startActivity(intent);
+ }
+ }
+ ));
+ }
+
+ return toast;
+
+ }
+
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java
index b5174bc63..fa0dc6af3 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java
@@ -124,12 +124,12 @@ public class ImportKeyResult extends OperationResult {
if ((resultType & ImportKeyResult.RESULT_WARNINGS) > 0) {
duration = 0;
color = Style.ORANGE;
- withWarnings += activity.getString(R.string.import_with_warnings);
+ withWarnings += activity.getString(R.string.with_warnings);
}
if ((resultType & ImportKeyResult.RESULT_CANCELLED) > 0) {
duration = 0;
color = Style.ORANGE;
- withWarnings += activity.getString(R.string.import_with_cancelled);
+ withWarnings += activity.getString(R.string.with_cancelled);
}
// New and updated keys
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResult.java
index 90e1d0037..5613aa794 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResult.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResult.java
@@ -521,6 +521,7 @@ public abstract class OperationResult implements Parcelable {
MSG_CRT_CERTIFY_ALL (LogLevel.DEBUG, R.string.msg_crt_certify_all),
MSG_CRT_CERTIFY_SOME (LogLevel.DEBUG, R.plurals.msg_crt_certify_some),
MSG_CRT_ERROR_MASTER_NOT_FOUND (LogLevel.ERROR, R.string.msg_crt_error_master_not_found),
+ MSG_CRT_ERROR_NOTHING (LogLevel.ERROR, R.string.msg_crt_error_nothing),
MSG_CRT_ERROR_UNLOCK (LogLevel.ERROR, R.string.msg_crt_error_unlock),
MSG_CRT_FP_MISMATCH (LogLevel.WARN, R.string.msg_crt_fp_mismatch),
MSG_CRT (LogLevel.START, R.string.msg_crt),
diff --git a/OpenKeychain/src/main/res/values-cs/strings.xml b/OpenKeychain/src/main/res/values-cs/strings.xml
index 9f676c6f9..a7090aaf0 100644
--- a/OpenKeychain/src/main/res/values-cs/strings.xml
+++ b/OpenKeychain/src/main/res/values-cs/strings.xml
@@ -329,7 +329,7 @@
<string name="view_log">Zobrazit log</string>
<string name="import_error_nothing">Nic k importu</string>
<string name="import_error_nothing_cancelled">Import zrušen.</string>
- <string name="import_with_warnings">, s varováními</string>
+ <string name="with_warnings">, s varováními</string>
<plurals name="import_error">
<item quantity="one">Import selhal!</item>
<item quantity="few">Import %d klíčů selhal!</item>
diff --git a/OpenKeychain/src/main/res/values-de/strings.xml b/OpenKeychain/src/main/res/values-de/strings.xml
index 1ff3fa024..d537bd6c3 100644
--- a/OpenKeychain/src/main/res/values-de/strings.xml
+++ b/OpenKeychain/src/main/res/values-de/strings.xml
@@ -369,8 +369,8 @@
<string name="view_log">Log ansehen</string>
<string name="import_error_nothing">Nichts zu importieren.</string>
<string name="import_error_nothing_cancelled">Import abgebrochen.</string>
- <string name="import_with_warnings">, mit Warnungen</string>
- <string name="import_with_cancelled">. bis abgebrochen wurde</string>
+ <string name="with_warnings">, mit Warnungen</string>
+ <string name="with_cancelled">. bis abgebrochen wurde</string>
<plurals name="import_error">
<item quantity="one">Importieren fehlgeschlagen!</item>
<item quantity="other">Importieren von %d Schlüsseln fehlgeschlagen!</item>
diff --git a/OpenKeychain/src/main/res/values-es/strings.xml b/OpenKeychain/src/main/res/values-es/strings.xml
index 968ece35a..d1836233c 100644
--- a/OpenKeychain/src/main/res/values-es/strings.xml
+++ b/OpenKeychain/src/main/res/values-es/strings.xml
@@ -357,8 +357,8 @@
<string name="view_log">Ver registro (log)</string>
<string name="import_error_nothing">No hay nada que importar.</string>
<string name="import_error_nothing_cancelled">Importación cancelada.</string>
- <string name="import_with_warnings">, con advertencias</string>
- <string name="import_with_cancelled">, hasta que este cancelada</string>
+ <string name="with_warnings">, con advertencias</string>
+ <string name="with_cancelled">, hasta que este cancelada</string>
<!--Intent labels-->
<string name="intent_decrypt_file">Descifrar archivo con OpenKeychain</string>
<string name="intent_import_key">Importar clave con OpenKeychain</string>
diff --git a/OpenKeychain/src/main/res/values-fr/strings.xml b/OpenKeychain/src/main/res/values-fr/strings.xml
index 91940c7c3..ef1659e7d 100644
--- a/OpenKeychain/src/main/res/values-fr/strings.xml
+++ b/OpenKeychain/src/main/res/values-fr/strings.xml
@@ -357,8 +357,8 @@
<string name="view_log">Consulter le journal</string>
<string name="import_error_nothing">Rien à importer.</string>
<string name="import_error_nothing_cancelled">Importation annulée.</string>
- <string name="import_with_warnings">, avec des avertissements</string>
- <string name="import_with_cancelled">, jusqu\'à l\'annulation</string>
+ <string name="with_warnings">, avec des avertissements</string>
+ <string name="with_cancelled">, jusqu\'à l\'annulation</string>
<!--Intent labels-->
<string name="intent_decrypt_file">Déchiffrer le fichier avec OpenKeychain</string>
<string name="intent_import_key">Importer la clef avec OpenKeychain</string>
diff --git a/OpenKeychain/src/main/res/values-it/strings.xml b/OpenKeychain/src/main/res/values-it/strings.xml
index 5c652fd73..a26dee6b3 100644
--- a/OpenKeychain/src/main/res/values-it/strings.xml
+++ b/OpenKeychain/src/main/res/values-it/strings.xml
@@ -362,7 +362,7 @@ Non potrai annullare!</string>
<string name="view_log">Mostra registro</string>
<string name="import_error_nothing">Niente da importare</string>
<string name="import_error_nothing_cancelled">Importazione cancellata.</string>
- <string name="import_with_warnings">, con avvisi</string>
+ <string name="with_warnings">, con avvisi</string>
<!--Intent labels-->
<string name="intent_decrypt_file">Decodifica File con OpenKeychain</string>
<string name="intent_import_key">Importa Chiave con OpenKeychain</string>
diff --git a/OpenKeychain/src/main/res/values-ja/strings.xml b/OpenKeychain/src/main/res/values-ja/strings.xml
index d1a90ff8c..661317852 100644
--- a/OpenKeychain/src/main/res/values-ja/strings.xml
+++ b/OpenKeychain/src/main/res/values-ja/strings.xml
@@ -371,8 +371,8 @@
<string name="view_log">ログを見る</string>
<string name="import_error_nothing">インポートするものがありません。</string>
<string name="import_error_nothing_cancelled">インポートをキャンセルしました。</string>
- <string name="import_with_warnings">、とワーニング</string>
- <string name="import_with_cancelled">、キャンセルされるまで</string>
+ <string name="with_warnings">、とワーニング</string>
+ <string name="with_cancelled">、キャンセルされるまで</string>
<plurals name="import_error">
<item quantity="other">%d 個の鍵のインポート失敗!</item>
</plurals>
diff --git a/OpenKeychain/src/main/res/values-ru/strings.xml b/OpenKeychain/src/main/res/values-ru/strings.xml
index 5ce53a9f1..73ef1ed19 100644
--- a/OpenKeychain/src/main/res/values-ru/strings.xml
+++ b/OpenKeychain/src/main/res/values-ru/strings.xml
@@ -311,7 +311,7 @@
</plurals>
<string name="view_log">Смотреть журнал</string>
<string name="import_error_nothing">Нет данных для импорта.</string>
- <string name="import_with_warnings">, с предупреждениями</string>
+ <string name="with_warnings">, с предупреждениями</string>
<!--Intent labels-->
<string name="intent_decrypt_file">OpenKeychain: Расшифровать файл</string>
<string name="intent_import_key">OpenKeychain: Импортировать ключ</string>
diff --git a/OpenKeychain/src/main/res/values-sl/strings.xml b/OpenKeychain/src/main/res/values-sl/strings.xml
index 491bf5cf5..0f54c95ef 100644
--- a/OpenKeychain/src/main/res/values-sl/strings.xml
+++ b/OpenKeychain/src/main/res/values-sl/strings.xml
@@ -319,8 +319,8 @@
<string name="view_log">Poglej dnevnik</string>
<string name="import_error_nothing">Nič za uvoziti.</string>
<string name="import_error_nothing_cancelled">Uvoz preklican.</string>
- <string name="import_with_warnings">, z opozorilom</string>
- <string name="import_with_cancelled"> do preklica</string>
+ <string name="with_warnings">, z opozorilom</string>
+ <string name="with_cancelled"> do preklica</string>
<!--Intent labels-->
<string name="intent_decrypt_file">Dešifriraj datoteko z OpenKeychain</string>
<string name="intent_import_key">Uvozi ključ z OpenKeychain</string>
diff --git a/OpenKeychain/src/main/res/values-sr/strings.xml b/OpenKeychain/src/main/res/values-sr/strings.xml
index c1121ef4d..c765d27af 100644
--- a/OpenKeychain/src/main/res/values-sr/strings.xml
+++ b/OpenKeychain/src/main/res/values-sr/strings.xml
@@ -330,8 +330,8 @@
<string name="view_log">Прикажи дневник</string>
<string name="import_error_nothing">Нема ништа за увоз.</string>
<string name="import_error_nothing_cancelled">Увоз је отказан.</string>
- <string name="import_with_warnings">, са упозорењима</string>
- <string name="import_with_cancelled">, док није отказано</string>
+ <string name="with_warnings">, са упозорењима</string>
+ <string name="with_cancelled">, док није отказано</string>
<!--Intent labels-->
<string name="intent_decrypt_file">Дешифруј фајл помоћу Отвореног кључарника</string>
<string name="intent_import_key">Увези кључ у Отворени кључарник</string>
diff --git a/OpenKeychain/src/main/res/values-uk/strings.xml b/OpenKeychain/src/main/res/values-uk/strings.xml
index f38a542be..d3b3f1753 100644
--- a/OpenKeychain/src/main/res/values-uk/strings.xml
+++ b/OpenKeychain/src/main/res/values-uk/strings.xml
@@ -327,7 +327,7 @@
</plurals>
<string name="view_log">Переглянути журнал</string>
<string name="import_error_nothing">Нема що імпортувати.</string>
- <string name="import_with_warnings">, із застереженнями</string>
+ <string name="with_warnings">, із застереженнями</string>
<!--Intent labels-->
<string name="intent_decrypt_file">Розшифрувати файл з OpenKeychain</string>
<string name="intent_import_key">Імпортувати ключ з OpenKeychain</string>
diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml
index 28933ac89..4ce73b5cb 100644
--- a/OpenKeychain/src/main/res/values/strings.xml
+++ b/OpenKeychain/src/main/res/values/strings.xml
@@ -387,6 +387,11 @@
<string name="import_qr_code_too_short_fingerprint">"Fingerprint is too short (&lt; 16 characters)"</string>
<string name="import_qr_code_button">"Scan QR Code…"</string>
+ <!-- Generic result toast -->
+ <string name="view_log">"View Log"</string>
+ <string name="with_warnings">", with warnings"</string>
+ <string name="with_cancelled">", until cancelled"</string>
+
<!-- Import result toast -->
<plurals name="import_keys_added_and_updated_1">
<item quantity="one">"Successfully imported key"</item>
@@ -408,15 +413,26 @@
<item quantity="one">"Import failed for one key!"</item>
<item quantity="other">"Import failed for %d keys!"</item>
</plurals>
- <string name="view_log">"View Log"</string>
- <string name="import_error_nothing">"Nothing to import."</string>
- <string name="import_error_nothing_cancelled">"Import cancelled."</string>
- <string name="import_with_warnings">", with warnings"</string>
- <string name="import_with_cancelled">", until cancelled"</string>
<plurals name="import_error">
<item quantity="one">"Import failed!"</item>
<item quantity="other">"Import of %d keys failed!"</item>
</plurals>
+ <string name="import_error_nothing">"Nothing to import."</string>
+ <string name="import_error_nothing_cancelled">"Import cancelled."</string>
+
+ <!-- Certify result toast -->
+ <plurals name="certify_keys_ok">
+ <item quantity="one">"Successfully certified key%2$s."</item>
+ <item quantity="other">"Successfully certified %1$d keys%2$s."</item>
+ </plurals>
+ <plurals name="certify_keys_with_errors">
+ <item quantity="one">"Certification failed!"</item>
+ <item quantity="other">"Certification failed for %d keys!"</item>
+ </plurals>
+ <plurals name="certify_error">
+ <item quantity="one">"Certification failed!"</item>
+ <item quantity="other">"Certification of %d keys failed!"</item>
+ </plurals>
<!-- Intent labels -->
<string name="intent_decrypt_file">"Decrypt File with OpenKeychain"</string>
@@ -882,6 +898,7 @@
<item quantity="other">"Certifying %1$d user ids for key %2$s"</item>
</plurals>
<string name="msg_crt_error_master_not_found">"Master key not found!"</string>
+ <string name="msg_crt_error_nothing">"No keys certified!"</string>
<string name="msg_crt_error_unlock">"Error unlocking master key!"</string>
<string name="msg_crt_fp_mismatch">"Fingerprint mismatch, not certifying!"</string>
<string name="msg_crt">"Certifying keyrings"</string>