fix special mode indicator

This commit is contained in:
Vincent Breitmoser 2017-06-28 15:18:10 +02:00
parent fc7b9b7c21
commit 9064396814
3 changed files with 18 additions and 18 deletions

View file

@ -114,7 +114,7 @@ public class ComposeCryptoStatus {
return CryptoSpecialModeDisplayType.SIGN_ONLY;
}
if (isEncryptionEnabled() && isPgpInlineModeEnabled()) {
if (canEncrypt() && isPgpInlineModeEnabled()) {
return CryptoSpecialModeDisplayType.PGP_INLINE;
}

View file

@ -29,10 +29,6 @@ import com.fsck.k9.view.ToolableViewAnimator;
public class RecipientMvpView implements OnFocusChangeListener, OnClickListener {
private static final int VIEW_INDEX_HIDDEN = -1;
private static final int VIEW_INDEX_CRYPTO_SPECIAL_PGP_INLINE = 0;
private static final int VIEW_INDEX_CRYPTO_SPECIAL_SIGN_ONLY = 1;
private static final int VIEW_INDEX_CRYPTO_SPECIAL_SIGN_ONLY_PGP_INLINE = 2;
private static final int VIEW_INDEX_BCC_EXPANDER_VISIBLE = 0;
private static final int VIEW_INDEX_BCC_EXPANDER_HIDDEN = 1;
@ -51,7 +47,7 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
private final RecipientSelectView bccView;
private final ToolableViewAnimator cryptoStatusView;
private final ViewAnimator recipientExpanderContainer;
private final ViewAnimator cryptoSpecialModeIndicator;
private final ToolableViewAnimator cryptoSpecialModeIndicator;
private RecipientPresenter presenter;
@ -68,7 +64,7 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
recipientExpanderContainer = (ViewAnimator) activity.findViewById(R.id.recipient_expander_container);
cryptoStatusView = (ToolableViewAnimator) activity.findViewById(R.id.crypto_status);
cryptoStatusView.setOnClickListener(this);
cryptoSpecialModeIndicator = (ViewAnimator) activity.findViewById(R.id.crypto_special_mode);
cryptoSpecialModeIndicator = (ToolableViewAnimator) activity.findViewById(R.id.crypto_special_mode);
cryptoSpecialModeIndicator.setOnClickListener(this);
toView.setOnFocusChangeListener(this);
@ -292,14 +288,14 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
}
public void showCryptoSpecialMode(CryptoSpecialModeDisplayType cryptoSpecialModeDisplayType) {
boolean shouldBeHidden = cryptoSpecialModeDisplayType.childToDisplay == VIEW_INDEX_HIDDEN;
boolean shouldBeHidden = cryptoSpecialModeDisplayType.childIdToDisplay == VIEW_INDEX_HIDDEN;
if (shouldBeHidden) {
cryptoSpecialModeIndicator.setVisibility(View.GONE);
return;
}
cryptoSpecialModeIndicator.setVisibility(View.VISIBLE);
cryptoSpecialModeIndicator.setDisplayedChild(cryptoSpecialModeDisplayType.childToDisplay);
cryptoSpecialModeIndicator.setDisplayedChildId(cryptoSpecialModeDisplayType.childIdToDisplay);
activity.invalidateOptionsMenu();
}
@ -470,15 +466,15 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
public enum CryptoSpecialModeDisplayType {
NONE(VIEW_INDEX_HIDDEN),
PGP_INLINE(VIEW_INDEX_CRYPTO_SPECIAL_PGP_INLINE),
SIGN_ONLY(VIEW_INDEX_CRYPTO_SPECIAL_SIGN_ONLY),
SIGN_ONLY_PGP_INLINE(VIEW_INDEX_CRYPTO_SPECIAL_SIGN_ONLY_PGP_INLINE);
PGP_INLINE(R.id.crypto_special_inline),
SIGN_ONLY(R.id.crypto_special_sign_only),
SIGN_ONLY_PGP_INLINE(R.id.crypto_special_sign_only_inline);
final int childToDisplay;
final int childIdToDisplay;
CryptoSpecialModeDisplayType(int childToDisplay) {
this.childToDisplay = childToDisplay;
CryptoSpecialModeDisplayType(int childIdToDisplay) {
this.childIdToDisplay = childIdToDisplay;
}
}
}

View file

@ -50,16 +50,17 @@
android:layout_gravity="center_vertical"
android:id="@+id/crypto_special_mode"
android:visibility="gone"
tools:visibility="gone"
tools:visibility="visible"
android:inAnimation="@anim/fade_in"
android:outAnimation="@anim/fade_out"
custom:previewInitialChild="2">
custom:previewInitialChild="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="8dp"
android:id="@+id/crypto_special_inline"
android:src="@drawable/compatibility"
android:tint="@color/light_black"
/>
@ -69,13 +70,16 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="8dp"
android:id="@+id/crypto_special_sign_only"
android:src="@drawable/status_signature_verified_cutout"
android:tint="?attr/openpgp_blue"
/>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:id="@+id/crypto_special_sign_only_inline"
>
<ImageView
android:layout_width="wrap_content"