aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Bird <sbird@cyngn.com>2015-06-12 12:36:16 -0700
committerSteve Kondik <steve@cyngn.com>2016-11-02 17:28:25 -0700
commit7cf7a731ef8a51d68e3cd0ac2d8c7ce569fe333f (patch)
tree76d196bc73908a21cd1edf4fde55f418db2619df
parent8f5038d00ee997d35e134752b271cca0d399c5bb (diff)
downloadandroid_packages_apps_CMFileManager-7cf7a731ef8a51d68e3cd0ac2d8c7ce569fe333f.tar.gz
android_packages_apps_CMFileManager-7cf7a731ef8a51d68e3cd0ac2d8c7ce569fe333f.tar.bz2
android_packages_apps_CMFileManager-7cf7a731ef8a51d68e3cd0ac2d8c7ce569fe333f.zip
Navigation & homepage
Move from single view to fragments. Add homepage. The base homepage is basically a list/scroll view with a search box at the top. Below will be search quick links and other fast link items. Change-Id: Ifd5fe9f1859837e1a76e250c42312c35e637657f
-rw-r--r--Android.mk25
-rw-r--r--AndroidManifest.xml9
-rw-r--r--proguard.flags4
-rw-r--r--res/layout/home_fragment.xml133
-rw-r--r--res/layout/nav_fragment.xml78
-rw-r--r--res/layout/navigation.xml73
-rw-r--r--res/layout/navigation_drawer.xml262
-rw-r--r--res/layout/navigation_view_customtitle.xml57
-rw-r--r--res/menu/navigation.xml44
-rw-r--r--res/values/attrs.xml2
-rw-r--r--res/values/strings.xml4
-rw-r--r--res/values/styles.xml21
-rw-r--r--res/xml/searchable.xml1
-rwxr-xr-xsrc/com/cyanogenmod/filemanager/activities/MainActivity.java394
-rwxr-xr-xsrc/com/cyanogenmod/filemanager/activities/SearchActivity.java10
-rw-r--r--src/com/cyanogenmod/filemanager/activities/ShortcutActivity.java4
-rw-r--r--src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java17
-rw-r--r--src/com/cyanogenmod/filemanager/ui/fragments/HomeFragment.java222
-rw-r--r--[-rwxr-xr-x]src/com/cyanogenmod/filemanager/ui/fragments/NavigationFragment.java (renamed from src/com/cyanogenmod/filemanager/activities/NavigationActivity.java)1182
-rw-r--r--src/com/cyanogenmod/filemanager/ui/widgets/ScrimInsetsFrameLayout.java2
-rw-r--r--src/com/cyanogenmod/filemanager/ui/widgets/WrappedGridView.java38
-rw-r--r--src/com/cyanogenmod/filemanager/util/DialogHelper.java6
22 files changed, 1455 insertions, 1133 deletions
diff --git a/Android.mk b/Android.mk
index 3ffaf4f5..f7e8c0ab 100644
--- a/Android.mk
+++ b/Android.mk
@@ -17,33 +17,42 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \
+ frameworks/support/design/res \
+ frameworks/support/v7/appcompat/res \
+ frameworks/support/v7/cardview/res \
+ external/uicommon/res
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SRC_FILES += $(call all-java-files-under, libs/android-syntax-highlight/src)
LOCAL_SRC_FILES += $(call all-java-files-under, libs/color-picker-view/src)
-uicommon_dir := ../../../external/uicommon
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \
- $(LOCAL_PATH)/$(uicommon_dir)/res
-
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages com.cyngn.uicommon
+LOCAL_AAPT_FLAGS += --extra-packages android.support.design:android.support.v7.appcompat:android.support.v7.cardview
+
LOCAL_STATIC_JAVA_LIBRARIES += libtruezip
-LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
LOCAL_STATIC_JAVA_LIBRARIES += juniversalchardet
LOCAL_STATIC_JAVA_LIBRARIES += uicommon
+LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
+LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat
+LOCAL_STATIC_JAVA_LIBRARIES += android-support-design
+LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-cardview
LOCAL_PACKAGE_NAME := CMFileManager
LOCAL_CERTIFICATE := platform
-LOCAL_PROGUARD_FLAG_FILES := proguard.flags
+#LOCAL_PROGUARD_FLAG_FILES := proguard.flags
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_AAPT_FLAGS := --auto-add-overlay
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
- juniversalchardet:libs/juniversalchardet/juniversalchardet-1.0.3.jar
+ juniversalchardet:libs/juniversalchardet/juniversalchardet-1.0.3.jar
include $(BUILD_MULTI_PREBUILT)
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 46602187..ec978a55 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -49,7 +49,7 @@
android:banner="@drawable/banner"
android:label="@string/app_name"
android:largeHeap="true"
- android:theme="@style/FileManager.Theme.Material.Light"
+ android:theme="@style/Base.AppTheme"
android:supportsRtl="true">
<meta-data
@@ -95,11 +95,10 @@
</service>
<activity
- android:name=".activities.NavigationActivity"
+ android:name=".activities.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:uiOptions="none"
- android:theme="@style/FileManager.Theme.Material.Light.NoActionBar"
android:windowSoftInputMode="adjustNothing"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true">
@@ -143,7 +142,6 @@
android:label="@string/picker"
android:uiOptions="none"
android:configChanges="orientation|keyboardHidden|screenSize"
- android:theme="@style/FileManager.Theme.Material.Light.Overlay"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
@@ -178,7 +176,6 @@
android:name=".activities.ShortcutActivity"
android:label="@string/app_name"
android:uiOptions="none"
- android:theme="@style/FileManager.Theme.Material.Light.Overlay"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
@@ -189,7 +186,6 @@
android:name=".activities.ChangeLogActivity"
android:label="@string/app_name"
android:uiOptions="none"
- android:theme="@style/FileManager.Theme.Material.Light.Overlay"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
@@ -232,7 +228,6 @@
android:label="@string/app_name"
android:uiOptions="none"
android:configChanges="orientation|keyboardHidden|screenSize"
- android:theme="@android:style/Theme.Material.Light.Dialog"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
diff --git a/proguard.flags b/proguard.flags
index 4714ce48..e151f2c2 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -13,6 +13,10 @@
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
+-keep class android.support.design.widget.** { *; }
+-keep interface android.support.design.widget.** { *; }
+-dontwarn android.support.design.**
+
#keep all classes that might be used in XML layouts
-keep public class * extends android.view.View {
public <init>(android.content.Context);
diff --git a/res/layout/home_fragment.xml b/res/layout/home_fragment.xml
new file mode 100644
index 00000000..7a2fcbc9
--- /dev/null
+++ b/res/layout/home_fragment.xml
@@ -0,0 +1,133 @@
+<?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.
+-->
+<android.support.design.widget.CoordinatorLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:card_view="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/main_content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <android.support.v4.widget.NestedScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <!-- A CardView that contains a TextView -->
+ <android.support.v7.widget.CardView
+ android:id="@+id/card_view"
+ android:layout_gravity="center"
+ android:layout_width="match_parent"
+ android:layout_height="400dp"
+ card_view:cardCornerRadius="4dp">
+
+ <TextView
+ android:id="@+id/info_text"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ </android.support.v7.widget.CardView>
+
+ <com.cyanogenmod.filemanager.ui.widgets.WrappedGridView
+ android:id="@+id/easy_modeView"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:columnWidth="90dp"
+ android:numColumns="auto_fit"
+ android:verticalSpacing="10dp"
+ android:horizontalSpacing="10dp"
+ android:stretchMode="columnWidth"
+ android:gravity="center" />
+
+ <!-- A CardView that contains a TextView -->
+ <android.support.v7.widget.CardView
+ android:id="@+id/card_view3"
+ android:layout_gravity="center"
+ android:layout_width="200dp"
+ android:layout_height="200dp"
+ card_view:cardCornerRadius="4dp">
+
+ <TextView
+ android:id="@+id/info_text2"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ </android.support.v7.widget.CardView>
+
+ </LinearLayout>
+
+ </android.support.v4.widget.NestedScrollView>
+
+ <android.support.design.widget.AppBarLayout
+ android:id="@+id/appbar"
+ android:layout_width="match_parent"
+ android:layout_height="300dp"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+ <android.support.design.widget.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_scrollFlags="scroll|exitUntilCollapsed">
+
+ <android.support.v7.widget.CardView
+ android:id="@+id/card_view2"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ card_view:cardCornerRadius="4dp"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
+ android:layout_gravity="bottom"
+ android:layout_alignParentBottom="true"
+ android:layout_marginBottom="4dp">
+
+ <android.support.v7.widget.SearchView
+ android:id="@+id/homepage_searchbar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_collapseMode="parallax"
+ android:background="@color/console_fg"
+ android:layout_alignParentBottom="true" />
+
+ </android.support.v7.widget.CardView>
+
+ <ImageView
+ android:id="@+id/backdrop"
+ android:src="@drawable/bg_header"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop"
+ android:fitsSystemWindows="true"
+ app:layout_collapseMode="pin" />
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/material_toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
+
+ </android.support.design.widget.CollapsingToolbarLayout>
+
+ </android.support.design.widget.AppBarLayout>
+
+</android.support.design.widget.CoordinatorLayout>
diff --git a/res/layout/nav_fragment.xml b/res/layout/nav_fragment.xml
new file mode 100644
index 00000000..f6dbc733
--- /dev/null
+++ b/res/layout/nav_fragment.xml
@@ -0,0 +1,78 @@
+<?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"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:filemanager="http://schemas.android.com/apk/res/com.cyanogenmod.filemanager"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/material_toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ android:background="?attr/colorPrimary"
+ app:layout_collapseMode="pin" />
+
+ <com.cyanogenmod.filemanager.ui.widgets.ScrimInsetsFrameLayout
+ 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 -->
+ <LinearLayout
+ android:id="@+id/navigation_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <!-- 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"/>
+
+ <!-- StatusBar -->
+ <include layout="@layout/navigation_view_statusbar"/>
+
+ </LinearLayout>
+
+ </com.cyanogenmod.filemanager.ui.widgets.ScrimInsetsFrameLayout>
+
+</LinearLayout>
diff --git a/res/layout/navigation.xml b/res/layout/navigation.xml
index 49d7c7b4..f46aee4e 100644
--- a/res/layout/navigation.xml
+++ b/res/layout/navigation.xml
@@ -15,67 +15,24 @@
limitations under the License.
-->
-<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:filemanager="http://schemas.android.com/apk/res/com.cyanogenmod.filemanager"
+<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">
- <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/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 -->
- <LinearLayout
- android:id="@+id/navigation_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <!-- We use a Toolbar so that our drawer can be displayed in front of the action bar -->
- <android.widget.Toolbar
- android:id="@+id/material_toolbar"
- android:fitsSystemWindows="true"
- android:layout_height="?android:attr/actionBarSize"
- android:layout_width="match_parent"
- android:minHeight="?android:attr/actionBarSize"
- android:background="?android:attr/colorPrimary"
- android:theme="@style/FileManager.NavigationActionBar"/>
-
- <!-- 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"/>
-
- <!-- StatusBar -->
- <include layout="@layout/navigation_view_statusbar"/>
- </LinearLayout>
- </com.cyanogenmod.filemanager.ui.widgets.ScrimInsetsFrameLayout>
-
- <!-- The navigation drawer -->
- <include layout="@layout/navigation_drawer" />
+ <FrameLayout
+ android:id="@+id/navigation_fragment_container"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1" />
+
+ <android.support.design.widget.NavigationView
+ android:id="@+id/navigation_view"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_gravity="start"
+ app:menu="@menu/navigation" />
</android.support.v4.widget.DrawerLayout>
diff --git a/res/layout/navigation_drawer.xml b/res/layout/navigation_drawer.xml
index db67648a..39082f5c 100644
--- a/res/layout/navigation_drawer.xml
+++ b/res/layout/navigation_drawer.xml
@@ -1,189 +1,195 @@
<?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">
+ 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">
+ 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">
+ 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">
+ 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_alignParentStart="true"
- android:contentDescription="@string/menu_settings"
- android:onClick="onActionBarItemClick"
- android:src="@drawable/ic_material_light_settings"/>
+ 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"/>
+ 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">
+ 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">
+ 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">
+ 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/bg_header"
- android:src="@drawable/header_gradient"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scaleType="centerCrop"/>
+ android:id="@+id/header"
+ android:background="@drawable/bg_header"
+ 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"/>
+ 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">
+ 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"/>
+ 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"/>
+ 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"/>
+ 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">
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
<include
- android:id="@+id/drawer_tab_divider2"
- layout="@layout/vertical_divider"/>
+ 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">
+ 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"/>
+ 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">
+ 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">
+ 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"/>
+ 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">
+ 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>
diff --git a/res/layout/navigation_view_customtitle.xml b/res/layout/navigation_view_customtitle.xml
index 72f2ac1e..379072c5 100644
--- a/res/layout/navigation_view_customtitle.xml
+++ b/res/layout/navigation_view_customtitle.xml
@@ -15,35 +15,36 @@
-->
<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="horizontal">
-
- <com.cyanogenmod.filemanager.ui.widgets.NavigationCustomTitleView
- android:id="@+id/navigation_title_flipper"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- 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" />
-
- <SearchView
- android:id="@+id/navigation_search_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:visibility="gone" />
+ 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"/>
+
+ <SearchView
+ android:id="@+id/navigation_search_bar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone" />
</LinearLayout>
diff --git a/res/menu/navigation.xml b/res/menu/navigation.xml
index e63074ba..97bf5318 100644
--- a/res/menu/navigation.xml
+++ b/res/menu/navigation.xml
@@ -14,12 +14,40 @@
** See the License for the specific language governing permissions and
** limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
-
- <!-- Actions -->
- <item
- android:id="@+id/mnu_search"
- android:showAsAction="ifRoom"
- android:title="@string/menu_search"/>
-
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:context=".MainActivity">
+ <group android:checkableBehavior="single">
+ <item
+ android:id="@+id/navigation_item_1"
+ android:checked="true"
+ android:icon="@drawable/ic_launcher_themes"
+ android:title="HEY!" />
+ <item
+ android:id="@+id/navigation_item_2"
+ android:icon="@drawable/ic_launcher_themes"
+ android:title="WOW" />
+ </group>
+ <group android:checkableBehavior="single">
+ <item
+ android:id="@+id/navigation_item_1"
+ android:checked="true"
+ android:icon="@drawable/ic_launcher_themes"
+ android:title="HEY!" />
+ <item
+ android:id="@+id/navigation_item_2"
+ android:icon="@drawable/ic_launcher_themes"
+ android:title="WOW" />
+ </group>
+ <group android:checkableBehavior="single">
+ <item
+ android:id="@+id/navigation_item_1"
+ android:checked="true"
+ android:icon="@drawable/ic_launcher_themes"
+ android:title="HEY!" />
+ <item
+ android:id="@+id/navigation_item_2"
+ android:icon="@drawable/ic_launcher_themes"
+ android:title="WOW" />
+ </group>
</menu> \ No newline at end of file
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 178970af..be5a19b5 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -44,6 +44,6 @@
</declare-styleable>
<declare-styleable name="ScrimInsetsView">
- <attr name="insetForeground" format="reference|color" />
+ <attr name="scrimInsetForeground" format="reference|color" />
</declare-styleable>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6dff6ea1..d6ced817 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -18,6 +18,8 @@
<!-- The name of the app -->
<string name="app_name">File Manager</string>
<!-- The description of the app -->
+ <string name="homepage_statement">This is the Homepage</string>
+
<string name="app_description">A CyanogenMod file manager</string>
<!-- Human readable sizes -->
@@ -315,7 +317,7 @@
<!-- Search - Search activity title -->
<string name="search">Search results</string>
<!-- Search - Search hint message -->
- <string name="search_hint">Type your search</string>
+ <string name="search_hint">Search local files</string>
<!-- Search - Voice search hint message -->
<string name="search_voice_hint">Speak your search</string>
<!-- Search - Search error message -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index cd6f8cc3..78d854a2 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -18,6 +18,27 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2" xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 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:colorAccent">@color/material_palette_blue_primary</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:windowActionBar">false</item>
+ <item name="windowActionBar">false</item>
+ <item name="windowNoTitle">true</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>
+ </style>
+
+ <style name="ThemeOverlay.FileManager.ActionBar" parent="ThemeOverlay.AppCompat.ActionBar">
+ <item name="android:textColorPrimary">@color/console_fg</item>
+ </style>
+
+ <!-- Pre-Google Support Themes -->
+ <!-- Base themes -->
<style name="FileManager.Theme.Material.Light.NoActionBar" parent="@android:style/Theme.Material.Light.NoActionBar">
<item name="android:windowBackground">@color/default_background</item>
<item name="android:windowActionBar">false</item>
diff --git a/res/xml/searchable.xml b/res/xml/searchable.xml
index f5e1d8ee..3480caab 100644
--- a/res/xml/searchable.xml
+++ b/res/xml/searchable.xml
@@ -14,7 +14,6 @@
limitations under the License.
-->
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
- android:icon="@null"
android:imeOptions="actionSearch"
android:includeInGlobalSearch="false"
android:label="@string/search"
diff --git a/src/com/cyanogenmod/filemanager/activities/MainActivity.java b/src/com/cyanogenmod/filemanager/activities/MainActivity.java
new file mode 100755
index 00000000..7f60d98d
--- /dev/null
+++ b/src/com/cyanogenmod/filemanager/activities/MainActivity.java
@@ -0,0 +1,394 @@
+/*
+ * 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.
+ */
+
+package com.cyanogenmod.filemanager.activities;
+
+import android.Manifest;
+import android.app.Activity;
+import android.app.Dialog;
+import android.app.FragmentTransaction;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.net.Uri;
+import android.nfc.NfcAdapter;
+import android.os.Bundle;
+import android.provider.Settings;
+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.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+
+import com.cyanogenmod.filemanager.R;
+import com.cyanogenmod.filemanager.model.Bookmark;
+import com.cyanogenmod.filemanager.model.FileSystemObject;
+import com.cyanogenmod.filemanager.preferences.FileManagerSettings;
+import com.cyanogenmod.filemanager.ui.ThemeManager;
+import com.cyanogenmod.filemanager.ui.fragments.HomeFragment;
+import com.cyanogenmod.filemanager.ui.fragments.NavigationFragment;
+import com.cyanogenmod.filemanager.util.FileHelper;
+import com.cyngn.uicommon.view.Snackbar;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The main navigation activity. This activity is the center of the application.
+ * From this the user can navigate, search, make actions.<br/>
+ * This activity is singleTop, so when it is displayed no other activities exists in
+ * the stack.<br/>
+ * This cause an issue with the saved instance of this class, because if another activity
+ * is displayed, and the process is killed, MainActivity is started and the saved
+ * instance gets corrupted.<br/>
+ * For this reason the methods {link {@link Activity#onSaveInstanceState(Bundle)} and
+ * {@link Activity#onRestoreInstanceState(Bundle)} are not implemented, and every time
+ * the app is killed, is restarted from his initial state.
+ */
+public class MainActivity extends ActionBarActivity {
+
+ private static final String TAG = MainActivity.class.getSimpleName();
+
+ 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$
+
+ /**
+ * Constant for extra information about selected search entry.
+ */
+ public static final String EXTRA_SEARCH_ENTRY_SELECTION =
+ "extra_search_entry_selection"; //$NON-NLS-1$
+
+ /**
+ * Constant for extra information about last search data.
+ */
+ public static final String EXTRA_SEARCH_LAST_SEARCH_DATA =
+ "extra_search_last_search_data"; //$NON-NLS-1$
+
+ /**
+ * Constant for extra information for request a navigation to the passed path.
+ */
+ public static final String EXTRA_NAVIGATE_TO =
+ "extra_navigate_to"; //$NON-NLS-1$
+
+ /**
+ * Constant for extra information for request to add navigation to the history
+ */
+ public static final String EXTRA_ADD_TO_HISTORY =
+ "extra_add_to_history"; //$NON-NLS-1$
+
+ /**
+ * Fragment types
+ */
+ private enum FragmentType {
+ // Home fragment
+ HOME,
+
+ // Navigation fragment
+ NAVIGATION,
+ }
+
+ static String MIME_TYPE_LOCALIZED_NAMES[];
+
+ public HomeFragment mHomeFragment;
+ public Toolbar mToolbar;
+ Fragment currentFragment;
+
+ private static final int REQUEST_CODE_STORAGE_PERMS = 321;
+ private boolean hasPermissions() {
+ int res = checkCallingOrSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
+ return (res == PackageManager.PERMISSION_GRANTED);
+ }
+
+ private void requestNecessaryPermissions() {
+ String[] permissions = new String[] {
+ Manifest.permission.WRITE_EXTERNAL_STORAGE,
+ };
+ requestPermissions(permissions, REQUEST_CODE_STORAGE_PERMS);
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String[] permissions,
+ int[] grandResults) {
+ boolean allowed = true;
+ switch (requestCode) {
+ case REQUEST_CODE_STORAGE_PERMS:
+ for (int res : grandResults) {
+ allowed = allowed && (res == PackageManager.PERMISSION_GRANTED);
+ }
+ break;
+ default:
+ allowed = false;
+ break;
+ }
+ if (allowed) {
+ finishOnCreate();
+
+ } else {
+ if (shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
+ String text = getResources().getString(R.string.storage_permissions_denied);
+ final ViewGroup viewGroup = (ViewGroup) ((ViewGroup) this
+ .findViewById(android.R.id.content)).getChildAt(0);
+ if (viewGroup != null) {
+ Snackbar snackbar = Snackbar.make(viewGroup, text,
+ Snackbar.LENGTH_INDEFINITE, 3);
+ snackbar.setAction(android.R.string.ok, new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ requestNecessaryPermissions();
+ }
+ });
+ snackbar.show();
+ }
+ } else {
+ StringBuilder builder = new StringBuilder(getString(R.string
+ .storage_permissions_denied));
+ builder.append("\n\n");
+ builder.append(getString(R.string.storage_permissions_explanation));
+ final ViewGroup viewGroup = (ViewGroup) ((ViewGroup) this
+ .findViewById(android.R.id.content)).getChildAt(0);
+ if (viewGroup != null) {
+ Snackbar snackbar = Snackbar.make(viewGroup, builder.toString(),
+ Snackbar.LENGTH_INDEFINITE, 7);
+ snackbar.setAction(R.string.snackbar_settings, new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ startInstalledAppDetailsActivity(MainActivity.this);
+ finish();
+ }
+ });
+ snackbar.show();
+ }
+ }
+ }
+ }
+
+ public static void startInstalledAppDetailsActivity(final Activity context) {
+ if (context == null) {
+ return;
+ }
+ final Intent i = new Intent();
+ i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+ i.addCategory(Intent.CATEGORY_DEFAULT);
+ i.setData(Uri.parse("package:" + context.getPackageName()));
+ i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
+ i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ context.startActivity(i);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onCreate(Bundle state) {
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+
+ // Set the theme before setContentView
+ ThemeManager.Theme theme = ThemeManager.getCurrentTheme(this);
+ theme.setBaseThemeNoActionBar(this);
+
+ //Set the main layout of the activity
+ setContentView(R.layout.navigation);
+
+ //Save state
+ super.onCreate(state);
+
+ if (!hasPermissions()) {
+ requestNecessaryPermissions();
+ } else {
+ finishOnCreate();
+ }
+ }
+
+ private void finishOnCreate() {
+ //Initialize nfc adapter
+ NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
+ if (mNfcAdapter != null) {
+ mNfcAdapter.setBeamPushUrisCallback(new NfcAdapter.CreateBeamUrisCallback() {
+ @Override
+ public android.net.Uri[] createBeamUris(android.nfc.NfcEvent event) {
+ if (currentFragment instanceof NavigationFragment) {
+ List<FileSystemObject> selectedFiles =
+ ((NavigationFragment)currentFragment).getCurrentNavigationView()
+ .getSelectedFiles();
+ if (selectedFiles.size() > 0) {
+ List<android.net.Uri> fileUri = new ArrayList<Uri>();
+ for (FileSystemObject f : selectedFiles) {
+ //Beam ignores folders and system files
+ if (!FileHelper.isDirectory(f) && !FileHelper.isSystemFile(f)) {
+ fileUri.add(Uri.fromFile(new File(f.getFullPath())));
+ }
+ }
+ if (fileUri.size() > 0) {
+ return fileUri.toArray(new android.net.Uri[fileUri.size()]);
+ }
+ }
+ }
+ return null;
+ }
+ }, this);
+ }
+ }
+
+ private void setCurrentFragment(FragmentType fragmentType) {
+ FragmentManager fragmentManager = getSupportFragmentManager();
+
+ switch (fragmentType) {
+ case NAVIGATION:
+ currentFragment = new NavigationFragment();
+ break;
+ case HOME:
+ default:
+ // Default to HOME
+ currentFragment = HomeFragment.newInstance();
+ break;
+ }
+
+ fragmentManager.beginTransaction()
+ .replace(R.id.navigation_fragment_container, currentFragment)
+ .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
+ .addToBackStack(null)
+ .commit();
+ }
+
+ public void addBookmark(Bookmark bookmark) {
+ // stub
+ }
+
+ public void updateActiveDialog(Dialog dialog) {
+ // stub
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onNewIntent(Intent intent) {
+ //stub
+ }
+
+
+ /**
+ * Method invoked when an action item is clicked.
+ *
+ * @param view The button pushed
+ */
+ public void onActionBarItemClick(android.view.View view) {
+
+ if (currentFragment instanceof NavigationFragment) {
+
+ 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:
+ //Show information of the filesystem
+ com.cyanogenmod.filemanager.model.MountPoint mp =
+ ((NavigationFragment)currentFragment)
+ .getCurrentNavigationView().getBreadcrumb().getMountPointInfo();
+ com.cyanogenmod.filemanager.model.DiskUsage du =
+ ((NavigationFragment)currentFragment)
+ .getCurrentNavigationView().getBreadcrumb().getDiskUsageInfo();
+ ((NavigationFragment)currentFragment).showMountPointInfo(mp, du);
+ break;
+
+ //######################
+ //Navigation view options
+ //######################
+ case com.cyanogenmod.filemanager.R.id.ab_sort_mode:
+ ((NavigationFragment)currentFragment).showSettingsPopUp(view,
+ java.util.Arrays.asList(
+ new FileManagerSettings[]{
+ FileManagerSettings.SETTINGS_SORT_MODE}));
+ 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
+ //######################
+ case com.cyanogenmod.filemanager.R.id.ab_selection_done:
+ //Show information of the filesystem
+ ((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;
+
+ default:
+ break;
+ }
+ }
+ }
+
+}
diff --git a/src/com/cyanogenmod/filemanager/activities/SearchActivity.java b/src/com/cyanogenmod/filemanager/activities/SearchActivity.java
index a5d9cc4a..6e6d7317 100755
--- a/src/com/cyanogenmod/filemanager/activities/SearchActivity.java
+++ b/src/com/cyanogenmod/filemanager/activities/SearchActivity.java
@@ -785,7 +785,7 @@ public class SearchActivity extends Activity
ArrayList<String> localizedNames = new ArrayList<String>(mMimeTypeCategories.size());
for (MimeTypeCategory category : mMimeTypeCategories) {
localizedNames
- .add(NavigationActivity.MIME_TYPE_LOCALIZED_NAMES[category.ordinal()]);
+ .add(MainActivity.MIME_TYPE_LOCALIZED_NAMES[category.ordinal()]);
}
this.mSearchTerms.setText(
Html.fromHtml(getString(R.string.search_terms, localizedNames)));
@@ -1324,7 +1324,7 @@ public class SearchActivity extends Activity
final Intent intent = new Intent();
if (this.mRestoreState != null) {
Bundle bundle = new Bundle();
- bundle.putParcelable(NavigationActivity.EXTRA_SEARCH_LAST_SEARCH_DATA,
+ bundle.putParcelable(MainActivity.EXTRA_SEARCH_LAST_SEARCH_DATA,
(Parcelable)this.mRestoreState);
intent.putExtras(bundle);
}
@@ -1388,7 +1388,7 @@ public class SearchActivity extends Activity
}
/**
- * Method that navigate to the file system used the intent (NavigationActivity)
+ * Method that navigate to the file system used the intent (MainActivity)
*
* @param fso The file system object to navigate to
* @return boolean If the action implies finish this activity
@@ -1398,8 +1398,8 @@ public class SearchActivity extends Activity
if (FileHelper.isDirectory(fso)) {
final Intent intent = new Intent();
Bundle bundle = new Bundle();
- bundle.putSerializable(NavigationActivity.EXTRA_SEARCH_ENTRY_SELECTION, fso);
- bundle.putParcelable(NavigationActivity.EXTRA_SEARCH_LAST_SEARCH_DATA,
+ bundle.putSerializable(MainActivity.EXTRA_SEARCH_ENTRY_SELECTION, fso);
+ bundle.putParcelable(MainActivity.EXTRA_SEARCH_LAST_SEARCH_DATA,
(Parcelable)createSearchInfo());
intent.putExtras(bundle);
setResult(RESULT_OK, intent);
diff --git a/src/com/cyanogenmod/filemanager/activities/ShortcutActivity.java b/src/com/cyanogenmod/filemanager/activities/ShortcutActivity.java
index f074641c..5870c21b 100644
--- a/src/com/cyanogenmod/filemanager/activities/ShortcutActivity.java
+++ b/src/com/cyanogenmod/filemanager/activities/ShortcutActivity.java
@@ -181,8 +181,8 @@ public class ShortcutActivity extends Activity implements OnCancelListener, OnDi
finish();
// Forward to the NavigationActivity
- Intent intent = new Intent(this, NavigationActivity.class);
- intent.putExtra(NavigationActivity.EXTRA_NAVIGATE_TO, fso.getFullPath());
+ Intent intent = new Intent(this, MainActivity.class);
+ intent.putExtra(MainActivity.EXTRA_NAVIGATE_TO, fso.getFullPath());
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
diff --git a/src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java b/src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java
index 25b20cd7..0b5e9a52 100644
--- a/src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java
+++ b/src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java
@@ -16,12 +16,10 @@
package com.cyanogenmod.filemanager.ui.dialogs;
-import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.os.Bundle;
import android.view.HapticFeedbackConstants;
import android.view.Menu;
import android.view.MenuItem;
@@ -37,7 +35,7 @@ import android.widget.Toast;
import com.cyanogenmod.filemanager.FileManagerApplication;
import com.cyanogenmod.filemanager.R;
-import com.cyanogenmod.filemanager.activities.NavigationActivity;
+import com.cyanogenmod.filemanager.ui.fragments.NavigationFragment;
import com.cyanogenmod.filemanager.adapters.TwoColumnsMenuListAdapter;
import com.cyanogenmod.filemanager.console.VirtualMountPointConsole;
import com.cyanogenmod.filemanager.listeners.OnRequestRefreshListener;
@@ -55,7 +53,6 @@ import com.cyanogenmod.filemanager.ui.ThemeManager.Theme;
import com.cyanogenmod.filemanager.ui.policy.BookmarksActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.CompressActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.CopyMoveActionPolicy;
-import com.cyanogenmod.filemanager.ui.policy.CopyMoveActionPolicy.LinkedResource;
import com.cyanogenmod.filemanager.ui.policy.DeleteActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.ExecutionActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.InfoActionPolicy;
@@ -71,17 +68,15 @@ import com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory;
import com.cyanogenmod.filemanager.util.SelectionHelper;
import com.cyanogenmod.filemanager.util.StorageHelper;
-import java.io.File;
import java.io.InvalidClassException;
-import java.util.ArrayList;
import java.util.List;
import static com.cyanogenmod.filemanager.activities.PickerActivity.INTENT_FOLDER_SELECT;
import static com.cyanogenmod.filemanager.activities.PickerActivity.EXTRA_ACTION;
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.NavigationActivity.INTENT_REQUEST_COPY;
-import static com.cyanogenmod.filemanager.activities.NavigationActivity.INTENT_REQUEST_MOVE;
+import static com.cyanogenmod.filemanager.ui.fragments.NavigationFragment.INTENT_REQUEST_COPY;
+import static com.cyanogenmod.filemanager.ui.fragments.NavigationFragment.INTENT_REQUEST_MOVE;
/**
* A class that wraps a dialog for showing the list of actions that
@@ -92,7 +87,7 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen
* @hide
*/
final Context mContext;
- final NavigationActivity mBackRef;
+ final NavigationFragment mBackRef;
private final boolean mGlobal;
private final boolean mSearch;
private final boolean mChRooted;
@@ -124,7 +119,7 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen
* @param global If the menu to display will be the global one (Global actions)
* @param search If the call is from search activity
*/
- public ActionsDialog(Context context, NavigationActivity backRef, FileSystemObject fso,
+ public ActionsDialog(Context context, NavigationFragment backRef, FileSystemObject fso,
boolean global, boolean search) {
super();
@@ -414,7 +409,7 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen
Bookmark bookmark = BookmarksActionPolicy.addToBookmarks(
this.mContext, this.mFso);
if (mBackRef != null && bookmark != null) {
- // tell NavigationActivity's drawer to add the bookmark
+ // tell MainActivity's drawer to add the bookmark
mBackRef.addBookmark(bookmark);
}
break;
diff --git a/src/com/cyanogenmod/filemanager/ui/fragments/HomeFragment.java b/src/com/cyanogenmod/filemanager/ui/fragments/HomeFragment.java
new file mode 100644
index 00000000..8de200d8
--- /dev/null
+++ b/src/com/cyanogenmod/filemanager/ui/fragments/HomeFragment.java
@@ -0,0 +1,222 @@
+/*
+ * 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.Intent;
+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.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;
+ private android.widget.ArrayAdapter<MimeTypeHelper.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);
+ return mView;
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ mToolBar = (Toolbar) mView.findViewById(
+ com.cyanogenmod.filemanager.R.id.material_toolbar);
+ ((ActionBarActivity) getActivity()).setSupportActionBar(mToolBar);
+ ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+ initEasyModePlus();
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle savedInstanceState)
+ {
+ super.onSaveInstanceState(savedInstanceState);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ }
+
+
+ private void initEasyModePlus() {
+
+ MIME_TYPE_LOCALIZED_NAMES = MimeTypeHelper.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);
+ }
+} \ No newline at end of file
diff --git a/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java b/src/com/cyanogenmod/filemanager/ui/fragments/NavigationFragment.java
index 2d604d1d..59de30a3 100755..100644
--- a/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java
+++ b/src/com/cyanogenmod/filemanager/ui/fragments/NavigationFragment.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.cyanogenmod.filemanager.activities;
+package com.cyanogenmod.filemanager.ui.fragments;
import android.app.Activity;
import android.app.AlertDialog;
@@ -46,13 +46,15 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.os.storage.StorageVolume;
import android.provider.Settings;
-import android.support.v4.app.ActionBarDrawerToggle;
+import android.support.v4.app.Fragment;
import android.support.v4.content.FileProvider;
-import android.support.v4.widget.DrawerLayout;
+import android.support.v7.app.ActionBarActivity;
+import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
+import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
@@ -69,12 +71,12 @@ import android.widget.PopupWindow;
import android.widget.SearchView;
import android.widget.TextView;
import android.widget.Toast;
-import android.widget.Toolbar;
import android.widget.ArrayAdapter;
import com.android.internal.util.XmlUtils;
import com.cyanogenmod.filemanager.FileManagerApplication;
import com.cyanogenmod.filemanager.R;
+import com.cyanogenmod.filemanager.activities.SearchActivity;
import com.cyanogenmod.filemanager.activities.preferences.SettingsPreferences;
import com.cyanogenmod.filemanager.adapters.MenuSettingsAdapter;
import com.cyanogenmod.filemanager.console.Console;
@@ -147,17 +149,17 @@ import static com.cyanogenmod.filemanager.activities.PickerActivity.EXTRA_FOLDER
* This activity is singleTop, so when it is displayed no other activities exists in
* the stack.<br/>
* This cause an issue with the saved instance of this class, because if another activity
- * is displayed, and the process is killed, NavigationActivity is started and the saved
+ * is displayed, and the process is killed, NavigationFragment is started and the saved
* instance gets corrupted.<br/>
* For this reason the methods {link {@link Activity#onSaveInstanceState(Bundle)} and
* {@link Activity#onRestoreInstanceState(Bundle)} are not implemented, and every time
* the app is killed, is restarted from his initial state.
*/
-public class NavigationActivity extends Activity
- implements OnHistoryListener, OnRequestRefreshListener,
- OnNavigationRequestMenuListener, OnNavigationSelectionChangedListener {
+public class NavigationFragment extends Fragment
+ implements OnHistoryListener, OnRequestRefreshListener,
+ OnNavigationRequestMenuListener, OnNavigationSelectionChangedListener {
- private static final String TAG = "NavigationActivity"; //$NON-NLS-1$
+ private static final String TAG = "NavigationFragment"; //$NON-NLS-1$
private static boolean DEBUG = false;
@@ -216,13 +218,15 @@ public class NavigationActivity extends Activity
// exit, and the toast is shown again after the first tap.
private static final int RELEASE_EXIT_CHECK_TIMEOUT = 3500;
-
private Toolbar mToolBar;
private SearchView mSearchView;
private NavigationCustomTitleView mCustomTitleView;
private InputMethodManager mImm;
private ListPopupWindow mPopupWindow;
private ActionsDialog mActionsDialog;
+ private View mTitleLayout;
+ private View mStatusBar;
+
private final BroadcastReceiver mNotificationReceiver = new BroadcastReceiver() {
@Override
@@ -230,7 +234,8 @@ public class NavigationActivity extends Activity
if (intent != null) {
if (intent.getAction().compareTo(FileManagerSettings.INTENT_SETTING_CHANGED) == 0) {
// The settings has changed
- String key = intent.getStringExtra(FileManagerSettings.EXTRA_SETTING_CHANGED_KEY);
+ String key = intent.getStringExtra(FileManagerSettings.
+ EXTRA_SETTING_CHANGED_KEY);
if (key != null) {
// Disk usage warning level
if (key.compareTo(FileManagerSettings.
@@ -270,19 +275,19 @@ public class NavigationActivity extends Activity
FileManagerSettings.SETTINGS_USE_FLINGER.getId(),
((Boolean)FileManagerSettings.
SETTINGS_USE_FLINGER.
- getDefaultValue()).booleanValue());
+ getDefaultValue()).booleanValue());
getCurrentNavigationView().setUseFlinger(useFlinger);
return;
}
// Access mode
if (key.compareTo(FileManagerSettings.
- SETTINGS_ACCESS_MODE.getId()) == 0) {
+ SETTINGS_ACCESS_MODE.getId()) == 0) {
// Is it necessary to create or exit of the ChRooted?
boolean chRooted =
FileManagerApplication.
- getAccessMode().compareTo(AccessMode.SAFE) == 0;
- if (chRooted != NavigationActivity.this.mChRooted) {
+ getAccessMode().compareTo(AccessMode.SAFE) == 0;
+ if (chRooted != NavigationFragment.this.mChRooted) {
if (chRooted) {
createChRooted();
} else {
@@ -313,7 +318,7 @@ public class NavigationActivity extends Activity
// Refresh the data
synchronized (FileHelper.DATETIME_SYNC) {
FileHelper.sReloadDateTimeFormats = true;
- NavigationActivity.this.getCurrentNavigationView().refresh();
+ getCurrentNavigationView().refresh();
}
}
}
@@ -338,12 +343,11 @@ public class NavigationActivity extends Activity
} else if (intent.getAction().compareTo(Intent.ACTION_TIME_CHANGED) == 0 ||
intent.getAction().compareTo(Intent.ACTION_DATE_CHANGED) == 0 ||
- intent.getAction().compareTo(Intent.ACTION_TIMEZONE_CHANGED) == 0 ||
- intent.getAction().compareTo(Intent.ACTION_LOCALE_CHANGED) == 0) {
+ intent.getAction().compareTo(Intent.ACTION_TIMEZONE_CHANGED) == 0) {
// Refresh the data
synchronized (FileHelper.DATETIME_SYNC) {
FileHelper.sReloadDateTimeFormats = true;
- NavigationActivity.this.getCurrentNavigationView().refresh();
+ NavigationFragment.this.getCurrentNavigationView().refresh();
}
} else if (intent.getAction().compareTo(
FileManagerSettings.INTENT_MOUNT_STATUS_CHANGED) == 0 ||
@@ -368,9 +372,9 @@ public class NavigationActivity extends Activity
mBookmarksTab.setSelected(true);
mHistoryTab.setSelected(false);
mBookmarksTab.setTextAppearance(
- NavigationActivity.this, R.style.primary_text_appearance);
+ getActivity(), R.style.primary_text_appearance);
mHistoryTab.setTextAppearance(
- NavigationActivity.this, R.style.secondary_text_appearance);
+ getActivity(), R.style.secondary_text_appearance);
mHistoryLayout.setVisibility(View.GONE);
mBookmarksLayout.setVisibility(View.VISIBLE);
applyTabTheme();
@@ -390,16 +394,16 @@ public class NavigationActivity extends Activity
mHistoryTab.setSelected(true);
mBookmarksTab.setSelected(false);
mHistoryTab.setTextAppearance(
- NavigationActivity.this, R.style.primary_text_appearance);
+ getActivity(), R.style.primary_text_appearance);
mBookmarksTab.setTextAppearance(
- NavigationActivity.this, R.style.secondary_text_appearance);
+ 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);
+ 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$
}
@@ -418,7 +422,6 @@ public class NavigationActivity extends Activity
public void onClick(View v) {
switch (v.getId()) {
case R.id.ab_settings:
- mDrawerLayout.closeDrawer(Gravity.START);
openSettings();
break;
case R.id.ab_clear_history:
@@ -442,10 +445,6 @@ public class NavigationActivity extends Activity
* @hide
*/
NavigationView[] mNavigationViews;
- /**
- * @hide
- */
- ListView mEasyModeListView;
/**
* Used to record the operation steps
@@ -457,34 +456,11 @@ public class NavigationActivity extends Activity
*/
private List<History> mHistorySaved;
- private static final List<MimeTypeCategory> EASY_MODE_LIST = new ArrayList<MimeTypeCategory>() {
- {
- add(NONE);
- add(IMAGE);
- add(VIDEO);
- add(AUDIO);
- add(DOCUMENT);
- add(APP);
- }
- };
-
- private ArrayAdapter<MimeTypeCategory> mEasyModeAdapter;
- private View.OnClickListener mEasyModeItemClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Integer position = (Integer) view.getTag();
- onClicked(position);
- }
- };
-
private int mCurrentNavigationView;
private ViewGroup mActionBar;
private SelectionView mSelectionBar;
- private DrawerLayout mDrawerLayout;
- private ViewGroup mDrawer;
- private ActionBarDrawerToggle mDrawerToggle;
private LinearLayout mDrawerHistory;
private TextView mDrawerHistoryEmpty;
@@ -507,191 +483,66 @@ public class NavigationActivity extends Activity
private int mOrientation;
- private boolean mNeedsEasyMode = false;
private boolean mDisplayingSearchResults;
/**
* @hide
*/
- boolean mChRooted;
+ public boolean mChRooted;
/**
* @hide
*/
Handler mHandler;
+ View mView;
+ LayoutInflater mLayoutInflater;
private AsyncTask<Void, Void, Boolean> mBookmarksTask;
private AsyncTask<Void, Void, Boolean> mHistoryTask;
- private static final int REQUEST_CODE_STORAGE_PERMS = 321;
- private boolean hasPermissions() {
- int res = checkCallingOrSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
- return (res == PackageManager.PERMISSION_GRANTED);
- }
+ public View onCreateView(
+ LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
- private void requestNecessaryPermissions() {
- String[] permissions = new String[] {
- Manifest.permission.WRITE_EXTERNAL_STORAGE,
- };
- requestPermissions(permissions, REQUEST_CODE_STORAGE_PERMS);
- }
-
- @Override
- public void onRequestPermissionsResult(int requestCode, String[] permissions,
- int[] grandResults) {
- boolean allowed = true;
- switch (requestCode) {
- case REQUEST_CODE_STORAGE_PERMS:
- for (int res : grandResults) {
- allowed = allowed && (res == PackageManager.PERMISSION_GRANTED);
- }
- break;
- default:
- allowed = false;
- break;
- }
- if (allowed) {
- finishOnCreate();
- if (mDrawerToggle != null) {
- mDrawerToggle.syncState();
- }
- } else {
- if (shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
- String text = getResources().getString(R.string.storage_permissions_denied);
- final ViewGroup viewGroup = (ViewGroup) ((ViewGroup) this
- .findViewById(android.R.id.content)).getChildAt(0);
- if (viewGroup != null) {
- Snackbar snackbar = Snackbar.make(viewGroup, text,
- Snackbar.LENGTH_INDEFINITE, 3);
- snackbar.setAction(android.R.string.ok, new OnClickListener() {
- @Override
- public void onClick(View v) {
- requestNecessaryPermissions();
- }
- });
- snackbar.show();
- }
- } else {
- StringBuilder builder = new StringBuilder(getString(R.string
- .storage_permissions_denied));
- builder.append("\n\n");
- builder.append(getString(R.string.storage_permissions_explanation));
- final ViewGroup viewGroup = (ViewGroup) ((ViewGroup) this
- .findViewById(android.R.id.content)).getChildAt(0);
- if (viewGroup != null) {
- Snackbar snackbar = Snackbar.make(viewGroup, builder.toString(),
- Snackbar.LENGTH_INDEFINITE, 7);
- snackbar.setAction(R.string.snackbar_settings, new OnClickListener() {
- @Override
- public void onClick(View v) {
- startInstalledAppDetailsActivity(NavigationActivity.this);
- finish();
- }
- });
- snackbar.show();
- }
- }
+ mLayoutInflater = inflater;
+ if (DEBUG) {
+ Log.d(TAG, "NavigationFragment.onCreate"); //$NON-NLS-1$
}
- }
+ // Set the theme before setContentView
+ ThemeManager.Theme theme = ThemeManager.getCurrentTheme(getActivity());
+ theme.setBaseThemeNoActionBar(getActivity());
- public static void startInstalledAppDetailsActivity(final Activity context) {
- if (context == null) {
- return;
- }
- final Intent i = new Intent();
- i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
- i.addCategory(Intent.CATEGORY_DEFAULT);
- i.setData(Uri.parse("package:" + context.getPackageName()));
- i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
- i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
- context.startActivity(i);
- }
-
- private void finishOnCreate() {
-
- // Register the broadcast receiver
- IntentFilter filter = new IntentFilter();
- filter.addAction(FileManagerSettings.INTENT_SETTING_CHANGED);
- filter.addAction(FileManagerSettings.INTENT_FILE_CHANGED);
- filter.addAction(FileManagerSettings.INTENT_THEME_CHANGED);
- filter.addAction(Intent.ACTION_DATE_CHANGED);
- filter.addAction(Intent.ACTION_TIME_CHANGED);
- filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
- filter.addAction(Intent.ACTION_LOCALE_CHANGED);
- filter.addAction(FileManagerSettings.INTENT_MOUNT_STATUS_CHANGED);
- registerReceiver(this.mNotificationReceiver, filter);
-
- // This filter needs the file data scheme, so it must be defined separately.
- IntentFilter newFilter = new IntentFilter();
- newFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
- newFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
- newFilter.addDataScheme(ContentResolver.SCHEME_FILE);
- registerReceiver(mNotificationReceiver, newFilter);
-
- //the input manager service
- mImm = (InputMethodManager) this.getSystemService(
- Context.INPUT_METHOD_SERVICE);
-
- //Initialize nfc adapter
- NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
- if (mNfcAdapter != null) {
- mNfcAdapter.setBeamPushUrisCallback(new NfcAdapter.CreateBeamUrisCallback() {
- @Override
- public Uri[] createBeamUris(NfcEvent event) {
- List<FileSystemObject> selectedFiles =
- getCurrentNavigationView().getSelectedFiles();
- if (selectedFiles.size() > 0) {
- List<Uri> fileUri = new ArrayList<Uri>();
- for (FileSystemObject f : selectedFiles) {
- //Beam ignores folders and system files
- if (!FileHelper.isDirectory(f) && !FileHelper.isSystemFile(f)) {
- fileUri.add(FileProvider.getUriForFile(
- NavigationActivity.this,
- "com.cyanogenmod.filemanager.providers.file",
- new File(f.getFullPath())));
- }
- }
- if (fileUri.size() > 0) {
- return fileUri.toArray(new Uri[fileUri.size()]);
- }
- }
- return null;
- }
- }, this);
- }
+ //Set the main layout of the activity
+ mView = inflater.inflate(R.layout.nav_fragment, container, false);
//Initialize activity
init();
- //Navigation views
initNavigationViews();
- // As we're using a Toolbar, we should retrieve it and set it
- // to be our ActionBar
- mToolBar = (Toolbar) findViewById(R.id.material_toolbar);
- setActionBar(mToolBar);
+ return mView;
+ }
+
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ mToolBar = (Toolbar) mView.findViewById(R.id.material_toolbar);
+ ((ActionBarActivity) getActivity()).setSupportActionBar(mToolBar);
+ ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ ((ActionBarActivity) getActivity()).getSupportActionBar().setHomeButtonEnabled(true);
//Initialize action bars
initTitleActionBar();
initStatusActionBar();
initSelectionBar();
-
- // Initialize navigation drawer
- initDrawer();
initBookmarks();
initHistory();
- // Adjust layout (only when start on landscape mode)
- int orientation = getResources().getConfiguration().orientation;
- if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
- onLayoutChanged();
- }
- this.mOrientation = orientation;
-
// Apply the theme
applyTheme();
@@ -706,69 +557,38 @@ public class NavigationActivity extends Activity
initConsole();
//Initialize navigation
- int cc = NavigationActivity.this.mNavigationViews.length;
+ int cc = NavigationFragment.this.mNavigationViews.length;
for (int i = 0; i < cc; i++) {
- initNavigation(i, false, getIntent());
+ initNavigation(i, false, getActivity().getIntent());
}
//Check the intent action
- checkIntent(getIntent());
+ checkIntent(getActivity().getIntent());
}
});
- MIME_TYPE_LOCALIZED_NAMES = MimeTypeCategory.getFriendlyLocalizedNames(NavigationActivity
- .this);
-
- EASY_MODE_ICONS.put(MimeTypeCategory.NONE, getResources().getDrawable(R.drawable
- .ic_em_all));
- EASY_MODE_ICONS.put(MimeTypeCategory.IMAGE, getResources().getDrawable(R.drawable
- .ic_em_image));
- EASY_MODE_ICONS.put(MimeTypeCategory.VIDEO, getResources().getDrawable(R.drawable
- .ic_em_video));
- EASY_MODE_ICONS.put(MimeTypeCategory.AUDIO, getResources().getDrawable(R.drawable
- .ic_em_music));
- EASY_MODE_ICONS.put(MimeTypeCategory.DOCUMENT, getResources().getDrawable(R.drawable
- .ic_em_document));
- EASY_MODE_ICONS.put(MimeTypeCategory.APP, getResources().getDrawable(R.drawable
- .ic_em_application));
-
+ // Adjust layout (only when start on landscape mode)
+ int orientation = getResources().getConfiguration().orientation;
+ if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ onLayoutChanged();
+ }
+ this.mOrientation = orientation;
}
/**
* {@inheritDoc}
*/
@Override
- protected void onCreate(Bundle state) {
-
- if (DEBUG) {
- Log.d(TAG, "NavigationActivity.onCreate"); //$NON-NLS-1$
- }
+ public void onResume() {
+ super.onResume();
- // Set the theme before setContentView
- Theme theme = ThemeManager.getCurrentTheme(this);
- theme.setBaseThemeNoActionBar(this);
-
- //Set the main layout of the activity
- setContentView(R.layout.navigation);
-
- //Save state
- super.onCreate(state);
-
- if (!hasPermissions()) {
- requestNecessaryPermissions();
- } else {
- finishOnCreate();
+ if (mDisplayingSearchResults) {
+ mDisplayingSearchResults = false;
+ closeSearch();
}
- }
-
- @Override
- protected void onStart() {
- super.onStart();
-
// Check restrictions
- if (!hasPermissions() ||
- !FileManagerApplication.checkRestrictSecondaryUsersAccess(this, mChRooted)) {
+ if (!FileManagerApplication.checkRestrictSecondaryUsersAccess(getActivity(), mChRooted)) {
return;
}
@@ -781,43 +601,14 @@ public class NavigationActivity extends Activity
onRequestBookmarksRefresh();
removeUnmountedHistory();
removeUnmountedSelection();
- }
- if (mDisplayingSearchResults) {
- mDisplayingSearchResults = false;
- closeSearch();
+ Intent intent = new Intent();
+ intent.putExtra(EXTRA_ADD_TO_HISTORY, false);
+ initNavigation(NavigationFragment.this.mCurrentNavigationView, false, intent);
}
- getCurrentNavigationView().refresh(true);
- }
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- // Sync the toggle state after onRestoreInstanceState has occurred.
- if (mDrawerToggle != null) {
- mDrawerToggle.syncState();
- }
- }
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onNewIntent(Intent intent) {
- // If no directory specified, restore current directory
- final String navigateTo = intent.getStringExtra(EXTRA_NAVIGATE_TO);
- final boolean restore = TextUtils.isEmpty(navigateTo);
-
- //Initialize navigation
- if (!hasPermissions()) {
- requestNecessaryPermissions();
- } else {
- initNavigation(this.mCurrentNavigationView, restore, intent);
+ getCurrentNavigationView().refresh(true);
}
-
- //Check the intent action
- checkIntent(intent);
}
/**
@@ -826,49 +617,16 @@ public class NavigationActivity extends Activity
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- if (hasPermissions()) {
- onLayoutChanged();
- if (mDrawerToggle != null ) {
- mDrawerToggle.onConfigurationChanged(newConfig);
- }
- }
- NavigationView navView = getCurrentNavigationView();
- if (navView != null) {
- navView.refreshViewMode();
- }
- if (mPopupWindow != null) {
- mPopupWindow.postShow();
- }
+ onLayoutChanged();
}
/**
* {@inheritDoc}
*/
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (mDrawerToggle.onOptionsItemSelected(item)) {
- return true;
- }
-
- if (mNeedsEasyMode) {
- if (item.getItemId() == android.R.id.home) {
- if (mHistory.size() == 0 && !isEasyModeVisible()) {
- performShowEasyMode();
- } else {
- back();
- }
- }
- }
- return super.onOptionsItemSelected(item);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onDestroy() {
+ public void onDestroy() {
if (DEBUG) {
- Log.d(TAG, "NavigationActivity.onDestroy"); //$NON-NLS-1$
+ Log.d(TAG, "NavigationFragment.onDestroy"); //$NON-NLS-1$
}
if (mActiveDialog != null && mActiveDialog.isShowing()) {
@@ -877,7 +635,7 @@ public class NavigationActivity extends Activity
// Unregister the receiver
try {
- unregisterReceiver(this.mNotificationReceiver);
+ getActivity().unregisterReceiver(this.mNotificationReceiver);
} catch (Throwable ex) {
/**NON BLOCK**/
}
@@ -921,26 +679,7 @@ public class NavigationActivity extends Activity
* access the application
*/
private void showWelcomeMsg() {
- boolean firstUse = Preferences.getSharedPreferences().getBoolean(
- FileManagerSettings.SETTINGS_FIRST_USE.getId(),
- ((Boolean)FileManagerSettings.SETTINGS_FIRST_USE.getDefaultValue()).booleanValue());
-
- //Display the welcome message?
- if (firstUse && FileManagerApplication.hasShellCommands()) {
- // open navigation drawer to show user that it exists
- mDrawerLayout.openDrawer(Gravity.START);
-
- AlertDialog dialog = DialogHelper.createAlertDialog(this,
- R.mipmap.ic_launcher_filemanager, R.string.welcome_title,
- getString(R.string.welcome_msg), false);
- DialogHelper.delegateDialogShow(this, dialog);
-
- // Don't display again this dialog
- try {
- Preferences.savePreference(
- FileManagerSettings.SETTINGS_FIRST_USE, Boolean.FALSE, true);
- } catch (Exception e) {/**NON BLOCK**/}
- }
+ // TODO: implement new initial welcome message
}
/**
@@ -948,10 +687,11 @@ public class NavigationActivity extends Activity
*/
private void initTitleActionBar() {
//Inflate the view and associate breadcrumb
- View titleLayout = getLayoutInflater().inflate(
+ mTitleLayout = mLayoutInflater.inflate(
R.layout.navigation_view_customtitle, null, false);
NavigationCustomTitleView title =
- (NavigationCustomTitleView)titleLayout.findViewById(R.id.navigation_title_flipper);
+ (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;
@@ -966,13 +706,13 @@ public class NavigationActivity extends Activity
// 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());
+ (String) FileManagerSettings.SETTINGS_DISK_USAGE_WARNING_LEVEL.getDefaultValue());
breadcrumb.setFreeDiskSpaceWarningLevel(Integer.parseInt(fds));
//Configure the action bar options
- getActionBar().setBackgroundDrawable(
+ mToolBar.setBackgroundDrawable(
getResources().getDrawable(R.drawable.bg_material_titlebar));
- mToolBar.addView(titleLayout);
+ mToolBar.addView(mTitleLayout);
}
/**
@@ -984,7 +724,7 @@ public class NavigationActivity extends Activity
//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)findViewById(R.id.navigation_actionbar);
+ this.mActionBar = (ViewGroup) mView.findViewById(R.id.navigation_actionbar);
this.mActionBar.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(
@@ -1008,11 +748,11 @@ public class NavigationActivity extends Activity
// Have overflow menu? Actually no. There is only a search action, so just hide
// the overflow
- View overflow = findViewById(R.id.ab_overflow);
+ View overflow = mView.findViewById(R.id.ab_overflow);
overflow.setVisibility(View.GONE);
// Show the status bar
- View statusBar = findViewById(R.id.navigation_statusbar_portrait_holder);
+ View statusBar = mView.findViewById(R.id.navigation_statusbar_portrait_holder);
statusBar.setVisibility(View.VISIBLE);
}
@@ -1020,31 +760,41 @@ public class NavigationActivity extends Activity
* Method that initializes the selectionbar of the activity.
*/
private void initSelectionBar() {
- this.mSelectionBar = (SelectionView)findViewById(R.id.navigation_selectionbar);
+ this.mSelectionBar = (SelectionView) mView.findViewById(R.id.navigation_selectionbar);
}
/**
* Method that initializes the navigation drawer of the activity.
*/
private void initDrawer() {
- mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ // 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) findViewById(R.id.drawer);
- mDrawerBookmarks = (LinearLayout) findViewById(R.id.bookmarks_list);
- mDrawerHistory = (LinearLayout) findViewById(R.id.history_list);
- mDrawerHistoryEmpty = (TextView) findViewById(R.id.history_empty);
-
- mBookmarksLayout = findViewById(R.id.drawer_bookmarks);
- mHistoryLayout = findViewById(R.id.drawer_history);
- mBookmarksTab = (TextView) findViewById(R.id.drawer_bookmarks_tab);
- mHistoryTab = (TextView) findViewById(R.id.drawer_history_tab);
+ 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 = (ButtonItem) findViewById(R.id.ab_settings);
+ mSettings = (cButtonItem) mView.findViewById(
+ R.id.ab_settings);
mSettings.setOnClickListener(mOnClickDrawerActionBarListener);
- mClearHistory = (ButtonItem) findViewById(R.id.ab_clear_history);
+ mClearHistory = (cButtonItem) mView.findViewById(
+ R.id.ab_clear_history);
mClearHistory.setOnClickListener(mOnClickDrawerActionBarListener);
// Restore the last tab pressed
@@ -1055,25 +805,24 @@ public class NavigationActivity extends Activity
mOnClickDrawerTabListener.onClick(lastTab == 0 ? mBookmarksTab : mHistoryTab);
// Set the navigation drawer "hamburger" icon
- mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
+ mDrawerToggle = new android.support.v4.app.ActionBarDrawerToggle(getActivity(),
+ mDrawerLayout,
R.drawable.ic_material_light_navigation_drawer,
R.string.drawer_open, R.string.drawer_close) {
- /** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
}
- /** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
onDrawerLayoutOpened(drawerView);
super.onDrawerOpened(drawerView);
}
};
- getActionBar().setDisplayHomeAsUpEnabled(true);
+ getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
// Set the drawer toggle as the DrawerListener
- mDrawerLayout.setDrawerListener(mDrawerToggle);
+ mDrawerLayout.setDrawerListener(mDrawerToggle);*/
}
/***
@@ -1103,11 +852,11 @@ public class NavigationActivity extends Activity
// hide empty message
mDrawerHistoryEmpty.setVisibility(View.GONE);
- Theme theme = ThemeManager.getCurrentTheme(this);
- IconHolder iconholder = new IconHolder(this, false);
+ Theme theme = ThemeManager.getCurrentTheme(getActivity());
+ IconHolder iconholder = new IconHolder(getActivity(), false);
// inflate single bookmark layout item and fill it
- LinearLayout view = (LinearLayout) getLayoutInflater().inflate(
+ LinearLayout view = (LinearLayout) mLayoutInflater.inflate(
R.layout.history_item, null);
ImageView iconView = (ImageView) view
@@ -1130,8 +879,8 @@ public class NavigationActivity extends Activity
name.setText(title);
directory.setText(navigable.getDescription());
- theme.setTextColor(this, name, "text_color");
- theme.setTextColor(this, directory, "text_color");
+ theme.setTextColor(getActivity(), name, "text_color");
+ theme.setTextColor(getActivity(), directory, "text_color");
// handle item click
view.setOnClickListener(new OnClickListener() {
@@ -1142,7 +891,6 @@ public class NavigationActivity extends Activity
final History history = mHistorySaved.get(count - index - 1);
navigateToHistory(history, true);
- mDrawerLayout.closeDrawer(Gravity.START);
}
});
@@ -1163,42 +911,15 @@ public class NavigationActivity extends Activity
}
/**
- * Show the easy mode view
- */
- private void performShowEasyMode() {
- mEasyModeListView.setVisibility(View.VISIBLE);
- getCurrentNavigationView().setVisibility(View.GONE);
- performShowBackArrow(false);
- }
-
- /**
- * Hide the easy mode view
- */
- private void performHideEasyMode() {
- mEasyModeListView.setVisibility(View.GONE);
- getCurrentNavigationView().setVisibility(View.VISIBLE);
- }
-
- private void performShowBackArrow(boolean showBackArrow) {
- if (mNeedsEasyMode) {
- mDrawerToggle.setDrawerIndicatorEnabled(!showBackArrow);
- }
- }
-
- private boolean isEasyModeVisible() {
- return mEasyModeListView.getVisibility() != View.GONE;
- }
-
- /**
* Method takes a bookmark as argument and adds it to the bookmark list in
* the drawer
*/
private void addBookmarkToDrawer(Bookmark bookmark) {
- Theme theme = ThemeManager.getCurrentTheme(this);
- IconHolder iconholder = new IconHolder(this, false);
+ Theme theme = ThemeManager.getCurrentTheme(getActivity());
+ IconHolder iconholder = new IconHolder(getActivity(), false);
// inflate single bookmark layout item and fill it
- LinearLayout view = (LinearLayout) getLayoutInflater().inflate(
+ LinearLayout view = (LinearLayout) mLayoutInflater.inflate(
R.layout.bookmarks_item, null);
ImageView icon = (ImageView) view
@@ -1211,8 +932,8 @@ public class NavigationActivity extends Activity
name.setText(bookmark.mName);
path.setText(bookmark.mPath);
- theme.setTextColor(this, name, "text_color");
- theme.setTextColor(this, path, "text_color");
+ theme.setTextColor(getActivity(), name, "text_color");
+ theme.setTextColor(getActivity(), path, "text_color");
icon.setImageDrawable(iconholder.getDrawable(BookmarksHelper
.getIcon(bookmark)));
@@ -1220,13 +941,13 @@ public class NavigationActivity extends Activity
Drawable action = null;
String actionCd = null;
if (bookmark.mType.compareTo(BOOKMARK_TYPE.HOME) == 0) {
- action = iconholder.getDrawable("ic_edit_home_bookmark_drawable"); //$NON-NLS-1$
- actionCd = getApplicationContext().getString(
+ action = iconholder.getDrawable("ic_config_drawable"); //$NON-NLS-1$
+ actionCd = getActivity().getApplicationContext().getString(
R.string.bookmarks_button_config_cd);
}
else if (bookmark.mType.compareTo(BOOKMARK_TYPE.USER_DEFINED) == 0) {
action = iconholder.getDrawable("ic_close_drawable"); //$NON-NLS-1$
- actionCd = getApplicationContext().getString(
+ actionCd = getActivity().getApplicationContext().getString(
R.string.bookmarks_button_remove_bookmark_cd);
}
@@ -1243,8 +964,9 @@ public class NavigationActivity extends Activity
if (bookmark.mType.compareTo(BOOKMARK_TYPE.HOME) == 0) {
// Show a dialog for configure initial directory
InitialDirectoryDialog dialog = new InitialDirectoryDialog(
- NavigationActivity.this);
- dialog.setOnValueChangedListener(new InitialDirectoryDialog.OnValueChangedListener() {
+ getActivity());
+ dialog.setOnValueChangedListener(
+ new InitialDirectoryDialog.OnValueChangedListener() {
@Override
public void onValueChanged(String newInitialDir) {
bookmark.mPath = newInitialDir;
@@ -1260,9 +982,9 @@ public class NavigationActivity extends Activity
// Remove bookmark
if (bookmark.mType.compareTo(BOOKMARK_TYPE.USER_DEFINED) == 0) {
boolean result = Bookmarks.removeBookmark(
- getApplicationContext(), bookmark);
+ getActivity().getApplicationContext(), bookmark);
if (!result) { // Show warning
- DialogHelper.showToast(getApplicationContext(),
+ DialogHelper.showToast(getActivity().getApplicationContext(),
R.string.msgs_operation_failure,
Toast.LENGTH_SHORT);
return;
@@ -1282,28 +1004,18 @@ public class NavigationActivity extends Activity
final int index = mDrawerBookmarks.indexOfChild(v);
final Bookmark bookmark = mBookmarks.get(index);
- boolean showEasyMode = (mSdBookmarks.contains(bookmark)) &&
- getResources().getBoolean(R.bool.cmcc_show_easy_mode);
-
// try to navigate to the bookmark path
try {
FileSystemObject fso = CommandHelper.getFileInfo(
- getApplicationContext(), bookmark.mPath, null);
+ getActivity().getApplicationContext(), bookmark.mPath, null);
if (fso != null) {
- if (showEasyMode) {
- performShowEasyMode();
- } else {
- performHideEasyMode();
- }
- performShowBackArrow(!mDrawerToggle.isDrawerIndicatorEnabled());
getCurrentNavigationView().open(fso);
- mDrawerLayout.closeDrawer(Gravity.START);
}
else {
// The bookmark does not exist, delete the user-defined
// bookmark
try {
- Bookmarks.removeBookmark(getApplicationContext(),
+ Bookmarks.removeBookmark(getActivity().getApplicationContext(),
bookmark);
// reset bookmarks list to default
@@ -1315,13 +1027,13 @@ public class NavigationActivity extends Activity
}
catch (Exception e) { // Capture the exception
ExceptionUtil
- .translateException(NavigationActivity.this, e);
+ .translateException(getActivity(), e);
if (e instanceof NoSuchFileOrDirectory
|| e instanceof FileNotFoundException) {
// The bookmark does not exist, delete the user-defined
// bookmark
try {
- Bookmarks.removeBookmark(getApplicationContext(),
+ Bookmarks.removeBookmark(getActivity().getApplicationContext(),
bookmark);
// reset bookmarks list to default
@@ -1342,16 +1054,18 @@ public class NavigationActivity extends Activity
* Method that initializes the bookmarks.
*/
private synchronized void initBookmarks() {
- if (mBookmarksTask != null &&
+ // TODO: Move into MainActivity or remove altogether.
+ /*if (mBookmarksTask != null &&
!mBookmarksTask.getStatus().equals(AsyncTask.Status.FINISHED)) {
return;
}
// Retrieve the loading view
- final View waiting = findViewById(R.id.bookmarks_loading);
+ final View waiting = mView.findViewById(
+ R.id.bookmarks_loading);
// Load bookmarks in background
- mBookmarksTask = new AsyncTask<Void, Void, Boolean>() {
+ mBookmarksTask = new android.os.AsyncTask<Void, Void, Boolean>() {
Exception mCause;
@Override
@@ -1383,8 +1097,7 @@ public class NavigationActivity extends Activity
}
else {
if (this.mCause != null) {
- ExceptionUtil.translateException(
- NavigationActivity.this, this.mCause);
+ ExceptionUtil.translateException(getActivity(), this.mCause);
}
}
mBookmarksTask = null;
@@ -1396,7 +1109,7 @@ public class NavigationActivity extends Activity
mBookmarksTask = null;
}
};
- mBookmarksTask.execute();
+ mBookmarksTask.execute(); */
}
/**
@@ -1439,7 +1152,7 @@ public class NavigationActivity extends Activity
} else {
if (this.mCause != null) {
ExceptionUtil.translateException(
- NavigationActivity.this, this.mCause);
+ getActivity(), this.mCause);
}
}
mHistoryTask = null;
@@ -1575,7 +1288,7 @@ public class NavigationActivity extends Activity
try {
// Recovery sdcards from storage manager
StorageVolume[] volumes = StorageHelper
- .getStorageVolumes(getApplication(), true);
+ .getStorageVolumes(getActivity().getApplication(), true);
for (StorageVolume volume: volumes) {
if (volume != null) {
String mountedState = volume.getState();
@@ -1590,10 +1303,12 @@ public class NavigationActivity extends Activity
Bookmark bookmark;
if (lowerPath.contains(STR_USB)) {
bookmark = new Bookmark(BOOKMARK_TYPE.USB, StorageHelper
- .getStorageVolumeDescription(getApplication(), volume), path);
+ .getStorageVolumeDescription(getActivity().getApplication(),
+ volume), path);
} else {
bookmark = new Bookmark(BOOKMARK_TYPE.SDCARD, StorageHelper
- .getStorageVolumeDescription(getApplication(), volume), path);
+ .getStorageVolumeDescription(getActivity().getApplication(),
+ volume), path);
}
bookmarks.add(bookmark);
}
@@ -1644,7 +1359,7 @@ public class NavigationActivity extends Activity
*/
private List<Bookmark> loadUserBookmarks() {
List<Bookmark> bookmarks = new ArrayList<Bookmark>();
- Cursor cursor = Bookmarks.getAllBookmarks(this.getContentResolver());
+ Cursor cursor = Bookmarks.getAllBookmarks(getActivity().getContentResolver());
try {
if (cursor != null && cursor.moveToFirst()) {
do {
@@ -1686,7 +1401,7 @@ public class NavigationActivity extends Activity
* Method that loads the history saved in database.
*/
private void loadHistory() {
- ContentResolver contentResolver = this.getContentResolver();
+ ContentResolver contentResolver = getContext().getContentResolver();
Cursor cursor = contentResolver.query(
History.Columns.CONTENT_URI,
History.Columns.HISTORY_QUERY_COLUMNS,
@@ -1725,7 +1440,7 @@ public class NavigationActivity extends Activity
values.put(History.Columns.TITLE, historyItem.getTitle());
values.put(History.Columns.DESCRIPTION, historyItem.getDescription());
- final Uri uri = getContentResolver()
+ final Uri uri = getContext().getContentResolver()
.insert(History.Columns.CONTENT_URI, values);
if ((int) ContentUris.parseId(uri) == -1) {
if (DEBUG) {
@@ -1741,7 +1456,7 @@ public class NavigationActivity extends Activity
* Method that clears the history database.
*/
private void deleteAllHistorys() {
- getContentResolver().delete(History.Columns.CONTENT_URI, "", null);
+ getContext().getContentResolver().delete(History.Columns.CONTENT_URI, "", null);
}
/**
@@ -1773,60 +1488,8 @@ public class NavigationActivity extends Activity
this.mNavigationViews = new NavigationView[1];
this.mCurrentNavigationView = 0;
//- 0
- this.mNavigationViews[0] = (NavigationView)findViewById(R.id.navigation_view);
+ this.mNavigationViews[0] = (NavigationView) mView.findViewById(R.id.navigation_view);
this.mNavigationViews[0].setId(0);
- this.mEasyModeListView = (ListView) findViewById(R.id.lv_easy_mode);
- mEasyModeAdapter = new ArrayAdapter<MimeTypeCategory>(this, R.layout
- .navigation_view_simple_item) {
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- convertView = (convertView == null) ?getLayoutInflater().inflate(R.layout
- .navigation_view_simple_item, parent, false) : convertView;
- MimeTypeCategory item = getItem(position);
- String typeTitle = MIME_TYPE_LOCALIZED_NAMES[item.ordinal()];
- TextView typeTitleTV = (TextView) convertView
- .findViewById(R.id.navigation_view_item_name);
- ImageView typeIconIV = (ImageView) convertView
- .findViewById(R.id.navigation_view_item_icon);
- View checkBoxView = convertView.findViewById(R.id.navigation_view_item_check);
- checkBoxView.setVisibility(View.GONE);
- typeTitleTV.setText(typeTitle);
- typeIconIV.setImageDrawable(EASY_MODE_ICONS.get(item));
- convertView.setOnClickListener(mEasyModeItemClickListener);
- convertView.setTag(position);
- return convertView;
- }
- };
- mEasyModeAdapter.addAll(EASY_MODE_LIST);
- mEasyModeListView.setAdapter(mEasyModeAdapter);
- }
-
- private void onClicked(int position) {
- Intent intent = new Intent(this, SearchActivity.class);
- intent.setAction(Intent.ACTION_SEARCH);
- intent.putExtra(SearchActivity.EXTRA_SEARCH_DIRECTORY,
- getCurrentNavigationView().getCurrentDir());
- intent.putExtra(SearchManager.QUERY, "*"); // Use wild-card '*'
-
- if (position == 0) {
- // the user has selected all items, they want to see their folders so let's do that.
- performHideEasyMode();
- performShowBackArrow(true);
- return;
-
- } else {
- ArrayList<MimeTypeCategory> searchCategories = new ArrayList<MimeTypeCategory>();
- MimeTypeCategory selectedCategory = EASY_MODE_LIST.get(position);
- searchCategories.add(selectedCategory);
- // a one off case where we implicitly want to also search for TEXT mimetypes when the
- // DOCUMENTS category is selected
- if (selectedCategory == MimeTypeCategory.DOCUMENT) {
- searchCategories.add(MimeTypeCategory.TEXT);
- }
- intent.putExtra(SearchActivity.EXTRA_SEARCH_MIMETYPE, searchCategories);
- }
-
- startActivity(intent);
}
/**
@@ -1836,18 +1499,18 @@ public class NavigationActivity extends Activity
void initConsole() {
//Create the default console (from the preferences)
try {
- Console console = ConsoleBuilder.getConsole(NavigationActivity.this);
+ Console console = ConsoleBuilder.getConsole(getActivity());
if (console == null) {
throw new ConsoleAllocException("console == null"); //$NON-NLS-1$
}
} catch (Throwable ex) {
- if (!NavigationActivity.this.mChRooted) {
+ if (!NavigationFragment.this.mChRooted) {
//Show exception and exit
Log.e(TAG, getString(R.string.msgs_cant_create_console), ex);
// We don't have any console
// Show exception and exit
DialogHelper.showToast(
- NavigationActivity.this,
+ getActivity(),
R.string.msgs_cant_create_console, Toast.LENGTH_LONG);
exit();
return;
@@ -1902,19 +1565,8 @@ public class NavigationActivity extends Activity
// Check if request navigation to directory (use as default), and
// ensure chrooted and absolute path
String navigateTo = intent.getStringExtra(EXTRA_NAVIGATE_TO);
- String intentAction = intent.getAction();
if (navigateTo != null && navigateTo.length() > 0) {
initialDir = navigateTo;
- } else if (intentAction != null && intentAction.equals(Intent.ACTION_VIEW)) {
- Uri data = intent.getData();
- if (data != null && (FileHelper.FILE_URI_SCHEME.equals(data.getScheme())
- || FileHelper.FOLDER_URI_SCHEME.equals(data.getScheme())
- || FileHelper.DIRECTORY_URI_SCHEME.equals(data.getScheme()))) {
- File path = new File(data.getPath());
- if (path.isDirectory()) {
- initialDir = path.getAbsolutePath();
- }
- }
}
// Add to history
@@ -1930,23 +1582,15 @@ public class NavigationActivity extends Activity
// Initial directory is the first external sdcard (sdcard, emmc, usb, ...)
if (!StorageHelper.isPathInStorageVolume(initialDir)) {
StorageVolume[] volumes =
- StorageHelper.getStorageVolumes(this, false);
+ StorageHelper.getStorageVolumes(getActivity(), false);
if (volumes != null && volumes.length > 0) {
initialDir = volumes[0].getPath();
- int count = volumes.length;
- for (int i = 0; i < count; i++) {
- StorageVolume volume = volumes[i];
- if (Environment.MEDIA_MOUNTED.equalsIgnoreCase(volume.getState())) {
- initialDir = volume.getPath();
- break;
- }
- }
//Ensure that initial directory is an absolute directory
initialDir = FileHelper.getAbsPath(initialDir);
} else {
// Show exception and exit
DialogHelper.showToast(
- this,
+ getActivity(),
R.string.msgs_cant_create_console, Toast.LENGTH_LONG);
exit();
return;
@@ -1962,33 +1606,37 @@ public class NavigationActivity extends Activity
if (!exists) {
// Fix for /data/media/0. Libcore doesn't detect it correctly.
try {
- exists = CommandHelper.getFileInfo(this, initialDir, false, null) != null;
+ exists = CommandHelper.getFileInfo(getActivity(),
+ initialDir, false, null) != null;
} catch (InsufficientPermissionsException ipex) {
ExceptionUtil.translateException(
- this, ipex, false, true, new OnRelaunchCommandResult() {
- @Override
- public void onSuccess() {
- navigationView.changeCurrentDir(absInitialDir, addToHistory);
- }
- @Override
- public void onFailed(Throwable cause) {
- showInitialInvalidDirectoryMsg(userInitialDir);
- navigationView.changeCurrentDir(FileHelper.ROOT_DIRECTORY,
- addToHistory);
- }
- @Override
- public void onCancelled() {
- showInitialInvalidDirectoryMsg(userInitialDir);
- navigationView.changeCurrentDir(FileHelper.ROOT_DIRECTORY,
- addToHistory);
- }
- });
+ getActivity(), ipex, false, true,
+ new ExceptionUtil.OnRelaunchCommandResult() {
+ @Override
+ public void onSuccess() {
+ navigationView.changeCurrentDir(absInitialDir, addToHistory);
+ }
+ @Override
+ public void onFailed(Throwable cause) {
+ showInitialInvalidDirectoryMsg(userInitialDir);
+ navigationView.changeCurrentDir(
+ FileHelper.ROOT_DIRECTORY,
+ addToHistory);
+ }
+ @Override
+ public void onCancelled() {
+ showInitialInvalidDirectoryMsg(userInitialDir);
+ navigationView.changeCurrentDir(
+ FileHelper.ROOT_DIRECTORY,
+ addToHistory);
+ }
+ });
// Asynchronous mode
return;
} catch (Exception ex) {
// We are not interested in other exceptions
- ExceptionUtil.translateException(this, ex, true, false);
+ ExceptionUtil.translateException(getActivity(), ex, true, false);
}
// Check again the initial directory
@@ -2001,24 +1649,6 @@ public class NavigationActivity extends Activity
}
}
- boolean needsEasyMode = false;
- if (mSdBookmarks != null ) {
- for (Bookmark bookmark :mSdBookmarks) {
- if (bookmark.mPath.equalsIgnoreCase(initialDir)) {
- needsEasyMode = true;
- break;
- }
- }
- }
-
- mNeedsEasyMode = getResources().getBoolean(R.bool.cmcc_show_easy_mode);
-
- needsEasyMode = needsEasyMode && mNeedsEasyMode;
- if (needsEasyMode) {
- performShowEasyMode();
- } else {
- performHideEasyMode();
- }
// Change the current directory to the user-defined initial directory
navigationView.changeCurrentDir(initialDir, addToHistory);
}
@@ -2032,7 +1662,7 @@ public class NavigationActivity extends Activity
void showInitialInvalidDirectoryMsg(String initialDir) {
// Change to root directory
DialogHelper.showToast(
- this,
+ getActivity(),
getString(
R.string.msgs_settings_invalid_initial_directory,
initialDir),
@@ -2049,7 +1679,7 @@ public class NavigationActivity extends Activity
void checkIntent(Intent intent) {
//Search action
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
- Intent searchIntent = new Intent(this, SearchActivity.class);
+ Intent searchIntent = new Intent(getActivity(), SearchActivity.class);
searchIntent.setAction(Intent.ACTION_SEARCH);
//- SearchActivity.EXTRA_SEARCH_DIRECTORY
searchIntent.putExtra(
@@ -2082,134 +1712,7 @@ public class NavigationActivity extends Activity
* {@inheritDoc}
*/
@Override
- public boolean onKeyUp(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_MENU) {
- if (mDrawerLayout != null) {
- if (mDrawerLayout.isDrawerOpen(mDrawer)) {
- mDrawerLayout.closeDrawer(Gravity.START);
- } else {
- mDrawerLayout.openDrawer(Gravity.START);
- }
- }
- return true;
- }
- return super.onKeyUp(keyCode, event);
- }
-
- @Override
- public void onBackPressed() {
- if (mDrawerLayout != null && mDrawerLayout.isDrawerOpen(Gravity.START)) {
- mDrawerLayout.closeDrawer(Gravity.START);
- return;
- }
-
- boolean upToParent = mHistory != null && mHistory.size() > 0;
-
- if (mNeedsEasyMode && !isEasyModeVisible() && !upToParent) {
- performShowEasyMode();
- return;
- } else {
- if (checkBackAction()) {
- return;
- }
- }
-
- // An exit event has occurred, force the destroy the consoles
- exit();
- }
-
- /**
- * Method invoked when an action item is clicked.
- *
- * @param view The button pushed
- */
- public void onActionBarItemClick(View view) {
- switch (view.getId()) {
- //######################
- //Navigation Custom Title
- //######################
- case R.id.ab_configuration:
- //Show navigation view configuration toolbar
- getCurrentNavigationView().getCustomTitle().showConfigurationView();
- break;
- case R.id.ab_close:
- //Hide navigation view configuration toolbar
- getCurrentNavigationView().getCustomTitle().hideConfigurationView();
- break;
-
- //######################
- //Breadcrumb Actions
- //######################
- case R.id.ab_filesystem_info:
- //Show information of the filesystem
- MountPoint mp = getCurrentNavigationView().getBreadcrumb().getMountPointInfo();
- DiskUsage du = getCurrentNavigationView().getBreadcrumb().getDiskUsageInfo();
- showMountPointInfo(mp, du);
- break;
-
- //######################
- //Navigation view options
- //######################
- case R.id.ab_sort_mode:
- showSettingsPopUp(view,
- Arrays.asList(
- new FileManagerSettings[]{
- FileManagerSettings.SETTINGS_SORT_MODE}));
- break;
- case R.id.ab_layout_mode:
- showSettingsPopUp(view,
- Arrays.asList(
- new FileManagerSettings[]{
- FileManagerSettings.SETTINGS_LAYOUT_MODE}));
- break;
- case R.id.ab_view_options:
- // If we are in ChRooted mode, then don't show non-secure items
- if (this.mChRooted) {
- showSettingsPopUp(view,
- Arrays.asList(new FileManagerSettings[]{
- FileManagerSettings.SETTINGS_SHOW_DIRS_FIRST}));
- } else {
- showSettingsPopUp(view,
- Arrays.asList(new FileManagerSettings[]{
- FileManagerSettings.SETTINGS_SHOW_DIRS_FIRST,
- FileManagerSettings.SETTINGS_SHOW_HIDDEN,
- FileManagerSettings.SETTINGS_SHOW_SYSTEM,
- FileManagerSettings.SETTINGS_SHOW_SYMLINKS}));
- }
-
- break;
-
- //######################
- //Selection Actions
- //######################
- case R.id.ab_selection_done:
- //Show information of the filesystem
- getCurrentNavigationView().onDeselectAll();
- break;
-
- //######################
- //Action Bar buttons
- //######################
- case R.id.ab_actions:
- openActionsDialog(getCurrentNavigationView().getCurrentDir(),
- true);
- break;
-
- case R.id.ab_search:
-
- openSearch();
- break;
-
- default:
- break;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == INTENT_REQUEST_SETTINGS) {
// reset bookmarks list to default as the user could changed the
// root mode which changes the system bookmarks
@@ -2220,7 +1723,7 @@ public class NavigationActivity extends Activity
if (data != null) {
switch (requestCode) {
case INTENT_REQUEST_SEARCH:
- if (resultCode == RESULT_OK) {
+ if (resultCode == getActivity().RESULT_OK) {
//Change directory?
Bundle bundle = data.getExtras();
if (bundle != null) {
@@ -2231,11 +1734,10 @@ public class NavigationActivity extends Activity
if (fso != null) {
//Goto to new directory
getCurrentNavigationView().open(fso, searchInfo);
- performHideEasyMode();
mDisplayingSearchResults = true;
}
}
- } else if (resultCode == RESULT_CANCELED) {
+ } else if (resultCode == getActivity().RESULT_CANCELED) {
SearchInfoParcelable searchInfo =
data.getParcelableExtra(EXTRA_SEARCH_LAST_SEARCH_DATA);
if (searchInfo != null && searchInfo.isSuccessNavigation()) {
@@ -2261,7 +1763,7 @@ public class NavigationActivity extends Activity
getCurrentNavigationView().onRequestSelectedFiles();
if (!TextUtils.isEmpty(destination)) {
CopyMoveActionPolicy.copyFileSystemObjects(
- this,
+ getActivity(),
selection,
destination,
getCurrentNavigationView(),
@@ -2279,7 +1781,7 @@ public class NavigationActivity extends Activity
getCurrentNavigationView().onRequestSelectedFiles();
if (!TextUtils.isEmpty(destination)) {
CopyMoveActionPolicy.moveFileSystemObjects(
- this,
+ getActivity(),
selection,
destination,
getCurrentNavigationView(),
@@ -2404,12 +1906,12 @@ public class NavigationActivity extends Activity
* @param anchor The action button that was pressed
* @param settings The array of settings associated with the action button
*/
- private void showSettingsPopUp(View anchor, List<FileManagerSettings> settings) {
+ public void showSettingsPopUp(View anchor, List<FileManagerSettings> settings) {
//Create the adapter
- final MenuSettingsAdapter adapter = new MenuSettingsAdapter(this, settings);
+ final MenuSettingsAdapter adapter = new MenuSettingsAdapter(getActivity(), settings);
//Create a show the popup menu
- mPopupWindow = DialogHelper.createListPopupWindow(this, adapter, anchor);
+ mPopupWindow = DialogHelper.createListPopupWindow(getActivity(), adapter, anchor);
mPopupWindow.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
@@ -2446,11 +1948,11 @@ public class NavigationActivity extends Activity
}
} catch (Exception e) {
Log.e(TAG, "Error applying navigation option", e); //$NON-NLS-1$
- NavigationActivity.this.mHandler.post(new Runnable() {
+ NavigationFragment.this.mHandler.post(new Runnable() {
@Override
public void run() {
DialogHelper.showToast(
- NavigationActivity.this,
+ getActivity(),
R.string.msgs_settings_save_failure, Toast.LENGTH_SHORT);
}
});
@@ -2478,21 +1980,21 @@ public class NavigationActivity extends Activity
* @param mp The mount point info
* @param du The disk usage of the mount point
*/
- private void showMountPointInfo(MountPoint mp, DiskUsage du) {
+ public void showMountPointInfo(MountPoint mp, DiskUsage du) {
//Has mount point info?
if (mp == null) {
//There is no information
AlertDialog alert =
DialogHelper.createWarningDialog(
- this,
+ getActivity(),
R.string.filesystem_info_warning_title,
R.string.filesystem_info_warning_msg);
- DialogHelper.delegateDialogShow(this, alert);
+ DialogHelper.delegateDialogShow(getActivity(), alert);
return;
}
//Show a the filesystem info dialog
- FilesystemInfoDialog dialog = new FilesystemInfoDialog(this, mp, du);
+ FilesystemInfoDialog dialog = new FilesystemInfoDialog(getActivity(), mp, du);
dialog.setOnMountListener(new OnMountListener() {
@Override
public void onRemount(MountPoint mountPoint) {
@@ -2506,7 +2008,7 @@ public class NavigationActivity extends Activity
// to a secure storage (do not add to history)
Intent intent = new Intent();
intent.putExtra(EXTRA_ADD_TO_HISTORY, false);
- initNavigation(NavigationActivity.this.mCurrentNavigationView, false, intent);
+ initNavigation(NavigationFragment.this.mCurrentNavigationView, false, intent);
}
}
});
@@ -2548,12 +2050,8 @@ public class NavigationActivity extends Activity
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(this, R.string.msgs_push_again_to_exit, Toast.LENGTH_SHORT);
- if (mNeedsEasyMode) {
- return isEasyModeVisible();
- } else {
- return true;
- }
+ DialogHelper.showToast(getActivity(), R.string.msgs_push_again_to_exit,
+ Toast.LENGTH_SHORT);
}
//Back action not applied
@@ -2618,20 +2116,16 @@ public class NavigationActivity extends Activity
} else if (realHistory.getItem() instanceof SearchInfoParcelable) {
//Search (open search with the search results)
SearchInfoParcelable info = (SearchInfoParcelable)realHistory.getItem();
- Intent searchIntent = new Intent(this, SearchActivity.class);
+ Intent searchIntent = new Intent(getActivity(), SearchActivity.class);
searchIntent.setAction(SearchActivity.ACTION_RESTORE);
searchIntent.putExtra(SearchActivity.EXTRA_SEARCH_RESTORE, (Parcelable)info);
startActivityForResult(searchIntent, INTENT_REQUEST_SEARCH);
} else if (realHistory.getItem() instanceof HistoryItem) {
final String path = realHistory.getItem().getDescription();
final FileSystemObject fso = CommandHelper.getFileInfo(
- getApplicationContext(), path, null);
+ getActivity().getApplicationContext(), path, null);
if (fso != null) {
- performHideEasyMode();
- performShowBackArrow(
- !mDrawerToggle.isDrawerIndicatorEnabled());
getCurrentNavigationView().open(fso);
- mDrawerLayout.closeDrawer(Gravity.START);
}
} else {
//The type is unknown
@@ -2668,7 +2162,7 @@ public class NavigationActivity extends Activity
@Override
public void run() {
DialogHelper.showToast(
- NavigationActivity.this,
+ getActivity(),
R.string.msgs_history_unknown, Toast.LENGTH_LONG);
}
});
@@ -2692,13 +2186,13 @@ public class NavigationActivity extends Activity
String path = ((NavigationViewInfoParcelable)h.getItem()).getCurrentDir();
try {
- FileSystemObject info = CommandHelper.getFileInfo(this, path, null);
+ FileSystemObject info = CommandHelper.getFileInfo(getActivity(), path, null);
if (info != null) {
break;
}
this.mHistory.remove(this.mHistory.size() - 1);
} catch (Exception e) {
- ExceptionUtil.translateException(this, e, true, false);
+ ExceptionUtil.translateException(getActivity(), e, true, false);
this.mHistory.remove(this.mHistory.size() - 1);
}
} else {
@@ -2716,17 +2210,17 @@ public class NavigationActivity extends Activity
return false;
}
- private void openActionsDialog(String path, boolean global) {
+ public void openActionsDialog(String path, boolean global) {
FileSystemObject fso = null;
try {
- fso = CommandHelper.getFileInfo(this, path, false, null);
+ 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(this, e);
+ ExceptionUtil.translateException(getActivity(), e);
// Remove the object
if (e instanceof FileNotFoundException || e instanceof NoSuchFileOrDirectory) {
@@ -2753,7 +2247,7 @@ public class NavigationActivity extends Activity
if (mActionsDialog != null && mActionsDialog.isShowing()) {
return;
}
- mActionsDialog = new ActionsDialog(this, this, item, global, false);
+ mActionsDialog = new ActionsDialog(getActivity(), this, item, global, false);
mActionsDialog.setOnRequestRefreshListener(this);
mActionsDialog.setOnSelectionListener(getCurrentNavigationView());
mActionsDialog.show();
@@ -2764,7 +2258,7 @@ public class NavigationActivity extends Activity
*
* @hide
*/
- void openSearch() {
+ public void openSearch() {
mSearchView.setVisibility(View.VISIBLE);
mSearchView.onActionViewExpanded();
mCustomTitleView.setVisibility(View.GONE);
@@ -2782,7 +2276,7 @@ public class NavigationActivity extends Activity
* @hide
*/
void openSettings() {
- Intent settingsIntent = new Intent(NavigationActivity.this,
+ Intent settingsIntent = new Intent(getActivity(),
SettingsPreferences.class);
startActivityForResult(settingsIntent, INTENT_REQUEST_SETTINGS);
}
@@ -2829,7 +2323,7 @@ public class NavigationActivity extends Activity
//Show a dialog asking the user
AlertDialog dialog =
DialogHelper.createYesNoDialog(
- this,
+ getActivity(),
R.string.msgs_change_to_prompt_access_mode_title,
R.string.msgs_change_to_prompt_access_mode_msg,
new DialogInterface.OnClickListener() {
@@ -2839,7 +2333,7 @@ public class NavigationActivity extends Activity
// We don't have any console
// Show exception and exit
DialogHelper.showToast(
- NavigationActivity.this,
+ getActivity(),
R.string.msgs_cant_create_console, Toast.LENGTH_LONG);
exit();
return;
@@ -2849,7 +2343,7 @@ public class NavigationActivity extends Activity
// here is a fatal error. We won't have any console to operate.
try {
// Change console
- ConsoleBuilder.changeToNonPrivilegedConsole(NavigationActivity.this);
+ ConsoleBuilder.changeToNonPrivilegedConsole(getActivity());
// Save preferences
Preferences.savePreference(
@@ -2860,13 +2354,13 @@ public class NavigationActivity extends Activity
// Displays an exception and exit
Log.e(TAG, getString(R.string.msgs_cant_create_console), e);
DialogHelper.showToast(
- NavigationActivity.this,
+ getActivity(),
R.string.msgs_cant_create_console, Toast.LENGTH_LONG);
exit();
}
}
- });
- DialogHelper.delegateDialogShow(this, dialog);
+ });
+ DialogHelper.delegateDialogShow(getActivity(), dialog);
}
/**
@@ -2914,7 +2408,7 @@ public class NavigationActivity extends Activity
* @hide
*/
void exit() {
- finish();
+ getActivity().finish();
}
private void recycle() {
@@ -2941,86 +2435,69 @@ public class NavigationActivity extends Activity
* Method that reconfigures the layout for better fit in portrait and landscape modes
*/
private void onLayoutChanged() {
- Theme theme = ThemeManager.getCurrentTheme(this);
- boolean drawerOpen = mDrawerLayout.isDrawerOpen(Gravity.START);
-
// Apply only when the orientation was changed
int orientation = getResources().getConfiguration().orientation;
if (this.mOrientation == orientation) return;
this.mOrientation = orientation;
- // imitate a closed drawer while layout is rebuilt to avoid NullPointerException
- if (drawerOpen) {
- mDrawerLayout.closeDrawer(Gravity.START);
- }
-
- if (this.mOrientation == Configuration.ORIENTATION_LANDSCAPE) {
- // Landscape mode
- ViewGroup statusBar = (ViewGroup)findViewById(R.id.navigation_statusbar);
- if (statusBar.getParent() != null) {
- ViewGroup parent = (ViewGroup) statusBar.getParent();
- parent.removeView(statusBar);
+ // Portrait mode
+ if (mStatusBar != null) {
+ if (mStatusBar.getParent() != null) {
+ ViewGroup parent = (ViewGroup) mStatusBar.getParent();
+ parent.removeView(mStatusBar);
}
-
- // 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 = statusBar.getChildCount();
- for (int i = 0; i < cc; i++) {
- View child = statusBar.getChildAt(i);
- if (child instanceof ButtonItem) {
- rbw += bw;
+ 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;
+ // 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);
- // Add to the new location
- ViewGroup newParent = (ViewGroup)findViewById(R.id.navigation_title_landscape_holder);
- LinearLayout.LayoutParams params =
- new LinearLayout.LayoutParams(
- w,
- ViewGroup.LayoutParams.MATCH_PARENT);
- statusBar.setLayoutParams(params);
- newParent.addView(statusBar);
-
- // Apply theme
- theme.setBackgroundDrawable(this, statusBar, "titlebar_drawable"); //$NON-NLS-1$
+ } 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);
- // Hide holder
- View holder = findViewById(R.id.navigation_statusbar_portrait_holder);
- holder.setVisibility(View.GONE);
+ // Apply theme
+ mStatusBar.setBackgroundResource(R.drawable.statusbar_drawable);
- } else {
- // Portrait mode
- ViewGroup statusBar = (ViewGroup)findViewById(R.id.navigation_statusbar);
- if (statusBar.getParent() != null) {
- ViewGroup parent = (ViewGroup) statusBar.getParent();
- parent.removeView(statusBar);
+ // Show holder
+ newParent.setVisibility(View.VISIBLE);
}
-
- // Add to the new location
- ViewGroup newParent = (ViewGroup)findViewById(
- R.id.navigation_statusbar_portrait_holder);
- LinearLayout.LayoutParams params =
- new LinearLayout.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT);
- statusBar.setLayoutParams(params);
- newParent.addView(statusBar);
-
- // Apply theme
- theme.setBackgroundDrawable(this, statusBar, "statusbar_drawable"); //$NON-NLS-1$
-
- // Show holder
- newParent.setVisibility(View.VISIBLE);
}
- // if drawer was open, imitate reopening
- if (drawerOpen) {
- mDrawerToggle.onDrawerOpened(mDrawer);
- }
}
/**
@@ -3038,12 +2515,9 @@ public class NavigationActivity extends Activity
navigableInfo.getCurrentDir());
if (vc != null && !vc.isMounted()) {
mHistory.remove(i);
- mDrawerHistory.removeViewAt(mDrawerHistory.getChildCount() - i - 1);
}
}
}
- mDrawerHistoryEmpty.setVisibility(
- mDrawerHistory.getChildCount() == 0 ? View.VISIBLE : View.GONE);
updateHistoryPositions();
}
@@ -3063,25 +2537,15 @@ public class NavigationActivity extends Activity
*/
void applyTheme() {
int orientation = getResources().getConfiguration().orientation;
- Theme theme = ThemeManager.getCurrentTheme(this);
- theme.setBaseThemeNoActionBar(this);
+ Theme theme = ThemeManager.getCurrentTheme(getActivity());
applyTabTheme();
- // imitate a closed drawer while layout is rebuilt to avoid NullPointerException
- boolean drawerOpen = mDrawerLayout.isDrawerOpen(Gravity.START);
- if (drawerOpen) {
- mDrawerLayout.closeDrawer(Gravity.START);
- }
-
//- Layout
- View v = findViewById(R.id.navigation_layout);
- theme.setBackgroundDrawable(this, v, "background_drawable"); //$NON-NLS-1$
-
- //- ActionBar
- theme.setTitlebarDrawable(this, getActionBar(), "titlebar_drawable"); //$NON-NLS-1$
+ View navLayout = mView.findViewById(R.id.navigation_layout);
+ navLayout.setBackgroundResource(R.drawable.background_drawable);
// Hackery to theme search view
- mSearchView = (SearchView) findViewById(R.id.navigation_search_bar);
+ mSearchView = (SearchView) mTitleLayout.findViewById(R.id.navigation_search_bar);
int searchPlateId = mSearchView.getContext().getResources()
.getIdentifier("android:id/search_plate", null, null);
View searchPlate = mSearchView.findViewById(searchPlateId);
@@ -3101,70 +2565,59 @@ public class NavigationActivity extends Activity
}
}
- SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
- mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
+ SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context
+ .SEARCH_SERVICE);
+ mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity()
+ .getComponentName()));
mSearchView.setIconifiedByDefault(false);
- mCustomTitleView = (NavigationCustomTitleView) findViewById(R.id.navigation_title_flipper);
+ mCustomTitleView = (NavigationCustomTitleView) mTitleLayout.findViewById(
+ R.id.navigation_title_flipper);
mCustomTitleView.setVisibility(View.VISIBLE);
//- StatusBar
- v = findViewById(R.id.navigation_statusbar);
+ mStatusBar = mView.findViewById(R.id.navigation_statusbar);
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
- theme.setBackgroundDrawable(this, v, "titlebar_drawable"); //$NON-NLS-1$
+ mStatusBar.setBackgroundResource(R.drawable.titlebar_drawable);
} else {
- theme.setBackgroundDrawable(this, v, "statusbar_drawable"); //$NON-NLS-1$
+ mStatusBar.setBackgroundResource(R.drawable.statusbar_drawable);
}
- v = findViewById(R.id.ab_overflow);
- theme.setImageDrawable(this, (ImageView)v, "ab_overflow_drawable"); //$NON-NLS-1$
- v = findViewById(R.id.ab_actions);
- theme.setImageDrawable(this, (ImageView)v, "ab_actions_drawable"); //$NON-NLS-1$
- v = findViewById(R.id.ab_search);
- theme.setImageDrawable(this, (ImageView)v, "ab_search_drawable"); //$NON-NLS-1$
+ 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 = findViewById(R.id.ab_configuration);
- theme.setImageDrawable(this, (ImageView)v, "expander_open_drawable"); //$NON-NLS-1$
- v = findViewById(R.id.ab_close);
- theme.setImageDrawable(this, (ImageView)v, "expander_close_drawable"); //$NON-NLS-1$
- v = findViewById(R.id.ab_sort_mode);
- theme.setImageDrawable(this, (ImageView)v, "ab_sort_mode_drawable"); //$NON-NLS-1$
- v = findViewById(R.id.ab_layout_mode);
- theme.setImageDrawable(this, (ImageView)v, "ab_layout_mode_drawable"); //$NON-NLS-1$
- v = findViewById(R.id.ab_view_options);
- theme.setImageDrawable(this, (ImageView)v, "ab_view_options_drawable"); //$NON-NLS-1$
+ 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 = findViewById(R.id.navigation_selectionbar);
- theme.setBackgroundDrawable(this, v, "selectionbar_drawable"); //$NON-NLS-1$
- v = findViewById(R.id.ab_selection_done);
- theme.setImageDrawable(this, (ImageView)v, "ab_selection_done_drawable"); //$NON-NLS-1$
- v = findViewById(R.id.navigation_status_selection_label);
- theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
-
- // - Navigation drawer
- v = findViewById(R.id.history_empty);
- theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
-
- for (int i=0; i<mDrawerHistory.getChildCount(); i++) {
- View item = mDrawerHistory.getChildAt(i);
-
- v = item.findViewById(R.id.history_item_name);
- theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
- v = item.findViewById(R.id.history_item_directory);
- theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
- }
+ v = 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$
//- NavigationView
int cc = this.mNavigationViews.length;
for (int i = 0; i < cc; i++) {
getNavigationView(i).applyTheme();
}
-
- // if drawer was open, imitate reopening
- if (drawerOpen) {
- mDrawerToggle.onDrawerOpened(mDrawer);
- }
}
/**
@@ -3172,20 +2625,7 @@ public class NavigationActivity extends Activity
*/
private void applyTabTheme() {
// Apply the theme
- Theme theme = ThemeManager.getCurrentTheme(this);
-
- View v = findViewById(R.id.drawer);
- theme.setBackgroundDrawable(this, v, "background_drawable"); //$NON-NLS-1$
-
- v = findViewById(R.id.drawer_bookmarks_tab);
- theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
- v = findViewById(R.id.drawer_history_tab);
- theme.setTextColor(this, (TextView)v, "text_color"); //$NON-NLS-1$
-
- v = findViewById(R.id.ab_settings);
- theme.setImageDrawable(this, (ButtonItem) v, "ab_settings_drawable"); //$NON-NLS-1$
- v = findViewById(R.id.ab_clear_history);
- theme.setImageDrawable(this, (ButtonItem) v, "ab_delete_drawable"); //$NON-NLS-1$
+ Theme theme = ThemeManager.getCurrentTheme(getActivity());
}
public void updateActiveDialog(Dialog dialog) {
diff --git a/src/com/cyanogenmod/filemanager/ui/widgets/ScrimInsetsFrameLayout.java b/src/com/cyanogenmod/filemanager/ui/widgets/ScrimInsetsFrameLayout.java
index 56741558..957419f7 100644
--- a/src/com/cyanogenmod/filemanager/ui/widgets/ScrimInsetsFrameLayout.java
+++ b/src/com/cyanogenmod/filemanager/ui/widgets/ScrimInsetsFrameLayout.java
@@ -58,7 +58,7 @@ public class ScrimInsetsFrameLayout extends FrameLayout {
if (a == null) {
return;
}
- mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForeground);
+ mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_scrimInsetForeground);
a.recycle();
setWillNotDraw(true);
diff --git a/src/com/cyanogenmod/filemanager/ui/widgets/WrappedGridView.java b/src/com/cyanogenmod/filemanager/ui/widgets/WrappedGridView.java
new file mode 100644
index 00000000..0c866371
--- /dev/null
+++ b/src/com/cyanogenmod/filemanager/ui/widgets/WrappedGridView.java
@@ -0,0 +1,38 @@
+package com.cyanogenmod.filemanager.ui.widgets;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.ViewGroup;
+import android.widget.GridView;
+
+/**
+ * Use this class when you want a gridview that doesn't scroll and automatically
+ * wraps to the height of its contents
+ * Concept from:
+ * stackoverflow.com/questions/20561663/gridview-show-according-to-actual-height-within-scroll-view
+ * Created By user: LongwayTo http://stackoverflow.com/users/3106513/longwayto
+ */
+public class WrappedGridView extends GridView {
+ public WrappedGridView(Context context) {
+ super(context);
+ }
+
+ public WrappedGridView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public WrappedGridView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ // Calculate entire height by providing a very large height hint.
+ // View.MEASURED_SIZE_MASK represents the largest height possible.
+ int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK, MeasureSpec.AT_MOST);
+ super.onMeasure(widthMeasureSpec, expandSpec);
+
+ ViewGroup.LayoutParams params = getLayoutParams();
+ params.height = getMeasuredHeight();
+ }
+}
diff --git a/src/com/cyanogenmod/filemanager/util/DialogHelper.java b/src/com/cyanogenmod/filemanager/util/DialogHelper.java
index d357d1b3..c1dd48a2 100644
--- a/src/com/cyanogenmod/filemanager/util/DialogHelper.java
+++ b/src/com/cyanogenmod/filemanager/util/DialogHelper.java
@@ -37,7 +37,7 @@ import android.widget.TextView;
import android.widget.Toast;
import com.cyanogenmod.filemanager.R;
-import com.cyanogenmod.filemanager.activities.NavigationActivity;
+import com.cyanogenmod.filemanager.activities.MainActivity;
import com.cyanogenmod.filemanager.adapters.CheckableListAdapter;
import com.cyanogenmod.filemanager.ui.ThemeManager;
import com.cyanogenmod.filemanager.ui.ThemeManager.Theme;
@@ -600,8 +600,8 @@ public final class DialogHelper {
boolean isActivityFinishing = false;
if (context instanceof Activity) {
Activity activity = (Activity) context;
- if (activity instanceof NavigationActivity) {
- ((NavigationActivity) activity).updateActiveDialog(dialog);
+ if (activity instanceof MainActivity) {
+ ((MainActivity) activity).updateActiveDialog(dialog);
}
isActivityFinishing = activity.isFinishing();
}