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 @@
+
+
+
+
+
\ 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 @@
"No encryption subkey available!"
"Do not create OpenKeychain-Accounts manually.\nFor more information, see Help."
"Show key (%s)"
+ "Swipe down to update from keyserver"
"Take back your privacy with OpenKeychain!"