diff options
Diffstat (limited to 'OpenPGP-Keychain-API')
4 files changed, 20 insertions, 24 deletions
diff --git a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/BaseActivity.java b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/BaseActivity.java index 7e8818b5b..d37689afc 100644 --- a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/BaseActivity.java +++ b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/BaseActivity.java @@ -16,9 +16,6 @@ package org.sufficientlysecure.keychain.demo; -import org.sufficientlysecure.keychain.demo.R; - -import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.preference.Preference; @@ -27,10 +24,7 @@ import android.preference.PreferenceActivity; import android.widget.Toast; public class BaseActivity extends PreferenceActivity { - private Activity mActivity; - private Preference mIntentDemo; - private Preference mContentProviderDemo; private Preference mCryptoProvider; /** @@ -40,14 +34,11 @@ public class BaseActivity extends PreferenceActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mActivity = this; - // load preferences from xml addPreferencesFromResource(R.xml.base_preference); // find preferences mIntentDemo = (Preference) findPreference("intent_demo"); - mContentProviderDemo = (Preference) findPreference("content_provider_demo"); mCryptoProvider = (Preference) findPreference("openpgp_provider_demo"); mIntentDemo.setOnPreferenceClickListener(new OnPreferenceClickListener() { @@ -63,12 +54,11 @@ public class BaseActivity extends PreferenceActivity { mCryptoProvider.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { - startActivity(new Intent(mActivity, OpenPgpProviderActivity.class)); + startActivity(new Intent(BaseActivity.this, OpenPgpProviderActivity.class)); return false; } }); - } } diff --git a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java index bf3943e1c..7b1aecae9 100644 --- a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java +++ b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java @@ -35,7 +35,6 @@ import android.widget.ListAdapter; import android.widget.TextView; import android.widget.Toast; -import org.openintents.openpgp.IOpenPgpService; import org.openintents.openpgp.OpenPgpError; import org.openintents.openpgp.util.OpenPgpApi; import org.openintents.openpgp.util.OpenPgpConstants; @@ -49,8 +48,6 @@ import java.util.ArrayList; import java.util.List; public class OpenPgpProviderActivity extends Activity { - Activity mActivity; - EditText mMessage; EditText mCiphertext; EditText mEncryptUserIds; @@ -59,7 +56,7 @@ public class OpenPgpProviderActivity extends Activity { Button mSignAndEncrypt; Button mDecryptAndVerify; - private OpenPgpServiceConnection mCryptoServiceConnection; + OpenPgpServiceConnection mCryptoServiceConnection; public static final int REQUEST_CODE_SIGN = 9910; public static final int REQUEST_CODE_ENCRYPT = 9911; @@ -71,16 +68,14 @@ public class OpenPgpProviderActivity extends Activity { super.onCreate(icicle); setContentView(R.layout.openpgp_provider); - mActivity = this; - mMessage = (EditText) findViewById(R.id.crypto_provider_demo_message); mCiphertext = (EditText) findViewById(R.id.crypto_provider_demo_ciphertext); mEncryptUserIds = (EditText) findViewById(R.id.crypto_provider_demo_encrypt_user_id); - mSign = (Button) findViewById(R.id.crypto_provider_demo_sign); mEncrypt = (Button) findViewById(R.id.crypto_provider_demo_encrypt); mSignAndEncrypt = (Button) findViewById(R.id.crypto_provider_demo_sign_and_encrypt); mDecryptAndVerify = (Button) findViewById(R.id.crypto_provider_demo_decrypt_and_verify); + mSign.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -110,11 +105,11 @@ public class OpenPgpProviderActivity extends Activity { } private void handleError(final OpenPgpError error) { - mActivity.runOnUiThread(new Runnable() { + runOnUiThread(new Runnable() { @Override public void run() { - Toast.makeText(mActivity, + Toast.makeText(OpenPgpProviderActivity.this, "onError id:" + error.getErrorId() + "\n\n" + error.getMessage(), Toast.LENGTH_LONG).show(); Log.e(Constants.TAG, "onError getErrorId:" + error.getErrorId()); diff --git a/OpenPGP-Keychain-API/example-app/src/main/res/xml/base_preference.xml b/OpenPGP-Keychain-API/example-app/src/main/res/xml/base_preference.xml index cb76dc10f..b38e07a36 100644 --- a/OpenPGP-Keychain-API/example-app/src/main/res/xml/base_preference.xml +++ b/OpenPGP-Keychain-API/example-app/src/main/res/xml/base_preference.xml @@ -1,18 +1,18 @@ <?xml version="1.0" encoding="utf-8"?> -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> - <PreferenceCategory android:title="Intent" > + <PreferenceCategory android:title="OpenKeychain Intents"> <Preference android:key="intent_demo" android:title="Intent Demo" /> </PreferenceCategory> - <PreferenceCategory android:title="OpenPGP Provider" > + <PreferenceCategory android:title="OpenPGP Provider API"> <org.openintents.openpgp.util.OpenPgpListPreference android:key="openpgp_provider_list" android:title="Select OpenPGP Provider!" /> <Preference android:key="openpgp_provider_demo" - android:title="OpenPGP Provider" /> + android:title="OpenPGP Provider Demo" /> </PreferenceCategory> </PreferenceScreen>
\ No newline at end of file diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java index 987c8c8fc..f1f326fca 100644 --- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java +++ b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java @@ -21,6 +21,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.ResolveInfo; +import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.preference.DialogPreference; import android.util.AttributeSet; @@ -161,6 +162,16 @@ public class OpenPgpListPreference extends DialogPreference { return getEntryByValue(mSelectedPackage); } + @Override + protected Object onGetDefaultValue(TypedArray a, int index) { + return a.getString(index); + } + + @Override + protected void onSetInitialValue(boolean restoreValue, Object defaultValue) { + setValue(restoreValue ? getPersistedString(mSelectedPackage) : (String) defaultValue); + } + public String getEntryByValue(String packageName) { for (OpenPgpProviderEntry app : mProviderList) { if (app.packageName.equals(packageName)) { |