forked from thunderbird/thunderbird-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request thunderbird#3075 from k9mail/prefer-encrypt-setting
Prefer encrypt setting
- Loading branch information
Showing
9 changed files
with
191 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
k9mail/src/main/java/com/fsck/k9/ui/dialog/AutocryptPreferEncryptDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.fsck.k9.ui.dialog; | ||
|
||
|
||
import android.annotation.SuppressLint; | ||
import android.app.AlertDialog; | ||
import android.app.Dialog; | ||
import android.content.Context; | ||
import android.content.DialogInterface; | ||
import android.text.method.LinkMovementMethod; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.View.OnClickListener; | ||
import android.widget.CheckBox; | ||
import android.widget.TextView; | ||
|
||
import com.fsck.k9.R; | ||
|
||
|
||
public class AutocryptPreferEncryptDialog extends AlertDialog implements OnClickListener { | ||
|
||
private final CheckBox preferEncryptCheckbox; | ||
private final OnPreferEncryptChangedListener onPreferEncryptChangedListener; | ||
|
||
private boolean preferEncryptEnabled; | ||
|
||
public AutocryptPreferEncryptDialog(Context context, boolean preferEncryptEnabled, | ||
OnPreferEncryptChangedListener onPreferEncryptChangedListener) { | ||
super(context); | ||
|
||
this.onPreferEncryptChangedListener = onPreferEncryptChangedListener; | ||
this.preferEncryptEnabled = preferEncryptEnabled; | ||
|
||
LayoutInflater inflater = LayoutInflater.from(context); | ||
|
||
@SuppressLint("InflateParams") | ||
View contentView = inflater.inflate(R.layout.dialog_autocrypt_prefer_encrypt, null); | ||
|
||
preferEncryptCheckbox = (CheckBox) contentView.findViewById(R.id.prefer_encrypt_check); | ||
preferEncryptCheckbox.setChecked(preferEncryptEnabled); | ||
|
||
contentView.findViewById(R.id.prefer_encrypt).setOnClickListener(this); | ||
|
||
// TODO add autocrypt logo? | ||
// setIcon(R.drawable.autocrypt); | ||
setView(contentView); | ||
setButton(Dialog.BUTTON_NEUTRAL, context.getString(R.string.done_action), new OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialogInterface, int i) { | ||
cancel(); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
toggleCheck(); | ||
} | ||
|
||
private void toggleCheck() { | ||
preferEncryptEnabled = !preferEncryptEnabled; | ||
preferEncryptCheckbox.setChecked(preferEncryptEnabled); | ||
|
||
onPreferEncryptChangedListener.onPreferEncryptChanged(preferEncryptEnabled); | ||
} | ||
|
||
public interface OnPreferEncryptChangedListener { | ||
void onPreferEncryptChanged(boolean enabled); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
k9mail/src/main/res/layout/dialog_autocrypt_prefer_encrypt.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_height="match_parent" | ||
android:layout_width="match_parent"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginLeft="24dp" | ||
android:layout_marginRight="24dp" | ||
android:layout_marginTop="24dp" | ||
android:layout_marginBottom="20dp" | ||
android:text="@string/dialog_autocrypt_mutual_title" | ||
style="?android:textAppearanceLarge" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginLeft="24dp" | ||
android:layout_marginRight="24dp" | ||
android:text="@string/dialog_autocrypt_mutual_description_1" /> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="12dp" | ||
android:paddingLeft="24dp" | ||
android:paddingRight="24dp" | ||
android:gravity="center_vertical" | ||
android:minHeight="?android:listPreferredItemHeight" | ||
android:orientation="horizontal" | ||
android:background="?android:selectableItemBackground" | ||
android:id="@+id/prefer_encrypt"> | ||
|
||
<TextView | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="@string/dialog_autocrypt_mutual_description_2" /> | ||
|
||
<CheckBox | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/prefer_encrypt_check" | ||
android:clickable="false" | ||
/> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> | ||
|
||
</ScrollView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters