Skip to content

Commit

Permalink
#212 - change icons for view files & compress image (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
vyankatesh24 authored and Swati4star committed Jul 17, 2018
1 parent 41ad0d3 commit d29ee45
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public class ViewFilesAdapter extends RecyclerView.Adapter<ViewFilesAdapter.View
/**
* Returns adapter instance
*
* @param activity the activity calling this adapter
* @param feedItems array list containing path of files
* @param activity the activity calling this adapter
* @param feedItems array list containing path of files
* @param emptyStateChangeListener interface for empty state change
*/
public ViewFilesAdapter(Activity activity,
Expand All @@ -63,6 +63,7 @@ public ViewFilesAdapter(Activity activity,
mFileUtils = new FileUtils(activity);
mPDFUtils = new PDFUtils(activity);
}

@NonNull
@Override
public ViewFilesHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
Expand Down Expand Up @@ -154,6 +155,7 @@ public void onSelection(MaterialDialog dialog, View view, int which, CharSequenc
}
});
}

public void checkAll() {
for (int i = 0; i < mFileList.size(); i++) {
if (!mDeleteNames.contains(i)) {
Expand All @@ -162,6 +164,12 @@ public void checkAll() {
notifyDataSetChanged();
}
}

public void unCheckAll() {
mDeleteNames.clear();
notifyDataSetChanged();
}

public ArrayList<String> getSelectedFilePath() {
ArrayList<String> filePathList = new ArrayList<>();
for (int position : mDeleteNames) {
Expand Down Expand Up @@ -240,7 +248,7 @@ public void deleteFiles() {

public void shareFiles() {
ArrayList<File> files = new ArrayList<>();
for (int position: mDeleteNames) {
for (int position : mDeleteNames) {
files.add(mFileList.get(position));
}
mFileUtils.shareMultipleFiles(files);
Expand All @@ -259,7 +267,7 @@ public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
Snackbar.LENGTH_LONG).show();
} else {
File oldfile = mFileList.get(position);
String oldPath = mFileList.get(position).getPath();
String oldPath = mFileList.get(position).getPath();
int index = oldPath.lastIndexOf('/');
String newfilename = oldPath.substring(0, index) + "/" + input.toString() +
mActivity.getString(R.string.pdf_ext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public List<EnhancementOptionsEntity> getEnhancementOptions() {
getResources().getString(R.string.edit_images_text)));

mEnhancementOptionsEntityArrayList.add(
new EnhancementOptionsEntity(getResources().getDrawable(R.drawable.pdf_compress),
new EnhancementOptionsEntity(getResources().getDrawable(R.drawable.ic_compress_image),
getString(R.string.compress_image) + " " +
mSharedPreferences.getInt(DEFAULT_COMPRESSION, 30) + "%)"));
mEnhancementOptionsEntityArrayList.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class ViewFilesFragment extends Fragment
@BindView(R.id.swipe)
SwipeRefreshLayout mSwipeView;
private Menu mMenuIcons;
private MenuItem mMenuItem;
private Activity mActivity;
private ViewFilesAdapter mViewFilesAdapter;
private final DialogInterface.OnClickListener mDialogClickListener = new DialogInterface.OnClickListener() {
Expand All @@ -94,6 +95,7 @@ public void onClick(DialogInterface dialog, int which) {
private SearchView mSearchView;
private int mCurrentSortingIndex;
private SharedPreferences mSharedPreferences;
private boolean mIsChecked = false;

//When the "GET STARTED" button is clicked, the user is taken to home
@OnClick(R.id.getStarted)
Expand Down Expand Up @@ -149,6 +151,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
populatePdfList();
return root;
}

@OnClick(R.id.new_dir)
void moveToNewDirectory() {
if (mViewFilesAdapter.areItemsSelected()) {
Expand All @@ -157,6 +160,7 @@ void moveToNewDirectory() {
showSnack(R.string.snackbar_no_pdfs_selected);
}
}

@OnClick(R.id.move_to_dir)
void moveToDirectory() {
if (mViewFilesAdapter.areItemsSelected()) {
Expand All @@ -165,12 +169,14 @@ void moveToDirectory() {
showSnack(R.string.snackbar_no_pdfs_selected);
}
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.activity_view_files_actions, menu);
mMenuIcons = menu;
MenuItem item = menu.findItem(R.id.action_search);
mMenuItem = menu.findItem(R.id.select_all);
mSearchView = (SearchView) item.getActionView();
mSearchView.setQueryHint(getString(R.string.search_hint));
mSearchView.setSubmitButtonEnabled(true);
Expand Down Expand Up @@ -227,7 +233,15 @@ public boolean onOptionsItemSelected(final MenuItem item) {
}
break;
case R.id.select_all:
mViewFilesAdapter.checkAll();
if (mIsChecked) {
mViewFilesAdapter.unCheckAll();
mMenuItem.setIcon(R.drawable.ic_check_box_outline_blank_24dp);
mIsChecked = false;
} else {
mViewFilesAdapter.checkAll();
mMenuItem.setIcon(R.drawable.ic_check_box_24dp);
mIsChecked = true;
}
break;
default:
break;
Expand Down Expand Up @@ -333,6 +347,7 @@ public void onClick(DialogInterface dialog, int i) {

/**
* Moves files from one directory to another
*
* @param operation - type of operation to be performed
* (create new Directory or move to an existing directory)
*/
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_check_box_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M19,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.11,0 2,-0.9 2,-2L21,5c0,-1.1 -0.89,-2 -2,-2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z" />
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/>
android:fillColor="#FFFFFF"
android:pathData="M19,5v14H5V5h14m0,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2z" />
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_compress_image.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#000000"
android:pathData="M19.5,3.09L20.91,4.5L16.41,9H20V11H13V4H15V7.59L19.5,3.09M20.91,19.5L19.5,20.91L15,16.41V20H13V13H20V15H16.41L20.91,19.5M4.5,3.09L9,7.59V4H11V11H4V9H7.59L3.09,4.5L4.5,3.09M3.09,19.5L7.59,15H4V13H11V20H9V16.41L4.5,20.91L3.09,19.5Z" />
</vector>
12 changes: 6 additions & 6 deletions app/src/main/res/menu/activity_view_files_actions.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/action_search"
Expand All @@ -13,27 +13,27 @@
<item
android:id="@+id/item_sort"
android:icon="@drawable/ic_sort_white_24px"
android:title="@string/sort"
android:orderInCategory="2"
android:title="@string/sort"
app:showAsAction="ifRoom" />
<item
android:id="@+id/select_all"
android:icon="@drawable/ic_done"
android:title="@string/select_all"
android:icon="@drawable/ic_check_box_outline_blank_24dp"
android:orderInCategory="1"
android:title="@string/select_all"
app:showAsAction="always" />

<item
android:id="@+id/item_delete"
android:icon="@drawable/baseline_delete_24"
android:title="@string/delete"
android:orderInCategory="3"
android:title="@string/delete"
app:showAsAction="ifRoom" />

<item
android:id="@+id/item_share"
android:icon="@drawable/baseline_share_24"
android:title="@string/share"
android:orderInCategory="4"
android:title="@string/share"
app:showAsAction="never" />
</menu>

0 comments on commit d29ee45

Please sign in to comment.