diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-02-28 00:39:18 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-02-28 00:39:18 +0100 |
commit | fd55cdb08e47b87d2fdc98d15fc679725e2d2619 (patch) | |
tree | 015276c8b732179deda7aa1a5b6f3719671787bd /OpenKeychain/src/main/java | |
parent | 453b67f7a8cb274d794843e54d6d050a7ef7a98a (diff) | |
parent | 9c62c3fd3985958a43707c7a25f07744a6cfcb95 (diff) | |
download | open-keychain-fd55cdb08e47b87d2fdc98d15fc679725e2d2619.tar.gz open-keychain-fd55cdb08e47b87d2fdc98d15fc679725e2d2619.tar.bz2 open-keychain-fd55cdb08e47b87d2fdc98d15fc679725e2d2619.zip |
Merge branch 'development' of github.com:open-keychain/open-keychain into development
Conflicts:
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java
Diffstat (limited to 'OpenKeychain/src/main/java')
3 files changed, 85 insertions, 4 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 ba9a96b28..bf3498f2f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -46,14 +46,19 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.view.ViewGroup.LayoutParams; +import android.view.ViewGroup.MarginLayoutParams; +import android.view.animation.TranslateAnimation; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; +import android.widget.RelativeLayout; import android.widget.TextView; import com.getbase.floatingactionbutton.FloatingActionButton; +import com.getbase.floatingactionbutton.FloatingActionsMenu; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; @@ -71,6 +76,7 @@ import org.sufficientlysecure.keychain.ui.util.Highlighter; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.util.ExportHelper; +import org.sufficientlysecure.keychain.util.FabContainer; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; @@ -87,7 +93,7 @@ import se.emilsjolander.stickylistheaders.StickyListHeadersListView; */ public class KeyListFragment extends LoaderFragment implements SearchView.OnQueryTextListener, AdapterView.OnItemClickListener, - LoaderManager.LoaderCallbacks<Cursor> { + LoaderManager.LoaderCallbacks<Cursor>, FabContainer { ExportHelper mExportHelper; @@ -102,6 +108,8 @@ public class KeyListFragment extends LoaderFragment private String mQuery; private SearchView mSearchView; + private FloatingActionsMenu mFab; + private FloatingActionButton mFabQrCode; private FloatingActionButton mFabCloud; private FloatingActionButton mFabFile; @@ -124,6 +132,8 @@ public class KeyListFragment extends LoaderFragment mStickyList = (StickyListHeadersListView) view.findViewById(R.id.key_list_list); mStickyList.setOnItemClickListener(this); + mFab = (FloatingActionsMenu) view.findViewById(R.id.fab_main); + mFabQrCode = (FloatingActionButton) view.findViewById(R.id.fab_add_qr_code); mFabCloud = (FloatingActionButton) view.findViewById(R.id.fab_add_cloud); mFabFile = (FloatingActionButton) view.findViewById(R.id.fab_add_file); @@ -609,6 +619,25 @@ public class KeyListFragment extends LoaderFragment } } + LayoutParams mFabOrigin = null; + @Override + public void fabMoveUp(int height) { + if (mFabOrigin == null) { + mFabOrigin = mFab.getLayoutParams(); + } + + // TODO reposition properly! + MarginLayoutParams marginParams = new MarginLayoutParams(mFabOrigin); + marginParams.setMargins(0, 0, 16, 16+height); + RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(marginParams); + mFab.setLayoutParams(layoutParams); + } + + @Override + public void fabRestorePosition() { + mFab.setLayoutParams(mFabOrigin); + } + /** * Implements StickyListHeadersAdapter from library */ diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java index ed9f3a02d..b6b2fcb8a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java @@ -25,10 +25,11 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.remote.ui.AppsListFragment; import org.sufficientlysecure.keychain.util.Preferences; +import org.sufficientlysecure.keychain.util.FabContainer; import it.neokree.materialnavigationdrawer.MaterialNavigationDrawer; -public class MainActivity extends MaterialNavigationDrawer { +public class MainActivity extends MaterialNavigationDrawer implements FabContainer { @Override public void init(Bundle savedInstanceState) { @@ -66,4 +67,20 @@ public class MainActivity extends MaterialNavigationDrawer { } } + @Override + public void fabMoveUp(int height) { + Object fragment = getCurrentSection().getTargetFragment(); + if (fragment instanceof FabContainer) { + ((FabContainer) fragment).fabMoveUp(height); + } + } + + @Override + public void fabRestorePosition() { + Object fragment = getCurrentSection().getTargetFragment(); + if (fragment instanceof FabContainer) { + ((FabContainer) fragment).fabRestorePosition(); + } + } + } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java index f6c979139..1c6f3bd3e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java @@ -19,15 +19,16 @@ package org.sufficientlysecure.keychain.ui.util; import android.app.Activity; import android.content.res.Resources; -import android.graphics.Color; import com.nispok.snackbar.Snackbar; import com.nispok.snackbar.Snackbar.SnackbarDuration; import com.nispok.snackbar.SnackbarManager; import com.nispok.snackbar.enums.SnackbarType; import com.nispok.snackbar.listeners.ActionClickListener; +import com.nispok.snackbar.listeners.EventListener; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.util.FabContainer; /** * Notify wrapper which allows a more easy use of different notification libraries @@ -45,13 +46,47 @@ public class Notify { * @param text Text to show * @param style Notification styling */ - public static void showNotify(Activity activity, CharSequence text, Style style) { + public static void showNotify(final Activity activity, CharSequence text, Style style) { Snackbar bar = Snackbar.with(activity) .text(text) .type(SnackbarType.MULTI_LINE) .duration(SnackbarDuration.LENGTH_LONG); + if (activity instanceof FabContainer) { + bar.eventListener(new EventListener() { + @Override + public void onShow(Snackbar snackbar) { + ((FabContainer) activity).fabMoveUp(snackbar.getHeight()); + } + + @Override + public void onShowByReplace(Snackbar snackbar) { + + } + + @Override + public void onShown(Snackbar snackbar) { + + } + + @Override + public void onDismiss(Snackbar snackbar) { + ((FabContainer) activity).fabRestorePosition(); + } + + @Override + public void onDismissByReplace(Snackbar snackbar) { + + } + + @Override + public void onDismissed(Snackbar snackbar) { + + } + }); + } + switch (style) { case OK: break; |