From 890171cdbbd57d3ec7aff859e022c223c772a486 Mon Sep 17 00:00:00 2001 From: Rohit Yengisetty Date: Tue, 27 Jan 2015 11:55:38 -0800 Subject: CM File Manager : Add Application category to Easy Mode List * add shortcut to search for application mimetypes (apk, msi, deb etc) * fix layout inflater bug that was causing layout params to be ignored Change-Id: I4bd63fdbdf720a49b536bc811ec10255cc2427db --- res/drawable-hdpi/ic_em_all.png | Bin 342 -> 832 bytes res/drawable-hdpi/ic_em_application.png | Bin 0 -> 830 bytes res/drawable-hdpi/ic_em_document.png | Bin 417 -> 819 bytes res/drawable-hdpi/ic_em_image.png | Bin 549 -> 893 bytes res/drawable-hdpi/ic_em_music.png | Bin 522 -> 882 bytes res/drawable-hdpi/ic_em_video.png | Bin 437 -> 885 bytes res/drawable-mdpi/ic_em_all.png | Bin 212 -> 570 bytes res/drawable-mdpi/ic_em_application.png | Bin 0 -> 558 bytes res/drawable-mdpi/ic_em_document.png | Bin 264 -> 557 bytes res/drawable-mdpi/ic_em_image.png | Bin 365 -> 609 bytes res/drawable-mdpi/ic_em_music.png | Bin 310 -> 596 bytes res/drawable-mdpi/ic_em_video.png | Bin 324 -> 598 bytes res/drawable-xhdpi/ic_em_all.png | Bin 496 -> 1052 bytes res/drawable-xhdpi/ic_em_application.png | Bin 0 -> 1069 bytes res/drawable-xhdpi/ic_em_document.png | Bin 538 -> 1052 bytes res/drawable-xhdpi/ic_em_image.png | Bin 793 -> 1134 bytes res/drawable-xhdpi/ic_em_music.png | Bin 665 -> 1118 bytes res/drawable-xhdpi/ic_em_video.png | Bin 639 -> 1122 bytes res/drawable-xxhdpi/ic_em_all.png | Bin 730 -> 1611 bytes res/drawable-xxhdpi/ic_em_application.png | Bin 0 -> 1612 bytes res/drawable-xxhdpi/ic_em_document.png | Bin 771 -> 1589 bytes res/drawable-xxhdpi/ic_em_image.png | Bin 1038 -> 1753 bytes res/drawable-xxhdpi/ic_em_music.png | Bin 960 -> 1703 bytes res/drawable-xxhdpi/ic_em_video.png | Bin 876 -> 1690 bytes res/layout/navigation_view_simple_item.xml | 9 +++-- res/values/dimen.xml | 3 +- .../filemanager/activities/NavigationActivity.java | 42 ++++++++++----------- .../filemanager/activities/SearchActivity.java | 16 +++++++- 28 files changed, 41 insertions(+), 29 deletions(-) create mode 100644 res/drawable-hdpi/ic_em_application.png create mode 100644 res/drawable-mdpi/ic_em_application.png create mode 100644 res/drawable-xhdpi/ic_em_application.png create mode 100644 res/drawable-xxhdpi/ic_em_application.png diff --git a/res/drawable-hdpi/ic_em_all.png b/res/drawable-hdpi/ic_em_all.png index ff4b9e6e..9bfaa8e0 100644 Binary files a/res/drawable-hdpi/ic_em_all.png and b/res/drawable-hdpi/ic_em_all.png differ diff --git a/res/drawable-hdpi/ic_em_application.png b/res/drawable-hdpi/ic_em_application.png new file mode 100644 index 00000000..c4f8fb95 Binary files /dev/null and b/res/drawable-hdpi/ic_em_application.png differ diff --git a/res/drawable-hdpi/ic_em_document.png b/res/drawable-hdpi/ic_em_document.png index bc2f379e..9db7b805 100644 Binary files a/res/drawable-hdpi/ic_em_document.png and b/res/drawable-hdpi/ic_em_document.png differ diff --git a/res/drawable-hdpi/ic_em_image.png b/res/drawable-hdpi/ic_em_image.png index 8ed5a967..2e1195c1 100644 Binary files a/res/drawable-hdpi/ic_em_image.png and b/res/drawable-hdpi/ic_em_image.png differ diff --git a/res/drawable-hdpi/ic_em_music.png b/res/drawable-hdpi/ic_em_music.png index 433e9177..84fabd07 100644 Binary files a/res/drawable-hdpi/ic_em_music.png and b/res/drawable-hdpi/ic_em_music.png differ diff --git a/res/drawable-hdpi/ic_em_video.png b/res/drawable-hdpi/ic_em_video.png index 33e643e7..8eb4b4fe 100644 Binary files a/res/drawable-hdpi/ic_em_video.png and b/res/drawable-hdpi/ic_em_video.png differ diff --git a/res/drawable-mdpi/ic_em_all.png b/res/drawable-mdpi/ic_em_all.png index 029b7b6d..36413d83 100644 Binary files a/res/drawable-mdpi/ic_em_all.png and b/res/drawable-mdpi/ic_em_all.png differ diff --git a/res/drawable-mdpi/ic_em_application.png b/res/drawable-mdpi/ic_em_application.png new file mode 100644 index 00000000..5930616d Binary files /dev/null and b/res/drawable-mdpi/ic_em_application.png differ diff --git a/res/drawable-mdpi/ic_em_document.png b/res/drawable-mdpi/ic_em_document.png index 7fbf5971..e984be9d 100644 Binary files a/res/drawable-mdpi/ic_em_document.png and b/res/drawable-mdpi/ic_em_document.png differ diff --git a/res/drawable-mdpi/ic_em_image.png b/res/drawable-mdpi/ic_em_image.png index 980ca1e1..8b71289a 100644 Binary files a/res/drawable-mdpi/ic_em_image.png and b/res/drawable-mdpi/ic_em_image.png differ diff --git a/res/drawable-mdpi/ic_em_music.png b/res/drawable-mdpi/ic_em_music.png index f097e53e..ff345181 100644 Binary files a/res/drawable-mdpi/ic_em_music.png and b/res/drawable-mdpi/ic_em_music.png differ diff --git a/res/drawable-mdpi/ic_em_video.png b/res/drawable-mdpi/ic_em_video.png index 363842b0..bf6bac91 100644 Binary files a/res/drawable-mdpi/ic_em_video.png and b/res/drawable-mdpi/ic_em_video.png differ diff --git a/res/drawable-xhdpi/ic_em_all.png b/res/drawable-xhdpi/ic_em_all.png index 62fb95b0..a16c620b 100644 Binary files a/res/drawable-xhdpi/ic_em_all.png and b/res/drawable-xhdpi/ic_em_all.png differ diff --git a/res/drawable-xhdpi/ic_em_application.png b/res/drawable-xhdpi/ic_em_application.png new file mode 100644 index 00000000..ec6ac7c9 Binary files /dev/null and b/res/drawable-xhdpi/ic_em_application.png differ diff --git a/res/drawable-xhdpi/ic_em_document.png b/res/drawable-xhdpi/ic_em_document.png index 69f231bc..fe9f7bd0 100644 Binary files a/res/drawable-xhdpi/ic_em_document.png and b/res/drawable-xhdpi/ic_em_document.png differ diff --git a/res/drawable-xhdpi/ic_em_image.png b/res/drawable-xhdpi/ic_em_image.png index 94df1c30..8ec54fff 100644 Binary files a/res/drawable-xhdpi/ic_em_image.png and b/res/drawable-xhdpi/ic_em_image.png differ diff --git a/res/drawable-xhdpi/ic_em_music.png b/res/drawable-xhdpi/ic_em_music.png index d45579c2..883fd871 100644 Binary files a/res/drawable-xhdpi/ic_em_music.png and b/res/drawable-xhdpi/ic_em_music.png differ diff --git a/res/drawable-xhdpi/ic_em_video.png b/res/drawable-xhdpi/ic_em_video.png index edf281da..97e3c004 100644 Binary files a/res/drawable-xhdpi/ic_em_video.png and b/res/drawable-xhdpi/ic_em_video.png differ diff --git a/res/drawable-xxhdpi/ic_em_all.png b/res/drawable-xxhdpi/ic_em_all.png index e1b4c2e6..26c2de82 100644 Binary files a/res/drawable-xxhdpi/ic_em_all.png and b/res/drawable-xxhdpi/ic_em_all.png differ diff --git a/res/drawable-xxhdpi/ic_em_application.png b/res/drawable-xxhdpi/ic_em_application.png new file mode 100644 index 00000000..fc8eb152 Binary files /dev/null and b/res/drawable-xxhdpi/ic_em_application.png differ diff --git a/res/drawable-xxhdpi/ic_em_document.png b/res/drawable-xxhdpi/ic_em_document.png index 41f47cc2..9db02122 100644 Binary files a/res/drawable-xxhdpi/ic_em_document.png and b/res/drawable-xxhdpi/ic_em_document.png differ diff --git a/res/drawable-xxhdpi/ic_em_image.png b/res/drawable-xxhdpi/ic_em_image.png index 783e35fa..8318efab 100644 Binary files a/res/drawable-xxhdpi/ic_em_image.png and b/res/drawable-xxhdpi/ic_em_image.png differ diff --git a/res/drawable-xxhdpi/ic_em_music.png b/res/drawable-xxhdpi/ic_em_music.png index 79ee9bd5..453e7978 100644 Binary files a/res/drawable-xxhdpi/ic_em_music.png and b/res/drawable-xxhdpi/ic_em_music.png differ diff --git a/res/drawable-xxhdpi/ic_em_video.png b/res/drawable-xxhdpi/ic_em_video.png index e8653918..a3a62f30 100644 Binary files a/res/drawable-xxhdpi/ic_em_video.png and b/res/drawable-xxhdpi/ic_em_video.png differ diff --git a/res/layout/navigation_view_simple_item.xml b/res/layout/navigation_view_simple_item.xml index f985022a..7dbd3e5b 100644 --- a/res/layout/navigation_view_simple_item.xml +++ b/res/layout/navigation_view_simple_item.xml @@ -29,10 +29,12 @@ @@ -41,7 +43,6 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" - android:layout_marginLeft="@dimen/small_margin" android:layout_marginRight="@dimen/extra_margin" android:gravity="left|center_vertical" android:singleLine="true" diff --git a/res/values/dimen.xml b/res/values/dimen.xml index ef836b4b..a06e24e0 100644 --- a/res/values/dimen.xml +++ b/res/values/dimen.xml @@ -131,6 +131,7 @@ 3dp 10dp - 48dp + 40dp + 16dp diff --git a/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java b/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java index f7e769a4..5754f27c 100644 --- a/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java +++ b/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java @@ -435,6 +435,7 @@ public class NavigationActivity extends Activity add(VIDEO); add(AUDIO); add(DOCUMENT); + add(APP); } }; @@ -605,6 +606,8 @@ public class NavigationActivity extends Activity .ic_em_music)); EASY_MODE_ICONS.put(MimeTypeCategory.DOCUMENT, getResources().getDrawable(R.drawable .ic_em_document)); + EASY_MODE_ICONS.put(MimeTypeCategory.APP, getResources().getDrawable(R.drawable + .ic_em_application)); //Save state super.onCreate(state); @@ -1421,7 +1424,7 @@ public class NavigationActivity extends Activity @Override public View getView(int position, View convertView, ViewGroup parent) { convertView = (convertView == null) ?getLayoutInflater().inflate(R.layout - .navigation_view_simple_item, null, true) : convertView; + .navigation_view_simple_item, parent, false) : convertView; MimeTypeCategory item = getItem(position); String typeTitle = MIME_TYPE_LOCALIZED_NAMES[item.ordinal()]; TextView typeTitleTV = (TextView) convertView @@ -1447,28 +1450,23 @@ public class NavigationActivity extends Activity intent.putExtra(SearchActivity.EXTRA_SEARCH_DIRECTORY, getCurrentNavigationView().getCurrentDir()); intent.putExtra(SearchManager.QUERY, "*"); // Use wild-card '*' - switch (position) { - case 0: - performHideEasyMode(); - return; - case 1: - intent.putExtra(SearchActivity.EXTRA_SEARCH_MIMETYPE, - new MimeTypeCategory[] { MimeTypeCategory.IMAGE }); - break; - case 2: - intent.putExtra(SearchActivity.EXTRA_SEARCH_MIMETYPE, - new MimeTypeCategory[] { MimeTypeCategory.VIDEO }); - break; - case 3: - intent.putExtra(SearchActivity.EXTRA_SEARCH_MIMETYPE, - new MimeTypeCategory[] { MimeTypeCategory.AUDIO }); - break; - case 4: - // search for both DOCUMENT and TEXT mime types - MimeTypeCategory[] categories = { MimeTypeCategory.DOCUMENT, MimeTypeCategory.TEXT }; - intent.putExtra(SearchActivity.EXTRA_SEARCH_MIMETYPE, categories); - break; + + if (position == 0) { + performHideEasyMode(); + return; + + } else { + ArrayList searchCategories = new ArrayList(); + MimeTypeCategory selectedCategory = EASY_MODE_LIST.get(position); + searchCategories.add(selectedCategory); + // a one off case where we implicitly want to also search for TEXT mimetypes when the + // DOCUMENTS category is selected + if (selectedCategory == MimeTypeCategory.DOCUMENT) { + searchCategories.add(MimeTypeCategory.TEXT); + } + intent.putExtra(SearchActivity.EXTRA_SEARCH_MIMETYPE, searchCategories); } + startActivity(intent); } diff --git a/src/com/cyanogenmod/filemanager/activities/SearchActivity.java b/src/com/cyanogenmod/filemanager/activities/SearchActivity.java index 63e47998..7c6bb2f2 100644 --- a/src/com/cyanogenmod/filemanager/activities/SearchActivity.java +++ b/src/com/cyanogenmod/filemanager/activities/SearchActivity.java @@ -479,6 +479,10 @@ public class SearchActivity extends Activity //Set out transition overridePendingTransition(R.anim.hold_in, R.anim.translate_to_left_out); super.onPause(); + // stop search if the activity moves out of the foreground + if (mExecutable != null) { + mExecutable.cancel(); + } } /** @@ -621,10 +625,10 @@ public class SearchActivity extends Activity Serializable mimeTypeExtra = getIntent().getSerializableExtra(EXTRA_SEARCH_MIMETYPE); if (mimeTypeExtra != null) { - MimeTypeCategory[] categories = (MimeTypeCategory[]) getIntent() + ArrayList categories = (ArrayList) getIntent() .getSerializableExtra(EXTRA_SEARCH_MIMETYPE); // setting load factor to 1 to avoid the backing map's resizing - mMimeTypeCategories = new HashSet(categories.length, 1); + mMimeTypeCategories = new HashSet(categories.size(), 1); for (MimeTypeCategory category : categories) { mMimeTypeCategories.add(category); } @@ -967,6 +971,10 @@ public class SearchActivity extends Activity public boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: + // release Console lock held by the async search task + if (mExecutable != null) { + mExecutable.cancel(); + } back(true, null, false); return true; default: @@ -981,6 +989,10 @@ public class SearchActivity extends Activity public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: + // release Console lock held by the async search task + if (mExecutable != null) { + mExecutable.cancel(); + } back(true, null, false); return true; default: -- cgit v1.2.3