diff options
author | Stephen Bird <sbird@cyngn.com> | 2015-08-12 11:54:53 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-11-02 22:08:43 -0700 |
commit | e0f0adeb9e438eb63561fd5e1e294a6021e57886 (patch) | |
tree | 5429e42ca5dbd0fd83c6335255bb947ffa70a178 | |
parent | 018c616026bea96595031c0e61fd773a46f7a9b6 (diff) | |
download | android_packages_apps_CMFileManager-e0f0adeb9e438eb63561fd5e1e294a6021e57886.tar.gz android_packages_apps_CMFileManager-e0f0adeb9e438eb63561fd5e1e294a6021e57886.tar.bz2 android_packages_apps_CMFileManager-e0f0adeb9e438eb63561fd5e1e294a6021e57886.zip |
Selection bar: New toolbar update
The file selection toolbar is now functional.
Also, Some small cleanup around the app, less themes.
Change-Id: Ic5465208a611be53c2d6b1b5b429b4e94d4319b5
28 files changed, 1068 insertions, 1554 deletions
diff --git a/res/anim/slide_in.xml b/res/anim/slide_in.xml new file mode 100644 index 00000000..df554737 --- /dev/null +++ b/res/anim/slide_in.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2015 The Android Open Source 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. +--> + +<translate xmlns:android="http://schemas.android.com/apk/res/android" + android:fromYDelta="100%" + android:toYDelta="0"/>
\ No newline at end of file diff --git a/res/anim/slide_out.xml b/res/anim/slide_out.xml new file mode 100644 index 00000000..eb55cc0e --- /dev/null +++ b/res/anim/slide_out.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2015 The Android Open Source 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. +--> + +<translate xmlns:android="http://schemas.android.com/apk/res/android" + android:fromYDelta="0" + android:toYDelta="100%"/>
\ No newline at end of file diff --git a/res/drawable/ic_details_gone.xml b/res/drawable/ic_details_gone.xml new file mode 100644 index 00000000..25a2abc9 --- /dev/null +++ b/res/drawable/ic_details_gone.xml @@ -0,0 +1,27 @@ +<?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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + + <path + android:fillColor="@android:color/transparent" + android:pathData="M11,17h2v-6h-2V17z M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10s10-4.5,10-10S17.5,2,12,2z +M12,20c-4.4,0-8-3.6-8-8s3.6-8,8-8s8,3.6,8,8S16.4,20,12,20z M11,9h2V7h-2V9z" /> +</vector>
\ No newline at end of file diff --git a/res/drawable/ic_object_copy.xml b/res/drawable/ic_object_copy.xml new file mode 100644 index 00000000..afe3feb3 --- /dev/null +++ b/res/drawable/ic_object_copy.xml @@ -0,0 +1,27 @@ +<?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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + + <path + android:fillColor="#FFFFFF" + android:pathData="M16 1h-12c-1.1 0-2 .9-2 2v14h2v-14h12v-2zm3 4h-11c-1.1 0-2 .9-2 2v14c0 1.1 .9 2 +2 2h11c1.1 0 2-.9 2-2v-14c0-1.1-.9-2-2-2zm0 16h-11v-14h11v14z" /> +</vector>
\ No newline at end of file diff --git a/res/drawable/ic_object_share.xml b/res/drawable/ic_object_share.xml new file mode 100644 index 00000000..c116569e --- /dev/null +++ b/res/drawable/ic_object_share.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2015 The Android Open Source 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. +--> + +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + + <path + android:pathData="M0 0h24v24H0z" /> + <path + android:fillColor="#FFFFFF" + android:pathData="M18 16.08c-.76 0-1.44 .3 -1.96 .77 L8.91 12.7c.05-.23 .09 -.46 .09 +-.7s-.04-.47-.09-.7l7.05-4.11c.54 .5 1.25 .81 2.04 .81 1.66 0 3-1.34 +3-3s-1.34-3-3-3-3 1.34-3 3c0 .24 .04 .47 .09 .7L8.04 9.81C7.5 9.31 6.79 9 6 +9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05 .21 -.08 +.43 -.08 .65 0 1.61 1.31 2.92 2.92 2.92 1.61 0 2.92-1.31 +2.92-2.92s-1.31-2.92-2.92-2.92z" /> +</vector>
\ No newline at end of file diff --git a/res/drawable/info_item.xml b/res/drawable/info_item.xml new file mode 100644 index 00000000..77ca59d8 --- /dev/null +++ b/res/drawable/info_item.xml @@ -0,0 +1,22 @@ +<?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. +--> +<selector xmlns:android="http://schemas.android.com/apk/res/android" + android:exitFadeDuration="@android:integer/config_mediumAnimTime" + > + <item android:state_selected="true" android:drawable="@drawable/ic_details_gone" /> + <item android:drawable="@drawable/ic_details" /> +</selector>
\ No newline at end of file diff --git a/res/layout/nav_fragment.xml b/res/layout/nav_fragment.xml index 55bb454f..35dab68c 100644 --- a/res/layout/nav_fragment.xml +++ b/res/layout/nav_fragment.xml @@ -29,47 +29,37 @@ android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:elevation="4dp" + android:theme="@style/FileManager.Theme.Material.NoActionBar" app:layout_collapseMode="pin" /> - <com.cyanogenmod.filemanager.ui.widgets.ScrimInsetsFrameLayout - android:id="@+id/scrimInsetsFrameLayoutNavigation" + <!-- The main content view --> + <FrameLayout + android:id="@+id/navigation_layout" android:layout_width="match_parent" android:layout_height="match_parent" - app:insetForeground="@color/material_palette_blue_primary_dark"> + android:clipChildren="true" + android:clipToPadding="true" + android:background="@drawable/background_drawable"> - <!-- The main content view --> - <LinearLayout - android:id="@+id/navigation_layout" + <!-- Navigation View --> + <com.cyanogenmod.filemanager.ui.widgets.NavigationView + android:id="@+id/navigation_view" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical"> + android:layout_weight="1" + filemanager:navigation="browsable" + android:clipChildren="true"/> - <!-- Navigation View --> - <com.cyanogenmod.filemanager.ui.widgets.NavigationView - android:id="@+id/navigation_view" - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - filemanager:navigation="browsable"/> - - <ListView - android:background="@android:color/white" - android:id="@+id/lv_easy_mode" - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - android:visibility="gone"/> - - <!-- SelectionBar --> - <com.cyanogenmod.filemanager.ui.widgets.SelectionView - android:id="@+id/navigation_selectionbar" - android:layout_width="match_parent" - android:layout_height="@dimen/small_row_height" - android:background="@drawable/bg_material_selectionbar" - android:visibility="invisible"/> - - </LinearLayout> + <!-- SelectionBar --> + <com.cyanogenmod.filemanager.ui.widgets.SelectionView + android:id="@+id/navigation_selectionbar" + android:layout_width="match_parent" + android:elevation="6dp" + android:layout_gravity="bottom" + android:layout_height="@dimen/selection_row_height" + android:background="@drawable/bg_material_selectionbar" + android:visibility="invisible"/> - </com.cyanogenmod.filemanager.ui.widgets.ScrimInsetsFrameLayout> + </FrameLayout> </LinearLayout> diff --git a/res/layout/navigation_view_details_item.xml b/res/layout/navigation_view_details_item.xml index d0dff422..e60755c7 100644 --- a/res/layout/navigation_view_details_item.xml +++ b/res/layout/navigation_view_details_item.xml @@ -48,6 +48,7 @@ android:layout_marginTop="@dimen/extra_margin" android:ellipsize="middle" android:singleLine="true" + android:textColor="@color/text_color" android:textAppearance="@style/primary_text_appearance" /> <TextView @@ -59,6 +60,7 @@ android:layout_marginBottom="@dimen/extra_margin" android:layout_marginStart="@dimen/default_margin" android:singleLine="true" + android:textColor="@color/text_color" android:textAppearance="@style/secondary_text_appearance" /> </RelativeLayout> diff --git a/res/layout/navigation_view_selectionbar.xml b/res/layout/navigation_view_selectionbar.xml index 91878fbb..efc452ed 100644 --- a/res/layout/navigation_view_selectionbar.xml +++ b/res/layout/navigation_view_selectionbar.xml @@ -15,43 +15,19 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="horizontal" > - - <com.cyanogenmod.filemanager.ui.widgets.ButtonItem - android:id="@+id/ab_selection_done" - android:layout_width="@dimen/small_buttom_width" - android:layout_height="@dimen/small_buttom_width" - android:width="@dimen/smallest_buttom_width" - android:height="@dimen/smallest_buttom_width" - android:contentDescription="@string/actionbar_button_selection_done_cd" - android:onClick="onActionBarItemClick" - android:scaleType="fitCenter" - android:src="@drawable/ic_material_light_accept" /> - - <include layout="@layout/horizontal_divider" - android:layout_marginEnd="@dimen/default_margin" /> - - <TextView - android:id="@+id/navigation_status_selection_label" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="1" - android:layout_marginStart="@dimen/default_margin" - android:layout_marginEnd="@dimen/default_margin" - android:singleLine="true" - android:ellipsize="end" - android:gravity="start|center_vertical" - android:text="@null" - android:textAppearance="@style/secondary_text_appearance" /> - - <Button - android:id="@+id/ab_actions" - android:layout_width="wrap_content" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" android:layout_height="match_parent" - android:text="@string/actionbar_button_actions_cd" - android:onClick="onActionBarItemClick" - android:gravity="end"/> + android:orientation="vertical" > + + <android.support.v7.widget.Toolbar + android:id="@+id/selection_toolbar" + android:layout_width="match_parent" + android:layout_height="@dimen/selection_row_height" + android:minHeight="@dimen/selection_row_height" + android:background="#455a64" + android:theme="@style/Base.SelectionToolbar" + app:popupTheme="@style/Theme.AppCompat.Light.NoActionBar" + android:elevation="6dp" /> </LinearLayout> diff --git a/res/layout/selection_view_customtitle.xml b/res/layout/selection_view_customtitle.xml new file mode 100644 index 00000000..bc4aacde --- /dev/null +++ b/res/layout/selection_view_customtitle.xml @@ -0,0 +1,39 @@ +<?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:layout_width="match_parent" + android:layout_height="match_parent" + android:animateLayoutChanges="true" + android:orientation="vertical"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:id="@+id/selector_title" + android:textSize="16sp" + android:singleLine="true" + android:ellipsize="middle" + android:textColor="@color/action_bar_title_text_color"/> + + <TextView + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:id="@+id/selector_subtitle" + android:textSize="14sp" + android:textColor="@color/action_bar_subtitle_text_color"/> + +</LinearLayout> diff --git a/res/menu/selection_menu.xml b/res/menu/selection_menu.xml new file mode 100644 index 00000000..4cad17c9 --- /dev/null +++ b/res/menu/selection_menu.xml @@ -0,0 +1,93 @@ +<?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. +--> +<menu xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> + <!-- Global Actions --> + <group android:id="@+id/mnu_actions_global"> + <item + android:id="@+id/mnu_actions_send" + app:showAsAction="always" + android:icon="@drawable/ic_object_share" + android:title="@string/actions_menu_send"/> + <item + android:id="@+id/mnu_actions_paste" + app:showAsAction="always" + android:icon="@drawable/ic_object_copy" + android:title="@string/actions_menu_paste_selection"/> + <item + android:id="@+id/mnu_actions_move" + app:showAsAction="always" + android:icon="@drawable/ic_object_move" + android:title="@string/actions_menu_move_selection"/> + <item + android:id="@+id/mnu_actions_open" + android:showAsAction="ifRoom" + android:title="@string/actions_menu_open"/> + <item + android:id="@+id/mnu_actions_open_with" + android:showAsAction="ifRoom" + android:title="@string/actions_menu_open_with"/> + <item + android:id="@+id/mnu_actions_delete" + android:showAsAction="ifRoom" + android:title="@string/actions_menu_delete"/> + <item + android:id="@+id/mnu_actions_rename" + android:showAsAction="ifRoom" + android:title="@string/actions_menu_rename"/> + <item + android:id="@+id/mnu_actions_compress" + android:showAsAction="ifRoom" + android:title="@string/actions_menu_compress"/> + <item + android:id="@+id/mnu_actions_extract" + android:showAsAction="ifRoom" + android:title="@string/actions_menu_extract"/> + <item + android:id="@+id/mnu_actions_create_copy" + android:showAsAction="ifRoom" + android:title="@string/actions_menu_create_copy"/> + <item + android:id="@+id/mnu_actions_create_link" + android:showAsAction="ifRoom" + android:title="@string/actions_menu_create_link"/> + <item + android:id="@+id/mnu_actions_execute" + android:showAsAction="ifRoom" + android:title="@string/actions_menu_execute"/> + <item + android:id="@+id/mnu_actions_print" + android:showAsAction="ifRoom" + android:title="@string/actions_menu_print"/> + <item + android:id="@+id/mnu_actions_add_shortcut" + android:showAsAction="ifRoom" + android:title="@string/actions_menu_add_shortcut"/> + <item + android:id="@+id/mnu_actions_compute_checksum" + android:showAsAction="ifRoom" + android:title="@string/actions_menu_compute_checksum"/> + <item + android:id="@+id/mnu_actions_open_parent_folder" + android:showAsAction="ifRoom" + android:title="@string/actions_menu_open_parent_folder"/> + <item + android:id="@+id/mnu_actions_deselect_all" + android:showAsAction="ifRoom" + android:title="@string/actions_deselect_all" /> + </group> +</menu>
\ No newline at end of file diff --git a/res/values/colors.xml b/res/values/colors.xml index ef3ee9fb..f85ad947 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -84,6 +84,7 @@ <!-- The text color of the ActionBar --> <color name="action_bar_text_color">@android:color/white</color> <color name="action_bar_title_text_color">#deffffff</color> + <color name="action_bar_subtitle_text_color">#8bffffff</color> <!-- Breadcrumb text color --> <color name="breadcrumb_text_color">#deffffff</color> diff --git a/res/values/dimen.xml b/res/values/dimen.xml index c5fa1326..67278575 100644 --- a/res/values/dimen.xml +++ b/res/values/dimen.xml @@ -51,6 +51,8 @@ <dimen name="small_margin">2dp</dimen> <!-- The minimal margin --> <dimen name="min_margin">1dp</dimen> + <!-- The default row height --> + <dimen name="selection_row_height">72dp</dimen> <!-- The breadcrumb item margin space --> <dimen name="breadcrumb_item_margin_space">3dp</dimen> diff --git a/res/values/plurals.xml b/res/values/plurals.xml index b7311229..30630179 100644 --- a/res/values/plurals.xml +++ b/res/values/plurals.xml @@ -24,6 +24,16 @@ <item quantity="other"><xliff:g id="files">%1$d</xliff:g> files</item> </plurals> + <plurals name="folders"> + <item quantity="one">Folder</item> + <item quantity="other">Folders</item> + </plurals> + + <!-- Statusbar text if there are selected files or folders --> + <plurals name="selection"> + <item quantity="other"><xliff:g id="folders">%1$d</xliff:g> selected</item> + </plurals> + <!-- Search - Found items --> <plurals name="search_found_items"> <item quantity="one"><xliff:g id="count">%1$d</xliff:g> item found</item> diff --git a/res/values/strings.xml b/res/values/strings.xml index f44cba21..f7eee320 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -517,9 +517,9 @@ <!-- Actions Dialog - Menu - Execute --> <string name="actions_menu_execute">Execute</string> <!-- Actions Dialog - Menu - Send --> - <string name="actions_menu_send">Send</string> + <string name="actions_menu_send">Share</string> <!-- Actions Dialog - Menu - Send selection --> - <string name="actions_menu_send_selection">Send selection</string> + <string name="actions_menu_send_selection">Share selection</string> <!-- Actions Dialog - Menu - Compress --> <string name="actions_menu_compress">Compress</string> <!-- Actions Dialog - Menu - Extract --> @@ -544,6 +544,8 @@ <string name="actions_menu_print">Print</string> <!-- Actions Dialog - Menu - Set as home --> <string name="actions_menu_set_as_home">Set as home</string> + <!-- Selection Dialog --> + <string name="actions_deselect_all">Clear selection</string> <!-- Actions - Ask user prior to do an undone operation. Dialog message --> <string name="actions_ask_undone_operation_msg">This action cannot be undone. Do you want to continue?</string> @@ -615,7 +617,7 @@ <!-- Selection --> <!-- For example "2 folders and 1 file selected." --> - <string name="selection_folders_and_files"><xliff:g id="folders">%1$s</xliff:g> and <xliff:g id="files">%2$s</xliff:g> selected.</string> + <string name="selection_folders_and_files"><xliff:g id="folders">%1$s</xliff:g>, <xliff:g id="files">%2$s</xliff:g></string> <!-- Category descriptions --> <string name="category_system">SYSTEM</string> diff --git a/res/values/styles.xml b/res/values/styles.xml index fe9de189..5260addc 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -31,6 +31,14 @@ <item name="android:dropDownListViewStyle">@style/dropDownListViewStyle</item> </style> + <style name="Base.SelectionToolbar" parent="Theme.AppCompat.NoActionBar"> + <item name="android:textColorPrimary">@color/action_bar_text_color</item> + <item name="android:textStyle">normal</item> + <item name="android:textColorPrimaryInverse">@color/action_bar_text_color</item> + <item name="actionMenuTextColor">@color/text_color</item> + <item name="android:textColorSecondary">@color/action_bar_text_color</item> + </style> + <style name="Widget.FileManager.ActionBar" parent="Widget.AppCompat.ActionBar"> <item name="android:background">@color/material_palette_blue_primary</item> <item name="android:theme">@style/ThemeOverlay.FileManager.ActionBar</item> diff --git a/src/com/cyanogenmod/filemanager/FileManagerApplication.java b/src/com/cyanogenmod/filemanager/FileManagerApplication.java index 245d4241..4cf30960 100644 --- a/src/com/cyanogenmod/filemanager/FileManagerApplication.java +++ b/src/com/cyanogenmod/filemanager/FileManagerApplication.java @@ -39,8 +39,6 @@ import com.cyanogenmod.filemanager.preferences.ObjectStringIdentifier; import com.cyanogenmod.filemanager.preferences.Preferences; import com.cyanogenmod.filemanager.providers.secure.SecureCacheCleanupService; import com.cyanogenmod.filemanager.service.MimeTypeIndexService; -import com.cyanogenmod.filemanager.ui.ThemeManager; -import com.cyanogenmod.filemanager.ui.ThemeManager.Theme; import com.cyanogenmod.filemanager.util.AIDHelper; import com.cyanogenmod.filemanager.util.AndroidHelper; import com.cyanogenmod.filemanager.util.MimeTypeHelper; @@ -113,62 +111,6 @@ public final class FileManagerApplication extends Application { } }; - // A broadcast receiver for detect the install/uninstall of apps (for themes, AIDs, ...) - private final BroadcastReceiver mUninstallReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (intent != null) { - if (intent.getAction().compareTo(Intent.ACTION_PACKAGE_REMOVED) == 0 || - intent.getAction().compareTo(Intent.ACTION_PACKAGE_FULLY_REMOVED) == 0) { - // Check that the remove package is not the current theme - if (intent.getData() != null) { - // --- AIDs - try { - AIDHelper.getAIDs(getApplicationContext(), true); - } catch (Exception e) { - Log.w(TAG, "Failed to reload AIDs", e); //$NON-NLS-1$ - } - - // --- Themes - try { - // Get the package name and remove the schema - String apkPackage = intent.getData().toString(); - apkPackage = apkPackage.substring("package:".length()); //$NON-NLS-1$ - - Theme currentTheme = ThemeManager.getCurrentTheme(context); - if (currentTheme.getPackage().compareTo(apkPackage) == 0) { - // The apk that contains the current theme was remove, change - // to default theme - String composedId = - (String)FileManagerSettings.SETTINGS_THEME.getDefaultValue(); - ThemeManager.setCurrentTheme(getApplicationContext(), composedId); - try { - Preferences.savePreference( - FileManagerSettings.SETTINGS_THEME, composedId, true); - } catch (Throwable ex) { - Log.w(TAG, "can't save theme preference", ex); //$NON-NLS-1$ - } - - // Notify the changes to activities - try { - Intent broadcastIntent = - new Intent(FileManagerSettings.INTENT_THEME_CHANGED); - broadcastIntent.putExtra( - FileManagerSettings.EXTRA_THEME_ID, composedId); - sendBroadcast(broadcastIntent); - } catch (Throwable ex) { - Log.w(TAG, "notify of theme change failed", ex); //$NON-NLS-1$ - } - } - } catch (Exception e) { - Log.w(TAG, "Failed to reload themes", e); //$NON-NLS-1$ - } - } - } - } - } - }; - private IMostStarUsedFilesManager mMStarUManager; @@ -214,11 +156,6 @@ public final class FileManagerApplication extends Application { /**NON BLOCK**/ } try { - unregisterReceiver(this.mUninstallReceiver); - } catch (Throwable ex) { - /**NON BLOCK**/ - } - try { destroyBackgroundConsole(); } catch (Throwable ex) { /**NON BLOCK**/ @@ -239,13 +176,6 @@ public final class FileManagerApplication extends Application { IntentFilter filter = new IntentFilter(); filter.addAction(FileManagerSettings.INTENT_SETTING_CHANGED); registerReceiver(this.mNotificationReceiver, filter); - - // Register the uninstall broadcast receiver - IntentFilter unfilter = new IntentFilter(); - unfilter.addAction(Intent.ACTION_PACKAGE_REMOVED); - unfilter.addAction(Intent.ACTION_PACKAGE_FULLY_REMOVED); - unfilter.addDataScheme("package"); //$NON-NLS-1$ - registerReceiver(this.mUninstallReceiver, unfilter); } /** @@ -275,27 +205,6 @@ public final class FileManagerApplication extends Application { // Read AIDs AIDHelper.getAIDs(getApplicationContext(), true); - // Allocate the default and current themes - String defaultValue = ((String)FileManagerSettings. - SETTINGS_THEME.getDefaultValue()); - String value = Preferences.getSharedPreferences().getString( - FileManagerSettings.SETTINGS_THEME.getId(), - defaultValue); - ThemeManager.getDefaultTheme(getApplicationContext()); - if (!ThemeManager.setCurrentTheme(getApplicationContext(), value)) { - //The current theme was not found. Mark the default setting as default theme - ThemeManager.setCurrentTheme(getApplicationContext(), defaultValue); - try { - Preferences.savePreference( - FileManagerSettings.SETTINGS_THEME, defaultValue, true); - } catch (Throwable ex) { - Log.w(TAG, "can't save theme preference", ex); //$NON-NLS-1$ - } - } - // Set the base theme - Theme theme = ThemeManager.getCurrentTheme(getApplicationContext()); - theme.setBaseTheme(getApplicationContext(), false); - //Create a console for background tasks. Register the virtual console prior to // the real console so mount point can be listed properly VirtualMountPointConsole.registerVirtualConsoles(getApplicationContext()); @@ -353,10 +262,7 @@ public final class FileManagerApplication extends Application { * @return boolean If the command is present */ public static boolean hasOptionalCommand(String commandId) { - if (!sOptionalCommandsMap.containsKey(commandId)) { - return false; - } - return sOptionalCommandsMap.get(commandId).booleanValue(); + return sOptionalCommandsMap.containsKey(commandId) && sOptionalCommandsMap.get(commandId); } /** @@ -472,9 +378,7 @@ public final class FileManagerApplication extends Application { ((ObjectStringIdentifier)FileManagerSettings. SETTINGS_ACCESS_MODE.getDefaultValue()).getId(); String id = FileManagerSettings.SETTINGS_ACCESS_MODE.getId(); - AccessMode mode = - AccessMode.fromId(Preferences.getSharedPreferences().getString(id, defaultValue)); - return mode; + return AccessMode.fromId(Preferences.getSharedPreferences().getString(id, defaultValue)); } public static boolean isRestrictSecondaryUsersAccess(Context context) { @@ -543,8 +447,8 @@ public final class FileManagerApplication extends Application { Log.w(TAG, "No shell commands."); //$NON-NLS-1$ return false; } - for (int i = 0; i < cc; i++) { - String c = commands[i].trim(); + for (String command : commands) { + String c = command.trim(); if (c.length() == 0) continue; File cmd = new File(c); if (!cmd.exists() || !cmd.isFile()) { @@ -604,10 +508,10 @@ public final class FileManagerApplication extends Application { Log.w(TAG, "No optional commands."); //$NON-NLS-1$ return; } - for (int i = 0; i < cc; i++) { - String c = commands[i].trim(); + for (String command : commands) { + String c = command.trim(); String key = c.substring(0, c.indexOf("=")).trim(); //$NON-NLS-1$ - c = c.substring(c.indexOf("=")+1).trim(); //$NON-NLS-1$ + c = c.substring(c.indexOf("=") + 1).trim(); //$NON-NLS-1$ if (c.length() == 0) continue; File cmd = new File(c); Boolean found = Boolean.valueOf(cmd.exists() && cmd.isFile()); diff --git a/src/com/cyanogenmod/filemanager/activities/MainActivity.java b/src/com/cyanogenmod/filemanager/activities/MainActivity.java index 9b3a4c84..2ec12849 100755 --- a/src/com/cyanogenmod/filemanager/activities/MainActivity.java +++ b/src/com/cyanogenmod/filemanager/activities/MainActivity.java @@ -642,32 +642,6 @@ public class MainActivity extends ActionBarActivity } /** - * Method invoked when an action item is clicked. - * - * @param view The button pushed - */ - public void onActionBarItemClick(android.view.View view) { - - if (currentFragment instanceof NavigationFragment) { - NavigationFragment navigationFragment = ((NavigationFragment)currentFragment); - switch (view.getId()) { - //###################### - //Selection Actions - //###################### - case R.id.ab_selection_done: - //Show information of the filesystem - navigationFragment.getCurrentNavigationView().onDeselectAll(); - break; - case R.id.ab_actions: - // Show the actions dialog - navigationFragment.openActionsDialog(null, true); - default: - break; - } - } - } - - /** * Method that opens the settings activity. * * @hide diff --git a/src/com/cyanogenmod/filemanager/adapters/FileSystemObjectAdapter.java b/src/com/cyanogenmod/filemanager/adapters/FileSystemObjectAdapter.java index bb5f940d..e655fce1 100644 --- a/src/com/cyanogenmod/filemanager/adapters/FileSystemObjectAdapter.java +++ b/src/com/cyanogenmod/filemanager/adapters/FileSystemObjectAdapter.java @@ -32,6 +32,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; + import android.widget.ArrayAdapter; import android.widget.ImageButton; import android.widget.ImageView; @@ -46,9 +47,6 @@ import com.cyanogenmod.filemanager.preferences.FileManagerSettings; import com.cyanogenmod.filemanager.preferences.Preferences; import com.cyanogenmod.filemanager.ui.IconHolder; import com.cyanogenmod.filemanager.ui.IconHolder.ICallback; -import com.cyanogenmod.filemanager.ui.ThemeManager; -import com.cyanogenmod.filemanager.ui.ThemeManager.Theme; -import com.cyanogenmod.filemanager.ui.dialogs.ActionsDialog; import com.cyanogenmod.filemanager.ui.policy.InfoActionPolicy; import com.cyanogenmod.filemanager.util.CommandHelper; import com.cyanogenmod.filemanager.util.ExceptionUtil; @@ -231,8 +229,6 @@ public class FileSystemObjectAdapter if (!mPickable) { viewHolder.mIvIcon.setOnClickListener(this); viewHolder.mBtInfo.setOnClickListener(this); - } else { - viewHolder.mBtInfo.setVisibility(View.GONE); } v.setTag(viewHolder); } @@ -340,7 +336,6 @@ public class FileSystemObjectAdapter this.mOnSelectionChangedListener.onSelectionChanged( new ArrayList<FileSystemObject>(mSelectedItems)); } - notifyDataSetChanged(); } diff --git a/src/com/cyanogenmod/filemanager/model/History.java b/src/com/cyanogenmod/filemanager/model/History.java index 07c73f0d..2c07b450 100644 --- a/src/com/cyanogenmod/filemanager/model/History.java +++ b/src/com/cyanogenmod/filemanager/model/History.java @@ -16,11 +16,7 @@ package com.cyanogenmod.filemanager.model; -import android.net.Uri; -import android.provider.BaseColumns; - import com.cyanogenmod.filemanager.parcelables.HistoryNavigable; -import com.cyanogenmod.filemanager.providers.BookmarksContentProvider; import java.io.Serializable; @@ -47,63 +43,6 @@ public class History implements Serializable, Comparable<History> { } /** - * Columns of the database - */ - public static class Columns implements BaseColumns { - /** - * The content:// style URL for this table - */ - public static final Uri CONTENT_URI = - Uri.parse(String.format( - "%s%s/%s", //$NON-NLS-1$ - "content://", //$NON-NLS-1$ - BookmarksContentProvider.AUTHORITY, - "/history")); //$NON-NLS-1$ - - /** - * The title of the history - * <P>Type: TEXT</P> - */ - public static final String TITLE = "title"; //$NON-NLS-1$ - - /** - * The description of the history - * <P>Type: TEXT</P> - */ - public static final String DESCRIPTION = "description"; //$NON-NLS-1$ - - /** - * The default sort order for this table - */ - public static final String DEFAULT_SORT_ORDER = - DESCRIPTION + " ASC"; //$NON-NLS-1$ - - /** - * @hide - */ - public static final String[] HISTORY_QUERY_COLUMNS = - { _ID, TITLE, DESCRIPTION }; - - /** - * These save calls to cursor.getColumnIndexOrThrow() - * THEY MUST BE KEPT IN SYNC WITH ABOVE QUERY COLUMNS - * - * @hide - */ - public static final int HISTORY_ID_INDEX = 0; - - /** - * @hide - */ - public static final int HISTORY_TITLE_INDEX = 1; - - /** - * @hide - */ - public static final int HISTORY_DESCRIPTION_INDEX = 2; - } - - /** * Method that returns the position of the history. * * @return int The history position diff --git a/src/com/cyanogenmod/filemanager/preferences/BookmarksDatabaseHelper.java b/src/com/cyanogenmod/filemanager/preferences/BookmarksDatabaseHelper.java index d0d5061b..f5b3e465 100644 --- a/src/com/cyanogenmod/filemanager/preferences/BookmarksDatabaseHelper.java +++ b/src/com/cyanogenmod/filemanager/preferences/BookmarksDatabaseHelper.java @@ -51,11 +51,6 @@ public class BookmarksDatabaseHelper extends SQLiteOpenHelper { db.execSQL("CREATE TABLE bookmarks (" + //$NON-NLS-1$ "_id INTEGER PRIMARY KEY," + //$NON-NLS-1$ "path TEXT);"); //$NON-NLS-1$ - - db.execSQL("CREATE TABLE history (" + //$NON-NLS-1$ - "_id INTEGER PRIMARY KEY," + //$NON-NLS-1$ - "title TEXT," + //$NON-NLS-1$ - "description TEXT);"); //$NON-NLS-1$ } /** diff --git a/src/com/cyanogenmod/filemanager/providers/BookmarksContentProvider.java b/src/com/cyanogenmod/filemanager/providers/BookmarksContentProvider.java index 2846951e..254ebde9 100644 --- a/src/com/cyanogenmod/filemanager/providers/BookmarksContentProvider.java +++ b/src/com/cyanogenmod/filemanager/providers/BookmarksContentProvider.java @@ -29,7 +29,6 @@ import android.text.TextUtils; import android.util.Log; import com.cyanogenmod.filemanager.model.Bookmark; -import com.cyanogenmod.filemanager.model.History; import com.cyanogenmod.filemanager.preferences.BookmarksDatabaseHelper; /** @@ -45,8 +44,6 @@ public class BookmarksContentProvider extends ContentProvider { private static final int BOOKMARKS = 1; private static final int BOOKMARKS_ID = 2; - private static final int HISTORY = 3; - private static final int HISTORY_ID = 4; /** * The authority string name. @@ -63,13 +60,6 @@ public class BookmarksContentProvider extends ContentProvider { sURLMatcher.addURI( AUTHORITY, "bookmarks/#", BOOKMARKS_ID); //$NON-NLS-1$ - - sURLMatcher.addURI( - AUTHORITY, - "history", HISTORY); //$NON-NLS-1$ - sURLMatcher.addURI( - AUTHORITY, - "history/#", HISTORY_ID); //$NON-NLS-1$ } /** @@ -107,14 +97,6 @@ public class BookmarksContentProvider extends ContentProvider { qb.appendWhere("_id="); //$NON-NLS-1$ qb.appendWhere(url.getPathSegments().get(1)); break; - case HISTORY: - qb.setTables("history"); //$NON-NLS-1$ - break; - case HISTORY_ID: - qb.setTables("history"); //$NON-NLS-1$ - qb.appendWhere("_id="); //$NON-NLS-1$ - qb.appendWhere(url.getPathSegments().get(1)); - break; default: throw new IllegalArgumentException("Unknown URL " + url); //$NON-NLS-1$ } @@ -145,10 +127,6 @@ public class BookmarksContentProvider extends ContentProvider { return "vnd.android.cursor.dir/bookmarks"; //$NON-NLS-1$ case BOOKMARKS_ID: return "vnd.android.cursor.item/bookmarks"; //$NON-NLS-1$ - case HISTORY: - return "vnd.android.cursor.dir/history"; //$NON-NLS-1$ - case HISTORY_ID: - return "vnd.android.cursor.item/history"; //$NON-NLS-1$ default: throw new IllegalArgumentException("Unknown URL"); //$NON-NLS-1$ } @@ -171,13 +149,6 @@ public class BookmarksContentProvider extends ContentProvider { "bookmarks", values, "_id=" + rowId, null); //$NON-NLS-1$ //$NON-NLS-2$ break; } - case HISTORY_ID: { - final String segment = url.getPathSegments().get(1); - rowId = Long.parseLong(segment); - count = db.update( - "history", values, "_id=" + rowId, null); //$NON-NLS-1$ //$NON-NLS-2$ - break; - } default: { throw new UnsupportedOperationException( "Cannot update URL: " + url); //$NON-NLS-1$ @@ -197,31 +168,20 @@ public class BookmarksContentProvider extends ContentProvider { */ @Override public Uri insert(Uri url, ContentValues initialValues) { - if (sURLMatcher.match(url) != BOOKMARKS - && sURLMatcher.match(url) != HISTORY) { + if (sURLMatcher.match(url) != BOOKMARKS) { throw new IllegalArgumentException("Cannot insert into URL: " + url); //$NON-NLS-1$ } // Add the bookmark SQLiteDatabase db = this.mOpenHelper.getWritableDatabase(); - String tablename = null; - Uri uri = null; - - if (sURLMatcher.match(url) == BOOKMARKS) { - tablename = "bookmarks"; - uri = Bookmark.Columns.CONTENT_URI; - } else { - tablename = "history"; - uri = History.Columns.CONTENT_URI; - } - long rowId = db.insert(tablename, null, initialValues); //$NON-NLS-1$ + long rowId = db.insert("bookmarks", null, initialValues); //$NON-NLS-1$ if (rowId < 0) { throw new SQLException("Failed to insert row"); //$NON-NLS-1$ } if (DEBUG) { - Log.v(TAG, "Added" + tablename + "rowId = " + rowId); //$NON-NLS-1$ + Log.v(TAG, "Added bookmark rowId = " + rowId); //$NON-NLS-1$ } - Uri newUrl = ContentUris.withAppendedId(uri, rowId); + Uri newUrl = ContentUris.withAppendedId(Bookmark.Columns.CONTENT_URI, rowId); // Notify changes getContext().getContentResolver().notifyChange(newUrl, null); @@ -241,7 +201,7 @@ public class BookmarksContentProvider extends ContentProvider { count = db.delete("bookmarks", whereQuery, whereArgs); //$NON-NLS-1$ break; case BOOKMARKS_ID: - final String segment = url.getPathSegments().get(1); + String segment = url.getPathSegments().get(1); if (TextUtils.isEmpty(whereQuery)) { whereQuery = "_id=" + segment; //$NON-NLS-1$ } else { @@ -250,20 +210,6 @@ public class BookmarksContentProvider extends ContentProvider { } count = db.delete("bookmarks", whereQuery, whereArgs); //$NON-NLS-1$ break; - case HISTORY: - db.execSQL("delete from history"); - count = 0; - break; - case HISTORY_ID: - String segment_h = url.getPathSegments().get(1); - if (TextUtils.isEmpty(whereQuery)) { - whereQuery = "_id=" + segment_h; //$NON-NLS-1$ - } else { - whereQuery = "_id=" + segment_h + //$NON-NLS-1$ - " AND (" + whereQuery + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } - count = db.delete("history", whereQuery, whereArgs); //$NON-NLS-1$ - break; default: throw new IllegalArgumentException("Cannot delete from URL: " + url); //$NON-NLS-1$ } diff --git a/src/com/cyanogenmod/filemanager/ui/dialogs/InputNameDialog.java b/src/com/cyanogenmod/filemanager/ui/dialogs/InputNameDialog.java index 36cf1d1e..56ad4335 100644 --- a/src/com/cyanogenmod/filemanager/ui/dialogs/InputNameDialog.java +++ b/src/com/cyanogenmod/filemanager/ui/dialogs/InputNameDialog.java @@ -222,6 +222,13 @@ public class InputNameDialog } /** + * Method that returns the current file system object that action is being preformed on + * + * @return FileSystemObject the file that the user is modifying + */ + public FileSystemObject getFso() { return this.mFso; } + + /** * {@inheritDoc} */ @Override diff --git a/src/com/cyanogenmod/filemanager/ui/fragments/NavigationFragment.java b/src/com/cyanogenmod/filemanager/ui/fragments/NavigationFragment.java index 27c72f25..647ba005 100644 --- a/src/com/cyanogenmod/filemanager/ui/fragments/NavigationFragment.java +++ b/src/com/cyanogenmod/filemanager/ui/fragments/NavigationFragment.java @@ -30,21 +30,11 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.res.Configuration; -import android.content.res.XmlResourceParser; -import android.database.Cursor; -import android.graphics.BitmapShader; import android.graphics.Color; -import android.graphics.ColorFilter; -import android.graphics.Paint; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; -import android.graphics.drawable.ColorDrawable; -import android.graphics.drawable.Drawable; import android.Manifest; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; -import android.os.Environment; import android.os.Handler; import android.os.Parcel; import android.os.Parcelable; @@ -62,93 +52,76 @@ 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.PopupWindow; import android.widget.SearchView; import android.widget.TextView; import android.widget.Toast; -import com.android.internal.util.XmlUtils; import com.cyanogenmod.filemanager.FileManagerApplication; import com.cyanogenmod.filemanager.R; import com.cyanogenmod.filemanager.activities.MainActivity; import com.cyanogenmod.filemanager.activities.SearchActivity; -import com.cyanogenmod.filemanager.activities.preferences.SettingsPreferences; -import com.cyanogenmod.filemanager.adapters.MenuSettingsAdapter; 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.VirtualMountPointConsole; import com.cyanogenmod.filemanager.console.secure.SecureConsole; import com.cyanogenmod.filemanager.dialogs.SortViewOptions; import com.cyanogenmod.filemanager.listeners.OnHistoryListener; import com.cyanogenmod.filemanager.listeners.OnRequestRefreshListener; -import com.cyanogenmod.filemanager.model.Bookmark; import com.cyanogenmod.filemanager.model.DiskUsage; import com.cyanogenmod.filemanager.model.FileSystemObject; import com.cyanogenmod.filemanager.model.History; import com.cyanogenmod.filemanager.model.MountPoint; -import com.cyanogenmod.filemanager.model.Bookmark.BOOKMARK_TYPE; import com.cyanogenmod.filemanager.parcelables.HistoryNavigable; import com.cyanogenmod.filemanager.parcelables.NavigationViewInfoParcelable; import com.cyanogenmod.filemanager.parcelables.SearchInfoParcelable; import com.cyanogenmod.filemanager.preferences.AccessMode; -import com.cyanogenmod.filemanager.preferences.Bookmarks; import com.cyanogenmod.filemanager.preferences.FileManagerSettings; import com.cyanogenmod.filemanager.preferences.NavigationLayoutMode; import com.cyanogenmod.filemanager.preferences.ObjectIdentifier; import com.cyanogenmod.filemanager.preferences.PreferenceHelper; import com.cyanogenmod.filemanager.preferences.Preferences; import com.cyanogenmod.filemanager.tasks.FileSystemInfoTask; -import com.cyanogenmod.filemanager.tasks.FilesystemAsyncTask; -import com.cyanogenmod.filemanager.ui.IconHolder; -import com.cyanogenmod.filemanager.ui.ThemeManager; -import com.cyanogenmod.filemanager.ui.ThemeManager.Theme; import com.cyanogenmod.filemanager.ui.dialogs.ActionsDialog; 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.dialogs.InputNameDialog; +import com.cyanogenmod.filemanager.ui.policy.CompressActionPolicy; import com.cyanogenmod.filemanager.ui.policy.CopyMoveActionPolicy; +import com.cyanogenmod.filemanager.ui.policy.DeleteActionPolicy; +import com.cyanogenmod.filemanager.ui.policy.ExecutionActionPolicy; import com.cyanogenmod.filemanager.ui.policy.InfoActionPolicy; +import com.cyanogenmod.filemanager.ui.policy.IntentsActionPolicy; +import com.cyanogenmod.filemanager.ui.policy.NewActionPolicy; +import com.cyanogenmod.filemanager.ui.policy.PrintActionPolicy; import com.cyanogenmod.filemanager.ui.widgets.Breadcrumb; -import com.cyanogenmod.filemanager.ui.widgets.ButtonItem; -import com.cyanogenmod.filemanager.ui.widgets.NavigationCustomTitleView; import com.cyanogenmod.filemanager.ui.widgets.NavigationView; import com.cyanogenmod.filemanager.ui.widgets.NavigationView.OnBackRequestListener; import com.cyanogenmod.filemanager.ui.widgets.NavigationView.OnDirectoryChangedListener; -import com.cyanogenmod.filemanager.ui.widgets.NavigationView.OnNavigationRequestMenuListener; import com.cyanogenmod.filemanager.ui.widgets.NavigationView.OnNavigationSelectionChangedListener; import com.cyanogenmod.filemanager.ui.widgets.SelectionView; import com.cyanogenmod.filemanager.util.AndroidHelper; -import com.cyanogenmod.filemanager.util.BookmarksHelper; import com.cyanogenmod.filemanager.util.CommandHelper; import com.cyanogenmod.filemanager.util.DialogHelper; import com.cyanogenmod.filemanager.util.ExceptionUtil; import com.cyanogenmod.filemanager.util.FileHelper; -import com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory; import com.cyanogenmod.filemanager.util.MountPointHelper; import com.cyanogenmod.filemanager.util.StorageHelper; import com.cyngn.uicommon.view.Snackbar; import java.io.File; -import java.io.FileNotFoundException; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Locale; -import java.util.Map; +import static com.cyanogenmod.filemanager.activities.PickerActivity.ACTION_MODE.COPY; +import static com.cyanogenmod.filemanager.activities.PickerActivity.ACTION_MODE.MOVE; +import static com.cyanogenmod.filemanager.activities.PickerActivity.EXTRA_ACTION; import static com.cyanogenmod.filemanager.activities.PickerActivity.EXTRA_FOLDER_PATH; +import static com.cyanogenmod.filemanager.activities.PickerActivity.INTENT_FOLDER_SELECT; /** * The main navigation activity. This activity is the center of the application. @@ -164,19 +137,13 @@ import static com.cyanogenmod.filemanager.activities.PickerActivity.EXTRA_FOLDER */ public class NavigationFragment extends Fragment implements OnHistoryListener, OnRequestRefreshListener, - OnNavigationRequestMenuListener, OnNavigationSelectionChangedListener, - OnDirectoryChangedListener { + OnNavigationSelectionChangedListener, OnDirectoryChangedListener, + Toolbar.OnMenuItemClickListener{ private static final String TAG = "NavigationFragment"; //$NON-NLS-1$ private static boolean DEBUG = false; - // Bookmark list XML tags - 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. */ @@ -221,18 +188,10 @@ public class NavigationFragment extends Fragment 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 InputMethodManager mImm; - private ListPopupWindow mPopupWindow; private ActionsDialog mActionsDialog; private View mTitleLayout; - private View mStatusBar; private OnBackRequestListener mOnBackRequestListener; private OnGoHomeRequestListener mOnGoHomeRequestListener; @@ -266,9 +225,11 @@ public class NavigationFragment extends Fragment Breadcrumb breadcrumb = getCurrentNavigationView().getBreadcrumb(); if (breadcrumb != null) { String fds = Preferences.getSharedPreferences().getString( - FileManagerSettings.SETTINGS_DISK_USAGE_WARNING_LEVEL.getId(), + FileManagerSettings.SETTINGS_DISK_USAGE_WARNING_LEVEL + .getId(), (String)FileManagerSettings. - SETTINGS_DISK_USAGE_WARNING_LEVEL.getDefaultValue()); + SETTINGS_DISK_USAGE_WARNING_LEVEL + .getDefaultValue()); mFreeDiskSpaceWarningLevel = Integer.parseInt(fds); breadcrumb.setFreeDiskSpaceWarningLevel(mFreeDiskSpaceWarningLevel); breadcrumb.updateMountPointInfo(); @@ -306,9 +267,9 @@ public class NavigationFragment extends Fragment boolean useFlinger = Preferences.getSharedPreferences().getBoolean( FileManagerSettings.SETTINGS_USE_FLINGER.getId(), - ((Boolean)FileManagerSettings. - SETTINGS_USE_FLINGER. - getDefaultValue()).booleanValue()); + (Boolean) FileManagerSettings. + SETTINGS_USE_FLINGER. + getDefaultValue()); getCurrentNavigationView().setUseFlinger(useFlinger); return; } @@ -415,13 +376,6 @@ public class NavigationFragment extends Fragment } }; - static String MIME_TYPE_LOCALIZED_NAMES[]; - /** - * @hide - */ - static Map<MimeTypeCategory, Drawable> EASY_MODE_ICONS = new - HashMap<MimeTypeCategory, Drawable>(); - /** * @hide */ @@ -438,25 +392,8 @@ public class NavigationFragment extends Fragment private List<History> mHistorySaved; private ViewGroup mActionBar; - private SelectionView mSelectionBar; - - 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 SelectionView mSelectionBar; private Dialog mActiveDialog = null; @@ -476,10 +413,10 @@ public class NavigationFragment extends Fragment * @hide */ Handler mHandler; + View mView; LayoutInflater mLayoutInflater; - private AsyncTask<Void, Void, Boolean> mBookmarksTask; private AsyncTask<Void, Void, Boolean> mHistoryTask; public View onCreateView( @@ -492,10 +429,6 @@ public class NavigationFragment extends Fragment Log.d(TAG, "NavigationFragment.onCreate"); //$NON-NLS-1$ } - // Set the theme before setContentView - ThemeManager.Theme theme = ThemeManager.getCurrentTheme(getActivity()); - theme.setBaseThemeNoActionBar(getActivity()); - //Set the main layout of the activity mView = inflater.inflate(R.layout.nav_fragment, container, false); @@ -515,7 +448,6 @@ public class NavigationFragment extends Fragment //Initialize action bars initTitleActionBar(); initSelectionBar(); - initHistory(); // Apply the theme applyTheme(); @@ -553,58 +485,8 @@ public class NavigationFragment extends Fragment @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.mnu_actions_select_all: - getCurrentNavigationView().onSelectAllVisibleItems(); - return true; - case R.id.mnu_actions_refresh: - onRequestRefresh(null, false); - return true; - case R.id.mnu_actions_search: - toggleSearch(); - return true; - case R.id.mnu_actions_sort: - SortViewOptions.createSortDialog(getActivity(), - FileManagerSettings.SETTINGS_SORT_MODE, - new SortViewOptions.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which, int result) { - if (which == DialogInterface.BUTTON_POSITIVE) { - if (PreferenceHelper.getIntPreference( - FileManagerSettings.SETTINGS_SORT_MODE) != result) { - updateSetting( - FileManagerSettings.SETTINGS_SORT_MODE, result); - } - } - } - }) - .show(); - return true; - case R.id.mnu_actions_new_directory: - ActionsDialog.showInputNameDialog(getActivity(), - getString(R.string.actions_menu_new_directory), item.getItemId(), - getCurrentNavigationView().getFiles(), getCurrentNavigationView(), this); - return true; - case R.id.mnu_actions_new_file: - ActionsDialog.showInputNameDialog(getActivity(), - getString(R.string.actions_menu_new_file), item.getItemId(), - getCurrentNavigationView().getFiles(), getCurrentNavigationView(), this); - return true; - case R.id.mnu_actions_properties_current_folder: - InfoActionPolicy.showPropertiesDialog(getActivity(), - getCurrentNavigationView().getCurrentFso(), this); - return true; - case R.id.mnu_actions_file_system_info: - if (mMountPoint != null && mDiskUsage != null) { - showMountPointInfo(mMountPoint, mDiskUsage); - } else { - Toast.makeText(getActivity(), getString(R.string.file_system_info_unavailable), - Toast.LENGTH_SHORT).show(); - } - return true; - default: - return false; - } + fileActions(item, null); + return true; } @Override @@ -712,7 +594,6 @@ public class NavigationFragment extends Fragment */ private void init() { this.mHistory = new ArrayList<History>(); - this.mHistorySaved = new ArrayList<History>(); this.mChRooted = FileManagerApplication.getAccessMode().compareTo(AccessMode.SAFE) == 0; } @@ -733,512 +614,8 @@ public class NavigationFragment extends Fragment */ private void initSelectionBar() { this.mSelectionBar = (SelectionView) mView.findViewById(R.id.navigation_selectionbar); - } - - /** - * Method that initializes the navigation drawer of the activity. - */ - private void initDrawer() { - // TODO: Move into MainActivity or remove altogether. - /*mDrawerLayout = (android.support.v4.widget.DrawerLayout) mView.findViewById( - R.id.drawer_layout); - //Set our status bar color - mDrawerLayout.setStatusBarBackgroundColor(R.color.material_palette_blue_primary_dark); - mDrawer = (ViewGroup) mView.findViewById( - R.id.drawer); - mDrawerBookmarks = (android.widget.LinearLayout) mView.findViewById( - R.id.bookmarks_list); - mDrawerHistory = (android.widget.LinearLayout) mView.findViewById( - R.id.history_list); - mDrawerHistoryEmpty = (TextView) mView.findViewById( - R.id.history_empty); - - mBookmarksLayout = mView.findViewById(R.id.drawer_bookmarks); - mHistoryLayout = mView.findViewById(R.id.drawer_history); - mBookmarksTab = (TextView) mView.findViewById( - R.id.drawer_bookmarks_tab); - mHistoryTab = (TextView) mView.findViewById( - R.id.drawer_history_tab); - mBookmarksTab.setOnClickListener(mOnClickDrawerTabListener); - mHistoryTab.setOnClickListener(mOnClickDrawerTabListener); - - mSettings = (cButtonItem) mView.findViewById( - R.id.ab_settings); - mSettings.setOnClickListener(mOnClickDrawerActionBarListener); - mClearHistory = (cButtonItem) mView.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 android.support.v4.app.ActionBarDrawerToggle(getActivity(), - mDrawerLayout, - R.drawable.ic_material_light_navigation_drawer, - R.string.drawer_open, R.string.drawer_close) { - - public void onDrawerClosed(View view) { - super.onDrawerClosed(view); - } - - public void onDrawerOpened(View drawerView) { - onDrawerLayoutOpened(drawerView); - super.onDrawerOpened(drawerView); - } - }; - getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); - - // Set the drawer toggle as the DrawerListener - mDrawerLayout.setDrawerListener(mDrawerToggle);*/ - } - - /*** - * 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 that adds a history entry to the history list in the drawer - */ - private void addHistoryToDrawer(int index, HistoryNavigable navigable) { - // hide empty message - mDrawerHistoryEmpty.setVisibility(View.GONE); - - Theme theme = ThemeManager.getCurrentTheme(getActivity()); - IconHolder iconholder = new IconHolder(getActivity(), false); - - // inflate single bookmark layout item and fill it - LinearLayout view = (LinearLayout) mLayoutInflater.inflate( - R.layout.history_item, null); - - ImageView iconView = (ImageView) view - .findViewById(R.id.history_item_icon); - TextView name = (TextView) view.findViewById(R.id.history_item_name); - TextView directory = (TextView) view - .findViewById(R.id.history_item_directory); - - int iconResId = R.drawable.ic_folder; - if (navigable instanceof SearchInfoParcelable) { - iconResId = R.drawable.ic_history_search_drawable; - } - iconView.setImageResource(iconResId); - - String title = navigable.getTitle(); - if (title == null || title.trim().length() == 0) { - title = getString(R.string.root_directory_name); - } - - name.setText(title); - directory.setText(navigable.getDescription()); - - theme.setTextColor(getActivity(), name, "text_color"); - theme.setTextColor(getActivity(), directory, "text_color"); - - // handle item click - view.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - final int index = mDrawerHistory.indexOfChild(v); - final int count = mDrawerHistory.getChildCount(); - final History history = mHistorySaved.get(count - index - 1); - - navigateToHistory(history, true); - } - }); - - // add as first child - mDrawerHistory.addView(view, 0); - - // Show clear button if history tab is selected - mClearHistory.setVisibility(mHistoryTab.isSelected() ? View.VISIBLE : View.GONE); - } - - /** - * Method that initializes the history. - */ - private synchronized void initHistory() { - if (mHistoryTask != null && - !mHistoryTask.getStatus().equals(AsyncTask.Status.FINISHED)) { - return; - } - - // Load history in background - mHistoryTask = new AsyncTask<Void, Void, Boolean>() { - Exception mCause; - - @Override - protected Boolean doInBackground(Void... params) { - try { - loadHistory(); - return Boolean.TRUE; - } - catch (Exception e) { - this.mCause = e; - return Boolean.FALSE; - } - } - - @Override - protected void onPreExecute() { - mDrawerHistory.removeAllViews(); - } - - @Override - protected void onPostExecute(Boolean result) { - if (result.booleanValue()) { - for (int i = 0; i < mHistory.size(); i++) { - final History history = mHistory.get(i); - addHistoryToDrawer(i, history.getItem()); - } - } else { - if (this.mCause != null) { - ExceptionUtil.translateException( - getActivity(), this.mCause); - } - } - mHistoryTask = null; - mHistory.clear(); - } - - @Override - protected void onCancelled() { - mHistoryTask = null; - } - }; - mHistoryTask.execute(); - } - - /** - * Method that loads all kind of bookmarks and join in an array to be used - * in the listview adapter. - * - * @return List<Bookmark> - * @hide - */ - List<Bookmark> loadBookmarks() { - // Bookmarks = HOME + FILESYSTEM + SD STORAGES + USER DEFINED - // In ChRooted mode = SD STORAGES + USER DEFINED (from SD STORAGES) - List<Bookmark> bookmarks = new ArrayList<Bookmark>(); - if (!this.mChRooted) { - bookmarks.add(loadHomeBookmarks()); - bookmarks.addAll(loadFilesystemBookmarks()); - } - mSdBookmarks = loadSdStorageBookmarks(); - bookmarks.addAll(mSdBookmarks); - bookmarks.addAll(loadVirtualBookmarks()); - bookmarks.addAll(loadUserBookmarks()); - return bookmarks; - } - - /** - * Method that loads the home bookmark from the user preference. - * - * @return Bookmark The bookmark loaded - */ - private Bookmark loadHomeBookmarks() { - String initialDir = Preferences.getSharedPreferences().getString( - FileManagerSettings.SETTINGS_INITIAL_DIR.getId(), - (String) FileManagerSettings.SETTINGS_INITIAL_DIR - .getDefaultValue()); - return new Bookmark(BOOKMARK_TYPE.HOME, - getString(R.string.bookmarks_home), initialDir); - } - - /** - * Method that loads the filesystem bookmarks from the internal xml file. - * (defined by this application) - * - * @return List<Bookmark> The bookmarks loaded - */ - private List<Bookmark> loadFilesystemBookmarks() { - try { - // Initialize the bookmarks - List<Bookmark> bookmarks = new ArrayList<Bookmark>(); - - // Read the command list xml file - XmlResourceParser parser = getResources().getXml( - R.xml.filesystem_bookmarks); - - try { - // Find the root element - XmlUtils.beginDocument(parser, TAG_BOOKMARKS); - while (true) { - XmlUtils.nextElement(parser); - String element = parser.getName(); - if (element == null) { - break; - } - - if (TAG_BOOKMARK.equals(element)) { - CharSequence name = null; - CharSequence directory = null; - - try { - name = getString(parser.getAttributeResourceValue( - R.styleable.Bookmark_name, 0)); - } - catch (Exception e) { - /** NON BLOCK **/ - } - try { - directory = getString(parser - .getAttributeResourceValue( - R.styleable.Bookmark_directory, 0)); - } - catch (Exception e) { - /** NON BLOCK **/ - } - if (directory == null) { - directory = parser - .getAttributeValue(R.styleable.Bookmark_directory); - } - if (name != null && directory != null) { - bookmarks.add(new Bookmark( - BOOKMARK_TYPE.FILESYSTEM, name.toString(), - directory.toString())); - } - } - } - - // Return the bookmarks - return bookmarks; - - } - finally { - parser.close(); - } - } - catch (Throwable ex) { - Log.e(TAG, "Load filesystem bookmarks failed", ex); //$NON-NLS-1$ - } - - // No data - return new ArrayList<Bookmark>(); - } - - /** - * Method that loads the secure digital card storage bookmarks from the - * system. - * - * @return List<Bookmark> The bookmarks loaded - */ - private List<Bookmark> loadSdStorageBookmarks() { - // Initialize the bookmarks - List<Bookmark> bookmarks = new ArrayList<Bookmark>(); - - try { - // Recovery sdcards from storage manager - StorageVolume[] volumes = StorageHelper - .getStorageVolumes(getActivity().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(getActivity().getApplication(), - volume), path); - } else { - bookmark = new Bookmark(BOOKMARK_TYPE.SDCARD, StorageHelper - .getStorageVolumeDescription(getActivity().getApplication(), - volume), path); - } - bookmarks.add(bookmark); - } - } - } - - // Return the bookmarks - return bookmarks; - } - catch (Throwable ex) { - Log.e(TAG, "Load filesystem bookmarks failed", ex); //$NON-NLS-1$ - } - - // No data - return new ArrayList<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 - */ - private List<Bookmark> loadUserBookmarks() { - List<Bookmark> bookmarks = new ArrayList<Bookmark>(); - Cursor cursor = Bookmarks.getAllBookmarks(getActivity().getContentResolver()); - try { - if (cursor != null && cursor.moveToFirst()) { - do { - Bookmark bm = new Bookmark(cursor); - if (this.mChRooted - && !StorageHelper.isPathInStorageVolume(bm.mPath)) { - continue; - } - bookmarks.add(bm); - } - while (cursor.moveToNext()); - } - } - finally { - try { - if (cursor != null) { - cursor.close(); - } - } - catch (Exception e) { - /** 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; - } - - /** - * Method that loads the history saved in database. - */ - private void loadHistory() { - ContentResolver contentResolver = getContext().getContentResolver(); - Cursor cursor = contentResolver.query( - History.Columns.CONTENT_URI, - History.Columns.HISTORY_QUERY_COLUMNS, - null, null, null); - try { - if (cursor != null && cursor.moveToFirst()) { - do { - String title = cursor.getString(1); - String desc = cursor.getString(2); - HistoryItem item = new HistoryItem(title, desc); - History history = new History(mHistory.size(), item); - - mHistory.add(history); - mHistorySaved.add(history); - } while (cursor.moveToNext()); - } - } finally { - try { - if (cursor != null) { - cursor.close(); - } - } catch (Exception e) { - // Ignore - } - } - } - - /** - * Method that saves the history to the database. - * - * @param historyItem - * @return boolean - */ - private boolean addHistory(HistoryNavigable historyItem) { - ContentValues values = new ContentValues(2); - values.put(History.Columns.TITLE, historyItem.getTitle()); - values.put(History.Columns.DESCRIPTION, historyItem.getDescription()); - - final Uri uri = getContext().getContentResolver() - .insert(History.Columns.CONTENT_URI, values); - if ((int) ContentUris.parseId(uri) == -1) { - if (DEBUG) { - Log.e(TAG, "Error inserting the navigation history"); - } - return false; - } - - return true; - } - - /** - * Method that clears the history database. - */ - private void deleteAllHistorys() { - getContext().getContentResolver().delete(History.Columns.CONTENT_URI, "", null); - } - - /** - * Method that decides if the history item should be saved to database. - * - * @param historyItem the history item to be saved to database - * @return boolean - */ - private boolean shouldAddHistory(HistoryNavigable historyItem) { - final String description = historyItem.getDescription(); - if (description == null) { - return false; - } - - for (History history : mHistorySaved) { - String desc = history.getItem().getDescription(); - if (desc != null && desc.equals(description)) { - return false; - } - } - return true; + this.mSelectionBar.setMenuClickListener(this); + this.mSelectionBar.setNavigationView(getCurrentNavigationView()); } /** @@ -1255,7 +632,6 @@ public class NavigationFragment extends Fragment private void attachNavigationViewListeners() { this.mNavigationView.setOnHistoryListener(this); this.mNavigationView.setOnNavigationSelectionChangedListener(this); - this.mNavigationView.setOnNavigationOnRequestMenuListener(this); this.mNavigationView.setOnDirectoryChangedListener(this); this.mNavigationView.setOnBackRequestListener(mOnBackRequestListener); } @@ -1266,7 +642,6 @@ public class NavigationFragment extends Fragment private void removeNavigationViewListeners() { this.mNavigationView.setOnHistoryListener(null); this.mNavigationView.setOnNavigationSelectionChangedListener(null); - this.mNavigationView.setOnNavigationOnRequestMenuListener(null); this.mNavigationView.setOnDirectoryChangedListener(null); this.mNavigationView.setOnBackRequestListener(null); } @@ -1451,7 +826,7 @@ public class NavigationFragment extends Fragment if (data != null) { switch (requestCode) { case INTENT_REQUEST_SEARCH: - if (resultCode == getActivity().RESULT_OK) { + if (resultCode == Activity.RESULT_OK) { //Change directory? Bundle bundle = data.getExtras(); if (bundle != null) { @@ -1464,7 +839,7 @@ public class NavigationFragment extends Fragment getCurrentNavigationView().open(fso, searchInfo); } } - } else if (resultCode == getActivity().RESULT_CANCELED) { + } else if (resultCode == Activity.RESULT_CANCELED) { SearchInfoParcelable searchInfo = data.getParcelableExtra(EXTRA_SEARCH_LAST_SEARCH_DATA); if (searchInfo != null && searchInfo.isSuccessNavigation()) { @@ -1530,14 +905,6 @@ public class NavigationFragment extends Fragment //Recollect information about current status History history = new History(this.mHistory.size(), navigable); this.mHistory.add(history); - if (!shouldAddHistory(navigable)) { - return; - } - // Show history in the navigation drawer - addHistoryToDrawer(this.mHistory.size() - 1, navigable); - mHistorySaved.add(history); - // Add history to the database - addHistory(navigable); } /** @@ -1554,7 +921,7 @@ public class NavigationFragment extends Fragment public void onRequestRefresh(Object o, boolean clearSelection) { if (o instanceof FileSystemObject) { // Refresh only the item - this.getCurrentNavigationView().refresh((FileSystemObject)o); + this.getCurrentNavigationView().refresh((FileSystemObject) o); } else if (o == null) { // Refresh all getCurrentNavigationView().refresh(); @@ -1601,24 +968,18 @@ public class NavigationFragment extends Fragment // nop } + private List<FileSystemObject> mCurrentSelection; + /** * {@inheritDoc} */ @Override public void onSelectionChanged(NavigationView navView, List<FileSystemObject> selectedItems) { + mCurrentSelection = selectedItems; this.mSelectionBar.setSelection(selectedItems); } /** - * {@inheritDoc} - */ - @Override - public void onRequestMenu(NavigationView navView, FileSystemObject item) { - // Show the actions dialog - openActionsDialog(item, false); - } - - /** * Updates the {@link FileManagerSettings} to the value passed in and refreshes the view * * @param setting {@link FileManagerSettings} to modify @@ -1646,8 +1007,8 @@ public class NavigationFragment extends Fragment Preferences.getSharedPreferences(). getBoolean( setting.getId(), - ((Boolean)setting.getDefaultValue()).booleanValue()); - Preferences.savePreference(setting, Boolean.valueOf(!newval), false); + (Boolean) setting.getDefaultValue()); + Preferences.savePreference(setting, !newval, false); } getCurrentNavigationView().refresh(); } @@ -1666,41 +1027,6 @@ public class NavigationFragment extends Fragment } /** - * Method that shows a popup with a menu associated a {@link FileManagerSettings}. - * - * @param anchor The action button that was pressed - * @param settings The array of settings associated with the action button - */ - public void showSettingsPopUp(View anchor, List<FileManagerSettings> settings) { - //Create the adapter - final MenuSettingsAdapter adapter = new MenuSettingsAdapter(getActivity(), settings); - - //Create a show the popup menu - mPopupWindow = DialogHelper.createListPopupWindow(getActivity(), adapter, anchor); - mPopupWindow.setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView<?> parent, View v, int position, long id) { - FileManagerSettings setting = - ((MenuSettingsAdapter)parent.getAdapter()).getSetting(position); - final int value = ((MenuSettingsAdapter)parent.getAdapter()).getId(position); - mPopupWindow.dismiss(); - mPopupWindow = null; - - updateSetting(setting, value); - adapter.dispose(); - } - }); - mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { - @Override - public void onDismiss() { - adapter.dispose(); - } - }); - mPopupWindow.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED); - mPopupWindow.show(); - } - - /** * Method that show the information of a filesystem mount point. * * @param mp The mount point info @@ -1760,49 +1086,6 @@ public class NavigationFragment extends Fragment mDiskUsage = ds; } - /** - * Method that checks the action that must be realized when the - * back button is pushed. - * - * @return boolean Indicates if the action must be intercepted - */ - private boolean checkBackAction() { - // 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()) { - getCurrentNavigationView().getCustomTitle().restoreView(); - return true; - } - - //Do back operation over the navigation history - boolean flag = this.mExitFlag; - - this.mExitFlag = !back(); - - // Retrieve if the exit status timeout has expired - long now = System.currentTimeMillis(); - boolean timeout = (this.mExitBackTimeout == -1 || - (now - this.mExitBackTimeout) > RELEASE_EXIT_CHECK_TIMEOUT); - - //Check if there no history and if the user was advised in the last back action - if (this.mExitFlag && (this.mExitFlag != flag || timeout)) { - //Communicate the user that the next time the application will be closed - this.mExitBackTimeout = System.currentTimeMillis(); - DialogHelper.showToast(getActivity(), R.string.msgs_push_again_to_exit, - Toast.LENGTH_SHORT); - } - - //Back action not applied - return !this.mExitFlag; - } - @Override public void startActivity(Intent intent) { // check if search intent @@ -1819,12 +1102,6 @@ public class NavigationFragment extends Fragment */ private void clearHistory() { this.mHistory.clear(); - mHistorySaved.clear(); - mDrawerHistory.removeAllViews(); - mDrawerHistoryEmpty.setVisibility(View.VISIBLE); - - // Delete all history items in the database - deleteAllHistorys(); } /** @@ -1842,12 +1119,9 @@ public class NavigationFragment extends Fragment //Navigation NavigationViewInfoParcelable info = (NavigationViewInfoParcelable)history.getItem(); - int viewId = info.getId(); // Selected items must not be restored from on history navigation info.setSelectedFiles(mNavigationView.getSelectedFiles()); - if (!mNavigationView.onRestoreState(info)) { - return true; - } + mNavigationView.onRestoreState(info); } else if (history.getItem() instanceof SearchInfoParcelable) { //Search (open search with the search results) @@ -1856,13 +1130,6 @@ public class NavigationFragment extends Fragment searchIntent.setAction(SearchActivity.ACTION_RESTORE); searchIntent.putExtra(SearchActivity.EXTRA_SEARCH_RESTORE, (Parcelable)info); startActivityForResult(searchIntent, INTENT_REQUEST_SEARCH); - } else if (history.getItem() instanceof HistoryItem) { - final String path = history.getItem().getDescription(); - final FileSystemObject fso = CommandHelper.getFileInfo( - getActivity().getApplicationContext(), path, null); - if (fso != null) { - getCurrentNavigationView().open(fso); - } } else { //The type is unknown throw new IllegalArgumentException("Unknown history type"); //$NON-NLS-1$ @@ -1880,7 +1147,7 @@ public class NavigationFragment extends Fragment if (history != null) { Log.e(TAG, String.format("Failed to navigate to history %d: %s", //$NON-NLS-1$ - Integer.valueOf(history.getPosition()), + history.getPosition(), history.getItem().getTitle()), ex); } else { Log.e(TAG, @@ -1983,17 +1250,6 @@ public class NavigationFragment extends Fragment } /** - * Method that opens the settings activity. - * - * @hide - */ - void openSettings() { - Intent settingsIntent = new Intent(getActivity(), - SettingsPreferences.class); - startActivityForResult(settingsIntent, INTENT_REQUEST_SETTINGS); - } - - /** * Method that remove the {@link FileSystemObject} from the history */ private void removeFromHistory(FileSystemObject fso) { @@ -2153,14 +1409,6 @@ public class NavigationFragment extends Fragment * @hide */ void applyTheme() { - int orientation = getResources().getConfiguration().orientation; - Theme theme = ThemeManager.getCurrentTheme(getActivity()); - applyTabTheme(); - - //- Layout - View navLayout = mView.findViewById(R.id.navigation_layout); - navLayout.setBackgroundResource(R.drawable.background_drawable); - // Hackery to theme search view mSearchView = (SearchView) mTitleLayout.findViewById(R.id.navigation_search_bar); int searchPlateId = mSearchView.getContext().getResources() @@ -2187,53 +1435,6 @@ public class NavigationFragment extends Fragment mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity() .getComponentName())); mSearchView.setIconifiedByDefault(false); - - //- SelectionBar - View v = mView.findViewById(R.id.navigation_selectionbar); - theme.setBackgroundDrawable(getActivity(), v, "selectionbar_drawable"); //$NON-NLS-1$ - v = mView.findViewById(R.id.ab_selection_done); - theme.setImageDrawable(getActivity(), - (ImageView)v, "ab_selection_done_drawable"); //$NON-NLS-1$ - v = mView.findViewById(R.id.navigation_status_selection_label); - theme.setTextColor(getActivity(), (TextView)v, "text_color"); //$NON-NLS-1$ - } - - /** - * Method that applies the current theme to the tab host - */ - private void applyTabTheme() { - // Apply the theme - Theme theme = ThemeManager.getCurrentTheme(getActivity()); - } - - public void updateActiveDialog(Dialog dialog) { - mActiveDialog = dialog; - } - - private class HistoryItem extends HistoryNavigable { - private final String mTitle; - private final String mDescription; - - public HistoryItem(String title, String description) { - mTitle = title; - mDescription = description; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) {} - - public String getTitle() { - return mTitle; - } - - public String getDescription() { - return mDescription; - } } /* @@ -2286,4 +1487,269 @@ public class NavigationFragment extends Fragment mOnDirectoryChangedListener.onDirectoryChanged(item); } } + + @Override + public boolean onMenuItemClick(MenuItem menuItem) { + + if (mSelectionBar != null && mCurrentSelection != null) { + fileActions(menuItem, mCurrentSelection); + return true; + } + + return false; + } + + /** + * Method that show a new dialog for input a name for an existing fso. + * + * @param menuItem The item menu associated + * @param fso The file system object + * @param allowFsoName If allow that the name of the fso will be returned + */ + private void showFsoInputNameDialog( + final MenuItem menuItem, final FileSystemObject fso, final boolean allowFsoName) { + + //Show the input name dialog + final InputNameDialog inputNameDialog = + new InputNameDialog( + getActivity(), + mCurrentSelection, + fso, + allowFsoName, + menuItem.getTitle().toString()); + inputNameDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + //Retrieve the name an execute the action + String name = inputNameDialog.getName(); + switch (menuItem.getItemId()) { + case R.id.mnu_actions_rename: + case R.id.mnu_actions_rename_selection: + // Rename the fso + if (getCurrentNavigationView() != null) { + CopyMoveActionPolicy.renameFileSystemObject( + getActivity(), + getCurrentNavigationView(), + inputNameDialog.getFso(), + name, + getCurrentNavigationView(), + getCurrentNavigationView()); + } + break; + + case R.id.mnu_actions_create_link: + case R.id.mnu_actions_create_link_global: + // Create a link to the fso + if (getCurrentNavigationView() != null) { + NewActionPolicy.createSymlink( + getActivity(), + inputNameDialog.getFso(), + name, + getCurrentNavigationView(), + getCurrentNavigationView()); + } + break; + + default: + break; + } + + } + }); + inputNameDialog.show(); + } + + private void fileActions(MenuItem item, List<FileSystemObject> selection) { + switch (item.getItemId()) { + + // Uncompress + case R.id.mnu_actions_extract: + // make this recursivly uncompress + CompressActionPolicy.uncompress( + getActivity(), + selection.get(0), + this); + break; + + // Compress + case R.id.mnu_actions_compress: + if (getCurrentNavigationView() != null) { + CompressActionPolicy.compress( + getActivity(), + selection, + getCurrentNavigationView(), + this); + } + break; + + // Paste + case R.id.mnu_actions_paste: + if (getCurrentNavigationView() != null) { + // Select destination + Intent intent = new Intent(INTENT_FOLDER_SELECT); + intent.putExtra(EXTRA_ACTION, COPY.ordinal()); + startActivityForResult(intent, INTENT_REQUEST_COPY); + } + break; + + // Move + case R.id.mnu_actions_move: + if (getCurrentNavigationView() != null) { + // Select destination + Intent intent = new Intent(INTENT_FOLDER_SELECT); + intent.putExtra(EXTRA_ACTION, MOVE.ordinal()); + startActivityForResult(intent, INTENT_REQUEST_MOVE); + } + break; + + // Add shortcut + case R.id.mnu_actions_add_shortcut: + IntentsActionPolicy.createShortcut(getActivity(), selection.get(0)); + break; + + // Compute checksum + case R.id.mnu_actions_compute_checksum: + InfoActionPolicy.showComputeChecksumDialog(getActivity(), selection.get(0)); + break; + + // Print + case R.id.mnu_actions_print: + PrintActionPolicy.printDocument(getActivity(), selection.get(0)); + break; + + // Create copy + case R.id.mnu_actions_create_copy: + // copy all the things + for (FileSystemObject fso : selection) { + CopyMoveActionPolicy.createCopyFileSystemObject( + getActivity(), + getCurrentNavigationView(), + fso, + getCurrentNavigationView(), + this); + } + break; + + // Delete + case R.id.mnu_actions_delete: + DeleteActionPolicy.removeFileSystemObjects( + getActivity(), + getCurrentNavigationView(), + selection, + getCurrentNavigationView(), + getCurrentNavigationView(), + null); + break; + + // Open + case R.id.mnu_actions_open: + IntentsActionPolicy.openFileSystemObject( + getActivity(), + getCurrentNavigationView(), + selection.get(0), + false, null); + break; + + // Open with + case R.id.mnu_actions_open_with: + IntentsActionPolicy.openFileSystemObject( + getActivity(), + getCurrentNavigationView(), + selection.get(0), + true, null); + break; + + // Execute + case R.id.mnu_actions_execute: + ExecutionActionPolicy.execute(getActivity(), selection.get(0)); + break; + + // Send + case R.id.mnu_actions_send: + IntentsActionPolicy.sendMultipleFileSystemObject( + getActivity(), selection, null); + break; + + // Rename + case R.id.mnu_actions_rename: + if (getCurrentNavigationView() != null) { + showFsoInputNameDialog(item, selection.get(0), false); + } + break; + + // select all + case R.id.mnu_actions_select_all: + getCurrentNavigationView().onSelectAllVisibleItems(); + break; + + // refresh + case R.id.mnu_actions_refresh: + onRequestRefresh(null, false); + break; + + // search + case R.id.mnu_actions_search: + toggleSearch(); + break; + + // sort + case R.id.mnu_actions_sort: + SortViewOptions.createSortDialog(getActivity(), + FileManagerSettings.SETTINGS_SORT_MODE, + new SortViewOptions.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which, int result) { + if (which == DialogInterface.BUTTON_POSITIVE) { + if (PreferenceHelper.getIntPreference( + FileManagerSettings.SETTINGS_SORT_MODE) != result) { + updateSetting( + FileManagerSettings.SETTINGS_SORT_MODE, result); + } + } + } + }) + .show(); + break; + + // new directory + case R.id.mnu_actions_new_directory: + ActionsDialog.showInputNameDialog(getActivity(), + getString(R.string.actions_menu_new_directory), item.getItemId(), + getCurrentNavigationView().getFiles(), getCurrentNavigationView(), this); + break; + + // new file + case R.id.mnu_actions_new_file: + ActionsDialog.showInputNameDialog(getActivity(), + getString(R.string.actions_menu_new_file), item.getItemId(), + getCurrentNavigationView().getFiles(), getCurrentNavigationView(), this); + break; + + // get properties + case R.id.mnu_actions_properties_current_folder: + InfoActionPolicy.showPropertiesDialog(getActivity(), + getCurrentNavigationView().getCurrentFso(), this); + break; + + // get file system info + case R.id.mnu_actions_file_system_info: + if (mMountPoint != null && mDiskUsage != null) { + showMountPointInfo(mMountPoint, mDiskUsage); + } else { + Toast.makeText(getActivity(), getString(R.string.file_system_info_unavailable), + Toast.LENGTH_SHORT).show(); + } + break; + + case R.id.mnu_actions_deselect_all: + getCurrentNavigationView().onDeselectAll(); + break; + + case R.id.mnu_actions_create_link: + if (getCurrentNavigationView() != null) { + showFsoInputNameDialog(item, selection.get(0), false); + } + break; + } + } } diff --git a/src/com/cyanogenmod/filemanager/ui/policy/CompressActionPolicy.java b/src/com/cyanogenmod/filemanager/ui/policy/CompressActionPolicy.java index 051d526d..4d3ac6e6 100644 --- a/src/com/cyanogenmod/filemanager/ui/policy/CompressActionPolicy.java +++ b/src/com/cyanogenmod/filemanager/ui/policy/CompressActionPolicy.java @@ -137,19 +137,33 @@ public final class CompressActionPolicy extends ActionsPolicy { * Method that compresses an uncompressed file. * * @param ctx The current context - * @param fso The compressed file + * @param fso The compressed file system object * @param onSelectionListener The listener for obtain selection information (required) * @param onRequestRefreshListener The listener for request a refresh (optional) * @hide */ - public static void compress( - final Context ctx, final FileSystemObject fso, - final OnSelectionListener onSelectionListener, - final OnRequestRefreshListener onRequestRefreshListener) { - + public static void compress(final Context ctx, final FileSystemObject fso, + final OnSelectionListener onSelectionListener, + final OnRequestRefreshListener onRequestRefreshListener) { // Create a list with the item final List<FileSystemObject> items = new ArrayList<FileSystemObject>(); items.add(fso); + compress(ctx, items, onSelectionListener, onRequestRefreshListener); + } + + /** + * Method that compresses an uncompressed file. + * + * @param ctx The current context + * @param items The compressed files + * @param onSelectionListener The listener for obtain selection information (required) + * @param onRequestRefreshListener The listener for request a refresh (optional) + * @hide + */ + public static void compress( + final Context ctx, final List<FileSystemObject> items, + final OnSelectionListener onSelectionListener, + final OnRequestRefreshListener onRequestRefreshListener) { // Show a dialog to allow the user make the compression mode choice final String[] labels = getSupportedCompressionModesLabels(ctx, items); diff --git a/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java b/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java index e8588edf..e84c2c52 100644 --- a/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java +++ b/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java @@ -27,12 +27,11 @@ import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; import android.view.View; -import android.view.animation.AccelerateInterpolator; +import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.widget.AdapterView; import android.widget.ListAdapter; -import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.Toast; @@ -61,9 +60,6 @@ import com.cyanogenmod.filemanager.preferences.FileManagerSettings; import com.cyanogenmod.filemanager.preferences.NavigationLayoutMode; import com.cyanogenmod.filemanager.preferences.ObjectIdentifier; import com.cyanogenmod.filemanager.preferences.Preferences; -import com.cyanogenmod.filemanager.ui.ThemeManager; -import com.cyanogenmod.filemanager.ui.ThemeManager.Theme; -import com.cyanogenmod.filemanager.ui.policy.ActionsPolicy; import com.cyanogenmod.filemanager.ui.policy.DeleteActionPolicy; import com.cyanogenmod.filemanager.ui.policy.IntentsActionPolicy; import com.cyanogenmod.filemanager.ui.widgets.FlingerListView.OnItemFlingerListener; @@ -106,21 +102,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe } /** - * An interface to communicate a request for show the menu associated - * with an item. - */ - public interface OnNavigationRequestMenuListener { - /** - * Method invoked when a request to show the menu associated - * with an item is started. - * - * @param navView The navigation view that generate the event - * @param item The item for which the request was started - */ - void onRequestMenu(NavigationView navView, FileSystemObject item); - } - - /** * An interface to communicate a request when the user choose a file. */ public interface OnFilePickedListener { @@ -189,10 +170,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe FileSystemObject fso = adapter.getItem(position); if (fso != null) { - if (fso instanceof ParentDirectory) { - return false; - } - return true; + return !(fso instanceof ParentDirectory); } } catch (Exception e) { ExceptionUtil.translateException(getContext(), e, true, false); @@ -276,21 +254,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe mIsNewHistory = (NavigationView.this.mPreviousDir != null); try { - //Reset the custom title view and returns to breadcrumb - if (NavigationView.this.mTitle != null) { - NavigationView.this.mTitle.post(new Runnable() { - @Override - public void run() { - try { - NavigationView.this.mTitle.restoreView(); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - } - - //Start of loading data if (NavigationView.this.mBreadcrumb != null) { try { @@ -300,7 +263,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe } } - List<FileSystemObject> files = null; + List<FileSystemObject> files; if (TextUtils.equals(mNewDirChecked, FileHelper.ROOTS_LIST)) { files = StorageHelper.getStorageVolumesFileSystemObjectList(getContext()); } else { @@ -389,7 +352,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe } private void done() { // Do animation - fadeEfect(false); + fadeEffect(false); } }; ExceptionUtil.translateException( @@ -413,11 +376,12 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe protected void onPostExecute(List<FileSystemObject> files) { // This means an exception. This method will be recalled then if (files != null) { + // Do animation + fadeEffect(true); + onPostExecuteTask(files, mAddToHistory, mIsNewHistory, mHasChanged, mSearchInfo, mNewDirChecked, mNewDirFSO, mScrollTo); - // Do animation - fadeEfect(false); } else { if (TextUtils.isEmpty(mCurrentDir)) { if (mOnBackRequestListener != null) { @@ -441,7 +405,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe * * @param out Fade out (true); Fade in (false) */ - void fadeEfect(final boolean out) { + void fadeEffect(final boolean out) { Activity activity = (Activity)getContext(); activity.runOnUiThread(new Runnable() { @Override @@ -449,14 +413,127 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe Animation fadeAnim = out ? new AlphaAnimation(1, 0) : new AlphaAnimation(0, 1); - fadeAnim.setDuration(50L); + fadeAnim.setDuration(400L); fadeAnim.setFillAfter(true); - fadeAnim.setInterpolator(new AccelerateInterpolator()); + fadeAnim.setInterpolator(new AccelerateDecelerateInterpolator()); NavigationView.this.startAnimation(fadeAnim); } }); } - }; + + /** + * Method invoked when a execution ends. + * + * @param files The files obtains from the list + * @param addToHistory If add path to history + * @param isNewHistory If is new history + * @param hasChanged If current directory was changed + * @param searchInfo The search information (if calling activity is {@link "SearchActivity"}) + * @param newDir The new directory + * @param newDirFSO the new directory in FSO form + * @param scrollTo If not null, then listview must scroll to this item + * @hide + */ + void onPostExecuteTask( + List<FileSystemObject> files, boolean addToHistory, boolean isNewHistory, + boolean hasChanged, SearchInfoParcelable searchInfo, + String newDir, final FileSystemObject newDirFSO, final FileSystemObject scrollTo) { + try { + //Check that there is not errors and have some data + if (files == null) { + return; + } + + if (!TextUtils.equals(FileHelper.ROOTS_LIST, newDir)) { + //Apply user preferences + files = FileHelper.applyUserPreferences(files, mRestrictions, mChRooted); + } + + //Remove parent directory if we are in the root of a chrooted environment + if (mChRooted && StorageHelper.isStorageVolume(newDir) || + TextUtils.equals(newDir, FileHelper.ROOT_DIRECTORY)) { + if (files.size() > 0 && files.get(0) instanceof ParentDirectory) { + files.remove(0); + } + if (mNavigationMode.compareTo(NAVIGATION_MODE.PICKABLE) == 0) { + files.add(0, new ParentDirectory(FileHelper.ROOTS_LIST)); + } + } else if (!TextUtils.equals(FileHelper.ROOTS_LIST, newDir) && + files.size() > 0 && !(files.get(0) instanceof ParentDirectory)) { + if (mNavigationMode.compareTo(NAVIGATION_MODE.PICKABLE) == 0) { + files.add(0, new ParentDirectory(FileHelper.ROOTS_LIST)); + } + } + + //Add to history? + if (addToHistory && hasChanged && isNewHistory) { + if (mOnHistoryListener != null) { + //Communicate the need of a history change + mOnHistoryListener.onNewHistory(onSaveState()); + } + } + + //Load the data + loadData(files); + mFiles = files; + if (searchInfo != null) { + searchInfo.setSuccessNavigation(true); + } + + //Change the breadcrumb + if (mBreadcrumb != null) { + mBreadcrumb.changeBreadcrumbPath(newDir, mChRooted); + } + + //If scrollTo is null, the position will be set to 0 + scrollTo(scrollTo); + + //The current directory is now the "newDir" + mCurrentDir = newDir; + mCurrentFileSystemObject = newDirFSO; + if (mOnDirectoryChangedListener != null) { + FileSystemObject dir = (newDirFSO != null) ? + newDirFSO : FileHelper.createFileSystemObject(new File(newDir)); + mOnDirectoryChangedListener.onDirectoryChanged(dir); + } + } finally { + //If calling activity is search, then save the search history + if (searchInfo != null) { + mOnHistoryListener.onNewHistory(searchInfo); + } + + //End of loading data + try { + mBreadcrumb.endLoading(); + } catch (Throwable ex) { + /**NON BLOCK**/ + } + + fadeEffect(false); + + } + } + + /** + * Method that ensures that the user does not go outside the ChRooted environment + * + * @param newDir The new directory to navigate to + * @return String + */ + private String checkChRootedNavigation(String newDir) { + // If we aren't in ChRooted environment, then there is nothing to check + if (!mChRooted) return newDir; + + // Check if the path is owned by one of the storage volumes + if (!StorageHelper.isPathInStorageVolume(newDir)) { + StorageVolume[] volumes = StorageHelper.getStorageVolumes(getContext(), false); + if (volumes != null && volumes.length > 0) { + return volumes[0].getPath(); + } + } + return newDir; + } + } private int mId; private String mCurrentDir; @@ -471,7 +548,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe private OnHistoryListener mOnHistoryListener; private OnNavigationSelectionChangedListener mOnNavigationSelectionChangedListener; - private OnNavigationRequestMenuListener mOnNavigationRequestMenuListener; private OnFilePickedListener mOnFilePickedListener; private OnDirectoryChangedListener mOnDirectoryChangedListener; private OnBackRequestListener mOnBackRequestListener; @@ -489,10 +565,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe * @hide */ Breadcrumb mBreadcrumb; - /** - * @hide - */ - NavigationCustomTitleView mTitle; + /** * @hide */ @@ -679,24 +752,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe } /** - * Method that returns the custom title fragment associated with this navigation view. - * - * @return NavigationCustomTitleView The custom title view fragment - */ - public NavigationCustomTitleView getCustomTitle() { - return this.mTitle; - } - - /** - * Method that associates the custom title fragment with this navigation view. - * - * @param title The custom title view fragment - */ - public void setCustomTitle(NavigationCustomTitleView title) { - this.mTitle = title; - } - - /** * Method that returns the breadcrumb associated with this navigation view. * * @return Breadcrumb The breadcrumb view fragment @@ -735,16 +790,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe } /** - * Method that sets the listener for menu item requests. - * - * @param onNavigationRequestMenuListener The listener reference - */ - public void setOnNavigationOnRequestMenuListener( - OnNavigationRequestMenuListener onNavigationRequestMenuListener) { - this.mOnNavigationRequestMenuListener = onNavigationRequestMenuListener; - } - - /** * @return the mOnFilePickedListener */ public OnFilePickedListener getOnFilePickedListener() { @@ -952,25 +997,17 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe RESOURCE_MODE_SIMPLE_LAYOUT, this, false); itemResourceId = RESOURCE_MODE_SIMPLE_ITEM; - // Set the flinger listener (only when navigate) - if (this.mNavigationMode.compareTo(NAVIGATION_MODE.BROWSABLE) == 0) { - if (useFlinger && newView instanceof FlingerListView) { - ((FlingerListView)newView). - setOnItemFlingerListener(this.mOnItemFlingerListener); - } - } - } else if (newMode.compareTo(NavigationLayoutMode.DETAILS) == 0) { newView = (AdapterView<ListAdapter>)LayoutInflater.from(getContext()).inflate( RESOURCE_MODE_DETAILS_LAYOUT, this, false); itemResourceId = RESOURCE_MODE_DETAILS_ITEM; + } - // Set the flinger listener (only when navigate) - if (this.mNavigationMode.compareTo(NAVIGATION_MODE.BROWSABLE) == 0) { - if (useFlinger && newView instanceof FlingerListView) { - ((FlingerListView)newView). - setOnItemFlingerListener(this.mOnItemFlingerListener); - } + // Set the flinger listener (only when navigate) + if (this.mNavigationMode.compareTo(NAVIGATION_MODE.BROWSABLE) == 0) { + if (useFlinger && newView instanceof FlingerListView) { + ((FlingerListView)newView). + setOnItemFlingerListener(this.mOnItemFlingerListener); } } @@ -1167,105 +1204,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe // listener itself } - - /** - * Method invoked when a execution ends. - * - * @param files The files obtains from the list - * @param addToHistory If add path to history - * @param isNewHistory If is new history - * @param hasChanged If current directory was changed - * @param searchInfo The search information (if calling activity is {@link "SearchActivity"}) - * @param newDir The new directory - * @param newDirFSO the new directory in FSO form - * @param scrollTo If not null, then listview must scroll to this item - * @hide - */ - void onPostExecuteTask( - List<FileSystemObject> files, boolean addToHistory, boolean isNewHistory, - boolean hasChanged, SearchInfoParcelable searchInfo, - String newDir, final FileSystemObject newDirFSO, final FileSystemObject scrollTo) { - try { - //Check that there is not errors and have some data - if (files == null) { - this.mCurrentDir = this.mPreviousDir; - return; - } - - List<FileSystemObject> sortedFiles = null; - if (!TextUtils.equals(FileHelper.ROOTS_LIST, newDir)) { - //Apply user preferences - sortedFiles = - FileHelper.applyUserPreferences(files, this.mRestrictions, this.mChRooted); - } else { - sortedFiles = files; - } - - //Remove parent directory if we are in the root of a chrooted environment - if (this.mChRooted && StorageHelper.isStorageVolume(newDir) || - TextUtils.equals(newDir, FileHelper.ROOT_DIRECTORY)) { - if (files.size() > 0 && files.get(0) instanceof ParentDirectory) { - files.remove(0); - } - if (mNavigationMode.compareTo(NAVIGATION_MODE.PICKABLE) == 0) { - files.add(0, new ParentDirectory(FileHelper.ROOTS_LIST)); - } - } else if (!TextUtils.equals(FileHelper.ROOTS_LIST, newDir) && - files.size() > 0 && !(files.get(0) instanceof ParentDirectory)) { - if (mNavigationMode.compareTo(NAVIGATION_MODE.PICKABLE) == 0) { - files.add(0, new ParentDirectory(FileHelper.ROOTS_LIST)); - } - } - - //Add to history? - if (addToHistory && hasChanged && isNewHistory) { - if (this.mOnHistoryListener != null) { - //Communicate the need of a history change - this.mOnHistoryListener.onNewHistory(onSaveState()); - } - } - - //Load the data - loadData(files); - this.mFiles = files; - if (searchInfo != null) { - searchInfo.setSuccessNavigation(true); - } - - //Change the breadcrumb - if (this.mBreadcrumb != null) { - this.mBreadcrumb.changeBreadcrumbPath(newDir, this.mChRooted); - } - - //If scrollTo is null, the position will be set to 0 - scrollTo(scrollTo); - - //The current directory is now the "newDir" - this.mCurrentFileSystemObject = newDirFSO; - if (this.mOnDirectoryChangedListener != null) { - FileSystemObject dir = (newDirFSO != null) ? - newDirFSO : FileHelper.createFileSystemObject(new File(newDir)); - this.mOnDirectoryChangedListener.onDirectoryChanged(dir); - } - - } finally { - //If calling activity is search, then save the search history - if (searchInfo != null) { - this.mOnHistoryListener.onNewHistory(searchInfo); - } - - this.mPreviousDir = null; - mNavigationTask = null; - - //End of loading data - try { - NavigationView.this.mBreadcrumb.endLoading(); - } catch (Throwable ex) { - /**NON BLOCK**/ - } - } - } - /** * Method that loads the files in the adapter. * @@ -1345,43 +1283,47 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe */ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { - try { - FileSystemObject fso = ((FileSystemObjectAdapter)parent.getAdapter()).getItem(position); - if (fso instanceof ParentDirectory) { - changeCurrentDir(fso.getParent(), true, false, false, null, null); - return; - } else if (fso instanceof Directory) { - changeCurrentDir(fso.getFullPath(), true, false, false, null, null); - return; - } else if (fso instanceof Symlink) { - Symlink symlink = (Symlink)fso; - if (symlink.getLinkRef() != null && symlink.getLinkRef() instanceof Directory) { - changeCurrentDir( - symlink.getLinkRef().getFullPath(), true, false, false, null, null); + FileSystemObject fso = ((FileSystemObjectAdapter) parent.getAdapter()).getItem(position); + if (!((FileSystemObjectAdapter) parent.getAdapter()).isSelected(position)) { + try { + if (fso instanceof ParentDirectory) { + changeCurrentDir(fso.getParent(), true, false, false, null, null); return; - } + } else if (fso instanceof Directory) { + changeCurrentDir(fso.getFullPath(), true, false, false, null, null); + return; + } else if (fso instanceof Symlink) { + Symlink symlink = (Symlink) fso; + if (symlink.getLinkRef() != null && symlink.getLinkRef() instanceof Directory) { + changeCurrentDir( + symlink.getLinkRef().getFullPath(), true, false, false, null, null); + return; + } - // Open the link ref - fso = symlink.getLinkRef(); - } else if (fso instanceof RootDirectory) { - RootDirectory rootDirectory = (RootDirectory)fso; - changeCurrentDir(rootDirectory.getRootPath(), true); - return; - } + // Open the link ref + fso = symlink.getLinkRef(); + } else if (fso instanceof RootDirectory) { + RootDirectory rootDirectory = (RootDirectory) fso; + changeCurrentDir(rootDirectory.getRootPath(), true); + return; + } - // Open the file (edit or pick) - if (this.mNavigationMode.compareTo(NAVIGATION_MODE.BROWSABLE) == 0) { - // Open the file with the preferred registered app - IntentsActionPolicy.openFileSystemObject(getContext(), - NavigationView.this, fso, false, null); - } else { - // Request a file pick selection - if (this.mOnFilePickedListener != null) { - this.mOnFilePickedListener.onFilePicked(fso); + // Open the file (edit or pick) + if (this.mNavigationMode.compareTo(NAVIGATION_MODE.BROWSABLE) == 0) { + // Open the file with the preferred registered app + IntentsActionPolicy.openFileSystemObject(getContext(), + NavigationView.this, fso, false, null); + } else { + // Request a file pick selection + if (this.mOnFilePickedListener != null) { + this.mOnFilePickedListener.onFilePicked(fso); + } } + } catch (Throwable ex) { + ExceptionUtil.translateException(getContext(), ex); } - } catch (Throwable ex) { - ExceptionUtil.translateException(getContext(), ex); + } else { + onToggleSelection(fso); } } @@ -1391,7 +1333,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe @Override public void onRequestRefresh(Object o, boolean clearSelection) { if (o instanceof FileSystemObject) { - refresh((FileSystemObject)o); + refresh((FileSystemObject) o); } else if (o == null) { refresh(); } @@ -1451,18 +1393,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe if (this.mOnNavigationSelectionChangedListener != null) { this.mOnNavigationSelectionChangedListener.onSelectionChanged(this, selectedItems); } - } - - /** - * Method invoked when a request to show the menu associated - * with an item is started. - * - * @param item The item for which the request was started - */ - public void onRequestMenu(final FileSystemObject item) { - if (this.mOnNavigationRequestMenuListener != null) { - this.mOnNavigationRequestMenuListener.onRequestMenu(this, item); - } + mAdapter.notifyDataSetChanged(); } /** @@ -1570,24 +1501,4 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe // Refresh refresh(); } - - /** - * Method that ensures that the user don't go outside the ChRooted environment - * - * @param newDir The new directory to navigate to - * @return String - */ - private String checkChRootedNavigation(String newDir) { - // If we aren't in ChRooted environment, then there is nothing to check - if (!this.mChRooted) return newDir; - - // Check if the path is owned by one of the storage volumes - if (!StorageHelper.isPathInStorageVolume(newDir)) { - StorageVolume[] volumes = StorageHelper.getStorageVolumes(getContext(), false); - if (volumes != null && volumes.length > 0) { - return volumes[0].getPath(); - } - } - return newDir; - } } diff --git a/src/com/cyanogenmod/filemanager/ui/widgets/SelectionView.java b/src/com/cyanogenmod/filemanager/ui/widgets/SelectionView.java index e79ee01b..10c34da9 100644 --- a/src/com/cyanogenmod/filemanager/ui/widgets/SelectionView.java +++ b/src/com/cyanogenmod/filemanager/ui/widgets/SelectionView.java @@ -16,22 +16,30 @@ package com.cyanogenmod.filemanager.ui.widgets; +import android.animation.ValueAnimator; import android.content.Context; import android.content.res.Resources; +import android.support.v7.widget.Toolbar; import android.util.AttributeSet; +import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.Animation; -import android.view.animation.Transformation; +import android.view.animation.AnimationUtils; +import android.widget.FrameLayout; import android.widget.LinearLayout; -import android.widget.TextView; +import android.widget.TextView; import com.cyanogenmod.filemanager.R; +import com.cyanogenmod.filemanager.commands.FolderUsageExecutable; import com.cyanogenmod.filemanager.model.FileSystemObject; +import com.cyanogenmod.filemanager.ui.policy.PrintActionPolicy; import com.cyanogenmod.filemanager.util.FileHelper; +import com.cyanogenmod.filemanager.util.MimeTypeHelper; +import java.lang.reflect.Field; import java.util.List; /** @@ -43,14 +51,17 @@ public class SelectionView extends LinearLayout { * @hide */ int mViewHeight; - private TextView mStatus; private int mEffectDuration; + private Toolbar mToolbar; + private View mTitleLayout; + int mSize = 0; + private NavigationView mNavigationView; /** * Constructor of <code>SelectionView</code>. * * @param context The current context - * @param attrs The attributes of the XML tag that is inflating the view. + * @param attrs The attributes of the XML tag that is inflating the view. */ public SelectionView(Context context, AttributeSet attrs) { super(context, attrs); @@ -60,12 +71,12 @@ public class SelectionView extends LinearLayout { /** * Constructor of <code>SelectionView</code>. * - * @param context The current context - * @param attrs The attributes of the XML tag that is inflating the view. + * @param context The current context + * @param attrs The attributes of the XML tag that is inflating the view. * @param defStyle The default style to apply to this view. If 0, no style - * will be applied (beyond what is included in the theme). This may - * either be an attribute resource, whose value will be retrieved - * from the current theme, or an explicit style resource. + * will be applied (beyond what is included in the theme). This may + * either be an attribute resource, whose value will be retrieved + * from the current theme, or an explicit style resource. */ public SelectionView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); @@ -90,33 +101,144 @@ public class SelectionView extends LinearLayout { SelectionView.this.mViewHeight = getHeight(); getViewTreeObserver().removeOnGlobalLayoutListener(this); setVisibility(View.GONE); - LayoutParams params = (LayoutParams)SelectionView.this.getLayoutParams(); + FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) + SelectionView.this.getLayoutParams(); params.height = 0; } - }); + }); //Recovery all views - this.mStatus = (TextView)content.findViewById(R.id.navigation_status_selection_label); + mToolbar = (Toolbar) content.findViewById(R.id.selection_toolbar); + + mToolbar.inflateMenu(R.menu.selection_menu); + + mTitleLayout = inflate(getContext(), R.layout.selection_view_customtitle, null); + + mToolbar.addView(mTitleLayout); // Obtain the duration of the effect this.mEffectDuration = - getContext().getResources().getInteger(android.R.integer.config_shortAnimTime); + getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime); addView(content); } /** + * Method that configures the menu to show certain items depending on the available selection + * + */ + private void configureMenu(List<FileSystemObject> selection) { + // Selection + mToolbar.getMenu().clear(); + mToolbar.inflateMenu(R.menu.selection_menu); + + Menu menu = mToolbar.getMenu(); + // run only single file specific items + FileSystemObject fso = selection.get(0); + if (selection.size() == 1) { + + // Print (only for text and image categories) + if (!PrintActionPolicy.isPrintedAllowed(getContext(), fso)) { + menu.removeItem(R.id.mnu_actions_print); + } + + if (fso.isSecure() || fso.isRemote()) { + menu.removeItem(R.id.mnu_actions_add_shortcut); + } + + //Execute only if mime/type category is EXEC + MimeTypeHelper.MimeTypeCategory category + = MimeTypeHelper.getCategory(getContext(), fso); + if (category.compareTo(MimeTypeHelper.MimeTypeCategory.EXEC) != 0) { + menu.removeItem(R.id.mnu_actions_execute); + } + + if (category.compareTo(MimeTypeHelper.MimeTypeCategory.COMPRESS) == 0) { + menu.removeItem(R.id.mnu_actions_compress); + } else { + menu.removeItem(R.id.mnu_actions_extract); + } + + + //- Open/Open with -> Only when the fso is not a folder + if (FileHelper.isDirectory(fso)) { + menu.removeItem(R.id.mnu_actions_open); + menu.removeItem(R.id.mnu_actions_open_with); + menu.removeItem(R.id.mnu_actions_send); + } + + } else { + // run only global items + // Don't allow mass rename to avoid horrors. + menu.removeItem(R.id.mnu_actions_rename); + + // TODO can we print multiple items? what voodoo is this + // does this feature even work? + menu.removeItem(R.id.mnu_actions_print); + + // don't allow multiple shortcut adds + menu.removeItem(R.id.mnu_actions_add_shortcut); + + // We don't compute multiple checksums at once + menu.removeItem(R.id.mnu_actions_compute_checksum); + + // Don't execute all the things + menu.removeItem(R.id.mnu_actions_execute); + + // open with sadness + menu.removeItem(R.id.mnu_actions_open); + menu.removeItem(R.id.mnu_actions_open_with); + menu.removeItem(R.id.mnu_actions_send); + + } + + // Remove extract for now, feature does not work + menu.removeItem(R.id.mnu_actions_extract); + + // Not allowed if not in search + // TODO figure out search and what kind of things it likes to do. + menu.removeItem(R.id.mnu_actions_open_parent_folder); + + // dark magic to show icons in the overflow menu + if (menu.getClass().getSimpleName().equals("MenuBuilder")) { + try { + Field field = menu.getClass().getDeclaredField("mOptionalIconsVisible"); + field.setAccessible(true); + field.setBoolean(menu, true); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + } + } + + /** * Method that computes the selection and returns a text message. * * @param selection The selection * @return String The computed text from the selection */ private String computeSelection(List<FileSystemObject> selection) { + int cc = selection.size(); + final Resources res = getContext().getResources(); + + configureMenu(selection); + + if (cc == 1) { + FileSystemObject fso = selection.get(0); + return fso.getName(); + } else { + return res.getQuantityString(R.plurals.selection, cc, cc); + } + } + + private String getSubtitle(List<FileSystemObject> selection) { int folders = 0; int files = 0; - int cc = selection.size(); - for (int i = 0; i < cc; i++) { - FileSystemObject fso = selection.get(i); + final Resources res = getContext().getResources(); + + for (FileSystemObject fso : selection) { if (FileHelper.isDirectory(fso)) { folders++; } else { @@ -125,30 +247,51 @@ public class SelectionView extends LinearLayout { } // Get the string - final Resources res = getContext().getResources(); - if (files == 0) { - return res.getQuantityString(R.plurals.selection_folders, folders, folders); + return res.getQuantityString(R.plurals.folders, folders, folders); } if (folders == 0) { - return res.getQuantityString(R.plurals.selection_files, files, files); + return getFileSizes(selection); } String nFoldersString = res.getQuantityString(R.plurals.n_folders, folders, folders); String nFilesString = res.getQuantityString(R.plurals.n_files, files, files); - return res.getString(R.string.selection_folders_and_files, nFoldersString, nFilesString); + return res.getString(R.string.selection_folders_and_files, nFilesString, nFoldersString); + } + + public String getFileSizes(List<FileSystemObject> selection) { + for (FileSystemObject fso : selection) { + mSize += fso.getSize(); + } + return FileHelper.getHumanReadableSize(mSize); + } + + public void setMenuClickListener(Toolbar.OnMenuItemClickListener menuClickListener) { + mToolbar.setOnMenuItemClickListener(menuClickListener); + } + + public void setNavigationView(NavigationView currentNavigationView) { + mNavigationView = currentNavigationView; } + /** * Method that sets the {@link FileSystemObject} selection list * * @param newSelection The new selection list */ - public void setSelection(List<FileSystemObject> newSelection) { + public void setSelection(final List<FileSystemObject> newSelection) { + // selection changed, wipe away old things + mSize = 0; + // Compute the selection - if (newSelection != null && newSelection.size() > 0) { - this.mStatus.setText(computeSelection(newSelection)); + TextView title = (TextView) mTitleLayout.findViewById(R.id.selector_title); + TextView subtitle = ((TextView) mTitleLayout.findViewById(R.id.selector_subtitle)); + + if (newSelection != null && newSelection.size() > 0 && title != null && subtitle != null) { + title.setText(computeSelection(newSelection)); + subtitle.setText(getSubtitle(newSelection)); } // Requires show the animation (expand or collapse)? @@ -162,120 +305,66 @@ public class SelectionView extends LinearLayout { return; } - // Need some animation - final ExpandCollapseAnimation.ANIMATION_TYPE effect = - (newSelection != null && newSelection.size() > 0) ? - ExpandCollapseAnimation.ANIMATION_TYPE.EXPAND : - ExpandCollapseAnimation.ANIMATION_TYPE.COLLAPSE; - ExpandCollapseAnimation animation = - new ExpandCollapseAnimation( - this, - this.mViewHeight, - this.mEffectDuration, - effect); - animation.setAnimationListener(new Animation.AnimationListener() { + int animation = newSelection != null && newSelection.size() > 0 + ? R.anim.slide_in : R.anim.slide_out; + Animation anim = AnimationUtils.loadAnimation(getContext(), animation); + anim.setInterpolator(new AccelerateDecelerateInterpolator()); + anim.setDuration(250L); + anim.setAnimationListener(new Animation.AnimationListener() { + @Override - public void onAnimationStart(Animation anim) { - LayoutParams params = (LayoutParams)getLayoutParams(); - if (effect.compareTo(ExpandCollapseAnimation.ANIMATION_TYPE.EXPAND) == 0) { - params.height = 0; - } else if (effect.compareTo(ExpandCollapseAnimation.ANIMATION_TYPE.COLLAPSE) == 0) { - params.height = SelectionView.this.mViewHeight; + public void onAnimationEnd(Animation animation) { + if (newSelection != null && newSelection.size() > 0) { + setVisibility(View.VISIBLE); } - SelectionView.this.setVisibility(View.VISIBLE); } @Override - public void onAnimationRepeat(Animation anim) {/**NON BLOCK**/} + public void onAnimationRepeat(Animation animation) { + } @Override - public void onAnimationEnd(Animation anim) { - LayoutParams params = (LayoutParams)getLayoutParams(); - if (effect.compareTo(ExpandCollapseAnimation.ANIMATION_TYPE.COLLAPSE) == 0) { - params.height = 0; - requestLayout(); - SelectionView.this.setVisibility(View.GONE); - } else { + public void onAnimationStart(Animation animation) { + FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) getLayoutParams(); + + if (newSelection != null && newSelection.size() > 0) { params.height = SelectionView.this.mViewHeight; - requestLayout(); - SelectionView.this.setVisibility(View.VISIBLE); + navigationViewAnimation(false); + } else { + params.height = 0; + setVisibility(View.GONE); + navigationViewAnimation(true); } + } + }); - animation.setInterpolator(new AccelerateDecelerateInterpolator()); - startAnimation(animation); + + startAnimation(anim); + } /** - * An animation effect for expand or collapse the view - * + * Animation for NavigationView to properly expand or shrink the navigation listview. + * @param isReversed reverses the animation */ - private static class ExpandCollapseAnimation extends Animation { - - /** - * The enumeration of the types of animation effects - */ - public enum ANIMATION_TYPE { - EXPAND, - COLLAPSE - } - - private final View mView; - private final LayoutParams mViewLayoutParams; - private final int mViewHeight; - private final ANIMATION_TYPE mEffect; - - /** - * Constructor of <code>ExpandCollapseAnimation</code> - * - * @param view The view to animate - * @param viewHeight The maximum height of view. Used to compute the animation translation - * @param duration The duration of the animation - * @param effect The effect of the animation - */ - public ExpandCollapseAnimation( - View view, int viewHeight, int duration, ANIMATION_TYPE effect) { - super(); - this.mView = view; - this.mViewHeight = viewHeight; - this.mEffect = effect; - this.mViewLayoutParams = (LayoutParams) view.getLayoutParams(); - setDuration(duration); - } - - /** - * {@inheritDoc} - */ - @Override - protected void applyTransformation(float interpolatedTime, Transformation t) { - super.applyTransformation(interpolatedTime, t); - if (interpolatedTime < 1.0f) { - int height = (int)(this.mViewHeight * interpolatedTime); - if (this.mEffect.compareTo(ANIMATION_TYPE.EXPAND) == 0) { - this.mViewLayoutParams.height = height; - } else { - this.mViewLayoutParams.height = this.mViewHeight - height; + public void navigationViewAnimation(boolean isReversed) { + if (mNavigationView != null) { + ValueAnimator va = ValueAnimator.ofInt(0, SelectionView.this.mViewHeight); + va.setDuration(400L); + va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + public void onAnimationUpdate(ValueAnimator animation) { + FrameLayout.LayoutParams params + = (FrameLayout.LayoutParams) mNavigationView.getLayoutParams(); + params.bottomMargin = (Integer) animation.getAnimatedValue(); + mNavigationView.requestLayout(); } - this.mView.setLayoutParams(this.mViewLayoutParams); - this.mView.requestLayout(); + }); + if (isReversed) { + va.reverse(); + } else { + va.start(); } } - - /** - * {@inheritDoc} - */ - @Override - public void initialize(int width, int height, int parentWidth, int parentHeight) { - super.initialize(width, height, parentWidth, parentHeight); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean willChangeBounds() { - return true; - } } - -} +}
\ No newline at end of file diff --git a/src/com/cyanogenmod/filemanager/util/FileHelper.java b/src/com/cyanogenmod/filemanager/util/FileHelper.java index a2b2fb31..7ff32662 100644 --- a/src/com/cyanogenmod/filemanager/util/FileHelper.java +++ b/src/com/cyanogenmod/filemanager/util/FileHelper.java @@ -23,6 +23,7 @@ import android.system.ErrnoException; import android.system.OsConstants; import android.text.format.DateUtils; import android.util.Log; + import com.cyanogenmod.filemanager.FileManagerApplication; import com.cyanogenmod.filemanager.R; import com.cyanogenmod.filemanager.commands.SyncResultExecutable; |