Skip to content

Commit

Permalink
Added dialog confirmation before deleting files
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciotogneri committed Sep 11, 2016
1 parent cba0930 commit 90c4f7b
Show file tree
Hide file tree
Showing 16 changed files with 200 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected void fillView(View rowView, ViewHolder viewHolder, FileInfo fileInfo)
{
int numberOfChildren = fileInfo.numberOfChildren();

viewHolder.size.setText(getContext().getResources().getQuantityString(R.plurals.labelItems, numberOfChildren, numberOfChildren));
viewHolder.size.setText(getContext().getResources().getQuantityString(R.plurals.itemAmount, numberOfChildren, numberOfChildren));

viewHolder.icon.setImageResource(R.drawable.ic_folder);
viewHolder.extension.setText(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void addFragment(FolderFragment fragment, boolean addToBackStack)
transaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_right);
}

transaction.add(R.id.fragment_container, fragment);
transaction.add(R.id.fragmentContainer, fragment);

if (addToBackStack)
{
Expand Down Expand Up @@ -92,13 +92,20 @@ public ButtonBar buttonBar()
@Override
public void onBackPressed()
{
if (fragments.size() > 1)
if (fragments.size() > 0)
{
FolderFragment fragment = fragments.peek();

if (fragment.onBackPressed())
{
removeFragment(fragment);
if (fragments.size() > 1)
{
removeFragment(fragment);
}
else
{
finish();
}
}
}
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package com.mauriciotogneri.fileexplorer.fragments;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
Expand Down Expand Up @@ -235,7 +237,7 @@ private void openFile(FileInfo fileInfo)
intent.setDataAndType(fileInfo.uri(), fileInfo.mimeType());
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

startActivity(Intent.createChooser(intent, getString(R.string.title_openFile)));
startActivity(Intent.createChooser(intent, getString(R.string.openFile_title)));
}

public void onSelectAll()
Expand Down Expand Up @@ -264,7 +266,7 @@ private void shareSingle(FileInfo fileInfo)
intent.setType(fileInfo.mimeType());
intent.putExtra(Intent.EXTRA_STREAM, fileInfo.uri());

startActivity(Intent.createChooser(intent, getString(R.string.title_shareFile)));
startActivity(Intent.createChooser(intent, getString(R.string.shareFile_title)));
}

private void shareMultiple(List<FileInfo> list)
Expand All @@ -282,18 +284,32 @@ private void shareMultiple(List<FileInfo> list)

intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);

startActivity(Intent.createChooser(intent, getString(R.string.title_shareFile)));
startActivity(Intent.createChooser(intent, getString(R.string.shareFile_title)));
}

public void onDelete()
{
final List<FileInfo> selectedItems = adapter.selectedItems(false);
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setCancelable(false);
builder.setTitle(R.string.delete_confirm);
builder.setPositiveButton(R.string.dialog_delete, new OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
deleteSelected(adapter.selectedItems(false));
}
});
builder.setNegativeButton(R.string.dialog_cancel, null);
builder.show();
}

final Dialog dialog = new Dialog(mainActivity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_waiting);
dialog.setCanceledOnTouchOutside(false);
private void deleteSelected(final List<FileInfo> selectedItems)
{
final ProgressDialog dialog = new ProgressDialog(getContext());
dialog.setMessage(getString(R.string.delete_deleting));
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
dialog.show();

new AsyncTask<Void, Void, Boolean>()
Expand All @@ -311,6 +327,15 @@ protected Boolean doInBackground(Void... params)
}
}

try
{
Thread.sleep(3000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}

return allDeleted;
}

Expand All @@ -323,7 +348,7 @@ protected void onPostExecute(Boolean result)

if (!result)
{
Toast.makeText(mainActivity, R.string.message_errorDeleting, Toast.LENGTH_SHORT).show();
Toast.makeText(mainActivity, R.string.delete_error, Toast.LENGTH_SHORT).show();
}
}
}.execute();
Expand Down
25 changes: 18 additions & 7 deletions app/src/main/res/drawable/ic_audio.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
<vector android:height="24dp" android:viewportHeight="48.0"
android:viewportWidth="48.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha="1" android:fillColor="#67a898"
android:pathData="M44,12.63 L44,44.21C44,46.3 42.15,48 39.86,48L8.14,48C5.85,48 4,46.3 4,44.21L4,3.79C4,1.7 5.85,0 8.14,0L30.21,0 44,12.63Z" android:strokeColor="#00000000"/>
<path android:fillAlpha="1" android:fillColor="#76c2af"
android:pathData="M44,11.92 L44,13.5 32.72,13.5C30.39,13.5 29.31,11.76 29.31,9.61L29.31,0 31.02,0 44,11.92Z" android:strokeColor="#00000000"/>
<path android:fillColor="#ffffff" android:pathData="M12.85,37.26C13.89,38.61 16.03,38.7 17.63,37.46 18.28,36.96 19.44,35.59 19.44,32.79L19.44,24.14 31.77,21.79 31.77,27.25C31.77,29.17 30.21,29.62 29.68,29.72 29.64,29.72 29.59,29.73 29.55,29.74 29.53,29.74 29.49,29.75 29.49,29.75L29.5,29.75C28.88,29.86 28.26,30.12 27.7,30.55 26.1,31.79 25.64,33.88 26.67,35.22 27.71,36.56 29.85,36.65 31.45,35.42 32.26,34.79 33.07,33.59 33.07,31.7L33.07,17.21C33.07,16.45 32.44,16.01 31.68,16.25L19.22,18.6C18.46,18.84 18.14,19.65 18.14,20.41L18.14,28.84C18.14,30.77 16.36,31.66 15.84,31.76 15.81,31.76 15.79,31.77 15.76,31.78 15.69,31.79 15.65,31.79 15.65,31.79L15.66,31.8C15.05,31.91 14.43,32.17 13.88,32.6 12.28,33.83 11.82,35.92 12.85,37.26Z"/>
<vector android:height="24dp"
android:viewportHeight="48.0"
android:viewportWidth="48.0"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillAlpha="1"
android:fillColor="#67a898"
android:pathData="M44,12.63 L44,44.21C44,46.3 42.15,48 39.86,48L8.14,48C5.85,48 4,46.3 4,44.21L4,3.79C4,1.7 5.85,0 8.14,0L30.21,0 44,12.63Z"
android:strokeColor="#00000000"/>
<path
android:fillAlpha="1"
android:fillColor="#76c2af"
android:pathData="M44,11.92 L44,13.5 32.72,13.5C30.39,13.5 29.31,11.76 29.31,9.61L29.31,0 31.02,0 44,11.92Z"
android:strokeColor="#00000000"/>
<path
android:fillColor="#ffffff"
android:pathData="M12.85,37.26C13.89,38.61 16.03,38.7 17.63,37.46 18.28,36.96 19.44,35.59 19.44,32.79L19.44,24.14 31.77,21.79 31.77,27.25C31.77,29.17 30.21,29.62 29.68,29.72 29.64,29.72 29.59,29.73 29.55,29.74 29.53,29.74 29.49,29.75 29.49,29.75L29.5,29.75C28.88,29.86 28.26,30.12 27.7,30.55 26.1,31.79 25.64,33.88 26.67,35.22 27.71,36.56 29.85,36.65 31.45,35.42 32.26,34.79 33.07,33.59 33.07,31.7L33.07,17.21C33.07,16.45 32.44,16.01 31.68,16.25L19.22,18.6C18.46,18.84 18.14,19.65 18.14,20.41L18.14,28.84C18.14,30.77 16.36,31.66 15.84,31.76 15.81,31.76 15.79,31.77 15.76,31.78 15.69,31.79 15.65,31.79 15.65,31.79L15.66,31.8C15.05,31.91 14.43,32.17 13.88,32.6 12.28,33.83 11.82,35.92 12.85,37.26Z"/>
</vector>
14 changes: 10 additions & 4 deletions app/src/main/res/drawable/ic_delete.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<vector android:height="24dp" android:viewportHeight="48.0"
android:viewportWidth="48.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha="1" android:fillColor="#feffff"
android:pathData="M8.14,42.67C8.14,45.61 10.51,48 13.43,48L34.57,48C37.49,48 39.86,45.61 39.86,42.67L39.86,10.67 8.14,10.67 8.14,42.67ZM42.5,2.67 L33.25,2.67 30.61,0 17.39,0 14.75,2.67 5.5,2.67 5.5,8 42.5,8 42.5,2.67Z" android:strokeColor="#00000000"/>
<vector android:height="24dp"
android:viewportHeight="48.0"
android:viewportWidth="48.0"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillAlpha="1"
android:fillColor="#feffff"
android:pathData="M8.14,42.67C8.14,45.61 10.51,48 13.43,48L34.57,48C37.49,48 39.86,45.61 39.86,42.67L39.86,10.67 8.14,10.67 8.14,42.67ZM42.5,2.67 L33.25,2.67 30.61,0 17.39,0 14.75,2.67 5.5,2.67 5.5,8 42.5,8 42.5,2.67Z"
android:strokeColor="#00000000"/>
</vector>
21 changes: 15 additions & 6 deletions app/src/main/res/drawable/ic_file.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<vector android:height="24dp" android:viewportHeight="64.0"
android:viewportWidth="64.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha="1" android:fillColor="#f0f0f0"
android:pathData="M11,0C7.69,0 5,2.62 5,5.82L5,29.09 5,40.73 5,58.18C5,61.38 7.69,64 11,64L53,64C56.31,64 59,61.38 59,58.18L59,40.73 59,29.09 59,17.45 41,0 11,0Z" android:strokeColor="#00000000"/>
<path android:fillAlpha="1" android:fillColor="#e6e6e6"
android:pathData="M59,17.45 L41,0 41,11.64C41,14.84 43.69,17.45 47,17.45L59,17.45Z" android:strokeColor="#00000000"/>
<vector android:height="24dp"
android:viewportHeight="64.0"
android:viewportWidth="64.0"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillAlpha="1"
android:fillColor="#f0f0f0"
android:pathData="M11,0C7.69,0 5,2.62 5,5.82L5,29.09 5,40.73 5,58.18C5,61.38 7.69,64 11,64L53,64C56.31,64 59,61.38 59,58.18L59,40.73 59,29.09 59,17.45 41,0 11,0Z"
android:strokeColor="#00000000"/>
<path
android:fillAlpha="1"
android:fillColor="#e6e6e6"
android:pathData="M59,17.45 L41,0 41,11.64C41,14.84 43.69,17.45 47,17.45L59,17.45Z"
android:strokeColor="#00000000"/>
</vector>
15 changes: 11 additions & 4 deletions app/src/main/res/drawable/ic_folder.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<vector android:height="24dp" android:viewportHeight="64.0"
android:viewportWidth="64.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#cca352" android:pathData="M60,7.73 L24,7.73C24,5.67 22.21,4 20,4L4,4C1.79,4 0,5.67 0,7.73L0,11.47 0,17.07 0,18.93C0,21 1.79,22.67 4,22.67L60,22.67C62.21,22.67 64,21 64,18.93L64,11.47C64,9.4 62.21,7.73 60,7.73Z"/>
<path android:fillColor="#ffcc66" android:pathData="M60,13.18 L4,13.18C1.79,13.18 0,14.93 0,17.09L0,56.1C0,58.25 1.79,60 4,60L60,60C62.21,60 64,58.25 64,56.1L64,17.09C64,14.93 62.21,13.18 60,13.18Z"/>
<vector android:height="24dp"
android:viewportHeight="64.0"
android:viewportWidth="64.0"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="#cca352"
android:pathData="M60,7.73 L24,7.73C24,5.67 22.21,4 20,4L4,4C1.79,4 0,5.67 0,7.73L0,11.47 0,17.07 0,18.93C0,21 1.79,22.67 4,22.67L60,22.67C62.21,22.67 64,21 64,18.93L64,11.47C64,9.4 62.21,7.73 60,7.73Z"/>
<path
android:fillColor="#ffcc66"
android:pathData="M60,13.18 L4,13.18C1.79,13.18 0,14.93 0,17.09L0,56.1C0,58.25 1.79,60 4,60L60,60C62.21,60 64,58.25 64,56.1L64,17.09C64,14.93 62.21,13.18 60,13.18Z"/>
</vector>
22 changes: 16 additions & 6 deletions app/src/main/res/drawable/ic_pdf.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
<vector android:height="24dp" android:viewportHeight="48.0"
android:viewportWidth="48.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#cb0606" android:pathData="M44,12.63 L44,44.21C44,46.3 42.15,48 39.86,48L8.14,48C5.85,48 4,46.3 4,44.21L4,3.79C4,1.7 5.85,0 8.14,0L30.21,0 44,12.63Z"/>
<path android:fillColor="#fb8d8d" android:pathData="M44,11.92 L44,13.5 32.72,13.5C30.39,13.5 29.31,11.76 29.31,9.61L29.31,0 31.02,0 44,11.92Z"/>
<path android:fillColor="#00000000"
<vector android:height="24dp"
android:viewportHeight="48.0"
android:viewportWidth="48.0"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="#cb0606"
android:pathData="M44,12.63 L44,44.21C44,46.3 42.15,48 39.86,48L8.14,48C5.85,48 4,46.3 4,44.21L4,3.79C4,1.7 5.85,0 8.14,0L30.21,0 44,12.63Z"/>
<path
android:fillColor="#fb8d8d"
android:pathData="M44,11.92 L44,13.5 32.72,13.5C30.39,13.5 29.31,11.76 29.31,9.61L29.31,0 31.02,0 44,11.92Z"/>
<path
android:fillColor="#00000000"
android:pathData="M24.05,16.39C24.52,16.61 24.42,16.89 24.28,18.22 24.13,19.6 23.65,22.11 22.71,24.58 21.77,27.05 20.38,29.48 19.16,31.27 17.95,33.07 16.91,34.23 16.12,34.91 15.32,35.58 14.78,35.76 14.42,35.82 14.06,35.88 13.9,35.82 13.8,35.64 13.71,35.46 13.67,35.16 13.76,34.8 13.84,34.44 14.03,34.03 14.58,33.49 15.13,32.95 16.04,32.29 17.3,31.68 18.56,31.06 20.18,30.49 21.51,30.1 22.84,29.72 23.87,29.51 24.78,29.34 25.69,29.18 26.46,29.06 27.22,29 27.99,28.94 28.73,28.94 29.46,29 30.19,29.06 30.9,29.18 31.52,29.33 32.13,29.48 32.65,29.66 33.1,29.94 33.56,30.22 33.95,30.61 34.14,31.05 34.34,31.48 34.34,31.96 34.17,32.31 34.01,32.65 33.69,32.86 33.31,32.98 32.94,33.1 32.52,33.13 32.02,32.98 31.52,32.83 30.93,32.5 30.32,32.07 29.7,31.63 29.06,31.09 28.21,30.26 27.37,29.42 26.34,28.28 25.46,27.17 24.59,26.07 23.87,24.99 23.39,24.08 22.9,23.16 22.64,22.41 22.43,21.67 22.22,20.92 22.06,20.17 22,19.5 21.93,18.82 21.96,18.22 22.03,17.74 22.09,17.27 22.19,16.9 22.35,16.66 22.51,16.43 22.74,16.31 22.9,16.25 23.06,16.19 23.16,16.19 23.26,16.17 23.35,16.16 23.45,16.13 23.6,16.17 23.74,16.22 23.93,16.33 24.11,16.45"
android:strokeColor="#ffffff" android:strokeLineJoin="round" android:strokeWidth="1.4318996668"/>
android:strokeColor="#ffffff"
android:strokeLineJoin="round"
android:strokeWidth="1.4318996668"/>
</vector>
17 changes: 13 additions & 4 deletions app/src/main/res/drawable/ic_select.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<vector android:height="24dp" android:viewportHeight="96.0"
android:viewportWidth="96.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha="1" android:fillColor="#ffffff" android:pathData="M80,4H16C9.37,4 4,9.37 4,16v64c0,6.63 5.37,12 12,12h64c6.63,0 12,-5.37 12,-12V16C92,9.37 86.63,4 80,4zM84,80c0,2.21 -1.79,4 -4,4H16c-2.21,0 -4,-1.79 -4,-4V16c0,-2.21 1.79,-4 4,-4h64c2.21,0 4,1.79 4,4V80z"/>
<path android:fillAlpha="1" android:fillColor="#ffffff" android:pathData="M72.31,31.17C70.25,29.1 66.9,29.1 64.83,31.17L42.39,53.61 31.17,42.39C29.1,40.33 25.75,40.33 23.69,42.39 21.62,44.46 21.62,47.81 23.69,49.87L38.65,64.83C40.71,66.9 44.06,66.9 46.13,64.83L72.31,38.65C74.38,36.58 74.38,33.24 72.31,31.17Z"/>
<vector android:height="24dp"
android:viewportHeight="96.0"
android:viewportWidth="96.0"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillAlpha="1"
android:fillColor="#ffffff"
android:pathData="M80,4H16C9.37,4 4,9.37 4,16v64c0,6.63 5.37,12 12,12h64c6.63,0 12,-5.37 12,-12V16C92,9.37 86.63,4 80,4zM84,80c0,2.21 -1.79,4 -4,4H16c-2.21,0 -4,-1.79 -4,-4V16c0,-2.21 1.79,-4 4,-4h64c2.21,0 4,1.79 4,4V80z"/>
<path
android:fillAlpha="1"
android:fillColor="#ffffff"
android:pathData="M72.31,31.17C70.25,29.1 66.9,29.1 64.83,31.17L42.39,53.61 31.17,42.39C29.1,40.33 25.75,40.33 23.69,42.39 21.62,44.46 21.62,47.81 23.69,49.87L38.65,64.83C40.71,66.9 44.06,66.9 46.13,64.83L72.31,38.65C74.38,36.58 74.38,33.24 72.31,31.17Z"/>
</vector>
14 changes: 10 additions & 4 deletions app/src/main/res/drawable/ic_share.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<vector android:height="24dp" android:viewportHeight="48.0"
android:viewportWidth="48.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha="1" android:fillColor="#ffffff"
android:pathData="M39.78,31.28C37.44,31.28 35.33,32.29 33.83,33.89L16.34,25.18C16.4,24.77 16.44,24.35 16.44,23.93 16.44,23.51 16.4,23.1 16.34,22.71L33.81,14.09C35.31,15.7 37.43,16.72 39.78,16.72 44.32,16.72 48,12.98 48,8.36 48,3.74 44.32,0 39.78,0 35.24,0 31.56,3.74 31.56,8.36 31.56,8.77 31.6,9.18 31.66,9.58L14.19,18.19C12.69,16.58 10.57,15.57 8.22,15.57 3.68,15.57 0,19.31 0,23.93 0,28.54 3.68,32.28 8.22,32.28 10.56,32.28 12.67,31.28 14.17,29.68L31.66,38.39C31.6,38.8 31.56,39.21 31.56,39.64 31.56,44.26 35.24,48 39.78,48 44.32,48 48,44.26 48,39.64 48,35.02 44.32,31.28 39.78,31.28Z" android:strokeColor="#00000000"/>
<vector android:height="24dp"
android:viewportHeight="48.0"
android:viewportWidth="48.0"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillAlpha="1"
android:fillColor="#ffffff"
android:pathData="M39.78,31.28C37.44,31.28 35.33,32.29 33.83,33.89L16.34,25.18C16.4,24.77 16.44,24.35 16.44,23.93 16.44,23.51 16.4,23.1 16.34,22.71L33.81,14.09C35.31,15.7 37.43,16.72 39.78,16.72 44.32,16.72 48,12.98 48,8.36 48,3.74 44.32,0 39.78,0 35.24,0 31.56,3.74 31.56,8.36 31.56,8.77 31.6,9.18 31.66,9.58L14.19,18.19C12.69,16.58 10.57,15.57 8.22,15.57 3.68,15.57 0,19.31 0,23.93 0,28.54 3.68,32.28 8.22,32.28 10.56,32.28 12.67,31.28 14.17,29.68L31.66,38.39C31.6,38.8 31.56,39.21 31.56,39.64 31.56,44.26 35.24,48 39.78,48 44.32,48 48,44.26 48,39.64 48,35.02 44.32,31.28 39.78,31.28Z"
android:strokeColor="#00000000"/>
</vector>
Loading

0 comments on commit 90c4f7b

Please sign in to comment.