diff options
Diffstat (limited to 'OpenPGP-Keychain/src/main')
3 files changed, 157 insertions, 78 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java index 3418fff85..3ee0202ef 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java @@ -57,6 +57,7 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.view.animation.AnimationUtils; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.ListView; @@ -73,6 +74,12 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer private KeyListPublicAdapter mAdapter; private StickyListHeadersListView mStickyList; + + // rebuild functionality of ListFragment, http://stackoverflow.com/a/12504097 + boolean mListShown; + View mProgressContainer; + View mListContainer; + private String mCurQuery; private SearchView mSearchView; // empty list layout @@ -85,9 +92,14 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.key_list_public_fragment, container, false); - setHasOptionsMenu(true); - mButtonEmptyCreate = (BootstrapButton) view.findViewById(R.id.key_list_empty_button_create); + View root = inflater.inflate(R.layout.key_list_public_fragment, container, false); + + mStickyList = (StickyListHeadersListView) root.findViewById(R.id.key_list_public_list); + mStickyList.setOnItemClickListener(this); + + + // empty view + mButtonEmptyCreate = (BootstrapButton) root.findViewById(R.id.key_list_empty_button_create); mButtonEmptyCreate.setOnClickListener(new OnClickListener() { @Override @@ -99,8 +111,7 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer startActivityForResult(intent, 0); } }); - - mButtonEmptyImport = (BootstrapButton) view.findViewById(R.id.key_list_empty_button_import); + mButtonEmptyImport = (BootstrapButton) root.findViewById(R.id.key_list_empty_button_import); mButtonEmptyImport.setOnClickListener(new OnClickListener() { @Override @@ -111,7 +122,12 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer } }); - return view; + // rebuild functionality of ListFragment, http://stackoverflow.com/a/12504097 + mListContainer = root.findViewById(R.id.key_list_public_list_container); + mProgressContainer = root.findViewById(R.id.key_list_public_progress_container); + mListShown = true; + + return root; } /** @@ -122,9 +138,6 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - mStickyList = (StickyListHeadersListView) getActivity().findViewById(R.id.list); - - mStickyList.setOnItemClickListener(this); mStickyList.setAreHeadersSticky(true); mStickyList.setDrawingListUnderStickyHeader(false); mStickyList.setFastScrollEnabled(true); @@ -134,7 +147,7 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer } // this view is made visible if no data is available - mStickyList.setEmptyView(getActivity().findViewById(R.id.empty)); + mStickyList.setEmptyView(getActivity().findViewById(R.id.key_list_public_empty)); /* * ActionBarSherlock does not support MultiChoiceModeListener. Thus multi-selection is only @@ -211,9 +224,12 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer }); } + // We have a menu item to show in action bar. + setHasOptionsMenu(true); + // NOTE: Not supported by StickyListHeader, thus no indicator is shown while loading // Start out with a progress indicator. - // setListShown(false); + setListShown(false); // Create an empty adapter we will use to display the loaded data. mAdapter = new KeyListPublicAdapter(getActivity(), null, Id.type.public_key, USER_ID_INDEX); @@ -262,11 +278,11 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer // NOTE: Not supported by StickyListHeader, thus no indicator is shown while loading // The list should now be shown. - // if (isResumed()) { - // setListShown(true); - // } else { - // setListShownNoAnimation(true); - // } + if (isResumed()) { + setListShown(true); + } else { + setListShownNoAnimation(true); + } } @Override @@ -376,4 +392,41 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer getLoaderManager().restartLoader(0, null, this); 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); + } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListSecretFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListSecretFragment.java index eaac6d8b1..9a5477762 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListSecretFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListSecretFragment.java @@ -17,7 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import java.util.ArrayList; import java.util.Set; import org.sufficientlysecure.keychain.Id; @@ -50,12 +49,10 @@ import android.widget.AdapterView; import android.widget.ListView; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView.OnItemClickListener; -import android.widget.Toast; public class KeyListSecretFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor>, OnItemClickListener { - private KeyListSecretActivity mKeyListSecretActivity; private KeyListSecretAdapter mAdapter; /** @@ -66,8 +63,6 @@ public class KeyListSecretFragment extends ListFragment implements public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - mKeyListSecretActivity = (KeyListSecretActivity) getActivity(); - getListView().setOnItemClickListener(this); // Give some text to display if there is no data. In a real @@ -114,7 +109,7 @@ public class KeyListSecretFragment extends ListFragment implements case R.id.menu_key_list_public_multi_select_all: { //Select all int localCount = getListView().getCount(); - for(int k = 0; k < localCount; k++) { + for (int k = 0; k < localCount; k++) { getListView().setItemChecked(k, true); } break; @@ -153,7 +148,7 @@ public class KeyListSecretFragment extends ListFragment implements setListShown(false); // Create an empty adapter we will use to display the loaded data. - mAdapter = new KeyListSecretAdapter(mKeyListSecretActivity, null, 0); + mAdapter = new KeyListSecretAdapter(getActivity(), null, 0); setListAdapter(mAdapter); // Prepare the loader. Either re-connect with an existing one, @@ -203,7 +198,7 @@ public class KeyListSecretFragment extends ListFragment implements */ @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { - Intent editIntent = new Intent(mKeyListSecretActivity, EditKeyActivity.class); + Intent editIntent = new Intent(getActivity(), EditKeyActivity.class); editIntent.setData(KeychainContract.KeyRings.buildSecretKeyRingsUri(Long.toString(id))); editIntent.setAction(EditKeyActivity.ACTION_EDIT_KEY); startActivityForResult(editIntent, 0); diff --git a/OpenPGP-Keychain/src/main/res/layout/key_list_public_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/key_list_public_fragment.xml index f3a21e1bf..db82c8771 100644 --- a/OpenPGP-Keychain/src/main/res/layout/key_list_public_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/key_list_public_fragment.xml @@ -3,75 +3,106 @@ xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" > - - <se.emilsjolander.stickylistheaders.StickyListHeadersListView - android:id="@+id/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" /> + android:orientation="vertical"> + <!--rebuild functionality of ListFragment --> <LinearLayout - android:id="@+id/empty" + android:id="@+id/key_list_public_progress_container" + android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" - android:gravity="center" - android:orientation="vertical" - android:visibility="gone" > + android:visibility="gone" + android:gravity="center"> - <TextView + <ProgressBar + style="?android:attr/progressBarStyleLarge" 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" /> + android:layout_height="wrap_content" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" - android:gravity="center" + android:textAppearance="?android:attr/textAppearanceSmall" android:text="" - android:textAppearance="?android:attr/textAppearanceLarge" /> + android:paddingTop="4dip" + android:singleLine="true" /> - <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" /> + </LinearLayout> - <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" /> + <FrameLayout + android:id="@+id/key_list_public_list_container" + android:layout_width="match_parent" + android:layout_height="match_parent"> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_margin="4dp" + <se.emilsjolander.stickylistheaders.StickyListHeadersListView + android:id="@+id/key_list_public_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_public_empty" + android:layout_width="match_parent" + android:layout_height="match_parent" android:gravity="center" - android:text="@string/key_list_empty_text3" - android:textAppearance="?android:attr/textAppearanceSmall" /> + android:orientation="vertical"> + + <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> - <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>
\ No newline at end of file |