diff options
author | Raj Yengisetty <rajesh@cyngn.com> | 2015-08-04 18:10:47 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-11-02 21:04:20 -0700 |
commit | d74a22588f9986a0cd80231c69592534603c80d8 (patch) | |
tree | 943ecc3baa19c9d619808be5878a01b838551c6d | |
parent | fd77582d34b8ddd0cff1f7bde979be9e65eedcf9 (diff) | |
download | android_packages_apps_CMFileManager-d74a22588f9986a0cd80231c69592534603c80d8.tar.gz android_packages_apps_CMFileManager-d74a22588f9986a0cd80231c69592534603c80d8.tar.bz2 android_packages_apps_CMFileManager-d74a22588f9986a0cd80231c69592534603c80d8.zip |
Implement new action bar
ref: CLOUD-69
Change-Id: Ia105bb65d2358ad779066b84672d6d508ad81e63
26 files changed, 575 insertions, 1148 deletions
diff --git a/res/drawable/ic_search_action_bar.xml b/res/drawable/ic_search_action_bar.xml new file mode 100644 index 00000000..4a7a14e9 --- /dev/null +++ b/res/drawable/ic_search_action_bar.xml @@ -0,0 +1,28 @@ +<?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="M15.5,14h-0.8l-0.3-0.3c1-1.1,1.6-2.6,1.6-4.2C16,5.9,13.1,3,9.5,3S3,5.9,3,9.5S5.9,16,9.5,16 +c1.6,0,3.1-0.6,4.2-1.6l0.3,0.3v0.8l5,5l1.5-1.5L15.5,14z +M9.5,14C7,14,5,12,5,9.5S7,5,9.5,5S14,7,14,9.5S12,14,9.5,14z" /> +</vector> diff --git a/res/layout/nav_fragment.xml b/res/layout/nav_fragment.xml index 5b4959f1..55bb454f 100644 --- a/res/layout/nav_fragment.xml +++ b/res/layout/nav_fragment.xml @@ -35,7 +35,6 @@ android:id="@+id/scrimInsetsFrameLayoutNavigation" android:layout_width="match_parent" android:layout_height="match_parent" - android:fitsSystemWindows="true" app:insetForeground="@color/material_palette_blue_primary_dark"> <!-- The main content view --> @@ -69,9 +68,6 @@ android:background="@drawable/bg_material_selectionbar" android:visibility="invisible"/> - <!-- StatusBar --> - <include layout="@layout/navigation_view_statusbar"/> - </LinearLayout> </com.cyanogenmod.filemanager.ui.widgets.ScrimInsetsFrameLayout> diff --git a/res/layout/navigation.xml b/res/layout/navigation.xml index cf48976e..0f3a1162 100644 --- a/res/layout/navigation.xml +++ b/res/layout/navigation.xml @@ -17,11 +17,13 @@ <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> + <include layout="@layout/home_fragment" + android:fitsSystemWindows="false" /> + <FrameLayout android:id="@+id/navigation_fragment_container" android:layout_width="match_parent" diff --git a/res/layout/navigation_drawer.xml b/res/layout/navigation_drawer.xml deleted file mode 100644 index e12d33bf..00000000 --- a/res/layout/navigation_drawer.xml +++ /dev/null @@ -1,202 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<com.cyanogenmod.filemanager.ui.widgets.ScrimInsetsFrameLayout - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:id="@+id/scrimInsetsFrameLayout" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_gravity="start" - android:fitsSystemWindows="true" - android:elevation="@dimen/scrim_layout_elevation" - app:insetForeground="#4000"> - - <LinearLayout - android:fitsSystemWindows="true" - android:layout_height="match_parent" - android:layout_width="match_parent" - android:orientation="vertical"> - - <RelativeLayout - android:id="@+id/drawer" - android:layout_width="280dp" - android:layout_height="match_parent" - android:layout_gravity="start" - android:background="@android:color/background_light"> - - <RelativeLayout - android:id="@+id/drawer_actionbar" - android:layout_width="match_parent" - android:layout_height="64dp" - android:layout_alignParentBottom="true"> - - <com.cyanogenmod.filemanager.ui.widgets.ButtonItem - android:id="@+id/ab_settings" - android:layout_width="@dimen/default_buttom_width" - android:layout_height="match_parent" - android:layout_alignParentEnd="true" - android:contentDescription="@string/menu_settings" - android:onClick="onActionBarItemClick" - android:src="@drawable/ic_material_light_settings"/> - - <com.cyanogenmod.filemanager.ui.widgets.ButtonItem - android:id="@+id/ab_clear_history" - android:layout_width="@dimen/default_buttom_width" - android:layout_height="match_parent" - android:layout_toEndOf="@id/ab_settings" - android:contentDescription="@string/menu_clear_history" - android:onClick="onActionBarItemClick" - android:src="@drawable/ic_material_light_delete"/> - </RelativeLayout> - - <LinearLayout - android:id="@+id/drawer_drawer_divider" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_above="@id/drawer_actionbar"> - - <include layout="@layout/vertical_divider"/> - - </LinearLayout> - - <ScrollView - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_above="@id/drawer_drawer_divider" - android:layout_alignParentTop="true"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"> - - <FrameLayout android:layout_height="@dimen/drawer_header_height" - android:layout_width="match_parent"> - <ImageView - android:id="@+id/header" - android:background="@drawable/fm_header_bg" - android:src="@drawable/header_gradient" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:scaleType="centerCrop"/> - - <TextView - android:layout_gravity="bottom" - android:paddingStart="10dp" - android:paddingBottom="10dp" - android:layout_height="wrap_content" - android:layout_width="match_parent" - android:textColor="@android:color/white" - android:textSize="30sp" - android:text="@string/app_name" - android:clickable="true"/> - - </FrameLayout> - - <LinearLayout - android:id="@+id/filesystem_info_dialog_tabhost" - android:layout_width="match_parent" - android:layout_height="@dimen/default_row_height" - android:orientation="horizontal"> - - <TextView - android:id="@+id/drawer_bookmarks_tab" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_weight="1" - android:background="@drawable/material_selector" - android:clickable="true" - android:gravity="center_horizontal|center_vertical" - android:text="@string/bookmarks" - android:textAllCaps="true" - android:textAppearance="@style/primary_text_appearance"/> - - <include - android:id="@+id/drawer_tab_divider1" - layout="@layout/horizontal_divider"/> - - <TextView - android:id="@+id/drawer_history_tab" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_weight="1" - android:background="@drawable/material_selector" - android:clickable="true" - android:gravity="center_horizontal|center_vertical" - android:text="@string/history" - android:textAllCaps="true" - android:textAppearance="@style/primary_text_appearance"/> - - </LinearLayout> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content"> - - <include - android:id="@+id/drawer_tab_divider2" - layout="@layout/vertical_divider"/> - - </LinearLayout> - - <LinearLayout - android:id="@+id/drawer_bookmarks" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/default_margin" - android:layout_marginEnd="@dimen/default_margin" - android:orientation="vertical"> - - <ProgressBar - android:id="@+id/bookmarks_loading" - android:layout_width="@dimen/default_row_height" - android:layout_height="@dimen/default_row_height" - android:indeterminate="true" - android:indeterminateOnly="true" - android:visibility="gone"/> - - <LinearLayout - android:id="@+id/bookmarks_list" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="@dimen/extra_margin" - android:orientation="vertical"> - - </LinearLayout> - - </LinearLayout> - - <LinearLayout - android:id="@+id/drawer_history" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/default_margin" - android:layout_marginEnd="@dimen/default_margin" - android:orientation="vertical" - android:visibility="gone"> - - <TextView - android:id="@+id/history_empty" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="@string/msgs_history_empty" - android:padding="@dimen/extra_margin" - android:gravity="center_horizontal" - android:textAppearance="@style/primary_text_appearance"/> - - <LinearLayout - android:id="@+id/history_list" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="@dimen/extra_margin" - android:orientation="vertical"> - </LinearLayout> - - </LinearLayout> - - </LinearLayout> - - </ScrollView> - </RelativeLayout> - </LinearLayout> -</com.cyanogenmod.filemanager.ui.widgets.ScrimInsetsFrameLayout> diff --git a/res/layout/navigation_view_customtitle.xml b/res/layout/navigation_view_customtitle.xml index 379072c5..8ee62ee6 100644 --- a/res/layout/navigation_view_customtitle.xml +++ b/res/layout/navigation_view_customtitle.xml @@ -20,26 +20,20 @@ android:animateLayoutChanges="true" android:orientation="horizontal"> - <com.cyanogenmod.filemanager.ui.widgets.NavigationCustomTitleView - android:id="@+id/navigation_title_flipper" - android:layout_width="0dp" - android:layout_height="?android:attr/actionBarSize" - android:layout_weight="1" - android:animateFirstView="true"> - - <!-- The breadcrumb layout (breadcrumb + configuration buttom) --> - <include layout="@layout/navigation_view_customtitle_breadcrumb" /> - - <!-- The configuration layout (sort, layout, other options, ...) --> - <include layout="@layout/navigation_view_customtitle_configuration" /> - - </com.cyanogenmod.filemanager.ui.widgets.NavigationCustomTitleView> - <LinearLayout android:id="@+id/navigation_title_landscape_holder" android:layout_width="wrap_content" android:layout_height="match_parent" - android:orientation="horizontal"/> + android:orientation="horizontal"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:id="@+id/drawer_title" + android:textSize="20sp" + android:textColor="@color/action_bar_title_text_color"/> + + </LinearLayout> <SearchView android:id="@+id/navigation_search_bar" diff --git a/res/layout/navigation_view_customtitle_breadcrumb.xml b/res/layout/navigation_view_customtitle_breadcrumb.xml deleted file mode 100644 index 0e9a6bae..00000000 --- a/res/layout/navigation_view_customtitle_breadcrumb.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2012 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. - --> - -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/tb_breadcrumb" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <com.cyanogenmod.filemanager.ui.widgets.ButtonItem - android:id="@+id/ab_configuration" - style="@style/breadcrumb_actionbar_buttom" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_alignParentEnd="true" - android:contentDescription="@null" - android:onClick="onActionBarItemClick" - android:src="@drawable/ic_material_light_expander_open" /> - - <com.cyanogenmod.filemanager.ui.widgets.BreadcrumbView - android:id="@+id/breadcrumb_view" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_toStartOf="@id/ab_configuration" /> - -</RelativeLayout> diff --git a/res/layout/navigation_view_customtitle_configuration.xml b/res/layout/navigation_view_customtitle_configuration.xml deleted file mode 100644 index 3831e515..00000000 --- a/res/layout/navigation_view_customtitle_configuration.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2012 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. - --> - -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/tb_configuration" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_alignParentStart="true" - android:layout_alignParentEnd="true" - android:layout_marginStart="@dimen/default_inverse_buttom_width" - android:gravity="center_horizontal" - android:orientation="horizontal" > - - <com.cyanogenmod.filemanager.ui.widgets.ButtonItem - android:id="@+id/ab_sort_mode" - android:layout_width="@dimen/default_buttom_width" - android:layout_height="match_parent" - android:contentDescription="@string/actionbar_button_sort_mode_cd" - android:onClick="onActionBarItemClick" - android:src="@drawable/ic_material_light_sort_alphabetically" /> - - <com.cyanogenmod.filemanager.ui.widgets.ButtonItem - android:id="@+id/ab_layout_mode" - android:layout_width="@dimen/default_buttom_width" - android:layout_height="match_parent" - android:contentDescription="@string/actionbar_button_layout_mode_cd" - android:onClick="onActionBarItemClick" - android:src="@drawable/ic_material_light_layout" /> - - <com.cyanogenmod.filemanager.ui.widgets.ButtonItem - android:id="@+id/ab_view_options" - android:layout_width="@dimen/default_buttom_width" - android:layout_height="match_parent" - android:contentDescription="@string/actionbar_button_other_view_options_cd" - android:onClick="onActionBarItemClick" - android:src="@drawable/ic_material_light_view" /> - </LinearLayout> - - <com.cyanogenmod.filemanager.ui.widgets.ButtonItem - android:id="@+id/ab_close" - android:layout_width="@dimen/default_buttom_width" - android:layout_height="match_parent" - android:layout_alignParentEnd="true" - android:contentDescription="@null" - android:onClick="onActionBarItemClick" - android:src="@drawable/ic_material_light_expander_close" /> - -</RelativeLayout> diff --git a/res/layout/navigation_view_selectionbar.xml b/res/layout/navigation_view_selectionbar.xml index 126ece26..91878fbb 100644 --- a/res/layout/navigation_view_selectionbar.xml +++ b/res/layout/navigation_view_selectionbar.xml @@ -46,4 +46,12 @@ android:text="@null" android:textAppearance="@style/secondary_text_appearance" /> + <Button + android:id="@+id/ab_actions" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:text="@string/actionbar_button_actions_cd" + android:onClick="onActionBarItemClick" + android:gravity="end"/> + </LinearLayout> diff --git a/res/layout/navigation_view_statusbar.xml b/res/layout/navigation_view_statusbar.xml deleted file mode 100644 index ae12f789..00000000 --- a/res/layout/navigation_view_statusbar.xml +++ /dev/null @@ -1,68 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2012 The CyanogenMod Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> - -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/navigation_statusbar_portrait_holder" - android:elevation="4dp" - android:layout_width="match_parent" - android:layout_height="@dimen/default_row_height" - android:background="@drawable/bg_material_statusbar" - android:visibility="invisible"> - - <RelativeLayout - android:id="@+id/navigation_statusbar" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <com.cyanogenmod.filemanager.ui.widgets.ButtonItem - android:id="@+id/ab_overflow" - android:layout_width="@dimen/default_buttom_width" - android:layout_height="match_parent" - android:layout_alignParentEnd="true" - android:contentDescription="@string/actionbar_button_overflow_cd" - android:onClick="onActionBarItemClick" - android:src="@drawable/ic_material_light_overflow" /> - - <com.cyanogenmod.filemanager.ui.widgets.ButtonItem - android:id="@+id/ab_actions" - android:layout_width="@dimen/default_buttom_width" - android:layout_height="match_parent" - android:contentDescription="@string/actionbar_button_actions_cd" - android:onClick="onActionBarItemClick" - android:src="@drawable/ic_material_light_contextual_action" /> - - <RelativeLayout - android:id="@+id/navigation_actionbar" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_toStartOf="@id/ab_overflow" - android:layout_toEndOf="@id/ab_actions"> - - <com.cyanogenmod.filemanager.ui.widgets.ButtonItem - android:id="@+id/ab_search" - android:layout_width="@dimen/default_buttom_width" - android:layout_height="match_parent" - android:layout_alignParentEnd="true" - android:contentDescription="@string/actionbar_button_search_cd" - android:onClick="onActionBarItemClick" - android:src="@drawable/ic_material_light_search" - android:visibility="invisible" /> - - </RelativeLayout> - - </RelativeLayout> - -</LinearLayout> diff --git a/res/menu/actions.xml b/res/menu/actions.xml index 8ea3bc2d..b39817da 100644 --- a/res/menu/actions.xml +++ b/res/menu/actions.xml @@ -23,26 +23,6 @@ android:showAsAction="ifRoom" android:title="@string/actions_menu_properties_current_folder"/> <item - android:id="@+id/mnu_actions_refresh" - android:showAsAction="ifRoom" - android:title="@string/actions_menu_refresh"/> - <item - android:id="@+id/mnu_actions_new_directory" - android:showAsAction="ifRoom" - android:title="@string/actions_menu_new_directory"/> - <item - android:id="@+id/mnu_actions_new_file" - android:showAsAction="ifRoom" - android:title="@string/actions_menu_new_file"/> - <item - android:id="@+id/mnu_actions_select_all" - android:showAsAction="ifRoom" - android:title="@string/actions_menu_select_all"/> - <item - android:id="@+id/mnu_actions_deselect_all" - android:showAsAction="ifRoom" - android:title="@string/actions_menu_deselect_all"/> - <item android:id="@+id/mnu_actions_paste_selection" android:showAsAction="ifRoom" android:title="@string/actions_menu_paste_selection"/> diff --git a/res/menu/navigation_menu.xml b/res/menu/navigation_menu.xml new file mode 100644 index 00000000..7a97c13e --- /dev/null +++ b/res/menu/navigation_menu.xml @@ -0,0 +1,49 @@ +<?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" > + + <item + android:id="@+id/mnu_actions_select_all" + app:showAsAction="never" + android:title="@string/actions_menu_select_all"/> + <item + android:id="@+id/mnu_actions_refresh" + app:showAsAction="never" + android:title="@string/actions_menu_refresh"/> + <item + android:id="@+id/mnu_actions_search" + app:showAsAction="always" + android:icon="@drawable/ic_search_action_bar" + android:title="@string/search_hint"/> + <item + android:id="@+id/mnu_actions_sort" + app:showAsAction="never" + android:title="@string/actionbar_button_sort_mode_cd"/> + <item + android:id="@+id/mnu_actions_new_directory" + app:showAsAction="never" + android:title="@string/actions_menu_new_directory"/> + <item + android:id="@+id/mnu_actions_new_file" + app:showAsAction="never" + android:title="@string/actions_menu_new_file"/> + <item + android:id="@+id/mnu_actions_properties_current_folder" + app:showAsAction="never" + android:title="@string/actions_menu_properties_current_folder"/> +</menu>
\ No newline at end of file diff --git a/res/values/colors.xml b/res/values/colors.xml index e6d03216..edc9487d 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -56,6 +56,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> <!-- Breadcrumb text color --> <color name="breadcrumb_text_color">#deffffff</color> @@ -151,4 +152,6 @@ <!-- The snackbar upgrade color --> <color name="snackbar_upgrade_color">#def2b807</color> + + <color name="status_bar_foreground_color">#33000000</color> </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index 55c6ce7b..09bf8dc6 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -480,7 +480,7 @@ <!-- Actions Dialog - Title --> <string name="actions_dialog_title">Actions</string> <!-- Actions Dialog - Menu - Properties of current folder --> - <string name="actions_menu_properties_current_folder">Properties</string> + <string name="actions_menu_properties_current_folder">Folder details</string> <!-- Actions Dialog - Menu - Refresh --> <string name="actions_menu_refresh">Refresh</string> <!-- Actions Dialog - Menu - New directory --> diff --git a/res/values/styles.xml b/res/values/styles.xml index 369c681c..59827cab 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -20,7 +20,7 @@ <!-- Base themes --> <style name="Base.AppTheme" parent="Theme.AppCompat.Light"> <item name="android:colorPrimary">@color/material_palette_blue_primary</item> - <item name="android:colorPrimaryDark">@color/material_palette_blue_primary_dark</item> + <item name="android:colorPrimaryDark">@android:color/transparent</item> <item name="android:colorAccent">@color/material_palette_blue_primary</item> <item name="android:windowNoTitle">true</item> <item name="android:windowActionBar">false</item> diff --git a/src/com/cyanogenmod/filemanager/activities/MainActivity.java b/src/com/cyanogenmod/filemanager/activities/MainActivity.java index a565b3a4..c9ad8483 100755 --- a/src/com/cyanogenmod/filemanager/activities/MainActivity.java +++ b/src/com/cyanogenmod/filemanager/activities/MainActivity.java @@ -19,15 +19,14 @@ package com.cyanogenmod.filemanager.activities; import android.Manifest; import android.app.Activity; import android.app.Dialog; -import android.app.FragmentTransaction; import android.app.SearchManager; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.nfc.NfcAdapter; import android.os.Bundle; @@ -37,8 +36,12 @@ import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager.OnBackStackChangedListener; +import android.support.v4.app.FragmentTransaction; +import android.support.v4.graphics.ColorUtils; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.CardView; +import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.util.Log; import android.view.Gravity; @@ -48,23 +51,27 @@ import android.view.ViewGroup; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; - +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.GridView; +import android.widget.ImageView; +import android.widget.SearchView; +import android.widget.TextView; +import android.widget.Toast; import com.cyanogenmod.filemanager.FileManagerApplication; import com.cyanogenmod.filemanager.R; import com.cyanogenmod.filemanager.activities.preferences.SettingsPreferences; import com.cyanogenmod.filemanager.controllers.NavigationDrawerController; -import com.cyanogenmod.filemanager.dialogs.SortViewOptions; import com.cyanogenmod.filemanager.model.Bookmark; import com.cyanogenmod.filemanager.model.FileSystemObject; import com.cyanogenmod.filemanager.preferences.FileManagerSettings; -import com.cyanogenmod.filemanager.preferences.PreferenceHelper; import com.cyanogenmod.filemanager.preferences.Preferences; import com.cyanogenmod.filemanager.ui.ThemeManager; -import com.cyanogenmod.filemanager.ui.fragments.HomeFragment; import com.cyanogenmod.filemanager.ui.fragments.NavigationFragment; import com.cyanogenmod.filemanager.ui.fragments.NavigationFragment.OnGoHomeRequestListener; import com.cyanogenmod.filemanager.ui.widgets.NavigationView.OnBackRequestListener; import com.cyanogenmod.filemanager.util.FileHelper; +import com.cyanogenmod.filemanager.util.MimeTypeHelper; import com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory; import com.cyanogenmod.filemanager.util.StorageHelper; @@ -73,6 +80,13 @@ import java.io.InvalidClassException; import java.util.ArrayList; import java.util.List; +import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.APP; +import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.AUDIO; +import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.DOCUMENT; +import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.IMAGE; +import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.NONE; +import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.VIDEO; + /** * The main navigation activity. This activity is the center of the application. * From this the user can navigate, search, make actions.<br/> @@ -127,6 +141,32 @@ public class MainActivity extends ActionBarActivity public static final String EXTRA_ADD_TO_HISTORY = "extra_add_to_history"; //$NON-NLS-1$ + static java.util.Map<MimeTypeCategory, Drawable> EASY_MODE_ICONS = new + java.util.HashMap<MimeTypeCategory, Drawable>(); + + private static final List<MimeTypeCategory> EASY_MODE_LIST = new ArrayList<MimeTypeCategory>() { + { + add(NONE); + add(IMAGE); + add(VIDEO); + add(AUDIO); + add(DOCUMENT); + add(APP); + } + }; + + private Toolbar mToolBar; + + private ArrayAdapter<MimeTypeCategory> mEasyModeAdapter; + + private View.OnClickListener mEasyModeItemClickListener = new View.OnClickListener() { + @Override + public void onClick(View view) { + Integer position = (Integer) view.getTag(); + onClicked(position); + } + }; + /** * Fragment types */ @@ -286,12 +326,12 @@ public class MainActivity extends ActionBarActivity @Override public void onBackStackChanged() { updateCurrentFragment(); - if (isCurrentFragment(FragmentType.HOME)) { - mNavigationDrawerController.setSelected(R.id.navigation_item_home); - } } }); - setCurrentFragment(FragmentType.HOME); + + handleSearchBar(); + + setHomeStatusBarColor(); //Initialize nfc adapter NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this); @@ -324,6 +364,51 @@ public class MainActivity extends ActionBarActivity handleNavigateIntent(getIntent()); } + private void handleSearchBar() { + SearchView searchView = (SearchView) findViewById(R.id.homepage_search_bar); + SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); + searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); + searchView.setIconifiedByDefault(false); + + int searchPlateId = searchView.getContext().getResources() + .getIdentifier("android:id/search_plate", null, null); + View searchPlate = searchView.findViewById(searchPlateId); + if (searchPlate != null) { + int searchTextId = searchPlate.getContext().getResources() + .getIdentifier("android:id/search_src_text", null, null); + TextView searchText = (TextView) searchPlate.findViewById(searchTextId); + if (searchText != null) { + int searchColor = getResources().getColor(R.color.search_bar_hint_text_color); + searchText.setTextColor(searchColor); + searchText.setHintTextColor(searchColor); + } + + // Update all the image views to our assets + int imageViewId = getResources().getIdentifier("android:id/search_button", null, null); + ImageView imageView = (ImageView) searchView.findViewById(imageViewId); + if (imageView != null) { + imageView.setImageResource(R.drawable.ic_search); + } + imageViewId = getResources().getIdentifier("android:id/search_mag_icon", null, null); + imageView = (ImageView) searchView.findViewById(imageViewId); + if (imageView != null) { + imageView.setImageResource(R.drawable.ic_search); + } + imageViewId = getResources().getIdentifier("android:id/search_voice_btn", null, null); + imageView = (ImageView) searchView.findViewById(imageViewId); + if (imageView != null) { + imageView.setImageResource(R.drawable.ic_search_voice); + } + imageViewId = getResources().getIdentifier("android:id/search_close_btn", null, null); + imageView = (ImageView) searchView.findViewById(imageViewId); + if (imageView != null) { + imageView.setImageResource(R.drawable.ic_cancel_close); + } + } + + searchView.setFocusable(false); + } + /** * {@inheritDoc} */ @@ -356,10 +441,23 @@ public class MainActivity extends ActionBarActivity case HOME: default: mPopBackStack = false; - currentFragment = HomeFragment.newInstance(); - fragmentTag = fragmentType.name(); + currentFragment = null; + int fragmentCount = fragmentManager.getBackStackEntryCount(); + for (int i = 0; i < fragmentCount; i++) { + FragmentManager.BackStackEntry backStackEntry = + fragmentManager.getBackStackEntryAt(i); + Fragment fragment = fragmentManager.findFragmentByTag(backStackEntry.getName()); + if (fragment != null) { + fragmentManager.beginTransaction() + .remove(fragment) + .commitAllowingStateLoss(); + fragmentManager.popBackStack(); + } + } mNavigationDrawerController.setSelected(R.id.navigation_item_home); - break; + setHomeStatusBarColor(); + + return; } fragmentManager.beginTransaction() @@ -369,18 +467,35 @@ public class MainActivity extends ActionBarActivity .commitAllowingStateLoss(); } + private void setHomeStatusBarColor() { + int foregroundColor = getResources().getColor(R.color.status_bar_foreground_color); + int backgroundColor = getResources().getColor(R.color.default_primary); + int statusBarColor = ColorUtils.compositeColors(foregroundColor, backgroundColor); + getWindow().setStatusBarColor(statusBarColor); + } + private void updateCurrentFragment() { - for (FragmentType type : FragmentType.values()) { - Fragment fragment = getSupportFragmentManager().findFragmentByTag(type.name()); - if (fragment != null && fragment.isVisible()) { - currentFragment = fragment; - } + FragmentManager fragmentManager = getSupportFragmentManager(); + + if (fragmentManager.getBackStackEntryCount() > 0) { + FragmentManager.BackStackEntry backEntry = fragmentManager.getBackStackEntryAt( + fragmentManager.getBackStackEntryCount() - 1); + currentFragment = fragmentManager.findFragmentByTag(backEntry.getName()); + } else { + // current fragment is Home + currentFragment = null; + mNavigationDrawerController.setSelected(R.id.navigation_item_home); + setHomeStatusBarColor(); } } private boolean isCurrentFragment(FragmentType fragmentType) { - Fragment fragment = getSupportFragmentManager().findFragmentByTag(fragmentType.name()); - return (fragment != null && fragment.isVisible()); + if (fragmentType == FragmentType.HOME) { + return getSupportFragmentManager().getFragments().size() <= 0; + } else { + Fragment fragment = getSupportFragmentManager().findFragmentByTag(fragmentType.name()); + return (fragment != null && fragment.isVisible()); + } } public void navigateToPath(String path) { @@ -457,6 +572,98 @@ public class MainActivity extends ActionBarActivity } @Override + protected void onStart() { + super.onStart(); + + mToolBar = (Toolbar) findViewById(R.id.material_toolbar); + setSupportActionBar(mToolBar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu); + + initEasyModePlus(); + } + + private void initEasyModePlus() { + + MIME_TYPE_LOCALIZED_NAMES = MimeTypeCategory.getFriendlyLocalizedNames(this); + EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.NONE, getResources().getDrawable( + R.drawable.ic_em_all)); + EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.IMAGE, getResources().getDrawable( + R.drawable.ic_em_image)); + EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.VIDEO, getResources().getDrawable( + R.drawable.ic_em_video)); + EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.AUDIO, getResources().getDrawable( + R.drawable.ic_em_music)); + EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.DOCUMENT, getResources().getDrawable( + R.drawable.ic_em_document)); + EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.APP, getResources().getDrawable( + R.drawable.ic_em_application)); + + GridView gridview = (GridView) findViewById(R.id.easy_modeView); + + mEasyModeAdapter = new android.widget.ArrayAdapter<MimeTypeCategory>(this, R.layout + .navigation_view_simple_item) { + @Override + public View getView(int position, View convertView, ViewGroup parent) { + convertView = (convertView == null) ? getLayoutInflater().inflate(R.layout + .navigation_view_simple_item, parent, false) : convertView; + MimeTypeCategory item = getItem(position); + String typeTitle = MIME_TYPE_LOCALIZED_NAMES[item.ordinal()]; + TextView typeTitleTV = (TextView) convertView + .findViewById(R.id.navigation_view_item_name); + ImageView typeIconIV = (ImageView) convertView + .findViewById(R.id.navigation_view_item_icon); + + typeTitleTV.setText(typeTitle); + typeIconIV.setImageDrawable(EASY_MODE_ICONS.get(item)); + convertView.setOnClickListener(mEasyModeItemClickListener); + convertView.setTag(position); + return convertView; + } + }; + mEasyModeAdapter.addAll(EASY_MODE_LIST); + gridview.setAdapter(mEasyModeAdapter); + + gridview.setOnItemClickListener(new OnItemClickListener() { + public void onItemClick(AdapterView<?> parent, View v, int position, long id) { + Toast.makeText(MainActivity.this, "" + position, Toast.LENGTH_SHORT).show(); + } + }); + } + + private void onClicked(int position) { + Intent intent = new Intent(this, SearchActivity.class); + intent.setAction(Intent.ACTION_SEARCH); + intent.putExtra(SearchActivity.EXTRA_SEARCH_DIRECTORY, FileHelper.ROOT_DIRECTORY); + intent.putExtra(SearchManager.QUERY, "*"); // Use wild-card '*' + + if (position == 0) { + FragmentManager fragmentManager = getSupportFragmentManager(); + + fragmentManager.beginTransaction() + .replace(R.id.navigation_fragment_container, new NavigationFragment()) + .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) + .commit(); + return; + + } else { + ArrayList<MimeTypeCategory> searchCategories = new ArrayList<MimeTypeCategory>(); + MimeTypeCategory selectedCategory = EASY_MODE_LIST.get(position); + searchCategories.add(selectedCategory); + // a one off case where we implicitly want to also search for TEXT mimetypes when the + // DOCUMENTS category is selected + if (selectedCategory == MimeTypeCategory.DOCUMENT) { + searchCategories.add( + MimeTypeCategory.TEXT); + } + intent.putExtra(SearchActivity.EXTRA_SEARCH_MIMETYPE, searchCategories); + } + + startActivity(intent); + } + + @Override public void onResume() { super.onResume(); mNavigationDrawerController.loadNavigationDrawerItems(); @@ -529,20 +736,6 @@ public class MainActivity extends ActionBarActivity switch (view.getId()) { //###################### - //Navigation Custom Title - //###################### - case com.cyanogenmod.filemanager.R.id.ab_configuration: - //Show navigation view configuration toolbar - ((NavigationFragment)currentFragment) - .getCurrentNavigationView().getCustomTitle().showConfigurationView(); - break; - case com.cyanogenmod.filemanager.R.id.ab_close: - //Hide navigation view configuration toolbar - ((NavigationFragment)currentFragment) - .getCurrentNavigationView().getCustomTitle().hideConfigurationView(); - break; - - //###################### //Breadcrumb Actions //###################### case com.cyanogenmod.filemanager.R.id.ab_filesystem_info: @@ -555,52 +748,6 @@ public class MainActivity extends ActionBarActivity .getCurrentNavigationView().getBreadcrumb().getDiskUsageInfo(); ((NavigationFragment)currentFragment).showMountPointInfo(mp, du); break; - - //###################### - //Navigation view options - //###################### - case com.cyanogenmod.filemanager.R.id.ab_sort_mode: - SortViewOptions.createSortDialog(this, - 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) { - ((NavigationFragment) currentFragment).updateSetting( - FileManagerSettings.SETTINGS_SORT_MODE, result); - } - } - } - }) - .show(); - break; - case com.cyanogenmod.filemanager.R.id.ab_layout_mode: - ((NavigationFragment)currentFragment).showSettingsPopUp(view, - java.util.Arrays.asList( - new FileManagerSettings[]{ - FileManagerSettings.SETTINGS_LAYOUT_MODE})); - break; - case com.cyanogenmod.filemanager.R.id.ab_view_options: - // If we are in ChRooted mode, then don't show non-secure items - if (((NavigationFragment)currentFragment).mChRooted) { - ((NavigationFragment)currentFragment).showSettingsPopUp(view, - java.util.Arrays - .asList(new FileManagerSettings[]{ - FileManagerSettings.SETTINGS_SHOW_DIRS_FIRST})); - } else { - ((NavigationFragment)currentFragment).showSettingsPopUp(view, - java.util.Arrays - .asList(new FileManagerSettings[]{ - FileManagerSettings.SETTINGS_SHOW_DIRS_FIRST, - FileManagerSettings.SETTINGS_SHOW_HIDDEN, - FileManagerSettings.SETTINGS_SHOW_SYSTEM, - FileManagerSettings.SETTINGS_SHOW_SYMLINKS})); - } - - break; - //###################### //Selection Actions //###################### @@ -609,21 +756,9 @@ public class MainActivity extends ActionBarActivity ((NavigationFragment)currentFragment) .getCurrentNavigationView().onDeselectAll(); break; - - //###################### - //Action Bar buttons - //###################### - case com.cyanogenmod.filemanager.R.id.ab_actions: - ((NavigationFragment)currentFragment).openActionsDialog( - ((NavigationFragment)currentFragment) - .getCurrentNavigationView().getCurrentDir(), - true); - break; - - case com.cyanogenmod.filemanager.R.id.ab_search: - ((NavigationFragment)currentFragment).openSearch(); - break; - + case R.id.ab_actions: + // Show the actions dialog + ((NavigationFragment) currentFragment).openActionsDialog(null, true); default: break; } @@ -694,7 +829,7 @@ public class MainActivity extends ActionBarActivity return; } } - if (getSupportFragmentManager().getBackStackEntryCount() == 1) { + if (getSupportFragmentManager().getBackStackEntryCount() == 0) { finish(); } super.onBackPressed(); @@ -717,4 +852,8 @@ public class MainActivity extends ActionBarActivity Snackbar.make(view, message, Snackbar.LENGTH_LONG).show(); } } + + public int getColorForPath(String path) { + return mNavigationDrawerController.getColorForPath(path); + } } diff --git a/src/com/cyanogenmod/filemanager/controllers/NavigationDrawerController.java b/src/com/cyanogenmod/filemanager/controllers/NavigationDrawerController.java index a573969e..c1a2c0eb 100755 --- a/src/com/cyanogenmod/filemanager/controllers/NavigationDrawerController.java +++ b/src/com/cyanogenmod/filemanager/controllers/NavigationDrawerController.java @@ -315,6 +315,21 @@ public class NavigationDrawerController implements OnDirectoryChangedListener { mAdapter.notifyDataSetChanged(); } + public int getColorForPath(String path) { + String volumePath = null; + + volumePath = StorageHelper.getStorageVolumeFromPath(path); + + for (NavigationDrawerItem item : mNavigationDrawerItemList) { + if (!TextUtils.isEmpty(volumePath) && + TextUtils.equals(item.getSummary(), volumePath)) { + return item.getSelectedColor(); + } + } + + return mCtx.getResources().getColor(R.color.default_primary); + } + @Override public void onDirectoryChanged(FileSystemObject item) { if (DEBUG) Log.d(TAG, "onDirectoryChanged::" + item.getFullPath()); diff --git a/src/com/cyanogenmod/filemanager/parcelables/NavigationViewInfoParcelable.java b/src/com/cyanogenmod/filemanager/parcelables/NavigationViewInfoParcelable.java index 0f286f75..50233cf0 100644 --- a/src/com/cyanogenmod/filemanager/parcelables/NavigationViewInfoParcelable.java +++ b/src/com/cyanogenmod/filemanager/parcelables/NavigationViewInfoParcelable.java @@ -39,6 +39,7 @@ public class NavigationViewInfoParcelable extends HistoryNavigable { private int mId; private String mCurrentDir; + private FileSystemObject mCurrentFileSystemObject; private boolean mChRooted; private List<FileSystemObject> mFiles; private List<FileSystemObject> mSelectedFiles; @@ -116,6 +117,24 @@ public class NavigationViewInfoParcelable extends HistoryNavigable { } /** + * Method that returns the current directory's {@link FileSystemObject}. + * + * @return String The current directory + */ + public FileSystemObject getCurrentFso() { + return this.mCurrentFileSystemObject; + } + + /** + * Method that sets the current directory's {@link FileSystemObject}. + * + * @param currentFso The current directory + */ + public void setCurrentFso(FileSystemObject currentFso) { + this.mCurrentFileSystemObject = currentFso; + } + + /** * Method that returns if the view is in a ChRooted environment. * * @return boolean If the view is in a ChRooted environment diff --git a/src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java b/src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java index 52a7300e..43a3cc53 100644 --- a/src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java +++ b/src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java @@ -224,16 +224,6 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen //What action was selected? switch ((int)id) { - //- Create new object - case R.id.mnu_actions_new_directory: - case R.id.mnu_actions_new_file: - // Dialog is dismissed inside showInputNameDialog - if (this.mOnSelectionListener != null) { - showInputNameDialog(menuItem); - return; - } - break; - //- Rename case R.id.mnu_actions_rename: case R.id.mnu_actions_rename_selection: @@ -281,13 +271,6 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen null); break; - //- Refresh - case R.id.mnu_actions_refresh: - if (this.mOnRequestRefreshListener != null) { - this.mOnRequestRefreshListener.onRequestRefresh(null, false); //Refresh all - } - break; - //- Select/Deselect case R.id.mnu_actions_select: case R.id.mnu_actions_deselect: @@ -295,16 +278,6 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen this.mOnSelectionListener.onToggleSelection(this.mFso); } break; - case R.id.mnu_actions_select_all: - if (this.mOnSelectionListener != null) { - this.mOnSelectionListener.onSelectAllVisibleItems(); - } - break; - case R.id.mnu_actions_deselect_all: - if (this.mOnSelectionListener != null) { - this.mOnSelectionListener.onDeselectAllVisibleItems(); - } - break; //- Open case R.id.mnu_actions_open: @@ -468,37 +441,29 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen /** * Method that show a new dialog for input a name. * - * @param menuItem The item menu associated + * @param context Context for showing dialog and creating file system object + * @param title The dialog title + * @param id The menu id to determine if creating a directory or file + * @param fileSystemObjects The list of file system objects in the current directory + * @param onSelectionListener + * @param onRequestRefreshListener */ - private void showInputNameDialog(final MenuItem menuItem) { - //Hide the dialog - this.mDialog.hide(); - + public static void showInputNameDialog(final Context context, String title, final int id, + List <FileSystemObject> fileSystemObjects, final OnSelectionListener onSelectionListener, + final OnRequestRefreshListener onRequestRefreshListener) { //Show the input name dialog final InputNameDialog inputNameDialog = new InputNameDialog( - this.mContext, - this.mOnSelectionListener.onRequestCurrentDir(), - menuItem.getTitle().toString()); - inputNameDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { - @Override - public void onCancel(DialogInterface dialog) { - //Show the menu again - DialogHelper.delegateDialogShow( - ActionsDialog.this.mContext, ActionsDialog.this.mDialog); - } - }); + context, + fileSystemObjects, + title); inputNameDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { //Retrieve the name an execute the action - try { - String name = inputNameDialog.getName(); - createNewFileSystemObject(menuItem.getItemId(), name); - - } finally { - ActionsDialog.this.mDialog.dismiss(); - } + String name = inputNameDialog.getName(); + createNewFileSystemObject(context, id, name, onSelectionListener, + onRequestRefreshListener); } }); inputNameDialog.show(); @@ -520,7 +485,7 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen final InputNameDialog inputNameDialog = new InputNameDialog( this.mContext, - this.mOnSelectionListener.onRequestCurrentDir(), + this.mOnSelectionListener.onRequestCurrentItems(), fso, allowFsoName, menuItem.getTitle().toString()); @@ -594,21 +559,24 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen /** * Method that create the a new file system object. * + * @param context Context to use for creating File System object * @param menuId The menu identifier (need to determine the fso type) * @param name The name of the file system object + * @param onSelectionListener + * @param onRequestRefreshListener * @hide */ - void createNewFileSystemObject(final int menuId, final String name) { + public static void createNewFileSystemObject(Context context, final int menuId, + final String name, OnSelectionListener onSelectionListener, + OnRequestRefreshListener onRequestRefreshListener) { switch (menuId) { case R.id.mnu_actions_new_directory: NewActionPolicy.createNewDirectory( - this.mContext, name, - this.mOnSelectionListener, this.mOnRequestRefreshListener); + context, name, onSelectionListener, onRequestRefreshListener); break; case R.id.mnu_actions_new_file: NewActionPolicy.createNewFile( - this.mContext, name, - this.mOnSelectionListener, this.mOnRequestRefreshListener); + context, name, onSelectionListener, onRequestRefreshListener); break; default: break; diff --git a/src/com/cyanogenmod/filemanager/ui/dialogs/InputNameDialog.java b/src/com/cyanogenmod/filemanager/ui/dialogs/InputNameDialog.java index dfe844aa..36cf1d1e 100644 --- a/src/com/cyanogenmod/filemanager/ui/dialogs/InputNameDialog.java +++ b/src/com/cyanogenmod/filemanager/ui/dialogs/InputNameDialog.java @@ -59,7 +59,7 @@ public class InputNameDialog /** * @hide */ - final String mParent; + final List<FileSystemObject> mFiles; /** * @hide */ @@ -81,8 +81,8 @@ public class InputNameDialog * @param dialogTitle The dialog title */ public InputNameDialog( - final Context context, String parent, String dialogTitle) { - this(context, parent, null, false, dialogTitle); + final Context context, List<FileSystemObject> files, String dialogTitle) { + this(context, files, null, false, dialogTitle); } /** @@ -95,18 +95,15 @@ public class InputNameDialog * @param dialogTitle The dialog title */ public InputNameDialog( - final Context context, - final String parent, - final FileSystemObject fso, - boolean allowFsoName, - final String dialogTitle) { + final Context context, final List<FileSystemObject> files, + final FileSystemObject fso, boolean allowFsoName, final String dialogTitle) { super(); //Save the context this.mContext = context; //Save the files - this.mParent = parent; + this.mFiles = files; this.mFso = fso; this.mAllowFsoName = allowFsoName; this.mCancelled = true; @@ -296,7 +293,7 @@ public class InputNameDialog } // Name exists - if (FileHelper.isNameExists(this.mContext, this.mParent, name)) { + if (FileHelper.isNameExists(this.mFiles, name)) { setMsg( InputNameDialog.this.mContext.getString( R.string.input_name_dialog_message_name_exists), false); diff --git a/src/com/cyanogenmod/filemanager/ui/fragments/HomeFragment.java b/src/com/cyanogenmod/filemanager/ui/fragments/HomeFragment.java deleted file mode 100644 index d1dfefef..00000000 --- a/src/com/cyanogenmod/filemanager/ui/fragments/HomeFragment.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (C) 2015 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cyanogenmod.filemanager.ui.fragments; - -import android.app.FragmentTransaction; -import android.app.SearchManager; -import android.content.Context; -import android.content.Intent; -import android.content.res.Resources; -import android.graphics.Color; -import android.graphics.drawable.Drawable; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v7.app.ActionBarActivity; -import android.support.v7.widget.Toolbar; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.GridView; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.SearchView; -import android.widget.TextView; -import android.widget.Toast; - -import com.cyanogenmod.filemanager.R; -import com.cyanogenmod.filemanager.activities.SearchActivity; -import com.cyanogenmod.filemanager.util.FileHelper; -import com.cyanogenmod.filemanager.util.MimeTypeHelper; -import com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory; - -import java.util.ArrayList; -import java.util.List; - -import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.APP; -import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.AUDIO; -import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.DOCUMENT; -import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.IMAGE; -import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.NONE; -import static com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory.VIDEO; - -public class HomeFragment extends Fragment { - - View mView; - Toolbar mToolBar; - SearchView mSearchView; - private android.widget.ArrayAdapter<MimeTypeCategory> mEasyModeAdapter; - private static final List<MimeTypeCategory> EASY_MODE_LIST = new ArrayList<MimeTypeCategory>() { - { - add(NONE); - add(IMAGE); - add(VIDEO); - add(AUDIO); - add(DOCUMENT); - add(APP); - } - }; - static java.util.Map<MimeTypeHelper.MimeTypeCategory, Drawable> EASY_MODE_ICONS = new - java.util.HashMap<MimeTypeHelper.MimeTypeCategory, Drawable>(); - static String MIME_TYPE_LOCALIZED_NAMES[]; - private View.OnClickListener mEasyModeItemClickListener = new View.OnClickListener() { - @Override - public void onClick(View view) { - Integer position = (Integer) view.getTag(); - onClicked(position); - } - }; - - LayoutInflater mLayoutInflater; - - - /** - * Returns a new instance of this fragment for the given section - * number. - */ - public static HomeFragment newInstance() { - HomeFragment frag = new HomeFragment(); - return frag; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - mLayoutInflater = inflater; - - mView = inflater.inflate(R.layout.home_fragment, container, false); - - handleSearchBar(); - - return mView; - } - - private void handleSearchBar() { - mSearchView = (SearchView) mView.findViewById(R.id.homepage_search_bar); - SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context - .SEARCH_SERVICE); - mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity() - .getComponentName())); - mSearchView.setIconifiedByDefault(false); - - Resources res = mSearchView.getContext().getResources(); - int searchPlateId = res.getIdentifier("android:id/search_plate", null, null); - View searchPlate = mSearchView.findViewById(searchPlateId); - if (searchPlate != null) { - int searchTextId = res.getIdentifier("android:id/search_src_text", null, null); - TextView searchText = (TextView) searchPlate.findViewById(searchTextId); - if (searchText != null) { - int searchColor = res.getColor(R.color.search_bar_hint_text_color); - searchText.setTextColor(searchColor); - searchText.setHintTextColor(searchColor); - } - - // Update all the image views to our assets - int imageViewId = res.getIdentifier("android:id/search_button", null, null); - ImageView imageView = (ImageView) mSearchView.findViewById(imageViewId); - if (imageView != null) { - imageView.setImageResource(R.drawable.ic_search); - } - imageViewId = res.getIdentifier("android:id/search_mag_icon", null, null); - imageView = (ImageView) mSearchView.findViewById(imageViewId); - if (imageView != null) { - imageView.setImageResource(R.drawable.ic_search); - } - imageViewId = res.getIdentifier("android:id/search_voice_btn", null, null); - imageView = (ImageView) mSearchView.findViewById(imageViewId); - if (imageView != null) { - imageView.setImageResource(R.drawable.ic_search_voice); - } - imageViewId = res.getIdentifier("android:id/search_close_btn", null, null); - imageView = (ImageView) mSearchView.findViewById(imageViewId); - if (imageView != null) { - imageView.setImageResource(R.drawable.ic_cancel_close); - } - } - - mSearchView.setFocusable(false); - } - - @Override - public void onStart() { - super.onStart(); - - mToolBar = (Toolbar) mView.findViewById(R.id.material_toolbar); - ActionBarActivity actionBarActivity = (ActionBarActivity) getActivity(); - actionBarActivity.setSupportActionBar(mToolBar); - actionBarActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); - actionBarActivity.getSupportActionBar().setHomeButtonEnabled(true); - actionBarActivity.getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu); - - initEasyModePlus(); - } - - @Override - public void onSaveInstanceState(Bundle savedInstanceState) - { - super.onSaveInstanceState(savedInstanceState); - } - - @Override - public void onResume() { - super.onResume(); - } - - - private void initEasyModePlus() { - - MIME_TYPE_LOCALIZED_NAMES = MimeTypeCategory.getFriendlyLocalizedNames(getActivity()); - EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.NONE, getResources().getDrawable( - R.drawable.ic_em_all)); - EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.IMAGE, getResources().getDrawable( - R.drawable.ic_em_image)); - EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.VIDEO, getResources().getDrawable( - R.drawable.ic_em_video)); - EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.AUDIO, getResources().getDrawable( - R.drawable.ic_em_music)); - EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.DOCUMENT, getResources().getDrawable( - R.drawable.ic_em_document)); - EASY_MODE_ICONS.put(MimeTypeHelper.MimeTypeCategory.APP, getResources().getDrawable( - R.drawable.ic_em_application)); - - - GridView gridview = (GridView) mView.findViewById(R.id.easy_modeView); - - mEasyModeAdapter = new android.widget.ArrayAdapter<com.cyanogenmod.filemanager.util - .MimeTypeHelper.MimeTypeCategory>(getActivity(), R.layout - .navigation_view_simple_item) { - @Override - public View getView(int position, View convertView, ViewGroup parent) { - convertView = (convertView == null) ?mLayoutInflater.inflate( - R.layout - .navigation_view_simple_item, parent, false) : convertView; - MimeTypeHelper.MimeTypeCategory item = getItem(position); - String typeTitle = MIME_TYPE_LOCALIZED_NAMES[item.ordinal()]; - TextView typeTitleTV = (TextView) convertView - .findViewById(R.id.navigation_view_item_name); - ImageView typeIconIV = (ImageView) convertView - .findViewById(R.id.navigation_view_item_icon); - - typeTitleTV.setText(typeTitle); - typeIconIV.setImageDrawable(EASY_MODE_ICONS.get(item)); - convertView.setOnClickListener(mEasyModeItemClickListener); - convertView.setTag(position); - return convertView; - } - }; - mEasyModeAdapter.addAll(EASY_MODE_LIST); - gridview.setAdapter(mEasyModeAdapter); - - - - gridview.setOnItemClickListener(new OnItemClickListener() { - public void onItemClick(AdapterView<?> parent, View v, int position, long id) { - Toast.makeText(getActivity(), "" + position, Toast.LENGTH_SHORT).show(); - } - }); - } - - private void onClicked(int position) { - Intent intent = new Intent(getActivity(), SearchActivity.class); - intent.setAction(Intent.ACTION_SEARCH); - intent.putExtra(SearchActivity.EXTRA_SEARCH_DIRECTORY, FileHelper.ROOT_DIRECTORY); - intent.putExtra(SearchManager.QUERY, "*"); // Use wild-card '*' - - if (position == 0) { - FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); - - fragmentManager.beginTransaction() - .replace(R.id.navigation_fragment_container, new NavigationFragment()) - .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) - .commit(); - return; - - } else { - ArrayList<MimeTypeCategory> searchCategories = new ArrayList<MimeTypeCategory>(); - MimeTypeHelper.MimeTypeCategory selectedCategory = EASY_MODE_LIST.get(position); - searchCategories.add(selectedCategory); - // a one off case where we implicitly want to also search for TEXT mimetypes when the - // DOCUMENTS category is selected - if (selectedCategory == MimeTypeCategory.DOCUMENT) { - searchCategories.add( - MimeTypeCategory.TEXT); - } - intent.putExtra(SearchActivity.EXTRA_SEARCH_MIMETYPE, searchCategories); - } - - startActivity(intent); - } -} diff --git a/src/com/cyanogenmod/filemanager/ui/fragments/NavigationFragment.java b/src/com/cyanogenmod/filemanager/ui/fragments/NavigationFragment.java index 66cac339..12fa67fd 100644 --- a/src/com/cyanogenmod/filemanager/ui/fragments/NavigationFragment.java +++ b/src/com/cyanogenmod/filemanager/ui/fragments/NavigationFragment.java @@ -32,7 +32,13 @@ 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; @@ -46,11 +52,15 @@ import android.os.storage.StorageVolume; import android.provider.Settings; import android.support.v4.app.Fragment; import android.support.v4.content.FileProvider; +import android.support.v4.graphics.ColorUtils; import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; +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; @@ -69,6 +79,7 @@ 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; @@ -79,6 +90,7 @@ 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; @@ -95,6 +107,7 @@ 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.ui.IconHolder; import com.cyanogenmod.filemanager.ui.ThemeManager; @@ -104,6 +117,7 @@ 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.policy.CopyMoveActionPolicy; +import com.cyanogenmod.filemanager.ui.policy.InfoActionPolicy; import com.cyanogenmod.filemanager.ui.widgets.Breadcrumb; import com.cyanogenmod.filemanager.ui.widgets.ButtonItem; import com.cyanogenmod.filemanager.ui.widgets.NavigationCustomTitleView; @@ -148,7 +162,8 @@ import static com.cyanogenmod.filemanager.activities.PickerActivity.EXTRA_FOLDER */ public class NavigationFragment extends Fragment implements OnHistoryListener, OnRequestRefreshListener, - OnNavigationRequestMenuListener, OnNavigationSelectionChangedListener { + OnNavigationRequestMenuListener, OnNavigationSelectionChangedListener, + OnDirectoryChangedListener { private static final String TAG = "NavigationFragment"; //$NON-NLS-1$ @@ -211,7 +226,6 @@ public class NavigationFragment extends Fragment private Toolbar mToolBar; private SearchView mSearchView; - private NavigationCustomTitleView mCustomTitleView; private InputMethodManager mImm; private ListPopupWindow mPopupWindow; private ActionsDialog mActionsDialog; @@ -395,77 +409,6 @@ public class NavigationFragment extends Fragment } }; - private OnClickListener mOnClickDrawerTabListener = new OnClickListener() { - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.drawer_bookmarks_tab: - if (!mBookmarksTab.isSelected()) { - mBookmarksTab.setSelected(true); - mHistoryTab.setSelected(false); - mBookmarksTab.setTextAppearance( - getActivity(), R.style.primary_text_appearance); - mHistoryTab.setTextAppearance( - getActivity(), R.style.secondary_text_appearance); - mHistoryLayout.setVisibility(View.GONE); - mBookmarksLayout.setVisibility(View.VISIBLE); - applyTabTheme(); - - try { - Preferences.savePreference(FileManagerSettings.USER_PREF_LAST_DRAWER_TAB, - Integer.valueOf(0), true); - } catch (Exception ex) { - Log.e(TAG, "Can't save last drawer tab", ex); //$NON-NLS-1$ - } - - mClearHistory.setVisibility(View.GONE); - } - break; - case R.id.drawer_history_tab: - if (!mHistoryTab.isSelected()) { - mHistoryTab.setSelected(true); - mBookmarksTab.setSelected(false); - mHistoryTab.setTextAppearance( - getActivity(), R.style.primary_text_appearance); - mBookmarksTab.setTextAppearance( - getActivity(), R.style.secondary_text_appearance); - mBookmarksLayout.setVisibility(View.GONE); - mHistoryLayout.setVisibility(View.VISIBLE); - applyTabTheme(); - - try { - Preferences.savePreference(FileManagerSettings. - USER_PREF_LAST_DRAWER_TAB, Integer.valueOf(1), true); - } catch (Exception ex) { - Log.e(TAG, "Can't save last drawer tab", ex); //$NON-NLS-1$ - } - - mClearHistory.setVisibility(mHistory.size() > 0 ? View.VISIBLE : View.GONE); - } - break; - default: - break; - } - } - }; - - private OnClickListener mOnClickDrawerActionBarListener = new OnClickListener() { - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.ab_settings: - openSettings(); - break; - case R.id.ab_clear_history: - clearHistory(); - mClearHistory.setVisibility(View.GONE); - break; - default: - break; - } - } - }; - static String MIME_TYPE_LOCALIZED_NAMES[]; /** * @hide @@ -559,12 +502,11 @@ public class NavigationFragment extends Fragment actionBarActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); actionBarActivity.getSupportActionBar().setHomeButtonEnabled(true); actionBarActivity.getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu); + actionBarActivity.getSupportActionBar().setDisplayShowTitleEnabled(false); //Initialize action bars initTitleActionBar(); - initStatusActionBar(); initSelectionBar(); - initBookmarks(); initHistory(); // Apply the theme @@ -592,6 +534,8 @@ public class NavigationFragment extends Fragment } this.mOrientation = orientation; + setHasOptionsMenu(true); + return mView; } @@ -599,6 +543,59 @@ public class NavigationFragment extends Fragment * {@inheritDoc} */ @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + inflater.inflate(R.menu.navigation_menu, menu); + } + + @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; + default: + return false; + } + } + + @Override public void onResume() { super.onResume(); @@ -628,6 +625,8 @@ public class NavigationFragment extends Fragment getCurrentNavigationView().refresh(true); } + + attachNavigationViewListeners(); } /** @@ -639,6 +638,13 @@ public class NavigationFragment extends Fragment onLayoutChanged(); } + @Override + public void onPause() { + super.onPause(); + + removeNavigationViewListeners(); + } + /** * {@inheritDoc} */ @@ -712,74 +718,12 @@ public class NavigationFragment extends Fragment //Inflate the view and associate breadcrumb mTitleLayout = mLayoutInflater.inflate( R.layout.navigation_view_customtitle, null, false); - NavigationCustomTitleView title = - (NavigationCustomTitleView) mTitleLayout. - findViewById(R.id.navigation_title_flipper); - title.setOnHistoryListener(this); - Breadcrumb breadcrumb = (Breadcrumb)title.findViewById(R.id.breadcrumb_view); - int cc = this.mNavigationViews.length; - for (int i = 0; i < cc; i++) { - this.mNavigationViews[i].setBreadcrumb(breadcrumb); - this.mNavigationViews[i].setOnHistoryListener(this); - this.mNavigationViews[i].setOnNavigationSelectionChangedListener(this); - this.mNavigationViews[i].setOnNavigationOnRequestMenuListener(this); - this.mNavigationViews[i].setCustomTitle(title); - } - - // Set the free disk space warning level of the breadcrumb widget - String fds = Preferences.getSharedPreferences().getString( - FileManagerSettings.SETTINGS_DISK_USAGE_WARNING_LEVEL.getId(), - (String) FileManagerSettings.SETTINGS_DISK_USAGE_WARNING_LEVEL.getDefaultValue()); - breadcrumb.setFreeDiskSpaceWarningLevel(Integer.parseInt(fds)); //Configure the action bar options - mToolBar.setBackgroundDrawable( - getResources().getDrawable(R.drawable.bg_material_titlebar)); mToolBar.addView(mTitleLayout); } /** - * Method that initializes the statusbar of the activity. - */ - private void initStatusActionBar() { - //Performs a width calculation of buttons. Buttons exceeds the width - //of the action bar should be hidden - //This application not use android ActionBar because the application - //make uses of the title and bottom areas, and wants to force to show - //the overflow button (without care of physical buttons) - this.mActionBar = (ViewGroup) mView.findViewById(R.id.navigation_actionbar); - this.mActionBar.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { - @Override - public void onLayoutChange( - View v, int left, int top, int right, int bottom, int oldLeft, - int oldTop, int oldRight, int oldBottom) { - //Get the width of the action bar - int w = v.getMeasuredWidth(); - - //Wake through children calculation his dimensions - int bw = (int)getResources().getDimension(R.dimen.default_buttom_width); - int cw = 0; - final ViewGroup abView = ((ViewGroup)v); - int cc = abView.getChildCount(); - for (int i = 0; i < cc; i++) { - View child = abView.getChildAt(i); - child.setVisibility(cw + bw > w ? View.INVISIBLE : View.VISIBLE); - cw += bw; - } - } - }); - - // Have overflow menu? Actually no. There is only a search action, so just hide - // the overflow - View overflow = mView.findViewById(R.id.ab_overflow); - overflow.setVisibility(View.GONE); - - // Show the status bar - View statusBar = mView.findViewById(R.id.navigation_statusbar_portrait_holder); - statusBar.setVisibility(View.VISIBLE); - } - - /** * Method that initializes the selectionbar of the activity. */ private void initSelectionBar() { @@ -1513,8 +1457,28 @@ public class NavigationFragment extends Fragment //- 0 this.mNavigationViews[0] = (NavigationView) mView.findViewById(R.id.navigation_view); this.mNavigationViews[0].setId(0); + } + + /** + * Method that adds listeners for the navigation views of the activity + */ + private void attachNavigationViewListeners() { + this.mNavigationViews[0].setOnHistoryListener(this); + this.mNavigationViews[0].setOnNavigationSelectionChangedListener(this); + this.mNavigationViews[0].setOnNavigationOnRequestMenuListener(this); + this.mNavigationViews[0].setOnDirectoryChangedListener(this); this.mNavigationViews[0].setOnBackRequestListener(mOnBackRequestListener); - this.mNavigationViews[0].setOnDirectoryChangedListener(mOnDirectoryChangedListener); + } + + /** + * Method that removes listeners for the navigation views of the activity + */ + private void removeNavigationViewListeners() { + this.mNavigationViews[0].setOnHistoryListener(null); + this.mNavigationViews[0].setOnNavigationSelectionChangedListener(null); + this.mNavigationViews[0].setOnNavigationOnRequestMenuListener(null); + this.mNavigationViews[0].setOnDirectoryChangedListener(null); + this.mNavigationViews[0].setOnBackRequestListener(null); } /** @@ -1840,7 +1804,7 @@ public class NavigationFragment extends Fragment this.getCurrentNavigationView().removeItem((FileSystemObject)o); //Remove from history - removeFromHistory((FileSystemObject)o); + removeFromHistory((FileSystemObject) o); } else { onRequestRefresh(null, clearSelection); } @@ -1923,8 +1887,6 @@ public class NavigationFragment extends Fragment } }); - } finally { - getCurrentNavigationView().getCustomTitle().restoreView(); } } @@ -2182,49 +2144,32 @@ public class NavigationFragment extends Fragment return false; } - public void openActionsDialog(String path, boolean global) { - FileSystemObject fso = null; - try { - fso = CommandHelper.getFileInfo(getActivity(), path, false, null); - if (fso == null) { - throw new NoSuchFileOrDirectory(path); - } - openActionsDialog(fso, global); - } catch (Exception e) { - // Notify the user - ExceptionUtil.translateException(getActivity(), e); - - // Remove the object - if (e instanceof FileNotFoundException || e instanceof NoSuchFileOrDirectory) { - // If have a FileSystemObject reference then there is no need to search - // the path (less resources used) - getCurrentNavigationView().removeItem(path); - } - return; - } - } - /** * Method that opens the actions dialog * - * @param item The path or the {@link FileSystemObject} + * @param fso The {@link FileSystemObject} * @param global If the menu to display is the one with global actions */ - private void openActionsDialog(FileSystemObject item, boolean global) { - // We used to refresh the item reference here, but the access to the SecureConsole is synchronized, - // which can/will cause on ANR in certain scenarios. We don't care if it doesn't exist anymore really - // For this to work, SecureConsole NEEDS to be refactored. + public void openActionsDialog(FileSystemObject fso, final boolean global) { + if (fso == null) { + fso = getCurrentNavigationView().getCurrentFso(); + } // Show the dialog - if (mActionsDialog != null && mActionsDialog.isShowing()) { - return; - } - mActionsDialog = new ActionsDialog(getActivity(), this, item, global, false); + mActionsDialog = new ActionsDialog(getActivity(), this, fso, global, false); mActionsDialog.setOnRequestRefreshListener(this); mActionsDialog.setOnSelectionListener(getCurrentNavigationView()); mActionsDialog.show(); } + public void toggleSearch() { + if (mSearchView.getVisibility() == View.VISIBLE) { + closeSearch(); + } else { + openSearch(); + } + } + /** * Method that opens the search view. * @@ -2233,13 +2178,15 @@ public class NavigationFragment extends Fragment public void openSearch() { mSearchView.setVisibility(View.VISIBLE); mSearchView.onActionViewExpanded(); - mCustomTitleView.setVisibility(View.GONE); + mTitleLayout.findViewById(R.id.navigation_title_landscape_holder) + .setVisibility(View.GONE); } void closeSearch() { mSearchView.setVisibility(View.GONE); mSearchView.onActionViewCollapsed(); - mCustomTitleView.setVisibility(View.VISIBLE); + mTitleLayout.findViewById(R.id.navigation_title_landscape_holder) + .setVisibility(View.VISIBLE); } /** @@ -2396,65 +2343,6 @@ public class NavigationFragment extends Fragment int orientation = getResources().getConfiguration().orientation; if (this.mOrientation == orientation) return; this.mOrientation = orientation; - - // Portrait mode - if (mStatusBar != null) { - if (mStatusBar.getParent() != null) { - ViewGroup parent = (ViewGroup) mStatusBar.getParent(); - parent.removeView(mStatusBar); - } - if (this.mOrientation == Configuration.ORIENTATION_LANDSCAPE) { - // Calculate the action button size (all the buttons must fit in the title bar) - int bw = (int)getResources().getDimension(R.dimen.default_buttom_width); - int abw = this.mActionBar.getChildCount() * bw; - int rbw = 0; - int cc = ((ViewGroup) mStatusBar).getChildCount(); - for (int i = 0; i < cc; i++) { - View child = ((ViewGroup) mStatusBar).getChildAt(i); - if (child instanceof ButtonItem) { - rbw += bw; - } - } - // Currently there isn't overflow menu - int w = abw + rbw - bw; - - // Add to the new location - ViewGroup newParent = (ViewGroup)mTitleLayout.findViewById( - R.id.navigation_title_landscape_holder); - LinearLayout.LayoutParams params = - new LinearLayout.LayoutParams( - w, - ViewGroup.LayoutParams.MATCH_PARENT); - mStatusBar.setLayoutParams(params); - newParent.addView(mStatusBar); - - // Apply theme - mStatusBar.setBackgroundResource(R.drawable.titlebar_drawable); - - // Hide holder - View holder = mView.findViewById( - R.id.navigation_statusbar_portrait_holder); - holder.setVisibility(View.GONE); - - } else { - // Add to the new location - ViewGroup newParent = (ViewGroup) mView.findViewById( - R.id.navigation_statusbar_portrait_holder); - LinearLayout.LayoutParams params = - new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - mStatusBar.setLayoutParams(params); - newParent.addView(mStatusBar); - - // Apply theme - mStatusBar.setBackgroundResource(R.drawable.statusbar_drawable); - - // Show holder - newParent.setVisibility(View.VISIBLE); - } - } - } /** @@ -2527,41 +2415,8 @@ public class NavigationFragment extends Fragment .getComponentName())); mSearchView.setIconifiedByDefault(false); - mCustomTitleView = (NavigationCustomTitleView) mTitleLayout.findViewById( - R.id.navigation_title_flipper); - mCustomTitleView.setVisibility(View.VISIBLE); - - //- StatusBar - mStatusBar = mView.findViewById(R.id.navigation_statusbar); - if (orientation == Configuration.ORIENTATION_LANDSCAPE) { - mStatusBar.setBackgroundResource(R.drawable.titlebar_drawable); - } else { - mStatusBar.setBackgroundResource(R.drawable.statusbar_drawable); - } - View v = mView.findViewById(R.id.ab_overflow); - theme.setImageDrawable(getActivity(), (ImageView)v, "ab_overflow_drawable"); //$NON-NLS-1$ - v = mView.findViewById(R.id.ab_actions); - theme.setImageDrawable(getActivity(), (ImageView)v, "ab_actions_drawable"); //$NON-NLS-1$ - v = mView.findViewById(R.id.ab_search); - theme.setImageDrawable(getActivity(), (ImageView)v, "ab_search_drawable"); //$NON-NLS-1$ - - //- Expanders - v = mTitleLayout.findViewById(R.id.ab_configuration); - theme.setImageDrawable(getActivity(), (ImageView)v, "expander_open_drawable"); //$NON-NLS-1$ - v = mTitleLayout.findViewById(R.id.ab_close); - theme.setImageDrawable(getActivity(), - (ImageView)v, "expander_close_drawable"); //$NON-NLS-1$ - v = mTitleLayout.findViewById(R.id.ab_sort_mode); - theme.setImageDrawable(getActivity(), (ImageView)v, "ab_sort_mode_drawable"); //$NON-NLS-1$ - v = mTitleLayout.findViewById(R.id.ab_layout_mode); - theme.setImageDrawable(getActivity(), - (ImageView)v, "ab_layout_mode_drawable"); //$NON-NLS-1$ - v = mTitleLayout.findViewById(R.id.ab_view_options); - theme.setImageDrawable(getActivity(), - (ImageView)v, "ab_view_options_drawable"); //$NON-NLS-1$ - //- SelectionBar - v = mView.findViewById(R.id.navigation_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(), @@ -2640,9 +2495,25 @@ public class NavigationFragment extends Fragment public void setOnDirectoryChangedListener( OnDirectoryChangedListener onDirectoryChangedListener) { mOnDirectoryChangedListener = onDirectoryChangedListener; - NavigationView current = getCurrentNavigationView(); - if (current != null) { - current.setOnDirectoryChangedListener(mOnDirectoryChangedListener); + } + + + @Override + public void onDirectoryChanged(FileSystemObject item) { + MainActivity mainActivity = (MainActivity) getActivity(); + TextView title = (TextView) mTitleLayout.findViewById(R.id.drawer_title); + title.setText(item.getName()); + + int foregroundColor = getResources().getColor(R.color.status_bar_foreground_color); + int backgroundColor = mainActivity.getColorForPath( + getCurrentNavigationView().getCurrentDir()); + int statusBarColor = ColorUtils.compositeColors(foregroundColor, backgroundColor); + mainActivity.getWindow().setStatusBarColor(statusBarColor); + + mToolBar.setBackgroundColor(backgroundColor); + + if (mOnDirectoryChangedListener != null) { + mOnDirectoryChangedListener.onDirectoryChanged(item); } } } diff --git a/src/com/cyanogenmod/filemanager/ui/policy/CompressActionPolicy.java b/src/com/cyanogenmod/filemanager/ui/policy/CompressActionPolicy.java index 01569776..d7b47452 100644 --- a/src/com/cyanogenmod/filemanager/ui/policy/CompressActionPolicy.java +++ b/src/com/cyanogenmod/filemanager/ui/policy/CompressActionPolicy.java @@ -307,7 +307,7 @@ public final class CompressActionPolicy extends ActionsPolicy { String newName = FileHelper.createNonExistingName( ctx, - onSelectionListener.onRequestCurrentDir(), + onSelectionListener.onRequestCurrentItems(), name, R.string.create_new_compress_file_regexp); String newNameAbs = diff --git a/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java b/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java index 6c1945ad..c6e8e0e0 100755 --- a/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java +++ b/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java @@ -139,10 +139,10 @@ public final class CopyMoveActionPolicy extends ActionsPolicy { final OnSelectionListener onSelectionListener, final OnRequestRefreshListener onRequestRefreshListener) { // Create a non-existing name - String curDir = onSelectionListener.onRequestCurrentDir(); + List<FileSystemObject> curFiles = onSelectionListener.onRequestCurrentItems(); String newName = FileHelper.createNonExistingName( - ctx, curDir, fso.getName(), R.string.create_copy_regexp); + ctx, curFiles, fso.getName(), R.string.create_copy_regexp); final String destination = fso.getParent(); List<LinkedResource> files = createLinkedResource(fso, newName); diff --git a/src/com/cyanogenmod/filemanager/ui/widgets/NavigationCustomTitleView.java b/src/com/cyanogenmod/filemanager/ui/widgets/NavigationCustomTitleView.java index 90dde597..86fd9dc3 100644 --- a/src/com/cyanogenmod/filemanager/ui/widgets/NavigationCustomTitleView.java +++ b/src/com/cyanogenmod/filemanager/ui/widgets/NavigationCustomTitleView.java @@ -63,9 +63,7 @@ public class NavigationCustomTitleView extends ViewFlipper { * in the breadcrumb view. */ public void restoreView() { - if (getCurrentView().getId() != R.id.tb_breadcrumb) { - hideConfigurationView(); - } + hideConfigurationView(); } /** @@ -99,7 +97,7 @@ public class NavigationCustomTitleView extends ViewFlipper { * @return boolean If the breadcrumb view is visible */ public boolean isConfigurationViewShowing() { - return getCurrentView().getId() != R.id.tb_breadcrumb; + return Boolean.TRUE; } } diff --git a/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java b/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java index 7afbb206..9963376d 100644 --- a/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java +++ b/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java @@ -459,6 +459,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe private int mId; private String mCurrentDir; private String mPreviousDir; + private FileSystemObject mCurrentFileSystemObject; private NavigationLayoutMode mCurrentMode; /** * @hide @@ -555,6 +556,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe NavigationViewInfoParcelable parcel = new NavigationViewInfoParcelable(); parcel.setId(this.mId); parcel.setCurrentDir(this.mPreviousDir); + parcel.setCurrentFso(this.mCurrentFileSystemObject); parcel.setChRooted(this.mChRooted); parcel.setSelectedFiles(this.mAdapter.getSelectedItems()); parcel.setFiles(this.mFiles); @@ -579,6 +581,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe //Restore the data this.mId = info.getId(); this.mCurrentDir = info.getCurrentDir(); + this.mCurrentFileSystemObject = info.getCurrentFso(); this.mChRooted = info.getChRooted(); this.mFiles = info.getFiles(); this.mAdapter.setSelectedItems(info.getSelectedFiles()); @@ -1063,6 +1066,15 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe } /** + * Method that returns the current directory's {@link FileSystemObject} + * + * @return String The current directory + */ + public FileSystemObject getCurrentFso() { + return this.mCurrentFileSystemObject; + } + + /** * Method that changes the current directory of the view. * * @param newDir The new directory location @@ -1214,6 +1226,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe 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)); diff --git a/src/com/cyanogenmod/filemanager/util/FileHelper.java b/src/com/cyanogenmod/filemanager/util/FileHelper.java index 926c85a6..a2b2fb31 100644 --- a/src/com/cyanogenmod/filemanager/util/FileHelper.java +++ b/src/com/cyanogenmod/filemanager/util/FileHelper.java @@ -27,16 +27,11 @@ import com.cyanogenmod.filemanager.FileManagerApplication; import com.cyanogenmod.filemanager.R; import com.cyanogenmod.filemanager.commands.SyncResultExecutable; import com.cyanogenmod.filemanager.commands.java.Program; -import com.cyanogenmod.filemanager.commands.shell.InvalidCommandDefinitionException; import com.cyanogenmod.filemanager.commands.shell.ResolveLinkCommand; import com.cyanogenmod.filemanager.console.CancelledOperationException; -import com.cyanogenmod.filemanager.console.CommandNotFoundException; import com.cyanogenmod.filemanager.console.Console; -import com.cyanogenmod.filemanager.console.ConsoleAllocException; import com.cyanogenmod.filemanager.console.ExecutionException; import com.cyanogenmod.filemanager.console.InsufficientPermissionsException; -import com.cyanogenmod.filemanager.console.NoSuchFileOrDirectory; -import com.cyanogenmod.filemanager.console.OperationTimeoutException; import com.cyanogenmod.filemanager.console.java.JavaConsole; import com.cyanogenmod.filemanager.model.AID; import com.cyanogenmod.filemanager.model.BlockDevice; @@ -64,7 +59,6 @@ import com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.ClosedByInterruptException; @@ -947,17 +941,17 @@ public final class FileHelper { * that is not current used by the filesystem. * * @param ctx The current context - * @param parentDir The directory in which we want to make the file + * @param files The list of files of the current directory * @param attemptedName The attempted name * @param regexp The resource of the regular expression to create the new name * @return String The new non-existing name */ public static String createNonExistingName( - final Context ctx, final String parentDir, + final Context ctx, final List<FileSystemObject> files, final String attemptedName, int regexp) { // Find a non-exiting name String newName = attemptedName; - if (!isNameExists(ctx, parentDir, newName)) return newName; + if (!isNameExists(files, newName)) return newName; do { String name = FileHelper.getName(newName); String ext = FileHelper.getExtension(newName); @@ -967,30 +961,27 @@ public final class FileHelper { ext = "." + ext; //$NON-NLS-1$ } newName = ctx.getString(regexp, name, ext); - } while (isNameExists(ctx, parentDir, newName)); + } while (isNameExists(files, newName)); return newName; } /** * Method that checks if a name exists in the current directory. * - * @param context The application context - * @param parentDir The full path to the parent directory + * @param files The list of files of the current directory * @param name The name to check * @return boolean Indicate if the name exists in the current directory */ - public static boolean isNameExists(Context context, String parentDir, String name) { - if (parentDir == null || parentDir.equals(ROOT_DIRECTORY)) { - parentDir = ""; - } + public static boolean isNameExists(List<FileSystemObject> files, String name) { //Verify if the name exists in the current file list - try { - return CommandHelper.getFileInfo(context, parentDir + "/" + name, null) != null; - } catch (Exception e) { - // This is a slight misreporting, however, I don't want to do a bunch of refactoring - Log.i(TAG, "Failed to get file info: " + e.getMessage()); - return false; + int cc = files.size(); + for (int i = 0; i < cc; i++) { + FileSystemObject fso = files.get(i); + if (fso.getName().compareTo(name) == 0) { + return true; + } } + return false; } /** |