Merge branch 'master' of github.com:open-keychain/open-keychain
This commit is contained in:
@@ -25,7 +25,6 @@ import android.net.Uri;
|
||||
import android.os.IBinder;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.openintents.openpgp.IOpenPgpService;
|
||||
@@ -34,13 +33,15 @@ import org.openintents.openpgp.OpenPgpError;
|
||||
import org.openintents.openpgp.OpenPgpMetadata;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.openintents.openpgp.util.OpenPgpApi;
|
||||
import org.spongycastle.bcpg.ArmoredOutputStream;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogEntryParcel;
|
||||
import org.sufficientlysecure.keychain.operations.results.PgpSignEncryptResult;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpSignEncryptInputParcel;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpSignEncryptOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
@@ -684,16 +685,47 @@ public class OpenPgpService extends RemoteService {
|
||||
|
||||
}
|
||||
|
||||
private Intent getKeyImpl(Intent data) {
|
||||
private Intent getKeyImpl(Intent data, ParcelFileDescriptor output) {
|
||||
try {
|
||||
long masterKeyId = data.getLongExtra(OpenPgpApi.EXTRA_KEY_ID, 0);
|
||||
|
||||
// output is optional, for getting the key
|
||||
OutputStream outputStream =
|
||||
(output != null) ? new ParcelFileDescriptor.AutoCloseOutputStream(output) : null;
|
||||
|
||||
try {
|
||||
// try to find key, throws NotFoundException if not in db!
|
||||
mProviderHelper.getCanonicalizedPublicKeyRing(masterKeyId);
|
||||
CanonicalizedPublicKeyRing keyRing =
|
||||
mProviderHelper.getCanonicalizedPublicKeyRing(masterKeyId);
|
||||
|
||||
Intent result = new Intent();
|
||||
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||
|
||||
// return public key if requested by defining a output stream
|
||||
if (outputStream != null) {
|
||||
boolean requestAsciiArmor =
|
||||
data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, false);
|
||||
|
||||
ArmoredOutputStream arOutStream = null;
|
||||
try {
|
||||
if (requestAsciiArmor) {
|
||||
arOutStream = new ArmoredOutputStream(outputStream);
|
||||
keyRing.encode(arOutStream);
|
||||
} else {
|
||||
keyRing.encode(outputStream);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (arOutStream != null) {
|
||||
arOutStream.close();
|
||||
}
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(Constants.TAG, "IOException when closing OutputStream", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// also return PendingIntent that opens the key view activity
|
||||
result.putExtra(OpenPgpApi.RESULT_INTENT, getShowKeyPendingIntent(masterKeyId));
|
||||
|
||||
@@ -890,7 +922,7 @@ public class OpenPgpService extends RemoteService {
|
||||
return getKeyIdsImpl(data);
|
||||
}
|
||||
case OpenPgpApi.ACTION_GET_KEY: {
|
||||
return getKeyImpl(data);
|
||||
return getKeyImpl(data, output);
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
|
||||
@@ -54,14 +54,8 @@ import java.util.List;
|
||||
|
||||
public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
|
||||
public static final String ACTION_PREFS_CLOUD = "org.sufficientlysecure.keychain.ui.PREFS_CLOUD";
|
||||
public static final String ACTION_PREFS_ADV = "org.sufficientlysecure.keychain.ui.PREFS_ADV";
|
||||
public static final String ACTION_PREFS_PROXY = "org.sufficientlysecure.keychain.ui.PREFS_PROXY";
|
||||
public static final String ACTION_PREFS_GUI = "org.sufficientlysecure.keychain.ui.PREFS_GUI";
|
||||
|
||||
public static final int REQUEST_CODE_KEYSERVER_PREF = 0x00007005;
|
||||
|
||||
private PreferenceScreen mKeyServerPreference = null;
|
||||
private static Preferences sPreferences;
|
||||
private ThemeChanger mThemeChanger;
|
||||
|
||||
@@ -74,49 +68,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setupToolbar();
|
||||
|
||||
String action = getIntent().getAction();
|
||||
|
||||
if (ACTION_PREFS_CLOUD.equals(action)) {
|
||||
addPreferencesFromResource(R.xml.cloud_search_prefs);
|
||||
|
||||
mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS);
|
||||
mKeyServerPreference.setSummary(keyserverSummary(this));
|
||||
mKeyServerPreference
|
||||
.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent intent = new Intent(SettingsActivity.this,
|
||||
SettingsKeyServerActivity.class);
|
||||
intent.putExtra(SettingsKeyServerActivity.EXTRA_KEY_SERVERS,
|
||||
sPreferences.getKeyServers());
|
||||
startActivityForResult(intent, REQUEST_CODE_KEYSERVER_PREF);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
initializeSearchKeyserver(
|
||||
(SwitchPreference) findPreference(Constants.Pref.SEARCH_KEYSERVER)
|
||||
);
|
||||
initializeSearchKeybase(
|
||||
(SwitchPreference) findPreference(Constants.Pref.SEARCH_KEYBASE)
|
||||
);
|
||||
|
||||
} else if (ACTION_PREFS_ADV.equals(action)) {
|
||||
addPreferencesFromResource(R.xml.passphrase_preferences);
|
||||
|
||||
initializePassphraseCacheSubs(
|
||||
(CheckBoxPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_SUBS));
|
||||
|
||||
initializePassphraseCacheTtl(
|
||||
(IntegerListPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_TTL));
|
||||
|
||||
initializeUseNumKeypadForYubiKeyPin(
|
||||
(CheckBoxPreference) findPreference(Constants.Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN));
|
||||
|
||||
} else if (ACTION_PREFS_GUI.equals(action)) {
|
||||
addPreferencesFromResource(R.xml.gui_preferences);
|
||||
|
||||
initializeTheme((ListPreference) findPreference(Constants.Pref.THEME));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -447,23 +398,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This fragment shows gui preferences.
|
||||
*/
|
||||
public static class GuiPrefsFragment extends PreferenceFragment {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
// Load the preferences from an XML resource
|
||||
addPreferencesFromResource(R.xml.gui_preferences);
|
||||
|
||||
initializeTheme((ListPreference) findPreference(Constants.Pref.THEME));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This fragment shows the keyserver/contacts sync preferences
|
||||
*/
|
||||
@@ -576,7 +510,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
return PassphrasePrefsFragment.class.getName().equals(fragmentName)
|
||||
|| CloudSearchPrefsFragment.class.getName().equals(fragmentName)
|
||||
|| ProxyPrefsFragment.class.getName().equals(fragmentName)
|
||||
|| GuiPrefsFragment.class.getName().equals(fragmentName)
|
||||
|| SyncPrefsFragment.class.getName().equals(fragmentName)
|
||||
|| ExperimentalPrefsFragment.class.getName().equals(fragmentName)
|
||||
|| super.isValidFragment(fragmentName);
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ListPreference
|
||||
android:persistent="false"
|
||||
android:key="theme"
|
||||
android:title="@string/label_theme"
|
||||
android:entries="@array/theme_entries"
|
||||
android:entryValues="@array/theme_values"
|
||||
android:dialogTitle="@string/label_theme" />
|
||||
|
||||
</PreferenceScreen>
|
||||
Reference in New Issue
Block a user