From 7b9b3d07bbb507823ec4621d37e2723460124e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 2 Jan 2014 22:36:57 +0100 Subject: final fixes for public key list --- OpenPGP-Keychain/res/drawable/header_selector.xml | 7 ---- .../res/layout/key_list_public_fragment.xml | 1 - OpenPGP-Keychain/res/layout/stickylist_header.xml | 3 +- OpenPGP-Keychain/res/values/colors.xml | 3 -- .../keychain/ui/KeyListPublicFragment.java | 46 +++++++++++----------- .../keychain/ui/adapter/KeyListPublicAdapter.java | 7 ++-- 6 files changed, 29 insertions(+), 38 deletions(-) delete mode 100644 OpenPGP-Keychain/res/drawable/header_selector.xml (limited to 'OpenPGP-Keychain') diff --git a/OpenPGP-Keychain/res/drawable/header_selector.xml b/OpenPGP-Keychain/res/drawable/header_selector.xml deleted file mode 100644 index 5dfb8265c..000000000 --- a/OpenPGP-Keychain/res/drawable/header_selector.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/OpenPGP-Keychain/res/layout/key_list_public_fragment.xml b/OpenPGP-Keychain/res/layout/key_list_public_fragment.xml index 451230a1f..2aca81cd6 100644 --- a/OpenPGP-Keychain/res/layout/key_list_public_fragment.xml +++ b/OpenPGP-Keychain/res/layout/key_list_public_fragment.xml @@ -14,7 +14,6 @@ android:paddingBottom="16dp" android:paddingLeft="16dp" android:paddingRight="32dp" - android:paddingTop="16dp" android:scrollbarStyle="outsideOverlay" /> + android:layout_height="wrap_content" > #31b6e7 #cecbce - #ffe74c3c - #ffc0392b - #FFDDDDDD \ No newline at end of file diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java index 84adaef99..7bc0bcd96 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java @@ -44,19 +44,28 @@ import com.actionbarsherlock.app.SherlockFragment; /** * Public key list with sticky list headers. * - * - uses StickyListHeaders library - custom adapter: KeyListPublicAdapter + * - uses StickyListHeaders library * - * TODO: - fix loader with spinning animation - fix design - fix view holder in adapter + * - custom adapter: KeyListPublicAdapter + * + * TODO: - fix view holder in adapter, fix loader * */ public class KeyListPublicFragment extends SherlockFragment implements AdapterView.OnItemClickListener, LoaderManager.LoaderCallbacks { private KeyListPublicActivity mKeyListPublicActivity; - private KeyListPublicAdapter mAdapter; + private StickyListHeadersListView mStickyList; - StickyListHeadersListView stickyList; + /** + * Load custom layout with StickyListView from library + */ + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.key_list_public_fragment, container, false); + return view; + } /** * Define Adapter and Loader on create of Activity @@ -67,20 +76,17 @@ public class KeyListPublicFragment extends SherlockFragment implements super.onActivityCreated(savedInstanceState); mKeyListPublicActivity = (KeyListPublicActivity) getActivity(); + mStickyList = (StickyListHeadersListView) getActivity().findViewById(R.id.list); - stickyList = (StickyListHeadersListView) getActivity().findViewById(R.id.list); - - stickyList.setOnItemClickListener(this); - // stickyList.setOnHeaderClickListener(this); - // stickyList.setOnStickyHeaderOffsetChangedListener(this); + mStickyList.setOnItemClickListener(this); // mStickyList.addHeaderView(inflater.inflate(R.layout.list_header, null)); // mStickyList.addFooterView(inflater.inflate(R.layout.list_footer, null)); - stickyList.setEmptyView(getActivity().findViewById(R.id.empty)); - stickyList.setAreHeadersSticky(true); - stickyList.setDrawingListUnderStickyHeader(true); - stickyList.setFastScrollEnabled(true); + mStickyList.setEmptyView(getActivity().findViewById(R.id.empty)); + mStickyList.setAreHeadersSticky(true); + mStickyList.setDrawingListUnderStickyHeader(false); + mStickyList.setFastScrollEnabled(true); try { - stickyList.setFastScrollAlwaysVisible(true); + mStickyList.setFastScrollAlwaysVisible(true); } catch (ApiLevelTooLowException e) { } @@ -101,12 +107,6 @@ public class KeyListPublicFragment extends SherlockFragment implements getLoaderManager().initLoader(0, null, this); } - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.key_list_public_fragment, container, false); - return view; - } - // These are the rows that we will retrieve. static final String[] PROJECTION = new String[] { KeyRings._ID, KeyRings.MASTER_KEY_ID, UserIds.USER_ID }; @@ -134,7 +134,7 @@ public class KeyListPublicFragment extends SherlockFragment implements mAdapter = new KeyListPublicAdapter(mKeyListPublicActivity, data, Id.type.public_key, userIdIndex); - stickyList.setAdapter(mAdapter); + mStickyList.setAdapter(mAdapter); // The list should now be shown. if (isResumed()) { @@ -152,9 +152,11 @@ public class KeyListPublicFragment extends SherlockFragment implements mAdapter.swapCursor(null); } + /** + * On click on item, start key view activity + */ @Override public void onItemClick(AdapterView adapterView, View view, int position, long id) { - // start key view on click Intent detailsIntent = new Intent(mKeyListPublicActivity, KeyViewActivity.class); detailsIntent.setData(KeychainContract.KeyRings.buildPublicKeyRingsUri(Long.toString(id))); startActivity(detailsIntent); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListPublicAdapter.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListPublicAdapter.java index 108fad917..ef3a0d228 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListPublicAdapter.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListPublicAdapter.java @@ -86,7 +86,6 @@ public class KeyListPublicAdapter extends CursorAdapter implements StickyListHea @Override public View getHeaderView(int position, View convertView, ViewGroup parent) { - HeaderViewHolder holder; if (convertView == null) { holder = new HeaderViewHolder(); @@ -97,6 +96,7 @@ public class KeyListPublicAdapter extends CursorAdapter implements StickyListHea holder = (HeaderViewHolder) convertView.getTag(); } + // similar to getView in CursorAdapter if (!mDataValid) { // no data available at this point Log.d(Constants.TAG, "getHeaderView: No data available at this point!"); @@ -108,17 +108,18 @@ public class KeyListPublicAdapter extends CursorAdapter implements StickyListHea throw new IllegalStateException("couldn't move cursor to position " + position); } - // set header text as first char in name + // set header text as first char in user id String headerText = "" + mCursor.getString(mSectionColumnIndex).subSequence(0, 1).charAt(0); holder.text.setText(headerText); return convertView; } /** - * Remember that these have to be static, position=1 should always return the same Id that is. + * Header IDs should be static, position=1 should always return the same Id that is. */ @Override public long getHeaderId(int position) { + // similar to getView in CursorAdapter if (!mDataValid) { // no data available at this point Log.d(Constants.TAG, "getHeaderView: No data available at this point!"); -- cgit v1.2.3