<string name="no_certificates">Keine Zertifikate</string>
<string name="system_tab">System</string>
<string name="user_tab">Benutzer</string>
+ <string name="local_tab">Importiert</string>
<!-- VPN state fragment -->
<string name="state_label">Status:</string>
<string name="no_certificates">Brak certyfikatów</string>
<string name="system_tab">System</string>
<string name="user_tab">Użytkownik</string>
+ <string name="local_tab">Imported</string>
<!-- VPN state fragment -->
<string name="state_label">Status:</string>
<string name="no_certificates">Нет доступных сертификатов</string>
<string name="system_tab">Система</string>
<string name="user_tab">Пользователь</string>
+ <string name="local_tab">Imported</string>
<!-- VPN state fragment -->
<string name="state_label">Статус:</string>
<string name="no_certificates">Немає сертифікатів</string>
<string name="system_tab">Система</string>
<string name="user_tab">Користувач</string>
+ <string name="local_tab">Imported</string>
<!-- VPN state fragment -->
<string name="state_label">Статус:</string>
<string name="no_certificates">No certificates</string>
<string name="system_tab">System</string>
<string name="user_tab">User</string>
+ <string name="local_tab">Imported</string>
<!-- VPN state fragment -->
<string name="state_label">Status:</string>
/*
- * Copyright (C) 2012 Tobias Brunner
+ * Copyright (C) 2012-2014 Tobias Brunner
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
public class TrustedCertificateListFragment extends ListFragment implements LoaderCallbacks<List<TrustedCertificateEntry>>, OnQueryTextListener
{
+ public static final String EXTRA_CERTIFICATE_SOURCE = "certificate_source";
private OnTrustedCertificateSelectedListener mListener;
private TrustedCertificateAdapter mAdapter;
- private boolean mUser;
+ private TrustedCertificateSource mSource = TrustedCertificateSource.SYSTEM;
/**
* The activity containing this fragment should implement this interface
setListShown(false);
- /* non empty arguments mean we list user certificate */
- mUser = getArguments() != null;
+ Bundle arguments = getArguments();
+ if (arguments != null)
+ {
+ mSource = (TrustedCertificateSource)arguments.getSerializable(EXTRA_CERTIFICATE_SOURCE);
+ }
getLoaderManager().initLoader(0, null, this);
}
@Override
public Loader<List<TrustedCertificateEntry>> onCreateLoader(int id, Bundle args)
{ /* we don't need the id as we have only one loader */
- return new CertificateListLoader(getActivity(), mUser);
+ return new CertificateListLoader(getActivity(), mSource);
}
@Override
public static class CertificateListLoader extends AsyncTaskLoader<List<TrustedCertificateEntry>>
{
private List<TrustedCertificateEntry> mData;
- private final boolean mUser;
+ private final TrustedCertificateSource mSource;
- public CertificateListLoader(Context context, boolean user)
+ public CertificateListLoader(Context context, TrustedCertificateSource source)
{
super(context);
- mUser = user;
+ mSource = source;
}
@Override
public List<TrustedCertificateEntry> loadInBackground()
{
TrustedCertificateManager certman = TrustedCertificateManager.getInstance().load();
- Hashtable<String,X509Certificate> certificates;
+ Hashtable<String,X509Certificate> certificates = certman.getCACertificates(mSource);
List<TrustedCertificateEntry> selected;
- certificates = mUser ? certman.getCACertificates(TrustedCertificateSource.USER) : certman.getCACertificates(TrustedCertificateSource.SYSTEM);
selected = new ArrayList<TrustedCertificateEntry>();
for (Entry<String, X509Certificate> entry : certificates.entrySet())
{
import org.strongswan.android.R;
import org.strongswan.android.data.VpnProfileDataSource;
+import org.strongswan.android.logic.TrustedCertificateManager.TrustedCertificateSource;
import org.strongswan.android.security.TrustedCertificateEntry;
import android.app.ActionBar;
actionBar.addTab(actionBar
.newTab()
.setText(R.string.system_tab)
- .setTabListener(new TrustedCertificatesTabListener(this, "system", false)));
+ .setTabListener(new TrustedCertificatesTabListener(this, "system", TrustedCertificateSource.SYSTEM)));
actionBar.addTab(actionBar
.newTab()
.setText(R.string.user_tab)
- .setTabListener(new TrustedCertificatesTabListener(this, "user", true)));
+ .setTabListener(new TrustedCertificatesTabListener(this, "user", TrustedCertificateSource.USER)));
+ actionBar.addTab(actionBar
+ .newTab()
+ .setText(R.string.local_tab)
+ .setTabListener(new TrustedCertificatesTabListener(this, "local", TrustedCertificateSource.LOCAL)));
if (savedInstanceState != null)
{
public static class TrustedCertificatesTabListener implements ActionBar.TabListener
{
private final String mTag;
- private final boolean mUser;
+ private final TrustedCertificateSource mSource;
private Fragment mFragment;
- public TrustedCertificatesTabListener(Activity activity, String tag, boolean user)
+ public TrustedCertificatesTabListener(Activity activity, String tag, TrustedCertificateSource source)
{
mTag = tag;
- mUser = user;
+ mSource = source;
/* check to see if we already have a fragment for this tab, probably
* from a previously saved state. if so, deactivate it, because the
* initial state is that no tab is shown */
if (mFragment == null)
{
mFragment = new TrustedCertificateListFragment();
- if (mUser)
- { /* use non empty arguments to indicate this */
- mFragment.setArguments(new Bundle());
- }
+ Bundle args = new Bundle();
+ args.putSerializable(TrustedCertificateListFragment.EXTRA_CERTIFICATE_SOURCE, mSource);
+ mFragment.setArguments(args);
ft.add(android.R.id.content, mFragment, mTag);
}
else