Browse Source

Significant progress on various things

Mario Danic 8 years ago
parent
commit
b0835b981f

+ 2 - 2
build.gradle

@@ -29,7 +29,7 @@ configurations.all {
 }
 
 ext {
-    supportLibraryVersion = '24.0.0'
+    supportLibraryVersion = '25.2.0'
 
     travisBuild = System.getenv("TRAVIS") == "true"
 
@@ -199,7 +199,7 @@ dependencies {
     androidTestCompile 'com.android.support.test:runner:0.5'
 
     // Android Annotation Support
-    androidTestCompile "com.android.support:support-annotations:25.0.0"
+    androidTestCompile "com.android.support:support-annotations:25.2.0"
 
     // Espresso core
     androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'

+ 4 - 2
src/custom/res/values/setup.xml

@@ -84,6 +84,8 @@
     <!--Destination mail for sending log files -->
     <string name="mail_logger"></string>
 
+    <!-- Determine is participate enabled -->
+    <bool name="participate_enabled">false</bool>
     <!-- Participate links -->
     <string name="fdroid_beta_link" translatable="false">https://f-droid.org/repository/browse/?fdid=com.nextcloud.android.beta</string>
     <string name="beta_apk_link" translatable="false">https://github.com/nextcloud/android/raw/beta/apks/latest.apk</string>
@@ -101,8 +103,8 @@
     <!-- analytics enabled -->
     <bool name="analytics_enabled">false</bool>
 
-    <!-- custom Files title -->
-    <string name="custom_files_title" translatable="true">Home</string>
+    <!-- Files becomes Home -->
+    <bool name="use_home">true</bool>
 
 </resources>
 

+ 47 - 5
src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java

@@ -35,7 +35,6 @@ import android.support.design.widget.NavigationView;
 import android.support.v4.view.GravityCompat;
 import android.support.v4.widget.DrawerLayout;
 import android.support.v7.app.ActionBarDrawerToggle;
-import android.text.TextUtils;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
@@ -57,10 +56,13 @@ import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.resources.files.SearchOperation;
 import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation;
 import com.owncloud.android.ui.TextDrawable;
+import com.owncloud.android.ui.events.MenuItemClickEvent;
 import com.owncloud.android.ui.events.SearchEvent;
 import com.owncloud.android.utils.DisplayUtils;
 
 import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
 
 /**
  * Base class to handle setup of the drawer implementation including user switching and avatar fetching and fallback
@@ -292,9 +294,16 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
         }
 
         if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
-            navigationView.getMenu().findItem(R.id.nav_all_files).setVisible(false);
-        } else if (!TextUtils.isEmpty(getResources().getString(R.string.custom_files_title))) {
-            navigationView.getMenu().findItem(R.id.nav_all_files).setTitle(R.string.custom_files_title);
+            navigationView.getMenu().removeItem(R.id.nav_all_files);
+            navigationView.getMenu().removeItem(R.id.nav_settings);
+            navigationView.getMenu().removeItem(R.id.nav_favorites);
+        } else if (getResources().getBoolean(R.bool.use_home)) {
+            navigationView.getMenu().findItem(R.id.nav_all_files).setTitle(getResources().
+                    getString(R.string.drawer_item_home));
+        }
+
+        if (!getResources().getBoolean(R.bool.participate_enabled)) {
+            navigationView.getMenu().removeItem(R.id.nav_participate);
         }
 
         if (AccountUtils.hasSearchSupport(AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext()))) {
@@ -316,13 +325,32 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
         }
     }
 
-    private void selectNavigationItem(final MenuItem menuItem) {
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMessageEvent(MenuItemClickEvent event) {
+        switch (event.menuItem.getItemId()) {
+            case R.id.nav_bar_files:
+                showFiles(false);
+                break;
+            case R.id.nav_bar_settings:
+                Intent settingsIntent = new Intent(getApplicationContext(), Preferences.class);
+                startActivity(settingsIntent);
+            default:
+                break;
+        }
+    }
+
+        private void selectNavigationItem(final MenuItem menuItem) {
         switch (menuItem.getItemId()) {
             case R.id.nav_all_files:
                 menuItem.setChecked(true);
                 mCheckedMenuItem = menuItem.getItemId();
                 showFiles(false);
                 break;
+            case R.id.nav_favorites:
+                menuItem.setChecked(true);
+                mCheckedMenuItem = menuItem.getItemId();
+                EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH));
+                break;
             case R.id.nav_on_device:
                 menuItem.setChecked(true);
                 mCheckedMenuItem = menuItem.getItemId();
@@ -356,8 +384,10 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
                 startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
                 break;
             case R.id.nav_recently_added:
+                EventBus.getDefault().post(new SearchEvent("%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH));
                 break;
             case R.id.nav_recently_modified:
+                EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH));
                 break;
             case R.id.nav_shared:
                 break;
@@ -887,4 +917,16 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
     public boolean isDrawerIndicatorAvailable() {
         return true;
     }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        EventBus.getDefault().register(this);
+    }
+
+    @Override
+    protected void onStop() {
+        EventBus.getDefault().unregister(this);
+        super.onStop();
+    }
 }

+ 34 - 0
src/main/java/com/owncloud/android/ui/events/MenuItemClickEvent.java

@@ -0,0 +1,34 @@
+/**
+ * Nextcloud Android client application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.owncloud.android.ui.events;
+
+import android.view.MenuItem;
+
+/**
+ * Menu item click event
+ */
+
+public class MenuItemClickEvent {
+    public final MenuItem menuItem;
+
+    public MenuItemClickEvent(MenuItem menuItem) {
+        this.menuItem = menuItem;
+    }
+}

+ 20 - 1
src/main/java/com/owncloud/android/ui/events/SearchEvent.java

@@ -1,9 +1,28 @@
+/**
+ * Nextcloud Android client application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
 package com.owncloud.android.ui.events;
 
 import com.owncloud.android.lib.resources.files.SearchOperation;
 
 /**
- * Created by mdjanic on 10/03/2017.
+ * Search event
  */
 
 public class SearchEvent {

+ 46 - 0
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -32,6 +32,8 @@ import android.content.SharedPreferences;
 import android.os.Build;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
+import android.support.annotation.NonNull;
+import android.support.design.widget.BottomNavigationView;
 import android.support.v4.widget.DrawerLayout;
 import android.support.v4.widget.SwipeRefreshLayout;
 import android.util.SparseBooleanArray;
@@ -71,6 +73,7 @@ import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
 import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
 import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment;
 import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
+import com.owncloud.android.ui.events.MenuItemClickEvent;
 import com.owncloud.android.ui.events.SearchEvent;
 import com.owncloud.android.ui.helpers.SparseBooleanArrayParcelable;
 import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface;
@@ -130,6 +133,8 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
     private ActionMode mActiveActionMode;
     private OCFileListFragment.MultiChoiceModeListener mMultiChoiceModeListener;
 
+    private BottomNavigationView bottomNavigationView;
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -171,6 +176,13 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         Log_OC.i(TAG, "onCreateView() start");
         View v = super.onCreateView(inflater, container, savedInstanceState);
+        bottomNavigationView = (BottomNavigationView) v.findViewById(R.id.bottom_navigation_view);
+
+        if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
+            bottomNavigationView.setVisibility(View.VISIBLE);
+            prepareBottomNavigationView();
+        }
+
         Bundle args = getArguments();
         boolean allowContextualActions = (args != null) && args.getBoolean(ARG_ALLOW_CONTEXTUAL_ACTIONS, false);
         if (allowContextualActions) {
@@ -180,6 +192,40 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
         return v;
     }
 
+    private void prepareBottomNavigationView() {
+        if (getResources().getBoolean(R.bool.use_home)) {
+            bottomNavigationView.getMenu().findItem(R.id.nav_bar_files).setTitle(getResources().
+                    getString(R.string.drawer_item_home));
+        }
+
+        bottomNavigationView.getMenu().findItem(R.id.nav_bar_settings).setCheckable(false);
+
+        bottomNavigationView.setOnNavigationItemSelectedListener(
+                new BottomNavigationView.OnNavigationItemSelectedListener() {
+            @Override
+            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
+                switch (item.getItemId()) {
+                    case R.id.nav_bar_files:
+                        EventBus.getDefault().post(new MenuItemClickEvent(item));
+                        break;
+                    case R.id.nav_bar_favorites:
+                        EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH));
+                        break;
+                    case R.id.nav_bar_photos:
+                        EventBus.getDefault().post(new SearchEvent("image/%",
+                                SearchOperation.SearchType.CONTENT_TYPE_SEARCH));
+                        break;
+                    case R.id.nav_bar_settings:
+                        EventBus.getDefault().post(new MenuItemClickEvent(item));
+                        break;
+                    default:
+                        break;
+                }
+                return true;
+            }
+        });
+    }
+
     @Override
     public void onResume() {
         super.onResume();

+ 41 - 26
src/main/res/layout/list_fragment.xml

@@ -18,15 +18,14 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:fab="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
+                xmlns:app="http://schemas.android.com/apk/res-auto"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
 
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    xmlns:fab="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    android:id="@+id/list_fragment_layout">
 
     <android.support.v4.widget.SwipeRefreshLayout
         android:id="@+id/swipe_containing_list"
@@ -80,18 +79,20 @@
             </ScrollView>
     </android.support.v4.widget.SwipeRefreshLayout>
 
+
 </FrameLayout>
+
     <com.getbase.floatingactionbutton.FloatingActionsMenu
         android:id="@+id/fab_main"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_alignParentBottom="true"
+        android:layout_above="@+id/bottom_navigation_view"
         android:layout_alignParentRight="true"
         android:layout_alignParentEnd="true"
-        fab:fab_addButtonColorNormal="@color/primary_button_background_color"
-        fab:fab_addButtonColorPressed="@color/owncloud_blue"
-        fab:fab_addButtonPlusIconColor="@color/white"
-        fab:fab_labelStyle="@style/menu_labels_style"
+        app:fab_addButtonColorNormal="@color/primary_button_background_color"
+        app:fab_addButtonColorPressed="@color/owncloud_blue"
+        app:fab_addButtonPlusIconColor="@color/white"
+        app:fab_labelStyle="@style/menu_labels_style"
         android:layout_marginBottom="@dimen/standard_margin"
         android:layout_marginRight="@dimen/standard_margin"
         android:layout_marginEnd="@dimen/standard_margin"
@@ -101,31 +102,45 @@
             android:id="@+id/fab_upload"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            fab:fab_size="mini"
-            fab:fab_icon="@drawable/ic_action_upload"
-            fab:fab_colorNormal="@color/primary_button_background_color"
-            fab:fab_colorPressed="@color/owncloud_blue"
-            fab:fab_title=""/>
+            app:fab_size="mini"
+            app:fab_icon="@drawable/ic_action_upload"
+            app:fab_colorNormal="@color/primary_button_background_color"
+            app:fab_colorPressed="@color/owncloud_blue"
+            app:fab_title=""/>
 
         <com.getbase.floatingactionbutton.FloatingActionButton
             android:id="@+id/fab_upload_from_app"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            fab:fab_size="mini"
-            fab:fab_icon="@drawable/ic_import"
-            fab:fab_colorNormal="@color/primary_button_background_color"
-            fab:fab_colorPressed="@color/owncloud_blue"
-            fab:fab_title=""/>
+            app:fab_size="mini"
+            app:fab_icon="@drawable/ic_import"
+            app:fab_colorNormal="@color/primary_button_background_color"
+            app:fab_colorPressed="@color/owncloud_blue"
+            app:fab_title=""/>
 
         <com.getbase.floatingactionbutton.FloatingActionButton
             android:id="@+id/fab_mkdir"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            fab:fab_size="mini"
-            fab:fab_icon="@drawable/ic_action_create_dir"
-            fab:fab_colorNormal="@color/primary_button_background_color"
-            fab:fab_colorPressed="@color/owncloud_blue"
-            fab:fab_title=""/>
+            app:fab_size="mini"
+            app:fab_icon="@drawable/ic_action_create_dir"
+            app:fab_colorNormal="@color/primary_button_background_color"
+            app:fab_colorPressed="@color/owncloud_blue"
+            app:fab_title=""/>
 
     </com.getbase.floatingactionbutton.FloatingActionsMenu>
+
+    <android.support.design.widget.BottomNavigationView
+        android:id="@+id/bottom_navigation_view"
+        android:visibility="gone"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="bottom"
+        android:layout_alignParentBottom="true"
+        app:itemBackground="@color/primary_button_background_color"
+        app:itemIconTint="@color/primary_button_text_color"
+        app:itemTextColor="@color/primary_button_text_color"
+        app:menu="@menu/navigation_bar_menu"/>
+
+
 </RelativeLayout>

+ 6 - 0
src/main/res/menu/drawer_menu.xml

@@ -28,6 +28,11 @@
             android:id="@+id/nav_all_files"
             android:icon="@drawable/ic_folder_open"
             android:title="@string/drawer_item_files"/>
+        <item
+            android:orderInCategory="0"
+            android:id="@+id/nav_favorites"
+            android:icon="@drawable/ic_favorite"
+            android:title="@string/drawer_item_favorites"/>
         <item
             android:orderInCategory="0"
             android:id="@+id/nav_on_device"
@@ -52,6 +57,7 @@
             android:orderInCategory="0"
             android:id="@+id/nav_videos"
             android:title="@string/drawer_item_videos"
+            android:icon="@drawable/file_movie"
             android:visible="false"/>
         <item
             android:orderInCategory="0"

+ 19 - 0
src/main/res/menu/navigation_bar_menu.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item
+        android:id="@+id/nav_bar_files"
+        android:icon="@drawable/ic_folder_open"
+        android:title="@string/drawer_item_files"/>
+    <item
+        android:id="@+id/nav_bar_favorites"
+        android:icon="@drawable/ic_favorite"
+        android:title="@string/drawer_item_favorites"/>
+    <item
+        android:id="@+id/nav_bar_photos"
+        android:icon="@drawable/file_image"
+        android:title="@string/drawer_item_photos"/>
+    <item
+        android:id="@+id/nav_bar_settings"
+        android:icon="@drawable/ic_settings"
+        android:title="@string/drawer_item_settings"/>
+</menu>

+ 4 - 2
src/main/res/values/setup.xml

@@ -85,6 +85,8 @@
     <!--Destination mail for sending log files -->
     <string name="mail_logger"></string>
 
+    <!-- Determine is participate enabled -->
+    <bool name="participate_enabled">true</bool>
     <!-- Participate links -->
     <string name="fdroid_beta_link" translatable="false">https://f-droid.org/repository/browse/?fdid=com.nextcloud.android.beta</string>
     <string name="beta_apk_link" translatable="false">https://github.com/nextcloud/android/raw/beta/apks/latest.apk</string>
@@ -102,8 +104,8 @@
     <!-- analytics enabled -->
     <bool name="analytics_enabled">false</bool>
 
-    <!-- custom Files title -->
-    <string name="custom_files_title" translatable="true"></string>
+    <!-- Files becomes Home -->
+    <bool name="use_home">false</bool>
 
 </resources>
 

+ 3 - 0
src/main/res/values/strings.xml

@@ -18,6 +18,9 @@
     <string name="menu_item_sort_by_size">Biggest - Smallest</string>
     <string name="drawer_item_all_files">All files</string>
     <string name="drawer_item_files">Files</string>
+    <string name="drawer_item_home">Home</string>
+    <string name="drawer_item_favorites">Favorites</string>
+    <string name="drawer_item_photos">Photos</string>
     <string name="drawer_item_on_device">On device</string>
     <string name="drawer_item_recently_added">Recently added</string>
     <string name="drawer_item_recently_modified">Recently modified</string>