Skip to content

Commit

Permalink
Added empty recycle bin button inside of recycle bin perspective.
Browse files Browse the repository at this point in the history
  • Loading branch information
aiman-al-masoud committed Aug 11, 2021
1 parent eb31b46 commit 858b5ce
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ public void compactSelection(){
}



/**
* Put a page in the recycle bin:
* this creates a copy of the original page
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;


}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

/**
Expand All @@ -21,9 +17,6 @@ public class SettingsActivity extends ColorActivity {

LinearLayout linearLayout;

Button restoreRecycleBin;

Button emptyRecycleBin;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -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);



}


Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/menu/pages_activity_toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,15 @@



<item
android:id="@+id/empty_recycle_bin_from_within"
android:icon="@android:drawable/ic_menu_delete"
android:title="@string/empty_recycle_bin"
android:visible="false"
app:showAsAction="always" />





</menu>

0 comments on commit 858b5ce

Please sign in to comment.