diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org')
4 files changed, 32 insertions, 44 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java index e1c2013ea..d5658586d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java @@ -23,7 +23,6 @@ import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import android.support.v4.app.Fragment; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; @@ -46,7 +45,7 @@ import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter; import se.emilsjolander.stickylistheaders.StickyListHeadersListView; -public class ViewKeyCertsFragment extends Fragment +public class ViewKeyCertsFragment extends LoaderFragment implements LoaderManager.LoaderCallbacks<Cursor>, AdapterView.OnItemClickListener { // These are the rows that we will retrieve. @@ -79,18 +78,19 @@ public class ViewKeyCertsFragment extends Fragment private static final int LOADER_ID = 4; @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.view_key_certs_fragment, container, false); + public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { + View root = super.onCreateView(inflater, superContainer, savedInstanceState); + View view = inflater.inflate(R.layout.view_key_certs_fragment, getContainer()); - return view; + mStickyList = (StickyListHeadersListView) view.findViewById(R.id.list); + + return root; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - mStickyList = (StickyListHeadersListView) getActivity().findViewById(R.id.list); - if (!getArguments().containsKey(ARG_DATA_URI)) { Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); getActivity().finish(); @@ -120,6 +120,7 @@ public class ViewKeyCertsFragment extends Fragment @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { + setContentShown(false); // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. return new CursorLoader(getActivity(), mDataUri, PROJECTION, null, null, SORT_ORDER); @@ -132,6 +133,8 @@ public class ViewKeyCertsFragment extends Fragment mAdapter.swapCursor(data); mStickyList.setAdapter(mAdapter); + + setContentShown(true); } /** diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyKeysFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyKeysFragment.java index 9ab6878d0..fb228f032 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyKeysFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyKeysFragment.java @@ -44,12 +44,11 @@ import org.sufficientlysecure.keychain.util.Log; import java.util.Date; -public class ViewKeyKeysFragment extends Fragment implements +public class ViewKeyKeysFragment extends LoaderFragment implements LoaderManager.LoaderCallbacks<Cursor> { public static final String ARG_DATA_URI = "uri"; - private LinearLayout mContainer; private ListView mKeys; private ViewKeyKeysAdapter mKeysAdapter; @@ -57,13 +56,13 @@ public class ViewKeyKeysFragment extends Fragment implements private Uri mDataUri; @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.view_key_keys_fragment, container, false); + public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { + View root = super.onCreateView(inflater, superContainer, savedInstanceState); + View view = inflater.inflate(R.layout.view_key_keys_fragment, getContainer()); - mContainer = (LinearLayout) view.findViewById(R.id.container); mKeys = (ListView) view.findViewById(R.id.keys); - return view; + return root; } @Override @@ -81,9 +80,6 @@ public class ViewKeyKeysFragment extends Fragment implements } private void loadData(Uri dataUri) { - getActivity().setProgressBarIndeterminateVisibility(true); - mContainer.setVisibility(View.GONE); - mDataUri = dataUri; Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); @@ -104,6 +100,7 @@ public class ViewKeyKeysFragment extends Fragment implements }; public Loader<Cursor> onCreateLoader(int id, Bundle args) { + setContentShown(false); Uri baseUri = Keys.buildKeysUri(mDataUri); return new CursorLoader(getActivity(), baseUri, KEYS_PROJECTION, null, null, null); } @@ -117,8 +114,7 @@ public class ViewKeyKeysFragment extends Fragment implements // old cursor once we return.) mKeysAdapter.swapCursor(data); - getActivity().setProgressBarIndeterminateVisibility(false); - mContainer.setVisibility(View.VISIBLE); + setContentShown(true); } /** diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index b30c9aaec..026417776 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -21,15 +21,12 @@ import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; -import android.support.v4.app.Fragment; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; -import android.text.format.DateFormat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.LinearLayout; import android.widget.ListView; import com.devspark.appmsg.AppMsg; @@ -37,7 +34,6 @@ import com.devspark.appmsg.AppMsg; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R;import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; -import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.adapter.ViewKeyUserIdsAdapter; @@ -45,12 +41,11 @@ import org.sufficientlysecure.keychain.util.Log; import java.util.Date; -public class ViewKeyMainFragment extends Fragment implements +public class ViewKeyMainFragment extends LoaderFragment implements LoaderManager.LoaderCallbacks<Cursor> { public static final String ARG_DATA_URI = "uri"; - private LinearLayout mContainer; private View mActionEdit; private View mActionEditDivider; private View mActionEncrypt; @@ -70,10 +65,10 @@ public class ViewKeyMainFragment extends Fragment implements private Uri mDataUri; @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.view_key_main_fragment, container, false); + public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { + View root = super.onCreateView(inflater, superContainer, savedInstanceState); + View view = inflater.inflate(R.layout.view_key_main_fragment, getContainer()); - mContainer = (LinearLayout) view.findViewById(R.id.container); mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids); mActionEdit = view.findViewById(R.id.view_key_action_edit); mActionEditDivider = view.findViewById(R.id.view_key_action_edit_divider); @@ -81,7 +76,7 @@ public class ViewKeyMainFragment extends Fragment implements mActionCertify = view.findViewById(R.id.view_key_action_certify); mActionCertifyDivider = view.findViewById(R.id.view_key_action_certify_divider); - return view; + return root; } @Override @@ -99,9 +94,6 @@ public class ViewKeyMainFragment extends Fragment implements } private void loadData(Uri dataUri) { - getActivity().setProgressBarIndeterminateVisibility(true); - mContainer.setVisibility(View.GONE); - mDataUri = dataUri; Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); @@ -143,6 +135,8 @@ public class ViewKeyMainFragment extends Fragment implements static final int INDEX_UNIFIED_HAS_ENCRYPT = 5; public Loader<Cursor> onCreateLoader(int id, Bundle args) { + setContentShown(false); + switch (id) { case LOADER_ID_UNIFIED: { Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri); @@ -219,8 +213,7 @@ public class ViewKeyMainFragment extends Fragment implements break; } - getActivity().setProgressBarIndeterminateVisibility(false); - mContainer.setVisibility(View.VISIBLE); + setContentShown(true); } /** diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java index 1a76f5eed..b3655133d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java @@ -53,12 +53,11 @@ import org.sufficientlysecure.keychain.util.QrCodeUtils; import java.io.IOException; -public class ViewKeyShareFragment extends Fragment implements +public class ViewKeyShareFragment extends LoaderFragment implements LoaderManager.LoaderCallbacks<Cursor> { public static final String ARG_DATA_URI = "uri"; - private LinearLayout mContainer; private TextView mFingerprint; private ImageView mFingerprintQrCode; private View mFingerprintShareButton; @@ -77,12 +76,12 @@ public class ViewKeyShareFragment extends Fragment implements private Uri mDataUri; @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.view_key_share_fragment, container, false); + public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { + View root = super.onCreateView(inflater, superContainer, savedInstanceState); + View view = inflater.inflate(R.layout.view_key_share_fragment, getContainer()); mProviderHelper = new ProviderHelper(ViewKeyShareFragment.this.getActivity()); - mContainer = (LinearLayout) view.findViewById(R.id.container); mFingerprint = (TextView) view.findViewById(R.id.view_key_fingerprint); mFingerprintQrCode = (ImageView) view.findViewById(R.id.view_key_fingerprint_qr_code_image); mFingerprintShareButton = view.findViewById(R.id.view_key_action_fingerprint_share); @@ -142,7 +141,7 @@ public class ViewKeyShareFragment extends Fragment implements } }); - return view; + return root; } private void share(Uri dataUri, ProviderHelper providerHelper, boolean fingerprintOnly, @@ -232,9 +231,6 @@ public class ViewKeyShareFragment extends Fragment implements } private void loadData(Uri dataUri) { - getActivity().setProgressBarIndeterminateVisibility(true); - mContainer.setVisibility(View.GONE); - mDataUri = dataUri; Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); @@ -260,6 +256,7 @@ public class ViewKeyShareFragment extends Fragment implements static final int INDEX_UNIFIED_EXPIRY = 8; public Loader<Cursor> onCreateLoader(int id, Bundle args) { + setContentShown(false); switch (id) { case LOADER_ID_UNIFIED: { Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri); @@ -299,8 +296,7 @@ public class ViewKeyShareFragment extends Fragment implements } } - getActivity().setProgressBarIndeterminateVisibility(false); - mContainer.setVisibility(View.VISIBLE); + setContentShown(true); } /** |