package com.cyanogenmod.filemanager.activities;
-import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
+import android.app.Dialog;
import android.app.SearchManager;
import android.content.BroadcastReceiver;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.database.Cursor;
+import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.nfc.NfcAdapter;
import android.nfc.NfcEvent;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.Environment;
import android.os.Handler;
import android.os.Parcelable;
import android.os.storage.StorageVolume;
+import android.support.v4.app.ActionBarDrawerToggle;
+import android.support.v4.widget.DrawerLayout;
+import android.text.TextUtils;
import android.util.Log;
+import android.view.Gravity;
import android.view.KeyEvent;
-import android.view.Menu;
-import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
+import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListPopupWindow;
+import android.widget.ListView;
import android.widget.PopupWindow;
-import android.widget.ScrollView;
+import android.widget.SearchView;
import android.widget.TextView;
import android.widget.Toast;
+import android.widget.Toolbar;
+import android.widget.ArrayAdapter;
import com.android.internal.util.XmlUtils;
import com.cyanogenmod.filemanager.FileManagerApplication;
import com.cyanogenmod.filemanager.R;
import com.cyanogenmod.filemanager.activities.preferences.SettingsPreferences;
-import com.cyanogenmod.filemanager.adapters.HighlightedSimpleMenuListAdapter;
import com.cyanogenmod.filemanager.adapters.MenuSettingsAdapter;
-import com.cyanogenmod.filemanager.adapters.SimpleMenuListAdapter;
import com.cyanogenmod.filemanager.console.Console;
import com.cyanogenmod.filemanager.console.ConsoleAllocException;
import com.cyanogenmod.filemanager.console.ConsoleBuilder;
import com.cyanogenmod.filemanager.console.InsufficientPermissionsException;
import com.cyanogenmod.filemanager.console.NoSuchFileOrDirectory;
+import com.cyanogenmod.filemanager.console.VirtualConsole;
+import com.cyanogenmod.filemanager.console.VirtualMountPointConsole;
+import com.cyanogenmod.filemanager.console.secure.SecureConsole;
import com.cyanogenmod.filemanager.listeners.OnHistoryListener;
import com.cyanogenmod.filemanager.listeners.OnRequestRefreshListener;
import com.cyanogenmod.filemanager.model.Bookmark;
import com.cyanogenmod.filemanager.ui.dialogs.FilesystemInfoDialog;
import com.cyanogenmod.filemanager.ui.dialogs.InitialDirectoryDialog;
import com.cyanogenmod.filemanager.ui.dialogs.FilesystemInfoDialog.OnMountListener;
-import com.cyanogenmod.filemanager.ui.widgets.ActionBarDrawerToggle;
import com.cyanogenmod.filemanager.ui.widgets.Breadcrumb;
import com.cyanogenmod.filemanager.ui.widgets.ButtonItem;
-import com.cyanogenmod.filemanager.ui.widgets.DrawerLayout;
import com.cyanogenmod.filemanager.ui.widgets.NavigationCustomTitleView;
import com.cyanogenmod.filemanager.ui.widgets.NavigationView;
import com.cyanogenmod.filemanager.ui.widgets.NavigationView.OnNavigationRequestMenuListener;
import com.cyanogenmod.filemanager.util.ExceptionUtil;
import com.cyanogenmod.filemanager.util.ExceptionUtil.OnRelaunchCommandResult;
import com.cyanogenmod.filemanager.util.FileHelper;
+import com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory;
import com.cyanogenmod.filemanager.util.StorageHelper;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
+
+import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.*;
/**
* The main navigation activity. This activity is the center of the application.
private static final String TAG_BOOKMARKS = "Bookmarks"; //$NON-NLS-1$
private static final String TAG_BOOKMARK = "bookmark"; //$NON-NLS-1$
+ private static final String STR_USB = "usb"; // $NON-NLS-1$
+
/**
* Intent code for request a search.
*/
public static final String EXTRA_NAVIGATE_TO =
"extra_navigate_to"; //$NON-NLS-1$
+ /**
+ * Constant for extra information for request to add navigation to the history
+ */
+ public static final String EXTRA_ADD_TO_HISTORY =
+ "extra_add_to_history"; //$NON-NLS-1$
+
// The timeout needed to reset the exit status for back button
// After this time user need to tap 2 times the back button to
// exit, and the toast is shown again after the first tap.
private static final int RELEASE_EXIT_CHECK_TIMEOUT = 3500;
+
+ private Toolbar mToolBar;
+ private SearchView mSearchView;
+ private NavigationCustomTitleView mCustomTitleView;
+ private InputMethodManager mImm;
+
private final BroadcastReceiver mNotificationReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
}
}
+ // Restricted access
+ if (key.compareTo(FileManagerSettings.
+ SETTINGS_RESTRICT_SECONDARY_USERS_ACCESS.getId()) == 0) {
+ if (AndroidHelper.isSecondaryUser(context)) {
+ try {
+ Preferences.savePreference(
+ FileManagerSettings.SETTINGS_ACCESS_MODE,
+ AccessMode.SAFE, true);
+ } catch (Throwable ex) {
+ Log.w(TAG, "can't save console preference", ex); //$NON-NLS-1$
+ }
+ ConsoleBuilder.changeToNonPrivilegedConsole(context);
+ createChRooted();
+ }
+ }
+
// Filetime format mode
if (key.compareTo(FileManagerSettings.
SETTINGS_FILETIME_FORMAT_MODE.getId()) == 0) {
} else if (intent.getAction().compareTo(Intent.ACTION_TIME_CHANGED) == 0 ||
intent.getAction().compareTo(Intent.ACTION_DATE_CHANGED) == 0 ||
- intent.getAction().compareTo(Intent.ACTION_TIMEZONE_CHANGED) == 0) {
+ intent.getAction().compareTo(Intent.ACTION_TIMEZONE_CHANGED) == 0 ||
+ intent.getAction().compareTo(Intent.ACTION_LOCALE_CHANGED) == 0) {
// Refresh the data
synchronized (FileHelper.DATETIME_SYNC) {
FileHelper.sReloadDateTimeFormats = true;
NavigationActivity.this.getCurrentNavigationView().refresh();
}
+ } else if (intent.getAction().compareTo(
+ FileManagerSettings.INTENT_MOUNT_STATUS_CHANGED) == 0 ||
+ intent.getAction().equals(Intent.ACTION_MEDIA_MOUNTED) ||
+ intent.getAction().equals(Intent.ACTION_MEDIA_UNMOUNTED)) {
+ onRequestBookmarksRefresh();
+ removeUnmountedHistory();
+ removeUnmountedSelection();
}
}
}
};
+ private OnClickListener mOnClickDrawerTabListener = new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.drawer_bookmarks_tab:
+ if (!mBookmarksTab.isSelected()) {
+ mBookmarksTab.setSelected(true);
+ mHistoryTab.setSelected(false);
+ mBookmarksTab.setTextAppearance(
+ NavigationActivity.this, R.style.primary_text_appearance);
+ mHistoryTab.setTextAppearance(
+ NavigationActivity.this, R.style.secondary_text_appearance);
+ mHistoryLayout.setVisibility(View.GONE);
+ mBookmarksLayout.setVisibility(View.VISIBLE);
+ applyTabTheme();
+
+ try {
+ Preferences.savePreference(FileManagerSettings.USER_PREF_LAST_DRAWER_TAB,
+ Integer.valueOf(0), true);
+ } catch (Exception ex) {
+ Log.e(TAG, "Can't save last drawer tab", ex); //$NON-NLS-1$
+ }
+
+ mClearHistory.setVisibility(View.GONE);
+ }
+ break;
+ case R.id.drawer_history_tab:
+ if (!mHistoryTab.isSelected()) {
+ mHistoryTab.setSelected(true);
+ mBookmarksTab.setSelected(false);
+ mHistoryTab.setTextAppearance(
+ NavigationActivity.this, R.style.primary_text_appearance);
+ mBookmarksTab.setTextAppearance(
+ NavigationActivity.this, R.style.secondary_text_appearance);
+ mBookmarksLayout.setVisibility(View.GONE);
+ mHistoryLayout.setVisibility(View.VISIBLE);
+ applyTabTheme();
+
+ try {
+ Preferences.savePreference(FileManagerSettings.USER_PREF_LAST_DRAWER_TAB,
+ Integer.valueOf(1), true);
+ } catch (Exception ex) {
+ Log.e(TAG, "Can't save last drawer tab", ex); //$NON-NLS-1$
+ }
+
+ mClearHistory.setVisibility(mHistory.size() > 0 ? View.VISIBLE : View.GONE);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ };
+
+ private OnClickListener mOnClickDrawerActionBarListener = new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.ab_settings:
+ mDrawerLayout.closeDrawer(Gravity.START);
+ openSettings();
+ break;
+ case R.id.ab_clear_history:
+ clearHistory();
+ mClearHistory.setVisibility(View.GONE);
+ break;
+ default:
+ break;
+ }
+ }
+ };
+
+ static String MIME_TYPE_LOCALIZED_NAMES[];
+ /**
+ * @hide
+ */
+ static Map<MimeTypeCategory, Drawable> EASY_MODE_ICONS = new
+ HashMap<MimeTypeCategory, Drawable>();
+
/**
* @hide
*/
NavigationView[] mNavigationViews;
+ /**
+ * @hide
+ */
+ ListView mEasyModeListView;
private List<History> mHistory;
+ private static final List<MimeTypeCategory> EASY_MODE_LIST = new ArrayList<MimeTypeCategory>() {
+ {
+ add(NONE);
+ add(IMAGE);
+ add(VIDEO);
+ add(AUDIO);
+ add(DOCUMENT);
+ add(APP);
+ }
+ };
+
+ private ArrayAdapter<MimeTypeCategory> mEasyModeAdapter;
+ private View.OnClickListener mEasyModeItemClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Integer position = (Integer) view.getTag();
+ onClicked(position);
+ }
+ };
+
private int mCurrentNavigationView;
private ViewGroup mActionBar;
private SelectionView mSelectionBar;
private DrawerLayout mDrawerLayout;
- private ScrollView mDrawer;
+ private ViewGroup mDrawer;
private ActionBarDrawerToggle mDrawerToggle;
private LinearLayout mDrawerHistory;
private TextView mDrawerHistoryEmpty;
+ private TextView mBookmarksTab;
+ private TextView mHistoryTab;
+ private View mBookmarksLayout;
+ private View mHistoryLayout;
+
+ private ButtonItem mSettings;
+ private ButtonItem mClearHistory;
+
private List<Bookmark> mBookmarks;
+ private List<Bookmark> mSdBookmarks;
private LinearLayout mDrawerBookmarks;
private boolean mExitFlag = false;
private long mExitBackTimeout = -1;
- private View mOptionsAnchorView;
+ private Dialog mActiveDialog = null;
private int mOrientation;
+ private boolean mNeedsEasyMode = false;
+
/**
* @hide
*/
*/
Handler mHandler;
+ private AsyncTask<Void, Void, Boolean> mBookmarksTask;
+
/**
* {@inheritDoc}
*/
filter.addAction(Intent.ACTION_DATE_CHANGED);
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
+ filter.addAction(Intent.ACTION_LOCALE_CHANGED);
+ filter.addAction(FileManagerSettings.INTENT_MOUNT_STATUS_CHANGED);
registerReceiver(this.mNotificationReceiver, filter);
+ // This filter needs the file data scheme, so it must be defined separately.
+ IntentFilter newFilter = new IntentFilter();
+ newFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
+ newFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
+ newFilter.addDataScheme(ContentResolver.SCHEME_FILE);
+ registerReceiver(mNotificationReceiver, newFilter);
+
+ //the input manager service
+ mImm = (InputMethodManager) this.getSystemService(
+ Context.INPUT_METHOD_SERVICE);
+
// Set the theme before setContentView
Theme theme = ThemeManager.getCurrentTheme(this);
- theme.setBaseTheme(this, false);
+ theme.setBaseThemeNoActionBar(this);
//Set the main layout of the activity
setContentView(R.layout.navigation);
//Navigation views
initNavigationViews();
+ // As we're using a Toolbar, we should retrieve it and set it
+ // to be our ActionBar
+ mToolBar = (Toolbar) findViewById(R.id.material_toolbar);
+ setActionBar(mToolBar);
+
//Initialize action bars
initTitleActionBar();
initStatusActionBar();
}
});
+ MIME_TYPE_LOCALIZED_NAMES = MimeTypeCategory.getFriendlyLocalizedNames(NavigationActivity
+ .this);
+
+ EASY_MODE_ICONS.put(MimeTypeCategory.NONE, getResources().getDrawable(R.drawable
+ .ic_em_all));
+ EASY_MODE_ICONS.put(MimeTypeCategory.IMAGE, getResources().getDrawable(R.drawable
+ .ic_em_image));
+ EASY_MODE_ICONS.put(MimeTypeCategory.VIDEO, getResources().getDrawable(R.drawable
+ .ic_em_video));
+ EASY_MODE_ICONS.put(MimeTypeCategory.AUDIO, getResources().getDrawable(R.drawable
+ .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);
}
@Override
+ protected void onResume() {
+ super.onResume();
+
+ if (mSearchView.getVisibility() == View.VISIBLE) {
+ closeSearch();
+ }
+
+ // Check restrictions
+ if (!FileManagerApplication.checkRestrictSecondaryUsersAccess(this, mChRooted)) {
+ return;
+ }
+
+ // Check that the current dir is mounted (for virtual filesystems)
+ String curDir = mNavigationViews[mCurrentNavigationView].getCurrentDir();
+ if (curDir != null) {
+ VirtualMountPointConsole vc = VirtualMountPointConsole.getVirtualConsoleForPath(
+ mNavigationViews[mCurrentNavigationView].getCurrentDir());
+ getCurrentNavigationView().refresh(true);
+ if (vc != null && !vc.isMounted()) {
+ onRequestBookmarksRefresh();
+ removeUnmountedHistory();
+ removeUnmountedSelection();
+
+ Intent intent = new Intent();
+ intent.putExtra(EXTRA_ADD_TO_HISTORY, false);
+ initNavigation(NavigationActivity.this.mCurrentNavigationView, false, intent);
+ }
+ }
+ }
+
+ @Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred.
* {@inheritDoc}
*/
@Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (mDrawerToggle.onOptionsItemSelected(item)) {
+ return true;
+ }
+
+ if (mNeedsEasyMode) {
+ if (item.getItemId() == android.R.id.home) {
+ if (mHistory.size() == 0 && !isEasyModeVisible()) {
+ performShowEasyMode();
+ } else {
+ back();
+ }
+ }
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
protected void onDestroy() {
if (DEBUG) {
Log.d(TAG, "NavigationActivity.onDestroy"); //$NON-NLS-1$
}
+ if (mActiveDialog != null && mActiveDialog.isShowing()) {
+ mActiveDialog.dismiss();
+ }
+
// Unregister the receiver
try {
unregisterReceiver(this.mNotificationReceiver);
/**NON BLOCK**/
}
+ recycle();
//All destroy. Continue
super.onDestroy();
}
((Boolean)FileManagerSettings.SETTINGS_FIRST_USE.getDefaultValue()).booleanValue());
//Display the welcome message?
- if (firstUse) {
+ if (firstUse && FileManagerApplication.hasShellCommands()) {
// open navigation drawer to show user that it exists
- mDrawerLayout.openDrawer(mDrawer);
+ mDrawerLayout.openDrawer(Gravity.START);
AlertDialog dialog = DialogHelper.createAlertDialog(this,
- R.drawable.ic_launcher, R.string.welcome_title,
+ R.mipmap.ic_launcher_filemanager, R.string.welcome_title,
getString(R.string.welcome_msg), false);
DialogHelper.delegateDialogShow(this, dialog);
* Method that initializes the titlebar of the activity.
*/
private void initTitleActionBar() {
- getActionBar().setTitle(R.string.app_name);
-
//Inflate the view and associate breadcrumb
View titleLayout = getLayoutInflater().inflate(
R.layout.navigation_view_customtitle, null, false);
//Configure the action bar options
getActionBar().setBackgroundDrawable(
- getResources().getDrawable(R.drawable.bg_holo_titlebar));
- getActionBar().setDisplayOptions(
- ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
- getActionBar().setCustomView(titleLayout);
+ getResources().getDrawable(R.drawable.bg_material_titlebar));
+ mToolBar.addView(titleLayout);
}
/**
}
});
- // Have overflow menu?
+ // Have overflow menu? Actually no. There is only a search action, so just hide
+ // the overflow
View overflow = findViewById(R.id.ab_overflow);
- boolean showOptionsMenu = AndroidHelper.showOptionsMenu(getApplicationContext());
- overflow.setVisibility(showOptionsMenu ? View.VISIBLE : View.GONE);
- this.mOptionsAnchorView = showOptionsMenu ? overflow : this.mActionBar;
+ overflow.setVisibility(View.GONE);
// Show the status bar
View statusBar = findViewById(R.id.navigation_statusbar_portrait_holder);
*/
private void initDrawer() {
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
- mDrawer = (ScrollView) findViewById(R.id.drawer);
+ //Set our status bar color
+ mDrawerLayout.setStatusBarBackgroundColor(R.color.material_palette_blue_primary_dark);
+ mDrawer = (ViewGroup) findViewById(R.id.drawer);
mDrawerBookmarks = (LinearLayout) findViewById(R.id.bookmarks_list);
mDrawerHistory = (LinearLayout) findViewById(R.id.history_list);
mDrawerHistoryEmpty = (TextView) findViewById(R.id.history_empty);
+ mBookmarksLayout = findViewById(R.id.drawer_bookmarks);
+ mHistoryLayout = findViewById(R.id.drawer_history);
+ mBookmarksTab = (TextView) findViewById(R.id.drawer_bookmarks_tab);
+ mHistoryTab = (TextView) findViewById(R.id.drawer_history_tab);
+ mBookmarksTab.setOnClickListener(mOnClickDrawerTabListener);
+ mHistoryTab.setOnClickListener(mOnClickDrawerTabListener);
+
+ mSettings = (ButtonItem) findViewById(R.id.ab_settings);
+ mSettings.setOnClickListener(mOnClickDrawerActionBarListener);
+ mClearHistory = (ButtonItem) findViewById(R.id.ab_clear_history);
+ mClearHistory.setOnClickListener(mOnClickDrawerActionBarListener);
+
+ // Restore the last tab pressed
+ Integer lastTab = Preferences.getSharedPreferences().getInt(
+ FileManagerSettings.USER_PREF_LAST_DRAWER_TAB.getId(),
+ (Integer) FileManagerSettings.USER_PREF_LAST_DRAWER_TAB
+ .getDefaultValue());
+ mOnClickDrawerTabListener.onClick(lastTab == 0 ? mBookmarksTab : mHistoryTab);
+
// Set the navigation drawer "hamburger" icon
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
- R.drawable.ic_holo_light_navigation_drawer,
+ R.drawable.ic_material_light_navigation_drawer,
R.string.drawer_open, R.string.drawer_close) {
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
- getActionBar().setDisplayOptions(
- ActionBar.DISPLAY_SHOW_CUSTOM
- | ActionBar.DISPLAY_SHOW_HOME);
- getActionBar().setDisplayHomeAsUpEnabled(true);
- getActionBar().setHomeButtonEnabled(true);
- invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}
/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
+ onDrawerLayoutOpened(drawerView);
super.onDrawerOpened(drawerView);
- getActionBar().setDisplayOptions(
- ActionBar.DISPLAY_SHOW_TITLE
- | ActionBar.DISPLAY_SHOW_HOME);
- getActionBar().setDisplayHomeAsUpEnabled(true);
- getActionBar().setHomeButtonEnabled(true);
-
- // change ActionBar title text color
- Theme theme = ThemeManager
- .getCurrentTheme(NavigationActivity.this);
- // get ActionBar title TextView id
- int titleId = Resources.getSystem().getIdentifier(
- "action_bar_title", "id", "android");
- TextView v = (TextView) findViewById(titleId);
- theme.setTextColor(NavigationActivity.this, v, "text_color"); //$NON-NLS-1$
-
- invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}
};
+ getActionBar().setDisplayHomeAsUpEnabled(true);
// Set the drawer toggle as the DrawerListener
mDrawerLayout.setDrawerListener(mDrawerToggle);
+ }
- getActionBar().setDisplayHomeAsUpEnabled(true);
- getActionBar().setHomeButtonEnabled(true);
+ /***
+ * Method that do something when the DrawerLayout opened.
+ */
+ private void onDrawerLayoutOpened(View drawerView){
+ if (mSearchView != null && mSearchView.getVisibility() == View.VISIBLE) {
+ closeSearch();
+ hideSoftInput(drawerView);
+ }
+ }
+
+ /**
+ * Method that hide the software when the software showing.
+ *
+ * */
+ private void hideSoftInput(View view){
+ if (mImm != null) {
+ mImm.hideSoftInputFromWindow(view.getWindowToken(), 0);
+ }
}
/**
- * Method adds a history entry to the history list in the drawer
+ * Method that adds a history entry to the history list in the drawer
*/
private void addHistoryToDrawer(int index, HistoryNavigable navigable) {
// hide empty message
TextView name = (TextView) view.findViewById(R.id.history_item_name);
TextView directory = (TextView) view
.findViewById(R.id.history_item_directory);
- TextView position = (TextView) view
- .findViewById(R.id.history_item_position);
- // if (history.getItem() instanceof NavigationViewInfoParcelable)
Drawable icon = iconholder.getDrawable("ic_fso_folder_drawable"); //$NON-NLS-1$
if (navigable instanceof SearchInfoParcelable) {
icon = iconholder.getDrawable("ic_history_search_drawable"); //$NON-NLS-1$
name.setText(title);
directory.setText(navigable.getDescription());
- position.setText(String.format("#%d", index + 1));
theme.setTextColor(this, name, "text_color");
theme.setTextColor(this, directory, "text_color");
- theme.setTextColor(this, position, "text_color");
// handle item click
view.setOnClickListener(new OnClickListener() {
final History history = mHistory.get(count - index - 1);
navigateToHistory(history);
- mDrawerLayout.closeDrawer(mDrawer);
+ mDrawerLayout.closeDrawer(Gravity.START);
}
});
// add as first child
mDrawerHistory.addView(view, 0);
+
+ // Show clear button if history tab is selected
+ mClearHistory.setVisibility(mHistoryTab.isSelected() ? View.VISIBLE : View.GONE);
}
/**
}
/**
+ * Show the easy mode view
+ */
+ private void performShowEasyMode() {
+ mEasyModeListView.setVisibility(View.VISIBLE);
+ getCurrentNavigationView().setVisibility(View.GONE);
+ performShowBackArrow(false);
+ }
+
+ /**
+ * Hide the easy mode view
+ */
+ private void performHideEasyMode() {
+ mEasyModeListView.setVisibility(View.GONE);
+ getCurrentNavigationView().setVisibility(View.VISIBLE);
+ }
+
+ private void performShowBackArrow(boolean showBackArrow) {
+ if (mNeedsEasyMode) {
+ mDrawerToggle.setDrawerIndicatorEnabled(!showBackArrow);
+ }
+ }
+
+ private boolean isEasyModeVisible() {
+ return mEasyModeListView.getVisibility() != View.GONE;
+ }
+
+ /**
* Method takes a bookmark as argument and adds it to the bookmark list in
* the drawer
*/
Drawable action = null;
String actionCd = null;
if (bookmark.mType.compareTo(BOOKMARK_TYPE.HOME) == 0) {
- action = iconholder.getDrawable("ic_config_drawable"); //$NON-NLS-1$
+ action = iconholder.getDrawable("ic_edit_home_bookmark_drawable"); //$NON-NLS-1$
actionCd = getApplicationContext().getString(
R.string.bookmarks_button_config_cd);
}
final int index = mDrawerBookmarks.indexOfChild(v);
final Bookmark bookmark = mBookmarks.get(index);
+ boolean showEasyMode = (mSdBookmarks.contains(bookmark)) &&
+ getResources().getBoolean(R.bool.cmcc_show_easy_mode);
+
// try to navigate to the bookmark path
try {
FileSystemObject fso = CommandHelper.getFileInfo(
getApplicationContext(), bookmark.mPath, null);
if (fso != null) {
+ if (showEasyMode) {
+ performShowEasyMode();
+ } else {
+ performHideEasyMode();
+ }
+ performShowBackArrow(!mDrawerToggle.isDrawerIndicatorEnabled());
getCurrentNavigationView().open(fso);
- mDrawerLayout.closeDrawer(mDrawer);
+ mDrawerLayout.closeDrawer(Gravity.START);
}
else {
// The bookmark does not exist, delete the user-defined
/**
* Method that initializes the bookmarks.
*/
- private void initBookmarks() {
+ private synchronized void initBookmarks() {
+ if (mBookmarksTask != null &&
+ !mBookmarksTask.getStatus().equals(AsyncTask.Status.FINISHED)) {
+ return;
+ }
+
// Retrieve the loading view
final View waiting = findViewById(R.id.bookmarks_loading);
// Load bookmarks in background
- AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
+ mBookmarksTask = new AsyncTask<Void, Void, Boolean>() {
Exception mCause;
@Override
NavigationActivity.this, this.mCause);
}
}
+ mBookmarksTask = null;
}
@Override
protected void onCancelled() {
waiting.setVisibility(View.GONE);
+ mBookmarksTask = null;
}
};
- task.execute();
+ mBookmarksTask.execute();
}
/**
bookmarks.add(loadHomeBookmarks());
bookmarks.addAll(loadFilesystemBookmarks());
}
- bookmarks.addAll(loadSdStorageBookmarks());
+ mSdBookmarks = loadSdStorageBookmarks();
+ bookmarks.addAll(mSdBookmarks);
+ bookmarks.addAll(loadVirtualBookmarks());
bookmarks.addAll(loadUserBookmarks());
return bookmarks;
}
try {
// Recovery sdcards from storage manager
StorageVolume[] volumes = StorageHelper
- .getStorageVolumes(getApplication());
- int cc = volumes.length;
- for (int i = 0; i < cc; i++) {
- if (volumes[i].getPath().toLowerCase(Locale.ROOT)
- .indexOf("usb") != -1) { //$NON-NLS-1$
- bookmarks.add(new Bookmark(BOOKMARK_TYPE.USB, StorageHelper
- .getStorageVolumeDescription(getApplication(),
- volumes[i]), volumes[i].getPath()));
- }
- else {
- bookmarks.add(new Bookmark(BOOKMARK_TYPE.SDCARD,
- StorageHelper.getStorageVolumeDescription(
- getApplication(), volumes[i]), volumes[i]
- .getPath()));
+ .getStorageVolumes(getApplication(), true);
+ for (StorageVolume volume: volumes) {
+ if (volume != null) {
+ String mountedState = volume.getState();
+ String path = volume.getPath();
+ if (!Environment.MEDIA_MOUNTED.equalsIgnoreCase(mountedState) &&
+ !Environment.MEDIA_MOUNTED_READ_ONLY.equalsIgnoreCase(mountedState)) {
+ Log.w(TAG, "Ignoring '" + path + "' with state of '"+ mountedState + "'");
+ continue;
+ }
+ if (!TextUtils.isEmpty(path)) {
+ String lowerPath = path.toLowerCase(Locale.ROOT);
+ Bookmark bookmark;
+ if (lowerPath.contains(STR_USB)) {
+ bookmark = new Bookmark(BOOKMARK_TYPE.USB, StorageHelper
+ .getStorageVolumeDescription(getApplication(), volume), path);
+ } else {
+ bookmark = new Bookmark(BOOKMARK_TYPE.SDCARD, StorageHelper
+ .getStorageVolumeDescription(getApplication(), volume), path);
+ }
+ bookmarks.add(bookmark);
+ }
}
}
}
/**
+ * Method that loads all virtual mount points.
+ *
+ * @return List<Bookmark> The bookmarks loaded
+ */
+ private List<Bookmark> loadVirtualBookmarks() {
+ // Initialize the bookmarks
+ List<Bookmark> bookmarks = new ArrayList<Bookmark>();
+ List<MountPoint> mps = VirtualMountPointConsole.getVirtualMountPoints();
+ for (MountPoint mp : mps) {
+ BOOKMARK_TYPE type = null;
+ String name = null;
+ if (mp.isSecure()) {
+ type = BOOKMARK_TYPE.SECURE;
+ name = getString(R.string.bookmarks_secure);
+ } else if (mp.isRemote()) {
+ type = BOOKMARK_TYPE.REMOTE;
+ name = getString(R.string.bookmarks_remote);
+ } else {
+ continue;
+ }
+ bookmarks.add(new Bookmark(type, name, mp.getMountPoint()));
+ }
+ return bookmarks;
+ }
+
+ /**
* Method that loads the user bookmarks (added by the user).
*
* @return List<Bookmark> The bookmarks loaded
/** NON BLOCK **/
}
}
+
+ // Remove bookmarks from virtual storage if the filesystem is not mount
+ int c = bookmarks.size() - 1;
+ for (int i = c; i >= 0; i--) {
+ VirtualMountPointConsole vc =
+ VirtualMountPointConsole.getVirtualConsoleForPath(bookmarks.get(i).mPath);
+ if (vc != null && !vc.isMounted()) {
+ bookmarks.remove(i);
+ }
+ }
+
return bookmarks;
}
//- 0
this.mNavigationViews[0] = (NavigationView)findViewById(R.id.navigation_view);
this.mNavigationViews[0].setId(0);
+ this.mEasyModeListView = (ListView) findViewById(R.id.lv_easy_mode);
+ mEasyModeAdapter = new 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);
+ View checkBoxView = convertView.findViewById(R.id.navigation_view_item_check);
+ checkBoxView.setVisibility(View.GONE);
+ typeTitleTV.setText(typeTitle);
+ typeIconIV.setImageDrawable(EASY_MODE_ICONS.get(item));
+ convertView.setOnClickListener(mEasyModeItemClickListener);
+ convertView.setTag(position);
+ return convertView;
+ }
+ };
+ mEasyModeAdapter.addAll(EASY_MODE_LIST);
+ mEasyModeListView.setAdapter(mEasyModeAdapter);
+ }
+
+ private void onClicked(int position) {
+ Intent intent = new Intent(this, SearchActivity.class);
+ intent.setAction(Intent.ACTION_SEARCH);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_DIRECTORY,
+ getCurrentNavigationView().getCurrentDir());
+ intent.putExtra(SearchManager.QUERY, "*"); // Use wild-card '*'
+
+ if (position == 0) {
+ // the user has selected all items, they want to see their folders so let's do that.
+ performHideEasyMode();
+ performShowBackArrow(true);
+ 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);
}
/**
// Check if request navigation to directory (use as default), and
// ensure chrooted and absolute path
String navigateTo = intent.getStringExtra(EXTRA_NAVIGATE_TO);
+ String intentAction = intent.getAction();
if (navigateTo != null && navigateTo.length() > 0) {
initialDir = navigateTo;
+ } else if (intentAction != null && intentAction.equals(Intent.ACTION_VIEW)) {
+ Uri data = intent.getData();
+ if (data != null && (FileHelper.FILE_URI_SCHEME.equals(data.getScheme())
+ || FileHelper.FOLDER_URI_SCHEME.equals(data.getScheme())
+ || FileHelper.DIRECTORY_URI_SCHEME.equals(data.getScheme()))) {
+ File path = new File(data.getPath());
+ if (path.isDirectory()) {
+ initialDir = path.getAbsolutePath();
+ }
+ }
+ }
+
+ // Add to history
+ final boolean addToHistory = intent.getBooleanExtra(EXTRA_ADD_TO_HISTORY, true);
+
+ // We cannot navigate to a secure console if it is unmounted. So go to root in that case
+ VirtualConsole vc = VirtualMountPointConsole.getVirtualConsoleForPath(initialDir);
+ if (vc != null && vc instanceof SecureConsole && !((SecureConsole) vc).isMounted()) {
+ initialDir = FileHelper.ROOT_DIRECTORY;
}
if (this.mChRooted) {
// Initial directory is the first external sdcard (sdcard, emmc, usb, ...)
if (!StorageHelper.isPathInStorageVolume(initialDir)) {
StorageVolume[] volumes =
- StorageHelper.getStorageVolumes(this);
+ StorageHelper.getStorageVolumes(this, false);
if (volumes != null && volumes.length > 0) {
initialDir = volumes[0].getPath();
+ int count = volumes.length;
+ for (int i = 0; i < count; i++) {
+ StorageVolume volume = volumes[i];
+ if (Environment.MEDIA_MOUNTED.equalsIgnoreCase(volume.getState())) {
+ initialDir = volume.getPath();
+ break;
+ }
+ }
//Ensure that initial directory is an absolute directory
initialDir = FileHelper.getAbsPath(initialDir);
} else {
this, ipex, false, true, new OnRelaunchCommandResult() {
@Override
public void onSuccess() {
- navigationView.changeCurrentDir(absInitialDir);
+ navigationView.changeCurrentDir(absInitialDir, addToHistory);
}
@Override
public void onFailed(Throwable cause) {
showInitialInvalidDirectoryMsg(userInitialDir);
- navigationView.changeCurrentDir(FileHelper.ROOT_DIRECTORY);
+ navigationView.changeCurrentDir(FileHelper.ROOT_DIRECTORY,
+ addToHistory);
}
@Override
public void onCancelled() {
showInitialInvalidDirectoryMsg(userInitialDir);
- navigationView.changeCurrentDir(FileHelper.ROOT_DIRECTORY);
+ navigationView.changeCurrentDir(FileHelper.ROOT_DIRECTORY,
+ addToHistory);
}
});
}
}
+ boolean needsEasyMode = false;
+ if (mSdBookmarks != null ) {
+ for (Bookmark bookmark :mSdBookmarks) {
+ if (bookmark.mPath.equalsIgnoreCase(initialDir)) {
+ needsEasyMode = true;
+ break;
+ }
+ }
+ }
+
+ mNeedsEasyMode = getResources().getBoolean(R.bool.cmcc_show_easy_mode);
+
+ needsEasyMode = needsEasyMode && mNeedsEasyMode;
+ if (needsEasyMode) {
+ performShowEasyMode();
+ } else {
+ performHideEasyMode();
+ }
// Change the current directory to the user-defined initial directory
- navigationView.changeCurrentDir(initialDir);
+ navigationView.changeCurrentDir(initialDir, addToHistory);
}
/**
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
- showOverflowPopUp(this.mOptionsAnchorView);
- return true;
- }
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- if (checkBackAction()) {
- return true;
+ if (mDrawerLayout.isDrawerOpen(mDrawer)) {
+ mDrawerLayout.closeDrawer(Gravity.START);
+ } else {
+ mDrawerLayout.openDrawer(Gravity.START);
}
-
- // An exit event has occurred, force the destroy the consoles
- exit();
+ return true;
}
return super.onKeyUp(keyCode, event);
}
- /**
- * {@inheritDoc}
- */
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Pass the event to ActionBarDrawerToggle, if it returns
- // true, then it has handled the app icon touch event
- if (mDrawerToggle.onOptionsItemSelected(item)) {
- return true;
- }
-
- // just handle the drawer list here
- switch (item.getItemId()) {
- case R.id.mnu_actions_add_to_bookmarks_current_folder:
- // TODO add bookmark
- Log.d(TAG, "add bookmark");
- return true;
- case R.id.mnu_clear_history:
- clearHistory();
- return true;
- case R.id.mnu_settings:
- openSettings();
- return true;
+ public void onBackPressed() {
+ if (mDrawerLayout.isDrawerOpen(Gravity.START)) {
+ mDrawerLayout.closeDrawer(Gravity.START);
+ return;
}
- return super.onOptionsItemSelected(item);
- }
-
- /**
- * Called when the menu is created. Just includes the drawer's overflow
- * menu. All entries are hidden until onPrepareOptionsMenu unhides them.
- */
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.drawer, menu);
- return true;
- }
+ boolean upToParent = mHistory.size() > 0;
- /**
- * Called whenever we call invalidateOptionsMenu()
- */
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawer);
-
- for (int i = 0; i < menu.size(); i++) {
- // show all items if drawer is open,
- // hide them if not
- menu.getItem(i).setVisible(drawerOpen);
-
- if (menu.getItem(i).getItemId() == R.id.mnu_clear_history) {
- menu.getItem(i).setEnabled(mHistory.size() > 0);
+ if (mNeedsEasyMode && !isEasyModeVisible() && !upToParent) {
+ performShowEasyMode();
+ return;
+ } else {
+ if (checkBackAction()) {
+ return;
}
}
- return super.onPrepareOptionsMenu(menu);
+ // An exit event has occurred, force the destroy the consoles
+ exit();
}
/**
case R.id.ab_configuration:
//Show navigation view configuration toolbar
getCurrentNavigationView().getCustomTitle().showConfigurationView();
- getActionBar().setDisplayHomeAsUpEnabled(true);
- getActionBar().setHomeButtonEnabled(true);
break;
case R.id.ab_close:
//Hide navigation view configuration toolbar
break;
case R.id.ab_search:
- openSearch();
- break;
- case R.id.ab_overflow:
- showOverflowPopUp(view);
+ openSearch();
break;
default:
case INTENT_REQUEST_SEARCH:
if (resultCode == RESULT_OK) {
//Change directory?
- FileSystemObject fso =
- (FileSystemObject)data.
- getSerializableExtra(EXTRA_SEARCH_ENTRY_SELECTION);
- SearchInfoParcelable searchInfo =
- data.getParcelableExtra(EXTRA_SEARCH_LAST_SEARCH_DATA);
- if (fso != null) {
- //Goto to new directory
- getCurrentNavigationView().open(fso, searchInfo);
+ Bundle bundle = data.getExtras();
+ if (bundle != null) {
+ FileSystemObject fso = (FileSystemObject) bundle.getSerializable(
+ EXTRA_SEARCH_ENTRY_SELECTION);
+ SearchInfoParcelable searchInfo =
+ bundle.getParcelable(EXTRA_SEARCH_LAST_SEARCH_DATA);
+ if (fso != null) {
+ //Goto to new directory
+ getCurrentNavigationView().open(fso, searchInfo);
+ performHideEasyMode();
+ }
}
} else if (resultCode == RESULT_CANCELED) {
SearchInfoParcelable searchInfo =
* {@inheritDoc}
*/
@Override
+ public void onRequestBookmarksRefresh() {
+ initBookmarks();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void onRequestRemove(Object o, boolean clearSelection) {
if (o instanceof FileSystemObject) {
// Remove from view
// Ignored
}
+ @Override
+ public void onCancel(){
+ // nop
+ }
+
/**
* {@inheritDoc}
*/
}
/**
- * Method that shows a popup with the activity main menu.
- *
- * @param anchor The action button that was pressed
- */
- private void showOverflowPopUp(View anchor) {
- SimpleMenuListAdapter adapter =
- new HighlightedSimpleMenuListAdapter(this, R.menu.navigation);
- Menu menu = adapter.getMenu();
- int cc = this.mActionBar.getChildCount();
- for (int i = 0, j = this.mActionBar.getChildCount() - 1; i < cc; i++, j--) {
- View child = this.mActionBar.getChildAt(i);
- boolean visible = child.getVisibility() == View.VISIBLE;
- if (visible) {
- menu.removeItem(menu.getItem(j).getItemId());
- }
- }
-
- final ListPopupWindow popup = DialogHelper.createListPopupWindow(this, adapter, anchor);
- popup.setOnItemClickListener(new OnItemClickListener() {
- @Override
- public void onItemClick(
- final AdapterView<?> parent, final View v, final int position, final long id) {
-
- final int itemId = (int)id;
- NavigationActivity.this.mHandler.post(new Runnable() {
- @Override
- public void run() {
- popup.dismiss();
- switch (itemId) {
- case R.id.mnu_settings:
- //Settings
- openSettings();
- break;
-
- case R.id.mnu_search:
- //Search
- openSearch();
- popup.dismiss();
- break;
- default:
- break;
- }
- }
- });
- }
- });
- popup.show();
- }
-
- /**
* Method that show the information of a filesystem mount point.
*
* @param mp The mount point info
if (breadcrumb.getMountPointInfo().compareTo(mountPoint) == 0) {
breadcrumb.updateMountPointInfo();
}
+ if (mountPoint.isSecure()) {
+ // Secure mountpoints only can be unmount, so we need to move the navigation
+ // to a secure storage (do not add to history)
+ Intent intent = new Intent();
+ intent.putExtra(EXTRA_ADD_TO_HISTORY, false);
+ initNavigation(NavigationActivity.this.mCurrentNavigationView, false, intent);
+ }
}
});
dialog.show();
// We need a basic structure to check this
if (getCurrentNavigationView() == null) return false;
+ if (mSearchView.getVisibility() == View.VISIBLE) {
+ closeSearch();
+ }
+
//Check if the configuration view is showing. In this case back
//action must be "close configuration"
if (getCurrentNavigationView().getCustomTitle().isConfigurationViewShowing()) {
//Communicate the user that the next time the application will be closed
this.mExitBackTimeout = System.currentTimeMillis();
DialogHelper.showToast(this, R.string.msgs_push_again_to_exit, Toast.LENGTH_SHORT);
- return true;
+ if (mNeedsEasyMode) {
+ return isEasyModeVisible();
+ } else {
+ return true;
+ }
}
//Back action not applied
return !this.mExitFlag;
}
- /**
- * {@inheritDoc}
- */
@Override
- public boolean onSearchRequested() {
- Bundle bundle = new Bundle();
- bundle.putString(
- SearchActivity.EXTRA_SEARCH_DIRECTORY,
- getCurrentNavigationView().getCurrentDir());
- startSearch(Preferences.getLastSearch(), true, bundle, false);
- return true;
+ public void startActivity(Intent intent) {
+ // check if search intent
+ if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_DIRECTORY,
+ getCurrentNavigationView().getCurrentDir());
+ }
+
+ super.startActivity(intent);
}
/**
}
//Navigate
+ boolean clearHistory = mHistoryTab.isSelected() && mHistory.size() > 0;
+ mClearHistory.setVisibility(clearHistory ? View.VISIBLE : View.GONE);
return true;
} catch (Throwable ex) {
}
}
- //Extract a history from the
+ //Navigate to history
if (this.mHistory.size() > 0) {
- //Navigate to history
return navigateToHistory(this.mHistory.get(this.mHistory.size() - 1));
}
//Nothing to apply
+ mClearHistory.setVisibility(View.GONE);
return false;
}
}
/**
- * Method that opens the search activity.
+ * Method that opens the search view.
*
* @hide
*/
void openSearch() {
- onSearchRequested();
+ mSearchView.setVisibility(View.VISIBLE);
+ mSearchView.onActionViewExpanded();
+ mCustomTitleView.setVisibility(View.GONE);
+ }
+
+ void closeSearch() {
+ mSearchView.setVisibility(View.GONE);
+ mSearchView.onActionViewCollapsed();
+ mCustomTitleView.setVisibility(View.VISIBLE);
}
/**
* Method that remove the {@link FileSystemObject} from the history
*/
private void removeFromHistory(FileSystemObject fso) {
- // TODO remove drawer entry here, too
if (this.mHistory != null) {
- int cc = this.mHistory.size();
- for (int i = cc-1; i >= 0 ; i--) {
+ int cc = this.mHistory.size() - 1;
+ for (int i = cc; i >= 0 ; i--) {
History history = this.mHistory.get(i);
if (history.getItem() instanceof NavigationViewInfoParcelable) {
String p0 = fso.getFullPath();
- String p1 =
- ((NavigationViewInfoParcelable)history.getItem()).getCurrentDir();
+ String p1 = ((NavigationViewInfoParcelable) history.getItem()).getCurrentDir();
if (p0.compareTo(p1) == 0) {
this.mHistory.remove(i);
+ mDrawerHistory.removeViewAt(mDrawerHistory.getChildCount() - i - 1);
+ mDrawerHistoryEmpty.setVisibility(
+ mDrawerHistory.getChildCount() == 0 ? View.VISIBLE : View.GONE);
+ updateHistoryPositions();
}
}
}
}
/**
+ * Update the history positions after one of the history is removed from drawer
+ */
+ private void updateHistoryPositions() {
+ int cc = this.mHistory.size() - 1;
+ for (int i = 0; i <= cc ; i++) {
+ History history = this.mHistory.get(i);
+ history.setPosition(i + 1);
+ }
+ }
+
+ /**
* Method that ask the user to change the access mode prior to crash.
* @hide
*/
* @hide
*/
void exit() {
+ finish();
+ }
+
+ private void recycle() {
// Recycle the navigation views
int cc = this.mNavigationViews.length;
for (int i = 0; i < cc; i++) {
} catch (Throwable ex) {
/**NON BLOCK**/
}
- finish();
}
/**
*/
private void onLayoutChanged() {
Theme theme = ThemeManager.getCurrentTheme(this);
- boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawer);
+ boolean drawerOpen = mDrawerLayout.isDrawerOpen(Gravity.START);
// Apply only when the orientation was changed
int orientation = getResources().getConfiguration().orientation;
// imitate a closed drawer while layout is rebuilt to avoid NullPointerException
if (drawerOpen) {
- mDrawerToggle.onDrawerClosed(mDrawer);
+ mDrawerLayout.closeDrawer(Gravity.START);
}
if (this.mOrientation == Configuration.ORIENTATION_LANDSCAPE) {
rbw += bw;
}
}
- int w = abw + rbw;
- boolean showOptionsMenu = AndroidHelper.showOptionsMenu(getApplicationContext());
- if (!showOptionsMenu) {
- w -= bw;
- }
+ // Currently there isn't overflow menu
+ int w = abw + rbw - bw;
// Add to the new location
ViewGroup newParent = (ViewGroup)findViewById(R.id.navigation_title_landscape_holder);
}
/**
+ * Method that removes all the history items that refers to virtual unmounted filesystems
+ */
+ private void removeUnmountedHistory() {
+ int cc = mHistory.size() - 1;
+ for (int i = cc; i >= 0; i--) {
+ History history = mHistory.get(i);
+ if (history.getItem() instanceof NavigationViewInfoParcelable) {
+ NavigationViewInfoParcelable navigableInfo =
+ ((NavigationViewInfoParcelable) history.getItem());
+ VirtualMountPointConsole vc =
+ VirtualMountPointConsole.getVirtualConsoleForPath(
+ navigableInfo.getCurrentDir());
+ if (vc != null && !vc.isMounted()) {
+ mHistory.remove(i);
+ mDrawerHistory.removeViewAt(mDrawerHistory.getChildCount() - i - 1);
+ }
+ }
+ }
+ mDrawerHistoryEmpty.setVisibility(
+ mDrawerHistory.getChildCount() == 0 ? View.VISIBLE : View.GONE);
+ updateHistoryPositions();
+ }
+
+ /**
+ * Method that removes all the selection items that refers to virtual unmounted filesystems
+ */
+ private void removeUnmountedSelection() {
+ for (NavigationView view : mNavigationViews) {
+ view.removeUnmountedSelection();
+ }
+ mSelectionBar.setSelection(getNavigationView(mCurrentNavigationView).getSelectedFiles());
+ }
+
+ /**
* Method that applies the current theme to the activity
* @hide
*/
void applyTheme() {
int orientation = getResources().getConfiguration().orientation;
Theme theme = ThemeManager.getCurrentTheme(this);
- theme.setBaseTheme(this, false);
+ theme.setBaseThemeNoActionBar(this);
+ applyTabTheme();
// imitate a closed drawer while layout is rebuilt to avoid NullPointerException
- boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawer);
+ boolean drawerOpen = mDrawerLayout.isDrawerOpen(Gravity.START);
if (drawerOpen) {
- mDrawerToggle.onDrawerClosed(mDrawer);
+ mDrawerLayout.closeDrawer(Gravity.START);
}
//- Layout
//- ActionBar
theme.setTitlebarDrawable(this, getActionBar(), "titlebar_drawable"); //$NON-NLS-1$
+ // Hackery to theme search view
+ mSearchView = (SearchView) findViewById(R.id.navigation_search_bar);
+ int searchPlateId = mSearchView.getContext().getResources()
+ .getIdentifier("android:id/search_plate", null, null);
+ View searchPlate = mSearchView.findViewById(searchPlateId);
+ if (searchPlate != null) {
+ int searchTextId = searchPlate.getContext().getResources()
+ .getIdentifier("android:id/search_src_text", null, null);
+ TextView searchText = (TextView) searchPlate.findViewById(searchTextId);
+ if (searchText != null) {
+ searchText.setTextColor(Color.WHITE);
+ searchText.setHintTextColor(Color.WHITE);
+ }
+
+ int magId = getResources().getIdentifier("android:id/search_mag_icon", null, null);
+ ImageView magImage = (ImageView) mSearchView.findViewById(magId);
+ if (magImage != null) {
+ magImage.setLayoutParams(new LinearLayout.LayoutParams(0, 0));
+ }
+ }
+
+ SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
+ mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
+ mSearchView.setIconifiedByDefault(false);
+
+ mCustomTitleView = (NavigationCustomTitleView) findViewById(R.id.navigation_title_flipper);
+ mCustomTitleView.setVisibility(View.VISIBLE);
+
//- StatusBar
v = findViewById(R.id.navigation_statusbar);
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
// - Navigation drawer
- theme.setBackgroundColor(this, mDrawer, "drawer_color");
- v = findViewById(R.id.bookmarks_header);
- theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
- v = findViewById(R.id.history_header);
- theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
v = findViewById(R.id.history_empty);
theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
- mDrawerToggle.setDrawerImageResource(theme.getResourceId(this, "drawer_icon"));
for (int i=0; i<mDrawerHistory.getChildCount(); i++) {
View item = mDrawerHistory.getChildAt(i);
theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
v = item.findViewById(R.id.history_item_directory);
theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
- v = item.findViewById(R.id.history_item_position);
- theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
}
//- NavigationView
}
}
+ /**
+ * Method that applies the current theme to the tab host
+ */
+ private void applyTabTheme() {
+ // Apply the theme
+ Theme theme = ThemeManager.getCurrentTheme(this);
+
+ View v = findViewById(R.id.drawer);
+ theme.setBackgroundDrawable(this, v, "background_drawable"); //$NON-NLS-1$
+
+ v = findViewById(R.id.drawer_bookmarks_tab);
+ theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
+ v = findViewById(R.id.drawer_history_tab);
+ theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
+
+ v = findViewById(R.id.ab_settings);
+ theme.setImageDrawable(this, (ButtonItem) v, "ab_settings_drawable"); //$NON-NLS-1$
+ v = findViewById(R.id.ab_clear_history);
+ theme.setImageDrawable(this, (ButtonItem) v, "ab_delete_drawable"); //$NON-NLS-1$
+ }
+
+ public void updateActiveDialog(Dialog dialog) {
+ mActiveDialog = dialog;
+ }
}