aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-05-14 16:02:28 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-05-14 16:02:28 +0200
commit2f95100d88954db389cba8e615390795d121c1c8 (patch)
tree1bf4ffb29bb83fac33ba2ed7c84fb1d6a8af2bd4 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote
parent90ac60b6db0637fbefbce5cb2cd80a64f5bb708d (diff)
parent638554f2560b3c5fd36ca9b4ba205cb5a999b84b (diff)
downloadopen-keychain-2f95100d88954db389cba8e615390795d121c1c8.tar.gz
open-keychain-2f95100d88954db389cba8e615390795d121c1c8.tar.bz2
open-keychain-2f95100d88954db389cba8e615390795d121c1c8.zip
Merge remote-tracking branch 'origin/master' into wrapped-key-ring
Conflicts: OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewCertActivity.java OpenKeychain/src/main/res/values/strings.xml
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java43
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java28
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java4
3 files changed, 55 insertions, 20 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
index 8a247a11b..58aa2ece8 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
@@ -42,6 +42,7 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.remote.ui.RemoteServiceActivity;
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
import org.sufficientlysecure.keychain.ui.ImportKeysActivity;
+import org.sufficientlysecure.keychain.ui.ViewKeyActivity;
import org.sufficientlysecure.keychain.util.InputData;
import org.sufficientlysecure.keychain.util.Log;
@@ -69,19 +70,25 @@ public class OpenPgpService extends RemoteService {
for (String email : encryptionUserIds) {
Uri uri = KeyRings.buildUnifiedKeyRingsFindByEmailUri(email);
- Cursor cur = getContentResolver().query(uri, null, null, null, null);
- if (cur.moveToFirst()) {
- long id = cur.getLong(cur.getColumnIndex(KeyRings.MASTER_KEY_ID));
- keyIds.add(id);
- } else {
- missingUserIdsCheck = true;
- missingUserIds.add(email);
- Log.d(Constants.TAG, "user id missing");
- }
- if (cur.moveToNext()) {
- duplicateUserIdsCheck = true;
- duplicateUserIds.add(email);
- Log.d(Constants.TAG, "more than one user id with the same email");
+ Cursor cursor = getContentResolver().query(uri, null, null, null, null);
+ try {
+ if (cursor != null && cursor.moveToFirst()) {
+ long id = cursor.getLong(cursor.getColumnIndex(KeyRings.MASTER_KEY_ID));
+ keyIds.add(id);
+ } else {
+ missingUserIdsCheck = true;
+ missingUserIds.add(email);
+ Log.d(Constants.TAG, "user id missing");
+ }
+ if (cursor != null && cursor.moveToNext()) {
+ duplicateUserIdsCheck = true;
+ duplicateUserIds.add(email);
+ Log.d(Constants.TAG, "more than one user id with the same email");
+ }
+ } finally {
+ if (cursor != null) {
+ cursor.close();
+ }
}
}
@@ -417,7 +424,15 @@ public class OpenPgpService extends RemoteService {
Intent result = new Intent();
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
- // TODO: also return PendingIntent that opens the key view activity
+ // also return PendingIntent that opens the key view activity
+ Intent intent = new Intent(getBaseContext(), ViewKeyActivity.class);
+ intent.setData(KeyRings.buildGenericKeyRingUri(Long.toString(masterKeyId)));
+
+ PendingIntent pi = PendingIntent.getActivity(getBaseContext(), 0,
+ intent,
+ PendingIntent.FLAG_CANCEL_CURRENT);
+
+ result.putExtra(OpenPgpApi.RESULT_INTENT, pi);
return result;
} catch (ProviderHelper.NotFoundException e) {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java
index c6637c058..8df341f9e 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java
@@ -40,6 +40,9 @@ public class AppSettingsActivity extends ActionBarActivity {
private AppSettingsFragment mSettingsFragment;
private AccountsListFragment mAccountsListFragment;
+ // model
+ AppSettings mAppSettings;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -80,22 +83,39 @@ public class AppSettingsActivity extends ActionBarActivity {
case R.id.menu_api_settings_revoke:
revokeAccess();
return true;
+ case R.id.menu_api_settings_start:
+ startApp();
+ return true;
}
return super.onOptionsItemSelected(item);
}
+ private void startApp() {
+ Intent i;
+ PackageManager manager = getPackageManager();
+ try {
+ i = manager.getLaunchIntentForPackage(mAppSettings.getPackageName());
+ if (i == null)
+ throw new PackageManager.NameNotFoundException();
+ i.addCategory(Intent.CATEGORY_LAUNCHER);
+ startActivity(i);
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(Constants.TAG, "startApp", e);
+ }
+ }
+
private void loadData(Bundle savedInstanceState, Uri appUri) {
- AppSettings settings = new ProviderHelper(this).getApiAppSettings(appUri);
- mSettingsFragment.setAppSettings(settings);
+ mAppSettings = new ProviderHelper(this).getApiAppSettings(appUri);
+ mSettingsFragment.setAppSettings(mAppSettings);
String appName;
PackageManager pm = getPackageManager();
try {
- ApplicationInfo ai = pm.getApplicationInfo(settings.getPackageName(), 0);
+ ApplicationInfo ai = pm.getApplicationInfo(mAppSettings.getPackageName(), 0);
appName = (String) pm.getApplicationLabel(ai);
} catch (PackageManager.NameNotFoundException e) {
// fallback
- appName = settings.getPackageName();
+ appName = mAppSettings.getPackageName();
}
setTitle(appName);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java
index 2fd1ad3b5..d0b958844 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java
@@ -250,7 +250,7 @@ public class RemoteServiceActivity extends ActionBarActivity {
// set text on view
HtmlTextView textView = (HtmlTextView) findViewById(R.id.api_select_pub_keys_text);
- textView.setHtmlFromString(text);
+ textView.setHtmlFromString(text, true);
/* Load select pub keys fragment */
// Check that the activity is using the layout version with
@@ -292,7 +292,7 @@ public class RemoteServiceActivity extends ActionBarActivity {
// set text on view
HtmlTextView textView = (HtmlTextView) findViewById(R.id.api_app_error_message_text);
- textView.setHtmlFromString(text);
+ textView.setHtmlFromString(text, true);
} else {
Log.e(Constants.TAG, "Action does not exist!");
setResult(RESULT_CANCELED);