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"); Copyright (C) 2015 ownCloud Inc.
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 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 This program is distributed in the hope that it will be useful,
distributed under the License is distributed on an "AS IS" BASIS, but WITHOUT ANY WARRANTY; without even the implied warranty of
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
See the License for the specific language governing permissions and GNU General Public License for more details.
limitations under the License.
--> You should have received a copy of the GNU General Public License
<TextView xmlns:android="http://schemas.android.com/apk/res/android" along with this program. If not, see <http://www.gnu.org/licenses/>.
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_width="fill_parent"
android:layout_height="56dp" android:layout_height="wrap_content"
android:gravity="center_vertical" android:layout_alignParentLeft="true"
android:paddingLeft="16dp" android:orientation="horizontal"
android:paddingRight="16dp" android:background="@color/background_color"
android:textColor="#000" android:layout_marginTop="10dp"
android:textSize="18dp" /> 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="@color/textColor"
android:text="@string/app_name"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:minHeight="?android:attr/listPreferredItemHeightSmall"/>
</LinearLayout>

View file

@ -47,50 +47,50 @@
</LinearLayout> </LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/background_color"
android:baselineAligned="false"
android:clickable="true"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:id="@+id/left_drawer"
android:layout_margin="5dp"> android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/background_color"
android:baselineAligned="false"
android:clickable="true"
android:orientation="vertical">
<ImageView <LinearLayout
android:id="@+id/drawer_userIcon" android:layout_width="match_parent"
android:layout_width="40dp" android:layout_height="wrap_content"
android:layout_height="40dp" android:layout_margin="5dp">
android:src="@drawable/abs__ab_solid_dark_holo" />
<ImageView
android:id="@+id/drawer_userIcon"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/abs__ab_solid_dark_holo" />
<TextView
android:id="@+id/drawer_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<TextView <TextView
android:id="@+id/drawer_username" android:layout_width="fill_parent"
android:layout_width="wrap_content" android:layout_height="2dip"
android:layout_height="wrap_content" android:background="@color/list_item_lastmod_and_filesize_text" />
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ListView
android:id="@+id/drawer_list"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@color/background_color"
android:choiceMode="singleChoice"
/>
</LinearLayout> </LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="@color/list_item_lastmod_and_filesize_text" />
<ListView
android:id="@+id/drawer_list"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@color/background_color"
android:choiceMode="singleChoice"
/>
</LinearLayout>
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>

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

View file

@ -56,7 +56,6 @@
<PreferenceCategory android:title="@string/prefs_category_more" android:key="more"> <PreferenceCategory android:title="@string/prefs_category_more" android:key="more">
<Preference android:title="@string/prefs_help" android:key="help" /> <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_recommend" android:key="recommend" />
<Preference android:title="@string/prefs_feedback" android:key="feedback" /> <Preference android:title="@string/prefs_feedback" android:key="feedback" />
<Preference android:title="@string/prefs_imprint" android:key="imprint" /> <Preference android:title="@string/prefs_imprint" android:key="imprint" />

View file

@ -54,8 +54,9 @@ public class MainApp extends Application {
private static Context mContext; private static Context mContext;
// TODO Enable when "On Device" is recovered?
// TODO better place // TODO better place
private static boolean mOnlyOnDevice = false; // private static boolean mOnlyOnDevice = false;
public void onCreate(){ public void onCreate(){
@ -175,13 +176,14 @@ public class MainApp extends Application {
return getAppContext().getResources().getString(R.string.log_name); return getAppContext().getResources().getString(R.string.log_name);
} }
public static void showOnlyFilesOnDevice(boolean state){ // TODO Enable when "On Device" is recovered ?
mOnlyOnDevice = state; // public static void showOnlyFilesOnDevice(boolean state){
} // mOnlyOnDevice = state;
// }
public static boolean getOnlyOnDevice(){ //
return mOnlyOnDevice; // public static boolean getOnlyOnDevice(){
} // return mOnlyOnDevice;
// }
// user agent // user agent
public static String getUserAgent() { 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) { 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 { } else {
return new Vector<OCFile>(); 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>(); Vector<OCFile> ret = new Vector<OCFile>();
if (folder != null) { if (folder != null) {
// TODO better implementation, filtering in the access to database instead of here // 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; OCFile current = null;
for (int i=0; i<tmp.size(); i++) { for (int i=0; i<tmp.size(); i++) {
current = tmp.get(i); current = tmp.get(i);
@ -547,7 +549,8 @@ public class FileDataStorageManager {
File localFolder = new File(localFolderPath); File localFolder = new File(localFolderPath);
if (localFolder.exists()) { if (localFolder.exists()) {
// stage 1: remove the local files already registered in the files database // 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) { if (files != null) {
for (OCFile file : files) { for (OCFile file : files) {
if (file.isFolder()) { 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>(); Vector<OCFile> ret = new Vector<OCFile>();
@ -758,9 +761,10 @@ public class FileDataStorageManager {
if (c.moveToFirst()) { if (c.moveToFirst()) {
do { do {
OCFile child = createFileInstance(c); 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); ret.add(child);
} // }
} while (c.moveToNext()); } while (c.moveToNext());
} }
@ -1443,7 +1447,8 @@ public class FileDataStorageManager {
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?"; + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
String [] whereArgs = new String[]{ "", mAccount.name }; 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) { for (OCFile file : files) {
whereArgs[0] = file.getRemotePath(); whereArgs[0] = file.getRemotePath();

View file

@ -201,7 +201,8 @@ public class RefreshFolderOperation extends RemoteOperation {
if (mRemoteFolderChanged) { if (mRemoteFolderChanged) {
result = fetchAndSyncRemoteFolder(client); result = fetchAndSyncRemoteFolder(client);
} else { } 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>(); List<SynchronizeFileOperation> filesToSyncContents = new Vector<SynchronizeFileOperation>();
// get current data about local contents of the folder to synchronize // 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()); Map<String, OCFile> localFilesMap = new HashMap<String, OCFile>(localFiles.size());
for (OCFile file : localFiles) { for (OCFile file : localFiles) {
localFilesMap.put(file.getRemotePath(), file); localFilesMap.put(file.getRemotePath(), file);

View file

@ -21,51 +21,33 @@
package com.owncloud.android.operations; package com.owncloud.android.operations;
import java.io.File; 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.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Vector; import java.util.Vector;
import org.apache.http.HttpStatus;
import android.accounts.Account; import android.accounts.Account;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log; import android.util.Log;
import com.owncloud.android.MainApp;
import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader; import com.owncloud.android.files.services.FileDownloader;
import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.OperationCancelledException; 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;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC; 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.ReadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation; import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
import com.owncloud.android.lib.resources.files.RemoteFile; 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.operations.common.SyncOperation;
import com.owncloud.android.services.OperationsService; import com.owncloud.android.services.OperationsService;
import com.owncloud.android.utils.FileStorageUtils; 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 java.util.concurrent.atomic.AtomicBoolean;
//import android.support.v4.content.LocalBroadcastManager; //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 // 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()); Map<String, OCFile> localFilesMap = new HashMap<String, OCFile>(localFiles.size());
for (OCFile file : localFiles) { for (OCFile file : localFiles) {
localFilesMap.put(file.getRemotePath(), file); localFilesMap.put(file.getRemotePath(), file);
@ -411,8 +394,8 @@ public class SynchronizeFolderOperation extends SyncOperation {
private void prepareOpsFromLocalKnowledge() throws OperationCancelledException { private void prepareOpsFromLocalKnowledge() throws OperationCancelledException {
// TODO TOBI ist das richtig? // TODO Enable when "On Device" is recovered ?
List<OCFile> children = getStorageManager().getFolderContent(mLocalFolder, false); List<OCFile> children = getStorageManager().getFolderContent(mLocalFolder/*, false*/);
for (OCFile child : children) { for (OCFile child : children) {
/// classify file to sync/download contents later /// classify file to sync/download contents later
if (child.isFolder()) { 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; package com.owncloud.android.ui.activity;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import android.accounts.Account; import android.accounts.Account;
import android.accounts.AccountManager; import android.accounts.AccountManager;
import android.accounts.AuthenticatorException; import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
@ -55,7 +55,6 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat; import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
@ -73,6 +72,7 @@ import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window; import com.actionbarsherlock.view.Window;
import com.owncloud.android.BuildConfig;
import com.owncloud.android.MainApp; import com.owncloud.android.MainApp;
import com.owncloud.android.R; import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils; 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.operations.UnshareLinkOperation;
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.adapter.FileListListAdapter; import com.owncloud.android.ui.NavigationDrawerItem;
import com.owncloud.android.ui.adapter.NavigationDrawerListAdapter; import com.owncloud.android.ui.adapter.NavigationDrawerListAdapter;
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment; import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment; 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_UPLOAD_SOURCE = "DIALOG_UPLOAD_SOURCE";
private static String DIALOG_CERT_NOT_SAVED = "DIALOG_CERT_NOT_SAVED"; private static String DIALOG_CERT_NOT_SAVED = "DIALOG_CERT_NOT_SAVED";
private NavigationDrawerListAdapter adapter = null;
private OCFile mWaitingToSend; private OCFile mWaitingToSend;
// Navigation Drawer
private DrawerLayout mDrawerLayout; private DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mDrawerToggle; 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -202,16 +211,91 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
// Inflate and set the layout view // Inflate and set the layout view
setContentView(R.layout.files); 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); 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( mDrawerToggle = new ActionBarDrawerToggle(
this, this,
mDrawerLayout, mDrawerLayout,
R.drawable.ic_drawer, R.drawable.ic_drawer,
R.string.drawer_open, R.string.drawer_open,
R.string.empty R.string.empty) {
) {
/** Called when a drawer has settled in a completely closed state. */ /** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) { public void onDrawerClosed(View view) {
@ -232,80 +316,11 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
}; };
mDrawerToggle.setDrawerIndicatorEnabled(true); mDrawerToggle.setDrawerIndicatorEnabled(true);
// Set the list's click listener
// Notification Drawer mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
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 drawer toggle as the DrawerListener // Set the drawer toggle as the DrawerListener
mDrawerLayout.setDrawerListener(mDrawerToggle); 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 @Override
@ -408,7 +423,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
/// First fragment /// First fragment
OCFileListFragment listOfFiles = getListOfFilesFragment(); OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) { if (listOfFiles != null) {
listOfFiles.listDirectory(getCurrentDir(), MainApp.getOnlyOnDevice()); listOfFiles.listDirectory(getCurrentDir());
// TODO Enable when "On Device" is recovered
// listOfFiles.listDirectory(getCurrentDir(), MainApp.getOnlyOnDevice());
} else { } else {
Log_OC.e(TAG, "Still have a chance to lose the initializacion of list fragment >("); Log_OC.e(TAG, "Still have a chance to lose the initializacion of list fragment >(");
} }
@ -528,7 +545,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
protected void refreshListOfFilesFragment() { protected void refreshListOfFilesFragment() {
OCFileListFragment fileListFragment = getListOfFilesFragment(); OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) { if (fileListFragment != null) {
fileListFragment.listDirectory(MainApp.getOnlyOnDevice()); fileListFragment.listDirectory();
// TODO Enable when "On Device" is recovered ?
// fileListFragment.listDirectory(MainApp.getOnlyOnDevice());
} }
} }
@ -623,19 +642,16 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
builder.setTitle(R.string.actionbar_sort_title) builder.setTitle(R.string.actionbar_sort_title)
.setSingleChoiceItems(R.array.actionbar_sortby, sortOrder , new DialogInterface.OnClickListener() { .setSingleChoiceItems(R.array.actionbar_sortby, sortOrder , new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which){ switch (which){
case 0: case 0:
sortByName(true); sortByName(true);
break; break;
case 1: case 1:
sortByDate(false); sortByDate(false);
break; break;
} }
dialog.dismiss(); dialog.dismiss();
} }
}); });
builder.create().show(); builder.create().show();
@ -895,7 +911,7 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
super.onResume(); super.onResume();
// refresh Navigation Drawer account list // refresh Navigation Drawer account list
adapter.updateAccountList(); mNavigationDrawerAdapter.updateAccountList();
// refresh list of files // refresh list of files
refreshListOfFilesFragment(); refreshListOfFilesFragment();
@ -1046,7 +1062,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
if (synchFolderRemotePath != null && currentDir.getRemotePath().equals(synchFolderRemotePath)) { if (synchFolderRemotePath != null && currentDir.getRemotePath().equals(synchFolderRemotePath)) {
OCFileListFragment fileListFragment = getListOfFilesFragment(); OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) { if (fileListFragment != null) {
fileListFragment.listDirectory(currentDir, MainApp.getOnlyOnDevice()); fileListFragment.listDirectory();
// TODO Enable when "On Device" is recovered ?
// fileListFragment.listDirectory(currentDir, MainApp.getOnlyOnDevice());
} }
} }
setFile(currentFile); setFile(currentFile);
@ -1275,7 +1293,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
popDirname(); popDirname();
} }
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH); 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()); setFile(listOfFiles.getCurrentFile());
startSyncFolderOperation(root, false); startSyncFolderOperation(root, false);
} }
@ -1290,7 +1310,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
OCFileListFragment listOfFiles = getListOfFilesFragment(); OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) { if (listOfFiles != null) {
setNavigationListWithFolder(folder); 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()); setFile(listOfFiles.getCurrentFile());
startSyncFolderOperation(folder, false); startSyncFolderOperation(folder, false);
} else { } else {
@ -1402,7 +1424,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
// a new chance to get the mDownloadBinder through getFileDownloadBinder() - THIS IS A MESS // a new chance to get the mDownloadBinder through getFileDownloadBinder() - THIS IS A MESS
OCFileListFragment listOfFiles = getListOfFilesFragment(); OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) { if (listOfFiles != null) {
listOfFiles.listDirectory(MainApp.getOnlyOnDevice()); listOfFiles.listDirectory();
// TODO Enable when "On Device" is recovered ?
// listOfFiles.listDirectory(MainApp.getOnlyOnDevice());
} }
FileFragment secondFragment = getSecondFragment(); FileFragment secondFragment = getSecondFragment();
if (secondFragment != null && secondFragment instanceof FileDetailFragment) { if (secondFragment != null && secondFragment instanceof FileDetailFragment) {
@ -1886,4 +1910,43 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
mDrawerLayout.closeDrawers(); 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; package com.owncloud.android.ui.activity;
import java.io.IOException;
import android.accounts.Account; import android.accounts.Account;
import android.accounts.AccountManager; import android.accounts.AccountManager;
import android.accounts.AuthenticatorException; import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -45,7 +42,6 @@ import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window; import com.actionbarsherlock.view.Window;
import com.owncloud.android.MainApp;
import com.owncloud.android.R; import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudAccount; import com.owncloud.android.lib.common.OwnCloudAccount;
@ -142,7 +138,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
if (!stateWasRecovered) { if (!stateWasRecovered) {
OCFileListFragment listOfFolders = getListOfFilesFragment(); OCFileListFragment listOfFolders = getListOfFilesFragment();
listOfFolders.listDirectory(folder, false); listOfFolders.listDirectory(folder/*, false*/);
startSyncFolderOperation(folder, false); startSyncFolderOperation(folder, false);
} }
@ -311,7 +307,9 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
protected void refreshListOfFilesFragment() { protected void refreshListOfFilesFragment() {
OCFileListFragment fileListFragment = getListOfFilesFragment(); OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) { 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(); OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) { // should never be null, indeed if (listOfFiles != null) { // should never be null, indeed
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH); 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()); setFile(listOfFiles.getCurrentFile());
updateNavigationElementsInActionBar(); updateNavigationElementsInActionBar();
startSyncFolderOperation(root, false); startSyncFolderOperation(root, false);
@ -471,7 +471,9 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
equals(synchFolderRemotePath)) { equals(synchFolderRemotePath)) {
OCFileListFragment fileListFragment = getListOfFilesFragment(); OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) { if (fileListFragment != null) {
fileListFragment.listDirectory(currentDir, false); fileListFragment.listDirectory(currentDir);
// TODO Enable when "On Device" is recovered ?
// fileListFragment.listDirectory(currentDir, false);
} }
} }
setFile(currentFile); setFile(currentFile);

View file

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

View file

@ -67,7 +67,8 @@ public class UploadPathActivity extends FolderPickerActivity implements FileFrag
if (!stateWasRecovered) { if (!stateWasRecovered) {
OCFileListFragment listOfFolders = getListOfFilesFragment(); OCFileListFragment listOfFolders = getListOfFilesFragment();
listOfFolders.listDirectory(folder, false); // TODO Enable when "On Device" is recovered ?
listOfFolders.listDirectory(folder/*, false*/);
startSyncFolderOperation(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.MainApp;
import com.owncloud.android.R; import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountAuthenticator; import com.owncloud.android.authentication.AccountAuthenticator;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.files.services.FileUploader;
import com.owncloud.android.lib.common.utils.Log_OC; 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.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult; 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.operations.CreateFolderOperation;
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment; import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
import com.owncloud.android.ui.dialog.LoadingDialog; 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) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// click on folder in the list // click on folder in the list
Log_OC.d(TAG, "on item click"); 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; if (tmpfiles.size() <= 0) return;
// filter on dirtype // filter on dirtype
Vector<OCFile> files = new Vector<OCFile>(); Vector<OCFile> files = new Vector<OCFile>();
@ -417,7 +411,8 @@ public class Uploader extends FileActivity
mFile = getStorageManager().getFileByPath(full_path); mFile = getStorageManager().getFileByPath(full_path);
if (mFile != null) { 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>>(); List<HashMap<String, Object>> data = new LinkedList<HashMap<String,Object>>();
for (OCFile f : files) { for (OCFile f : files) {
HashMap<String, Object> h = new HashMap<String, Object>(); 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 * @param updatedStorageManager Optional updated storage manager; used to replace
* mStorageManager if is different (and not NULL) * 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; mFile = directory;
if (updatedStorageManager != null && updatedStorageManager != mStorageManager) { if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {
mStorageManager = updatedStorageManager; mStorageManager = updatedStorageManager;
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext); mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
} }
if (mStorageManager != null) { if (mStorageManager != null) {
mFiles = mStorageManager.getFolderContent(mFile, onlyOnDevice); // TODO Enable when "On Device" is recovered ?
mFiles = mStorageManager.getFolderContent(mFile/*, onlyOnDevice*/);
mFilesOrig.clear(); mFilesOrig.clear();
mFilesOrig.addAll(mFiles); 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; package com.owncloud.android.ui.adapter;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -20,6 +41,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.RadioGroup; import android.widget.RadioGroup;
import android.widget.RadioGroup.LayoutParams; import android.widget.RadioGroup.LayoutParams;
@ -29,6 +51,7 @@ import com.owncloud.android.MainApp;
import com.owncloud.android.R; import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.lib.common.utils.Log_OC; 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.TextDrawable;
import com.owncloud.android.ui.activity.FileDisplayActivity; import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.utils.BitmapUtils; import com.owncloud.android.utils.BitmapUtils;
@ -37,41 +60,41 @@ import org.apache.commons.codec.binary.Hex;
public class NavigationDrawerListAdapter extends BaseAdapter { public class NavigationDrawerListAdapter extends BaseAdapter {
private final static String TAG = "NavigationDrawerListAdapter"; private final static String TAG = NavigationDrawerListAdapter.class.getSimpleName();
private Context mContext; 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 Account[] mAccounts;
private boolean mShowAccounts; private boolean mShowAccounts;
private Account currentAccount; private Account mCurrentAccount;
private FileDisplayActivity mFileDisplayActivity; private FileDisplayActivity mFileDisplayActivity;
public NavigationDrawerListAdapter(Context context, FileDisplayActivity fileDisplayActivity){ public NavigationDrawerListAdapter(Context context, FileDisplayActivity fileDisplayActivity,
ArrayList<NavigationDrawerItem> navigationDrawerItems){
mFileDisplayActivity = fileDisplayActivity; mFileDisplayActivity = fileDisplayActivity;
mContext = context; mContext = context;
mNavigationDrawerItems = navigationDrawerItems;
for (String string : mContext.getResources().getStringArray(R.array.drawer_items)) {
mDrawerItems.add(string);
}
updateAccountList(); updateAccountList();
all.addAll(mDrawerItems); mAll.addAll(mNavigationDrawerItems);
} }
public void updateAccountList(){ public void updateAccountList(){
AccountManager am = (AccountManager) mContext.getSystemService(mContext.ACCOUNT_SERVICE); AccountManager am = (AccountManager) mContext.getSystemService(mContext.ACCOUNT_SERVICE);
mAccounts = am.getAccountsByType(MainApp.getAccountType()); mAccounts = am.getAccountsByType(MainApp.getAccountType());
currentAccount = AccountUtils.getCurrentOwnCloudAccount(mContext); mCurrentAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
} }
@Override @Override
public int getCount() { public int getCount() {
if (mShowAccounts){ if (mShowAccounts){
return mDrawerItems.size() + 1; return mNavigationDrawerItems.size() + 1;
} else { } else {
return mDrawerItems.size(); return mNavigationDrawerItems.size();
} }
} }
@ -92,21 +115,23 @@ public class NavigationDrawerListAdapter extends BaseAdapter {
LayoutInflater inflator = (LayoutInflater) mContext LayoutInflater inflator = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE); .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (all.size() > position) { if (mAll.size() > position) {
// Normal entry // 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 view = inflator.inflate(R.layout.drawer_list_item, null);
view.setMinimumHeight(40); view.setMinimumHeight(40);
TextView textView = (TextView) view.findViewById(R.id.drawer_textView); LinearLayout itemLayout = (LinearLayout) view.findViewById(R.id.itemLayout);
itemLayout.setContentDescription(navItem.getContentDescription());
String entry = (String) all.get(position); TextView itemText = (TextView) view.findViewById(R.id.itemTitle);
textView.setText(entry); itemText.setText(navItem.getTitle());
return view; return view;
} }
// Account // 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 View view = inflator.inflate(R.layout.drawer_account_group, null);
final RadioGroup group = (RadioGroup) view.findViewById(R.id.drawer_radio_group); 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); RadioButton rb = new RadioButton(mContext);
rb.setText(account.name); rb.setText(account.name);
rb.setContentDescription(account.name);
rb.setTextColor(Color.BLACK); rb.setTextColor(Color.BLACK);
rb.setEllipsize(TextUtils.TruncateAt.MIDDLE); rb.setEllipsize(TextUtils.TruncateAt.MIDDLE);
rb.setSingleLine(); rb.setSingleLine();
@ -155,7 +181,7 @@ public class NavigationDrawerListAdapter extends BaseAdapter {
params.setMargins(15, 5, 5, 5); params.setMargins(15, 5, 5, 5);
// Check the current account that is being used // Check the current account that is being used
if (account.name.equals(currentAccount.name)) { if (account.name.equals(mCurrentAccount.name)) {
rb.setChecked(true); rb.setChecked(true);
} else { } else {
rb.setChecked(false); 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 // TODO update Account List after creating a new account and on fresh installation
public void setShowAccounts(boolean value){ public void setShowAccounts(boolean value){
all.clear(); mAll.clear();
all.addAll(mDrawerItems); mAll.addAll(mNavigationDrawerItems);
if (value){ if (value){
all.add(1, mAccounts); mAll.add(1, mAccounts);
} }
mShowAccounts = value; mShowAccounts = value;
} }

View file

@ -112,7 +112,8 @@ implements ConfirmationDialogFragmentListener {
boolean containsKeepInSync = false; boolean containsKeepInSync = false;
if (mTargetFile.isFolder()) { 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) { for(OCFile file: files) {
containsKeepInSync = file.keepInSync() || containsKeepInSync; containsKeepInSync = file.keepInSync() || containsKeepInSync;

View file

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

View file

@ -38,7 +38,6 @@ import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window; import com.actionbarsherlock.view.Window;
import com.ortiz.touch.ExtendedViewPager; import com.ortiz.touch.ExtendedViewPager;
import com.owncloud.android.MainApp;
import com.owncloud.android.R; import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.FileDataStorageManager;
@ -140,7 +139,9 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener {
// should not be necessary // should not be necessary
parentFolder = getStorageManager().getFileByPath(OCFile.ROOT_PATH); 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); mViewPager = (ExtendedViewPager) findViewById(R.id.fragmentPager);
int position = mHasSavedPosition ? mSavedPosition : mPreviewImagePagerAdapter.getFilePosition(getFile()); int position = mHasSavedPosition ? mSavedPosition : mPreviewImagePagerAdapter.getFilePosition(getFile());
position = (position >= 0) ? position : 0; position = (position >= 0) ? position : 0;

View file

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