From 6fdae001cc5ee742cceaeea82c75f0e314a3449f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 8 Sep 2013 16:08:36 +0200 Subject: Make select fragments more reusable --- .../keychain/ui/SelectSecretKeyFragment.java | 31 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java') diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java index 74393fa91..17539fe72 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Dominik Schürmann + * Copyright (C) 2012-2013 Dominik Schürmann * Copyright (C) 2010 Thialfihar * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -47,6 +47,31 @@ public class SelectSecretKeyFragment extends SherlockListFragment implements private SelectSecretKeyActivity mActivity; private SelectKeyCursorAdapter mAdapter; private ListView mListView; + + private boolean mFilterCertify; + + private static final String ARG_FILTER_CERTIFY = "filter_certify"; + + /** + * Creates new instance of this fragment + */ + public static SelectSecretKeyFragment newInstance(boolean filterCertify) { + SelectSecretKeyFragment frag = new SelectSecretKeyFragment(); + Bundle args = new Bundle(); + + args.putBoolean(ARG_FILTER_CERTIFY, filterCertify); + + frag.setArguments(args); + + return frag; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + mFilterCertify = getArguments().getBoolean(ARG_FILTER_CERTIFY); + } /** * Define Adapter and Loader on create of Activity @@ -92,8 +117,8 @@ public class SelectSecretKeyFragment extends SherlockListFragment implements Uri baseUri = KeyRings.buildSecretKeyRingsUri(); String CapFilter = null; - if (((SelectSecretKeyActivity)getActivity()).filterCertify == true) { - CapFilter = "(cert>0)"; + if (mFilterCertify) { + CapFilter = "(cert > 0)"; } // These are the rows that we will retrieve. -- cgit v1.2.3