mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-07 01:35:00 -05:00
action bar and a small fix
This commit is contained in:
parent
d4d6de1bc5
commit
aee4ec6d1f
@ -55,6 +55,7 @@ import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -97,6 +98,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
private String mSavedNewPassPhrase = null;
|
||||
private boolean mIsPassPhraseSet;
|
||||
private boolean mNeedsSaving;
|
||||
private MenuItem mSaveButton;
|
||||
|
||||
private BootstrapButton mChangePassPhrase;
|
||||
|
||||
@ -109,12 +111,19 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
|
||||
ExportHelper mExportHelper;
|
||||
|
||||
public void somethingChanged()
|
||||
public boolean needsSaving()
|
||||
{
|
||||
mNeedsSaving = mUserIdsView.needsSaving();
|
||||
mNeedsSaving |= mKeysView.needsSaving();
|
||||
mNeedsSaving |= hasPassphraseChanged();
|
||||
Toast.makeText(this, "Needs saving: " + Boolean.toString(mNeedsSaving) + "(" + Boolean.toString(mUserIdsView.needsSaving()) + ", " + Boolean.toString(mKeysView.needsSaving()) + ")", Toast.LENGTH_LONG).show();
|
||||
return mNeedsSaving;
|
||||
}
|
||||
|
||||
|
||||
public void somethingChanged()
|
||||
{
|
||||
ActivityCompat.invalidateOptionsMenu(this);
|
||||
//Toast.makeText(this, "Needs saving: " + Boolean.toString(mNeedsSaving) + "(" + Boolean.toString(mUserIdsView.needsSaving()) + ", " + Boolean.toString(mKeysView.needsSaving()) + ")", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public void onDeleted(Editor e, boolean wasNewItem)
|
||||
@ -133,6 +142,10 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
|
||||
mExportHelper = new ExportHelper(this);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setIcon(android.R.color.transparent);
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
|
||||
mUserIds = new Vector<String>();
|
||||
mKeys = new Vector<PGPSecretKey>();
|
||||
mKeysUsages = new Vector<Integer>();
|
||||
@ -153,20 +166,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
* @param intent
|
||||
*/
|
||||
private void handleActionCreateKey(Intent intent) {
|
||||
// Inflate a "Done"/"Cancel" custom action bar
|
||||
ActionBarHelper.setDoneCancelView(getSupportActionBar(), R.string.btn_save,
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
saveClicked();
|
||||
}
|
||||
}, R.string.btn_do_not_save, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
cancelClicked();
|
||||
}
|
||||
});
|
||||
|
||||
Bundle extras = intent.getExtras();
|
||||
|
||||
mCurrentPassPhrase = "";
|
||||
@ -255,15 +254,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
* @param intent
|
||||
*/
|
||||
private void handleActionEditKey(Intent intent) {
|
||||
// Inflate a "Done"/"Cancel" custom action bar
|
||||
ActionBarHelper.setDoneView(getSupportActionBar(), R.string.btn_save,
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
saveClicked();
|
||||
}
|
||||
});
|
||||
|
||||
mDataUri = intent.getData();
|
||||
if (mDataUri == null) {
|
||||
Log.e(Constants.TAG, "Intent data missing. Should be Uri of key!");
|
||||
@ -325,12 +315,17 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
getMenuInflater().inflate(R.menu.key_edit, menu);
|
||||
mSaveButton = (MenuItem) menu.findItem(R.id.menu_key_edit_save);
|
||||
mSaveButton.setEnabled(needsSaving());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
cancelClicked();
|
||||
return true;
|
||||
case R.id.menu_key_edit_cancel:
|
||||
cancelClicked();
|
||||
return true;
|
||||
@ -353,6 +348,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
mExportHelper.deleteKey(mDataUri, Id.type.secret_key, returnHandler);
|
||||
return true;
|
||||
}
|
||||
case R.id.menu_key_edit_save:
|
||||
saveClicked();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@ -373,8 +371,15 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
Toast.makeText(this, R.string.error_no_secret_key_found, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
if (masterKey != null) {
|
||||
boolean isSet = false;
|
||||
for (String userId : new IterableIterator<String>(masterKey.getUserIDs())) {
|
||||
Log.d(Constants.TAG, "Added userId " + userId);
|
||||
if (!isSet) {
|
||||
isSet = true;
|
||||
String[] parts = PgpKeyHelper.splitUserId(userId);
|
||||
if (parts[0] != null)
|
||||
setTitle(parts[0]);
|
||||
}
|
||||
mUserIds.add(userId);
|
||||
}
|
||||
}
|
||||
@ -465,7 +470,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
}
|
||||
});
|
||||
|
||||
// disable passphrase when no passphrase checkobox is checked!
|
||||
// disable passphrase when no passphrase checkbox is checked!
|
||||
mNoPassphrase.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
|
@ -133,6 +133,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
public void onDeleted(Editor editor, boolean wasNewItem) {
|
||||
oldItemDeleted |= !wasNewItem;
|
||||
this.updateEditorsVisible();
|
||||
if (mEditorListener != null) {
|
||||
mEditorListener.onEdited();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -137,12 +137,12 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
|
||||
mOriginalName = result[0];
|
||||
}
|
||||
if (result[1] != null) {
|
||||
mComment.setText(result[1]);
|
||||
mOriginalComment = result[1];
|
||||
mEmail.setText(result[1]);
|
||||
mOriginalEmail = result[1];
|
||||
}
|
||||
if (result[2] != null) {
|
||||
mEmail.setText(result[2]);
|
||||
mOriginalEmail = result[2];
|
||||
mComment.setText(result[2]);
|
||||
mOriginalComment = result[2];
|
||||
}
|
||||
|
||||
mOriginallyMainUserID = isMainID;
|
||||
|
@ -2,6 +2,12 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_key_edit_save"
|
||||
android:icon="@drawable/ic_action_done"
|
||||
app:showAsAction="always"
|
||||
android:title="@string/btn_save">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/menu_key_edit_export_file"
|
||||
app:showAsAction="never"
|
||||
|
Loading…
Reference in New Issue
Block a user