diff options
Diffstat (limited to 'OpenKeychain/src')
3 files changed, 66 insertions, 0 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 4fda4cede..30db01fb4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -36,6 +36,7 @@ import android.support.v4.content.Loader; import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.CursorAdapter; import android.support.v4.widget.SwipeRefreshLayout; +import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.SearchView; import android.view.ActionMode; @@ -43,6 +44,7 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -94,6 +96,8 @@ public class KeyListFragment extends LoaderFragment private Button mButtonEmptyCreate; private Button mButtonEmptyImport; + boolean hideMenu = false; + /** * Load custom layout with StickyListView from library */ @@ -134,10 +138,50 @@ public class KeyListFragment extends LoaderFragment R.color.android_purple_dark, R.color.android_purple_light); mSwipeRefreshLayout.setStickyListHeadersListView(mStickyList); + mSwipeRefreshLayout.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_MOVE) { + updateActionbarForSwipe(true); + } else { + updateActionbarForSwipe(false); + } + return false; + } + }); return root; } + private void updateActionbarForSwipe(boolean show) { + ActionBarActivity activity = (ActionBarActivity) getActivity(); + ActionBar bar = activity.getSupportActionBar(); + + if (show) { + bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); + bar.setDisplayUseLogoEnabled(false); + bar.setCustomView(R.layout.custom_actionbar); + TextView title = (TextView) getActivity().findViewById(R.id.custom_actionbar_text); + title.setText(R.string.swipe_to_update); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + hideMenu = true; + activity.invalidateOptionsMenu(); + } + } else { + bar.setTitle(getActivity().getTitle()); + bar.setDisplayHomeAsUpEnabled(true); + bar.setDisplayShowTitleEnabled(true); + bar.setDisplayUseLogoEnabled(true); + bar.setDisplayShowHomeEnabled(true); + bar.setDisplayShowCustomEnabled(false); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + hideMenu = false; + activity.invalidateOptionsMenu(); + } + } + } + @Override public void onResume() { String[] servers = Preferences.getPreferences(getActivity()).getKeyServers(); @@ -421,6 +465,12 @@ public class KeyListFragment extends LoaderFragment } }); + if (hideMenu) { + for (int i = 0; i < menu.size(); i++) { + menu.getItem(i).setVisible(false); + } + } + super.onCreateOptionsMenu(menu, inflater); } @@ -723,5 +773,6 @@ public class KeyListFragment extends LoaderFragment } }; updateHelper.updateAllKeys(getActivity(), finishedHandler); + updateActionbarForSwipe(false); } } diff --git a/OpenKeychain/src/main/res/layout/custom_actionbar.xml b/OpenKeychain/src/main/res/layout/custom_actionbar.xml new file mode 100644 index 000000000..63c32335e --- /dev/null +++ b/OpenKeychain/src/main/res/layout/custom_actionbar.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView + android:id="@+id/custom_actionbar_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:text="" + android:textSize="18sp" /> +</LinearLayout>
\ No newline at end of file diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 9e9b47c7c..afaf4740c 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -834,6 +834,7 @@ <string name="error_no_encrypt_subkey">"No encryption subkey available!"</string> <string name="info_no_manual_account_creation">"Do not create OpenKeychain-Accounts manually.\nFor more information, see Help."</string> <string name="contact_show_key">"Show key (%s)"</string> + <string name="swipe_to_update">"Swipe down to update from keyserver"</string> <!-- First Time --> <string name="first_time_text1">"Take back your privacy with OpenKeychain!"</string> |