--- /dev/null
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ 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
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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.
+ -->
+ <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/drawer_radio_group"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:orientation="vertical" >
+ </RadioGroup>
\ No newline at end of file
--- /dev/null
+<?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/>.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/itemLayout"
+ android:layout_width="fill_parent"
+ 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="@color/textColor"
+ android:text="@string/app_name"
+ android:textAppearance="?android:attr/textAppearanceListItemSmall"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall"/>
+</LinearLayout>
+
--- /dev/null
+<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/drawer_radiobutton"
+ android:layout_width="fill_parent"
+ android:layout_height="56dp"
+ android:gravity="center_vertical"
+ android:paddingLeft="16dp"
+ android:paddingRight="16dp"
+ android:textColor="#000"
+ android:textSize="18dp" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>\r
-<!-- \r
+<!--\r
ownCloud Android client application\r
\r
Copyright (C) 2012 Bartek Przybylski\r
\r
You should have received a copy of the GNU General Public License\r
along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- -->\r
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+ -->\r
+<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+ android:id="@+id/drawer_layout"\r
android:layout_width="match_parent"\r
android:layout_height="match_parent"\r
- android:background="@color/background_color"\r
- android:orientation="horizontal"\r
- android:baselineAligned="false"\r
- >\r
-\r
- <FrameLayout \r
- android:layout_width="0dp"\r
- android:layout_height="match_parent"\r
- android:layout_weight="1"\r
- android:id="@+id/left_fragment_container"\r
- />\r
- \r
- <FrameLayout \r
- android:layout_width="0dp"\r
- android:layout_height="match_parent"\r
- android:layout_weight="2"\r
- android:id="@+id/right_fragment_container"\r
- />\r
- \r
- </LinearLayout>
\ No newline at end of file
+ android:clickable="true" >\r
+\r
+ <!-- The main content view -->\r
+ <LinearLayout\r
+ xmlns:android="http://schemas.android.com/apk/res/android"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="match_parent"\r
+ android:background="@color/background_color"\r
+ android:baselineAligned="false"\r
+ android:orientation="horizontal" >\r
+\r
+\r
+ <FrameLayout\r
+ android:id="@+id/left_fragment_container"\r
+ android:layout_width="0dp"\r
+ android:layout_height="match_parent"\r
+ android:layout_weight="1" />\r
+\r
+ <FrameLayout\r
+ android:id="@+id/right_fragment_container"\r
+ android:layout_width="0dp"\r
+ android:layout_height="match_parent"\r
+ android:layout_weight="2" />\r
+ </LinearLayout>\r
+\r
+\r
+ <LinearLayout\r
+ xmlns:android="http://schemas.android.com/apk/res/android"\r
+ android:id="@+id/left_drawer"\r
+ android:layout_width="240dp"\r
+ android:layout_height="match_parent"\r
+ android:layout_gravity="start"\r
+ android:background="@color/background_color"\r
+ android:baselineAligned="false"\r
+ android:clickable="true"\r
+ android:orientation="vertical">\r
+\r
+ <LinearLayout\r
+ android:layout_width="match_parent"\r
+ android:layout_height="wrap_content"\r
+ android:layout_margin="5dp">\r
+\r
+ <ImageView\r
+ android:id="@+id/drawer_userIcon"\r
+ android:layout_width="40dp"\r
+ android:layout_height="40dp"\r
+ android:src="@drawable/abc_ab_bottom_solid_dark_holo" />\r
+\r
+ <TextView\r
+ android:id="@+id/drawer_username"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_gravity="center_vertical"\r
+ android:layout_marginLeft="5dp"\r
+ android:layout_marginStart="5dp"\r
+ android:textAppearance="?android:attr/textAppearanceLarge" />\r
+\r
+ </LinearLayout>\r
+\r
+ <TextView\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="2dip"\r
+ android:background="@color/list_item_lastmod_and_filesize_text" />\r
+\r
+ <ListView\r
+ android:id="@+id/drawer_list"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="match_parent"\r
+ android:background="@color/background_color"\r
+ android:choiceMode="singleChoice"\r
+ />\r
+ </LinearLayout>\r
+</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
--- /dev/null
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="56dp"
+ android:clickable="true"
+ android:orientation="vertical"
+ android:background="#fff"
+ android:paddingLeft="16dp"
+ tools:context=".MainActivity" >
+
+ <TextView
+ android:id="@+id/textView1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:drawablePadding="5dp"
+ android:gravity="center_vertical"
+ android:paddingLeft="16dp"
+ android:textSize="16dp" >
+
+ </TextView>
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="@android:color/black" />
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/textView1"
+ android:layout_width="wrap_content"
+ android:background="#fff"
+ android:layout_height="56dp"
+ android:layout_marginLeft="8dp"
+ android:gravity="left"
+ android:paddingLeft="16dp"
+ android:paddingTop="8dp"
+ android:textSize="16dp"
+ android:groupIndicator="@android:color/transparent"
+/>
\ No newline at end of file
android:layout_width="wrap_content" android:background="#fefefe"
android:gravity="center">
<TextView android:layout_width="fill_parent" android:text="@string/uploader_top_message"
- android:layout_height="wrap_content" android:id="@+id/textView1" android:textColor="@android:color/black"
+ android:layout_height="wrap_content" android:id="@+id/drawer_username" android:textColor="@android:color/black"
android:gravity="center_horizontal"></TextView>
<FrameLayout android:layout_height="fill_parent"
android:layout_width="fill_parent" android:id="@+id/frameLayout1"
- android:layout_below="@+id/textView1" android:layout_above="@+id/linearLayout1">
+ android:layout_below="@+id/drawer_username" android:layout_above="@+id/linearLayout1">
<ListView android:id="@android:id/list" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:divider="@drawable/uploader_list_separator"
android:dividerHeight="1dip"></ListView>
<TextView
android:text="TextView"
android:layout_width="fill_parent"
- android:id="@+id/textView1"
+ android:id="@+id/drawer_username"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:layout_gravity="center_vertical"
android:contentDescription="@string/actionbar_logger"/>
<item
android:id="@+id/action_sort"
- android:icon="@android:drawable/ic_menu_sort_alphabetically"
+ android:icon="@android:drawable/ic_menu_sort_by_size"
android:orderInCategory="2"
- app:showAsAction="never"
+ app:showAsAction="always"
android:title="@string/actionbar_sort"
android:contentDescription="@string/actionbar_sort"/>
<color name="filelist_icon_backgorund">#DDDDDD</color>
<color name="owncloud_blue_bright">#00ddff</color>
<color name="list_item_lastmod_and_filesize_text">#989898</color>
+ <color name="black">#000000</color>
<color name="textColor">#303030</color>
<color name="list_divider_background">#fff0f0f0</color>
--- /dev/null
+<?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>
\ No newline at end of file
<!-- TODO re-enable when server-side folder size calculation is available
<item>Biggest - Smallest</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>
<string name="prefs_category_more">More</string>
<string name="prefs_accounts">Accounts</string>
<string name="prefs_instant_video_upload_path_title">Upload Video Path</string>
<string name="download_folder_failed_content">Download of %1$s folder could not be completed</string>
- <string name="subject_token">%1$s shared \"%2$s\" with you</string>
+ <string name="shared_subject_header">shared</string>
+ <string name="with_you_subject_header">with you</string>
+
+ <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
<string name="auth_refresh_button">Refresh connection</string>
<string name="auth_host_address">Server address</string>
<string name="common_error_out_memory">Not enough memory</string>
+ <string name="username">Username</string>
</resources>
private static final String POLICY_ALWAYS_NEW_CLIENT = "always new client";
private static Context mContext;
+
+ // TODO Enable when "On Device" is recovered?
+ // TODO better place
+ // private static boolean mOnlyOnDevice = false;
+
public void onCreate(){
super.onCreate();
return getAppContext().getResources().getString(R.string.log_name);
}
+ // 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() {
String appString = getAppContext().getResources().getString(R.string.user_agent);
import java.util.List;
import java.util.Vector;
-import com.owncloud.android.MainApp;
-import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
-import com.owncloud.android.lib.common.utils.Log_OC;
-import com.owncloud.android.lib.resources.shares.OCShare;
-import com.owncloud.android.lib.resources.shares.ShareType;
-import com.owncloud.android.lib.resources.files.FileUtils;
-import com.owncloud.android.utils.FileStorageUtils;
-
import android.accounts.Account;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.os.RemoteException;
import android.provider.MediaStore;
+import com.owncloud.android.MainApp;
+import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
+import com.owncloud.android.lib.common.utils.Log_OC;
+import com.owncloud.android.lib.resources.files.FileUtils;
+import com.owncloud.android.lib.resources.shares.OCShare;
+import com.owncloud.android.lib.resources.shares.ShareType;
+import com.owncloud.android.utils.FileStorageUtils;
+
public class FileDataStorageManager {
public static final int ROOT_PARENT_ID = 0;
}
- public Vector<OCFile> getFolderContent(OCFile f) {
+ public Vector<OCFile> getFolderContent(OCFile f/*, boolean onlyOnDevice*/) {
if (f != null && f.isFolder() && f.getFileId() != -1) {
- return getFolderContent(f.getFileId());
+ // TODO Enable when "On Device" is recovered ?
+ return getFolderContent(f.getFileId()/*, onlyOnDevice*/);
} else {
return new Vector<OCFile>();
}
- public Vector<OCFile> getFolderImages(OCFile folder) {
+ 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);
+ // TODO better implementation, filtering in the access to database instead of here
+ // 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);
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());
+ // TODO Enable when "On Device" is recovered ?
+ Vector<OCFile> files = getFolderContent(folder.getFileId()/*, false*/);
if (files != null) {
for (OCFile file : files) {
if (file.isFolder()) {
}
- private Vector<OCFile> getFolderContent(long parentId) {
+ private Vector<OCFile> getFolderContent(long parentId/*, boolean onlyOnDevice*/) {
Vector<OCFile> ret = new Vector<OCFile>();
if (c.moveToFirst()) {
do {
OCFile child = createFileInstance(c);
- ret.add(child);
+ // TODO Enable when "On Device" is recovered ?
+ // if (child.isFolder() || !onlyOnDevice || onlyOnDevice && child.isDown()){
+ ret.add(child);
+ // }
} while (c.moveToNext());
}
}
private ArrayList<ContentProviderOperation> prepareRemoveSharesInFolder(
- OCFile folder, ArrayList<ContentProviderOperation> preparedOperations
- ) {
+ OCFile folder, ArrayList<ContentProviderOperation> preparedOperations) {
if (folder != null) {
String where = ProviderTableMeta.OCSHARES_PATH + "=?" + " AND "
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
String [] whereArgs = new String[]{ "", mAccount.name };
-
- Vector<OCFile> files = getFolderContent(folder);
+
+ // TODO Enable when "On Device" is recovered ?
+ Vector<OCFile> files = getFolderContent(folder /*, false*/);
for (OCFile file : files) {
whereArgs[0] = file.getRemotePath();
if (mRemoteFolderChanged) {
result = fetchAndSyncRemoteFolder(client);
} else {
- mChildren = mStorageManager.getFolderContent(mLocalFolder);
+ // TODO Enable when "On Device" is recovered ?
+ mChildren = mStorageManager.getFolderContent(mLocalFolder/*, false*/);
}
}
List<SynchronizeFileOperation> filesToSyncContents = new Vector<SynchronizeFileOperation>();
// get current data about local contents of the folder to synchronize
- List<OCFile> localFiles = mStorageManager.getFolderContent(mLocalFolder);
+ // 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);
package com.owncloud.android.operations;
+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 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.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;
}
// get current data about local contents of the folder to synchronize
- List<OCFile> localFiles = storageManager.getFolderContent(mLocalFolder);
+ // 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);
private void prepareOpsFromLocalKnowledge() throws OperationCancelledException {
- List<OCFile> children = getStorageManager().getFolderContent(mLocalFolder);
+ // 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()) {
--- /dev/null
+/**
+ * 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;
+ }
+}
package com.owncloud.android.ui.activity;
import java.io.File;
+import java.util.ArrayList;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.SyncRequest;
+import android.content.res.Configuration;
import android.content.res.Resources.NotFoundException;
import android.database.Cursor;
import android.net.Uri;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.provider.OpenableColumns;
+import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.Fragment;
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.support.v7.app.ActionBar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
+
+import android.widget.AdapterView;
import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.owncloud.android.BuildConfig;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
+import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader;
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
import com.owncloud.android.operations.UnshareLinkOperation;
import com.owncloud.android.services.observer.FileObserverService;
import com.owncloud.android.syncadapter.FileSyncAdapter;
+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;
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
private static String DIALOG_UPLOAD_SOURCE = "DIALOG_UPLOAD_SOURCE";
private static String DIALOG_CERT_NOT_SAVED = "DIALOG_CERT_NOT_SAVED";
-
private OCFile mWaitingToSend;
+
+ // Navigation Drawer
+ private DrawerLayout mDrawerLayout;
+ private ActionBarDrawerToggle mDrawerToggle;
+ 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) {
/// USER INTERFACE
// Inflate and set the layout view
- setContentView(R.layout.files);
+ setContentView(R.layout.files);
+
+ // 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);
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) {
+
+ /** Called when a drawer has settled in a completely closed state. */
+ public void onDrawerClosed(View view) {
+ super.onDrawerClosed(view);
+ getSupportActionBar().setDisplayShowTitleEnabled(true);
+ getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
+ initFragmentsWithFile();
+ invalidateOptionsMenu();
+ }
+
+ /** Called when a drawer has settled in a completely open state. */
+ public void onDrawerOpened(View drawerView) {
+ super.onDrawerOpened(drawerView);
+ getSupportActionBar().setTitle(R.string.drawer_open);
+ getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+ invalidateOptionsMenu();
+ }
+ };
+
+ mDrawerToggle.setDrawerIndicatorEnabled(true);
+ // Set the list's click listener
+ mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
+
+ // Set the drawer toggle as the DrawerListener
+ mDrawerLayout.setDrawerListener(mDrawerToggle);
+ }
+
@Override
protected void onStart() {
Log_OC.v(TAG, "onStart() start");
getSupportActionBar().setIcon(DisplayUtils.getSeasonalIconId());
Log_OC.v(TAG, "onStart() end");
}
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ // Sync the toggle state after onRestoreInstanceState has occurred.
+ mDrawerToggle.syncState();
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ mDrawerToggle.onConfigurationChanged(newConfig);
+ }
@Override
protected void onDestroy() {
/// First fragment
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) {
- listOfFiles.listDirectory(getCurrentDir());
+ 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 >(");
}
protected void refreshListOfFilesFragment() {
OCFileListFragment fileListFragment = getListOfFilesFragment();
- if (fileListFragment != null) {
+ if (fileListFragment != null) {
fileListFragment.listDirectory();
+ // TODO Enable when "On Device" is recovered ?
+ // fileListFragment.listDirectory(MainApp.getOnlyOnDevice());
}
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
- if (BuildConfig.DEBUG) {
- menu.findItem(R.id.action_logger).setVisible(true);
- } else {
- menu.findItem(R.id.action_logger).setVisible(false);
- }
+ boolean drawerOpen = mDrawerLayout.isDrawerOpen(GravityCompat.START);
+ menu.findItem(R.id.action_upload).setVisible(!drawerOpen);
+ menu.findItem(R.id.action_create_dir).setVisible(!drawerOpen);
+ menu.findItem(R.id.action_sort).setVisible(!drawerOpen);
+
return super.onPrepareOptionsMenu(menu);
}
inflater.inflate(R.menu.main_menu, menu);
return true;
}
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
dialog.show(getSupportFragmentManager(), DIALOG_CREATE_FOLDER);
break;
}
- case R.id.action_sync_account: {
- startSynchronization();
- break;
- }
case R.id.action_upload: {
UploadSourceDialogFragment dialog = UploadSourceDialogFragment.newInstance(getAccount());
dialog.show(getSupportFragmentManager(), DIALOG_UPLOAD_SOURCE);
break;
}
- case R.id.action_settings: {
- Intent settingsIntent = new Intent(this, Preferences.class);
- startActivity(settingsIntent);
- break;
- }
- case R.id.action_logger: {
- Intent loggerIntent = new Intent(getApplicationContext(),LogHistoryActivity.class);
- startActivity(loggerIntent);
- break;
- }
case android.R.id.home: {
- FileFragment second = getSecondFragment();
- OCFile currentDir = getCurrentDir();
- if((currentDir != null && currentDir.getParentId() != 0) ||
- (second != null && second.getFile() != null)) {
- onBackPressed();
-
+ if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
+ mDrawerLayout.closeDrawer(GravityCompat.START);
+ } else {
+ mDrawerLayout.openDrawer(GravityCompat.START);
}
+ // TODO add hamburger to left of android.R.id.home
break;
}
case R.id.action_sort: {
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);
- break;
- case 1:
- sortByDate(false);
- break;
-
+ case 0:
+ sortByName(true);
+ break;
+ case 1:
+ sortByDate(false);
+ break;
}
-
+
dialog.dismiss();
-
}
});
builder.create().show();
} else {
Log_OC.d(TAG, "User clicked on 'Update' with no selection");
- Toast t = Toast.makeText(this, getString(R.string.filedisplay_no_file_selected), Toast.LENGTH_LONG);
+ Toast t = Toast.makeText(this, getString(R.string.filedisplay_no_file_selected),
+ Toast.LENGTH_LONG);
t.show();
return;
}
Log_OC.v(TAG, "onResume() start");
super.onResume();
+ // refresh Navigation Drawer account list
+ mNavigationDrawerAdapter.updateAccountList();
+
// refresh list of files
refreshListOfFilesFragment();
if (currentDir == null) {
// current folder was removed from the server
Toast.makeText( FileDisplayActivity.this,
- String.format(getString(R.string.sync_current_folder_was_removed),
+ String.format(
+ getString(R.string.sync_current_folder_was_removed),
mDirectories.getItem(0)),
Toast.LENGTH_LONG)
.show();
} else {
if (currentFile == null && !getFile().isFolder()) {
- // currently selected file was removed in the server, and now we know it
+ // currently selected file was removed in the server, and now we
+ // know it
cleanSecondFragment();
currentFile = currentDir;
}
currentDir.getRemotePath().equals(synchFolderRemotePath)) {
OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) {
- fileListFragment.listDirectory(currentDir);
+ fileListFragment.listDirectory();
+ // TODO Enable when "On Device" is recovered ?
+ // fileListFragment.listDirectory(currentDir,
+ // MainApp.getOnlyOnDevice());
}
}
setFile(currentFile);
}
mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) &&
- !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event));
+ !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED
+ .equals(event));
if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.
equals(event) &&
}
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
listOfFiles.listDirectory(root);
+ // TODO Enable when "On Device" is recovered ?
+ // listOfFiles.listDirectory(root, MainApp.getOnlyOnDevice());
setFile(listOfFiles.getCurrentFile());
startSyncFolderOperation(root, false);
}
if (listOfFiles != null) {
setNavigationListWithFolder(folder);
listOfFiles.listDirectory(folder);
+ // TODO Enable when "On Device" is recovered ?
+ // listOfFiles.listDirectory(folder, MainApp.getOnlyOnDevice());
setFile(listOfFiles.getCurrentFile());
startSyncFolderOperation(folder, false);
} else {
// only list of files - set for browsing through folders
OCFile currentDir = getCurrentDir();
boolean noRoot = (currentDir != null && currentDir.getParentId() != 0);
- actionBar.setDisplayHomeAsUpEnabled(noRoot);
- actionBar.setDisplayShowTitleEnabled(!noRoot);
+// actionBar.setDisplayHomeAsUpEnabled(noRoot);
+// actionBar.setDisplayShowTitleEnabled(!noRoot);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowTitleEnabled(true);
if (!noRoot) {
actionBar.setTitle(getString(R.string.default_display_name_for_root_folder));
View actionBarTitleView = getWindow().getDecorView().findViewById(actionBarTitleId);
if (actionBarTitleView != null) { // it's null in Android 2.x
- actionBarTitleView.setContentDescription(getString(R.string.default_display_name_for_root_folder));
+ actionBarTitleView.setContentDescription(
+ getString(R.string.default_display_name_for_root_folder));
}
}
actionBar.setNavigationMode(!noRoot ? ActionBar.NAVIGATION_MODE_STANDARD :
@Override
public void onServiceConnected(ComponentName component, IBinder service) {
- if (component.equals(new ComponentName(FileDisplayActivity.this, FileDownloader.class))) {
+ if (component.equals(new ComponentName(
+ FileDisplayActivity.this, FileDownloader.class))) {
Log_OC.d(TAG, "Download service connected");
mDownloaderBinder = (FileDownloaderBinder) service;
if (mWaitingToPreview != null)
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) {
listOfFiles.listDirectory();
+ // TODO Enable when "On Device" is recovered ?
+ // listOfFiles.listDirectory(MainApp.getOnlyOnDevice());
}
FileFragment secondFragment = getSecondFragment();
if (secondFragment != null && secondFragment instanceof FileDetailFragment) {
public void showUntrustedCertDialog(RemoteOperationResult result) {
// Show a dialog with the certificate info
SslUntrustedCertDialog dialog = SslUntrustedCertDialog.newInstanceForFullSslError(
- (CertificateCombinedException)result.getException());
+ (CertificateCombinedException) result.getException());
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
dialog.show(ft, DIALOG_UNTRUSTED_CERT);
private void sortByName(boolean ascending){
getListOfFilesFragment().sortByName(ascending);
}
+
+ public void restart(){
+ Intent i = new Intent(this, FileDisplayActivity.class);
+ i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(i);
+ }
+
+ public void closeDrawer() {
+ 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;
+ }
+ }
+ }
}
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;
if (!stateWasRecovered) {
OCFileListFragment listOfFolders = getListOfFilesFragment();
- listOfFolders.listDirectory(folder);
+ listOfFolders.listDirectory(folder/*, false*/);
startSyncFolderOperation(folder, false);
}
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
menu.findItem(R.id.action_upload).setVisible(false);
- menu.findItem(R.id.action_settings).setVisible(false);
- menu.findItem(R.id.action_sync_account).setVisible(false);
- menu.findItem(R.id.action_logger).setVisible(false);
menu.findItem(R.id.action_sort).setVisible(false);
return true;
}
protected void refreshListOfFilesFragment() {
OCFileListFragment fileListFragment = getListOfFilesFragment();
- if (fileListFragment != null) {
+ if (fileListFragment != null) {
fileListFragment.listDirectory();
+ // TODO Enable when "On Device" is recovered ?
+ // fileListFragment.listDirectory(false);
}
}
if (listOfFiles != null) { // should never be null, indeed
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
listOfFiles.listDirectory(root);
+ // TODO Enable when "On Device" is recovered ?
+ // listOfFiles.listDirectory(root, false);
setFile(listOfFiles.getCurrentFile());
updateNavigationElementsInActionBar();
startSyncFolderOperation(root, false);
OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) {
fileListFragment.listDirectory(currentDir);
+ // TODO Enable when "On Device" is recovered ?
+ // fileListFragment.listDirectory(currentDir, false);
}
}
setFile(currentFile);
import android.widget.ListAdapter;
import android.widget.ListView;
+import com.owncloud.android.BuildConfig;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
}
}
+
+ if (BuildConfig.DEBUG) {
+ Preference pLog = findPreference("log");
+ if (pLog != null ){
+ pLog.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ Intent loggerIntent = new Intent(getApplicationContext(),LogHistoryActivity.class);
+ startActivity(loggerIntent);
+ return true;
+ }
+ });
+ }
+ }
-
boolean recommendEnabled = getResources().getBoolean(R.bool.recommend_enabled);
Preference pRecommend = findPreference("recommend");
if (pRecommend != null){
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);
package com.owncloud.android.ui.activity;
import android.accounts.Account;
-
import android.os.Bundle;
import android.view.View.OnClickListener;
if (!stateWasRecovered) {
OCFileListFragment listOfFolders = getListOfFilesFragment();
- listOfFolders.listDirectory(folder);
+ // TODO Enable when "On Device" is recovered ?
+ listOfFolders.listDirectory(folder/*, false*/);
startSyncFolderOperation(folder, false);
}
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.utils.Log_OC;
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;
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);
+ // 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>();
mFile = getStorageManager().getFileByPath(full_path);
if (mFile != null) {
- Vector<OCFile> files = getStorageManager().getFolderContent(mFile);
+ // 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>();
* @param updatedStorageManager Optional updated storage manager; used to replace \r
* mStorageManager if is different (and not NULL)\r
*/\r
- public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager) {\r
+ public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager\r
+ /*, boolean onlyOnDevice*/) {\r
mFile = directory;\r
if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {\r
mStorageManager = updatedStorageManager;\r
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);\r
}\r
if (mStorageManager != null) {\r
- mFiles = mStorageManager.getFolderContent(mFile);\r
+ // TODO Enable when "On Device" is recovered ?\r
+ mFiles = mStorageManager.getFolderContent(mFile/*, onlyOnDevice*/);\r
mFilesOrig.clear();\r
mFilesOrig.addAll(mFiles);\r
\r
--- /dev/null
+package com.owncloud.android.ui.adapter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Group {
+
+ public String string;
+ public final List<String> children = new ArrayList<String>();
+
+ public Group(String string) {
+ this.string = string;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package com.owncloud.android.ui.adapter;
+
+import android.app.Activity;
+import android.util.SparseArray;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.BaseExpandableListAdapter;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.owncloud.android.R;
+
+public class MyExpandableListAdapter extends BaseExpandableListAdapter {
+
+ private final SparseArray<Group> groups;
+ public LayoutInflater inflater;
+ public Activity activity;
+
+ public MyExpandableListAdapter(Activity act, SparseArray<Group> groups) {
+ activity = act;
+ this.groups = groups;
+ inflater = act.getLayoutInflater();
+
+ }
+
+
+ @Override
+ public Object getChild(int groupPosition, int childPosition) {
+ return groups.get(groupPosition).children.get(childPosition);
+ }
+
+ @Override
+ public long getChildId(int groupPosition, int childPosition) {
+ return 0;
+ }
+
+ @Override
+ public View getChildView(int groupPosition, final int childPosition,
+ boolean isLastChild, View convertView, ViewGroup parent) {
+ final String children = (String) getChild(groupPosition, childPosition);
+ TextView text = null;
+ if (convertView == null) {
+ convertView = inflater.inflate(R.layout.listrow_details, null);
+ }
+
+
+ text = (TextView) convertView.findViewById(R.id.textView1);
+ text.setText(children);
+ convertView.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Toast.makeText(activity, children, Toast.LENGTH_SHORT).show();
+ }
+ });
+ return convertView;
+ }
+
+ @Override
+ public View getGroupView(int groupPosition, boolean isExpanded,
+ View convertView, ViewGroup parent) {
+ if (convertView == null) {
+ convertView = inflater.inflate(R.layout.listrow_group, null);
+ }
+
+ final Group group = (Group) getGroup(groupPosition);
+ if (group.children.size() == 0){
+ convertView.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Toast.makeText(activity, group.string, Toast.LENGTH_SHORT).show();
+ }
+ });
+ }
+ ((TextView) convertView).setText(group.string);
+
+ return convertView;
+ }
+
+ @Override
+ public int getChildrenCount(int groupPosition) {
+ return groups.get(groupPosition).children.size();
+ }
+
+ @Override
+ public Object getGroup(int groupPosition) {
+ return groups.get(groupPosition);
+ }
+
+ @Override
+ public int getGroupCount() {
+ return groups.size();
+ }
+
+ @Override
+ public void onGroupCollapsed(int groupPosition) {
+ super.onGroupCollapsed(groupPosition);
+ }
+
+ @Override
+ public void onGroupExpanded(int groupPosition) {
+ super.onGroupExpanded(groupPosition);
+ }
+
+ @Override
+ public long getGroupId(int groupPosition) {
+ return 0;
+ }
+
+ @Override
+ public boolean hasStableIds() {
+ return false;
+ }
+
+ @Override
+ public boolean isChildSelectable(int groupPosition, int childPosition) {
+ return false;
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ * 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;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.content.Context;
+import android.graphics.Color;
+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;
+import android.widget.TextView;
+
+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.activity.FileDisplayActivity;
+import com.owncloud.android.utils.BitmapUtils;
+
+public class NavigationDrawerListAdapter extends BaseAdapter {
+
+ private final static String TAG = NavigationDrawerListAdapter.class.getSimpleName();
+
+ private Context mContext;
+
+ private ArrayList<NavigationDrawerItem> mNavigationDrawerItems;
+ private ArrayList<Object> mAll = new ArrayList<Object>();
+ private Account[] mAccounts;
+ private boolean mShowAccounts;
+ private Account mCurrentAccount;
+ private FileDisplayActivity mFileDisplayActivity;
+
+
+ public NavigationDrawerListAdapter(Context context, FileDisplayActivity fileDisplayActivity,
+ ArrayList<NavigationDrawerItem> navigationDrawerItems){
+ mFileDisplayActivity = fileDisplayActivity;
+ mContext = context;
+ mNavigationDrawerItems = navigationDrawerItems;
+
+ updateAccountList();
+
+ mAll.addAll(mNavigationDrawerItems);
+ }
+
+ public void updateAccountList(){
+ AccountManager am = (AccountManager) mContext.getSystemService(mContext.ACCOUNT_SERVICE);
+ mAccounts = am.getAccountsByType(MainApp.getAccountType());
+ mCurrentAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
+ }
+
+ @Override
+ public int getCount() {
+ if (mShowAccounts){
+ return mNavigationDrawerItems.size() + 1;
+ } else {
+ return mNavigationDrawerItems.size();
+ }
+ }
+
+ @Override
+ public Object getItem(int position) {
+ //return all.get(position);
+ return null;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return 0;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+
+ LayoutInflater inflator = (LayoutInflater) mContext
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+
+ if (mAll.size() > position) {
+ // Normal entry
+ 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);
+ 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 (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);
+
+ for (Account account : mAccounts) {
+ RadioButton rb = new RadioButton(mContext);
+ rb.setText(account.name);
+ rb.setContentDescription(account.name);
+
+ try {
+ byte[] bytesOfMessage = account.name.substring(0,5).getBytes("UTF-8");
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ byte[] digest = md.digest(bytesOfMessage);
+ int result = Math.abs(ByteBuffer.wrap(digest).getInt());
+
+ Log_OC.d(TAG, "Integer: " + result % 100000);
+ Log_OC.d(TAG, "length: " + digest.length);
+
+
+ Double hue = (result % 100000) / 99999.0;
+
+ Log_OC.d(TAG, "hue: " + hue);
+
+ int[] rgb = BitmapUtils.hslToRgb(hue, 0.9, 0.65);
+ rb.setTextColor(Color.rgb(rgb[0], rgb[1], rgb[2]));
+ Log_OC.d(TAG, "Color: " + rgb[0] + " " + rgb[1] + rgb[2]);
+
+ } catch (Exception e){
+ Log_OC.d(TAG, e.toString());
+ rb.setTextColor(mContext.getResources().getColor(R.color.black));
+ }
+ RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(
+ LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
+ params.weight=1.0f;
+ params.setMargins(15, 5, 5, 5);
+
+ // Check the current account that is being used
+ if (account.name.equals(mCurrentAccount.name)) {
+ rb.setChecked(true);
+ } else {
+ rb.setChecked(false);
+ }
+
+ group.addView(rb, params);
+ }
+
+ group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
+ // checkedId is the RadioButton selected
+ RadioButton rb = (RadioButton) view.findViewById(checkedId);
+
+ AccountUtils.setCurrentOwnCloudAccount(mContext,rb.getText().toString());
+ notifyDataSetChanged();
+ mFileDisplayActivity.closeDrawer();
+
+ // restart the main activity
+ mFileDisplayActivity.restart();
+ }
+ });
+
+ return view;
+ }
+ }
+ return convertView;
+ }
+
+ // TODO update Account List after creating a new account and on fresh installation
+ public void setShowAccounts(boolean value){
+ mAll.clear();
+ mAll.addAll(mNavigationDrawerItems);
+
+ if (value){
+ mAll.add(1, mAccounts);
+ }
+ mShowAccounts = value;
+ }
+}
boolean containsKeepInSync = false;
if (mTargetFile.isFolder()) {
- Vector<OCFile> files = storageManager.getFolderContent(mTargetFile);
+ // TODO Enable when "On Device" is recovered ?
+ Vector<OCFile> files = storageManager.getFolderContent(mTargetFile/*, false*/);
for(OCFile file: files) {
containsKeepInSync = file.keepInSync() || containsKeepInSync;
private boolean mJustFolders;
private OCFile mTargetFile;
-
+
+
/**
* {@inheritDoc}
moveCount++;
} // exit is granted because storageManager.getFileByPath("/") never returns null
mFile = parentDir;
-
- listDirectory(mFile);
+
+ // TODO Enable when "On Device" is recovered ?
+ listDirectory(mFile /*, MainApp.getOnlyOnDevice()*/);
onRefresh(false);
if (file != null) {
if (file.isFolder()) {
// update state and view of this fragment
- listDirectory(file);
+ // 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
/**
* Calls {@link OCFileListFragment#listDirectory(OCFile)} with a null parameter
*/
- public void listDirectory(){
+ public void listDirectory(/*boolean onlyOnDevice*/){
listDirectory(null);
+ // TODO Enable when "On Device" is recovered ?
+ // listDirectory(null, onlyOnDevice);
+ }
+
+ public void refreshDirectory(){
+ // TODO Enable when "On Device" is recovered ?
+ listDirectory(getCurrentFile()/*, MainApp.getOnlyOnDevice()*/);
}
/**
*
* @param directory File to be listed
*/
- public void listDirectory(OCFile directory) {
+ public void listDirectory(OCFile directory/*, boolean onlyOnDevice*/) {
FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
if (storageManager != null) {
directory = storageManager.getFileById(directory.getParentId());
}
- mAdapter.swapDirectory(directory, storageManager);
+ // TODO Enable when "On Device" is recovered ?
+ mAdapter.swapDirectory(directory, storageManager/*, onlyOnDevice*/);
if (mFile == null || !mFile.equals(directory)) {
mCurrentListView.setSelection(0);
}
public void sortBySize(boolean descending) {
mAdapter.setSortOrder(FileStorageUtils.SORT_SIZE, descending);
}
-
+
+
+
}
// should not be necessary
parentFolder = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
}
+
+ // TODO Enable when "On Device" is recovered ?
mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(),
- parentFolder, getAccount(), getStorageManager());
+ parentFolder, getAccount(), getStorageManager()/*, MainApp.getOnlyOnDevice()*/);
+
mViewPager = (ExtendedViewPager) findViewById(R.id.fragmentPager);
int position = mHasSavedPosition ? mSavedPosition :
mPreviewImagePagerAdapter.getFilePosition(getFile());
*/
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;
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;
/**
* 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) {
+ public PreviewImagePagerAdapter(FragmentManager fragmentManager, OCFile parentFolder,
+ Account account, FileDataStorageManager storageManager /*,
+ boolean onlyOnDevice*/) {
super(fragmentManager);
if (fragmentManager == null) {
mAccount = account;
mStorageManager = storageManager;
- mImageFiles = mStorageManager.getFolderImages(parentFolder);
+ // TODO Enable when "On Device" is recovered ?
+ mImageFiles = mStorageManager.getFolderImages(parentFolder/*, false*/);
mImageFiles = FileStorageUtils.sortFolder(mImageFiles);
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);
}
/**
+ * Converts an HSL color value to RGB. Conversion formula
+ * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
+ * Assumes h, s, and l are contained in the set [0, 1] and
+ * returns r, g, and b in the set [0, 255].
+ * from: http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c
+ *
+ * @param integer h The hue
+ * @param Integer s The saturation
+ * @param Integer l The lightness
+ * @return Array The RGB representation
+ */
+ public static int[] hslToRgb(Double h, Double s, Double l){
+ Double r, g, b;
+
+ if(s == 0){
+ r = g = b = l; // achromatic
+ } else {
+ Double q = l < 0.5 ? l * (1 + s) : l + s - l * s;
+ Double p = 2 * l - q;
+ r = hue2rgb(p, q, h + 1/3) * 255;
+ g = hue2rgb(p, q, h) * 255;
+ b = hue2rgb(p, q, h - 1/3) * 255;
+ }
+
+
+ int[] array = {r.intValue(), g.intValue(), b.intValue()};
+ return array;
+ }
+
+ private static Double hue2rgb(Double p, Double q, Double t){
+ if(t < 0) t += 1;
+ if(t > 1) t -= 1;
+ if(t < 1/6) return p + (q - p) * 6 * t;
+ if(t < 1/2) return q;
+ if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
+ return p;
+ }
+
+
+ /**
* Checks if file passed is an image
* @param file
* @return true/false