aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Bird <sbird@cyngn.com>2015-07-31 14:57:24 -0700
committerSteve Kondik <steve@cyngn.com>2016-11-02 21:21:42 -0700
commit2892dc60c727ef3e9bd2d3118061ae07c4a20732 (patch)
tree58604fdf24792324e4fbc3868cb05ab288ecada4
parent27c778a6bf2f91eb2df6c6673996f34922f22df1 (diff)
downloadandroid_packages_apps_CMFileManager-2892dc60c727ef3e9bd2d3118061ae07c4a20732.tar.gz
android_packages_apps_CMFileManager-2892dc60c727ef3e9bd2d3118061ae07c4a20732.tar.bz2
android_packages_apps_CMFileManager-2892dc60c727ef3e9bd2d3118061ae07c4a20732.zip
Quick Search: Bring Design up to par
Change-Id: I5fd21e4bdc916e11a37e465d25ce040831190e34
-rw-r--r--res/layout/home_fragment.xml15
-rw-r--r--res/layout/quick_search_item.xml38
-rw-r--r--res/values/dimen.xml7
-rw-r--r--res/values/strings.xml11
-rwxr-xr-xsrc/com/cyanogenmod/filemanager/activities/MainActivity.java136
-rwxr-xr-xsrc/com/cyanogenmod/filemanager/activities/SearchActivity.java3
-rw-r--r--src/com/cyanogenmod/filemanager/adapters/QuickSearchAdapter.java163
-rw-r--r--src/com/cyanogenmod/filemanager/util/MimeTypeHelper.java46
8 files changed, 290 insertions, 129 deletions
diff --git a/res/layout/home_fragment.xml b/res/layout/home_fragment.xml
index 383c8b15..2dc24c03 100644
--- a/res/layout/home_fragment.xml
+++ b/res/layout/home_fragment.xml
@@ -48,12 +48,23 @@
</android.support.v7.widget.CardView>
+ <TextView
+ android:text="@string/quick_search"
+ android:id="@+id/cardChildText"
+ android:textSize="14sp"
+ android:layout_marginStart="@dimen/quick_search_text_margin_left"
+ android:layout_marginTop="@dimen/quick_search_text_margin_top"
+ android:layout_marginBottom="@dimen/quick_search_text_margin_top"
+ android:layout_gravity="center_vertical"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/quick_search_text_height" />
+
<com.cyanogenmod.filemanager.ui.widgets.WrappedGridView
- android:id="@+id/easy_modeView"
+ android:id="@+id/quick_search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnWidth="90dp"
- android:numColumns="auto_fit"
+ android:numColumns="3"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
diff --git a/res/layout/quick_search_item.xml b/res/layout/quick_search_item.xml
new file mode 100644
index 00000000..7395ba9c
--- /dev/null
+++ b/res/layout/quick_search_item.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The CyanogenMod Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/navigation_view_details_item"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/quick_search_grid"
+ android:orientation="vertical">
+
+ <com.cyanogenmod.filemanager.ui.widgets.FixedSizeImageView
+ android:id="@+id/navigation_view_item_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical|center_horizontal"
+ android:scaleType="center"
+ android:contentDescription="@null"
+ android:src="@null" />
+
+ <TextView
+ android:id="@+id/navigation_view_item_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical|center_horizontal" />
+
+</LinearLayout>
diff --git a/res/values/dimen.xml b/res/values/dimen.xml
index bdbe1035..f2b918fb 100644
--- a/res/values/dimen.xml
+++ b/res/values/dimen.xml
@@ -192,4 +192,11 @@
<!-- Search -->
<dimen name="search_bar_height">48dp</dimen>
<dimen name="search_image_dimensions">24dp</dimen>
+
+ <!-- The quick search grid -->
+ <dimen name="quick_search_grid">80dp</dimen>
+ <dimen name="quick_search_text_margin_left">16dp</dimen>
+ <dimen name="quick_search_text_margin_top">15dp</dimen>
+ <dimen name="quick_search_text_height">16dp</dimen>
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 98022ed3..203b819b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -922,7 +922,16 @@
<string name="snackbar_unable_to_complete">Unable to complete action</string>
<string name="snackbar_retry">RETRY</string>
<string name="snackbar_upgrade">UPGRADE</string>
-
+
<!-- File System info -->
<string name="file_system_info_unavailable">Unable to fetch file system info for this path</string>
+
+ <!-- Quick search strings -->
+ <string name="quick_search">Quick Search</string>
+ <string name="images">Images</string>
+ <string name="audio">Audio</string>
+ <string name="videos">Videos</string>
+ <string name="docs">Docs</string>
+ <string name="apps">Apps</string>
+ <string name="archives">Archives</string>
</resources>
diff --git a/src/com/cyanogenmod/filemanager/activities/MainActivity.java b/src/com/cyanogenmod/filemanager/activities/MainActivity.java
index 619f02bf..a6bba46e 100755
--- a/src/com/cyanogenmod/filemanager/activities/MainActivity.java
+++ b/src/com/cyanogenmod/filemanager/activities/MainActivity.java
@@ -26,7 +26,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
-import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.nfc.NfcAdapter;
import android.os.Bundle;
@@ -51,16 +50,15 @@ import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.SearchView;
import android.widget.TextView;
-import android.widget.Toast;
import com.cyanogenmod.filemanager.FileManagerApplication;
import com.cyanogenmod.filemanager.R;
import com.cyanogenmod.filemanager.activities.preferences.SettingsPreferences;
+import com.cyanogenmod.filemanager.adapters.QuickSearchAdapter;
import com.cyanogenmod.filemanager.controllers.NavigationDrawerController;
import com.cyanogenmod.filemanager.model.Bookmark;
import com.cyanogenmod.filemanager.model.FileSystemObject;
@@ -71,8 +69,6 @@ import com.cyanogenmod.filemanager.ui.fragments.NavigationFragment;
import com.cyanogenmod.filemanager.ui.fragments.NavigationFragment.OnGoHomeRequestListener;
import com.cyanogenmod.filemanager.ui.widgets.NavigationView.OnBackRequestListener;
import com.cyanogenmod.filemanager.util.FileHelper;
-import com.cyanogenmod.filemanager.util.MimeTypeHelper;
-import com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory;
import com.cyanogenmod.filemanager.util.StorageHelper;
import java.io.File;
@@ -80,13 +76,6 @@ import java.io.InvalidClassException;
import java.util.ArrayList;
import java.util.List;
-import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.APP;
-import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.AUDIO;
-import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.DOCUMENT;
-import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.IMAGE;
-import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.NONE;
-import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.VIDEO;
-
/**
* The main navigation activity. This activity is the center of the application.
* From this the user can navigate, search, make actions.<br/>
@@ -141,32 +130,8 @@ public class MainActivity extends ActionBarActivity
public static final String EXTRA_ADD_TO_HISTORY =
"extra_add_to_history"; //$NON-NLS-1$
- static java.util.Map<MimeTypeCategory, Drawable> EASY_MODE_ICONS = new
- java.util.HashMap<MimeTypeCategory, Drawable>();
-
- private static final List<MimeTypeCategory> EASY_MODE_LIST = new ArrayList<MimeTypeCategory>() {
- {
- add(NONE);
- add(IMAGE);
- add(VIDEO);
- add(AUDIO);
- add(DOCUMENT);
- add(APP);
- }
- };
-
private Toolbar mToolBar;
- private ArrayAdapter<MimeTypeCategory> mEasyModeAdapter;
-
- private View.OnClickListener mEasyModeItemClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Integer position = (Integer) view.getTag();
- onClicked(position);
- }
- };
-
/**
* Fragment types
*/
@@ -178,8 +143,6 @@ public class MainActivity extends ActionBarActivity
NAVIGATION,
}
- static String MIME_TYPE_LOCALIZED_NAMES[];
-
private Fragment currentFragment;
private DrawerLayout mDrawerLayout;
private NavigationDrawerController mNavigationDrawerController;
@@ -317,8 +280,6 @@ public class MainActivity extends ActionBarActivity
(NavigationView) findViewById(R.id.navigation_view);
mNavigationDrawerController = new NavigationDrawerController(this, navigationDrawer);
- MIME_TYPE_LOCALIZED_NAMES = MimeTypeCategory.getFriendlyLocalizedNames(this);
-
showWelcomeMsg();
//FragmentManager.OnBackStackChangedListener
@@ -330,7 +291,7 @@ public class MainActivity extends ActionBarActivity
});
handleSearchBar();
-
+ initQuickSearch();
setHomeStatusBarColor();
//Initialize nfc adapter
@@ -580,87 +541,13 @@ public class MainActivity extends ActionBarActivity
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu);
-
- initEasyModePlus();
- }
-
- private void initEasyModePlus() {
-
- MIME_TYPE_LOCALIZED_NAMES = MimeTypeCategory.getFriendlyLocalizedNames(this);
- EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.NONE, getResources().getDrawable(
- R.drawable.ic_em_all));
- EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.IMAGE, getResources().getDrawable(
- R.drawable.ic_em_image));
- EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.VIDEO, getResources().getDrawable(
- R.drawable.ic_em_video));
- EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.AUDIO, getResources().getDrawable(
- R.drawable.ic_em_music));
- EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.DOCUMENT, getResources().getDrawable(
- R.drawable.ic_em_document));
- EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.APP, getResources().getDrawable(
- R.drawable.ic_em_application));
-
- GridView gridview = (GridView) findViewById(R.id.easy_modeView);
-
- mEasyModeAdapter = new android.widget.ArrayAdapter<MimeTypeCategory>(this, R.layout
- .navigation_view_simple_item) {
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- convertView = (convertView == null) ? getLayoutInflater().inflate(R.layout
- .navigation_view_simple_item, parent, false) : convertView;
- MimeTypeCategory item = getItem(position);
- String typeTitle = MIME_TYPE_LOCALIZED_NAMES[item.ordinal()];
- TextView typeTitleTV = (TextView) convertView
- .findViewById(R.id.navigation_view_item_name);
- ImageView typeIconIV = (ImageView) convertView
- .findViewById(R.id.navigation_view_item_icon);
-
- typeTitleTV.setText(typeTitle);
- typeIconIV.setImageDrawable(EASY_MODE_ICONS.get(item));
- convertView.setOnClickListener(mEasyModeItemClickListener);
- convertView.setTag(position);
- return convertView;
- }
- };
- mEasyModeAdapter.addAll(EASY_MODE_LIST);
- gridview.setAdapter(mEasyModeAdapter);
-
- gridview.setOnItemClickListener(new OnItemClickListener() {
- public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
- Toast.makeText(MainActivity.this, "" + position, Toast.LENGTH_SHORT).show();
- }
- });
}
- private void onClicked(int position) {
- Intent intent = new Intent(this, SearchActivity.class);
- intent.setAction(Intent.ACTION_SEARCH);
- intent.putExtra(SearchActivity.EXTRA_SEARCH_DIRECTORY, FileHelper.ROOT_DIRECTORY);
- intent.putExtra(SearchManager.QUERY, "*"); // Use wild-card '*'
-
- if (position == 0) {
- FragmentManager fragmentManager = getSupportFragmentManager();
-
- fragmentManager.beginTransaction()
- .replace(R.id.navigation_fragment_container, new NavigationFragment())
- .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
- .commit();
- return;
-
- } else {
- ArrayList<MimeTypeCategory> searchCategories = new ArrayList<MimeTypeCategory>();
- 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);
+ private void initQuickSearch() {
+ GridView gridview = (GridView) findViewById(R.id.quick_search_view);
+ QuickSearchAdapter quickSearchAdapter = new QuickSearchAdapter(this, R.layout.quick_search_item);
+ quickSearchAdapter.addAll(quickSearchAdapter.QUICK_SEARCH_LIST);
+ gridview.setAdapter(quickSearchAdapter);
}
@Override
@@ -733,19 +620,18 @@ public class MainActivity extends ActionBarActivity
public void onActionBarItemClick(android.view.View view) {
if (currentFragment instanceof NavigationFragment) {
-
+ NavigationFragment navigationFragment = ((NavigationFragment)currentFragment);
switch (view.getId()) {
//######################
//Selection Actions
//######################
- case com.cyanogenmod.filemanager.R.id.ab_selection_done:
+ case R.id.ab_selection_done:
//Show information of the filesystem
- ((NavigationFragment)currentFragment)
- .getCurrentNavigationView().onDeselectAll();
+ navigationFragment.getCurrentNavigationView().onDeselectAll();
break;
case R.id.ab_actions:
// Show the actions dialog
- ((NavigationFragment) currentFragment).openActionsDialog(null, true);
+ navigationFragment.openActionsDialog(null, true);
default:
break;
}
diff --git a/src/com/cyanogenmod/filemanager/activities/SearchActivity.java b/src/com/cyanogenmod/filemanager/activities/SearchActivity.java
index 0449c999..b3f31554 100755
--- a/src/com/cyanogenmod/filemanager/activities/SearchActivity.java
+++ b/src/com/cyanogenmod/filemanager/activities/SearchActivity.java
@@ -754,7 +754,8 @@ public class SearchActivity extends Activity
ArrayList<String> localizedNames = new ArrayList<String>(mMimeTypeCategories.size());
for (MimeTypeCategory category : mMimeTypeCategories) {
localizedNames
- .add(MainActivity.MIME_TYPE_LOCALIZED_NAMES[category.ordinal()]);
+ .add(MimeTypeHelper.MimeTypeCategory
+ .getFriendlyLocalizedNames(this)[category.ordinal()]);
}
this.mSearchTerms.setText(
Html.fromHtml(getString(R.string.search_terms, localizedNames)));
diff --git a/src/com/cyanogenmod/filemanager/adapters/QuickSearchAdapter.java b/src/com/cyanogenmod/filemanager/adapters/QuickSearchAdapter.java
new file mode 100644
index 00000000..15835522
--- /dev/null
+++ b/src/com/cyanogenmod/filemanager/adapters/QuickSearchAdapter.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2015 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.filemanager.adapters;
+
+import android.app.SearchManager;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.ColorStateList;
+import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.StateListDrawable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+import com.cyanogenmod.filemanager.R;
+import com.cyanogenmod.filemanager.activities.SearchActivity;
+import com.cyanogenmod.filemanager.ui.IconHolder;
+import com.cyanogenmod.filemanager.util.FileHelper;
+import com.cyanogenmod.filemanager.util.MimeTypeHelper;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.APP;
+import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.COMPRESS;
+import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.IMAGE;
+import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.AUDIO;
+import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.VIDEO;
+import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.DOCUMENT;
+
+public class QuickSearchAdapter extends ArrayAdapter<MimeTypeHelper.MimeTypeCategory>
+ implements View.OnClickListener {
+
+ static String MIME_TYPE_LOCALIZED_NAMES[];
+
+ static Map<MimeTypeHelper.MimeTypeCategory, Integer> QUICK_SEARCH_ICONS
+ = new HashMap<MimeTypeHelper.MimeTypeCategory, Integer>();
+ static {
+ QUICK_SEARCH_ICONS.put(MimeTypeHelper.MimeTypeCategory.IMAGE,
+ R.drawable.ic_category_images);
+ QUICK_SEARCH_ICONS.put(MimeTypeHelper.MimeTypeCategory.AUDIO, R.drawable.ic_category_audio);
+ QUICK_SEARCH_ICONS.put(MimeTypeHelper.MimeTypeCategory.VIDEO, R.drawable.ic_category_video);
+ QUICK_SEARCH_ICONS.put(MimeTypeHelper.MimeTypeCategory.DOCUMENT,
+ R.drawable.ic_category_docs);
+ QUICK_SEARCH_ICONS.put(MimeTypeHelper.MimeTypeCategory.APP, R.drawable.ic_category_apps);
+ QUICK_SEARCH_ICONS.put(MimeTypeHelper.MimeTypeCategory.COMPRESS,
+ R.drawable.ic_category_archives);
+ }
+
+ public static final List<MimeTypeHelper.MimeTypeCategory> QUICK_SEARCH_LIST
+ = new ArrayList<MimeTypeHelper.MimeTypeCategory>() {
+ {
+ add(IMAGE);
+ add(AUDIO);
+ add(VIDEO);
+ add(DOCUMENT);
+ add(APP);
+ add(COMPRESS);
+ }
+ };
+
+ IconHolder mIconHolder;
+
+ public QuickSearchAdapter(Context context, int resource) {
+ super(context, resource);
+
+ MIME_TYPE_LOCALIZED_NAMES =
+ MimeTypeHelper.MimeTypeCategory.getDefinedLocalizedNames(context);
+ mIconHolder = new IconHolder(context, false);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ convertView = (convertView == null) ? LayoutInflater.from(getContext()).inflate(
+ R.layout.quick_search_item, parent, false) : convertView;
+
+ MimeTypeHelper.MimeTypeCategory item = getItem(position);
+ String typeTitle = MIME_TYPE_LOCALIZED_NAMES[item.ordinal()];
+ TextView typeTitleTV = (TextView) convertView
+ .findViewById(R.id.navigation_view_item_name);
+ ImageView typeIconIV = (ImageView) convertView
+ .findViewById(R.id.navigation_view_item_icon);
+
+ typeTitleTV.setText(typeTitle);
+ convertView.setOnClickListener(this);
+ convertView.setTag(position);
+
+ int colorId = MimeTypeHelper.getIconColorFromIconId(getContext(), QUICK_SEARCH_ICONS.get(item));
+ setIcon(typeIconIV, getContext().getResources().getDrawable(QUICK_SEARCH_ICONS.get(item)),
+ R.color.navigation_view_icon_unselected, R.drawable.ic_icon_background,
+ getContext().getResources().getColor(colorId));
+
+ return convertView;
+ }
+
+ // Set drawable as icon
+ private void setIcon(ImageView view, Drawable iconDrawable, int iconColorId, int backgroundId,
+ int backgroundColor) {
+
+ StateListDrawable stateListDrawable = new StateListDrawable();
+ addUnselected(getContext().getResources(), stateListDrawable, iconDrawable, iconColorId);
+
+ ColorStateList colorList = new ColorStateList(
+ new int[][]{new int[]{android.R.attr.state_selected},
+ new int[]{}},
+ new int[]{getContext().getResources()
+ .getColor(R.color.navigation_view_icon_selected), backgroundColor});
+
+ view.setBackgroundResource(backgroundId);
+ view.setBackgroundTintList(colorList);
+ view.setImageDrawable(stateListDrawable);
+ }
+
+ // default
+ private void addUnselected(Resources res, StateListDrawable drawable, Drawable iconDrawable,
+ int colorId) {
+ iconDrawable.setTint(res.getColor(colorId));
+ drawable.addState(new int[0], iconDrawable);
+ }
+
+ @Override
+ public void onClick(View view) {
+ Integer position = (Integer) view.getTag();
+
+ Intent intent = new Intent(getContext(), SearchActivity.class);
+ intent.setAction(Intent.ACTION_SEARCH);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_DIRECTORY, FileHelper.ROOT_DIRECTORY);
+ intent.putExtra(SearchManager.QUERY, "*"); // Use wild-card '*'
+
+ ArrayList<MimeTypeHelper.MimeTypeCategory> searchCategories =
+ new ArrayList<MimeTypeHelper.MimeTypeCategory>();
+ MimeTypeHelper.MimeTypeCategory selectedCategory = QUICK_SEARCH_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 == MimeTypeHelper.MimeTypeCategory.DOCUMENT) {
+ searchCategories.add(
+ MimeTypeHelper.MimeTypeCategory.TEXT);
+ }
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_MIMETYPE, searchCategories);
+
+ getContext().startActivity(intent);
+ }
+} \ No newline at end of file
diff --git a/src/com/cyanogenmod/filemanager/util/MimeTypeHelper.java b/src/com/cyanogenmod/filemanager/util/MimeTypeHelper.java
index e6a945d6..5dcb81f8 100644
--- a/src/com/cyanogenmod/filemanager/util/MimeTypeHelper.java
+++ b/src/com/cyanogenmod/filemanager/util/MimeTypeHelper.java
@@ -115,6 +115,14 @@ public final class MimeTypeHelper {
*/
SECURITY;
+ private static final String CAT_IMAGE = "IMAGE";
+ private static final String CAT_AUDIO = "AUDIO";
+ private static final String CAT_VIDEO = "VIDEO";
+ private static final String CAT_DOCUMENT = "DOCUMENT";
+ private static final String CAT_APP = "APP";
+ private static final String CAT_COMPRESS = "COMPRESS";
+ private static final String CAT_ALL = "-";
+
public static String[] names() {
MimeTypeCategory[] categories = values();
String[] names = new String[categories.length];
@@ -142,6 +150,44 @@ public final class MimeTypeHelper {
return localizedNames;
}
+
+ public static String[] getDefinedLocalizedNames(Context context) {
+ MimeTypeCategory[] categories = values();
+ String[] localizedNames = new String[categories.length];
+
+ for (int i = 0; i < categories.length; i++) {
+ String description = getCategoryDescription(context, categories[i]);
+ switch (description) {
+ case CAT_IMAGE:
+ description = context.getString(R.string.images);
+ break;
+ case CAT_AUDIO:
+ description = context.getString(R.string.audio);
+ break;
+ case CAT_VIDEO:
+ description = context.getString(R.string.videos);
+ break;
+ case CAT_DOCUMENT:
+ description = context.getString(R.string.docs);
+ break;
+ case CAT_APP:
+ description = context.getString(R.string.apps);
+ break;
+ case CAT_COMPRESS:
+ description = context.getString(R.string.archives);
+ break;
+ case CAT_ALL:
+ description = context.getString(R.string.category_all);
+ break;
+ }
+ description = description.substring(0, 1).toUpperCase()
+ + description.substring(1).toLowerCase();
+ localizedNames[i] = description;
+ }
+
+ return localizedNames;
+ }
+
}
/**