diff options
Diffstat (limited to 'OpenKeychain/src/main')
4 files changed, 89 insertions, 6 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; diff --git a/OpenKeychain/src/main/res/layout/key_list_fragment.xml b/OpenKeychain/src/main/res/layout/key_list_fragment.xml index f31d5fce6..65935f9c8 100644 --- a/OpenKeychain/src/main/res/layout/key_list_fragment.xml +++ b/OpenKeychain/src/main/res/layout/key_list_fragment.xml @@ -2,7 +2,8 @@ <RelativeLayout xmlns:fab="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" - android:layout_width="match_parent"> + android:layout_width="match_parent" + > <!--rebuild functionality of ListFragment --> <FrameLayout @@ -52,7 +53,8 @@ fab:fab_labelStyle="@style/FabMenuStyle" android:layout_marginBottom="8dp" android:layout_marginRight="16dp" - android:layout_marginEnd="16dp"> + android:layout_marginEnd="16dp" + > <com.getbase.floatingactionbutton.FloatingActionButton android:id="@+id/fab_add_qr_code" |