show status indicators in EncryptFragment

This commit is contained in:
Vincent Breitmoser 2015-05-30 02:24:45 +02:00
parent 313b4ac7d3
commit 61a6346f89
4 changed files with 130 additions and 18 deletions

View File

@ -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;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:interpolator="@android:anim/bounce_interpolator"
android:duration="700"
/>
</set>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="300"
/>
</set>

View File

@ -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">
<org.sufficientlysecure.keychain.ui.widget.EncryptKeyCompletionView
android:id="@+id/recipient_list"
android:layout_width="match_parent"
android:minHeight="56dip"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="0dp"
android:layout_margin="0dp"
style="@android:style/Widget.EditText">
android:layout_margin="0dp">
<TextView
android:paddingLeft="8dp"
<ViewAnimator
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/label_asymmetric_from"
android:paddingRight="8dp"/>
android:id="@+id/result_encryption_icon"
android:layout_gravity="center_vertical"
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
android:paddingBottom="12dp"
android:inAnimation="@anim/fade_in"
android:outAnimation="@anim/fade_out">
<org.sufficientlysecure.keychain.ui.widget.SignKeySpinner
android:id="@+id/sign"
android:minHeight="56dip"
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/status_lock_open_24dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/status_lock_closed_24dp" />
</ViewAnimator>
<org.sufficientlysecure.keychain.ui.widget.EncryptKeyCompletionView
android:id="@+id/recipient_list"
android:layout_width="match_parent"
android:minHeight="56dip"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="0dp"
android:layout_margin="0dp">
<ViewAnimator
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/status_signature_unverified_cutout_24dp"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/status_signature_verified_cutout_24dp"
/>
</ViewAnimator>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="0dp"
android:layout_margin="0dp"
style="@android:style/Widget.EditText">
<TextView
android:paddingLeft="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/label_asymmetric_from"
android:paddingRight="8dp"/>
<org.sufficientlysecure.keychain.ui.widget.SignKeySpinner
android:id="@+id/sign"
android:minHeight="56dip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
</LinearLayout>
</LinearLayout>