mirror of
https://github.com/nextcloud/android.git
synced 2024-12-21 08:24:08 +03:00
Progress on all fronts
This commit is contained in:
parent
1e16812ab3
commit
b0700a38e9
12 changed files with 406 additions and 211 deletions
|
@ -1,23 +1,23 @@
|
||||||
/**
|
/**
|
||||||
* Nextcloud Android client application
|
* Nextcloud Android client application
|
||||||
*
|
*
|
||||||
* @author Andy Scherzinger
|
* @author Andy Scherzinger
|
||||||
* 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/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.owncloud.android.ui.activity;
|
package com.owncloud.android.ui.activity;
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectNavigationItem(final MenuItem menuItem) {
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onMessageEvent(DummyDrawerEvent event) {
|
||||||
|
unsetAllDrawerMenuItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
@ -363,7 +377,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||||
startActivity(uploadListIntent);
|
startActivity(uploadListIntent);
|
||||||
break;
|
break;
|
||||||
case R.id.nav_folder_sync:
|
case R.id.nav_folder_sync:
|
||||||
Intent folderSyncIntent = new Intent(getApplicationContext(),FolderSyncActivity.class);
|
Intent folderSyncIntent = new Intent(getApplicationContext(), FolderSyncActivity.class);
|
||||||
startActivity(folderSyncIntent);
|
startActivity(folderSyncIntent);
|
||||||
break;
|
break;
|
||||||
case R.id.nav_settings:
|
case R.id.nav_settings:
|
||||||
|
@ -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
|
||||||
|
@ -654,9 +679,9 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||||
/**
|
/**
|
||||||
* configured the quota to be displayed.
|
* configured the quota to be displayed.
|
||||||
*
|
*
|
||||||
* @param usedSpace the used space
|
* @param usedSpace the used space
|
||||||
* @param totalSpace the total space
|
* @param totalSpace the total space
|
||||||
* @param relative the percentage of space already used
|
* @param relative the percentage of space already used
|
||||||
*/
|
*/
|
||||||
private void setQuotaInformation(long usedSpace, long totalSpace, int relative) {
|
private void setQuotaInformation(long usedSpace, long totalSpace, int relative) {
|
||||||
mQuotaProgressBar.setProgress(relative);
|
mQuotaProgressBar.setProgress(relative);
|
||||||
|
@ -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.
|
||||||
*
|
*
|
||||||
|
@ -881,10 +917,10 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||||
@Override
|
@Override
|
||||||
public void avatarGenerated(Drawable avatarDrawable, Object callContext) {
|
public void avatarGenerated(Drawable avatarDrawable, Object callContext) {
|
||||||
if (callContext instanceof MenuItem) {
|
if (callContext instanceof MenuItem) {
|
||||||
MenuItem mi = (MenuItem)callContext;
|
MenuItem mi = (MenuItem) callContext;
|
||||||
mi.setIcon(avatarDrawable);
|
mi.setIcon(avatarDrawable);
|
||||||
} else if (callContext instanceof ImageView) {
|
} else if (callContext instanceof ImageView) {
|
||||||
ImageView iv = (ImageView)callContext;
|
ImageView iv = (ImageView) callContext;
|
||||||
iv.setImageDrawable(avatarDrawable);
|
iv.setImageDrawable(avatarDrawable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -892,10 +928,10 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldCallGeneratedCallback(String tag, Object callContext) {
|
public boolean shouldCallGeneratedCallback(String tag, Object callContext) {
|
||||||
if (callContext instanceof MenuItem) {
|
if (callContext instanceof MenuItem) {
|
||||||
MenuItem mi = (MenuItem)callContext;
|
MenuItem mi = (MenuItem) callContext;
|
||||||
return String.valueOf(mi.getTitle()).equals(tag);
|
return String.valueOf(mi.getTitle()).equals(tag);
|
||||||
} else if (callContext instanceof ImageView) {
|
} else if (callContext instanceof ImageView) {
|
||||||
ImageView iv = (ImageView)callContext;
|
ImageView iv = (ImageView) callContext;
|
||||||
return String.valueOf(iv.getTag()).equals(tag);
|
return String.valueOf(iv.getTag()).equals(tag);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -904,7 +940,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||||
/**
|
/**
|
||||||
* Adds other listeners to react on changes of the drawer layout.
|
* Adds other listeners to react on changes of the drawer layout.
|
||||||
*
|
*
|
||||||
* @param listener Object interested in changes of the drawer layout.
|
* @param listener Object interested in changes of the drawer layout.
|
||||||
*/
|
*/
|
||||||
public void addDrawerListener(DrawerLayout.DrawerListener listener) {
|
public void addDrawerListener(DrawerLayout.DrawerListener listener) {
|
||||||
if (mDrawerLayout != null) {
|
if (mDrawerLayout != null) {
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
}
|
|
@ -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() {
|
||||||
|
|
|
@ -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,16 +67,28 @@ 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 {
|
||||||
|
|
||||||
protected static final String TAG = ExtendedListFragment.class.getSimpleName();
|
protected static final String TAG = ExtendedListFragment.class.getSimpleName();
|
||||||
|
|
||||||
protected static final String KEY_SAVED_LIST_POSITION = "SAVED_LIST_POSITION";
|
protected static final String KEY_SAVED_LIST_POSITION = "SAVED_LIST_POSITION";
|
||||||
|
|
||||||
private static final String KEY_INDEXES = "INDEXES";
|
private static final String KEY_INDEXES = "INDEXES";
|
||||||
private static final String KEY_FIRST_POSITIONS= "FIRST_POSITIONS";
|
private static final String KEY_FIRST_POSITIONS = "FIRST_POSITIONS";
|
||||||
private static final String KEY_TOPS = "TOPS";
|
private static final String KEY_TOPS = "TOPS";
|
||||||
private static final String KEY_HEIGHT_CELL = "HEIGHT_CELL";
|
private static final String KEY_HEIGHT_CELL = "HEIGHT_CELL";
|
||||||
private static final String KEY_EMPTY_LIST_MESSAGE = "EMPTY_LIST_MESSAGE";
|
private static final String KEY_EMPTY_LIST_MESSAGE = "EMPTY_LIST_MESSAGE";
|
||||||
|
@ -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);
|
||||||
|
@ -160,12 +192,13 @@ public class ExtendedListFragment extends Fragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGridEnabled(){
|
public boolean isGridEnabled() {
|
||||||
return (mCurrentListView != null && mCurrentListView.equals(mGridView));
|
return (mCurrentListView != null && mCurrentListView.equals(mGridView));
|
||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
|
@ -284,11 +329,11 @@ public class ExtendedListFragment extends Fragment
|
||||||
if ((activity = getActivity()) != null) {
|
if ((activity = getActivity()) != null) {
|
||||||
if (activity instanceof FileDisplayActivity) {
|
if (activity instanceof FileDisplayActivity) {
|
||||||
((FileDisplayActivity) activity).refreshListOfFilesFragment(true);
|
((FileDisplayActivity) activity).refreshListOfFilesFragment(true);
|
||||||
} else if (activity instanceof UploadFilesActivity){
|
} else if (activity instanceof UploadFilesActivity) {
|
||||||
LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) mAdapter;
|
LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) mAdapter;
|
||||||
localFileListAdapter.filter(query);
|
localFileListAdapter.filter(query);
|
||||||
} else if (activity instanceof FolderPickerActivity) {
|
} else if (activity instanceof FolderPickerActivity) {
|
||||||
((FolderPickerActivity)activity).refreshListOfFilesFragment(true);
|
((FolderPickerActivity) activity).refreshListOfFilesFragment(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -305,7 +350,7 @@ public class ExtendedListFragment extends Fragment
|
||||||
View v = inflater.inflate(R.layout.list_fragment, null);
|
View v = inflater.inflate(R.layout.list_fragment, null);
|
||||||
setupEmptyList(v);
|
setupEmptyList(v);
|
||||||
|
|
||||||
mListView = (ExtendedListView)(v.findViewById(R.id.list_root));
|
mListView = (ExtendedListView) (v.findViewById(R.id.list_root));
|
||||||
mListView.setOnItemClickListener(this);
|
mListView.setOnItemClickListener(this);
|
||||||
mListFooterView = inflater.inflate(R.layout.list_footer, null, false);
|
mListFooterView = inflater.inflate(R.layout.list_footer, null, false);
|
||||||
|
|
||||||
|
@ -366,23 +411,23 @@ public class ExtendedListFragment extends Fragment
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mIndexes = savedInstanceState.getIntegerArrayList(KEY_INDEXES);
|
mIndexes = savedInstanceState.getIntegerArrayList(KEY_INDEXES);
|
||||||
mFirstPositions = savedInstanceState.getIntegerArrayList(KEY_FIRST_POSITIONS);
|
mFirstPositions = savedInstanceState.getIntegerArrayList(KEY_FIRST_POSITIONS);
|
||||||
mTops = savedInstanceState.getIntegerArrayList(KEY_TOPS);
|
mTops = savedInstanceState.getIntegerArrayList(KEY_TOPS);
|
||||||
mHeightCell = savedInstanceState.getInt(KEY_HEIGHT_CELL);
|
mHeightCell = savedInstanceState.getInt(KEY_HEIGHT_CELL);
|
||||||
setMessageForEmptyList(savedInstanceState.getString(KEY_EMPTY_LIST_MESSAGE));
|
setMessageForEmptyList(savedInstanceState.getString(KEY_EMPTY_LIST_MESSAGE));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
mIndexes = new ArrayList<>();
|
mIndexes = new ArrayList<>();
|
||||||
mFirstPositions = new ArrayList<>();
|
mFirstPositions = new ArrayList<>();
|
||||||
mTops = new ArrayList<>();
|
mTops = new ArrayList<>();
|
||||||
mHeightCell = 0;
|
mHeightCell = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle savedInstanceState) {
|
public void onSaveInstanceState(Bundle savedInstanceState) {
|
||||||
super.onSaveInstanceState(savedInstanceState);
|
super.onSaveInstanceState(savedInstanceState);
|
||||||
|
@ -400,10 +445,10 @@ public class ExtendedListFragment extends Fragment
|
||||||
* Calculates the position of the item that will be used as a reference to
|
* Calculates the position of the item that will be used as a reference to
|
||||||
* reposition the visible items in the list when the device is turned to
|
* reposition the visible items in the list when the device is turned to
|
||||||
* other position.
|
* other position.
|
||||||
*
|
*
|
||||||
* The current policy is take as a reference the visible item in the center
|
* The current policy is take as a reference the visible item in the center
|
||||||
* of the screen.
|
* of the screen.
|
||||||
*
|
*
|
||||||
* @return The position in the list of the visible item in the center of the
|
* @return The position in the list of the visible item in the center of the
|
||||||
* screen.
|
* screen.
|
||||||
*/
|
*/
|
||||||
|
@ -421,25 +466,25 @@ public class ExtendedListFragment extends Fragment
|
||||||
* Restore index and position
|
* Restore index and position
|
||||||
*/
|
*/
|
||||||
protected void restoreIndexAndTopPosition() {
|
protected void restoreIndexAndTopPosition() {
|
||||||
if (mIndexes.size() > 0) {
|
if (mIndexes.size() > 0) {
|
||||||
// needs to be checked; not every browse-up had a browse-down before
|
// needs to be checked; not every browse-up had a browse-down before
|
||||||
|
|
||||||
int index = mIndexes.remove(mIndexes.size() - 1);
|
int index = mIndexes.remove(mIndexes.size() - 1);
|
||||||
final int firstPosition = mFirstPositions.remove(mFirstPositions.size() -1);
|
final int firstPosition = mFirstPositions.remove(mFirstPositions.size() - 1);
|
||||||
int top = mTops.remove(mTops.size() - 1);
|
int top = mTops.remove(mTops.size() - 1);
|
||||||
|
|
||||||
Log_OC.v(TAG, "Setting selection to position: " + firstPosition + "; top: "
|
Log_OC.v(TAG, "Setting selection to position: " + firstPosition + "; top: "
|
||||||
+ top + "; index: " + index);
|
+ top + "; index: " + index);
|
||||||
|
|
||||||
if (mCurrentListView!= null && mCurrentListView.equals(mListView)) {
|
if (mCurrentListView != null && mCurrentListView.equals(mListView)) {
|
||||||
if (mHeightCell*index <= mListView.getHeight()) {
|
if (mHeightCell * index <= mListView.getHeight()) {
|
||||||
mListView.setSelectionFromTop(firstPosition, top);
|
mListView.setSelectionFromTop(firstPosition, top);
|
||||||
} else {
|
} else {
|
||||||
mListView.setSelectionFromTop(index, 0);
|
mListView.setSelectionFromTop(index, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (mHeightCell*index <= mGridView.getHeight()) {
|
if (mHeightCell * index <= mGridView.getHeight()) {
|
||||||
mGridView.setSelection(firstPosition);
|
mGridView.setSelection(firstPosition);
|
||||||
//mGridView.smoothScrollToPosition(firstPosition);
|
//mGridView.smoothScrollToPosition(firstPosition);
|
||||||
} else {
|
} else {
|
||||||
|
@ -450,29 +495,29 @@ public class ExtendedListFragment extends Fragment
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Save index and top position
|
* Save index and top position
|
||||||
*/
|
*/
|
||||||
protected void saveIndexAndTopPosition(int index) {
|
protected void saveIndexAndTopPosition(int index) {
|
||||||
|
|
||||||
mIndexes.add(index);
|
mIndexes.add(index);
|
||||||
|
|
||||||
int firstPosition = mCurrentListView.getFirstVisiblePosition();
|
int firstPosition = mCurrentListView.getFirstVisiblePosition();
|
||||||
mFirstPositions.add(firstPosition);
|
mFirstPositions.add(firstPosition);
|
||||||
|
|
||||||
View view = mCurrentListView.getChildAt(0);
|
View view = mCurrentListView.getChildAt(0);
|
||||||
int top = (view == null) ? 0 : view.getTop() ;
|
int top = (view == null) ? 0 : view.getTop();
|
||||||
|
|
||||||
mTops.add(top);
|
mTops.add(top);
|
||||||
|
|
||||||
// Save the height of a cell
|
// Save the height of a cell
|
||||||
mHeightCell = (view == null || mHeightCell != 0) ? mHeightCell : view.getHeight();
|
mHeightCell = (view == null || mHeightCell != 0) ? mHeightCell : view.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
// to be @overriden
|
// to be @overriden
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,7 +546,7 @@ public class ExtendedListFragment extends Fragment
|
||||||
public void setOnRefreshListener(OnEnforceableRefreshListener listener) {
|
public void setOnRefreshListener(OnEnforceableRefreshListener listener) {
|
||||||
mOnRefreshListener = listener;
|
mOnRefreshListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables swipe gesture.
|
* Disables swipe gesture.
|
||||||
|
@ -526,7 +571,7 @@ public class ExtendedListFragment extends Fragment
|
||||||
* @param enabled Desired visibility for the FAB.
|
* @param enabled Desired visibility for the FAB.
|
||||||
*/
|
*/
|
||||||
public void setFabEnabled(boolean enabled) {
|
public void setFabEnabled(boolean enabled) {
|
||||||
if(enabled) {
|
if (enabled) {
|
||||||
mFabMain.setVisibility(View.VISIBLE);
|
mFabMain.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
mFabMain.setVisibility(View.GONE);
|
mFabMain.setVisibility(View.GONE);
|
||||||
|
@ -555,22 +600,52 @@ public class ExtendedListFragment extends Fragment
|
||||||
mEmptyListMessage.setText(message);
|
mEmptyListMessage.setText(message);
|
||||||
mEmptyListIcon.setImageResource(icon);
|
mEmptyListIcon.setImageResource(icon);
|
||||||
|
|
||||||
mEmptyListIcon.setVisibility(View.VISIBLE);
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||||
mEmptyListProgress.setVisibility(View.GONE);
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mEmptyListIcon.setVisibility(View.VISIBLE);
|
||||||
|
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,14 +657,19 @@ public class ExtendedListFragment extends Fragment
|
||||||
mEmptyListHeadline.setText(R.string.file_list_loading);
|
mEmptyListHeadline.setText(R.string.file_list_loading);
|
||||||
mEmptyListMessage.setText("");
|
mEmptyListMessage.setText("");
|
||||||
|
|
||||||
mEmptyListIcon.setVisibility(View.GONE);
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||||
mEmptyListProgress.setVisibility(View.VISIBLE);
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mEmptyListIcon.setVisibility(View.GONE);
|
||||||
|
mEmptyListProgress.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the text of EmptyListMessage TextView.
|
* Get the text of EmptyListMessage TextView.
|
||||||
*
|
*
|
||||||
* @return String empty text view text-value
|
* @return String empty text view text-value
|
||||||
*/
|
*/
|
||||||
public String getEmptyViewText() {
|
public String getEmptyViewText() {
|
||||||
|
@ -632,7 +712,7 @@ public class ExtendedListFragment extends Fragment
|
||||||
protected void setFooterEnabled(boolean enabled) {
|
protected void setFooterEnabled(boolean enabled) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
if (mGridView.getFooterViewCount() == 0 && mGridView.isCorrectAdapter()) {
|
if (mGridView.getFooterViewCount() == 0 && mGridView.isCorrectAdapter()) {
|
||||||
if (mGridFooterView.getParent() != null ) {
|
if (mGridFooterView.getParent() != null) {
|
||||||
((ViewGroup) mGridFooterView.getParent()).removeView(mGridFooterView);
|
((ViewGroup) mGridFooterView.getParent()).removeView(mGridFooterView);
|
||||||
}
|
}
|
||||||
mGridView.addFooterView(mGridFooterView, null, false);
|
mGridView.addFooterView(mGridFooterView, null, false);
|
||||||
|
@ -640,7 +720,7 @@ public class ExtendedListFragment extends Fragment
|
||||||
mGridFooterView.invalidate();
|
mGridFooterView.invalidate();
|
||||||
|
|
||||||
if (mListView.getFooterViewsCount() == 0) {
|
if (mListView.getFooterViewsCount() == 0) {
|
||||||
if (mListFooterView.getParent() != null ) {
|
if (mListFooterView.getParent() != null) {
|
||||||
((ViewGroup) mListFooterView.getParent()).removeView(mListFooterView);
|
((ViewGroup) mListFooterView.getParent()).removeView(mListFooterView);
|
||||||
}
|
}
|
||||||
mListView.addFooterView(mListFooterView, null, false);
|
mListView.addFooterView(mListFooterView, null, false);
|
||||||
|
@ -660,8 +740,8 @@ public class ExtendedListFragment extends Fragment
|
||||||
*/
|
*/
|
||||||
protected void setFooterText(String text) {
|
protected void setFooterText(String text) {
|
||||||
if (text != null && text.length() > 0) {
|
if (text != null && text.length() > 0) {
|
||||||
((TextView)mListFooterView.findViewById(R.id.footerText)).setText(text);
|
((TextView) mListFooterView.findViewById(R.id.footerText)).setText(text);
|
||||||
((TextView)mGridFooterView.findViewById(R.id.footerText)).setText(text);
|
((TextView) mGridFooterView.findViewById(R.id.footerText)).setText(text);
|
||||||
setFooterEnabled(true);
|
setFooterEnabled(true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,24 +1,23 @@
|
||||||
/**
|
/**
|
||||||
* ownCloud Android client application
|
* ownCloud Android client application
|
||||||
*
|
|
||||||
* @author Bartek Przybylski
|
|
||||||
* @author masensio
|
|
||||||
* @author David A. Velasco
|
|
||||||
* Copyright (C) 2011 Bartek Przybylski
|
|
||||||
* Copyright (C) 2016 ownCloud Inc.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License version 2,
|
|
||||||
* as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
*
|
||||||
|
* @author Bartek Przybylski
|
||||||
|
* @author masensio
|
||||||
|
* @author David A. Velasco
|
||||||
|
* Copyright (C) 2011 Bartek Przybylski
|
||||||
|
* Copyright (C) 2016 ownCloud Inc.
|
||||||
|
* <p>
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2,
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
* <p>
|
||||||
|
* 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 General Public License for more details.
|
||||||
|
* <p>
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* 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;
|
||||||
|
@ -200,28 +202,29 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
|
|
||||||
bottomNavigationView.setOnNavigationItemSelectedListener(
|
bottomNavigationView.setOnNavigationItemSelectedListener(
|
||||||
new BottomNavigationView.OnNavigationItemSelectedListener() {
|
new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.nav_bar_files:
|
case R.id.nav_bar_files:
|
||||||
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,
|
||||||
break;
|
SearchEvent.UnsetType.UNSET_DRAWER));
|
||||||
case R.id.nav_bar_photos:
|
break;
|
||||||
EventBus.getDefault().post(new SearchEvent("image/%",
|
case R.id.nav_bar_photos:
|
||||||
SearchOperation.SearchType.CONTENT_TYPE_SEARCH));
|
EventBus.getDefault().post(new SearchEvent("image/%",
|
||||||
break;
|
SearchOperation.SearchType.CONTENT_TYPE_SEARCH, SearchEvent.UnsetType.UNSET_DRAWER));
|
||||||
case R.id.nav_bar_settings:
|
break;
|
||||||
EventBus.getDefault().post(new MenuItemClickEvent(item));
|
case R.id.nav_bar_settings:
|
||||||
break;
|
EventBus.getDefault().post(new MenuItemClickEvent(item));
|
||||||
default:
|
break;
|
||||||
break;
|
default:
|
||||||
}
|
break;
|
||||||
return true;
|
}
|
||||||
}
|
return true;
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -276,12 +279,12 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
|
|
||||||
// detect if a mini FAB has ever been clicked
|
// detect if a mini FAB has ever been clicked
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
if(prefs.getLong(KEY_FAB_EVER_CLICKED, 0) > 0) {
|
if (prefs.getLong(KEY_FAB_EVER_CLICKED, 0) > 0) {
|
||||||
miniFabClicked = true;
|
miniFabClicked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add labels to the min FABs when none of them has ever been clicked on
|
// add labels to the min FABs when none of them has ever been clicked on
|
||||||
if(!miniFabClicked) {
|
if (!miniFabClicked) {
|
||||||
setFabLabels();
|
setFabLabels();
|
||||||
} else {
|
} else {
|
||||||
removeFabLabels();
|
removeFabLabels();
|
||||||
|
@ -399,7 +402,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
*/
|
*/
|
||||||
private void recordMiniFabClick() {
|
private void recordMiniFabClick() {
|
||||||
// only record if it hasn't been done already at some other time
|
// only record if it hasn't been done already at some other time
|
||||||
if(!miniFabClicked) {
|
if (!miniFabClicked) {
|
||||||
final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
sp.edit().putLong(KEY_FAB_EVER_CLICKED, 1).apply();
|
sp.edit().putLong(KEY_FAB_EVER_CLICKED, 1).apply();
|
||||||
miniFabClicked = true;
|
miniFabClicked = true;
|
||||||
|
@ -435,7 +438,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
* and closed.
|
* and closed.
|
||||||
*/
|
*/
|
||||||
private class MultiChoiceModeListener
|
private class MultiChoiceModeListener
|
||||||
implements AbsListView.MultiChoiceModeListener, DrawerLayout.DrawerListener {
|
implements AbsListView.MultiChoiceModeListener, DrawerLayout.DrawerListener {
|
||||||
|
|
||||||
private static final String KEY_ACTION_MODE_CLOSED_BY_DRAWER = "KILLED_ACTION_MODE";
|
private static final String KEY_ACTION_MODE_CLOSED_BY_DRAWER = "KILLED_ACTION_MODE";
|
||||||
private static final String KEY_SELECTION_WHEN_CLOSED_BY_DRAWER = "CHECKED_ITEMS";
|
private static final String KEY_SELECTION_WHEN_CLOSED_BY_DRAWER = "CHECKED_ITEMS";
|
||||||
|
@ -468,12 +471,12 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onDrawerClosed(View drawerView) {
|
public void onDrawerClosed(View drawerView) {
|
||||||
if (mSelectionWhenActionModeClosedByDrawer !=null && mActionModeClosedByDrawer) {
|
if (mSelectionWhenActionModeClosedByDrawer != null && mActionModeClosedByDrawer) {
|
||||||
for (int i = 0; i< mSelectionWhenActionModeClosedByDrawer.size(); i++) {
|
for (int i = 0; i < mSelectionWhenActionModeClosedByDrawer.size(); i++) {
|
||||||
if (mSelectionWhenActionModeClosedByDrawer.valueAt(i)) {
|
if (mSelectionWhenActionModeClosedByDrawer.valueAt(i)) {
|
||||||
getListView().setItemChecked(
|
getListView().setItemChecked(
|
||||||
mSelectionWhenActionModeClosedByDrawer.keyAt(i),
|
mSelectionWhenActionModeClosedByDrawer.keyAt(i),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -535,16 +538,16 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
List<OCFile> checkedFiles = mAdapter.getCheckedItems(getListView());
|
List<OCFile> checkedFiles = mAdapter.getCheckedItems(getListView());
|
||||||
final int checkedCount = checkedFiles.size();
|
final int checkedCount = checkedFiles.size();
|
||||||
String title = getResources().getQuantityString(
|
String title = getResources().getQuantityString(
|
||||||
R.plurals.items_selected_count,
|
R.plurals.items_selected_count,
|
||||||
checkedCount,
|
checkedCount,
|
||||||
checkedCount
|
checkedCount
|
||||||
);
|
);
|
||||||
mode.setTitle(title);
|
mode.setTitle(title);
|
||||||
FileMenuFilter mf = new FileMenuFilter(
|
FileMenuFilter mf = new FileMenuFilter(
|
||||||
checkedFiles,
|
checkedFiles,
|
||||||
((FileActivity) getActivity()).getAccount(),
|
((FileActivity) getActivity()).getAccount(),
|
||||||
mContainerActivity,
|
mContainerActivity,
|
||||||
getActivity()
|
getActivity()
|
||||||
);
|
);
|
||||||
mf.filter(menu);
|
mf.filter(menu);
|
||||||
return true;
|
return true;
|
||||||
|
@ -570,7 +573,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
DisplayUtils.colorToolbarProgressBar(getActivity(), mProgressBarColor);
|
DisplayUtils.colorToolbarProgressBar(getActivity(), mProgressBarColor);
|
||||||
|
|
||||||
// show FAB on multi selection mode exit
|
// show FAB on multi selection mode exit
|
||||||
if(!mHideFab) {
|
if (!mHideFab) {
|
||||||
setFabEnabled(true);
|
setFabEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -580,7 +583,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
outState.putBoolean(KEY_ACTION_MODE_CLOSED_BY_DRAWER, mActionModeClosedByDrawer);
|
outState.putBoolean(KEY_ACTION_MODE_CLOSED_BY_DRAWER, mActionModeClosedByDrawer);
|
||||||
if (mSelectionWhenActionModeClosedByDrawer != null) {
|
if (mSelectionWhenActionModeClosedByDrawer != null) {
|
||||||
SparseBooleanArrayParcelable sbap = new SparseBooleanArrayParcelable(
|
SparseBooleanArrayParcelable sbap = new SparseBooleanArrayParcelable(
|
||||||
mSelectionWhenActionModeClosedByDrawer
|
mSelectionWhenActionModeClosedByDrawer
|
||||||
);
|
);
|
||||||
outState.putParcelable(KEY_SELECTION_WHEN_CLOSED_BY_DRAWER, sbap);
|
outState.putParcelable(KEY_SELECTION_WHEN_CLOSED_BY_DRAWER, sbap);
|
||||||
}
|
}
|
||||||
|
@ -588,11 +591,11 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
|
|
||||||
public void loadStateFrom(Bundle savedInstanceState) {
|
public void loadStateFrom(Bundle savedInstanceState) {
|
||||||
mActionModeClosedByDrawer = savedInstanceState.getBoolean(
|
mActionModeClosedByDrawer = savedInstanceState.getBoolean(
|
||||||
KEY_ACTION_MODE_CLOSED_BY_DRAWER,
|
KEY_ACTION_MODE_CLOSED_BY_DRAWER,
|
||||||
mActionModeClosedByDrawer
|
mActionModeClosedByDrawer
|
||||||
);
|
);
|
||||||
SparseBooleanArrayParcelable sbap = savedInstanceState.getParcelable(
|
SparseBooleanArrayParcelable sbap = savedInstanceState.getParcelable(
|
||||||
KEY_SELECTION_WHEN_CLOSED_BY_DRAWER
|
KEY_SELECTION_WHEN_CLOSED_BY_DRAWER
|
||||||
);
|
);
|
||||||
if (sbap != null) {
|
if (sbap != null) {
|
||||||
mSelectionWhenActionModeClosedByDrawer = sbap.getSparseBooleanArray();
|
mSelectionWhenActionModeClosedByDrawer = sbap.getSparseBooleanArray();
|
||||||
|
@ -609,7 +612,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
mMultiChoiceModeListener.loadStateFrom(savedInstanceState);
|
mMultiChoiceModeListener.loadStateFrom(savedInstanceState);
|
||||||
}
|
}
|
||||||
setMultiChoiceModeListener(mMultiChoiceModeListener);
|
setMultiChoiceModeListener(mMultiChoiceModeListener);
|
||||||
((FileActivity)getActivity()).addDrawerListener(mMultiChoiceModeListener);
|
((FileActivity) getActivity()).addDrawerListener(mMultiChoiceModeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -623,7 +626,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareOptionsMenu (Menu menu) {
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
changeGridIcon(menu); // this is enough if the option stays out of the action bar
|
changeGridIcon(menu); // this is enough if the option stays out of the action bar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,9 +691,9 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
} else { /// Click on a file
|
} else { /// Click on a file
|
||||||
if (PreviewImageFragment.canBePreviewed(file)) {
|
if (PreviewImageFragment.canBePreviewed(file)) {
|
||||||
// preview image - it handles the download, if needed
|
// preview image - it handles the download, if needed
|
||||||
((FileDisplayActivity)mContainerActivity).startImagePreview(file);
|
((FileDisplayActivity) mContainerActivity).startImagePreview(file);
|
||||||
} else if (PreviewTextFragment.canBePreviewed(file)){
|
} else if (PreviewTextFragment.canBePreviewed(file)) {
|
||||||
((FileDisplayActivity)mContainerActivity).startTextPreview(file);
|
((FileDisplayActivity) mContainerActivity).startTextPreview(file);
|
||||||
} else if (file.isDown()) {
|
} else if (file.isDown()) {
|
||||||
if (PreviewMediaFragment.canBePreviewed(file)) {
|
if (PreviewMediaFragment.canBePreviewed(file)) {
|
||||||
// media preview
|
// media preview
|
||||||
|
@ -817,11 +820,11 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
/**
|
/**
|
||||||
* Calls {@link OCFileListFragment#listDirectory(OCFile, boolean, boolean)} with a null parameter
|
* Calls {@link OCFileListFragment#listDirectory(OCFile, boolean, boolean)} with a null parameter
|
||||||
*/
|
*/
|
||||||
public void listDirectory(boolean onlyOnDevice, boolean fromSearch){
|
public void listDirectory(boolean onlyOnDevice, boolean fromSearch) {
|
||||||
listDirectory(null, onlyOnDevice, fromSearch);
|
listDirectory(null, onlyOnDevice, fromSearch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshDirectory(){
|
public void refreshDirectory() {
|
||||||
listDirectory(getCurrentFile(), MainApp.isOnlyOnDevice(), false);
|
listDirectory(getCurrentFile(), MainApp.isOnlyOnDevice(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -911,7 +914,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
updateFooter();
|
updateFooter();
|
||||||
// decide grid vs list view
|
// decide grid vs list view
|
||||||
OwnCloudVersion version = AccountUtils.getServerVersion(
|
OwnCloudVersion version = AccountUtils.getServerVersion(
|
||||||
((FileActivity)mContainerActivity).getAccount());
|
((FileActivity) mContainerActivity).getAccount());
|
||||||
if (version != null && version.supportsRemoteThumbnails() &&
|
if (version != null && version.supportsRemoteThumbnails() &&
|
||||||
isGridViewPreferred(mFile)) {
|
isGridViewPreferred(mFile)) {
|
||||||
switchToGridView();
|
switchToGridView();
|
||||||
|
@ -923,7 +926,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invalidateActionMode() {
|
private void invalidateActionMode() {
|
||||||
if(mActiveActionMode != null){
|
if (mActiveActionMode != null) {
|
||||||
mActiveActionMode.invalidate();
|
mActiveActionMode.invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -986,7 +989,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
* @param file Folder to check.
|
* @param file Folder to check.
|
||||||
* @return 'true' is folder should be shown in grid mode, 'false' if list mode is preferred.
|
* @return 'true' is folder should be shown in grid mode, 'false' if list mode is preferred.
|
||||||
*/
|
*/
|
||||||
public boolean isGridViewPreferred(OCFile file){
|
public boolean isGridViewPreferred(OCFile file) {
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
OCFile fileToTest = file;
|
OCFile fileToTest = file;
|
||||||
OCFile parentDir;
|
OCFile parentDir;
|
||||||
|
@ -1034,9 +1037,9 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeGridIcon(Menu menu){
|
private void changeGridIcon(Menu menu) {
|
||||||
MenuItem menuItem = menu.findItem(R.id.action_switch_view);
|
MenuItem menuItem = menu.findItem(R.id.action_switch_view);
|
||||||
if (isGridViewPreferred(mFile)){
|
if (isGridViewPreferred(mFile)) {
|
||||||
menuItem.setTitle(getString(R.string.action_switch_list_view));
|
menuItem.setTitle(getString(R.string.action_switch_list_view));
|
||||||
menuItem.setIcon(R.drawable.ic_view_list);
|
menuItem.setIcon(R.drawable.ic_view_list);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1055,7 +1058,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
switchToGridView();
|
switchToGridView();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveGridAsPreferred(boolean setGrid){
|
private void saveGridAsPreferred(boolean setGrid) {
|
||||||
SharedPreferences setting = getActivity().getSharedPreferences(
|
SharedPreferences setting = getActivity().getSharedPreferences(
|
||||||
GRID_IS_PREFERED_PREFERENCE, Context.MODE_PRIVATE
|
GRID_IS_PREFERED_PREFERENCE, Context.MODE_PRIVATE
|
||||||
);
|
);
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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 -->
|
||||||
|
|
|
@ -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…</string>
|
<string name="file_list_loading">Loading…</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>
|
||||||
|
|
Loading…
Reference in a new issue