diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-03-02 18:09:00 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-03-02 18:09:00 +0100 |
commit | 23464e7a893492a853c7b077d6eb7779c34817b0 (patch) | |
tree | 274cc8887c059c73de4b9baa0b586b0daa87119f /OpenKeychain/src/main/java/org | |
parent | 817afffecc5454e7a185a85c4f9dcdc11fb9cd32 (diff) | |
download | open-keychain-23464e7a893492a853c7b077d6eb7779c34817b0.tar.gz open-keychain-23464e7a893492a853c7b077d6eb7779c34817b0.tar.bz2 open-keychain-23464e7a893492a853c7b077d6eb7779c34817b0.zip |
some cleanup in ViewKey*
Diffstat (limited to 'OpenKeychain/src/main/java/org')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java | 19 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java | 19 |
2 files changed, 20 insertions, 18 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java index 9bcad36c5..58596f9e3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java @@ -34,7 +34,6 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment; import org.sufficientlysecure.keychain.util.Log; @@ -143,16 +142,14 @@ public class ViewKeyFragment extends LoaderFragment implements private void loadData(Uri dataUri) { mDataUri = dataUri; - Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); + Log.i(Constants.TAG, "mDataUri: " + mDataUri); // Prepare the loaders. Either re-connect with an existing ones, // or start new ones. + // TODO Is this loader the same as the one in the activity? getLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); } - // don't show revoked user ids here, irrelevant for average users - public static final String USER_IDS_WHERE = UserPackets.IS_REVOKED + " = 0"; - public Loader<Cursor> onCreateLoader(int id, Bundle args) { setContentShown(false); @@ -161,11 +158,8 @@ public class ViewKeyFragment extends LoaderFragment implements Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri); return new CursorLoader(getActivity(), baseUri, UNIFIED_PROJECTION, null, null, null); } - case LOADER_ID_USER_IDS: { - Uri baseUri = UserPackets.buildUserIdsUri(mDataUri); - return new CursorLoader(getActivity(), baseUri, - UserIdsAdapter.USER_IDS_PROJECTION, USER_IDS_WHERE, null, null); - } + case LOADER_ID_USER_IDS: + return UserIdsAdapter.yo(getActivity(), mDataUri); default: return null; @@ -187,11 +181,6 @@ public class ViewKeyFragment extends LoaderFragment implements if (data.moveToFirst()) { mIsSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0; - boolean hasEncrypt = data.getInt(INDEX_HAS_ENCRYPT) != 0; - boolean isRevoked = data.getInt(INDEX_IS_REVOKED) > 0; - boolean isExpired = !data.isNull(INDEX_EXPIRY) - && new Date(data.getLong(INDEX_EXPIRY) * 1000).before(new Date()); - boolean isVerified = data.getInt(INDEX_VERIFIED) > 0; // load user ids after we know if it's a secret key mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0, !mIsSecret, null); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java index bba59d939..ee72dac5b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java @@ -1,5 +1,6 @@ /* - * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de> + * Copyright (C) 2014-2015 Dominik Schürmann <dominik@dominikschuermann.de> + * Copyright (C) 2015 Vincent Breitmoser <v.breitmoser@mugenguild.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,9 +18,12 @@ package org.sufficientlysecure.keychain.ui.adapter; +import android.app.Activity; import android.content.Context; import android.database.Cursor; import android.graphics.Typeface; +import android.net.Uri; +import android.support.v4.content.CursorLoader; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -29,6 +33,7 @@ import android.widget.TextView; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.provider.KeychainContract.Certs; +import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; import org.sufficientlysecure.keychain.service.SaveKeyringParcel; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; @@ -173,8 +178,16 @@ public class UserIdsAdapter extends UserAttributesAdapter { @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { - View view = mInflater.inflate(R.layout.view_key_adv_user_id_item, null); - return view; + return mInflater.inflate(R.layout.view_key_adv_user_id_item, null); + } + + // don't show revoked user ids, irrelevant for average users + public static final String USER_IDS_WHERE = UserPackets.IS_REVOKED + " = 0"; + + public static CursorLoader yo (Activity activity, Uri dataUri) { + Uri baseUri = UserPackets.buildUserIdsUri(dataUri); + return new CursorLoader(activity, baseUri, + UserIdsAdapter.USER_IDS_PROJECTION, USER_IDS_WHERE, null, null); } } |