...
 
Commits (15)
......@@ -5,6 +5,7 @@ import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.DrawableRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
......@@ -78,12 +79,13 @@ public abstract class K9Activity extends AppCompatActivity implements K9Activity
// }
public void setUpToolbar(boolean showUpButton) {
public void setUpToolbar(boolean showUpButton, @DrawableRes Integer... drawable) {
if (toolbar != null) {
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(showUpButton);
if (drawable.length > 0)
getSupportActionBar().setHomeAsUpIndicator(drawable[0]);
}
if (K9.getK9Theme() == K9.Theme.DARK) {
toolbar.setPopupTheme(R.style.PEpThemeOverlay);
......
......@@ -97,6 +97,7 @@ import javax.inject.Inject;
import foundation.pEp.jniadapter.Rating;
import security.pEp.permissions.PermissionRequester;
import security.pEp.ui.PEpUIUtils;
import security.pEp.ui.resources.ResourcesProvider;
import security.pEp.ui.toolbar.ToolBarCustomizer;
import timber.log.Timber;
......@@ -119,7 +120,8 @@ public class MessageList extends PepActivity implements MessageListFragmentListe
ToolBarCustomizer toolBarCustomizer;
@Inject
Preferences preferences;
@Inject
ResourcesProvider resourcesProvider;
@Deprecated
//TODO: Remove after 2017-09-11
......@@ -2157,6 +2159,9 @@ public class MessageList extends PepActivity implements MessageListFragmentListe
if (mDisplayMode != DisplayMode.SPLIT_VIEW) {
showMessageView();
}
setUpToolbar(true, resourcesProvider.getAttributeResource(R.attr.iconActionCancel));
}
}
......@@ -2265,6 +2270,8 @@ public class MessageList extends PepActivity implements MessageListFragmentListe
if (transactionId >= 0 && mFirstBackStackId < 0) {
mFirstBackStackId = transactionId;
}
setUpToolbar(true, resourcesProvider.getAttributeResource(R.attr.iconActionPreviousMessage));
}
@Override
......
......@@ -39,6 +39,7 @@ import java.util.List;
import foundation.pEp.jniadapter.Identity;
import foundation.pEp.jniadapter.Rating;
import security.pEp.ui.message_compose.ComposeAccountRecipient;
public class RecipientMvpView implements OnFocusChangeListener, OnClickListener {
......@@ -68,7 +69,7 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
private final ActionRecipientSelectView toView;
private final ActionRecipientSelectView ccView;
private final ActionRecipientSelectView bccView;
private final TextView fromView;
private final ComposeAccountRecipient fromView;
private final ViewAnimator cryptoStatusView;
private final ViewAnimator recipientExpanderContainer;
private final Account mAccount;
......@@ -85,7 +86,7 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
public RecipientMvpView(MessageCompose activity) {
this.activity = activity;
this.mAccount = activity.getAccount();
fromView = (TextView) activity.findViewById(R.id.identity);
fromView = activity.findViewById(R.id.identity);
toView = (ActionRecipientSelectView) activity.findViewById(R.id.to);
ccView = (ActionRecipientSelectView) activity.findViewById(R.id.cc);
bccView = (ActionRecipientSelectView) activity.findViewById(R.id.bcc);
......@@ -601,7 +602,7 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
}
public String getFrom() {
return fromView.getText().toString();
return fromView.getText();
}
public enum CryptoSpecialModeDisplayType {
......
......@@ -22,6 +22,8 @@ import dagger.Module;
import dagger.Provides;
import security.pEp.permissions.PermissionChecker;
import security.pEp.ui.permissions.PEpPermissionChecker;
import security.pEp.ui.resources.PEpResourcesProvider;
import security.pEp.ui.resources.ResourcesProvider;
@Module
public class PEpModule {
......@@ -76,4 +78,10 @@ public class PEpModule {
public Preferences providePreferences() {
return Preferences.getPreferences(context);
}
@Provides
public ResourcesProvider providepEpResourcesProvider() {
return new PEpResourcesProvider(context.getApplicationContext());
}
}
......@@ -10,12 +10,9 @@ import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.style.StyleSpan;
import android.util.AttributeSet;
import timber.log.Timber;
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.PopupMenu;
......@@ -39,22 +36,22 @@ import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.pEp.PEpProvider;
import com.fsck.k9.pEp.PEpUtils;
import com.fsck.k9.pEp.PePUIArtefactCache;
import com.fsck.k9.pEp.ui.PEpContactBadge;
import com.fsck.k9.pEp.ui.infrastructure.MessageAction;
import com.fsck.k9.pEp.ui.listeners.OnMessageOptionsListener;
import com.fsck.k9.pEp.ui.tools.FeedbackTools;
import com.fsck.k9.pEp.PePUIArtefactCache;
import com.fsck.k9.ui.messageview.OnCryptoClickListener;
import foundation.pEp.jniadapter.Rating;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import foundation.pEp.jniadapter.Rating;
import timber.log.Timber;
public class MessageHeader extends LinearLayout implements OnClickListener, OnLongClickListener {
private Context mContext;
......@@ -87,10 +84,8 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
private OnCryptoClickListener onCryptoClickListener;
private Rating pEpRating;
private PePUIArtefactCache pePUIArtefactCache;
private OnMessageOptionsListener onMessageOptionsListener;
private ImageView replyMessage;
private ImageView moreOptions;
public void setOnMessageOptionsListener(OnMessageOptionsListener onMessageOptionsListener) {
......@@ -115,7 +110,6 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
super(context, attrs);
mContext = context;
mContacts = Contacts.getInstance(mContext);
pePUIArtefactCache = PePUIArtefactCache.getInstance(context);
}
@Override
......@@ -124,56 +118,47 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
mAnsweredIcon = findViewById(R.id.answered);
mForwardedIcon = findViewById(R.id.forwarded);
mFromView = (TextView) findViewById(R.id.from);
mSenderView = (TextView) findViewById(R.id.sender);
mToView = (TextView) findViewById(R.id.to);
mToLabel = (TextView) findViewById(R.id.to_label);
mCcView = (TextView) findViewById(R.id.cc);
mCcLabel = (TextView) findViewById(R.id.cc_label);
replyMessage = (ImageView) findViewById(R.id.reply_message);
moreOptions = (ImageView) findViewById(R.id.message_more_options);
replyMessage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onMessageOptionsListener.OnMessageOptionsListener(MessageAction.REPLY);
}
});
mFromView = findViewById(R.id.from);
mSenderView = findViewById(R.id.sender);
mToView = findViewById(R.id.to);
mToLabel = findViewById(R.id.to_label);
mCcView = findViewById(R.id.cc);
mCcLabel = findViewById(R.id.cc_label);
moreOptions = findViewById(R.id.message_more_options);
moreOptions.setOnClickListener(view -> {
PopupMenu popupMenu = new PopupMenu(getContext(), view);
popupMenu.getMenuInflater().inflate(R.menu.message_more_options_menu, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(item -> {
switch (item.getItemId()) {
case R.id.reply:
onMessageOptionsListener.OnMessageOptionsListener(MessageAction.REPLY);
break;
case R.id.reply_all:
onMessageOptionsListener.OnMessageOptionsListener(MessageAction.REPLY_ALL);
break;
case R.id.forward:
onMessageOptionsListener.OnMessageOptionsListener(MessageAction.FORWARD);
break;
case R.id.share:
onMessageOptionsListener.OnMessageOptionsListener(MessageAction.SHARE);
break;
}
return true;
});
moreOptions.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
PopupMenu popupMenu = new PopupMenu(getContext(), view);
popupMenu.getMenuInflater().inflate(R.menu.message_more_options_menu, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.reply_all:
onMessageOptionsListener.OnMessageOptionsListener(MessageAction.REPLY_ALL);
break;
case R.id.forward:
onMessageOptionsListener.OnMessageOptionsListener(MessageAction.FORWARD);
break;
case R.id.share:
onMessageOptionsListener.OnMessageOptionsListener(MessageAction.SHARE);
break;
}
return true;
}
});
popupMenu.show();
}
popupMenu.show();
});
mContactBadge = (PEpContactBadge) findViewById(R.id.contact_badge);
mContactBadge = findViewById(R.id.contact_badge);
mSubjectView = (TextView) findViewById(R.id.subject);
mAdditionalHeadersView = (TextView) findViewById(R.id.additional_headers_view);
mSubjectView = findViewById(R.id.subject);
mAdditionalHeadersView = findViewById(R.id.additional_headers_view);
mChip = findViewById(R.id.chip);
mDateView = (TextView) findViewById(R.id.date);
mDateView = findViewById(R.id.date);
defaultSubjectColor = mSubjectView.getCurrentTextColor();
mFontSizes.setViewTextSize(mSubjectView, mFontSizes.getMessageViewSubject());
......
package security.pEp.ui.message_compose
import android.content.Context
import android.util.AttributeSet
import android.widget.LinearLayout
import com.fsck.k9.helper.ContactPicture
import com.fsck.k9.mail.Address
import kotlinx.android.synthetic.main.compose_account_item.view.*
class ComposeAccountRecipient(context: Context?, attrs: AttributeSet?) : LinearLayout(context, attrs) {
fun bindView(name: String) {
ContactPicture.getContactPictureLoader(context).loadContactPicture(Address(name), accountImage)
accountName.text = name
}
fun getText(): String {
return accountName.text.toString()
}
}
\ No newline at end of file
package security.pEp.ui.resources
import android.content.Context
import android.content.res.TypedArray
import androidx.annotation.AttrRes
import com.fsck.k9.K9
interface ResourcesProvider {
fun getAttributeResource(@AttrRes resource: Int): Int
}
class PEpResourcesProvider(private val context: Context) : ResourcesProvider {
override fun getAttributeResource(resource: Int): Int {
val a: TypedArray = context.theme.obtainStyledAttributes(K9.getK9ThemeResourceId(), intArrayOf(resource))
return a.getResourceId(0, 0)
}
}
<?xml version="1.0" encoding="utf-8"?>
<security.pEp.ui.message_compose.ComposeAccountRecipient xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/identity"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:background="@drawable/recipient_token_shape"
android:orientation="horizontal"
android:padding="0dp">
<com.fsck.k9.pEp.ui.PEpContactBadge
android:id="@+id/accountImage"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginStart="3dp"
android:clickable="false"
android:gravity="center_vertical"
tools:src="@drawable/ic_contact_picture" />
<TextView
android:id="@+id/accountName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
tools:text="francisco.cunha@peptest.ch" />
</security.pEp.ui.message_compose.ComposeAccountRecipient>
\ No newline at end of file
......@@ -20,8 +20,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/download_remainder"
android:clipToPadding="false"
android:padding="8dp">
android:clipToPadding="false">
<LinearLayout
android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<com.fsck.k9.ui.messageview.MessageContainerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Content area -->
<com.fsck.k9.view.MessageWebView
android:id="@+id/message_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
android:layout_marginStart="@dimen/outer_margin"
android:layout_marginEnd="@dimen/outer_margin" />
<!-- Unsigned content area -->
<LinearLayout
android:id="@+id/message_unsigned_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/outer_margin"
android:layout_marginEnd="@dimen/outer_margin"
android:orientation="vertical"
android:id="@+id/message_unsigned_container"
android:visibility="gone"
tools:visibility="visible" >
tools:visibility="visible">
<LinearLayout
android:id="@+id/message_unsigned_divider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
>
android:layout_marginTop="4dp">
<View
android:layout_width="16dp"
android:layout_height="4dp"
android:layout_marginTop="1dp"
android:layout_gravity="center_vertical"
android:background="#d55"
/>
android:layout_marginTop="1dp"
android:background="#d55" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:textAppearance="?android:textAppearanceSmall"
android:text="@string/unsigned_text_divider_label"
android:textColor="#d55"
/>
android:textAppearance="?android:textAppearanceSmall"
android:textColor="#d55" />
<View
android:layout_width="wrap_content"
android:layout_height="4dp"
android:layout_marginTop="1dp"
android:layout_gravity="center_vertical"
android:layout_marginTop="1dp"
android:background="#d55" />
</LinearLayout>
<TextView
android:id="@+id/message_unsigned_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:padding="8dp"
tools:text="Unsigned text content"
/>
tools:text="Unsigned text content" />
</LinearLayout>
<!-- Attachments area -->
<LinearLayout
android:id="@+id/attachments_container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#E1E1E1" />
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/attachments"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
android:orientation="vertical" />
</LinearLayout>
</com.fsck.k9.ui.messageview.MessageContainerView>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:background="@drawable/recipient_token_shape"
android:padding="4dp">
android:orientation="horizontal"
android:padding="0dp">
<com.fsck.k9.pEp.ui.PEpContactBadge
android:id="@+id/contact_photo"
android:layout_width="32dp"
android:layout_height="32dp"
android:gravity="center_vertical"
android:id="@+id/contact_photo"
tools:src="@drawable/ic_contact_picture"
android:layout_marginStart="3dp"
android:clickable="false"
android:layout_marginLeft="3dp"
/>
android:gravity="center_vertical"
tools:src="@drawable/ic_contact_picture" />
<TextView
android:id="@android:id/text1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@android:id/text1"
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:maxLines="1"
android:layout_weight="1"
android:ellipsize="end"
tools:text="Name"
/>
android:maxLines="1"
tools:text="Name" />
<ImageView
android:id="@+id/contact_crypto_status_red"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_marginEnd="6dp"
android:layout_gravity="center_vertical"
android:id="@+id/contact_crypto_status_red"
android:src="@drawable/status_dots_1"
android:layout_marginEnd="6dp"
android:tint="?attr/openpgp_red"
android:visibility="gone"
/>
app:srcCompat="@drawable/status_dots_1" />
<ImageView
android:id="@+id/contact_crypto_status_orange"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_marginEnd="6dp"
android:layout_gravity="center_vertical"
android:id="@+id/contact_crypto_status_orange"
android:src="@drawable/status_dots_2"
android:layout_marginEnd="6dp"
android:tint="?attr/openpgp_orange"
android:visibility="gone"
tools:visibility="visible"
/>
app:srcCompat="@drawable/status_dots_2"
tools:visibility="visible" />
<ImageView
android:id="@+id/contact_crypto_status_green"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_marginEnd="6dp"
android:layout_gravity="center_vertical"
android:id="@+id/contact_crypto_status_green"
android:src="@drawable/status_dots_3"
android:layout_marginEnd="6dp"
android:tint="?attr/openpgp_green"
android:visibility="gone"
/>
app:srcCompat="@drawable/status_dots_3" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/reply"
android:title="@string/reply_action"/>
<item
android:id="@+id/reply_all"
android:title="@string/reply_all_action"/>
......
......@@ -57,4 +57,7 @@
<color name="status_todo_chevron">#888</color>
<color name="status_error_cross">#f44336</color>
<color name="status_ok_checkmark">#7bad45</color>
<color name="compose_gray">#FFAAAAAA</color>
</resources>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="pep_sync_add_device_padding_vertical">8dp</dimen>
......
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="outer_margin">16dp</dimen>
<dimen name="outer_margin_small">8dp</dimen>
<dimen name="min_height">52dp</dimen>
<dimen name="min_label_width">52dp</dimen>
</resources>
......@@ -35,16 +35,26 @@
<item name="android:shadowRadius">4.0</item>
</style>
<style name="ComposeTextLabel" parent="@android:style/TextAppearance.Medium">
<item name="android:textSize">15sp</item>
<item name="android:textColor">#aaa</item>
<style name="ComposeLabel" parent="@android:style/TextAppearance.Small">
<item name="android:textColor">@color/compose_gray</item>
</style>
<style name="ComposeEditText" parent="@android:style/TextAppearance.Medium">
<item name="android:textSize">15sp</item>
<item name="android:textColorHint">#aaa</item>
<style name="ComposeLabelLarge" parent="@android:style/TextAppearance.Medium">
<item name="android:textColor">@color/compose_gray</item>
</style>
<style name="ComposeText" parent="@android:style/TextAppearance.Small">
<item name="android:textColorHint">@color/compose_gray</item>
</style>
<style name="ComposeEditTextLarge" parent="@android:style/TextAppearance.Medium">
<item name="android:textColorHint">#aaa</item>
<style name="ComposeTextLarge" parent="@android:style/TextAppearance.Medium">
<item name="android:textColorHint">@color/compose_gray</item>
</style>
<style name="ComposeEditTextLarge" parent="ComposeTextLarge">
<item name="background">@android:color/transparent</item>
<item name="android:background">@android:color/transparent</item>
<item name="android:inputType">textMultiLine|textAutoCorrect|textCapSentences</item>
</style>
<style name="ShowcaseTheme" parent="ShowcaseView.Light">
......