move sign-only into a mode of its own
This commit is contained in:
parent
cedaecb38e
commit
d40a046bf6
18 changed files with 352 additions and 270 deletions
3
images/drawables-pgp/24x24/bullet_point_neutral.svg
Normal file
3
images/drawables-pgp/24x24/bullet_point_neutral.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg id="Capa_1" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" style="enable-background:new 0 0 457.47 457.469;" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" height="457.47px" viewBox="0 0 457.47 457.469" width="457.47px" version="1.1" y="0px" x="0px" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata id="metadata41"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/><dc:title/></cc:Work></rdf:RDF></metadata><g id="g3" transform="matrix(0.57627118,0,0,0.57627118,96.921399,96.921399)"><path id="path5" d="M228.75,96.906c-72.8,0-131.84,59.044-131.84,131.84,0,72.8,59.044,131.81,131.84,131.81,72.8,0,131.81-59.01,131.81-131.81s-59.01-131.84-131.81-131.84zm0,76.594c30.51,0,55.22,24.74,55.22,55.25s-24.71,55.22-55.22,55.22-55.25-24.71-55.25-55.22,24.74-55.25,55.25-55.25z" transform="matrix(1.7352942,0,0,1.7352942,-168.18714,-168.18714)"/></g></svg>
|
After Width: | Height: | Size: 1.1 KiB |
|
@ -256,6 +256,7 @@ public class K9 extends Application {
|
|||
private static boolean sMessageViewSpamActionVisible = false;
|
||||
|
||||
private static int sPgpInlineDialogCounter;
|
||||
private static int sPgpSignOnlyDialogCounter;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -495,6 +496,7 @@ public class K9 extends Application {
|
|||
editor.putBoolean("messageViewSpamActionVisible", sMessageViewSpamActionVisible);
|
||||
|
||||
editor.putInt("pgpInlineDialogCounter", sPgpInlineDialogCounter);
|
||||
editor.putInt("pgpSignOnlyDialogCounter", sPgpSignOnlyDialogCounter);
|
||||
|
||||
fontSizes.save(editor);
|
||||
}
|
||||
|
@ -743,6 +745,7 @@ public class K9 extends Application {
|
|||
sMessageViewSpamActionVisible = storage.getBoolean("messageViewSpamActionVisible", false);
|
||||
|
||||
sPgpInlineDialogCounter = storage.getInt("pgpInlineDialogCounter", 0);
|
||||
sPgpSignOnlyDialogCounter = storage.getInt("pgpSignOnlyDialogCounter", 0);
|
||||
|
||||
K9.setK9Language(storage.getString("language", ""));
|
||||
|
||||
|
@ -1329,6 +1332,14 @@ public class K9 extends Application {
|
|||
K9.sPgpInlineDialogCounter = pgpInlineDialogCounter;
|
||||
}
|
||||
|
||||
public static int getPgpSignOnlyDialogCounter() {
|
||||
return sPgpSignOnlyDialogCounter;
|
||||
}
|
||||
|
||||
public static void setPgpSignOnlyDialogCounter(int pgpSignOnlyDialogCounter) {
|
||||
K9.sPgpSignOnlyDialogCounter = pgpSignOnlyDialogCounter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we already know whether all databases are using the current database schema.
|
||||
*
|
||||
|
|
|
@ -60,6 +60,7 @@ import com.fsck.k9.activity.compose.CryptoSettingsDialog.OnCryptoModeChangedList
|
|||
import com.fsck.k9.activity.compose.IdentityAdapter;
|
||||
import com.fsck.k9.activity.compose.IdentityAdapter.IdentityContainer;
|
||||
import com.fsck.k9.activity.compose.PgpInlineDialog.OnOpenPgpInlineChangeListener;
|
||||
import com.fsck.k9.activity.compose.PgpSignOnlyDialog.OnOpenPgpSignOnlyChangeListener;
|
||||
import com.fsck.k9.activity.compose.RecipientMvpView;
|
||||
import com.fsck.k9.activity.compose.RecipientPresenter;
|
||||
import com.fsck.k9.activity.compose.RecipientPresenter.CryptoMode;
|
||||
|
@ -98,7 +99,7 @@ import com.fsck.k9.ui.compose.QuotedMessagePresenter;
|
|||
@SuppressWarnings("deprecation")
|
||||
public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
CancelListener, OnFocusChangeListener, OnCryptoModeChangedListener,
|
||||
OnOpenPgpInlineChangeListener, MessageBuilder.Callback {
|
||||
OnOpenPgpInlineChangeListener, OnOpenPgpSignOnlyChangeListener, MessageBuilder.Callback {
|
||||
|
||||
private static final int DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE = 1;
|
||||
private static final int DIALOG_CONFIRM_DISCARD_ON_BACK = 2;
|
||||
|
@ -211,6 +212,11 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||
recipientPresenter.onCryptoPgpInlineChanged(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpenPgpSignOnlyChange(boolean enabled) {
|
||||
recipientPresenter.onCryptoPgpSignOnlyDisabled();
|
||||
}
|
||||
|
||||
public enum Action {
|
||||
COMPOSE(R.string.compose_title_compose),
|
||||
REPLY(R.string.compose_title_reply),
|
||||
|
@ -996,6 +1002,12 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||
recipientPresenter.onMenuSetPgpInline(false);
|
||||
updateMessageFormat();
|
||||
break;
|
||||
case R.id.openpgp_sign_only:
|
||||
recipientPresenter.onMenuSetSignOnly(true);
|
||||
break;
|
||||
case R.id.openpgp_sign_only_disable:
|
||||
recipientPresenter.onMenuSetSignOnly(false);
|
||||
break;
|
||||
case R.id.add_attachment:
|
||||
attachmentPresenter.onClickAddAttachment(recipientPresenter);
|
||||
break;
|
||||
|
|
|
@ -104,6 +104,10 @@ public class ComposeCryptoStatus {
|
|||
return cryptoSupportSignOnly;
|
||||
}
|
||||
|
||||
public boolean isSignOnly() {
|
||||
return cryptoMode == CryptoMode.SIGN_ONLY;
|
||||
}
|
||||
|
||||
public boolean isSigningEnabled() {
|
||||
return cryptoMode != CryptoMode.DISABLE && signingKeyId != null;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import com.fsck.k9.view.LinearViewAnimator;
|
|||
|
||||
public class CryptoSettingsDialog extends DialogFragment implements CryptoStatusSelectedListener {
|
||||
private static final String ARG_CURRENT_MODE = "current_mode";
|
||||
private static final String ARG_SUPPORT_SIGN_ONLY = "support_sing_only";
|
||||
|
||||
|
||||
private CryptoModeSelector cryptoModeSelector;
|
||||
|
@ -31,12 +30,11 @@ public class CryptoSettingsDialog extends DialogFragment implements CryptoStatus
|
|||
private CryptoMode currentMode;
|
||||
|
||||
|
||||
public static CryptoSettingsDialog newInstance(CryptoMode initialMode, boolean supportSignOnly) {
|
||||
public static CryptoSettingsDialog newInstance(CryptoMode initialMode) {
|
||||
CryptoSettingsDialog dialog = new CryptoSettingsDialog();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_CURRENT_MODE, initialMode.toString());
|
||||
args.putBoolean(ARG_SUPPORT_SIGN_ONLY, supportSignOnly);
|
||||
dialog.setArguments(args);
|
||||
|
||||
return dialog;
|
||||
|
@ -45,12 +43,10 @@ public class CryptoSettingsDialog extends DialogFragment implements CryptoStatus
|
|||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
Bundle arguments = savedInstanceState != null ? savedInstanceState : getArguments();
|
||||
boolean supportSignOnly = arguments.getBoolean(ARG_SUPPORT_SIGN_ONLY);
|
||||
currentMode = CryptoMode.valueOf(arguments.getString(ARG_CURRENT_MODE));
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
View view = LayoutInflater.from(getActivity()).inflate(supportSignOnly ?
|
||||
R.layout.crypto_settings_dialog_sign_only : R.layout.crypto_settings_dialog, null);
|
||||
View view = LayoutInflater.from(getActivity()).inflate(R.layout.crypto_settings_dialog, null);
|
||||
cryptoModeSelector = (CryptoModeSelector) view.findViewById(R.id.crypto_status_selector);
|
||||
cryptoStatusText = (LinearViewAnimator) view.findViewById(R.id.crypto_status_text);
|
||||
|
||||
|
@ -98,16 +94,14 @@ public class CryptoSettingsDialog extends DialogFragment implements CryptoStatus
|
|||
cryptoStatusText.setDisplayedChild(0, animate);
|
||||
break;
|
||||
case SIGN_ONLY:
|
||||
cryptoModeSelector.setCryptoStatus(CryptoModeSelectorState.SIGN_ONLY);
|
||||
cryptoStatusText.setDisplayedChild(1, animate);
|
||||
break;
|
||||
throw new IllegalStateException("This state can't be set here!");
|
||||
case OPPORTUNISTIC:
|
||||
cryptoModeSelector.setCryptoStatus(CryptoModeSelectorState.OPPORTUNISTIC);
|
||||
cryptoStatusText.setDisplayedChild(2, animate);
|
||||
cryptoStatusText.setDisplayedChild(1, animate);
|
||||
break;
|
||||
case PRIVATE:
|
||||
cryptoModeSelector.setCryptoStatus(CryptoModeSelectorState.PRIVATE);
|
||||
cryptoStatusText.setDisplayedChild(3, animate);
|
||||
cryptoStatusText.setDisplayedChild(2, animate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -126,8 +120,7 @@ public class CryptoSettingsDialog extends DialogFragment implements CryptoStatus
|
|||
currentMode = CryptoMode.DISABLE;
|
||||
break;
|
||||
case SIGN_ONLY:
|
||||
currentMode = CryptoMode.SIGN_ONLY;
|
||||
break;
|
||||
throw new IllegalStateException("This widget doesn't support sign-only state!");
|
||||
case OPPORTUNISTIC:
|
||||
currentMode = CryptoMode.OPPORTUNISTIC;
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package com.fsck.k9.activity.compose;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.view.HighlightDialogFragment;
|
||||
|
||||
|
||||
public class PgpSignOnlyDialog extends HighlightDialogFragment {
|
||||
public static final String ARG_FIRST_TIME = "first_time";
|
||||
|
||||
|
||||
public static PgpSignOnlyDialog newInstance(boolean firstTime, @IdRes int showcaseView) {
|
||||
PgpSignOnlyDialog dialog = new PgpSignOnlyDialog();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_FIRST_TIME, firstTime ? 1 : 0);
|
||||
args.putInt(ARG_HIGHLIGHT_VIEW, showcaseView);
|
||||
dialog.setArguments(args);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
Activity activity = getActivity();
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
View view = LayoutInflater.from(activity).inflate(R.layout.openpgp_sign_only_dialog, null);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setView(view);
|
||||
|
||||
if (getArguments().getInt(ARG_FIRST_TIME) != 0) {
|
||||
builder.setPositiveButton(R.string.openpgp_sign_only_ok, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
builder.setPositiveButton(R.string.openpgp_sign_only_disable, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
((OnOpenPgpSignOnlyChangeListener) activity).onOpenPgpSignOnlyChange(false);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.openpgp_sign_only_keep_enabled, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
public interface OnOpenPgpSignOnlyChangeListener {
|
||||
void onOpenPgpSignOnlyChange(boolean enabled);
|
||||
}
|
||||
|
||||
}
|
|
@ -378,8 +378,8 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
|
|||
}
|
||||
}
|
||||
|
||||
public void showCryptoDialog(CryptoMode currentCryptoMode, boolean supportSignOnly) {
|
||||
CryptoSettingsDialog dialog = CryptoSettingsDialog.newInstance(currentCryptoMode, supportSignOnly);
|
||||
public void showCryptoDialog(CryptoMode currentCryptoMode) {
|
||||
CryptoSettingsDialog dialog = CryptoSettingsDialog.newInstance(currentCryptoMode);
|
||||
dialog.show(activity.getFragmentManager(), "crypto_settings");
|
||||
}
|
||||
|
||||
|
@ -388,6 +388,11 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
|
|||
dialog.show(activity.getFragmentManager(), "openpgp_inline");
|
||||
}
|
||||
|
||||
public void showOpenPgpSignOnlyDialog(boolean firstTime) {
|
||||
PgpSignOnlyDialog dialog = PgpSignOnlyDialog.newInstance(firstTime, R.id.crypto_status);
|
||||
dialog.show(activity.getFragmentManager(), "openpgp_signonly");
|
||||
}
|
||||
|
||||
public void launchUserInteractionPendingIntent(PendingIntent pendingIntent, int requestCode) {
|
||||
activity.launchUserInteractionPendingIntent(pendingIntent, requestCode);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class RecipientPresenter implements PermissionPingCallback {
|
|||
private static final int CONTACT_PICKER_BCC = 3;
|
||||
private static final int OPENPGP_USER_INTERACTION = 4;
|
||||
|
||||
private static final int PGP_INLINE_DIALOG_DISPLAY_THRESHOLD = 2;
|
||||
private static final int PGP_DIALOG_DISPLAY_THRESHOLD = 2;
|
||||
|
||||
|
||||
// transient state, which is either obtained during construction and initialization, or cached
|
||||
|
@ -249,6 +249,11 @@ public class RecipientPresenter implements PermissionPingCallback {
|
|||
menu.findItem(R.id.openpgp_inline_enable).setVisible(isCryptoConfigured && !cryptoEnablePgpInline);
|
||||
menu.findItem(R.id.openpgp_inline_disable).setVisible(isCryptoConfigured && cryptoEnablePgpInline);
|
||||
|
||||
boolean showSignOnly = isCryptoConfigured && account.getCryptoSupportSignOnly();
|
||||
boolean isSignOnly = cachedCryptoStatus.isSignOnly();
|
||||
menu.findItem(R.id.openpgp_sign_only).setVisible(showSignOnly && !isSignOnly);
|
||||
menu.findItem(R.id.openpgp_sign_only_disable).setVisible(showSignOnly && isSignOnly);
|
||||
|
||||
boolean noContactPickerAvailable = !hasContactPicker();
|
||||
if (noContactPickerAvailable) {
|
||||
menu.findItem(R.id.add_from_contacts).setVisible(false);
|
||||
|
@ -354,7 +359,7 @@ public class RecipientPresenter implements PermissionPingCallback {
|
|||
ComposeCryptoStatusBuilder builder = new ComposeCryptoStatusBuilder()
|
||||
.setCryptoProviderState(cryptoProviderState)
|
||||
.setCryptoMode(currentCryptoMode)
|
||||
.setCryptoSupportSignOnly(account.getCryptoSupportSignOnly())
|
||||
.setCryptoSupportSignOnly(false) // TODO get rid of this setting
|
||||
.setEnablePgpInline(cryptoEnablePgpInline)
|
||||
.setRecipients(getAllRecipients());
|
||||
|
||||
|
@ -546,7 +551,11 @@ public class RecipientPresenter implements PermissionPingCallback {
|
|||
Log.e(K9.LOG_TAG, "click on crypto status while unconfigured - this should not really happen?!");
|
||||
return;
|
||||
case OK:
|
||||
recipientMvpView.showCryptoDialog(currentCryptoMode, account.getCryptoSupportSignOnly());
|
||||
if (cachedCryptoStatus.isSignOnly()) {
|
||||
recipientMvpView.showOpenPgpSignOnlyDialog(false);
|
||||
} else {
|
||||
recipientMvpView.showCryptoDialog(currentCryptoMode);
|
||||
}
|
||||
return;
|
||||
|
||||
case LOST_CONNECTION:
|
||||
|
@ -723,15 +732,40 @@ public class RecipientPresenter implements PermissionPingCallback {
|
|||
}
|
||||
}
|
||||
|
||||
public void onMenuSetSignOnly(boolean enableSignOnly) {
|
||||
if (enableSignOnly) {
|
||||
onCryptoModeChanged(CryptoMode.SIGN_ONLY);
|
||||
boolean shouldShowPgpSignOnlyDialog = checkAndIncrementPgpSignOnlyDialogCounter();
|
||||
if (shouldShowPgpSignOnlyDialog) {
|
||||
recipientMvpView.showOpenPgpSignOnlyDialog(true);
|
||||
}
|
||||
} else {
|
||||
onCryptoModeChanged(CryptoMode.OPPORTUNISTIC);
|
||||
}
|
||||
}
|
||||
|
||||
public void onCryptoPgpSignOnlyDisabled() {
|
||||
onCryptoModeChanged(CryptoMode.OPPORTUNISTIC);
|
||||
}
|
||||
|
||||
private boolean checkAndIncrementPgpInlineDialogCounter() {
|
||||
int pgpInlineDialogCounter = K9.getPgpInlineDialogCounter();
|
||||
if (pgpInlineDialogCounter < PGP_INLINE_DIALOG_DISPLAY_THRESHOLD) {
|
||||
if (pgpInlineDialogCounter < PGP_DIALOG_DISPLAY_THRESHOLD) {
|
||||
K9.setPgpInlineDialogCounter(pgpInlineDialogCounter + 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkAndIncrementPgpSignOnlyDialogCounter() {
|
||||
int pgpSignOnlyDialogCounter = K9.getPgpSignOnlyDialogCounter();
|
||||
if (pgpSignOnlyDialogCounter < PGP_DIALOG_DISPLAY_THRESHOLD) {
|
||||
K9.setPgpSignOnlyDialogCounter(pgpSignOnlyDialogCounter + 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onClickPgpInlineIndicator() {
|
||||
recipientMvpView.showOpenPgpInlineDialog(false);
|
||||
}
|
||||
|
|
|
@ -1,185 +0,0 @@
|
|||
package com.fsck.k9.view;
|
||||
|
||||
|
||||
import android.animation.ArgbEvaluator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
|
||||
import com.fsck.k9.R;
|
||||
|
||||
|
||||
public class CryptoModeWithSignOnlySelector extends FrameLayout implements CryptoModeSelector, OnSeekBarChangeListener {
|
||||
public static final int CROSSFADE_THRESH_1_LOW = -50;
|
||||
public static final int CROSSFADE_THRESH_1_HIGH = 50;
|
||||
public static final int CROSSFADE_THRESH_2_LOW = 50;
|
||||
public static final int CROSSFADE_THRESH_2_HIGH = 150;
|
||||
public static final int CROSSFADE_THRESH_3_LOW = 150;
|
||||
public static final int CROSSFADE_THRESH_3_HIGH = 250;
|
||||
public static final int CROSSFADE_THRESH_4_LOW = 250;
|
||||
public static final float CROSSFADE_DIVISOR_1 = 50.0f;
|
||||
public static final float CROSSFADE_DIVISOR_2 = 50.0f;
|
||||
public static final float CROSSFADE_DIVISOR_3 = 50.0f;
|
||||
public static final float CROSSFADE_DIVISOR_4 = 50.0f;
|
||||
|
||||
|
||||
private SeekBar seekbar;
|
||||
private ImageView modeIconDisabled;
|
||||
private ImageView modeIconSignOnly;
|
||||
private ImageView modeIconOpportunistic;
|
||||
private ImageView modeIconPrivate;
|
||||
|
||||
private ObjectAnimator currentSeekbarAnim;
|
||||
|
||||
private CryptoModeSelectorState currentCryptoStatus;
|
||||
|
||||
private CryptoStatusSelectedListener cryptoStatusListener;
|
||||
private static final ArgbEvaluator ARGB_EVALUATOR = new ArgbEvaluator();
|
||||
|
||||
|
||||
public CryptoModeWithSignOnlySelector(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public CryptoModeWithSignOnlySelector(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
inflate(getContext(), R.layout.crypto_mode_with_sign_only_selector, this);
|
||||
seekbar = (SeekBar) findViewById(R.id.seek_bar);
|
||||
modeIconDisabled = (ImageView) findViewById(R.id.icon_disabled);
|
||||
modeIconSignOnly = (ImageView) findViewById(R.id.icon_sign_only);
|
||||
modeIconOpportunistic = (ImageView) findViewById(R.id.icon_opportunistic);
|
||||
modeIconPrivate = (ImageView) findViewById(R.id.icon_private);
|
||||
|
||||
seekbar.setOnSeekBarChangeListener(this);
|
||||
onProgressChanged(seekbar, seekbar.getProgress(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
int grey = ThemeUtils.getStyledColor(getContext(), R.attr.openpgp_grey);
|
||||
|
||||
float crossfadeValue1, crossfadeValue2, crossfadeValue3, crossfadeValue4;
|
||||
|
||||
if (progress < CROSSFADE_THRESH_1_HIGH) {
|
||||
crossfadeValue1 = (progress -CROSSFADE_THRESH_1_LOW) / CROSSFADE_DIVISOR_1;
|
||||
if (crossfadeValue1 > 1.0f) {
|
||||
crossfadeValue1 = 2.0f -crossfadeValue1;
|
||||
}
|
||||
} else {
|
||||
crossfadeValue1 = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
if (progress > CROSSFADE_THRESH_2_LOW && progress < CROSSFADE_THRESH_2_HIGH) {
|
||||
crossfadeValue2 = (progress -CROSSFADE_THRESH_2_LOW) / CROSSFADE_DIVISOR_2;
|
||||
if (crossfadeValue2 > 1.0f) {
|
||||
crossfadeValue2 = 2.0f -crossfadeValue2;
|
||||
}
|
||||
} else {
|
||||
crossfadeValue2 = 0.0f;
|
||||
}
|
||||
|
||||
if (progress > CROSSFADE_THRESH_3_LOW && progress < CROSSFADE_THRESH_3_HIGH) {
|
||||
crossfadeValue3 = (progress -CROSSFADE_THRESH_3_LOW) / CROSSFADE_DIVISOR_3;
|
||||
if (crossfadeValue3 > 1.0f) {
|
||||
crossfadeValue3 = 2.0f -crossfadeValue3;
|
||||
}
|
||||
} else {
|
||||
crossfadeValue3 = 0.0f;
|
||||
}
|
||||
|
||||
if (progress > CROSSFADE_THRESH_4_LOW) {
|
||||
crossfadeValue4 = (progress -CROSSFADE_THRESH_4_LOW) / CROSSFADE_DIVISOR_4;
|
||||
} else {
|
||||
crossfadeValue4 = 0.0f;
|
||||
}
|
||||
|
||||
int crossfadedColor;
|
||||
|
||||
crossfadedColor = crossfadeColor(grey, ThemeUtils.getStyledColor(getContext(), R.attr.openpgp_dark_grey), crossfadeValue1);
|
||||
modeIconDisabled.setColorFilter(crossfadedColor, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
crossfadedColor = crossfadeColor(grey, ThemeUtils.getStyledColor(getContext(), R.attr.openpgp_blue), crossfadeValue2);
|
||||
modeIconSignOnly.setColorFilter(crossfadedColor, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
crossfadedColor = crossfadeColor(grey, ThemeUtils.getStyledColor(getContext(), R.attr.openpgp_orange), crossfadeValue3);
|
||||
modeIconOpportunistic.setColorFilter(crossfadedColor, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
crossfadedColor = crossfadeColor(grey, ThemeUtils.getStyledColor(getContext(), R.attr.openpgp_green), crossfadeValue4);
|
||||
modeIconPrivate.setColorFilter(crossfadedColor, PorterDuff.Mode.SRC_ATOP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
CryptoModeSelectorState newCryptoStatus;
|
||||
|
||||
int progress = seekbar.getProgress();
|
||||
if (progress < 50) {
|
||||
animateSnapTo(0);
|
||||
newCryptoStatus = CryptoModeSelectorState.DISABLED;
|
||||
} else if (progress < 150) {
|
||||
animateSnapTo(100);
|
||||
newCryptoStatus = CryptoModeSelectorState.SIGN_ONLY;
|
||||
} else if (progress < 250) {
|
||||
animateSnapTo(200);
|
||||
newCryptoStatus = CryptoModeSelectorState.OPPORTUNISTIC;
|
||||
} else {
|
||||
animateSnapTo(300);
|
||||
newCryptoStatus = CryptoModeSelectorState.PRIVATE;
|
||||
}
|
||||
|
||||
if (currentCryptoStatus != newCryptoStatus) {
|
||||
currentCryptoStatus = newCryptoStatus;
|
||||
cryptoStatusListener.onCryptoStatusSelected(newCryptoStatus);
|
||||
}
|
||||
}
|
||||
|
||||
private void animateSnapTo(int value) {
|
||||
if (currentSeekbarAnim != null) {
|
||||
currentSeekbarAnim.cancel();
|
||||
}
|
||||
currentSeekbarAnim = ObjectAnimator.ofInt(seekbar, "progress", seekbar.getProgress(), value);
|
||||
currentSeekbarAnim.setDuration(150);
|
||||
currentSeekbarAnim.start();
|
||||
}
|
||||
|
||||
public static int crossfadeColor(int color1, int color2, float factor) {
|
||||
return (Integer) ARGB_EVALUATOR.evaluate(factor, color1, color2);
|
||||
}
|
||||
|
||||
public void setCryptoStatusListener(CryptoStatusSelectedListener cryptoStatusListener) {
|
||||
this.cryptoStatusListener = cryptoStatusListener;
|
||||
}
|
||||
|
||||
public void setCryptoStatus(CryptoModeSelectorState status) {
|
||||
currentCryptoStatus = status;
|
||||
switch (status) {
|
||||
case DISABLED:
|
||||
seekbar.setProgress(0);
|
||||
break;
|
||||
case SIGN_ONLY:
|
||||
seekbar.setProgress(100);
|
||||
break;
|
||||
case OPPORTUNISTIC:
|
||||
seekbar.setProgress(200);
|
||||
break;
|
||||
case PRIVATE:
|
||||
seekbar.setProgress(300);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
16
k9mail/src/main/res/drawable/bullet_point_neutral.xml
Normal file
16
k9mail/src/main/res/drawable/bullet_point_neutral.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="457.47"
|
||||
android:viewportHeight="457.469">
|
||||
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M228.75,96.906 C155.95,96.906,96.91,155.95,96.91,228.746
|
||||
C96.91,301.546,155.954,360.556,228.75,360.556
|
||||
C301.55,360.556,360.56,301.546,360.56,228.746 S301.55,96.906,228.75,96.906 Z
|
||||
M228.75,173.5 C259.26,173.5,283.97,198.24,283.97,228.75
|
||||
S259.26,283.97,228.75,283.97 S173.5,259.26,173.5,228.75
|
||||
S198.24,173.5,228.75,173.5 Z" />
|
||||
</vector>
|
|
@ -24,12 +24,6 @@
|
|||
android:text="@string/crypto_mode_disabled"
|
||||
/>
|
||||
|
||||
<Space
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:custom="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<com.fsck.k9.view.LinearViewAnimator
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:id="@+id/crypto_status_text"
|
||||
custom:upInAnimation="@anim/fade_in_right"
|
||||
custom:upOutAnimation="@anim/fade_out_right"
|
||||
custom:downInAnimation="@anim/fade_in_left"
|
||||
custom:downOutAnimation="@anim/fade_out_left">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
android:text="@string/crypto_mode_supsig_disabled"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
android:text="@string/crypto_mode_supsig_sign_only"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
android:text="@string/crypto_mode_supsig_opportunistic"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
android:text="@string/crypto_mode_supsig_private"
|
||||
/>
|
||||
|
||||
</com.fsck.k9.view.LinearViewAnimator>
|
||||
|
||||
<com.fsck.k9.view.CryptoModeWithSignOnlySelector
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/crypto_status_selector"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
144
k9mail/src/main/res/layout/openpgp_sign_only_dialog.xml
Normal file
144
k9mail/src/main/res/layout/openpgp_sign_only_dialog.xml
Normal file
|
@ -0,0 +1,144 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="10dp"
|
||||
tools:ignore="UseCompoundDrawables"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/status_signature_verified_cutout"
|
||||
android:scaleType="fitCenter"
|
||||
android:tint="@color/light_black"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginRight="6dp"
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
android:text="@string/openpgp_dialog_sign_only_title"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:text="@string/openpgp_dialog_sign_only_text"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PositiveBulletPoint"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:text="@string/openpgp_dialog_sign_only_plus_verified"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="4dp"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/NegativeBulletPoint"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:text="@string/openpgp_dialog_sign_only_minus_break"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="4dp"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/NegativeBulletPoint"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:text="@string/openpgp_dialog_sign_only_minus_attach"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/NeutralBulletPoint"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:text="@string/openpgp_dialog_sign_only_neutral_encsigned"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -49,4 +49,16 @@
|
|||
android:title="@string/disable_inline_pgp"
|
||||
android:showAsAction="never"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/openpgp_sign_only"
|
||||
android:alphabeticShortcut="g"
|
||||
android:title="@string/enable_sign_only"
|
||||
android:showAsAction="never"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/openpgp_sign_only_disable"
|
||||
android:alphabeticShortcut="g"
|
||||
android:title="@string/disable_sign_only"
|
||||
android:showAsAction="never"
|
||||
/>
|
||||
</menu>
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
<attr name="contactPictureFallbackDefaultBackgroundColor" format="reference|color"/>
|
||||
<attr name="contactTokenBackgroundColor" format="reference|color"/>
|
||||
<attr name="tintColorBulletPointPositive" format="reference|color"/>
|
||||
<attr name="tintColorBulletPointNeutral" format="reference|color"/>
|
||||
<attr name="tintColorBulletPointNegative" format="reference|color"/>
|
||||
|
||||
<attr name="openpgp_black" format="reference|color" />
|
||||
|
|
|
@ -1167,6 +1167,8 @@ Please submit bug reports, contribute new features and ask questions at
|
|||
<string name="error_crypto_inline_attach">PGP/INLINE mode does not support attachments!</string>
|
||||
<string name="enable_inline_pgp">Enable PGP/INLINE</string>
|
||||
<string name="disable_inline_pgp">Disable PGP/INLINE</string>
|
||||
<string name="enable_sign_only">Attach PGP Signature</string>
|
||||
<string name="disable_sign_only">Disable PGP-Signing</string>
|
||||
<string name="openpgp_inline_title">PGP/INLINE Mode</string>
|
||||
<string name="openpgp_inline_text">The email is sent in PGP/INLINE format.\nThis should only be used for compatibility:</string>
|
||||
<string name="openpgp_inline_plus_compat">Some clients only support this format</string>
|
||||
|
@ -1175,6 +1177,9 @@ Please submit bug reports, contribute new features and ask questions at
|
|||
<string name="openpgp_inline_ok">Got it!</string>
|
||||
<string name="openpgp_inline_disable">Disable</string>
|
||||
<string name="openpgp_inline_keep_enabled">Keep Enabled</string>
|
||||
<string name="openpgp_sign_only_ok">Got it!</string>
|
||||
<string name="openpgp_sign_only_disable">Disable</string>
|
||||
<string name="openpgp_sign_only_keep_enabled">Keep Enabled</string>
|
||||
|
||||
<string name="crypto_msg_disabled">Message is not encrypted</string>
|
||||
|
||||
|
@ -1222,5 +1227,11 @@ Please submit bug reports, contribute new features and ask questions at
|
|||
<string name="recipient_error_non_ascii">Special characters are currently not supported!</string>
|
||||
<string name="recipient_error_parse_failed">Error parsing address!</string>
|
||||
<string name="account_settings_crypto_support_sign_only">Support signing of unencrypted messages</string>
|
||||
<string name="openpgp_dialog_sign_only_title">Attach PGP Signature</string>
|
||||
<string name="openpgp_dialog_sign_only_text">Your PGP key will be used to create a cryptographic signature of the email.</string>
|
||||
<string name="openpgp_dialog_sign_only_plus_verified">This does not encrypt the email, but verifies that it was sent from your key.</string>
|
||||
<string name="openpgp_dialog_sign_only_minus_break">Signatures may break when sent to mailing lists.</string>
|
||||
<string name="openpgp_dialog_sign_only_minus_attach">Signatures may be displayed as \'signature.asc\' attachments in some clients.</string>
|
||||
<string name="openpgp_dialog_sign_only_neutral_encsigned">Encrypted messages always include a signature.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -60,6 +60,11 @@
|
|||
<item name="android:tint">?attr/tintColorBulletPointPositive</item>
|
||||
</style>
|
||||
|
||||
<style name="NeutralBulletPoint">
|
||||
<item name="android:src">@drawable/bullet_point_neutral</item>
|
||||
<item name="android:tint">?attr/tintColorBulletPointNeutral</item>
|
||||
</style>
|
||||
|
||||
<style name="NegativeBulletPoint">
|
||||
<item name="android:src">@drawable/bullet_point_negative</item>
|
||||
<item name="android:tint">?attr/tintColorBulletPointNegative</item>
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
<item name="composerBackgroundColor">@android:color/background_light</item>
|
||||
<item name="tintColorBulletPointPositive">#77aa22</item>
|
||||
<item name="tintColorBulletPointNegative">#dd2222</item>
|
||||
<item name="tintColorBulletPointNeutral">#888</item>
|
||||
|
||||
<item name="openpgp_black">#000</item>
|
||||
<item name="openpgp_orange">#FF8800</item>
|
||||
|
@ -127,6 +128,7 @@
|
|||
<item name="composerBackgroundColor">@android:color/background_dark</item>
|
||||
<item name="tintColorBulletPointPositive">#77aa22</item>
|
||||
<item name="tintColorBulletPointNegative">#dd2222</item>
|
||||
<item name="tintColorBulletPointNeutral">#bbb</item>
|
||||
|
||||
<item name="openpgp_black">#fff</item>
|
||||
<item name="openpgp_orange">#ee7700</item>
|
||||
|
|
Loading…
Reference in a new issue