mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix toolbar paste action and colors
This commit is contained in:
@@ -41,7 +41,6 @@ import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.getkeepsafe.taptargetview.TapTarget;
|
||||
@@ -102,7 +101,11 @@ public class GroupActivity extends ListNodesActivity
|
||||
protected boolean readOnly = false;
|
||||
|
||||
private static final String OLD_GROUP_TO_UPDATE_KEY = "OLD_GROUP_TO_UPDATE_KEY";
|
||||
private static final String NODE_TO_COPY_KEY = "NODE_TO_COPY_KEY";
|
||||
private static final String NODE_TO_MOVE_KEY = "NODE_TO_MOVE_KEY";
|
||||
private PwGroup oldGroupToUpdate;
|
||||
private PwNode nodeToCopy;
|
||||
private PwNode nodeToMove;
|
||||
|
||||
public static void launch(Activity act) {
|
||||
startRecordTime(act);
|
||||
@@ -160,11 +163,6 @@ public class GroupActivity extends ListNodesActivity
|
||||
|
||||
attachFragmentToContentView();
|
||||
|
||||
if (savedInstanceState != null
|
||||
&& savedInstanceState.containsKey(OLD_GROUP_TO_UPDATE_KEY)) {
|
||||
oldGroupToUpdate = (PwGroup) savedInstanceState.getSerializable(OLD_GROUP_TO_UPDATE_KEY);
|
||||
}
|
||||
|
||||
iconView = findViewById(R.id.icon);
|
||||
addNodeButtonView = findViewById(R.id.add_node_button);
|
||||
addNodeButtonView.enableAddGroup(addGroupEnabled);
|
||||
@@ -178,18 +176,26 @@ public class GroupActivity extends ListNodesActivity
|
||||
toolbarPasteExpandableLayout = findViewById(R.id.expandable_toolbar_paste_layout);
|
||||
toolbarPaste = findViewById(R.id.toolbar_paste);
|
||||
toolbarPaste.inflateMenu(R.menu.node_paste_menu);
|
||||
toolbarPaste.setTitle(R.string.where);
|
||||
toolbarPasteExpandableLayout.setOnExpansionUpdateListener((expansionFraction, state) -> {
|
||||
switch (state) {
|
||||
case ExpandableLayout.State.COLLAPSED:
|
||||
toolbarPaste.setVisibility(View.GONE);
|
||||
break;
|
||||
case ExpandableLayout.State.EXPANDING:
|
||||
toolbarPaste.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
toolbarPaste.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
|
||||
toolbarPaste.setNavigationOnClickListener(view -> {
|
||||
toolbarPasteExpandableLayout.collapse();
|
||||
nodeToCopy = null;
|
||||
nodeToMove = null;
|
||||
});
|
||||
toolbarPasteExpandableLayout.collapse(false);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
if (savedInstanceState.containsKey(OLD_GROUP_TO_UPDATE_KEY))
|
||||
oldGroupToUpdate = (PwGroup) savedInstanceState.getSerializable(OLD_GROUP_TO_UPDATE_KEY);
|
||||
|
||||
if (savedInstanceState.containsKey(NODE_TO_COPY_KEY)) {
|
||||
nodeToCopy = (PwNode) savedInstanceState.getSerializable(NODE_TO_COPY_KEY);
|
||||
toolbarPaste.setOnMenuItemClickListener(new OnCopyMenuItemClickListener());
|
||||
}
|
||||
else if (savedInstanceState.containsKey(NODE_TO_MOVE_KEY)) {
|
||||
nodeToMove = (PwNode) savedInstanceState.getSerializable(NODE_TO_MOVE_KEY);
|
||||
toolbarPaste.setOnMenuItemClickListener(new OnMoveMenuItemClickListener());
|
||||
}
|
||||
}
|
||||
|
||||
addNodeButtonView.setAddGroupClickListener(v -> {
|
||||
GroupEditDialogFragment.build()
|
||||
@@ -210,6 +216,10 @@ public class GroupActivity extends ListNodesActivity
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
outState.putSerializable(GROUP_ID_KEY, mCurrentGroup.getId());
|
||||
outState.putSerializable(OLD_GROUP_TO_UPDATE_KEY, oldGroupToUpdate);
|
||||
if (nodeToCopy != null)
|
||||
outState.putSerializable(NODE_TO_COPY_KEY, nodeToCopy);
|
||||
if (nodeToMove != null)
|
||||
outState.putSerializable(NODE_TO_MOVE_KEY, nodeToMove);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@@ -305,25 +315,32 @@ public class GroupActivity extends ListNodesActivity
|
||||
public boolean onCopyMenuClick(PwNode node) {
|
||||
|
||||
toolbarPasteExpandableLayout.expand();
|
||||
toolbarPaste.setOnMenuItemClickListener(item -> {
|
||||
nodeToCopy = node;
|
||||
toolbarPaste.setOnMenuItemClickListener(new OnCopyMenuItemClickListener());
|
||||
return false;
|
||||
}
|
||||
|
||||
private class OnCopyMenuItemClickListener implements Toolbar.OnMenuItemClickListener{
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
toolbarPasteExpandableLayout.collapse();
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_paste:
|
||||
switch (node.getType()) {
|
||||
switch (nodeToCopy.getType()) {
|
||||
case GROUP:
|
||||
Log.e(TAG, "Copy not allowed for group");
|
||||
break;
|
||||
case ENTRY:
|
||||
copyNode((PwEntry) node, mCurrentGroup);
|
||||
copyNode((PwEntry) nodeToCopy, mCurrentGroup);
|
||||
break;
|
||||
}
|
||||
nodeToCopy = null;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void copyNode(PwEntry entryToCopy, PwGroup newParent) {
|
||||
@@ -341,25 +358,32 @@ public class GroupActivity extends ListNodesActivity
|
||||
public boolean onMoveMenuClick(PwNode node) {
|
||||
|
||||
toolbarPasteExpandableLayout.expand();
|
||||
toolbarPaste.setOnMenuItemClickListener(item -> {
|
||||
nodeToMove = node;
|
||||
toolbarPaste.setOnMenuItemClickListener(new OnMoveMenuItemClickListener());
|
||||
return false;
|
||||
}
|
||||
|
||||
private class OnMoveMenuItemClickListener implements Toolbar.OnMenuItemClickListener{
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
toolbarPasteExpandableLayout.collapse();
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_paste:
|
||||
switch (node.getType()) {
|
||||
switch (nodeToMove.getType()) {
|
||||
case GROUP:
|
||||
moveGroup((PwGroup) node, mCurrentGroup);
|
||||
moveGroup((PwGroup) nodeToMove, mCurrentGroup);
|
||||
break;
|
||||
case ENTRY:
|
||||
moveEntry((PwEntry) node, mCurrentGroup);
|
||||
moveEntry((PwEntry) nodeToMove, mCurrentGroup);
|
||||
break;
|
||||
}
|
||||
nodeToMove = null;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void moveGroup(PwGroup groupToMove, PwGroup newParent) {
|
||||
|
||||
9
app/src/main/res/drawable/ic_arrow_left_white_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_arrow_left_white_24dp.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M15.41,16.09l-4.58,-4.59 4.58,-4.59L14,5.5l-6,6 6,6z"/>
|
||||
</vector>
|
||||
@@ -3,4 +3,4 @@
|
||||
android:id="@+id/nodes_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:attr/colorBackground" />
|
||||
android:background="?android:attr/windowBackground" />
|
||||
@@ -88,18 +88,17 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:el_duration="250"
|
||||
app:el_expanded="true"
|
||||
app:el_duration="300"
|
||||
app:el_expanded="false"
|
||||
app:el_parallax="0.5">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar_paste"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorAccentCompat"
|
||||
android:elevation="4dp"
|
||||
app:theme="?attr/toolbarAppearance"
|
||||
app:theme="?attr/toolbarBottomAppearance"
|
||||
android:background="?attr/colorAccent"
|
||||
tools:targetApi="lollipop" />
|
||||
|
||||
</net.cachapa.expandablelayout.ExpandableLayout>
|
||||
|
||||
@@ -22,5 +22,5 @@
|
||||
<item android:id="@+id/menu_paste"
|
||||
android:title="@string/menu_paste"
|
||||
android:orderInCategory="1090"
|
||||
app:showAsAction="always|withText" />
|
||||
app:showAsAction="ifRoom|withText" />
|
||||
</menu>
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
-->
|
||||
<resources>
|
||||
<attr name="toolbarAppearance" format="reference" />
|
||||
<attr name="toolbarBottomAppearance" format="reference" />
|
||||
<attr name="toolbarPopupAppearance" format="reference" />
|
||||
|
||||
<attr name="colorAccentCompat" format="reference|color" />
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
<string name="menu_move">Move</string>
|
||||
<string name="menu_paste">Paste</string>
|
||||
<string name="menu_delete">Delete</string>
|
||||
<string name="menu_cancel">Cancel</string>
|
||||
<string name="menu_hide_password">Hide Pass</string>
|
||||
<string name="menu_lock">Lock Database</string>
|
||||
<string name="menu_open">Open</string>
|
||||
@@ -134,7 +135,6 @@
|
||||
<string name="menu_showpass">Show pass</string>
|
||||
<string name="menu_fingerprint_remove_key">Remove the fingerprint key</string>
|
||||
<string name="menu_url">Go to URL</string>
|
||||
<string name="where">Where ?</string>
|
||||
<string name="minus">Minus</string>
|
||||
<string name="never">Never</string>
|
||||
<string name="no_results">No search results</string>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<item name="android:textColorHintInverse">@color/blue_lighter</item>
|
||||
<item name="android:windowBackground">@color/background_light</item>
|
||||
<item name="toolbarAppearance">@style/KeepassDXStyle.Toolbar.Blue</item>
|
||||
<item name="toolbarBottomAppearance">@style/KeepassDXStyle.Toolbar.Bottom.Blue</item>
|
||||
<item name="actionModeStyle">@style/KeepassDXStyle.ActionMode.Blue</item>
|
||||
</style>
|
||||
<!-- Toolbar Style Blue -->
|
||||
@@ -40,6 +41,9 @@
|
||||
<item name="android:editTextColor">@color/colorTextInverse</item>
|
||||
<item name="android:textColorHint">@color/blue_lighter</item>
|
||||
</style>
|
||||
<style name="KeepassDXStyle.Toolbar.Bottom.Blue" parent="KeepassDXStyle.Toolbar.Blue">
|
||||
<item name="actionMenuTextColor">@color/colorTextInverse</item>
|
||||
</style>
|
||||
<!-- Contextual Action Bar Blue -->
|
||||
<style name="KeepassDXStyle.ActionMode.Blue" parent="@style/Widget.AppCompat.ActionMode">
|
||||
<item name="background">@color/blue_dark</item>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<item name="android:textColorHintInverse">#80cbc4</item>
|
||||
<item name="android:windowBackground">@color/background_dark</item>
|
||||
<item name="toolbarAppearance">@style/KeepassDXStyle.Toolbar.Dark</item>
|
||||
<item name="toolbarBottomAppearance">@style/KeepassDXStyle.Toolbar.Dark</item>
|
||||
<item name="android:alertDialogTheme">@style/KeepassDXStyle.Dark.Dialog</item>
|
||||
<item name="alertDialogTheme">@style/KeepassDXStyle.Dark.Dialog</item>
|
||||
<item name="actionModeStyle">@style/KeepassDXStyle.ActionMode.Dark</item>
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
<item name="android:textColorHintInverse">@color/purple_lighter</item>
|
||||
<item name="android:windowBackground">@color/background_purple</item>
|
||||
<item name="toolbarAppearance">@style/KeepassDXStyle.Toolbar.Purple</item>
|
||||
<item name="toolbarBottomAppearance">@style/KeepassDXStyle.Toolbar.Bottom.Purple</item>
|
||||
<item name="actionModeStyle">@style/KeepassDXStyle.ActionMode.Purple</item>
|
||||
<item name="iconPreferenceColor">@color/purple_light</item>
|
||||
</style>
|
||||
@@ -42,6 +43,9 @@
|
||||
<item name="android:editTextColor">@color/colorTextInverse</item>
|
||||
<item name="android:textColorHint">@color/purple_lighter</item>
|
||||
</style>
|
||||
<style name="KeepassDXStyle.Toolbar.Bottom.Purple" parent="KeepassDXStyle.Toolbar.Purple">
|
||||
<item name="actionMenuTextColor">@color/colorTextInverse</item>
|
||||
</style>
|
||||
<!-- Contextual Action Bar Purple -->
|
||||
<style name="KeepassDXStyle.ActionMode.Purple" parent="@style/Widget.AppCompat.ActionMode">
|
||||
<item name="background">@color/purple_dark</item>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<item name="android:textColorHintInverse">@color/red_lighter</item>
|
||||
<item name="android:windowBackground">@color/background_night</item>
|
||||
<item name="toolbarAppearance">@style/KeepassDXStyle.Toolbar.Red</item>
|
||||
<item name="toolbarBottomAppearance">@style/KeepassDXStyle.Toolbar.Red</item>
|
||||
<item name="actionModeStyle">@style/KeepassDXStyle.ActionMode.Red</item>
|
||||
</style>
|
||||
<!-- Toolbar Style Red -->
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
<!-- Toolbar -->
|
||||
<item name="toolbarAppearance">@style/KeepassDXStyle.Toolbar.Light</item>
|
||||
<item name="toolbarPopupAppearance">@style/KeepassDXStyle.Light.Toolbar.Popup</item>
|
||||
<item name="toolbarBottomAppearance">@style/KeepassDXStyle.Toolbar.Night</item>
|
||||
<item name="actionModeStyle">@style/KeepassDXStyle.ActionMode</item>
|
||||
|
||||
<!-- White FAB -->
|
||||
@@ -124,6 +125,7 @@
|
||||
<!-- Toolbar -->
|
||||
<item name="toolbarAppearance">@style/KeepassDXStyle.Toolbar.Night</item>
|
||||
<item name="toolbarPopupAppearance">@style/KeepassDXStyle.Night.Toolbar.Popup</item>
|
||||
<item name="toolbarBottomAppearance">@style/KeepassDXStyle.Toolbar.Night</item>
|
||||
<item name="actionModeStyle">@style/KeepassDXStyle.ActionMode</item>
|
||||
|
||||
<!-- White FAB -->
|
||||
|
||||
Reference in New Issue
Block a user