Refactor for list of nodes, solve bug of add button

This commit is contained in:
J-Jamet committed 2018-02-16 16:33:25 +01:00
1 parent 79750c5320
commit 5c4d2e607a
12 files changed
+151 -198

No files matched your search

@@ -30,6 +30,7 @@ import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import com.keepassdroid.adapters.NodeAdapter;
import com.keepassdroid.app.App;
@@ -50,13 +51,11 @@ import com.keepassdroid.dialog.ReadOnlyDialog;
import com.keepassdroid.fragments.GroupEditDialogFragment;
import com.keepassdroid.fragments.IconPickerDialogFragment;
import com.keepassdroid.tasks.ProgressTask;
import com.keepassdroid.view.GroupAddEntryView;
import com.keepassdroid.view.GroupRootView;
import com.keepassdroid.view.GroupViewOnlyView;
import com.keepassdroid.view.ListNodesWithAddButtonView;
import com.kunzisoft.keepass.KeePass;
import com.kunzisoft.keepass.R;
public abstract class GroupActivity extends GroupBaseActivity
public abstract class GroupActivity extends ListNodesActivity
implements GroupEditDialogFragment.EditGroupListener, IconPickerDialogFragment.IconPickerListener {
protected boolean addGroupEnabled = false;
@@ -143,17 +142,11 @@ public abstract class GroupActivity extends GroupBaseActivity
setupButtons();
if ( addGroupEnabled && addEntryEnabled ) {
setContentView(new GroupAddEntryView(this));
} else if ( addGroupEnabled ) {
setContentView(new GroupRootView(this));
} else if ( addEntryEnabled ) {
setContentView(new GroupAddEntryView(this));
View addGroup = findViewById(R.id.add_group);
addGroup.setVisibility(View.GONE);
} else {
setContentView(new GroupViewOnlyView(this));
}
// Construct main view
ListNodesWithAddButtonView rootView = new ListNodesWithAddButtonView(this);
rootView.enableAddGroup(addGroupEnabled);
rootView.enableAddEntry(addEntryEnabled);
setContentView(rootView);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("");
@@ -162,8 +155,6 @@ public abstract class GroupActivity extends GroupBaseActivity
if ( mCurrentGroup.getParent() != null )
toolbar.setNavigationIcon(R.drawable.ic_arrow_up_white_24dp);
Log.w(TAG, "Set view");
if ( addGroupEnabled ) {
// Add Group button
View addGroup = findViewById(R.id.add_group);
@@ -247,6 +238,13 @@ public abstract class GroupActivity extends GroupBaseActivity
}
}
protected void setGroupIcon() {
if (mCurrentGroup != null) {
ImageView iv = (ImageView) findViewById(R.id.icon);
App.getDB().drawFactory.assignDrawableTo(iv, getResources(), mCurrentGroup.getIcon());
}
}
private void deleteEntry(PwEntry entry) {
Handler handler = new Handler();
DeleteEntry task = new DeleteEntry(this, App.getDB(), entry,