drop specialized MessageCryptoStatusView
This was introduced when the crypto icon was combined from an icon and dots. That's no longer the case, so we can simplify.
This commit is contained in:
parent
a592b0dfba
commit
c96ced3bc3
5 changed files with 35 additions and 77 deletions
|
@ -14,6 +14,7 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
|
|||
|
||||
public enum MessageCryptoDisplayStatus {
|
||||
LOADING (
|
||||
false,
|
||||
R.attr.openpgp_grey,
|
||||
R.drawable.status_lock_disabled
|
||||
),
|
||||
|
@ -26,6 +27,7 @@ public enum MessageCryptoDisplayStatus {
|
|||
),
|
||||
|
||||
DISABLED (
|
||||
false,
|
||||
R.attr.openpgp_grey,
|
||||
R.drawable.status_lock_disabled,
|
||||
R.string.crypto_msg_title_plaintext,
|
||||
|
@ -190,6 +192,7 @@ public enum MessageCryptoDisplayStatus {
|
|||
@DrawableRes public final int statusIconRes;
|
||||
@StringRes public final Integer titleTextRes;
|
||||
@StringRes public final Integer descriptionTextRes;
|
||||
public boolean isEnabled;
|
||||
|
||||
MessageCryptoDisplayStatus(@AttrRes int colorAttr, @DrawableRes int statusIconRes, @StringRes int titleTextRes,
|
||||
Integer descriptionTextRes) {
|
||||
|
@ -200,12 +203,20 @@ public enum MessageCryptoDisplayStatus {
|
|||
this.descriptionTextRes = descriptionTextRes;
|
||||
}
|
||||
|
||||
MessageCryptoDisplayStatus(@AttrRes int colorAttr, @DrawableRes int statusIconRes) {
|
||||
MessageCryptoDisplayStatus(boolean isEnabled, @AttrRes int colorAttr, @DrawableRes int statusIconRes,
|
||||
@StringRes int titleTextRes, Integer descriptionTextRes) {
|
||||
this(colorAttr, statusIconRes, titleTextRes, descriptionTextRes);
|
||||
this.isEnabled = isEnabled;
|
||||
}
|
||||
|
||||
MessageCryptoDisplayStatus(boolean isEnabled, @AttrRes int colorAttr, @DrawableRes int statusIconRes) {
|
||||
this.colorAttr = colorAttr;
|
||||
this.statusIconRes = statusIconRes;
|
||||
|
||||
this.titleTextRes = null;
|
||||
this.descriptionTextRes = null;
|
||||
|
||||
this.isEnabled = isEnabled;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
package com.fsck.k9.view;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.fsck.k9.ui.R;
|
||||
|
||||
|
||||
public class MessageCryptoStatusView extends FrameLayout {
|
||||
|
||||
private ImageView iconSingle;
|
||||
|
||||
public MessageCryptoStatusView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public MessageCryptoStatusView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public MessageCryptoStatusView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
iconSingle = findViewById(R.id.crypto_status_single);
|
||||
}
|
||||
|
||||
public void setCryptoDisplayStatus(MessageCryptoDisplayStatus displayStatus) {
|
||||
@ColorInt int color = ThemeUtils.getStyledColor(getContext(), displayStatus.colorAttr);
|
||||
|
||||
iconSingle.setImageResource(displayStatus.statusIconRes);
|
||||
iconSingle.setColorFilter(color);
|
||||
}
|
||||
}
|
|
@ -21,11 +21,11 @@ import android.text.format.DateUtils;
|
|||
import android.text.style.StyleSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnLongClickListener;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -60,7 +60,7 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
|
|||
private TextView mBccView;
|
||||
private TextView mBccLabel;
|
||||
private TextView mSubjectView;
|
||||
private MessageCryptoStatusView mCryptoStatusIcon;
|
||||
private ImageView mCryptoStatusIcon;
|
||||
|
||||
private View mChip;
|
||||
private CheckBox mFlagged;
|
||||
|
@ -376,21 +376,23 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
|
|||
}
|
||||
|
||||
public void setCryptoStatusLoading() {
|
||||
mCryptoStatusIcon.setVisibility(View.VISIBLE);
|
||||
mCryptoStatusIcon.setEnabled(false);
|
||||
mCryptoStatusIcon.setCryptoDisplayStatus(MessageCryptoDisplayStatus.LOADING);
|
||||
setCryptoDisplayStatus(MessageCryptoDisplayStatus.LOADING);
|
||||
}
|
||||
|
||||
public void setCryptoStatusDisabled() {
|
||||
mCryptoStatusIcon.setVisibility(View.VISIBLE);
|
||||
mCryptoStatusIcon.setEnabled(false);
|
||||
mCryptoStatusIcon.setCryptoDisplayStatus(MessageCryptoDisplayStatus.DISABLED);
|
||||
setCryptoDisplayStatus(MessageCryptoDisplayStatus.DISABLED);
|
||||
}
|
||||
|
||||
public void setCryptoStatus(MessageCryptoDisplayStatus displayStatus) {
|
||||
setCryptoDisplayStatus(displayStatus);
|
||||
}
|
||||
|
||||
private void setCryptoDisplayStatus(MessageCryptoDisplayStatus displayStatus) {
|
||||
int color = ThemeUtils.getStyledColor(getContext(), displayStatus.colorAttr);
|
||||
mCryptoStatusIcon.setEnabled(displayStatus.isEnabled);
|
||||
mCryptoStatusIcon.setVisibility(View.VISIBLE);
|
||||
mCryptoStatusIcon.setEnabled(true);
|
||||
mCryptoStatusIcon.setCryptoDisplayStatus(displayStatus);
|
||||
mCryptoStatusIcon.setImageResource(displayStatus.statusIconRes);
|
||||
mCryptoStatusIcon.setColorFilter(color);
|
||||
}
|
||||
|
||||
public void onShowAdditionalHeaders() {
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.fsck.k9.view.MessageCryptoStatusView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:custom="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/crypto_status_icon"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:visibility="gone"
|
||||
custom:previewInitialChild="0"
|
||||
android:background="?selectableItemBackground"
|
||||
tools:showIn="@layout/message_view_header"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:id="@+id/crypto_status_single"
|
||||
android:src="@drawable/status_lock_disabled"
|
||||
android:tint="?attr/openpgp_grey"
|
||||
/>
|
||||
|
||||
</com.fsck.k9.view.MessageCryptoStatusView>
|
|
@ -241,15 +241,24 @@
|
|||
-->
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon_single_message_options"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/icon_single_message_options"
|
||||
android:src="?iconActionSingleMessageOptions"
|
||||
android:padding="8dp"
|
||||
android:background="?selectableItemBackground"
|
||||
/>
|
||||
|
||||
<include layout="@layout/message_crypto_status_view" />
|
||||
<ImageView
|
||||
android:id="@+id/crypto_status_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:padding="8dp"
|
||||
android:src="@drawable/status_lock_disabled"
|
||||
android:tint="?attr/openpgp_grey"
|
||||
android:background="?selectableItemBackground"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue