diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9c5bee226..3dc14c510 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -23,8 +23,9 @@
android:theme="@style/KeepassDXStyle.Light"
tools:replace="android:theme">
-
+
-
-
-
@@ -90,21 +94,14 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
+
diff --git a/app/src/main/java/com/keepassdroid/activities/GroupActivity.java b/app/src/main/java/com/keepassdroid/activities/GroupActivity.java
index 557d2b288..36c2a50b8 100644
--- a/app/src/main/java/com/keepassdroid/activities/GroupActivity.java
+++ b/app/src/main/java/com/keepassdroid/activities/GroupActivity.java
@@ -35,14 +35,9 @@ import android.widget.ImageView;
import com.keepassdroid.adapters.NodeAdapter;
import com.keepassdroid.app.App;
import com.keepassdroid.database.Database;
-import com.keepassdroid.database.PwDatabase;
-import com.keepassdroid.database.PwDatabaseV3;
-import com.keepassdroid.database.PwDatabaseV4;
import com.keepassdroid.database.PwEntry;
import com.keepassdroid.database.PwGroup;
import com.keepassdroid.database.PwGroupId;
-import com.keepassdroid.database.PwGroupV3;
-import com.keepassdroid.database.PwGroupV4;
import com.keepassdroid.database.PwNode;
import com.keepassdroid.database.edit.AddGroup;
import com.keepassdroid.database.edit.DeleteEntry;
@@ -55,7 +50,7 @@ import com.keepassdroid.view.ListNodesWithAddButtonView;
import com.kunzisoft.keepass.KeePass;
import com.kunzisoft.keepass.R;
-public abstract class GroupActivity extends ListNodesActivity
+public class GroupActivity extends ListNodesActivity
implements GroupEditDialogFragment.EditGroupListener, IconPickerDialogFragment.IconPickerListener {
protected boolean addGroupEnabled = false;
@@ -75,37 +70,11 @@ public abstract class GroupActivity extends ListNodesActivity
}
public static void Launch(Activity act, PwGroup group) {
- Intent i;
-
- // Need to use PwDatabase since tree may be null
- PwDatabase db = App.getDB().pm;
- if ( db instanceof PwDatabaseV3 ) {
- i = new Intent(act, GroupActivityV3.class);
-
- if ( group != null ) {
- PwGroupV3 g = (PwGroupV3) group;
- i.putExtra(KEY_ENTRY, g.groupId);
- }
- } else if ( db instanceof PwDatabaseV4 ) {
- i = new Intent(act, GroupActivityV4.class);
-
- if ( group != null ) {
- PwGroupV4 g = (PwGroupV4) group;
- i.putExtra(KEY_ENTRY, g.uuid.toString());
- }
- } else {
- // Reached if db is null
- Log.d(TAG, "Tried to launch with null db");
- return;
- }
-
- act.startActivityForResult(i,0);
- }
-
- protected abstract PwGroupId retrieveGroupId(Intent i);
-
- protected void setupButtons() {
- addGroupEnabled = !readOnly;
+ Intent intent = new Intent(act, GroupActivity.class);
+ if ( group != null ) {
+ intent.putExtra(KEY_ENTRY, group.getId());
+ }
+ act.startActivityForResult(intent,0);
}
@Override
@@ -119,17 +88,15 @@ public abstract class GroupActivity extends ListNodesActivity
setResult(KeePass.EXIT_NORMAL);
Log.w(TAG, "Creating tree view");
- Intent intent = getIntent();
-
- PwGroupId id = retrieveGroupId(intent);
+ PwGroupId pwGroupId = (PwGroupId) getIntent().getSerializableExtra(KEY_ENTRY);
Database db = App.getDB();
readOnly = db.readOnly;
PwGroup root = db.pm.rootGroup;
- if ( id == null ) {
+ if ( pwGroupId == null ) {
mCurrentGroup = root;
} else {
- mCurrentGroup = db.pm.groups.get(id);
+ mCurrentGroup = db.pm.groups.get(pwGroupId);
}
Log.w(TAG, "Retrieved tree");
@@ -137,10 +104,13 @@ public abstract class GroupActivity extends ListNodesActivity
Log.w(TAG, "Group was null");
return;
}
-
- isRoot = mCurrentGroup == root;
-
- setupButtons();
+
+ addGroupEnabled = !readOnly;
+ addEntryEnabled = !readOnly;
+
+ isRoot = (mCurrentGroup == root);
+ if ( !mCurrentGroup.allowAddEntryIfIsRoot() )
+ addEntryEnabled = !isRoot && addEntryEnabled;
// Construct main view
ListNodesWithAddButtonView rootView = new ListNodesWithAddButtonView(this);
diff --git a/app/src/main/java/com/keepassdroid/activities/GroupActivityV3.java b/app/src/main/java/com/keepassdroid/activities/GroupActivityV3.java
deleted file mode 100644
index e7d72f8a2..000000000
--- a/app/src/main/java/com/keepassdroid/activities/GroupActivityV3.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
- *
- * This file is part of KeePass DX.
- *
- * KeePass DX is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * KeePass DX is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with KeePass DX. If not, see .
- *
- */
-package com.keepassdroid.activities;
-
-import android.content.Intent;
-
-import com.keepassdroid.database.PwGroupIdV3;
-
-public class GroupActivityV3 extends GroupActivity {
-
- @Override
- protected PwGroupIdV3 retrieveGroupId(Intent i) {
- int id = i.getIntExtra(KEY_ENTRY, -1);
-
- if ( id == -1 ) {
- return null;
- }
-
- return new PwGroupIdV3(id);
- }
-
- @Override
- protected void setupButtons() {
- super.setupButtons();
- addEntryEnabled = !isRoot && !readOnly;
- }
-}
diff --git a/app/src/main/java/com/keepassdroid/activities/GroupActivityV4.java b/app/src/main/java/com/keepassdroid/activities/GroupActivityV4.java
deleted file mode 100644
index b13d9719a..000000000
--- a/app/src/main/java/com/keepassdroid/activities/GroupActivityV4.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
- *
- * This file is part of KeePass DX.
- *
- * KeePass DX is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * KeePass DX is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with KeePass DX. If not, see .
- *
- */
-package com.keepassdroid.activities;
-
-import java.util.UUID;
-
-import android.content.Intent;
-
-import com.keepassdroid.database.PwGroupId;
-import com.keepassdroid.database.PwGroupIdV4;
-
-public class GroupActivityV4 extends GroupActivity {
-
- @Override
- protected PwGroupId retrieveGroupId(Intent i) {
- String uuid = i.getStringExtra(KEY_ENTRY);
-
- if ( uuid == null || uuid.length() == 0 ) {
- return null;
- }
-
- return new PwGroupIdV4(UUID.fromString(uuid));
- }
-
- @Override
- protected void setupButtons() {
- super.setupButtons();
- addEntryEnabled = !readOnly;
- }
-}
diff --git a/app/src/main/java/com/keepassdroid/database/PwGroup.java b/app/src/main/java/com/keepassdroid/database/PwGroup.java
index 3cae125c7..7a38240bd 100644
--- a/app/src/main/java/com/keepassdroid/database/PwGroup.java
+++ b/app/src/main/java/com/keepassdroid/database/PwGroup.java
@@ -119,6 +119,10 @@ public abstract class PwGroup extends PwNode {
public abstract void setLastAccessTime(Date date);
public abstract void setLastModificationTime(Date date);
+
+ public boolean allowAddEntryIfIsRoot() {
+ return false;
+ }
public void touch(boolean modified, boolean touchParents) {
Date now = new Date();
diff --git a/app/src/main/java/com/keepassdroid/database/PwGroupV4.java b/app/src/main/java/com/keepassdroid/database/PwGroupV4.java
index c37604c9d..3592e79dc 100644
--- a/app/src/main/java/com/keepassdroid/database/PwGroupV4.java
+++ b/app/src/main/java/com/keepassdroid/database/PwGroupV4.java
@@ -19,11 +19,6 @@
*/
package com.keepassdroid.database;
-import android.content.Intent;
-import android.os.Bundle;
-
-import com.keepassdroid.utils.Types;
-
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -213,7 +208,11 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger {
@Override
public void setParent(PwGroup prt) {
parent = (PwGroupV4) prt;
-
+ }
+
+ @Override
+ public boolean allowAddEntryIfIsRoot() {
+ return true;
}
@Override