Merge branch 'navigationDrawer_update' of github.com:owncloud/android into navigationDrawer_update

This commit is contained in:
tobiasKaminsky 2015-05-27 18:35:21 +02:00
commit e80828afed
23 changed files with 487 additions and 287 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -1,25 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2013 The Android Open Source Project
ownCloud Android client application
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Copyright (C) 2015 ownCloud Inc.
http://www.apache.org/licenses/LICENSE-2.0
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.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
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/>.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_textView"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/itemLayout"
android:layout_width="fill_parent"
android:layout_height="56dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:orientation="horizontal"
android:background="@color/background_color"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/itemTitle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColor="#000"
android:textSize="18dp" />
android:textColor="@color/textColor"
android:text="@string/app_name"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:minHeight="?android:attr/listPreferredItemHeightSmall"/>
</LinearLayout>

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
ownCloud Android client application
Copyright (C) 2015 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/>.
-->
<resources>
<!-- Nav Drawer Menu Items -->
<string-array name="drawer_items">
<item>@string/prefs_accounts</item>
<item>@string/drawer_item_all_files</item>
<!--<item>@string/drawer_item_on_device</item>-->
<item>@string/actionbar_settings</item>
<item>@string/actionbar_logger</item>
</string-array>
<!-- Nav Drawer Content Descriptions -->
<string-array name="drawer_content_descriptions">
<item>@string/drawer_item_accounts</item>
<item>@string/drawer_item_all_files</item>
<!--<item>@string/drawer_item_on_device</item>-->
<item>@string/drawer_item_settings</item>
<item>@string/drawer_item_logs</item>
</string-array>
</resources>

View file

@ -20,12 +20,12 @@
<!-- TODO re-enable when server-side folder size calculation is available
<item>Biggest - Smallest</item> -->
</string-array>
<string-array name="drawer_items">
<item>Accounts</item>
<item>All Files</item>
<item>On device</item>
<item>Settings</item>
</string-array>
<string name="drawer_item_accounts">Accounts</string>
<string name="drawer_item_all_files">All files</string>
<!-- TODO re-enable when "On Device" is available
<string name="drawer_item_on_device">On device</string>-->
<string name="drawer_item_settings">Settings</string>
<string name="drawer_item_logs">Logs</string>
<string name="drawer_open">ownCloud</string>
<string name="drawer_close">Close</string>
<string name="prefs_category_general">General</string>

View file

@ -56,7 +56,6 @@
<PreferenceCategory android:title="@string/prefs_category_more" android:key="more">
<Preference android:title="@string/prefs_help" android:key="help" />
<Preference android:title="@string/actionbar_logger" android:key="log" />
<Preference android:title="@string/prefs_recommend" android:key="recommend" />
<Preference android:title="@string/prefs_feedback" android:key="feedback" />
<Preference android:title="@string/prefs_imprint" android:key="imprint" />

View file

@ -54,8 +54,9 @@ public class MainApp extends Application {
private static Context mContext;
// TODO Enable when "On Device" is recovered?
// TODO better place
private static boolean mOnlyOnDevice = false;
// private static boolean mOnlyOnDevice = false;
public void onCreate(){
@ -175,13 +176,14 @@ public class MainApp extends Application {
return getAppContext().getResources().getString(R.string.log_name);
}
public static void showOnlyFilesOnDevice(boolean state){
mOnlyOnDevice = state;
}
public static boolean getOnlyOnDevice(){
return mOnlyOnDevice;
}
// TODO Enable when "On Device" is recovered ?
// public static void showOnlyFilesOnDevice(boolean state){
// mOnlyOnDevice = state;
// }
//
// public static boolean getOnlyOnDevice(){
// return mOnlyOnDevice;
// }
// user agent
public static String getUserAgent() {

View file

@ -142,9 +142,10 @@ public class FileDataStorageManager {
}
public Vector<OCFile> getFolderContent(OCFile f, boolean onlyOnDevice) {
public Vector<OCFile> getFolderContent(OCFile f/*, boolean onlyOnDevice*/) {
if (f != null && f.isFolder() && f.getFileId() != -1) {
return getFolderContent(f.getFileId(), onlyOnDevice);
// TODO Enable when "On Device" is recovered ?
return getFolderContent(f.getFileId()/*, onlyOnDevice*/);
} else {
return new Vector<OCFile>();
@ -152,11 +153,12 @@ public class FileDataStorageManager {
}
public Vector<OCFile> getFolderImages(OCFile folder, boolean onlyOnDevice) {
public Vector<OCFile> getFolderImages(OCFile folder/*, boolean onlyOnDevice*/) {
Vector<OCFile> ret = new Vector<OCFile>();
if (folder != null) {
// TODO better implementation, filtering in the access to database instead of here
Vector<OCFile> tmp = getFolderContent(folder, onlyOnDevice);
// TODO Enable when "On Device" is recovered ?
Vector<OCFile> tmp = getFolderContent(folder/*, onlyOnDevice*/);
OCFile current = null;
for (int i=0; i<tmp.size(); i++) {
current = tmp.get(i);
@ -547,7 +549,8 @@ public class FileDataStorageManager {
File localFolder = new File(localFolderPath);
if (localFolder.exists()) {
// stage 1: remove the local files already registered in the files database
Vector<OCFile> files = getFolderContent(folder.getFileId(), false);
// TODO Enable when "On Device" is recovered ?
Vector<OCFile> files = getFolderContent(folder.getFileId()/*, false*/);
if (files != null) {
for (OCFile file : files) {
if (file.isFolder()) {
@ -731,7 +734,7 @@ public class FileDataStorageManager {
}
private Vector<OCFile> getFolderContent(long parentId, boolean onlyOnDevice) {
private Vector<OCFile> getFolderContent(long parentId/*, boolean onlyOnDevice*/) {
Vector<OCFile> ret = new Vector<OCFile>();
@ -758,9 +761,10 @@ public class FileDataStorageManager {
if (c.moveToFirst()) {
do {
OCFile child = createFileInstance(c);
if (child.isFolder() || !onlyOnDevice || onlyOnDevice && child.isDown()){
// TODO Enable when "On Device" is recovered ?
// if (child.isFolder() || !onlyOnDevice || onlyOnDevice && child.isDown()){
ret.add(child);
}
// }
} while (c.moveToNext());
}
@ -1443,7 +1447,8 @@ public class FileDataStorageManager {
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
String [] whereArgs = new String[]{ "", mAccount.name };
Vector<OCFile> files = getFolderContent(folder, false);
// TODO Enable when "On Device" is recovered ?
Vector<OCFile> files = getFolderContent(folder /*, false*/);
for (OCFile file : files) {
whereArgs[0] = file.getRemotePath();

View file

@ -201,7 +201,8 @@ public class RefreshFolderOperation extends RemoteOperation {
if (mRemoteFolderChanged) {
result = fetchAndSyncRemoteFolder(client);
} else {
mChildren = mStorageManager.getFolderContent(mLocalFolder, false);
// TODO Enable when "On Device" is recovered ?
mChildren = mStorageManager.getFolderContent(mLocalFolder/*, false*/);
}
}
@ -341,7 +342,8 @@ public class RefreshFolderOperation extends RemoteOperation {
List<SynchronizeFileOperation> filesToSyncContents = new Vector<SynchronizeFileOperation>();
// get current data about local contents of the folder to synchronize
List<OCFile> localFiles = mStorageManager.getFolderContent(mLocalFolder, false);
// TODO Enable when "On Device" is recovered ?
List<OCFile> localFiles = mStorageManager.getFolderContent(mLocalFolder/*, false*/);
Map<String, OCFile> localFilesMap = new HashMap<String, OCFile>(localFiles.size());
for (OCFile file : localFiles) {
localFilesMap.put(file.getRemotePath(), file);

View file

@ -21,51 +21,33 @@
package com.owncloud.android.operations;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.apache.http.HttpStatus;
import android.accounts.Account;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.owncloud.android.MainApp;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.OperationCancelledException;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.FileUtils;
import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.syncadapter.FileSyncAdapter;
import com.owncloud.android.operations.common.SyncOperation;
import com.owncloud.android.services.OperationsService;
import com.owncloud.android.utils.FileStorageUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicBoolean;
//import android.support.v4.content.LocalBroadcastManager;
@ -316,7 +298,8 @@ public class SynchronizeFolderOperation extends SyncOperation {
}
// get current data about local contents of the folder to synchronize
List<OCFile> localFiles = storageManager.getFolderContent(mLocalFolder, false);
// TODO Enable when "On Device" is recovered ?
List<OCFile> localFiles = storageManager.getFolderContent(mLocalFolder/*, false*/);
Map<String, OCFile> localFilesMap = new HashMap<String, OCFile>(localFiles.size());
for (OCFile file : localFiles) {
localFilesMap.put(file.getRemotePath(), file);
@ -411,8 +394,8 @@ public class SynchronizeFolderOperation extends SyncOperation {
private void prepareOpsFromLocalKnowledge() throws OperationCancelledException {
// TODO TOBI ist das richtig?
List<OCFile> children = getStorageManager().getFolderContent(mLocalFolder, false);
// TODO Enable when "On Device" is recovered ?
List<OCFile> children = getStorageManager().getFolderContent(mLocalFolder/*, false*/);
for (OCFile child : children) {
/// classify file to sync/download contents later
if (child.isFolder()) {

View file

@ -0,0 +1,56 @@
/**
* ownCloud Android client application
*
* @author masensio
* Copyright (C) 2015 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/>.
*
*/
package com.owncloud.android.ui;
public class NavigationDrawerItem {
private String mTitle;
private String mContentDescription;
// Constructors
public NavigationDrawerItem(){}
public NavigationDrawerItem(String title){
mTitle = title;
}
public NavigationDrawerItem(String title, String contentDescription){
mTitle = title;
mContentDescription = contentDescription;
}
// Getters and Setters
public String getTitle() {
return mTitle;
}
public void setTitle(String title) {
this.mTitle = title;
}
public String getContentDescription() {
return mContentDescription;
}
public void setContentDescription(String contentDescription) {
this.mContentDescription = contentDescription;
}
}

View file

@ -23,11 +23,11 @@
package com.owncloud.android.ui.activity;
import java.io.File;
import java.util.ArrayList;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
@ -55,7 +55,6 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
@ -73,6 +72,7 @@ import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window;
import com.owncloud.android.BuildConfig;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
@ -101,7 +101,7 @@ import com.owncloud.android.operations.RefreshFolderOperation;
import com.owncloud.android.operations.UnshareLinkOperation;
import com.owncloud.android.services.observer.FileObserverService;
import com.owncloud.android.syncadapter.FileSyncAdapter;
import com.owncloud.android.ui.adapter.FileListListAdapter;
import com.owncloud.android.ui.NavigationDrawerItem;
import com.owncloud.android.ui.adapter.NavigationDrawerListAdapter;
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
@ -164,13 +164,22 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
private static String DIALOG_UPLOAD_SOURCE = "DIALOG_UPLOAD_SOURCE";
private static String DIALOG_CERT_NOT_SAVED = "DIALOG_CERT_NOT_SAVED";
private NavigationDrawerListAdapter adapter = null;
private OCFile mWaitingToSend;
// Navigation Drawer
private DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mDrawerToggle;
private boolean showAccounts = false;
private ListView mDrawerList;
// Slide menu items
private String[] mDrawerTitles;
private String[] mDrawerContentDescriptions;
private ArrayList<NavigationDrawerItem> mDrawerItems;
private NavigationDrawerListAdapter mNavigationDrawerAdapter = null;
private boolean mShowAccounts = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -202,16 +211,91 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
// Inflate and set the layout view
setContentView(R.layout.files);
// TODO move to another place that all activity can use it
// Navigation Drawer
initDrawer();
mDualPane = getResources().getBoolean(R.bool.large_land_layout);
mLeftFragmentContainer = findViewById(R.id.left_fragment_container);
mRightFragmentContainer = findViewById(R.id.right_fragment_container);
if (savedInstanceState == null) {
createMinFragments();
}
// Action bar setup
mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation
getSupportActionBar().setDisplayShowCustomEnabled(true); // CRUCIAL - for displaying your custom actionbar
getSupportActionBar().setDisplayShowTitleEnabled(true);
setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/); // always AFTER setContentView(...) ; to work around bug in its implementation
// TODO Remove??, it is done in onPostCreate
mDrawerToggle.syncState();
setBackgroundText();
Log_OC.v(TAG, "onCreate() end");
}
private void initDrawer(){
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
// Notification Drawer
LinearLayout navigationDrawerLayout = (LinearLayout) findViewById(R.id.left_drawer);
mDrawerList = (ListView) navigationDrawerLayout.findViewById(R.id.drawer_list);
// load Account in the Drawer Title
// User-Icon
ImageView userIcon = (ImageView) navigationDrawerLayout.findViewById(R.id.drawer_userIcon);
userIcon.setImageResource(DisplayUtils.getSeasonalIconId());
// Username
TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
if (account != null) {
int lastAtPos = account.name.lastIndexOf("@");
username.setText(account.name.substring(0, lastAtPos));
}
// load slide menu items
mDrawerTitles = getResources().getStringArray(R.array.drawer_items);
// nav drawer content description from resources
mDrawerContentDescriptions = getResources().
getStringArray(R.array.drawer_content_descriptions);
// nav drawer items
mDrawerItems = new ArrayList<NavigationDrawerItem>();
// adding nav drawer items to array
// Accounts
mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[0], mDrawerContentDescriptions[0]));
// All Files
mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[1], mDrawerContentDescriptions[1]));
// TODO Enable when "On Device" is recovered
// On Device
//mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2],
// mDrawerContentDescriptions[2]));
// Settings
mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2], mDrawerContentDescriptions[2]));
// Logs
if (BuildConfig.DEBUG) {
mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[3],
mDrawerContentDescriptions[3]));
}
// setting the nav drawer list adapter
mNavigationDrawerAdapter = new NavigationDrawerListAdapter(getApplicationContext(), this,
mDrawerItems);
mDrawerList.setAdapter(mNavigationDrawerAdapter);
mDrawerToggle = new ActionBarDrawerToggle(
this,
mDrawerLayout,
R.drawable.ic_drawer,
R.string.drawer_open,
R.string.empty
) {
R.string.empty) {
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
@ -232,80 +316,11 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
};
mDrawerToggle.setDrawerIndicatorEnabled(true);
// Notification Drawer
LinearLayout notificatonDrawer = (LinearLayout) findViewById(R.id.left_drawer);
// ListView
ListView listView = (ListView) notificatonDrawer.findViewById(R.id.drawer_list);
adapter = new NavigationDrawerListAdapter(getApplicationContext(), this);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (showAccounts && position > 0){
position = position - 1;
}
switch (position){
case 0:
showAccounts = !showAccounts;
adapter.setShowAccounts(showAccounts);
adapter.notifyDataSetChanged();
break;
case 1:
MainApp.showOnlyFilesOnDevice(false);
mDrawerLayout.closeDrawers();
break;
case 2:
MainApp.showOnlyFilesOnDevice(true);
mDrawerLayout.closeDrawers();
break;
case 3:
Intent settingsIntent = new Intent(getApplicationContext(), Preferences.class);
startActivity(settingsIntent);
break;
}
}
});
// User-Icon
ImageView userIcon = (ImageView) notificatonDrawer.findViewById(R.id.drawer_userIcon);
userIcon.setImageResource(DisplayUtils.getSeasonalIconId());
// Username
TextView username = (TextView) notificatonDrawer.findViewById(R.id.drawer_username);
Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
if (account != null) {
int lastAtPos = account.name.lastIndexOf("@");
username.setText(account.name.substring(0, lastAtPos));
}
// Set the list's click listener
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
// Set the drawer toggle as the DrawerListener
mDrawerLayout.setDrawerListener(mDrawerToggle);
mDualPane = getResources().getBoolean(R.bool.large_land_layout);
mLeftFragmentContainer = findViewById(R.id.left_fragment_container);
mRightFragmentContainer = findViewById(R.id.right_fragment_container);
if (savedInstanceState == null) {
createMinFragments();
}
// Action bar setup
mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation
getSupportActionBar().setDisplayShowCustomEnabled(true); // CRUCIAL - for displaying your custom actionbar
getSupportActionBar().setDisplayShowTitleEnabled(true);
setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/); // always AFTER setContentView(...) ; to work around bug in its implementation
mDrawerToggle.syncState();
setBackgroundText();
Log_OC.v(TAG, "onCreate() end");
}
@Override
@ -408,7 +423,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
/// First fragment
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) {
listOfFiles.listDirectory(getCurrentDir(), MainApp.getOnlyOnDevice());
listOfFiles.listDirectory(getCurrentDir());
// TODO Enable when "On Device" is recovered
// listOfFiles.listDirectory(getCurrentDir(), MainApp.getOnlyOnDevice());
} else {
Log_OC.e(TAG, "Still have a chance to lose the initializacion of list fragment >(");
}
@ -528,7 +545,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
protected void refreshListOfFilesFragment() {
OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) {
fileListFragment.listDirectory(MainApp.getOnlyOnDevice());
fileListFragment.listDirectory();
// TODO Enable when "On Device" is recovered ?
// fileListFragment.listDirectory(MainApp.getOnlyOnDevice());
}
}
@ -623,7 +642,6 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
builder.setTitle(R.string.actionbar_sort_title)
.setSingleChoiceItems(R.array.actionbar_sortby, sortOrder , new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
switch (which){
case 0:
sortByName(true);
@ -631,11 +649,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
case 1:
sortByDate(false);
break;
}
dialog.dismiss();
}
});
builder.create().show();
@ -895,7 +911,7 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
super.onResume();
// refresh Navigation Drawer account list
adapter.updateAccountList();
mNavigationDrawerAdapter.updateAccountList();
// refresh list of files
refreshListOfFilesFragment();
@ -1046,7 +1062,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
if (synchFolderRemotePath != null && currentDir.getRemotePath().equals(synchFolderRemotePath)) {
OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) {
fileListFragment.listDirectory(currentDir, MainApp.getOnlyOnDevice());
fileListFragment.listDirectory();
// TODO Enable when "On Device" is recovered ?
// fileListFragment.listDirectory(currentDir, MainApp.getOnlyOnDevice());
}
}
setFile(currentFile);
@ -1275,7 +1293,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
popDirname();
}
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
listOfFiles.listDirectory(root, MainApp.getOnlyOnDevice());
listOfFiles.listDirectory(root);
// TODO Enable when "On Device" is recovered ?
// listOfFiles.listDirectory(root, MainApp.getOnlyOnDevice());
setFile(listOfFiles.getCurrentFile());
startSyncFolderOperation(root, false);
}
@ -1290,7 +1310,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) {
setNavigationListWithFolder(folder);
listOfFiles.listDirectory(folder, MainApp.getOnlyOnDevice());
listOfFiles.listDirectory(folder);
// TODO Enable when "On Device" is recovered ?
// listOfFiles.listDirectory(folder, MainApp.getOnlyOnDevice());
setFile(listOfFiles.getCurrentFile());
startSyncFolderOperation(folder, false);
} else {
@ -1402,7 +1424,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
// a new chance to get the mDownloadBinder through getFileDownloadBinder() - THIS IS A MESS
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) {
listOfFiles.listDirectory(MainApp.getOnlyOnDevice());
listOfFiles.listDirectory();
// TODO Enable when "On Device" is recovered ?
// listOfFiles.listDirectory(MainApp.getOnlyOnDevice());
}
FileFragment secondFragment = getSecondFragment();
if (secondFragment != null && secondFragment instanceof FileDetailFragment) {
@ -1886,4 +1910,43 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
mDrawerLayout.closeDrawers();
}
private class DrawerItemClickListener implements ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (mShowAccounts && position > 0){
position = position - 1;
}
switch (position){
case 0: // Accounts
mShowAccounts = !mShowAccounts;
mNavigationDrawerAdapter.setShowAccounts(mShowAccounts);
mNavigationDrawerAdapter.notifyDataSetChanged();
break;
case 1: // All Files
// TODO Enable when "On Device" is recovered ?
//MainApp.showOnlyFilesOnDevice(false);
mDrawerLayout.closeDrawers();
break;
// TODO Enable when "On Device" is recovered ?
// case 2:
// MainApp.showOnlyFilesOnDevice(true);
// mDrawerLayout.closeDrawers();
// break;
case 2: // Settings
Intent settingsIntent = new Intent(getApplicationContext(),
Preferences.class);
startActivity(settingsIntent);
break;
case 3: // Logs
Intent loggerIntent = new Intent(getApplicationContext(),
LogHistoryActivity.class);
startActivity(loggerIntent);
break;
}
}
}
}

View file

@ -19,12 +19,9 @@
package com.owncloud.android.ui.activity;
import java.io.IOException;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@ -45,7 +42,6 @@ import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudAccount;
@ -142,7 +138,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
if (!stateWasRecovered) {
OCFileListFragment listOfFolders = getListOfFilesFragment();
listOfFolders.listDirectory(folder, false);
listOfFolders.listDirectory(folder/*, false*/);
startSyncFolderOperation(folder, false);
}
@ -311,7 +307,9 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
protected void refreshListOfFilesFragment() {
OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) {
fileListFragment.listDirectory(false);
fileListFragment.listDirectory();
// TODO Enable when "On Device" is recovered ?
// fileListFragment.listDirectory(false);
}
}
@ -319,7 +317,9 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) { // should never be null, indeed
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
listOfFiles.listDirectory(root, false);
listOfFiles.listDirectory(root);
// TODO Enable when "On Device" is recovered ?
// listOfFiles.listDirectory(root, false);
setFile(listOfFiles.getCurrentFile());
updateNavigationElementsInActionBar();
startSyncFolderOperation(root, false);
@ -471,7 +471,9 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
equals(synchFolderRemotePath)) {
OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) {
fileListFragment.listDirectory(currentDir, false);
fileListFragment.listDirectory(currentDir);
// TODO Enable when "On Device" is recovered ?
// fileListFragment.listDirectory(currentDir, false);
}
}
setFile(currentFile);

View file

@ -236,7 +236,8 @@ public class Preferences extends SherlockPreferenceActivity
Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(Preferences.this);
String username = currentAccount.name.substring(0, currentAccount.name.lastIndexOf('@'));
String recommendSubject = String.format(getString(R.string.recommend_subject), appName);
String recommendSubject = String.format(getString(R.string.recommend_subject),
appName);
String recommendText = String.format(getString(R.string.recommend_text),
appName, downloadUrl, username);

View file

@ -67,7 +67,8 @@ public class UploadPathActivity extends FolderPickerActivity implements FileFrag
if (!stateWasRecovered) {
OCFileListFragment listOfFolders = getListOfFilesFragment();
listOfFolders.listDirectory(folder, false);
// TODO Enable when "On Device" is recovered ?
listOfFolders.listDirectory(folder/*, false*/);
startSyncFolderOperation(folder, false);
}

View file

@ -70,18 +70,11 @@ import com.actionbarsherlock.view.MenuItem;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountAuthenticator;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileUploader;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountAuthenticator;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileUploader;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.operations.CreateFolderOperation;
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
import com.owncloud.android.ui.dialog.LoadingDialog;
@ -332,7 +325,8 @@ public class Uploader extends FileActivity
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// click on folder in the list
Log_OC.d(TAG, "on item click");
Vector<OCFile> tmpfiles = getStorageManager().getFolderContent(mFile, false);
// TODO Enable when "On Device" is recovered ?
Vector<OCFile> tmpfiles = getStorageManager().getFolderContent(mFile /*, false*/);
if (tmpfiles.size() <= 0) return;
// filter on dirtype
Vector<OCFile> files = new Vector<OCFile>();
@ -417,7 +411,8 @@ public class Uploader extends FileActivity
mFile = getStorageManager().getFileByPath(full_path);
if (mFile != null) {
Vector<OCFile> files = getStorageManager().getFolderContent(mFile, false);
// TODO Enable when "On Device" is recovered ?
Vector<OCFile> files = getStorageManager().getFolderContent(mFile/*, false*/);
List<HashMap<String, Object>> data = new LinkedList<HashMap<String,Object>>();
for (OCFile f : files) {
HashMap<String, Object> h = new HashMap<String, Object>();

View file

@ -407,14 +407,16 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
* @param updatedStorageManager Optional updated storage manager; used to replace
* mStorageManager if is different (and not NULL)
*/
public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager, boolean onlyOnDevice) {
public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager
/*, boolean onlyOnDevice*/) {
mFile = directory;
if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {
mStorageManager = updatedStorageManager;
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
}
if (mStorageManager != null) {
mFiles = mStorageManager.getFolderContent(mFile, onlyOnDevice);
// TODO Enable when "On Device" is recovered ?
mFiles = mStorageManager.getFolderContent(mFile/*, onlyOnDevice*/);
mFilesOrig.clear();
mFilesOrig.addAll(mFiles);

View file

@ -1,3 +1,24 @@
/**
* ownCloud Android client application
*
* @author tobiasKaminsky
* @author masensio
* Copyright (C) 2015 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/>.
*
*/
package com.owncloud.android.ui.adapter;
import java.nio.ByteBuffer;
@ -20,6 +41,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.LayoutParams;
@ -29,6 +51,7 @@ import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.NavigationDrawerItem;
import com.owncloud.android.ui.TextDrawable;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.utils.BitmapUtils;
@ -37,41 +60,41 @@ import org.apache.commons.codec.binary.Hex;
public class NavigationDrawerListAdapter extends BaseAdapter {
private final static String TAG = "NavigationDrawerListAdapter";
private final static String TAG = NavigationDrawerListAdapter.class.getSimpleName();
private Context mContext;
private ArrayList<String> mDrawerItems = new ArrayList<String>();
ArrayList<Object> all = new ArrayList<Object>();
private ArrayList<NavigationDrawerItem> mNavigationDrawerItems;
private ArrayList<Object> mAll = new ArrayList<Object>();
private Account[] mAccounts;
private boolean mShowAccounts;
private Account currentAccount;
private Account mCurrentAccount;
private FileDisplayActivity mFileDisplayActivity;
public NavigationDrawerListAdapter(Context context, FileDisplayActivity fileDisplayActivity){
public NavigationDrawerListAdapter(Context context, FileDisplayActivity fileDisplayActivity,
ArrayList<NavigationDrawerItem> navigationDrawerItems){
mFileDisplayActivity = fileDisplayActivity;
mContext = context;
for (String string : mContext.getResources().getStringArray(R.array.drawer_items)) {
mDrawerItems.add(string);
}
mNavigationDrawerItems = navigationDrawerItems;
updateAccountList();
all.addAll(mDrawerItems);
mAll.addAll(mNavigationDrawerItems);
}
public void updateAccountList(){
AccountManager am = (AccountManager) mContext.getSystemService(mContext.ACCOUNT_SERVICE);
mAccounts = am.getAccountsByType(MainApp.getAccountType());
currentAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
mCurrentAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
}
@Override
public int getCount() {
if (mShowAccounts){
return mDrawerItems.size() + 1;
return mNavigationDrawerItems.size() + 1;
} else {
return mDrawerItems.size();
return mNavigationDrawerItems.size();
}
}
@ -92,21 +115,23 @@ public class NavigationDrawerListAdapter extends BaseAdapter {
LayoutInflater inflator = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (all.size() > position) {
if (mAll.size() > position) {
// Normal entry
if (all.get(position) instanceof String){
if (mAll.get(position) instanceof NavigationDrawerItem){
NavigationDrawerItem navItem = (NavigationDrawerItem) mAll.get(position);
View view = inflator.inflate(R.layout.drawer_list_item, null);
view.setMinimumHeight(40);
TextView textView = (TextView) view.findViewById(R.id.drawer_textView);
String entry = (String) all.get(position);
textView.setText(entry);
LinearLayout itemLayout = (LinearLayout) view.findViewById(R.id.itemLayout);
itemLayout.setContentDescription(navItem.getContentDescription());
TextView itemText = (TextView) view.findViewById(R.id.itemTitle);
itemText.setText(navItem.getTitle());
return view;
}
// Account
if (all.get(position) instanceof Account[]){
if (mAll.get(position) instanceof Account[]){
final View view = inflator.inflate(R.layout.drawer_account_group, null);
final RadioGroup group = (RadioGroup) view.findViewById(R.id.drawer_radio_group);
@ -115,6 +140,7 @@ public class NavigationDrawerListAdapter extends BaseAdapter {
RadioButton rb = new RadioButton(mContext);
rb.setText(account.name);
rb.setContentDescription(account.name);
rb.setTextColor(Color.BLACK);
rb.setEllipsize(TextUtils.TruncateAt.MIDDLE);
rb.setSingleLine();
@ -155,7 +181,7 @@ public class NavigationDrawerListAdapter extends BaseAdapter {
params.setMargins(15, 5, 5, 5);
// Check the current account that is being used
if (account.name.equals(currentAccount.name)) {
if (account.name.equals(mCurrentAccount.name)) {
rb.setChecked(true);
} else {
rb.setChecked(false);
@ -186,11 +212,11 @@ public class NavigationDrawerListAdapter extends BaseAdapter {
// TODO update Account List after creating a new account and on fresh installation
public void setShowAccounts(boolean value){
all.clear();
all.addAll(mDrawerItems);
mAll.clear();
mAll.addAll(mNavigationDrawerItems);
if (value){
all.add(1, mAccounts);
mAll.add(1, mAccounts);
}
mShowAccounts = value;
}

View file

@ -112,7 +112,8 @@ implements ConfirmationDialogFragmentListener {
boolean containsKeepInSync = false;
if (mTargetFile.isFolder()) {
Vector<OCFile> files = storageManager.getFolderContent(mTargetFile, false);
// TODO Enable when "On Device" is recovered ?
Vector<OCFile> files = storageManager.getFolderContent(mTargetFile/*, false*/);
for(OCFile file: files) {
containsKeepInSync = file.keepInSync() || containsKeepInSync;

View file

@ -29,15 +29,12 @@ import android.content.Intent;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.TextView;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
@ -187,7 +184,8 @@ public class OCFileListFragment extends ExtendedListFragment {
} // exit is granted because storageManager.getFileByPath("/") never returns null
mFile = parentDir;
listDirectory(mFile, MainApp.getOnlyOnDevice());
// TODO Enable when "On Device" is recovered ?
listDirectory(mFile /*, MainApp.getOnlyOnDevice()*/);
onRefresh(false);
@ -205,7 +203,8 @@ public class OCFileListFragment extends ExtendedListFragment {
if (file != null) {
if (file.isFolder()) {
// update state and view of this fragment
listDirectory(file, MainApp.getOnlyOnDevice());
// TODO Enable when "On Device" is recovered ?
listDirectory(file/*, MainApp.getOnlyOnDevice()*/);
// then, notify parent activity to let it update its state and view
mContainerActivity.onBrowsedDownTo(file);
// save index and top position
@ -359,12 +358,15 @@ public class OCFileListFragment extends ExtendedListFragment {
/**
* Calls {@link OCFileListFragment#listDirectory(OCFile)} with a null parameter
*/
public void listDirectory(boolean onlyOnDevice){
listDirectory(null, onlyOnDevice);
public void listDirectory(/*boolean onlyOnDevice*/){
listDirectory(null);
// TODO Enable when "On Device" is recovered ?
// listDirectory(null, onlyOnDevice);
}
public void refreshDirectory(){
listDirectory(getCurrentFile(), MainApp.getOnlyOnDevice());
// TODO Enable when "On Device" is recovered ?
listDirectory(getCurrentFile()/*, MainApp.getOnlyOnDevice()*/);
}
/**
@ -374,7 +376,7 @@ public class OCFileListFragment extends ExtendedListFragment {
*
* @param directory File to be listed
*/
public void listDirectory(OCFile directory, boolean onlyOnDevice) {
public void listDirectory(OCFile directory/*, boolean onlyOnDevice*/) {
FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
if (storageManager != null) {
@ -395,7 +397,8 @@ public class OCFileListFragment extends ExtendedListFragment {
directory = storageManager.getFileById(directory.getParentId());
}
mAdapter.swapDirectory(directory, storageManager, onlyOnDevice);
// TODO Enable when "On Device" is recovered ?
mAdapter.swapDirectory(directory, storageManager/*, onlyOnDevice*/);
if (mFile == null || !mFile.equals(directory)) {
mCurrentListView.setSelection(0);
}

View file

@ -38,7 +38,6 @@ import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window;
import com.ortiz.touch.ExtendedViewPager;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.FileDataStorageManager;
@ -140,7 +139,9 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener {
// should not be necessary
parentFolder = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
}
mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), parentFolder, getAccount(), getStorageManager(), MainApp.getOnlyOnDevice());
// TODO Enable when "On Device" is recovered ?
mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(),
parentFolder, getAccount(), getStorageManager()/*, MainApp.getOnlyOnDevice()*/);
mViewPager = (ExtendedViewPager) findViewById(R.id.fragmentPager);
int position = mHasSavedPosition ? mSavedPosition : mPreviewImagePagerAdapter.getFilePosition(getFile());
position = (position >= 0) ? position : 0;

View file

@ -19,8 +19,6 @@
*/
package com.owncloud.android.ui.preview;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -36,7 +34,6 @@ import android.view.ViewGroup;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.ui.adapter.FileListListAdapter;
import com.owncloud.android.ui.fragment.FileFragment;
import com.owncloud.android.utils.FileStorageUtils;
@ -58,11 +55,14 @@ public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
/**
* Constructor.
*
* @param fragmentManager {@link FragmentManager} instance that will handle the {@link Fragment}s provided by the adapter.
* @param fragmentManager {@link FragmentManager} instance that will handle
* the {@link Fragment}s provided by the adapter.
* @param parentFolder Folder where images will be searched for.
* @param storageManager Bridge to database.
*/
public PreviewImagePagerAdapter(FragmentManager fragmentManager, OCFile parentFolder, Account account, FileDataStorageManager storageManager, boolean onlyOnDevice) {
public PreviewImagePagerAdapter(FragmentManager fragmentManager, OCFile parentFolder,
Account account, FileDataStorageManager storageManager /*,
boolean onlyOnDevice*/) {
super(fragmentManager);
if (fragmentManager == null) {
@ -77,7 +77,8 @@ public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
mAccount = account;
mStorageManager = storageManager;
mImageFiles = mStorageManager.getFolderImages(parentFolder, false);
// TODO Enable when "On Device" is recovered ?
mImageFiles = mStorageManager.getFolderImages(parentFolder/*, false*/);
mImageFiles = FileStorageUtils.sortFolder(mImageFiles);
@ -102,7 +103,8 @@ public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
OCFile file = mImageFiles.get(i);
Fragment fragment = null;
if (file.isDown()) {
fragment = PreviewImageFragment.newInstance(file, mObsoletePositions.contains(Integer.valueOf(i)));
fragment = PreviewImageFragment.newInstance(file,
mObsoletePositions.contains(Integer.valueOf(i)));
} else if (mDownloadErrors.contains(Integer.valueOf(i))) {
fragment = FileDownloadFragment.newInstance(file, mAccount, true);