diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2016-01-11 08:32:41 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2016-01-11 08:32:41 +0100 |
commit | fd3a1e900e7f8ea7ed8c15791f227203df118ada (patch) | |
tree | 30d89dbad51bc29e6486e9fb717877387af38934 | |
parent | f691ef2a262012898c3f0b61fa9357a59292288b (diff) | |
download | open-keychain-fd3a1e900e7f8ea7ed8c15791f227203df118ada.tar.gz open-keychain-fd3a1e900e7f8ea7ed8c15791f227203df118ada.tar.bz2 open-keychain-fd3a1e900e7f8ea7ed8c15791f227203df118ada.zip |
Move edit key configuration to menu
4 files changed, 53 insertions, 70 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java index 5c3ac999c..78e91b56c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java @@ -17,16 +17,15 @@ package org.sufficientlysecure.keychain.ui; - -import java.util.Date; -import java.util.Iterator; - import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; @@ -54,6 +53,9 @@ import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; import org.sufficientlysecure.keychain.util.Preferences; +import java.util.Date; +import java.util.Iterator; + public class CreateKeyFinalFragment extends Fragment { public static final int REQUEST_EDIT_KEY = 0x00008007; @@ -63,8 +65,6 @@ public class CreateKeyFinalFragment extends Fragment { CheckBox mUploadCheckbox; View mBackButton; View mCreateButton; - TextView mEditText; - View mEditButton; SaveKeyringParcel mSaveKeyringParcel; @@ -96,8 +96,6 @@ public class CreateKeyFinalFragment extends Fragment { mUploadCheckbox = (CheckBox) view.findViewById(R.id.create_key_upload); mBackButton = view.findViewById(R.id.create_key_back_button); mCreateButton = view.findViewById(R.id.create_key_next_button); - mEditText = (TextView) view.findViewById(R.id.create_key_edit_text); - mEditButton = view.findViewById(R.id.create_key_edit_button); CreateKeyActivity createKeyActivity = (CreateKeyActivity) getActivity(); @@ -135,15 +133,6 @@ public class CreateKeyFinalFragment extends Fragment { } }); - mEditButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent edit = new Intent(getActivity(), EditKeyActivity.class); - edit.putExtra(EditKeyActivity.EXTRA_SAVE_KEYRING_PARCEL, mSaveKeyringParcel); - startActivityForResult(edit, REQUEST_EDIT_KEY); - } - }); - // If this is a debug build, don't upload by default if (Constants.DEBUG) { mUploadCheckbox.setChecked(false); @@ -153,6 +142,38 @@ public class CreateKeyFinalFragment extends Fragment { } @Override + public void onPrepareOptionsMenu(Menu menu) { + CreateKeyActivity createKeyActivity = (CreateKeyActivity) getActivity(); + + MenuItem editItem = menu.findItem(R.id.menu_create_key_edit); + editItem.setEnabled(!createKeyActivity.mCreateSecurityToken); + + super.onPrepareOptionsMenu(menu); + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + inflater.inflate(R.menu.create_key_final, menu); + + super.onCreateOptionsMenu(menu, inflater); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + + case R.id.menu_create_key_edit: + Intent edit = new Intent(getActivity(), EditKeyActivity.class); + edit.putExtra(EditKeyActivity.EXTRA_SAVE_KEYRING_PARCEL, mSaveKeyringParcel); + startActivityForResult(edit, REQUEST_EDIT_KEY); + return true; + + default: + return super.onOptionsItemSelected(item); + } + } + + @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (mCreateOpHelper != null) { mCreateOpHelper.handleActivityResult(requestCode, resultCode, data); @@ -168,7 +189,6 @@ public class CreateKeyFinalFragment extends Fragment { case REQUEST_EDIT_KEY: { if (resultCode == Activity.RESULT_OK) { mSaveKeyringParcel = data.getParcelableExtra(EditKeyActivity.EXTRA_SAVE_KEYRING_PARCEL); - mEditText.setText(R.string.create_key_custom); } break; } @@ -184,6 +204,9 @@ public class CreateKeyFinalFragment extends Fragment { CreateKeyActivity createKeyActivity = (CreateKeyActivity) getActivity(); + // We have a menu item to show in action bar. + setHasOptionsMenu(true); + if (mSaveKeyringParcel == null) { mSaveKeyringParcel = new SaveKeyringParcel(); @@ -194,8 +217,6 @@ public class CreateKeyFinalFragment extends Fragment { 2048, null, KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE, 0L)); mSaveKeyringParcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(Algorithm.RSA, 2048, null, KeyFlags.AUTHENTICATION, 0L)); - mEditText.setText(R.string.create_key_custom); - mEditButton.setEnabled(false); // use empty passphrase mSaveKeyringParcel.mNewUnlock = new ChangeUnlockParcel(new Passphrase(), null); @@ -333,7 +354,7 @@ public class CreateKeyFinalFragment extends Fragment { // define subkeys that should be moved to the card Cursor cursor = activity.getContentResolver().query( KeychainContract.Keys.buildKeysUri(changeKeyringParcel.mMasterKeyId), - new String[] { KeychainContract.Keys.KEY_ID, }, null, null, null + new String[]{KeychainContract.Keys.KEY_ID,}, null, null, null ); try { while (cursor != null && cursor.moveToNext()) { diff --git a/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml b/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml index 118f0661a..578e036d8 100644 --- a/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml +++ b/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml @@ -75,54 +75,6 @@ android:layout_height="1dip" android:background="?android:attr/listDivider" /> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal"> - - <TextView - android:id="@+id/create_key_edit_text" - android:padding="8dp" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="@string/create_key_rsa" - android:textColor="?attr/colorPrimary" - android:textAppearance="?android:attr/textAppearanceMedium" - android:minHeight="?android:attr/listPreferredItemHeight" - android:clickable="true" - android:gravity="center_vertical" - android:layout_gravity="center_vertical" /> - - <View - android:layout_width="1dp" - android:layout_height="match_parent" - android:layout_marginTop="8dp" - android:layout_marginBottom="8dp" - android:background="?android:attr/listDivider" /> - - <TextView - android:id="@+id/create_key_edit_button" - android:paddingLeft="8dp" - android:paddingRight="8dp" - android:textAppearance="?android:attr/textAppearanceMedium" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="@string/create_key_edit" - android:minHeight="?android:attr/listPreferredItemHeight" - android:gravity="center_vertical" - android:clickable="true" - android:background="?android:selectableItemBackground" - android:layout_gravity="center_vertical" /> - </LinearLayout> - - - <View - android:layout_width="match_parent" - android:layout_height="1dip" - android:background="?android:attr/listDivider" /> - <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/OpenKeychain/src/main/res/layout/create_key_start_fragment.xml b/OpenKeychain/src/main/res/layout/create_key_start_fragment.xml index 5221fa6e6..e6e92c451 100644 --- a/OpenKeychain/src/main/res/layout/create_key_start_fragment.xml +++ b/OpenKeychain/src/main/res/layout/create_key_start_fragment.xml @@ -80,7 +80,7 @@ android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_centerVertical="true" - android:paddingRight="10dp" + android:paddingRight="4dp" android:src="@drawable/ic_chevron_right_grey_24dp" /> <TextView diff --git a/OpenKeychain/src/main/res/menu/create_key_final.xml b/OpenKeychain/src/main/res/menu/create_key_final.xml new file mode 100644 index 000000000..e68b9b4a4 --- /dev/null +++ b/OpenKeychain/src/main/res/menu/create_key_final.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> + + <item + android:id="@+id/menu_create_key_edit" + android:title="@string/create_key_edit" + app:showAsAction="never" /> + +</menu> |