Progress on all fronts

This commit is contained in:
Mario Danic 2017-03-12 14:26:37 +01:00 committed by AndyScherzinger
parent 1e16812ab3
commit b0700a38e9
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
12 changed files with 406 additions and 211 deletions

View file

@ -5,17 +5,17 @@
* Copyright (C) 2016 Andy Scherzinger * Copyright (C) 2016 Andy Scherzinger
* Copyright (C) 2016 Nextcloud * Copyright (C) 2016 Nextcloud
* Copyright (C) 2016 ownCloud Inc. * Copyright (C) 2016 ownCloud Inc.
* * <p>
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 3 of the License, or any later version. * version 3 of the License, or any later version.
* * <p>
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
* * <p>
* You should have received a copy of the GNU Affero General Public * 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/>. * License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -56,6 +56,7 @@ import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.SearchOperation; import com.owncloud.android.lib.resources.files.SearchOperation;
import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation; import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation;
import com.owncloud.android.ui.TextDrawable; import com.owncloud.android.ui.TextDrawable;
import com.owncloud.android.ui.events.DummyDrawerEvent;
import com.owncloud.android.ui.events.MenuItemClickEvent; import com.owncloud.android.ui.events.MenuItemClickEvent;
import com.owncloud.android.ui.events.SearchEvent; import com.owncloud.android.ui.events.SearchEvent;
import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.DisplayUtils;
@ -294,6 +295,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
} }
if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) { if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
navigationView.getMenu().removeItem(R.id.nav_photos);
navigationView.getMenu().removeItem(R.id.nav_all_files); navigationView.getMenu().removeItem(R.id.nav_all_files);
navigationView.getMenu().removeItem(R.id.nav_settings); navigationView.getMenu().removeItem(R.id.nav_settings);
navigationView.getMenu().removeItem(R.id.nav_favorites); navigationView.getMenu().removeItem(R.id.nav_favorites);
@ -339,7 +341,14 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
} }
} }
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(DummyDrawerEvent event) {
unsetAllDrawerMenuItems();
}
private void selectNavigationItem(final MenuItem menuItem) { private void selectNavigationItem(final MenuItem menuItem) {
switch (menuItem.getItemId()) { switch (menuItem.getItemId()) {
case R.id.nav_all_files: case R.id.nav_all_files:
menuItem.setChecked(true); menuItem.setChecked(true);
@ -349,7 +358,12 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
case R.id.nav_favorites: case R.id.nav_favorites:
menuItem.setChecked(true); menuItem.setChecked(true);
mCheckedMenuItem = menuItem.getItemId(); mCheckedMenuItem = menuItem.getItemId();
EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH)); EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH,
SearchEvent.UnsetType.NO_UNSET));
break;
case R.id.nav_photos:
EventBus.getDefault().post(new SearchEvent("image/%",
SearchOperation.SearchType.CONTENT_TYPE_SEARCH, SearchEvent.UnsetType.NO_UNSET));
break; break;
case R.id.nav_on_device: case R.id.nav_on_device:
menuItem.setChecked(true); menuItem.setChecked(true);
@ -384,15 +398,26 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS); startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
break; break;
case R.id.nav_recently_added: case R.id.nav_recently_added:
EventBus.getDefault().post(new SearchEvent("%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH)); menuItem.setChecked(true);
mCheckedMenuItem = menuItem.getItemId();
EventBus.getDefault().post(new SearchEvent("%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
break; break;
case R.id.nav_recently_modified: case R.id.nav_recently_modified:
EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH)); menuItem.setChecked(true);
mCheckedMenuItem = menuItem.getItemId();
EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH,
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
break; break;
case R.id.nav_shared: case R.id.nav_shared:
menuItem.setChecked(true);
mCheckedMenuItem = menuItem.getItemId();
break; break;
case R.id.nav_videos: case R.id.nav_videos:
EventBus.getDefault().post(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH)); menuItem.setChecked(true);
mCheckedMenuItem = menuItem.getItemId();
EventBus.getDefault().post(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
break; break;
case Menu.NONE: case Menu.NONE:
// account clicked // account clicked
@ -670,6 +695,17 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
showQuota(true); showQuota(true);
} }
protected void unsetAllDrawerMenuItems() {
if (mNavigationView != null && mNavigationView.getMenu() != null) {
Menu menu = mNavigationView.getMenu();
for (int i = 0; i < menu.size(); i++) {
menu.getItem(i).setChecked(false);
}
}
mCheckedMenuItem = Menu.NONE;
}
/** /**
* checks/highlights the provided menu item if the drawer has been initialized and the menu item exists. * checks/highlights the provided menu item if the drawer has been initialized and the menu item exists.
* *

View file

@ -81,6 +81,7 @@ import com.owncloud.android.operations.SynchronizeFileOperation;
import com.owncloud.android.operations.UploadFileOperation; import com.owncloud.android.operations.UploadFileOperation;
import com.owncloud.android.services.observer.FileObserverService; import com.owncloud.android.services.observer.FileObserverService;
import com.owncloud.android.syncadapter.FileSyncAdapter; import com.owncloud.android.syncadapter.FileSyncAdapter;
import com.owncloud.android.ui.fragment.ExtendedListFragment;
import com.owncloud.android.ui.fragment.FileDetailFragment; import com.owncloud.android.ui.fragment.FileDetailFragment;
import com.owncloud.android.ui.fragment.FileFragment; import com.owncloud.android.ui.fragment.FileFragment;
import com.owncloud.android.ui.fragment.OCFileListFragment; import com.owncloud.android.ui.fragment.OCFileListFragment;
@ -319,27 +320,6 @@ public class FileDisplayActivity extends HookActivity
} }
} }
@Override
protected void onStart() {
Log_OC.v(TAG, "onStart() start");
super.onStart();
Log_OC.v(TAG, "onStart() end");
}
@Override
protected void onStop() {
Log_OC.v(TAG, "onStop() start");
super.onStop();
Log_OC.v(TAG, "onStop() end");
}
@Override
protected void onDestroy() {
Log_OC.v(TAG, "onDestroy() start");
super.onDestroy();
Log_OC.v(TAG, "onDestroy() end");
}
/** /**
* Called when the ownCloud {@link Account} associated to the Activity was just updated. * Called when the ownCloud {@link Account} associated to the Activity was just updated.
*/ */
@ -941,6 +921,16 @@ public class FileDisplayActivity extends HookActivity
return (mSearchEditFrame != null && mSearchEditFrame.getVisibility() == View.VISIBLE); return (mSearchEditFrame != null && mSearchEditFrame.getVisibility() == View.VISIBLE);
} }
private void revertBottomNavigationBarToAllFiles() {
if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
BottomNavigationView bottomNavigationView = (BottomNavigationView) getListOfFilesFragment().getView()
.findViewById(R.id.bottom_navigation_view);
if (bottomNavigationView.getMenu().findItem(R.id.nav_bar_settings).isChecked()) {
bottomNavigationView.getMenu().findItem(R.id.nav_bar_files).setChecked(true);
}
}
}
@Override @Override
public void onBackPressed() { public void onBackPressed() {
boolean isFabOpen = isFabOpen(); boolean isFabOpen = isFabOpen();
@ -955,14 +945,6 @@ public class FileDisplayActivity extends HookActivity
* 4. navigate up (only if drawer and FAB aren't open) * 4. navigate up (only if drawer and FAB aren't open)
*/ */
if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
BottomNavigationView bottomNavigationView = (BottomNavigationView) getListOfFilesFragment().getView()
.findViewById(R.id.bottom_navigation_view);
if (bottomNavigationView.getMenu().findItem(R.id.nav_bar_settings).isChecked()) {
bottomNavigationView.getMenu().findItem(R.id.nav_bar_files).setChecked(true);
}
}
if (isSearchOpen && searchView != null) { if (isSearchOpen && searchView != null) {
searchView.setQuery("", true); searchView.setQuery("", true);
searchView.onActionViewCollapsed(); searchView.onActionViewCollapsed();
@ -1018,6 +1000,7 @@ public class FileDisplayActivity extends HookActivity
Log_OC.v(TAG, "onResume() start"); Log_OC.v(TAG, "onResume() start");
super.onResume(); super.onResume();
revertBottomNavigationBarToAllFiles();
// refresh list of files // refresh list of files
if (searchView != null && !TextUtils.isEmpty(searchQuery)) { if (searchView != null && !TextUtils.isEmpty(searchQuery)) {
@ -1206,7 +1189,7 @@ public class FileDisplayActivity extends HookActivity
OCFileListFragment ocFileListFragment = getListOfFilesFragment(); OCFileListFragment ocFileListFragment = getListOfFilesFragment();
if (ocFileListFragment != null) { if (ocFileListFragment != null) {
if (!mSyncInProgress) { if (!mSyncInProgress) {
ocFileListFragment.setEmptyListMessage(false); ocFileListFragment.setEmptyListMessage(ExtendedListFragment.SearchType.NO_SEARCH);
} else { } else {
ocFileListFragment.setEmptyListLoadingMessage(); ocFileListFragment.setEmptyListLoadingMessage();
} }

View file

@ -809,5 +809,4 @@ public class Preferences extends PreferenceActivity
public void onCancelMigration() { public void onCancelMigration() {
// Migration was canceled so we don't do anything // Migration was canceled so we don't do anything
} }
} }

View file

@ -0,0 +1,27 @@
/**
* 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;
/**
* Dummy drawer event
*/
public class DummyDrawerEvent {
}

View file

@ -30,11 +30,24 @@ public class SearchEvent {
public final SearchOperation.SearchType searchType; public final SearchOperation.SearchType searchType;
public final UnsetType unsetType;
public SearchEvent(String searchQuery, SearchOperation.SearchType searchType) { public enum UnsetType {
NO_UNSET,
UNSET_DRAWER,
UNSET_BOTTOM_NAV_BAR;
}
public SearchEvent(String searchQuery, SearchOperation.SearchType searchType, UnsetType unsetType) {
this.searchQuery = searchQuery; this.searchQuery = searchQuery;
this.searchType = searchType; this.searchType = searchType;
this.unsetType = unsetType;
}
public UnsetType getUnsetType() {
return unsetType;
} }
public String getSearchQuery() { public String getSearchQuery() {

View file

@ -1,21 +1,20 @@
/** /**
* ownCloud Android client application * ownCloud Android client application
* * <p>
* Copyright (C) 2012 Bartek Przybylski * Copyright (C) 2012 Bartek Przybylski
* Copyright (C) 2012-2016 ownCloud Inc. * Copyright (C) 2012-2016 ownCloud Inc.
* * <p>
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, * it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation. * as published by the Free Software Foundation.
* * <p>
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* * <p>
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/ */
package com.owncloud.android.ui.fragment; package com.owncloud.android.ui.fragment;
@ -24,8 +23,10 @@ import android.animation.LayoutTransition;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
@ -66,6 +67,18 @@ import java.util.ArrayList;
import third_parties.in.srain.cube.GridViewWithHeaderAndFooter; import third_parties.in.srain.cube.GridViewWithHeaderAndFooter;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.FAVORITE_SEARCH;
import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.FAVORITE_SEARCH_FILTER;
import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.FILE_SEARCH;
import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.NO_SEARCH;
import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.PHOTO_SEARCH;
import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.RECENTLY_ADDED_SEARCH;
import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.RECENTLY_ADDED_SEARCH_FILTER;
import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.RECENTLY_MODIFIED_SEARCH;
import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.RECENTLY_MODIFIED_SEARCH_FILTER;
import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.REGULAR_FILTER;
import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.VIDEO_SEARCH;
import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.VIDEO_SEARCH_FILTER;
public class ExtendedListFragment extends Fragment public class ExtendedListFragment extends Fragment
implements OnItemClickListener, OnEnforceableRefreshListener, SearchView.OnQueryTextListener { implements OnItemClickListener, OnEnforceableRefreshListener, SearchView.OnQueryTextListener {
@ -114,6 +127,25 @@ public class ExtendedListFragment extends Fragment
protected SearchView searchView; protected SearchView searchView;
private Handler handler = new Handler(); private Handler handler = new Handler();
protected Menu mMenu;
public enum SearchType {
NO_SEARCH,
REGULAR_FILTER,
FILE_SEARCH,
FAVORITE_SEARCH,
FAVORITE_SEARCH_FILTER,
VIDEO_SEARCH,
VIDEO_SEARCH_FILTER,
PHOTO_SEARCH,
PHOTOS_SEARCH_FILTER,
RECENTLY_MODIFIED_SEARCH,
RECENTLY_MODIFIED_SEARCH_FILTER,
RECENTLY_ADDED_SEARCH,
RECENTLY_ADDED_SEARCH_FILTER
}
protected void setListAdapter(BaseAdapter listAdapter) { protected void setListAdapter(BaseAdapter listAdapter) {
mAdapter = listAdapter; mAdapter = listAdapter;
mCurrentListView.setAdapter(listAdapter); mCurrentListView.setAdapter(listAdapter);
@ -166,6 +198,7 @@ public class ExtendedListFragment extends Fragment
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
mMenu = menu;
final MenuItem item = menu.findItem(R.id.action_search); final MenuItem item = menu.findItem(R.id.action_search);
searchView = (SearchView) MenuItemCompat.getActionView(item); searchView = (SearchView) MenuItemCompat.getActionView(item);
searchView.setOnQueryTextListener(this); searchView.setOnQueryTextListener(this);
@ -200,6 +233,17 @@ public class ExtendedListFragment extends Fragment
public void run() { public void run() {
if (getActivity() != null && !(getActivity() instanceof FolderPickerActivity)) { if (getActivity() != null && !(getActivity() instanceof FolderPickerActivity)) {
setFabEnabled(!hasFocus); setFabEnabled(!hasFocus);
if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
BottomNavigationView bottomNavigationView = (BottomNavigationView) getActivity().
findViewById(R.id.bottom_navigation_view);
if (hasFocus) {
bottomNavigationView.setVisibility(View.GONE);
} else {
bottomNavigationView.setVisibility(View.VISIBLE);
}
}
} }
} }
}, 100); }, 100);
@ -220,9 +264,10 @@ public class ExtendedListFragment extends Fragment
if (currentVisibility != oldVisibility) { if (currentVisibility != oldVisibility) {
if (currentVisibility == View.VISIBLE) { if (currentVisibility == View.VISIBLE) {
setEmptyListMessage(true);
setEmptyListMessage(SearchType.REGULAR_FILTER);
} else { } else {
setEmptyListMessage(false); setEmptyListMessage(NO_SEARCH);
} }
oldVisibility = currentVisibility; oldVisibility = currentVisibility;
@ -555,22 +600,52 @@ public class ExtendedListFragment extends Fragment
mEmptyListMessage.setText(message); mEmptyListMessage.setText(message);
mEmptyListIcon.setImageResource(icon); mEmptyListIcon.setImageResource(icon);
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
mEmptyListIcon.setVisibility(View.VISIBLE); mEmptyListIcon.setVisibility(View.VISIBLE);
mEmptyListProgress.setVisibility(View.GONE); mEmptyListProgress.setVisibility(View.GONE);
} }
});
}
} }
public void setEmptyListMessage(boolean isSearch) { public void setEmptyListMessage(SearchType searchType) {
if (isSearch) { if (searchType == NO_SEARCH) {
setMessageForEmptyList(R.string.file_list_empty_headline_search,
R.string.file_list_empty_search, R.drawable.ic_search_light_grey);
} else {
setMessageForEmptyList( setMessageForEmptyList(
R.string.file_list_empty_headline, R.string.file_list_empty_headline,
R.string.file_list_empty, R.string.file_list_empty,
R.drawable.ic_list_empty_folder R.drawable.ic_list_empty_folder
); );
} else if (searchType == FILE_SEARCH) {
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
R.string.file_list_empty, R.drawable.ic_search_light_grey);
} else if (searchType == FAVORITE_SEARCH) {
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
R.string.file_list_empty_favorites, R.drawable.ic_search_light_grey);
} else if (searchType == VIDEO_SEARCH) {
setMessageForEmptyList(R.string.file_list_empty_headline_server_search_videos,
R.string.file_list_empty_text_videos, R.drawable.ic_search_light_grey);
} else if (searchType == PHOTO_SEARCH) {
setMessageForEmptyList(R.string.file_list_empty_headline_server_search_photos,
R.string.file_list_empty_text_photos, R.drawable.ic_search_light_grey);
} else if (searchType == RECENTLY_MODIFIED_SEARCH) {
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
R.string.file_list_empty_recently_modified, R.drawable.ic_search_light_grey);
} else if (searchType == RECENTLY_ADDED_SEARCH) {
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
R.string.file_list_empty_recently_added, R.drawable.ic_search_light_grey);
} else if (searchType == REGULAR_FILTER) {
setMessageForEmptyList(R.string.file_list_empty_headline_search,
R.string.file_list_empty_search, R.drawable.ic_search_light_grey);
} else if (searchType == FAVORITE_SEARCH_FILTER) {
} else if (searchType == VIDEO_SEARCH_FILTER) {
} else if (searchType == RECENTLY_MODIFIED_SEARCH_FILTER) {
} else if (searchType == RECENTLY_ADDED_SEARCH_FILTER) {
} }
} }
@ -582,9 +657,14 @@ public class ExtendedListFragment extends Fragment
mEmptyListHeadline.setText(R.string.file_list_loading); mEmptyListHeadline.setText(R.string.file_list_loading);
mEmptyListMessage.setText(""); mEmptyListMessage.setText("");
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
mEmptyListIcon.setVisibility(View.GONE); mEmptyListIcon.setVisibility(View.GONE);
mEmptyListProgress.setVisibility(View.VISIBLE); mEmptyListProgress.setVisibility(View.VISIBLE);
} }
});
}
} }
/** /**

View file

@ -6,19 +6,18 @@
* @author David A. Velasco * @author David A. Velasco
* Copyright (C) 2011 Bartek Przybylski * Copyright (C) 2011 Bartek Przybylski
* Copyright (C) 2016 ownCloud Inc. * Copyright (C) 2016 ownCloud Inc.
* * <p>
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, * it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation. * as published by the Free Software Foundation.
* * <p>
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* * <p>
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/ */
package com.owncloud.android.ui.fragment; package com.owncloud.android.ui.fragment;
@ -31,6 +30,8 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView; import android.support.design.widget.BottomNavigationView;
@ -73,6 +74,7 @@ import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment; import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment; import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment;
import com.owncloud.android.ui.dialog.RenameFileDialogFragment; import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
import com.owncloud.android.ui.events.DummyDrawerEvent;
import com.owncloud.android.ui.events.MenuItemClickEvent; import com.owncloud.android.ui.events.MenuItemClickEvent;
import com.owncloud.android.ui.events.SearchEvent; import com.owncloud.android.ui.events.SearchEvent;
import com.owncloud.android.ui.helpers.SparseBooleanArrayParcelable; import com.owncloud.android.ui.helpers.SparseBooleanArrayParcelable;
@ -207,11 +209,12 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
EventBus.getDefault().post(new MenuItemClickEvent(item)); EventBus.getDefault().post(new MenuItemClickEvent(item));
break; break;
case R.id.nav_bar_favorites: case R.id.nav_bar_favorites:
EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH)); EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH,
SearchEvent.UnsetType.UNSET_DRAWER));
break; break;
case R.id.nav_bar_photos: case R.id.nav_bar_photos:
EventBus.getDefault().post(new SearchEvent("image/%", EventBus.getDefault().post(new SearchEvent("image/%",
SearchOperation.SearchType.CONTENT_TYPE_SEARCH)); SearchOperation.SearchType.CONTENT_TYPE_SEARCH, SearchEvent.UnsetType.UNSET_DRAWER));
break; break;
case R.id.nav_bar_settings: case R.id.nav_bar_settings:
EventBus.getDefault().post(new MenuItemClickEvent(item)); EventBus.getDefault().post(new MenuItemClickEvent(item));
@ -1065,8 +1068,32 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
editor.apply(); editor.apply();
} }
private void unsetAllMenuItems(final boolean unsetDrawer) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
if (unsetDrawer) {
EventBus.getDefault().post(new DummyDrawerEvent());
} else {
if (bottomNavigationView != null) {
bottomNavigationView.getMenu().findItem(R.id.nav_bar_files).setChecked(true);
}
}
}
});
}
@Subscribe(threadMode = ThreadMode.BACKGROUND) @Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onMessageEvent(SearchEvent event) { public void onMessageEvent(SearchEvent event) {
setEmptyListLoadingMessage();
if (event.getUnsetType().equals(SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR)) {
unsetAllMenuItems(false);
} else if (event.getUnsetType().equals(SearchEvent.UnsetType.UNSET_DRAWER)) {
unsetAllMenuItems(true);
}
Account currentAccount = com.owncloud.android.authentication.AccountUtils. Account currentAccount = com.owncloud.android.authentication.AccountUtils.
getCurrentOwnCloudAccount(MainApp.getAppContext()); getCurrentOwnCloudAccount(MainApp.getAppContext());
@ -1081,7 +1108,25 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
SearchOperation operation = new SearchOperation(event.getSearchQuery(), event.getSearchType()); SearchOperation operation = new SearchOperation(event.getSearchQuery(), event.getSearchType());
RemoteOperationResult remoteOperationResult = operation.execute(mClient); RemoteOperationResult remoteOperationResult = operation.execute(mClient);
if (remoteOperationResult.isSuccess() || remoteOperationResult.getData() != null) { if (remoteOperationResult.isSuccess() || remoteOperationResult.getData() != null) {
if (event.getSearchType().equals(SearchOperation.SearchType.FILE_SEARCH)) {
setEmptyListMessage(SearchType.FILE_SEARCH);
} else if (event.getSearchType().equals(SearchOperation.SearchType.CONTENT_TYPE_SEARCH)) {
if (event.getSearchQuery().equals("image/%")) {
setEmptyListMessage(SearchType.PHOTO_SEARCH);
} else if (event.getSearchQuery().equals("video/%")) {
setEmptyListMessage(SearchType.VIDEO_SEARCH);
}
} else if (event.getSearchType().equals(SearchOperation.SearchType.FAVORITE_SEARCH)) {
setEmptyListMessage(SearchType.FAVORITE_SEARCH);
} else if (event.getSearchType().equals(SearchOperation.SearchType.RECENTLY_ADDED_SEARCH)) {
setEmptyListMessage(SearchType.RECENTLY_ADDED_SEARCH);
} else if (event.getSearchType().equals(SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH)) {
setEmptyListMessage(SearchType.RECENTLY_MODIFIED_SEARCH);
}
mAdapter.setData(remoteOperationResult.getData()); mAdapter.setData(remoteOperationResult.getData());
} }
} catch (AuthenticatorException e) { } catch (AuthenticatorException e) {
e.printStackTrace(); e.printStackTrace();
@ -1092,8 +1137,6 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
} catch (OperationCanceledException e) { } catch (OperationCanceledException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@Override @Override

View file

@ -66,7 +66,8 @@ public class UploadListFragment extends ExpandableListFragment {
View v = super.onCreateView(inflater, container, savedInstanceState); View v = super.onCreateView(inflater, container, savedInstanceState);
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
setMessageForEmptyList( setMessageForEmptyList(
R.string.upload_list_empty_headline, R.string.upload_list_empty_text, R.drawable.ic_list_empty_upload R.string.upload_list_empty_headline, R.string.upload_list_empty_text_auto_upload,
R.drawable.ic_list_empty_upload
); );
setOnRefreshListener(this); setOnRefreshListener(this);
return v; return v;

View file

@ -27,17 +27,16 @@
android:orderInCategory="0" android:orderInCategory="0"
android:id="@+id/nav_all_files" android:id="@+id/nav_all_files"
android:icon="@drawable/ic_folder_open" android:icon="@drawable/ic_folder_open"
android:title="@string/drawer_item_files"/> android:title="@string/drawer_item_all_files"/>
<item <item
android:orderInCategory="0" android:orderInCategory="0"
android:id="@+id/nav_favorites" android:id="@+id/nav_favorites"
android:icon="@drawable/ic_favorite" android:icon="@drawable/ic_favorite"
android:title="@string/drawer_item_favorites"/> android:title="@string/drawer_item_favorites"/>
<item <item
android:orderInCategory="0" android:id="@+id/nav_photos"
android:id="@+id/nav_on_device" android:icon="@drawable/file_image"
android:icon="@drawable/ic_action_available_offline" android:title="@string/drawer_item_photos"/>
android:title="@string/drawer_item_on_device"/>
<item <item
android:orderInCategory="0" android:orderInCategory="0"
android:id="@+id/nav_recently_added" android:id="@+id/nav_recently_added"
@ -59,6 +58,11 @@
android:title="@string/drawer_item_videos" android:title="@string/drawer_item_videos"
android:icon="@drawable/file_movie" android:icon="@drawable/file_movie"
android:visible="false"/> android:visible="false"/>
<item
android:orderInCategory="0"
android:id="@+id/nav_on_device"
android:icon="@drawable/ic_action_available_offline"
android:title="@string/drawer_item_on_device"/>
<item <item
android:orderInCategory="0" android:orderInCategory="0"
android:id="@+id/nav_folder_sync" android:id="@+id/nav_folder_sync"

View file

@ -3,7 +3,7 @@
<item <item
android:id="@+id/nav_bar_files" android:id="@+id/nav_bar_files"
android:icon="@drawable/ic_folder_open" android:icon="@drawable/ic_folder_open"
android:title="@string/drawer_item_files"/> android:title="@string/drawer_item_all_files"/>
<item <item
android:id="@+id/nav_bar_favorites" android:id="@+id/nav_bar_favorites"
android:icon="@drawable/ic_favorite" android:icon="@drawable/ic_favorite"

View file

@ -62,7 +62,7 @@
<!-- Drawer options --> <!-- Drawer options -->
<bool name="recently_added_enabled">false</bool> <bool name="recently_added_enabled">false</bool>
<bool name="recently_modified_enabled">false</bool> <bool name="recently_modified_enabled">false</bool>
<bool name="shared_enabled">false</bool> <bool name="shared_enabled">true</bool>
<bool name="videos_enabled">false</bool> <bool name="videos_enabled">false</bool>
<!-- Bottom toolbar --> <!-- Bottom toolbar -->

View file

@ -88,13 +88,22 @@
<string name="file_list_seconds_ago">seconds ago</string> <string name="file_list_seconds_ago">seconds ago</string>
<string name="file_list_empty_headline">No files in here</string> <string name="file_list_empty_headline">No files in here</string>
<string name="file_list_empty">Upload some content or sync with your devices!</string> <string name="file_list_empty">Upload some content or sync with your devices!</string>
<string name="file_list_empty_favorites">Favorite some files or sync with your devices!</string>
<string name="file_list_loading">Loading&#8230;</string> <string name="file_list_loading">Loading&#8230;</string>
<string name="file_list_no_app_for_file_type">No app found for file type!</string> <string name="file_list_no_app_for_file_type">No app found for file type!</string>
<string name="local_file_list_empty">There are no files in this folder.</string> <string name="local_file_list_empty">There are no files in this folder.</string>
<string name="file_list_empty_headline_search">No results in this folder</string> <string name="file_list_empty_headline_search">No results in this folder</string>
<string name="file_list_empty_headline_server_search">No results</string>
<string name="file_list_empty_headline_server_search_videos">No videos</string>
<string name="file_list_empty_headline_server_search_photos">No photos</string>
<string name="file_list_empty_search">Try looking in another folder?</string> <string name="file_list_empty_search">Try looking in another folder?</string>
<string name="file_list_empty_recently_modified">No recently modified files found</string>
<string name="file_list_empty_recently_added">No recently added files found</string>
<string name="file_list_empty_text_photos">Upload some photos or activate auto upload!</string>
<string name="file_list_empty_text_videos">Upload some videos or activate auto upload!</string>
<string name="upload_list_empty_headline">No uploads available</string> <string name="upload_list_empty_headline">No uploads available</string>
<string name="upload_list_empty_text">Upload some content or activate instant upload!</string> <string name="upload_list_empty_text">Upload some content or activate instant upload!</string>
<string name="upload_list_empty_text_auto_upload">Upload some content or activate auto upload!</string>
<string name="file_list_folder">folder</string> <string name="file_list_folder">folder</string>
<string name="file_list_folders">folders</string> <string name="file_list_folders">folders</string>
<string name="file_list_file">file</string> <string name="file_list_file">file</string>