mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
file encrypt layout entirely rewritten, should be much more userfriendly and work on more devices, changed message encrypt layout to match
This commit is contained in:
parent
b01a47a115
commit
86192e39d9
@ -74,7 +74,6 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".EncryptFileActivity"
|
android:name=".EncryptFileActivity"
|
||||||
android:label="@string/title_encryptFile"
|
android:label="@string/title_encryptFile"
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:configChanges="keyboardHidden|orientation|keyboard">
|
android:configChanges="keyboardHidden|orientation|keyboard">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -21,11 +21,23 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingTop="5dip">
|
android:paddingTop="5dip">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="0dip"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:fillViewport="true">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginLeft="5dip"
|
||||||
|
android:layout_marginRight="?android:attr/scrollbarSize">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal">
|
||||||
android:paddingLeft="5dip">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_filename"
|
android:id="@+id/label_filename"
|
||||||
@ -48,89 +60,75 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TableLayout
|
<LinearLayout
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:stretchColumns="1"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="6dip">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TableRow>
|
|
||||||
|
|
||||||
<TextView android:id="@+id/label_algorithm"
|
<TextView android:id="@+id/label_algorithm"
|
||||||
android:text="Algorithm:"
|
android:text="@string/label_algorithm"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dip"
|
||||||
|
android:layout_weight="1"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingRight="10dip"/>
|
android:paddingRight="10dip"/>
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/algorithm"
|
android:id="@+id/algorithm"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_ascii_armour"
|
android:id="@+id/label_ascii_armour"
|
||||||
android:text="@string/ascii_armour"
|
android:text="@string/label_ascii_armour"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingRight="10dip"
|
android:paddingRight="10dip"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"/>
|
android:layout_width="0dip"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/ascii_armour"
|
android:id="@+id/ascii_armour"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="right|center_vertical"/>
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
</TableRow>
|
</LinearLayout>
|
||||||
|
|
||||||
</TableLayout>
|
<View
|
||||||
|
|
||||||
<TabHost
|
|
||||||
android:id="@+id/tab_host"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="0dip">
|
android:layout_height="1dip"
|
||||||
|
android:background="?android:attr/listDivider"
|
||||||
<TabWidget
|
android:layout_marginBottom="5dip"/>
|
||||||
android:id="@android:id/tabs"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="65dip"/>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@android:id/tabcontent"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:paddingTop="65dip">
|
|
||||||
|
|
||||||
<!-- -->
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/tab_asymmetric"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="3dip"
|
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<CheckBox
|
<TextView
|
||||||
android:text="@string/sign"
|
android:id="@+id/label_sign"
|
||||||
android:id="@+id/sign"
|
android:text="@string/label_sign"
|
||||||
android:layout_width="wrap_content"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_weight="1"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"/>
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingRight="5dip">
|
android:paddingRight="5dip">
|
||||||
|
|
||||||
@ -152,46 +150,77 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/sign"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingBottom="3dip"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/label_select_public_keys"
|
||||||
|
android:text="@string/label_select_public_keys"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:text="@string/btn_selectEncryptKeys"
|
||||||
|
android:id="@+id/btn_selectEncryptKeys"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/separator"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="1dip"
|
android:layout_height="1dip"
|
||||||
android:background="?android:attr/listDivider"/>
|
android:background="?android:attr/listDivider"
|
||||||
|
android:layout_marginBottom="5dip"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_encrypt_keys"
|
android:id="@+id/label_use_pass_phrase"
|
||||||
android:text="@string/label_encrypt_keys"
|
android:text="@string/label_use_pass_phrase"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:layout_width="wrap_content"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_height="wrap_content"/>
|
android:paddingRight="10dip"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<ListView
|
<CheckBox
|
||||||
android:id="@+id/public_key_list"
|
android:id="@+id/use_pass_phrase"
|
||||||
android:choiceMode="multipleChoice"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="fill_parent"/>
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<!-- -->
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/tab_symmetric"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingTop="3dip">
|
|
||||||
|
|
||||||
<TableLayout
|
<TableLayout
|
||||||
android:layout_height="fill_parent"
|
android:id="@+id/layout_pass_phrase"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:stretchColumns="1"
|
android:stretchColumns="1">
|
||||||
android:paddingLeft="6dip">
|
|
||||||
|
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
|
||||||
<TextView android:id="@+id/label_pass_phrase"
|
<TextView android:id="@+id/label_pass_phrase"
|
||||||
android:text="Pass phrase"
|
android:text="@string/label_pass_phrase"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
@ -207,7 +236,7 @@
|
|||||||
<TableRow>
|
<TableRow>
|
||||||
|
|
||||||
<TextView android:id="@+id/label_pass_phrase_again"
|
<TextView android:id="@+id/label_pass_phrase_again"
|
||||||
android:text="Again:"
|
android:text="@string/label_pass_phrase_again"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
@ -222,12 +251,9 @@
|
|||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</ScrollView>
|
||||||
|
|
||||||
</TabHost>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
@ -30,21 +30,23 @@
|
|||||||
android:inputType="text|textCapSentences|textMultiLine|textLongMessage"/>
|
android:inputType="text|textCapSentences|textMultiLine|textLongMessage"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:paddingBottom="3dip">
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<CheckBox
|
<TextView
|
||||||
android:text="@string/sign"
|
android:id="@+id/label_sign"
|
||||||
android:id="@+id/sign"
|
android:text="@string/label_sign"
|
||||||
android:layout_width="wrap_content"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_weight="1"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"/>
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingRight="5dip">
|
android:paddingRight="5dip">
|
||||||
|
|
||||||
@ -66,6 +68,36 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/sign"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingBottom="3dip"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/label_select_public_keys"
|
||||||
|
android:text="@string/label_select_public_keys"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:text="@string/btn_selectEncryptKeys"
|
||||||
|
android:id="@+id/btn_selectEncryptKeys"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -74,18 +106,10 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="@android:style/ButtonBar">
|
style="@android:style/ButtonBar">
|
||||||
|
|
||||||
<Button
|
|
||||||
android:text="@string/btn_selectEncryptKeys"
|
|
||||||
android:id="@+id/btn_selectEncryptKeys"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_width="0dip"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_send"
|
android:id="@+id/btn_send"
|
||||||
android:text="@string/btn_send"
|
android:text="@string/btn_send"
|
||||||
android:layout_weight="1"
|
android:layout_width="fill_parent"
|
||||||
android:layout_width="0dip"
|
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -45,24 +45,25 @@
|
|||||||
<string name="btn_save">Save</string>
|
<string name="btn_save">Save</string>
|
||||||
<string name="btn_doNotSave">Cancel</string>
|
<string name="btn_doNotSave">Cancel</string>
|
||||||
|
|
||||||
<string name="tab_symmetric">Use Pass Phrase</string>
|
|
||||||
<string name="tab_asymmetric">Use Public Key</string>
|
|
||||||
|
|
||||||
<string name="menu_about">About</string>
|
<string name="menu_about">About</string>
|
||||||
<string name="menu_addAccount">Add GMail Account</string>
|
<string name="menu_addAccount">Add GMail Account</string>
|
||||||
<string name="menu_managePublicKeys">Manage Public Keys</string>
|
<string name="menu_managePublicKeys">Manage Public Keys</string>
|
||||||
<string name="menu_manageSecretKeys">Manage Secret Keys</string>
|
<string name="menu_manageSecretKeys">Manage Secret Keys</string>
|
||||||
|
|
||||||
<string name="sign">Sign</string>
|
<string name="no_keys_selected">Select</string>
|
||||||
<string name="sign_as">Sign as</string>
|
<string name="one_key_selected">1 Selected</string>
|
||||||
<string name="no_keys_selected">Select Recipients</string>
|
<string name="n_keys_selected">Selected</string>
|
||||||
<string name="one_key_selected">1 Recipient</string>
|
|
||||||
<string name="n_keys_selected">Recipients</string>
|
|
||||||
<string name="unknown_user_id"><unknown></string>
|
<string name="unknown_user_id"><unknown></string>
|
||||||
<string name="none"><none></string>
|
<string name="none"><none></string>
|
||||||
|
|
||||||
<string name="label_file">File:</string>
|
<string name="label_sign">Sign</string>
|
||||||
<string name="label_encrypt_keys">Encrypt with:</string>
|
<string name="label_file">File</string>
|
||||||
|
<string name="label_pass_phrase">Pass Phrase</string>
|
||||||
|
<string name="label_pass_phrase_again">Again</string>
|
||||||
|
<string name="label_algorithm">Algorithm</string>
|
||||||
|
<string name="label_ascii_armour">ASCII Armour</string>
|
||||||
|
<string name="label_select_public_keys">Public Key(s)</string>
|
||||||
|
<string name="label_use_pass_phrase">Use Pass Phrase</string>
|
||||||
|
|
||||||
<string name="sign_only">Sign only</string>
|
<string name="sign_only">Sign only</string>
|
||||||
<string name="encrypt_only">Encrypt only</string>
|
<string name="encrypt_only">Encrypt only</string>
|
||||||
@ -83,7 +84,5 @@
|
|||||||
<string name="filemanager_title_save">Save As...</string>
|
<string name="filemanager_title_save">Save As...</string>
|
||||||
<string name="filemanager_btn_save">Save</string>
|
<string name="filemanager_btn_save">Save</string>
|
||||||
|
|
||||||
<string name="ascii_armour">ASCII armour</string>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
@ -27,12 +27,9 @@ import java.io.OutputStream;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.NoSuchProviderException;
|
import java.security.NoSuchProviderException;
|
||||||
import java.security.SignatureException;
|
import java.security.SignatureException;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.bouncycastle2.openpgp.PGPEncryptedData;
|
import org.bouncycastle2.openpgp.PGPEncryptedData;
|
||||||
import org.bouncycastle2.openpgp.PGPException;
|
import org.bouncycastle2.openpgp.PGPException;
|
||||||
import org.bouncycastle2.openpgp.PGPPublicKeyRing;
|
|
||||||
import org.bouncycastle2.openpgp.PGPSecretKey;
|
import org.bouncycastle2.openpgp.PGPSecretKey;
|
||||||
import org.bouncycastle2.openpgp.PGPSecretKeyRing;
|
import org.bouncycastle2.openpgp.PGPSecretKeyRing;
|
||||||
import org.openintents.intents.FileManager;
|
import org.openintents.intents.FileManager;
|
||||||
@ -47,35 +44,31 @@ import android.os.Bundle;
|
|||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TabHost;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.widget.TabHost.TabSpec;
|
|
||||||
|
|
||||||
public class EncryptFileActivity extends BaseActivity {
|
public class EncryptFileActivity extends BaseActivity {
|
||||||
private final String TAB_ASYMMETRIC = "TAB_ASYMMETRIC";
|
|
||||||
private final String TAB_SYMMETRIC = "TAB_SYMMETRIC";
|
|
||||||
|
|
||||||
private TabHost mTabHost = null;
|
|
||||||
private EditText mFilename = null;
|
private EditText mFilename = null;
|
||||||
private ImageButton mBrowse = null;
|
private ImageButton mBrowse = null;
|
||||||
private CheckBox mSign = null;
|
private CheckBox mSign = null;
|
||||||
private TextView mMainUserId = null;
|
private TextView mMainUserId = null;
|
||||||
private TextView mMainUserIdRest = null;
|
private TextView mMainUserIdRest = null;
|
||||||
private ListView mPublicKeyList = null;
|
|
||||||
private Spinner mAlgorithm = null;
|
private Spinner mAlgorithm = null;
|
||||||
private EditText mPassPhrase = null;
|
private EditText mPassPhrase = null;
|
||||||
private EditText mPassPhraseAgain = null;
|
private EditText mPassPhraseAgain = null;
|
||||||
private CheckBox mAsciiArmour = null;
|
private CheckBox mAsciiArmour = null;
|
||||||
|
private CheckBox mUsePassPhrase = null;
|
||||||
|
private ViewGroup mPassPhraseLayout = null;
|
||||||
private Button mEncryptButton = null;
|
private Button mEncryptButton = null;
|
||||||
|
private Button mSelectKeysButton = null;
|
||||||
|
|
||||||
private long mEncryptionKeyIds[] = null;
|
private long mEncryptionKeyIds[] = null;
|
||||||
private String mInputFilename = null;
|
private String mInputFilename = null;
|
||||||
@ -89,30 +82,14 @@ public class EncryptFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
mAsciiArmour = (CheckBox) findViewById(R.id.ascii_armour);
|
mAsciiArmour = (CheckBox) findViewById(R.id.ascii_armour);
|
||||||
|
|
||||||
mTabHost = (TabHost) findViewById(R.id.tab_host);
|
|
||||||
mTabHost.setup();
|
|
||||||
|
|
||||||
TabSpec ts1 = mTabHost.newTabSpec(TAB_ASYMMETRIC);
|
|
||||||
ts1.setIndicator(getString(R.string.tab_asymmetric),
|
|
||||||
getResources().getDrawable(R.drawable.key));
|
|
||||||
ts1.setContent(R.id.tab_asymmetric);
|
|
||||||
mTabHost.addTab(ts1);
|
|
||||||
|
|
||||||
TabSpec ts2 = mTabHost.newTabSpec(TAB_SYMMETRIC);
|
|
||||||
ts2.setIndicator(getString(R.string.tab_symmetric),
|
|
||||||
getResources().getDrawable(R.drawable.key));
|
|
||||||
ts2.setContent(R.id.tab_symmetric);
|
|
||||||
mTabHost.addTab(ts2);
|
|
||||||
|
|
||||||
mTabHost.setCurrentTab(0);
|
|
||||||
|
|
||||||
// asymmetric tab
|
// asymmetric tab
|
||||||
|
mSelectKeysButton = (Button) findViewById(R.id.btn_selectEncryptKeys);
|
||||||
Vector<PGPPublicKeyRing> keyRings =
|
mSelectKeysButton.setOnClickListener(new OnClickListener() {
|
||||||
(Vector<PGPPublicKeyRing>) Apg.getPublicKeyRings().clone();
|
@Override
|
||||||
Collections.sort(keyRings, new Apg.PublicKeySorter());
|
public void onClick(View v) {
|
||||||
mPublicKeyList = (ListView) findViewById(R.id.public_key_list);
|
selectPublicKeys();
|
||||||
mPublicKeyList.setAdapter(new SelectPublicKeyListAdapter(mPublicKeyList, keyRings));
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mFilename = (EditText) findViewById(R.id.filename);
|
mFilename = (EditText) findViewById(R.id.filename);
|
||||||
mBrowse = (ImageButton) findViewById(R.id.btn_browse);
|
mBrowse = (ImageButton) findViewById(R.id.btn_browse);
|
||||||
@ -167,9 +144,30 @@ public class EncryptFileActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mUsePassPhrase = (CheckBox) findViewById(R.id.use_pass_phrase);
|
||||||
|
mPassPhraseLayout = (ViewGroup) findViewById(R.id.layout_pass_phrase);
|
||||||
mPassPhrase = (EditText) findViewById(R.id.pass_phrase);
|
mPassPhrase = (EditText) findViewById(R.id.pass_phrase);
|
||||||
mPassPhraseAgain = (EditText) findViewById(R.id.pass_phrase_again);
|
mPassPhraseAgain = (EditText) findViewById(R.id.pass_phrase_again);
|
||||||
|
|
||||||
|
mUsePassPhrase.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
CheckBox checkBox = (CheckBox) v;
|
||||||
|
if (checkBox.isChecked()) {
|
||||||
|
mPassPhraseLayout.setVisibility(ViewGroup.VISIBLE);
|
||||||
|
} else {
|
||||||
|
mPassPhrase.setText("");
|
||||||
|
mPassPhraseAgain.setText("");
|
||||||
|
mPassPhraseLayout.setVisibility(ViewGroup.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (mUsePassPhrase.isChecked()) {
|
||||||
|
mPassPhraseLayout.setVisibility(ViewGroup.VISIBLE);
|
||||||
|
} else {
|
||||||
|
mPassPhraseLayout.setVisibility(ViewGroup.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
mEncryptButton.setOnClickListener(new OnClickListener() {
|
mEncryptButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -181,8 +179,16 @@ public class EncryptFileActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateView() {
|
private void updateView() {
|
||||||
|
if (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0) {
|
||||||
|
mSelectKeysButton.setText(R.string.no_keys_selected);
|
||||||
|
} else if (mEncryptionKeyIds.length == 1) {
|
||||||
|
mSelectKeysButton.setText(R.string.one_key_selected);
|
||||||
|
} else {
|
||||||
|
mSelectKeysButton.setText("" + mEncryptionKeyIds.length + " " +
|
||||||
|
getResources().getString(R.string.n_keys_selected));
|
||||||
|
}
|
||||||
|
|
||||||
if (getSecretKeyId() == 0) {
|
if (getSecretKeyId() == 0) {
|
||||||
mSign.setText(R.string.sign);
|
|
||||||
mSign.setChecked(false);
|
mSign.setChecked(false);
|
||||||
mMainUserId.setText("");
|
mMainUserId.setText("");
|
||||||
mMainUserIdRest.setText("");
|
mMainUserIdRest.setText("");
|
||||||
@ -203,7 +209,6 @@ public class EncryptFileActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
mMainUserId.setText(uid);
|
mMainUserId.setText(uid);
|
||||||
mMainUserIdRest.setText(uidExtra);
|
mMainUserIdRest.setText(uidExtra);
|
||||||
mSign.setText(R.string.sign_as);
|
|
||||||
mSign.setChecked(true);
|
mSign.setChecked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,6 +236,12 @@ public class EncryptFileActivity extends BaseActivity {
|
|||||||
startActivityForResult(intent, Id.request.secret_keys);
|
startActivityForResult(intent, Id.request.secret_keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void selectPublicKeys() {
|
||||||
|
Intent intent = new Intent(this, SelectPublicKeyListActivity.class);
|
||||||
|
intent.putExtra("selection", mEncryptionKeyIds);
|
||||||
|
startActivityForResult(intent, Id.request.public_keys);
|
||||||
|
}
|
||||||
|
|
||||||
private void encryptClicked() {
|
private void encryptClicked() {
|
||||||
String currentFilename = mFilename.getText().toString();
|
String currentFilename = mFilename.getText().toString();
|
||||||
if (mInputFilename == null || !mInputFilename.equals(currentFilename)) {
|
if (mInputFilename == null || !mInputFilename.equals(currentFilename)) {
|
||||||
@ -245,36 +256,9 @@ public class EncryptFileActivity extends BaseActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTabHost.getCurrentTabTag().equals(TAB_ASYMMETRIC)) {
|
|
||||||
Vector<Long> vector = new Vector<Long>();
|
|
||||||
for (int i = 0; i < mPublicKeyList.getCount(); ++i) {
|
|
||||||
if (mPublicKeyList.isItemChecked(i)) {
|
|
||||||
vector.add(mPublicKeyList.getItemIdAtPosition(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (vector.size() > 0) {
|
|
||||||
mEncryptionKeyIds = new long[vector.size()];
|
|
||||||
for (int i = 0; i < vector.size(); ++i) {
|
|
||||||
mEncryptionKeyIds[i] = vector.get(i);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mEncryptionKeyIds = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean encryptIt = mEncryptionKeyIds != null && mEncryptionKeyIds.length > 0;
|
|
||||||
// for now only support encryption
|
|
||||||
if (!encryptIt) {
|
|
||||||
Toast.makeText(this, "Select at least one encryption key.",
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getSecretKeyId() != 0 && Apg.getPassPhrase() == null) {
|
|
||||||
showDialog(Id.dialog.pass_phrase);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// symmetric encryption
|
// symmetric encryption
|
||||||
|
boolean gotPassPhrase = false;
|
||||||
|
if (mUsePassPhrase.isChecked()) {
|
||||||
String passPhrase = mPassPhrase.getText().toString();
|
String passPhrase = mPassPhrase.getText().toString();
|
||||||
String passPhraseAgain = mPassPhraseAgain.getText().toString();
|
String passPhraseAgain = mPassPhraseAgain.getText().toString();
|
||||||
if (!passPhrase.equals(passPhraseAgain)) {
|
if (!passPhrase.equals(passPhraseAgain)) {
|
||||||
@ -283,13 +267,27 @@ public class EncryptFileActivity extends BaseActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (passPhrase.length() == 0) {
|
gotPassPhrase = (passPhrase.length() != 0);
|
||||||
|
if (!gotPassPhrase) {
|
||||||
Toast.makeText(this, "Enter a pass phrase.",
|
Toast.makeText(this, "Enter a pass phrase.",
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean encryptIt = mEncryptionKeyIds != null && mEncryptionKeyIds.length > 0;
|
||||||
|
// for now require at least one form of encryption
|
||||||
|
if (!encryptIt && !gotPassPhrase) {
|
||||||
|
Toast.makeText(this, "Select at least one encryption key or a pass phrase.",
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getSecretKeyId() != 0 && Apg.getPassPhrase() == null) {
|
||||||
|
showDialog(Id.dialog.pass_phrase);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
askForOutputFilename();
|
askForOutputFilename();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,21 +323,15 @@ public class EncryptFileActivity extends BaseActivity {
|
|||||||
InputStream in = new FileInputStream(mInputFilename);
|
InputStream in = new FileInputStream(mInputFilename);
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
|
||||||
if (mTabHost.getCurrentTabTag().equals(TAB_ASYMMETRIC)) {
|
String passPhrase = mPassPhrase.getText().toString();
|
||||||
boolean encryptIt = mEncryptionKeyIds != null && mEncryptionKeyIds.length > 0;
|
if (passPhrase.length() == 0) {
|
||||||
|
passPhrase = null;
|
||||||
if (encryptIt) {
|
}
|
||||||
Apg.encrypt(in, out, mAsciiArmour.isChecked(),
|
Apg.encrypt(in, out, mAsciiArmour.isChecked(),
|
||||||
mEncryptionKeyIds, getSecretKeyId(),
|
mEncryptionKeyIds, getSecretKeyId(),
|
||||||
Apg.getPassPhrase(), this,
|
Apg.getPassPhrase(), this,
|
||||||
PGPEncryptedData.AES_256, null);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Apg.encrypt(in, out, mAsciiArmour.isChecked(),
|
|
||||||
null, 0, null, this,
|
|
||||||
((Choice) mAlgorithm.getSelectedItem()).getId(),
|
((Choice) mAlgorithm.getSelectedItem()).getId(),
|
||||||
mPassPhrase.getText().toString());
|
passPhrase);
|
||||||
}
|
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
OutputStream fileOut = new FileOutputStream(mOutputFilename);
|
OutputStream fileOut = new FileOutputStream(mOutputFilename);
|
||||||
@ -447,6 +439,23 @@ public class EncryptFileActivity extends BaseActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case Id.request.secret_keys: {
|
||||||
|
if (resultCode == RESULT_OK) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Id.request.public_keys: {
|
||||||
|
if (resultCode == RESULT_OK) {
|
||||||
|
Bundle bundle = data.getExtras();
|
||||||
|
mEncryptionKeyIds = bundle.getLongArray("selection");
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,6 @@ public class EncryptMessageActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getSecretKeyId() == 0) {
|
if (getSecretKeyId() == 0) {
|
||||||
mSign.setText(R.string.sign);
|
|
||||||
mSign.setChecked(false);
|
mSign.setChecked(false);
|
||||||
mMainUserId.setText("");
|
mMainUserId.setText("");
|
||||||
mMainUserIdRest.setText("");
|
mMainUserIdRest.setText("");
|
||||||
@ -264,7 +263,6 @@ public class EncryptMessageActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
mMainUserId.setText(uid);
|
mMainUserId.setText(uid);
|
||||||
mMainUserIdRest.setText(uidExtra);
|
mMainUserIdRest.setText(uidExtra);
|
||||||
mSign.setText(R.string.sign_as);
|
|
||||||
mSign.setChecked(true);
|
mSign.setChecked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,6 +222,8 @@ public class MainActivity extends BaseActivity {
|
|||||||
SpannableString info =
|
SpannableString info =
|
||||||
new SpannableString("Read the warnings!\n\n" +
|
new SpannableString("Read the warnings!\n\n" +
|
||||||
"Changes:\n" +
|
"Changes:\n" +
|
||||||
|
"* new layout for encrypt file\n" +
|
||||||
|
"* layout more consistent\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"WARNING: be careful editing your existing keys, as they " +
|
"WARNING: be careful editing your existing keys, as they " +
|
||||||
"WILL be stripped of certificates right now.\n" +
|
"WILL be stripped of certificates right now.\n" +
|
||||||
|
Loading…
Reference in New Issue
Block a user