fix bug in UploadKeyActivity, minor work on uri handling

This commit is contained in:
Vincent Breitmoser 2014-07-31 23:07:20 +02:00
parent c5ce794ef7
commit caad5d1fc1
3 changed files with 21 additions and 25 deletions

View File

@ -233,6 +233,12 @@ public class ProviderHelper {
}
private KeyRing getCanonicalizedKeyRing(Uri queryUri, boolean secret) throws NotFoundException {
// if this is not a unified query, we /will/ get hard to trace errors below!
if ( ! queryUri.getPath().contains("unified")) {
throw new RuntimeException("only unified uris can be passed to getCanonicalizedKeyRing!");
}
Cursor cursor = mContentResolver.query(queryUri,
new String[]{
// we pick from cache only information that is not easily available from keyrings

View File

@ -36,6 +36,7 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.Preferences;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
import org.sufficientlysecure.keychain.util.Log;
@ -92,7 +93,7 @@ public class UploadKeyActivity extends ActionBarActivity {
intent.setAction(KeychainIntentService.ACTION_UPLOAD_KEYRING);
// set data uri as path to keyring
Uri blobUri = KeychainContract.KeyRingData.buildPublicKeyRingUri(mDataUri);
Uri blobUri = KeyRings.buildUnifiedKeyRingUri(mDataUri);
intent.setData(blobUri);
// fill values for this action

View File

@ -145,20 +145,27 @@ public class ViewKeyActivity extends ActionBarActivity implements
switchToTab = intent.getExtras().getInt(EXTRA_SELECTED_TAB);
}
Uri dataUri = getDataUri();
if (dataUri == null) {
Log.e(Constants.TAG, "Data missing. Should be Uri of key!");
mDataUri = getIntent().getData();
if (mDataUri == null) {
Log.e(Constants.TAG, "Data missing. Should be uri of key!");
finish();
return;
}
if (mDataUri.getHost().equals(ContactsContract.AUTHORITY)) {
mDataUri = ContactHelper.dataUriFromContactUri(this, mDataUri);
}
loadData(dataUri);
Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString());
initNfc(dataUri);
// Prepare the loaders. Either re-connect with an existing ones,
// or start new ones.
getSupportLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this);
initNfc(mDataUri);
mShowAdvancedTabs = false;
initTabs(dataUri);
initTabs(mDataUri);
// switch to tab selected by extra
mViewPager.setCurrentItem(switchToTab);
@ -235,24 +242,6 @@ public class ViewKeyActivity extends ActionBarActivity implements
mSlidingTabLayout.setViewPager(mViewPager);
}
private Uri getDataUri() {
Uri dataUri = getIntent().getData();
if (dataUri != null && dataUri.getHost().equals(ContactsContract.AUTHORITY)) {
dataUri = ContactHelper.dataUriFromContactUri(this, dataUri);
}
return dataUri;
}
private void loadData(Uri dataUri) {
mDataUri = dataUri;
Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString());
// Prepare the loaders. Either re-connect with an existing ones,
// or start new ones.
getSupportLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);