diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-10-15 19:10:06 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-10-15 19:10:06 +0200 |
commit | 8279f84eb88a80e197514f2ab94e0e91416a19e7 (patch) | |
tree | 7cf1533e1a57af50e65341aea6bb7f1db900e20b /OpenKeychain/src | |
parent | cad89f12e21568255d8892b8a3004ce85353d657 (diff) | |
download | open-keychain-8279f84eb88a80e197514f2ab94e0e91416a19e7.tar.gz open-keychain-8279f84eb88a80e197514f2ab94e0e91416a19e7.tar.bz2 open-keychain-8279f84eb88a80e197514f2ab94e0e91416a19e7.zip |
Add restore to backup fragment, cleanup, renamings
Diffstat (limited to 'OpenKeychain/src')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupRestoreFragment.java | 66 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptDecryptFragment.java (renamed from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptDecryptOverviewFragment.java) | 7 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java | 4 | ||||
-rw-r--r-- | OpenKeychain/src/main/res/layout/backup_restore_fragment.xml (renamed from OpenKeychain/src/main/res/layout/drawer_backup_fragment.xml) | 22 | ||||
-rw-r--r-- | OpenKeychain/src/main/res/layout/encrypt_decrypt_fragment.xml (renamed from OpenKeychain/src/main/res/layout/encrypt_decrypt_overview_fragment.xml) | 0 | ||||
-rw-r--r-- | OpenKeychain/src/main/res/values/strings.xml | 1 |
6 files changed, 80 insertions, 20 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupRestoreFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupRestoreFragment.java index 5336f909c..25601d655 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupRestoreFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupRestoreFragment.java @@ -17,13 +17,13 @@ package org.sufficientlysecure.keychain.ui; - import java.util.ArrayList; import android.app.Activity; import android.content.ContentResolver; import android.content.Intent; import android.database.Cursor; +import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.Nullable; @@ -36,6 +36,8 @@ import android.view.ViewGroup; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; +import org.sufficientlysecure.keychain.ui.util.Notify; +import org.sufficientlysecure.keychain.util.FileHelper; public class BackupRestoreFragment extends Fragment { @@ -44,14 +46,16 @@ public class BackupRestoreFragment extends Fragment { // This index for remembering the number of master key. private int mIndex; - static final int REQUEST_REPEAT_PASSPHRASE = 1; + private static final int REQUEST_REPEAT_PASSPHRASE = 0x00007002; + private static final int REQUEST_CODE_INPUT = 0x00007003; @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.drawer_backup_fragment, container, false); + View view = inflater.inflate(R.layout.backup_restore_fragment, container, false); View backupAll = view.findViewById(R.id.backup_all); View backupPublicKeys = view.findViewById(R.id.backup_public_keys); + final View restore = view.findViewById(R.id.restore); backupAll.setOnClickListener(new View.OnClickListener() { @Override @@ -67,6 +71,13 @@ public class BackupRestoreFragment extends Fragment { } }); + restore.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + restore(); + } + }); + return view; } @@ -81,12 +92,12 @@ public class BackupRestoreFragment extends Fragment { return; } - new AsyncTask<ContentResolver,Void,ArrayList<Long>>() { + new AsyncTask<ContentResolver, Void, ArrayList<Long>>() { @Override protected ArrayList<Long> doInBackground(ContentResolver... resolver) { ArrayList<Long> askPassphraseIds = new ArrayList<>(); Cursor cursor = resolver[0].query( - KeyRings.buildUnifiedKeyRingsUri(), new String[] { + KeyRings.buildUnifiedKeyRingsUri(), new String[]{ KeyRings.MASTER_KEY_ID, KeyRings.HAS_SECRET, }, KeyRings.HAS_SECRET + " != 0", null, null); @@ -136,7 +147,6 @@ public class BackupRestoreFragment extends Fragment { } }.execute(activity.getContentResolver()); - } private void startPassphraseActivity() { @@ -153,25 +163,53 @@ public class BackupRestoreFragment extends Fragment { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == REQUEST_REPEAT_PASSPHRASE) { - if (resultCode != Activity.RESULT_OK) { - return; + switch (requestCode) { + case REQUEST_REPEAT_PASSPHRASE: { + if (resultCode != Activity.RESULT_OK) { + return; + } + if (mIndex < mIdsForRepeatAskPassphrase.size()) { + startPassphraseActivity(); + return; + } + + startBackup(true); + + break; } - if (mIndex < mIdsForRepeatAskPassphrase.size()) { - startPassphraseActivity(); - return; + + case REQUEST_CODE_INPUT: { + if (resultCode != Activity.RESULT_OK || data == null) { + return; + } + + Uri uri = data.getData(); + if (uri == null) { + Notify.create(getActivity(), R.string.no_file_selected, Notify.Style.ERROR).show(); + return; + } + + Intent intent = new Intent(getActivity(), DecryptActivity.class); + intent.setAction(Intent.ACTION_VIEW); + intent.setData(uri); + startActivity(intent); + break; } - startBackup(true); + default: { + super.onActivityResult(requestCode, resultCode, data); + } } } private void startBackup(boolean exportSecret) { - Intent intent = new Intent(getActivity(), BackupActivity.class); intent.putExtra(BackupActivity.EXTRA_SECRET, exportSecret); startActivity(intent); + } + private void restore() { + FileHelper.openDocument(this, null, "*/*", false, REQUEST_CODE_INPUT); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptDecryptOverviewFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptDecryptFragment.java index 84660ca7a..89ea6165b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptDecryptOverviewFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptDecryptFragment.java @@ -25,7 +25,6 @@ import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; @@ -42,7 +41,7 @@ import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.ui.util.SubtleAttentionSeeker; import org.sufficientlysecure.keychain.util.FileHelper; -public class EncryptDecryptOverviewFragment extends Fragment { +public class EncryptDecryptFragment extends Fragment { View mClipboardIcon; @@ -56,7 +55,7 @@ public class EncryptDecryptOverviewFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.encrypt_decrypt_overview_fragment, container, false); + View view = inflater.inflate(R.layout.encrypt_decrypt_fragment, container, false); View mEncryptFile = view.findViewById(R.id.encrypt_files); View mEncryptText = view.findViewById(R.id.encrypt_text); @@ -83,7 +82,7 @@ public class EncryptDecryptOverviewFragment extends Fragment { mDecryptFile.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - FileHelper.openDocument(EncryptDecryptOverviewFragment.this, null, "*/*", false, REQUEST_CODE_INPUT); + FileHelper.openDocument(EncryptDecryptFragment.this, null, "*/*", false, REQUEST_CODE_INPUT); } }); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java index 51bc99ea3..7e9b4953c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java @@ -190,7 +190,7 @@ public class MainActivity extends BaseNfcActivity implements FabContainer, OnBac private void onEnDecryptSelected() { mToolbar.setTitle(R.string.nav_encrypt_decrypt); mDrawer.setSelectionByIdentifier(ID_ENCRYPT_DECRYPT, false); - Fragment frag = new EncryptDecryptOverviewFragment(); + Fragment frag = new EncryptDecryptFragment(); setFragment(frag, true); } @@ -259,7 +259,7 @@ public class MainActivity extends BaseNfcActivity implements FabContainer, OnBac if (frag instanceof KeyListFragment) { mToolbar.setTitle(R.string.app_name); mDrawer.setSelection(mDrawer.getPositionFromIdentifier(ID_KEYS), false); - } else if (frag instanceof EncryptDecryptOverviewFragment) { + } else if (frag instanceof EncryptDecryptFragment) { mToolbar.setTitle(R.string.nav_encrypt_decrypt); mDrawer.setSelection(mDrawer.getPositionFromIdentifier(ID_ENCRYPT_DECRYPT), false); } else if (frag instanceof AppsListFragment) { diff --git a/OpenKeychain/src/main/res/layout/drawer_backup_fragment.xml b/OpenKeychain/src/main/res/layout/backup_restore_fragment.xml index 96fba954b..ce97b7fd4 100644 --- a/OpenKeychain/src/main/res/layout/drawer_backup_fragment.xml +++ b/OpenKeychain/src/main/res/layout/backup_restore_fragment.xml @@ -61,6 +61,28 @@ android:text="@string/backup_public_keys" android:textAppearance="?android:attr/textAppearanceMedium" /> + <TextView + style="@style/SectionHeader" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="16dp" + android:text="@string/restore_section" /> + + <TextView + android:id="@+id/restore" + style="?android:attr/borderlessButtonStyle" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:clickable="true" + android:drawablePadding="8dp" + android:drawableRight="@drawable/ic_folder_grey_24dp" + android:gravity="center_vertical" + android:minHeight="?android:attr/listPreferredItemHeight" + android:paddingLeft="8dp" + android:paddingRight="8dp" + android:text="@string/btn_decrypt_files" + android:textAppearance="?android:attr/textAppearanceMedium" /> + <View android:layout_width="match_parent" android:layout_height="1dip" diff --git a/OpenKeychain/src/main/res/layout/encrypt_decrypt_overview_fragment.xml b/OpenKeychain/src/main/res/layout/encrypt_decrypt_fragment.xml index 7bd919abc..7bd919abc 100644 --- a/OpenKeychain/src/main/res/layout/encrypt_decrypt_overview_fragment.xml +++ b/OpenKeychain/src/main/res/layout/encrypt_decrypt_fragment.xml diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 8dd1f1b50..f1154645d 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -1434,6 +1434,7 @@ <string name="backup_all">"All keys + your own keys"</string> <string name="backup_public_keys">"All keys"</string> <string name="backup_section">"Backup"</string> + <string name="restore_section">"Restore"</string> <!-- unsorted --> <string name="section_certifier_id">"Certifier"</string> |