diff --git a/app/src/main/java/com/luxlunaris/noadpadlight/control/classes/Notebook.java b/app/src/main/java/com/luxlunaris/noadpadlight/control/classes/Notebook.java index e049ab4..e02a3c9 100644 --- a/app/src/main/java/com/luxlunaris/noadpadlight/control/classes/Notebook.java +++ b/app/src/main/java/com/luxlunaris/noadpadlight/control/classes/Notebook.java @@ -406,7 +406,6 @@ public void compactSelection(){ } - /** * Put a page in the recycle bin: * this creates a copy of the original page @@ -459,11 +458,13 @@ private void removeFromRecycleBin(Page page){ /** * Permanently delete all of the pages in the recycle bin. + * And notify the listening UI that they got deleted. */ public void emptyRecycleBin(){ for(Page page : getRecycleBin()){ FileIO.deleteDirectory(((File)page).getPath() ); Log.d("DELETED_PAGE", "deleting forever: "+page.getName()); + listener.onDeleted(page); } recycleBin.clear(); Log.d("DELETED_PAGE", "recycle bin size: "+ new File(PAGES_RECYCLE_BIN).listFiles().length); diff --git a/app/src/main/java/com/luxlunaris/noadpadlight/ui/PagesActivity.java b/app/src/main/java/com/luxlunaris/noadpadlight/ui/PagesActivity.java index d81cbf5..6a39533 100644 --- a/app/src/main/java/com/luxlunaris/noadpadlight/ui/PagesActivity.java +++ b/app/src/main/java/com/luxlunaris/noadpadlight/ui/PagesActivity.java @@ -277,6 +277,8 @@ private void showRecycleBin(){ optionsMenu.findItem(R.id.app_bar_search).setVisible(false); optionsMenu.findItem(R.id.load_more_pages).setVisible(false); optionsMenu.findItem(R.id.show_recycle_bin).setVisible(false); + optionsMenu.findItem(R.id.empty_recycle_bin_from_within).setVisible(true); + //in edit menu editMenu = editMenu==null? new EditMenu(this, findViewById(R.id.edit)) : editMenu; @@ -293,6 +295,7 @@ private void exitRecycleBin(){ optionsMenu.findItem(R.id.app_bar_search).setVisible(true); optionsMenu.findItem(R.id.load_more_pages).setVisible(true); optionsMenu.findItem(R.id.show_recycle_bin).setVisible(true); + optionsMenu.findItem(R.id.empty_recycle_bin_from_within).setVisible(false); //in edit menu editMenu = editMenu==null? new EditMenu(this, findViewById(R.id.edit)) : editMenu; @@ -375,6 +378,9 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { case R.id.show_recycle_bin: showRecycleBin(); break; + case R.id.empty_recycle_bin_from_within: + notebook.emptyRecycleBin(); + break; } diff --git a/app/src/main/java/com/luxlunaris/noadpadlight/ui/SettingsActivity.java b/app/src/main/java/com/luxlunaris/noadpadlight/ui/SettingsActivity.java index 4a2245b..c002007 100644 --- a/app/src/main/java/com/luxlunaris/noadpadlight/ui/SettingsActivity.java +++ b/app/src/main/java/com/luxlunaris/noadpadlight/ui/SettingsActivity.java @@ -1,16 +1,12 @@ package com.luxlunaris.noadpadlight.ui; -import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; -import androidx.appcompat.app.AppCompatActivity; - import com.luxlunaris.noadpadlight.R; -import com.luxlunaris.noadpadlight.control.classes.Notebook; import com.luxlunaris.noadpadlight.control.classes.SETTINGS_TAGS; /** @@ -21,9 +17,6 @@ public class SettingsActivity extends ColorActivity { LinearLayout linearLayout; - Button restoreRecycleBin; - - Button emptyRecycleBin; @Override protected void onCreate(Bundle savedInstanceState) { @@ -58,37 +51,6 @@ public void onClick(View v) { BackupFragment backupFragment = BackupFragment.newInstance(); getSupportFragmentManager().beginTransaction().add(linearLayout.getId(), backupFragment, "").commit(); - - - - - - - restoreRecycleBin = new Button(this); - linearLayout.addView(restoreRecycleBin); - restoreRecycleBin.setText(R.string.restore_recycle_bin); - restoreRecycleBin.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Notebook.getInstance().restoreAllFromRecycleBin(); - } - }); - restoreRecycleBin.setBackgroundColor(Color.GREEN); - - - emptyRecycleBin = new Button(this); - linearLayout.addView(emptyRecycleBin); - emptyRecycleBin.setText(R.string.empty_recycle_bin); - emptyRecycleBin.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Notebook.getInstance().emptyRecycleBin(); - } - }); - emptyRecycleBin.setBackgroundColor(Color.RED); - - - } diff --git a/app/src/main/res/menu/pages_activity_toolbar.xml b/app/src/main/res/menu/pages_activity_toolbar.xml index 709244f..6311295 100644 --- a/app/src/main/res/menu/pages_activity_toolbar.xml +++ b/app/src/main/res/menu/pages_activity_toolbar.xml @@ -46,4 +46,15 @@ + + + + + + \ No newline at end of file