From: Bartek Przybylski Date: Sat, 14 Apr 2012 23:00:38 +0000 (+0200) Subject: fix file display, fix syncing, fix authenticator & other stuff X-Git-Tag: oc-android-1.4.3~443^2~1 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/7cf441258b957fe9cac5d0dbd823d9b53b96c6e3 fix file display, fix syncing, fix authenticator & other stuff --- diff --git a/src/eu/alefzero/owncloud/authenticator/AuthUtils.java b/src/eu/alefzero/owncloud/authenticator/AuthUtils.java index e3fc32c4..8287e128 100644 --- a/src/eu/alefzero/owncloud/authenticator/AuthUtils.java +++ b/src/eu/alefzero/owncloud/authenticator/AuthUtils.java @@ -244,6 +244,9 @@ public class AuthUtils { break; } } + } else if (ocAccounts.length != 0) { + // we at least need to take first account as fallback + defaultAccount = ocAccounts[0]; } return defaultAccount; diff --git a/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java b/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java index 827435fe..38212785 100644 --- a/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java +++ b/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java @@ -90,7 +90,7 @@ public class FileDataStorageManager implements DataStorageManager { cv.put(ProviderTableMeta.FILE_PATH, file.getPath()); cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath()); cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name); - + if (fileExists(file.getPath())) { overriden = true; if (getContentResolver() != null) { @@ -109,15 +109,20 @@ public class FileDataStorageManager implements DataStorageManager { } } } else { + Uri result_uri = null; if (getContentResolver() != null) { - getContentResolver().insert(ProviderTableMeta.CONTENT_URI_FILE, cv); + result_uri = getContentResolver().insert(ProviderTableMeta.CONTENT_URI_FILE, cv); } else { try { - getContentProvider().insert(ProviderTableMeta.CONTENT_URI_FILE, cv); + result_uri = getContentProvider().insert(ProviderTableMeta.CONTENT_URI_FILE, cv); } catch (RemoteException e) { Log.e(TAG, "Fail to insert insert file to database " + e.getMessage()); } } + if (result_uri != null) { + long new_id = Long.parseLong(result_uri.getPathSegments().get(1)); + file.setFileId(new_id); + } } if (file.isDirectory() && file.needsUpdatingWhileSaving()) @@ -158,6 +163,7 @@ public class FileDataStorageManager implements DataStorageManager { Uri req_uri = Uri.withAppendedPath( ProviderTableMeta.CONTENT_URI_DIR, String.valueOf(f.getFileId())); Cursor c = null; + if (getContentProvider() != null) { try { c = getContentProvider().query(req_uri, null, null, null, null); @@ -169,12 +175,13 @@ public class FileDataStorageManager implements DataStorageManager { c = getContentResolver().query(req_uri, null, null, null, null); } - if (c.moveToFirst()) + if (c.moveToFirst()) { do { OCFile child = createFileInstance(c); ret.add(child); } while (c.moveToNext()); - + } + c.close(); return ret; } diff --git a/src/eu/alefzero/owncloud/datamodel/OCFile.java b/src/eu/alefzero/owncloud/datamodel/OCFile.java index 62705f15..62bf0656 100644 --- a/src/eu/alefzero/owncloud/datamodel/OCFile.java +++ b/src/eu/alefzero/owncloud/datamodel/OCFile.java @@ -38,9 +38,9 @@ public class OCFile { * @param path The remote path of the file */ public OCFile(String path) { + resetData(); update_while_saving_ = false; path_ = path; - resetData(); } /** diff --git a/src/eu/alefzero/owncloud/syncadapter/AbstractOwnCloudSyncAdapter.java b/src/eu/alefzero/owncloud/syncadapter/AbstractOwnCloudSyncAdapter.java index a3eead94..698fda8b 100644 --- a/src/eu/alefzero/owncloud/syncadapter/AbstractOwnCloudSyncAdapter.java +++ b/src/eu/alefzero/owncloud/syncadapter/AbstractOwnCloudSyncAdapter.java @@ -222,6 +222,7 @@ public abstract class AbstractOwnCloudSyncAdapter extends Log.d(TAG, "No update for file/dir " + file.getFileName() + " is needed"); } else { + file = new OCFile(n.getProperty(NodeProperty.PATH)); Log.d(TAG, "File " + n.getProperty(NodeProperty.PATH) + " will be " + (file.fileExists() ? "updated" : "created")); @@ -231,7 +232,7 @@ public abstract class AbstractOwnCloudSyncAdapter extends long create = n.getProperty(NodeProperty.CREATE_DATE) == null ? 0 : Long.parseLong(n .getProperty(NodeProperty.CREATE_DATE)); - file = new OCFile(n.getProperty(NodeProperty.PATH)); + file.setFileLength(len); file.setCreationTimestamp(create); file.setModificationTimestamp(mod); diff --git a/src/eu/alefzero/owncloud/ui/fragment/FileListFragment.java b/src/eu/alefzero/owncloud/ui/fragment/FileListFragment.java index 3f762da6..fa3e9046 100644 --- a/src/eu/alefzero/owncloud/ui/fragment/FileListFragment.java +++ b/src/eu/alefzero/owncloud/ui/fragment/FileListFragment.java @@ -23,6 +23,7 @@ import java.util.Vector; import android.accounts.Account; import android.content.Intent; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.AdapterView; import eu.alefzero.owncloud.R; @@ -56,8 +57,6 @@ public class FileListFragment extends FragmentListView { mAccount = AuthUtils.getCurrentOwnCloudAccount(getActivity()); populateFileList(); - // TODO: Remove this testing stuff - //addContact(mAccount, "Bartek Przybylski", "czlowiek"); } @Override @@ -80,6 +79,7 @@ public class FileListFragment extends FragmentListView { i.putExtra("FILE_NAME", file.getFileName()); i.putExtra("FULL_PATH", file.getPath()); i.putExtra("FILE_ID", id_); + Log.e("ASD", mAccount+""); i.putExtra("ACCOUNT", mAccount); FileDetailFragment fd = (FileDetailFragment) getFragmentManager().findFragmentById(R.id.fileDetail); if (fd != null) { @@ -103,10 +103,10 @@ public class FileListFragment extends FragmentListView { private void populateFileList() { String s = "/"; for (String a : mDirNames) - s+= a+"/"; + s+= a + "/"; mStorageManager = new FileDataStorageManager(mAccount, getActivity().getContentResolver()); - OCFile file = new OCFile(s); + OCFile file = mStorageManager.getFileByPath(s); mFiles = mStorageManager.getDirectoryContent(file); setListAdapter(new FileListListAdapter(file, mStorageManager, getActivity())); }