wip: show descriptive dialog when user enables encryption from menu
This commit is contained in:
parent
2c3c77e483
commit
143079f81a
6 changed files with 174 additions and 4 deletions
|
@ -0,0 +1,49 @@
|
|||
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 PgpEncryptDescriptionDialog extends HighlightDialogFragment {
|
||||
public static PgpEncryptDescriptionDialog newInstance(@IdRes int showcaseView) {
|
||||
PgpEncryptDescriptionDialog dialog = new PgpEncryptDescriptionDialog();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
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_encrypt_description_dialog, null);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setView(view);
|
||||
|
||||
builder.setPositiveButton(R.string.openpgp_sign_only_ok, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
}
|
|
@ -397,6 +397,11 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
|
|||
dialog.show(activity.getFragmentManager(), "openpgp_signonly");
|
||||
}
|
||||
|
||||
public void showOpenPgpEncryptExplanationDialog() {
|
||||
PgpEncryptDescriptionDialog dialog = PgpEncryptDescriptionDialog.newInstance(R.id.crypto_status);
|
||||
dialog.show(activity.getFragmentManager(), "openpgp_description");
|
||||
}
|
||||
|
||||
public void launchUserInteractionPendingIntent(PendingIntent pendingIntent, int requestCode) {
|
||||
activity.launchUserInteractionPendingIntent(pendingIntent, requestCode);
|
||||
}
|
||||
|
|
|
@ -822,10 +822,23 @@ public class RecipientPresenter implements PermissionPingCallback {
|
|||
}
|
||||
|
||||
public void onMenuSetEnableEncryption(boolean enableEncryption) {
|
||||
if (cachedCryptoStatus == null) {
|
||||
Timber.e("Received crypto button press while status wasn't initialized?");
|
||||
return;
|
||||
}
|
||||
if (enableEncryption) {
|
||||
onCryptoModeChanged(CryptoMode.CHOICE_ENABLED);
|
||||
if (cachedCryptoStatus.canEncryptAndIsMutual()) {
|
||||
onCryptoModeChanged(CryptoMode.NO_CHOICE);
|
||||
} else {
|
||||
recipientMvpView.showOpenPgpEncryptExplanationDialog();
|
||||
onCryptoModeChanged(CryptoMode.CHOICE_ENABLED);
|
||||
}
|
||||
} else {
|
||||
onCryptoModeChanged(CryptoMode.NO_CHOICE);
|
||||
if (cachedCryptoStatus.canEncryptAndIsMutual()) {
|
||||
onCryptoModeChanged(CryptoMode.CHOICE_DISABLED);
|
||||
} else {
|
||||
onCryptoModeChanged(CryptoMode.NO_CHOICE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
<?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:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="14dp"
|
||||
android:paddingBottom="14dp">
|
||||
|
||||
<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="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="OpenPGP Encryption"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:text="@string/openpgp_description_text1"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp"
|
||||
android:src="@drawable/status_lock_disabled"
|
||||
android:tint="?attr/openpgp_dark_grey"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/ic_action_next_message_light"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp"
|
||||
android:src="@drawable/status_lock"
|
||||
android:tint="?attr/openpgp_green"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:text="@string/openpgp_description_text2"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:text="@string/openpgp_description_text3"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
|
@ -40,13 +40,13 @@
|
|||
<item
|
||||
android:id="@+id/openpgp_encrypt_enable"
|
||||
android:alphabeticShortcut="c"
|
||||
android:title="Enable Encryption"
|
||||
android:title="@string/enable_encryption"
|
||||
android:showAsAction="never"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/openpgp_encrypt_disable"
|
||||
android:alphabeticShortcut="c"
|
||||
android:title="Disable Encryption"
|
||||
android:title="@string/disable_encryption"
|
||||
android:showAsAction="never"
|
||||
/>
|
||||
<item
|
||||
|
|
|
@ -1242,4 +1242,10 @@ Please submit bug reports, contribute new features and ask questions at
|
|||
<string name="fetching_folders_failed">Fetching folder list failed</string>
|
||||
<string name="messageview_crypto_warning_details">Show Details</string>
|
||||
<string name="error_recipient_crypto_retrieve">Error retrieving recipient status from OpenPGP provider!</string>
|
||||
|
||||
<string name="enable_encryption">Enable Encryption</string>
|
||||
<string name="disable_encryption">Disable Encryption</string>
|
||||
<string name="openpgp_description_text1">Encrypting messages ensures they can be read by the recipient, and nobody else.</string>
|
||||
<string name="openpgp_description_text3">Encryption will only show up if supported by all recipients, and they must have sent you an e-mail before.</string>
|
||||
<string name="openpgp_description_text2">Toggle encryption by clicking this icon.</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue