From 61a6346f896806c9e21fba5e43997b06853e4b2c Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 30 May 2015 02:24:45 +0200 Subject: show status indicators in EncryptFragment --- .../keychain/ui/EncryptModeAsymmetricFragment.java | 33 ++++++++ OpenKeychain/src/main/res/anim/fade_in.xml | 7 ++ OpenKeychain/src/main/res/anim/fade_out.xml | 7 ++ .../res/layout/encrypt_asymmetric_fragment.xml | 99 ++++++++++++++++++---- 4 files changed, 129 insertions(+), 17 deletions(-) create mode 100644 OpenKeychain/src/main/res/anim/fade_in.xml create mode 100644 OpenKeychain/src/main/res/anim/fade_out.xml diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptModeAsymmetricFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptModeAsymmetricFragment.java index 258a9b3dc..9c7e494d1 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptModeAsymmetricFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptModeAsymmetricFragment.java @@ -21,7 +21,9 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ViewAnimator; +import com.tokenautocomplete.TokenCompleteTextView.TokenListener; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing; @@ -33,6 +35,7 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException import org.sufficientlysecure.keychain.ui.adapter.KeyAdapter.KeyItem; import org.sufficientlysecure.keychain.ui.widget.EncryptKeyCompletionView; import org.sufficientlysecure.keychain.ui.widget.KeySpinner; +import org.sufficientlysecure.keychain.ui.widget.KeySpinner.OnKeyChangedListener; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; @@ -72,10 +75,40 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.encrypt_asymmetric_fragment, container, false); + mSignKeySpinner = (KeySpinner) view.findViewById(R.id.sign); mEncryptKeyView = (EncryptKeyCompletionView) view.findViewById(R.id.recipient_list); mEncryptKeyView.setThreshold(1); // Start working from first character + final ViewAnimator vSignatureIcon = (ViewAnimator) view.findViewById(R.id.result_signature_icon); + mSignKeySpinner.setOnKeyChangedListener(new OnKeyChangedListener() { + @Override + public void onKeyChanged(long masterKeyId) { + int child = masterKeyId != Constants.key.none ? 1 : 0; + if (vSignatureIcon.getDisplayedChild() != child) { + vSignatureIcon.setDisplayedChild(child); + } + } + }); + + final ViewAnimator vEncryptionIcon = (ViewAnimator) view.findViewById(R.id.result_encryption_icon); + mEncryptKeyView.setTokenListener(new TokenListener() { + @Override + public void onTokenAdded(Object o) { + if (vEncryptionIcon.getDisplayedChild() != 1) { + vEncryptionIcon.setDisplayedChild(1); + } + } + + @Override + public void onTokenRemoved(Object o) { + int child = mEncryptKeyView.getObjects().isEmpty() ? 0 : 1; + if (vEncryptionIcon.getDisplayedChild() != child) { + vEncryptionIcon.setDisplayedChild(child); + } + } + }); + return view; } diff --git a/OpenKeychain/src/main/res/anim/fade_in.xml b/OpenKeychain/src/main/res/anim/fade_in.xml new file mode 100644 index 000000000..7c3475326 --- /dev/null +++ b/OpenKeychain/src/main/res/anim/fade_in.xml @@ -0,0 +1,7 @@ + + + + diff --git a/OpenKeychain/src/main/res/anim/fade_out.xml b/OpenKeychain/src/main/res/anim/fade_out.xml new file mode 100644 index 000000000..9a9dbbbc8 --- /dev/null +++ b/OpenKeychain/src/main/res/anim/fade_out.xml @@ -0,0 +1,7 @@ + + + + diff --git a/OpenKeychain/src/main/res/layout/encrypt_asymmetric_fragment.xml b/OpenKeychain/src/main/res/layout/encrypt_asymmetric_fragment.xml index aa295050a..56647ec65 100644 --- a/OpenKeychain/src/main/res/layout/encrypt_asymmetric_fragment.xml +++ b/OpenKeychain/src/main/res/layout/encrypt_asymmetric_fragment.xml @@ -3,39 +3,104 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" + android:paddingTop="4dp" android:paddingBottom="4dp" android:paddingRight="16dp" android:paddingLeft="16dp"> - + android:layout_height="wrap_content" + android:padding="0dp" + android:layout_margin="0dp"> + + + + + + + + + + + + + android:layout_margin="0dp"> - + android:id="@+id/result_signature_icon" + android:layout_gravity="center_vertical" + android:layout_marginRight="4dp" + android:layout_marginEnd="4dp" + android:inAnimation="@anim/fade_in" + android:outAnimation="@anim/fade_out"> - + + + + + + + android:padding="0dp" + android:layout_margin="0dp" + style="@android:style/Widget.EditText"> + + + + + + \ No newline at end of file -- cgit v1.2.3