mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-26 00:48:51 -05:00
Merge pull request #619 from Valodim/loader-fragment
Introduce LoaderFragment
This commit is contained in:
commit
5a1120e791
@ -29,7 +29,6 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
@ -45,10 +44,8 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.AnimationUtils;
|
|
||||||
import android.widget.AbsListView.MultiChoiceModeListener;
|
import android.widget.AbsListView.MultiChoiceModeListener;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -78,18 +75,13 @@ import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
|||||||
* Public key list with sticky list headers. It does _not_ extend ListFragment because it uses
|
* Public key list with sticky list headers. It does _not_ extend ListFragment because it uses
|
||||||
* StickyListHeaders library which does not extend upon ListView.
|
* StickyListHeaders library which does not extend upon ListView.
|
||||||
*/
|
*/
|
||||||
public class KeyListFragment extends Fragment
|
public class KeyListFragment extends LoaderFragment
|
||||||
implements SearchView.OnQueryTextListener, AdapterView.OnItemClickListener,
|
implements SearchView.OnQueryTextListener, AdapterView.OnItemClickListener,
|
||||||
LoaderManager.LoaderCallbacks<Cursor> {
|
LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
private KeyListAdapter mAdapter;
|
private KeyListAdapter mAdapter;
|
||||||
private StickyListHeadersListView mStickyList;
|
private StickyListHeadersListView mStickyList;
|
||||||
|
|
||||||
// rebuild functionality of ListFragment, http://stackoverflow.com/a/12504097
|
|
||||||
boolean mListShown;
|
|
||||||
View mProgressContainer;
|
|
||||||
View mListContainer;
|
|
||||||
|
|
||||||
private String mCurQuery;
|
private String mCurQuery;
|
||||||
private SearchView mSearchView;
|
private SearchView mSearchView;
|
||||||
// empty list layout
|
// empty list layout
|
||||||
@ -101,14 +93,15 @@ public class KeyListFragment extends Fragment
|
|||||||
* Load custom layout with StickyListView from library
|
* Load custom layout with StickyListView from library
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) {
|
||||||
View root = inflater.inflate(R.layout.key_list_fragment, container, false);
|
View root = super.onCreateView(inflater, superContainer, savedInstanceState);
|
||||||
|
View view = inflater.inflate(R.layout.key_list_fragment, getContainer());
|
||||||
|
|
||||||
mStickyList = (StickyListHeadersListView) root.findViewById(R.id.key_list_list);
|
mStickyList = (StickyListHeadersListView) view.findViewById(R.id.key_list_list);
|
||||||
mStickyList.setOnItemClickListener(this);
|
mStickyList.setOnItemClickListener(this);
|
||||||
|
|
||||||
// empty view
|
// empty view
|
||||||
mButtonEmptyCreate = (BootstrapButton) root.findViewById(R.id.key_list_empty_button_create);
|
mButtonEmptyCreate = (BootstrapButton) view.findViewById(R.id.key_list_empty_button_create);
|
||||||
mButtonEmptyCreate.setOnClickListener(new OnClickListener() {
|
mButtonEmptyCreate.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -120,7 +113,7 @@ public class KeyListFragment extends Fragment
|
|||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mButtonEmptyImport = (BootstrapButton) root.findViewById(R.id.key_list_empty_button_import);
|
mButtonEmptyImport = (BootstrapButton) view.findViewById(R.id.key_list_empty_button_import);
|
||||||
mButtonEmptyImport.setOnClickListener(new OnClickListener() {
|
mButtonEmptyImport.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -131,11 +124,6 @@ public class KeyListFragment extends Fragment
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// rebuild functionality of ListFragment, http://stackoverflow.com/a/12504097
|
|
||||||
mListContainer = root.findViewById(R.id.key_list_list_container);
|
|
||||||
mProgressContainer = root.findViewById(R.id.key_list_progress_container);
|
|
||||||
mListShown = true;
|
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,9 +222,8 @@ public class KeyListFragment extends Fragment
|
|||||||
// We have a menu item to show in action bar.
|
// We have a menu item to show in action bar.
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
// NOTE: Not supported by StickyListHeader, but reimplemented here
|
|
||||||
// Start out with a progress indicator.
|
// Start out with a progress indicator.
|
||||||
setListShown(false);
|
setContentShown(false);
|
||||||
|
|
||||||
// Create an empty adapter we will use to display the loaded data.
|
// Create an empty adapter we will use to display the loaded data.
|
||||||
mAdapter = new KeyListAdapter(getActivity(), null, 0);
|
mAdapter = new KeyListAdapter(getActivity(), null, 0);
|
||||||
@ -298,12 +285,11 @@ public class KeyListFragment extends Fragment
|
|||||||
// this view is made visible if no data is available
|
// this view is made visible if no data is available
|
||||||
mStickyList.setEmptyView(getActivity().findViewById(R.id.key_list_empty));
|
mStickyList.setEmptyView(getActivity().findViewById(R.id.key_list_empty));
|
||||||
|
|
||||||
// NOTE: Not supported by StickyListHeader, but reimplemented here
|
|
||||||
// The list should now be shown.
|
// The list should now be shown.
|
||||||
if (isResumed()) {
|
if (isResumed()) {
|
||||||
setListShown(true);
|
setContentShown(true);
|
||||||
} else {
|
} else {
|
||||||
setListShownNoAnimation(true);
|
setContentShownNoAnimation(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,43 +404,6 @@ public class KeyListFragment extends Fragment
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rebuild functionality of ListFragment, http://stackoverflow.com/a/12504097
|
|
||||||
public void setListShown(boolean shown, boolean animate) {
|
|
||||||
if (mListShown == shown) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mListShown = shown;
|
|
||||||
if (shown) {
|
|
||||||
if (animate) {
|
|
||||||
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
|
|
||||||
getActivity(), android.R.anim.fade_out));
|
|
||||||
mListContainer.startAnimation(AnimationUtils.loadAnimation(
|
|
||||||
getActivity(), android.R.anim.fade_in));
|
|
||||||
}
|
|
||||||
mProgressContainer.setVisibility(View.GONE);
|
|
||||||
mListContainer.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
if (animate) {
|
|
||||||
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
|
|
||||||
getActivity(), android.R.anim.fade_in));
|
|
||||||
mListContainer.startAnimation(AnimationUtils.loadAnimation(
|
|
||||||
getActivity(), android.R.anim.fade_out));
|
|
||||||
}
|
|
||||||
mProgressContainer.setVisibility(View.VISIBLE);
|
|
||||||
mListContainer.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rebuild functionality of ListFragment, http://stackoverflow.com/a/12504097
|
|
||||||
public void setListShown(boolean shown) {
|
|
||||||
setListShown(shown, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// rebuild functionality of ListFragment, http://stackoverflow.com/a/12504097
|
|
||||||
public void setListShownNoAnimation(boolean shown) {
|
|
||||||
setListShown(shown, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements StickyListHeadersAdapter from library
|
* Implements StickyListHeadersAdapter from library
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,78 @@
|
|||||||
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.animation.AnimationUtils;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
|
||||||
|
/** This is a fragment helper class, which implements a generic
|
||||||
|
* progressbar/container view.
|
||||||
|
*
|
||||||
|
* To use it in a fragment, simply subclass, use onCreateView to create the
|
||||||
|
* layout's root view, and ues getContainer() as root view of your subclass.
|
||||||
|
* The layout shows a progress bar by default, and can be switched to the
|
||||||
|
* actual contents by calling setContentShown().
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class LoaderFragment extends Fragment {
|
||||||
|
private boolean mContentShown;
|
||||||
|
private View mProgressContainer;
|
||||||
|
private ViewGroup mContainer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
View root = inflater.inflate(R.layout.loader_layout, container, false);
|
||||||
|
|
||||||
|
mContentShown = true;
|
||||||
|
mContainer = (ViewGroup) root.findViewById(R.id.loader_container);
|
||||||
|
mProgressContainer = root.findViewById(R.id.loader_progress);
|
||||||
|
|
||||||
|
// content is not shown (by visibility statuses in the layout files)
|
||||||
|
mContentShown = false;
|
||||||
|
|
||||||
|
return root;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ViewGroup getContainer() {
|
||||||
|
return mContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContentShown(boolean shown, boolean animate) {
|
||||||
|
if (mContentShown == shown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mContentShown = shown;
|
||||||
|
if (shown) {
|
||||||
|
if (animate) {
|
||||||
|
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
|
||||||
|
getActivity(), android.R.anim.fade_out));
|
||||||
|
mContainer.startAnimation(AnimationUtils.loadAnimation(
|
||||||
|
getActivity(), android.R.anim.fade_in));
|
||||||
|
}
|
||||||
|
mProgressContainer.setVisibility(View.GONE);
|
||||||
|
mContainer.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
if (animate) {
|
||||||
|
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
|
||||||
|
getActivity(), android.R.anim.fade_in));
|
||||||
|
mContainer.startAnimation(AnimationUtils.loadAnimation(
|
||||||
|
getActivity(), android.R.anim.fade_out));
|
||||||
|
}
|
||||||
|
mProgressContainer.setVisibility(View.VISIBLE);
|
||||||
|
mContainer.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContentShown(boolean shown) {
|
||||||
|
setContentShown(shown, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContentShownNoAnimation(boolean shown) {
|
||||||
|
setContentShown(shown, false);
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,6 @@ import android.database.Cursor;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
@ -46,7 +45,7 @@ import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
|
|||||||
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
||||||
|
|
||||||
|
|
||||||
public class ViewKeyCertsFragment extends Fragment
|
public class ViewKeyCertsFragment extends LoaderFragment
|
||||||
implements LoaderManager.LoaderCallbacks<Cursor>, AdapterView.OnItemClickListener {
|
implements LoaderManager.LoaderCallbacks<Cursor>, AdapterView.OnItemClickListener {
|
||||||
|
|
||||||
// These are the rows that we will retrieve.
|
// These are the rows that we will retrieve.
|
||||||
@ -79,18 +78,19 @@ public class ViewKeyCertsFragment extends Fragment
|
|||||||
private static final int LOADER_ID = 4;
|
private static final int LOADER_ID = 4;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.view_key_certs_fragment, container, false);
|
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
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
mStickyList = (StickyListHeadersListView) getActivity().findViewById(R.id.list);
|
|
||||||
|
|
||||||
if (!getArguments().containsKey(ARG_DATA_URI)) {
|
if (!getArguments().containsKey(ARG_DATA_URI)) {
|
||||||
Log.e(Constants.TAG, "Data missing. Should be Uri of key!");
|
Log.e(Constants.TAG, "Data missing. Should be Uri of key!");
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
@ -120,6 +120,7 @@ public class ViewKeyCertsFragment extends Fragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
|
setContentShown(false);
|
||||||
// Now create and return a CursorLoader that will take care of
|
// Now create and return a CursorLoader that will take care of
|
||||||
// creating a Cursor for the data being displayed.
|
// creating a Cursor for the data being displayed.
|
||||||
return new CursorLoader(getActivity(), mDataUri, PROJECTION, null, null, SORT_ORDER);
|
return new CursorLoader(getActivity(), mDataUri, PROJECTION, null, null, SORT_ORDER);
|
||||||
@ -132,6 +133,8 @@ public class ViewKeyCertsFragment extends Fragment
|
|||||||
mAdapter.swapCursor(data);
|
mAdapter.swapCursor(data);
|
||||||
|
|
||||||
mStickyList.setAdapter(mAdapter);
|
mStickyList.setAdapter(mAdapter);
|
||||||
|
|
||||||
|
setContentShown(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,12 +44,11 @@ import org.sufficientlysecure.keychain.util.Log;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
public class ViewKeyKeysFragment extends Fragment implements
|
public class ViewKeyKeysFragment extends LoaderFragment implements
|
||||||
LoaderManager.LoaderCallbacks<Cursor> {
|
LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
public static final String ARG_DATA_URI = "uri";
|
public static final String ARG_DATA_URI = "uri";
|
||||||
|
|
||||||
private LinearLayout mContainer;
|
|
||||||
private ListView mKeys;
|
private ListView mKeys;
|
||||||
|
|
||||||
private ViewKeyKeysAdapter mKeysAdapter;
|
private ViewKeyKeysAdapter mKeysAdapter;
|
||||||
@ -57,13 +56,13 @@ public class ViewKeyKeysFragment extends Fragment implements
|
|||||||
private Uri mDataUri;
|
private Uri mDataUri;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.view_key_keys_fragment, container, false);
|
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);
|
mKeys = (ListView) view.findViewById(R.id.keys);
|
||||||
|
|
||||||
return view;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -81,9 +80,6 @@ public class ViewKeyKeysFragment extends Fragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadData(Uri dataUri) {
|
private void loadData(Uri dataUri) {
|
||||||
getActivity().setProgressBarIndeterminateVisibility(true);
|
|
||||||
mContainer.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
mDataUri = dataUri;
|
mDataUri = dataUri;
|
||||||
|
|
||||||
Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString());
|
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) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
|
setContentShown(false);
|
||||||
Uri baseUri = Keys.buildKeysUri(mDataUri);
|
Uri baseUri = Keys.buildKeysUri(mDataUri);
|
||||||
return new CursorLoader(getActivity(), baseUri, KEYS_PROJECTION, null, null, null);
|
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.)
|
// old cursor once we return.)
|
||||||
mKeysAdapter.swapCursor(data);
|
mKeysAdapter.swapCursor(data);
|
||||||
|
|
||||||
getActivity().setProgressBarIndeterminateVisibility(false);
|
setContentShown(true);
|
||||||
mContainer.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,15 +21,12 @@ import android.content.Intent;
|
|||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
import android.text.format.DateFormat;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import com.devspark.appmsg.AppMsg;
|
import com.devspark.appmsg.AppMsg;
|
||||||
@ -37,7 +34,6 @@ import com.devspark.appmsg.AppMsg;
|
|||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.R;import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
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.KeychainContract.UserIds;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.ViewKeyUserIdsAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.ViewKeyUserIdsAdapter;
|
||||||
@ -45,12 +41,11 @@ import org.sufficientlysecure.keychain.util.Log;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class ViewKeyMainFragment extends Fragment implements
|
public class ViewKeyMainFragment extends LoaderFragment implements
|
||||||
LoaderManager.LoaderCallbacks<Cursor> {
|
LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
public static final String ARG_DATA_URI = "uri";
|
public static final String ARG_DATA_URI = "uri";
|
||||||
|
|
||||||
private LinearLayout mContainer;
|
|
||||||
private View mActionEdit;
|
private View mActionEdit;
|
||||||
private View mActionEditDivider;
|
private View mActionEditDivider;
|
||||||
private View mActionEncrypt;
|
private View mActionEncrypt;
|
||||||
@ -70,10 +65,10 @@ public class ViewKeyMainFragment extends Fragment implements
|
|||||||
private Uri mDataUri;
|
private Uri mDataUri;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.view_key_main_fragment, container, false);
|
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);
|
mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids);
|
||||||
mActionEdit = view.findViewById(R.id.view_key_action_edit);
|
mActionEdit = view.findViewById(R.id.view_key_action_edit);
|
||||||
mActionEditDivider = view.findViewById(R.id.view_key_action_edit_divider);
|
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);
|
mActionCertify = view.findViewById(R.id.view_key_action_certify);
|
||||||
mActionCertifyDivider = view.findViewById(R.id.view_key_action_certify_divider);
|
mActionCertifyDivider = view.findViewById(R.id.view_key_action_certify_divider);
|
||||||
|
|
||||||
return view;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -99,9 +94,6 @@ public class ViewKeyMainFragment extends Fragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadData(Uri dataUri) {
|
private void loadData(Uri dataUri) {
|
||||||
getActivity().setProgressBarIndeterminateVisibility(true);
|
|
||||||
mContainer.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
mDataUri = dataUri;
|
mDataUri = dataUri;
|
||||||
|
|
||||||
Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString());
|
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;
|
static final int INDEX_UNIFIED_HAS_ENCRYPT = 5;
|
||||||
|
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
|
setContentShown(false);
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case LOADER_ID_UNIFIED: {
|
case LOADER_ID_UNIFIED: {
|
||||||
Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri);
|
Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri);
|
||||||
@ -219,8 +213,7 @@ public class ViewKeyMainFragment extends Fragment implements
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
getActivity().setProgressBarIndeterminateVisibility(false);
|
setContentShown(true);
|
||||||
mContainer.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,12 +53,11 @@ import org.sufficientlysecure.keychain.util.QrCodeUtils;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
public class ViewKeyShareFragment extends Fragment implements
|
public class ViewKeyShareFragment extends LoaderFragment implements
|
||||||
LoaderManager.LoaderCallbacks<Cursor> {
|
LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
public static final String ARG_DATA_URI = "uri";
|
public static final String ARG_DATA_URI = "uri";
|
||||||
|
|
||||||
private LinearLayout mContainer;
|
|
||||||
private TextView mFingerprint;
|
private TextView mFingerprint;
|
||||||
private ImageView mFingerprintQrCode;
|
private ImageView mFingerprintQrCode;
|
||||||
private View mFingerprintShareButton;
|
private View mFingerprintShareButton;
|
||||||
@ -77,12 +76,12 @@ public class ViewKeyShareFragment extends Fragment implements
|
|||||||
private Uri mDataUri;
|
private Uri mDataUri;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.view_key_share_fragment, container, false);
|
View root = super.onCreateView(inflater, superContainer, savedInstanceState);
|
||||||
|
View view = inflater.inflate(R.layout.view_key_share_fragment, getContainer());
|
||||||
|
|
||||||
mProviderHelper = new ProviderHelper(ViewKeyShareFragment.this.getActivity());
|
mProviderHelper = new ProviderHelper(ViewKeyShareFragment.this.getActivity());
|
||||||
|
|
||||||
mContainer = (LinearLayout) view.findViewById(R.id.container);
|
|
||||||
mFingerprint = (TextView) view.findViewById(R.id.view_key_fingerprint);
|
mFingerprint = (TextView) view.findViewById(R.id.view_key_fingerprint);
|
||||||
mFingerprintQrCode = (ImageView) view.findViewById(R.id.view_key_fingerprint_qr_code_image);
|
mFingerprintQrCode = (ImageView) view.findViewById(R.id.view_key_fingerprint_qr_code_image);
|
||||||
mFingerprintShareButton = view.findViewById(R.id.view_key_action_fingerprint_share);
|
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,
|
private void share(Uri dataUri, ProviderHelper providerHelper, boolean fingerprintOnly,
|
||||||
@ -232,9 +231,6 @@ public class ViewKeyShareFragment extends Fragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadData(Uri dataUri) {
|
private void loadData(Uri dataUri) {
|
||||||
getActivity().setProgressBarIndeterminateVisibility(true);
|
|
||||||
mContainer.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
mDataUri = dataUri;
|
mDataUri = dataUri;
|
||||||
|
|
||||||
Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString());
|
Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString());
|
||||||
@ -260,6 +256,7 @@ public class ViewKeyShareFragment extends Fragment implements
|
|||||||
static final int INDEX_UNIFIED_EXPIRY = 8;
|
static final int INDEX_UNIFIED_EXPIRY = 8;
|
||||||
|
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
|
setContentShown(false);
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case LOADER_ID_UNIFIED: {
|
case LOADER_ID_UNIFIED: {
|
||||||
Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri);
|
Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri);
|
||||||
@ -299,8 +296,7 @@ public class ViewKeyShareFragment extends Fragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
getActivity().setProgressBarIndeterminateVisibility(false);
|
setContentShown(true);
|
||||||
mContainer.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,103 +6,74 @@
|
|||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<!--rebuild functionality of ListFragment -->
|
<!--rebuild functionality of ListFragment -->
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/key_list_progress_container"
|
<se.emilsjolander.stickylistheaders.StickyListHeadersListView
|
||||||
android:orientation="vertical"
|
android:id="@+id/key_list_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="visible"
|
android:clipToPadding="false"
|
||||||
android:gravity="center">
|
android:drawSelectorOnTop="true"
|
||||||
|
android:fastScrollEnabled="true"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="32dp"
|
||||||
|
android:scrollbarStyle="outsideOverlay" />
|
||||||
|
|
||||||
<ProgressBar
|
<LinearLayout
|
||||||
style="?android:attr/progressBarStyleLarge"
|
android:id="@+id/key_list_empty"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="visible">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:gravity="center"
|
||||||
android:text=""
|
android:text="@string/key_list_empty_text1"
|
||||||
android:paddingTop="4dip"
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
android:singleLine="true" />
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text=""
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="4dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/key_list_empty_text2"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
<com.beardedhen.androidbootstrap.BootstrapButton
|
||||||
|
android:id="@+id/key_list_empty_button_create"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="4dp"
|
||||||
|
android:text="@string/key_list_empty_button_create"
|
||||||
|
bootstrapbutton:bb_icon_left="fa-plus"
|
||||||
|
bootstrapbutton:bb_type="default" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="4dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/key_list_empty_text3"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
<com.beardedhen.androidbootstrap.BootstrapButton
|
||||||
|
android:id="@+id/key_list_empty_button_import"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="4dp"
|
||||||
|
android:text="@string/key_list_empty_button_import"
|
||||||
|
bootstrapbutton:bb_icon_left="fa-download"
|
||||||
|
bootstrapbutton:bb_type="default" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/key_list_list_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<se.emilsjolander.stickylistheaders.StickyListHeadersListView
|
|
||||||
android:id="@+id/key_list_list"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:clipToPadding="false"
|
|
||||||
android:drawSelectorOnTop="true"
|
|
||||||
android:fastScrollEnabled="true"
|
|
||||||
android:paddingBottom="16dp"
|
|
||||||
android:paddingLeft="16dp"
|
|
||||||
android:paddingRight="32dp"
|
|
||||||
android:scrollbarStyle="outsideOverlay" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/key_list_empty"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/key_list_empty_text1"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text=""
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="4dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/key_list_empty_text2"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
|
||||||
|
|
||||||
<com.beardedhen.androidbootstrap.BootstrapButton
|
|
||||||
android:id="@+id/key_list_empty_button_create"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="4dp"
|
|
||||||
android:text="@string/key_list_empty_button_create"
|
|
||||||
bootstrapbutton:bb_icon_left="fa-plus"
|
|
||||||
bootstrapbutton:bb_type="default" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="4dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/key_list_empty_text3"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
|
||||||
|
|
||||||
<com.beardedhen.androidbootstrap.BootstrapButton
|
|
||||||
android:id="@+id/key_list_empty_button_import"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="4dp"
|
|
||||||
android:text="@string/key_list_empty_button_import"
|
|
||||||
bootstrapbutton:bb_icon_left="fa-download"
|
|
||||||
bootstrapbutton:bb_type="default" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
39
OpenKeychain/src/main/res/layout/loader_layout.xml
Normal file
39
OpenKeychain/src/main/res/layout/loader_layout.xml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<!--rebuild functionality of ListFragment -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/loader_progress"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
style="?android:attr/progressBarStyleLarge"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:text=""
|
||||||
|
android:paddingTop="4dip"
|
||||||
|
android:singleLine="true" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/loader_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
@ -11,8 +11,7 @@
|
|||||||
android:descendantFocusability="beforeDescendants"
|
android:descendantFocusability="beforeDescendants"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp">
|
||||||
android:id="@+id/container">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/SectionHeader"
|
style="@style/SectionHeader"
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
@ -12,9 +11,7 @@
|
|||||||
android:descendantFocusability="beforeDescendants"
|
android:descendantFocusability="beforeDescendants"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp">
|
||||||
android:id="@+id/container"
|
|
||||||
android:visibility="visible">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/SectionHeader"
|
style="@style/SectionHeader"
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
@ -12,8 +11,7 @@
|
|||||||
android:descendantFocusability="beforeDescendants"
|
android:descendantFocusability="beforeDescendants"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp">
|
||||||
android:id="@+id/container">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/SectionHeader"
|
style="@style/SectionHeader"
|
||||||
|
Loading…
Reference in New Issue
Block a user