diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2014-07-26 03:59:12 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2014-07-26 03:59:12 +0200 |
commit | 043ed600e69683022818bf763c0d8e9396d3dff5 (patch) | |
tree | 97fd9455f181075921da42399e309d62576e1360 /OpenKeychain/src | |
parent | 7296ac484914bbe5cec90b37cc1319db49f7d9b8 (diff) | |
parent | 9ea514855080513664ed7a95bb658e59cfb1bc17 (diff) | |
download | open-keychain-043ed600e69683022818bf763c0d8e9396d3dff5.tar.gz open-keychain-043ed600e69683022818bf763c0d8e9396d3dff5.tar.bz2 open-keychain-043ed600e69683022818bf763c0d8e9396d3dff5.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'OpenKeychain/src')
4 files changed, 48 insertions, 43 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java index e55c14a2a..5d765b663 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java @@ -139,7 +139,7 @@ public class Preferences { editor.commit(); } - public boolean getFirstTime() { + public boolean isFirstTime() { return mSharedPreferences.getBoolean(Constants.Pref.FIRST_TIME, true); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyActivity.java index d2073d9a7..fe1b7e688 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyActivity.java @@ -45,10 +45,10 @@ import java.util.regex.Matcher; public class CreateKeyActivity extends ActionBarActivity { - AutoCompleteTextView nameEdit; - AutoCompleteTextView emailEdit; - EditText passphraseEdit; - Button createButton; + AutoCompleteTextView mNameEdit; + AutoCompleteTextView mEmailEdit; + EditText mPassphraseEdit; + Button mCreateButton; @Override protected void onCreate(Bundle savedInstanceState) { @@ -56,19 +56,19 @@ public class CreateKeyActivity extends ActionBarActivity { setContentView(R.layout.create_key_activity); - nameEdit = (AutoCompleteTextView) findViewById(R.id.name); - emailEdit = (AutoCompleteTextView) findViewById(R.id.email); - passphraseEdit = (EditText) findViewById(R.id.passphrase); - createButton = (Button) findViewById(R.id.create_key_button); + mNameEdit = (AutoCompleteTextView) findViewById(R.id.name); + mEmailEdit = (AutoCompleteTextView) findViewById(R.id.email); + mPassphraseEdit = (EditText) findViewById(R.id.passphrase); + mCreateButton = (Button) findViewById(R.id.create_key_button); - emailEdit.setThreshold(1); // Start working from first character - emailEdit.setAdapter( + mEmailEdit.setThreshold(1); // Start working from first character + mEmailEdit.setAdapter( new ArrayAdapter<String> (this, android.R.layout.simple_spinner_dropdown_item, ContactHelper.getPossibleUserEmails(this) ) ); - emailEdit.addTextChangedListener(new TextWatcher() { + mEmailEdit.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @@ -83,27 +83,28 @@ public class CreateKeyActivity extends ActionBarActivity { if (email.length() > 0) { Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email); if (emailMatcher.matches()) { - emailEdit.setCompoundDrawablesWithIntrinsicBounds(0, 0, + mEmailEdit.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.uid_mail_ok, 0); } else { - emailEdit.setCompoundDrawablesWithIntrinsicBounds(0, 0, + mEmailEdit.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.uid_mail_bad, 0); } } else { // remove drawable if email is empty - emailEdit.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + mEmailEdit.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); } } }); - nameEdit.setThreshold(1); // Start working from first character - nameEdit.setAdapter( + + mNameEdit.setThreshold(1); // Start working from first character + mNameEdit.setAdapter( new ArrayAdapter<String> (this, android.R.layout.simple_spinner_dropdown_item, ContactHelper.getPossibleUserNames(this) ) ); - createButton.setOnClickListener(new View.OnClickListener() { + mCreateButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { createKeyCheck(); @@ -113,9 +114,9 @@ public class CreateKeyActivity extends ActionBarActivity { } private void createKeyCheck() { - if (isEditTextNotEmpty(this, nameEdit) - && isEditTextNotEmpty(this, emailEdit) - && isEditTextNotEmpty(this, passphraseEdit)) { + if (isEditTextNotEmpty(this, mNameEdit) + && isEditTextNotEmpty(this, mEmailEdit) + && isEditTextNotEmpty(this, mPassphraseEdit)) { createKey(); } } @@ -134,6 +135,7 @@ public class CreateKeyActivity extends ActionBarActivity { super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { + CreateKeyActivity.this.setResult(RESULT_OK); CreateKeyActivity.this.finish(); } } @@ -146,9 +148,9 @@ public class CreateKeyActivity extends ActionBarActivity { parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(Constants.choice.algorithm.rsa, 4096, KeyFlags.CERTIFY_OTHER, null)); parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(Constants.choice.algorithm.rsa, 4096, KeyFlags.SIGN_DATA, null)); parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(Constants.choice.algorithm.rsa, 4096, KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE, null)); - String userId = nameEdit.getText().toString() + " <" + emailEdit.getText().toString() + ">"; + String userId = mNameEdit.getText().toString() + " <" + mEmailEdit.getText().toString() + ">"; parcel.mAddUserIds.add(userId); - parcel.mNewPassphrase = passphraseEdit.getText().toString(); + parcel.mNewPassphrase = mPassphraseEdit.getText().toString(); // get selected key entries data.putParcelable(KeychainIntentService.SAVE_KEYRING_PARCEL, parcel); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/FirstTimeActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/FirstTimeActivity.java index aa4120d2c..4271b2d5a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/FirstTimeActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/FirstTimeActivity.java @@ -25,6 +25,7 @@ import android.view.Window; import android.widget.Button; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.Preferences; public class FirstTimeActivity extends ActionBarActivity { @@ -47,9 +48,7 @@ public class FirstTimeActivity extends ActionBarActivity { mSkipSetup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent intent = new Intent(FirstTimeActivity.this, KeyListActivity.class); - startActivity(intent); - finish(); + finishSetup(); } }); @@ -58,8 +57,7 @@ public class FirstTimeActivity extends ActionBarActivity { public void onClick(View v) { Intent intent = new Intent(FirstTimeActivity.this, ImportKeysActivity.class); intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN); - startActivity(intent); - finish(); + startActivityForResult(intent, 1); } }); @@ -67,11 +65,26 @@ public class FirstTimeActivity extends ActionBarActivity { @Override public void onClick(View v) { Intent intent = new Intent(FirstTimeActivity.this, CreateKeyActivity.class); - startActivity(intent); - finish(); + startActivityForResult(intent, 1); } }); } + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + + if (resultCode == RESULT_OK) { + finishSetup(); + } + } + + private void finishSetup() { + Preferences prefs = Preferences.getPreferences(this); + prefs.setFirstTime(false); + Intent intent = new Intent(FirstTimeActivity.this, KeyListActivity.class); + startActivity(intent); + finish(); + } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java index 9cc623c83..095762283 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java @@ -17,28 +17,19 @@ package org.sufficientlysecure.keychain.ui; -import android.app.ProgressDialog; import android.content.Intent; import android.os.Bundle; -import android.os.Message; -import android.os.Messenger; import android.view.Menu; import android.view.MenuItem; import com.devspark.appmsg.AppMsg; -import org.spongycastle.bcpg.sig.KeyFlags; import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.Constants.choice.algorithm; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.ExportHelper; import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainDatabase; -import org.sufficientlysecure.keychain.service.KeychainIntentService; -import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; -import org.sufficientlysecure.keychain.service.SaveKeyringParcel; -import org.sufficientlysecure.keychain.service.SaveKeyringParcel.SubkeyAdd; import org.sufficientlysecure.keychain.util.Log; import java.io.IOException; @@ -51,11 +42,10 @@ public class KeyListActivity extends DrawerActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + // if this is the first time show first time activity Preferences prefs = Preferences.getPreferences(this); - if (prefs.getFirstTime()) { - prefs.setFirstTime(false); - Intent intent = new Intent(this, FirstTimeActivity.class); - startActivity(intent); + if (prefs.isFirstTime()) { + startActivity(new Intent(this, FirstTimeActivity.class)); finish(); return; } |