From 41545e5e52cd75b3408c127feeb43d4f2bd86e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ha=C3=9F?= Date: Sun, 15 Jun 2014 19:59:41 +0200 Subject: [PATCH 1/7] Added notification wrapper for toast like notifys --- .../keychain/ui/adapter/Notify.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/Notify.java diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/Notify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/Notify.java new file mode 100644 index 000000000..5b8979235 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/Notify.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2012-2014 Dominik Schürmann + * Copyright (C) 2011 Senecaso + * + * 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.sufficientlysecure.keychain.ui.adapter; + +import android.app.Activity; +import android.content.res.Resources; + +import com.github.johnpersano.supertoasts.SuperCardToast; +import com.github.johnpersano.supertoasts.SuperToast; + +/** + * @author danielhass + * Notify wrapper which allows a more easy use of different notification libraries + */ +public class Notify { + + public static enum Style {OK, WARN, ERROR} + + /** + * Shows a simple in-layout notification with the CharSequence given as parameter + * @param activity + * @param text Text to show + * @param style Notification styling + */ + public static void showNotify(Activity activity, CharSequence text, Style style) { + + SuperCardToast st = new SuperCardToast(activity); + st.setText(text); + st.setDuration(SuperToast.Duration.MEDIUM); + switch (style){ + case OK: + st.setBackground(SuperToast.Background.GREEN); + break; + case WARN: + st.setBackground(SuperToast.Background.ORANGE); + break; + case ERROR: + st.setBackground(SuperToast.Background.RED); + break; + } + st.show(); + + } + + /** + * Shows a simple in-layout notification with the resource text from given id + * @param activity + * @param resId ResourceId of notification text + * @param style Notification styling + * @throws Resources.NotFoundException + */ + public static void showNotify(Activity activity, int resId, Style style) throws Resources.NotFoundException { + showNotify(activity, activity.getResources().getText(resId), style); + } +} \ No newline at end of file From 998f6166077693781f79268d191b776516d04cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ha=C3=9F?= Date: Sun, 15 Jun 2014 20:02:09 +0200 Subject: [PATCH 2/7] Added notification area as reusable layout --- .../src/main/res/layout/notification_area.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 OpenKeychain/src/main/res/layout/notification_area.xml diff --git a/OpenKeychain/src/main/res/layout/notification_area.xml b/OpenKeychain/src/main/res/layout/notification_area.xml new file mode 100644 index 000000000..d1ba265a5 --- /dev/null +++ b/OpenKeychain/src/main/res/layout/notification_area.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file From e48d5e4474a19cb81fa1842f35c85906c6ce5132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ha=C3=9F?= Date: Sun, 15 Jun 2014 20:03:40 +0200 Subject: [PATCH 3/7] Replaced AppMsg with notify wrapper call --- .../sufficientlysecure/keychain/ui/DecryptFileFragment.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index d953e2591..6805ae49a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -24,6 +24,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.Messenger; +import android.provider.SyncStateContract; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -39,6 +40,7 @@ import org.sufficientlysecure.keychain.helper.FileHelper; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; +import org.sufficientlysecure.keychain.ui.adapter.Notify; import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment; import org.sufficientlysecure.keychain.util.Log; @@ -115,7 +117,8 @@ public class DecryptFileFragment extends DecryptFragment { } if (mInputFilename.equals("")) { - AppMsg.makeText(getActivity(), R.string.no_file_selected, AppMsg.STYLE_ALERT).show(); + //AppMsg.makeText(getActivity(), R.string.no_file_selected, AppMsg.STYLE_ALERT).show(); + Notify.showNotify(getActivity(), R.string.no_file_selected, Notify.Style.ERROR); return; } From 76d733cbc7175c7c7635cc96364e889f839993bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ha=C3=9F?= Date: Sun, 15 Jun 2014 20:04:31 +0200 Subject: [PATCH 4/7] Added notification area to decrypt content --- OpenKeychain/src/main/res/layout/decrypt_content.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenKeychain/src/main/res/layout/decrypt_content.xml b/OpenKeychain/src/main/res/layout/decrypt_content.xml index a496d8b9d..866857143 100644 --- a/OpenKeychain/src/main/res/layout/decrypt_content.xml +++ b/OpenKeychain/src/main/res/layout/decrypt_content.xml @@ -6,6 +6,8 @@ android:layout_height="match_parent" android:orientation="vertical"> + + Date: Sun, 15 Jun 2014 20:11:40 +0200 Subject: [PATCH 5/7] Removed unused import --- .../org/sufficientlysecure/keychain/ui/DecryptFileFragment.java | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index 6805ae49a..f0bdabe93 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -24,7 +24,6 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.Messenger; -import android.provider.SyncStateContract; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; From 5bd0b5011e2af23dc8b1054f65c9459bdeddcd8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ha=C3=9F?= Date: Mon, 16 Jun 2014 13:13:43 +0200 Subject: [PATCH 6/7] Moved Notify class to utils --- .../org/sufficientlysecure/keychain/ui/DecryptFileFragment.java | 2 +- .../keychain/{ui/adapter => util}/Notify.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename OpenKeychain/src/main/java/org/sufficientlysecure/keychain/{ui/adapter => util}/Notify.java (97%) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index f0bdabe93..7fdab7bdd 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -39,7 +39,7 @@ import org.sufficientlysecure.keychain.helper.FileHelper; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; -import org.sufficientlysecure.keychain.ui.adapter.Notify; +import org.sufficientlysecure.keychain.util.Notify; import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment; import org.sufficientlysecure.keychain.util.Log; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/Notify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Notify.java similarity index 97% rename from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/Notify.java rename to OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Notify.java index 5b8979235..245a99be7 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/Notify.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Notify.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.sufficientlysecure.keychain.ui.adapter; +package org.sufficientlysecure.keychain.util; import android.app.Activity; import android.content.res.Resources; From da28c000adf57baab1c282cc6efd3f1d8eb9e392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ha=C3=9F?= Date: Mon, 16 Jun 2014 13:19:34 +0200 Subject: [PATCH 7/7] Changed license header --- .../keychain/util/Notify.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Notify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Notify.java index 245a99be7..67f81fb24 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Notify.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Notify.java @@ -1,18 +1,18 @@ /* - * Copyright (C) 2012-2014 Dominik Schürmann - * Copyright (C) 2011 Senecaso + * Copyright (C) 2014 Dominik Schürmann * - * 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 + * 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. * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. * - * 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. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package org.sufficientlysecure.keychain.util;