along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<manifest package="com.owncloud.android"
- android:versionCode="104000"
- android:versionName="1.4.0" xmlns:android="http://schemas.android.com/apk/res/android">
+ android:versionCode="104001"
+ android:versionName="1.4.1" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<activity android:name="com.owncloud.android.ui.preview.PreviewVideoActivity"
android:label="@string/app_name"
- android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
+ android:theme="@style/Theme.ownCloud.Fullscreen" >
</activity>
<service
import android.webkit.MimeTypeMap;
import com.actionbarsherlock.app.SherlockFragmentActivity;
- import com.owncloud.android.AccountUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountAuthenticator;
+ import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.OCFile;
import eu.alefzero.webdav.WebdavUtils;
/** Flag to signal that the activity will is finishing to enforce the creation of an ownCloud {@link Account} */
private boolean mRedirectingToSetupAccount = false;
+ /** Flag to signal when the value of mAccount was set */
+ private boolean mAccountWasSet;
+
+ /** Flag to signal when the value of mAccount was restored from a saved state */
+ private boolean mAccountWasRestored;
+
/**
* Loads the cownCloud {@link Account} and main {@link OCFile} to be handled by the instance of
mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
}
+ Account oldAccount = mAccount;
grantValidAccount();
if (mAccount != null) {
- onAccountSet(savedInstanceState != null);
+ mAccountWasSet = true;
+ mAccountWasRestored = (savedInstanceState != null && mAccount.equals(oldAccount));
+ } else {
+ mAccountWasSet = false;
+ mAccountWasRestored = false;
}
}
Account oldAccount = mAccount;
grantValidAccount();
if (mAccount != null && !mAccount.equals(oldAccount)) {
- onAccountSet(false);
+ mAccountWasSet = true;
+ mAccountWasRestored = false;
+ } else {
+ mAccountWasSet = false;
+ mAccountWasRestored = false;
}
}
+
-
/**
* Validates the ownCloud {@link Account} associated to the Activity any time it is restarted.
*
}
+ @Override
+ protected void onStart() {
+ // maybe better in onPostCreate() ?
+ super.onStart();
+ if (mAccountWasSet) {
+ onAccountSet(mAccountWasRestored);
+ }
+ }
+
+
/**
* Launches the account creation activity. To use when no ownCloud account is available
*/
FileActivity.this.onAccountSet(false);
}
} catch (OperationCanceledException e) {
- Log_OC.e(TAG, "Account creation canceled");
+ Log_OC.d(TAG, "Account creation canceled");
} catch (Exception e) {
Log_OC.e(TAG, "Account creation finished in exception: ", e);
Log_OC.e(TAG, "Account creation callback with null bundle");
}
if (mAccount == null) {
- finish();
+ moveTaskToBack(true);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
Log_OC.d(TAG, "onCreate() start");
- requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+ super.onCreate(savedInstanceState);
- super.onCreate(savedInstanceState); // this calls onAccountChanged() when ownCloud Account is valid
+ requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
mHandler = new Handler();
mRightFragmentContainer = findViewById(R.id.right_fragment_container);
if (savedInstanceState == null) {
createMinFragments();
- if (!isRedirectingToSetupAccount()) {
- initFragmentsWithFile();
- }
}
// Action bar setup
mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);
- OCFile currFile = getFile();
- if (mStorageManager != null) {
- while(currFile != null && currFile.getFileName() != OCFile.PATH_SEPARATOR) {
- if (currFile.isDirectory()) {
- mDirectories.add(currFile.getFileName());
- }
- currFile = mStorageManager.getFileById(currFile.getParentId());
- }
- }
- mDirectories.add(OCFile.PATH_SEPARATOR);
- ActionBar actionBar = getSupportActionBar();
- actionBar.setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation
- setSupportProgressBarIndeterminateVisibility(false); // always AFTER setContentView(...) ; to workaround bug in its implementation
+ getSupportActionBar().setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation
+ setSupportProgressBarIndeterminateVisibility(false); // always AFTER setContentView(...) ; to work around bug in its implementation
Log_OC.d(TAG, "onCreate() end");
}
/// Check whether the 'main' OCFile handled by the Activity is contained in the current Account
OCFile file = getFile();
if (file != null) {
- file = mStorageManager.getFileByPath(file.getRemotePath()); // currentDir = null if not in the current Account
+ if (file.isDown() && file.getLastSyncDateForProperties() == 0) {
+ // upload in progress - right now, files are not inserted in the local cache until the upload is successful
+ if (mStorageManager.getFileById(file.getParentId()) == null) {
+ file = null; // not able to know the directory where the file is uploading
+ }
+ } else {
+ file = mStorageManager.getFileByPath(file.getRemotePath()); // currentDir = null if not in the current Account
+ }
}
if (file == null) {
// fall back to root folder
- file = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR); // never should return null
+ file = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR); // never returns null
}
setFile(file);
-
- if (findViewById(android.R.id.content) != null && !stateWasRecovered) {
+ mDirectories.clear();
+ OCFile fileIt = file;
+ while(fileIt != null && fileIt.getFileName() != OCFile.PATH_SEPARATOR) {
+ if (fileIt.isDirectory()) {
+ mDirectories.add(fileIt.getFileName());
+ }
+ fileIt = mStorageManager.getFileById(fileIt.getParentId());
+ }
+ mDirectories.add(OCFile.PATH_SEPARATOR);
+ if (!stateWasRecovered) {
Log_OC.e(TAG, "Initializing Fragments in onAccountChanged..");
initFragmentsWithFile();
+
} else {
- Log_OC.e(TAG, "Fragment initializacion ignored in onAccountChanged due to lack of CONTENT VIEW");
+ updateFragmentsVisibility(!file.isDirectory());
+ updateNavigationElementsInActionBar(file.isDirectory() ? null : file);
}
+
} else {
Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
}
private void initFragmentsWithFile() {
if (getAccount() != null && getFile() != null) {
+ /// First fragment
+ OCFileListFragment listOfFiles = getListOfFilesFragment();
+ if (listOfFiles != null) {
+ listOfFiles.listDirectory(getCurrentDir());
+ } else {
+ Log.e(TAG, "Still have a chance to lose the initializacion of list fragment >(");
+ }
+
/// Second fragment
OCFile file = getFile();
Fragment secondFragment = chooseInitialSecondFragment(file);
if (secondFragment != null) {
setSecondFragment(secondFragment);
+ updateFragmentsVisibility(true);
+ updateNavigationElementsInActionBar(file);
+
+ } else {
+ cleanSecondFragment();
}
} else {
private Fragment chooseInitialSecondFragment(OCFile file) {
Fragment secondFragment = null;
if (file != null && !file.isDirectory()) {
- if (file.isDown() && PreviewMediaFragment.canBePreviewed(file)) {
+ if (file.isDown() && PreviewMediaFragment.canBePreviewed(file)
+ && file.getLastSyncDateForProperties() > 0 // temporal fix
+ ) {
int startPlaybackPosition = getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true);
secondFragment = new PreviewMediaFragment(file, getAccount(), startPlaybackPosition, autoplay);
FragmentTransaction tr = getSupportFragmentManager().beginTransaction();
tr.remove(second);
tr.commit();
- updateFragmentsVisibility(false);
}
+ updateFragmentsVisibility(false);
+ updateNavigationElementsInActionBar(null);
}
protected void refeshListOfFilesFragment() {
setFile(listOfFiles.getCurrentFile());
}
cleanSecondFragment();
- updateNavigationElementsInActionBar(null);
}
@Override
outState.putParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW, mWaitingToPreview);
Log_OC.d(TAG, "onSaveInstanceState() end");
}
-
- @Override
- protected void onStart() {
- super.onStart();
- FileFragment second = getSecondFragment();
- updateFragmentsVisibility(second != null);
- updateNavigationElementsInActionBar((second == null) ? null : second.getFile());
- }
+
@Override
protected void onResume() {
mDownloadFinishReceiver = new DownloadFinishReceiver();
registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
- // List current directory
- OCFileListFragment listOfFiles = getListOfFilesFragment();
- if (listOfFiles != null) {
- listOfFiles.listDirectory(getCurrentDir()); // TODO we should find the way to avoid the need of this (maybe it's not necessary yet; to check)
- }
-
Log_OC.d(TAG, "onResume() end");
}
public void onBrowsedDownTo(OCFile directory) {
pushDirname(directory);
cleanSecondFragment();
- updateNavigationElementsInActionBar(null);
}
/**
/**
* TODO
*/
- private void updateNavigationElementsInActionBar(OCFile currentFile) {
+ private void updateNavigationElementsInActionBar(OCFile chosenFile) {
ActionBar actionBar = getSupportActionBar();
- if (currentFile == null || mDualPane) {
+ if (chosenFile == null || mDualPane) {
// only list of files - set for browsing through folders
OCFile currentDir = getCurrentDir();
actionBar.setDisplayHomeAsUpEnabled(currentDir != null && currentDir.getParentId() != 0);
} else {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
- actionBar.setTitle(currentFile.getFileName());
+ actionBar.setTitle(chosenFile.getFileName());
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
}
}
* {@inheritDoc}
*/
@Override
- public OCFile getInitialDirectory() {
- return getCurrentDir();
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
public void onFileStateChanged() {
refeshListOfFilesFragment();
+ updateNavigationElementsInActionBar(getSecondFragment().getFile());
}
if (file != null) {
if (file.isDirectory()) {
return file;
- } else {
+ } else if (mStorageManager != null) {
return mStorageManager.getFileById(file.getParentId());
}
- } else {
- return null;
}
+ return null;
}
}
import android.accounts.Account;
import android.content.Intent;
- import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
- import android.widget.MediaController;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
--import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
- import com.owncloud.android.datamodel.FileDataStorageManager;
- import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.ui.dialog.IndeterminateProgressDialog;
import com.owncloud.android.ui.fragment.ConfirmationDialogFragment;
import com.owncloud.android.ui.fragment.LocalFileListFragment;
import com.owncloud.android.ui.fragment.ConfirmationDialogFragment.ConfirmationDialogFragmentListener;
import com.owncloud.android.utils.FileStorageUtils;
- import com.owncloud.android.AccountUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
*
*/
-public class UploadFilesActivity extends SherlockFragmentActivity implements
+public class UploadFilesActivity extends FileActivity implements
LocalFileListFragment.ContainerActivity, OnNavigationListener, OnClickListener, ConfirmationDialogFragmentListener {
private ArrayAdapter<String> mDirectories;
private LocalFileListFragment mFileListFragment;
private Button mCancelBtn;
private Button mUploadBtn;
- private Account mAccount;
+ private Account mAccountOnCreation;
private DialogFragment mCurrentDialog;
- public static final String EXTRA_ACCOUNT = UploadFilesActivity.class.getCanonicalName() + ".EXTRA_ACCOUNT";
public static final String EXTRA_CHOSEN_FILES = UploadFilesActivity.class.getCanonicalName() + ".EXTRA_CHOSEN_FILES";
public static final int RESULT_OK_AND_MOVE = RESULT_FIRST_USER;
mCurrentDir = Environment.getExternalStorageDirectory();
}
- mAccount = getIntent().getParcelableExtra(EXTRA_ACCOUNT);
+ mAccountOnCreation = getAccount();
/// USER INTERFACE
File localFile = new File(localPath);
total += localFile.length();
}
- return (FileStorageUtils.getUsableSpace(mAccount.name) >= total);
+ return (FileStorageUtils.getUsableSpace(mAccountOnCreation.name) >= total);
}
/**
public void onCancel(String callerTag) {
/// nothing to do; don't finish, let the user change the selection
Log_OC.d(TAG, "Negative button in dialog was clicked; dialog tag is " + callerTag);
+ }
+
+
+ @Override
+ protected void onAccountSet(boolean stateWasRecovered) {
+ if (getAccount() != null) {
+ if (!mAccountOnCreation.equals(getAccount())) {
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+
+ } else {
+ Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
+ setResult(RESULT_CANCELED);
+ finish();
+ }
}
-
-/* ownCloud Android client application
- * Copyright (C) 2011 Bartek Przybylski
- * Copyright (C) 2012-2013 ownCloud Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU 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.util.Vector;
-
-import android.accounts.Account;
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import com.owncloud.android.DisplayUtils;
-import com.owncloud.android.R;
-import com.owncloud.android.authentication.AccountUtils;
-import com.owncloud.android.datamodel.DataStorageManager;
-import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
-import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
-import com.owncloud.android.ui.activity.TransferServiceGetter;
-
-/**
- * This Adapter populates a ListView with all files and folders in an ownCloud
- * instance.
- *
- * @author Bartek Przybylski
- *
- */
-public class FileListListAdapter extends BaseAdapter implements ListAdapter {
- private Context mContext;
- private OCFile mFile = null;
- private Vector<OCFile> mFiles = null;
- private DataStorageManager mStorageManager;
- private Account mAccount;
- private TransferServiceGetter mTransferServiceGetter;
- //total size of a directory (recursive)
- private Long totalSizeOfDirectoriesRecursive = null;
- private Long lastModifiedOfAllSubdirectories = null;
-
- public FileListListAdapter(OCFile file, DataStorageManager storage_man,
- Context context, TransferServiceGetter transferServiceGetter) {
- mStorageManager = storage_man;
- mContext = context;
- mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
- mTransferServiceGetter = transferServiceGetter;
- swapDirectory(file, mStorageManager);
- /*mFile = file;
- mFiles = mStorageManager.getDirectoryContent(mFile);*/
- }
-
- @Override
- public boolean areAllItemsEnabled() {
- return true;
- }
-
- @Override
- public boolean isEnabled(int position) {
- return true;
- }
-
- @Override
- public int getCount() {
- return mFiles != null ? mFiles.size() : 0;
- }
-
- @Override
- public Object getItem(int position) {
- if (mFiles == null || mFiles.size() <= position)
- return null;
- return mFiles.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- if (mFiles == null || mFiles.size() <= position)
- return 0;
- return mFiles.get(position).getFileId();
- }
-
- @Override
- public int getItemViewType(int position) {
- return 0;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- View view = convertView;
- if (view == null) {
- LayoutInflater inflator = (LayoutInflater) mContext
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- view = inflator.inflate(R.layout.list_item, null);
- }
- if (mFiles != null && mFiles.size() > position) {
- OCFile file = mFiles.get(position);
- TextView fileName = (TextView) view.findViewById(R.id.Filename);
- String name = file.getFileName();
-
- fileName.setText(name);
- ImageView fileIcon = (ImageView) view.findViewById(R.id.imageView1);
- fileIcon.setImageResource(DisplayUtils.getResourceId(file.getMimetype()));
- ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2);
- FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder();
- FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();
- if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) {
- localStateView.setImageResource(R.drawable.downloading_file_indicator);
- localStateView.setVisibility(View.VISIBLE);
- } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {
- localStateView.setImageResource(R.drawable.uploading_file_indicator);
- localStateView.setVisibility(View.VISIBLE);
- } else if (file.isDown()) {
- localStateView.setImageResource(R.drawable.local_file_indicator);
- localStateView.setVisibility(View.VISIBLE);
- } else {
- localStateView.setVisibility(View.INVISIBLE);
- }
-
-
- TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);
- TextView lastModV = (TextView) view.findViewById(R.id.last_mod);
- ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);
-
- if (!file.isDirectory()) {
- fileSizeV.setVisibility(View.VISIBLE);
- fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
- lastModV.setVisibility(View.VISIBLE);
- lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
- // this if-else is needed even thoe fav icon is visible by default
- // because android reuses views in listview
- if (!file.keepInSync()) {
- view.findViewById(R.id.imageView3).setVisibility(View.GONE);
- } else {
- view.findViewById(R.id.imageView3).setVisibility(View.VISIBLE);
- }
-
- ListView parentList = (ListView)parent;
- if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) {
- checkBoxV.setVisibility(View.GONE);
- } else {
- if (parentList.isItemChecked(position)) {
- checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);
- } else {
- checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);
- }
- checkBoxV.setVisibility(View.VISIBLE);
- }
-
- }
- else {
-
- getDirectorySizeNumber(file,true);
- if (lastModifiedOfAllSubdirectories == null)
- {
- lastModV.setVisibility(View.GONE);
- fileSizeV.setVisibility(View.GONE);
- }
- else
- {
- lastModV.setVisibility(View.VISIBLE);
- lastModV.setText(DisplayUtils.unixTimeToHumanReadable(lastModifiedOfAllSubdirectories));
- fileSizeV.setVisibility(View.VISIBLE);
- fileSizeV.setText(DisplayUtils.bytesToHumanReadable((totalSizeOfDirectoriesRecursive == null) ? 0 : totalSizeOfDirectoriesRecursive));
- }
- checkBoxV.setVisibility(View.GONE);
- view.findViewById(R.id.imageView3).setVisibility(View.GONE);
- }
- }
-
- return view;
- }
-
-
- /**
- * - This method counts recursively all subdirectories and their files from the root directory.
- * - It also shows a timestamp of the last modificated file inside the root directory
- *
- * @param OCFile : startDirectory
- * @param boolean : counting starts from here ?
- */
- private void getDirectorySizeNumber(OCFile directory,boolean startOfRecursive) {
- if (startOfRecursive) {
- totalSizeOfDirectoriesRecursive = null;
- }
- Vector<OCFile> files = mStorageManager.getDirectoryContent(directory);
- for (OCFile file : files) {
- if(!file.isDirectory()) {
- if (totalSizeOfDirectoriesRecursive == null) {
- totalSizeOfDirectoriesRecursive = file.getFileLength();
- lastModifiedOfAllSubdirectories = file.getModificationTimestamp();
- continue;
- }
-
- totalSizeOfDirectoriesRecursive += file.getFileLength();
- if (lastModifiedOfAllSubdirectories < file.getModificationTimestamp()) {
- lastModifiedOfAllSubdirectories = file.getModificationTimestamp();
- }
- }
- else {
- this.getDirectorySizeNumber(file, false);
- }
- }
- }
-
-
- @Override
- public int getViewTypeCount() {
- return 1;
- }
-
- @Override
- public boolean hasStableIds() {
- return true;
- }
-
- @Override
- public boolean isEmpty() {
- return (mFiles == null || mFiles.isEmpty());
- }
-
- /**
- * Change the adapted directory for a new one
- * @param directory New file to adapt. Can be NULL, meaning "no content to adapt".
- * @param updatedStorageManager Optional updated storage manager; used to replace mStorageManager if is different (and not NULL)
- */
- public void swapDirectory(OCFile directory, DataStorageManager updatedStorageManager) {
- mFile = directory;
- if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {
- mStorageManager = updatedStorageManager;
- mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
- }
- if (mStorageManager != null) {
- mFiles = mStorageManager.getDirectoryContent(mFile);
- } else {
- mFiles = null;
- }
- notifyDataSetChanged();
- }
-
-}
+/* ownCloud Android client application\r
+ * Copyright (C) 2011 Bartek Przybylski\r
+ * Copyright (C) 2012-2013 ownCloud Inc.\r
+ *\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License version 2,\r
+ * as published by the Free Software Foundation.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\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
+ */\r
+package com.owncloud.android.ui.adapter;\r
+\r
- import java.util.Vector;\r
- \r
- import com.owncloud.android.AccountUtils;\r
- import com.owncloud.android.DisplayUtils;\r
- import com.owncloud.android.datamodel.DataStorageManager;\r
- import com.owncloud.android.datamodel.OCFile;\r
- import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;\r
- import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;\r
- import com.owncloud.android.ui.activity.TransferServiceGetter;\r
- \r
- import com.owncloud.android.R;\r
- \r
+import android.accounts.Account;\r
+import android.content.Context;\r
+import android.view.LayoutInflater;\r
+import android.view.View;\r
+import android.view.ViewGroup;\r
+import android.widget.BaseAdapter;\r
+import android.widget.ImageView;\r
+import android.widget.ListAdapter;\r
+import android.widget.ListView;\r
+import android.widget.TextView;\r
+\r
++import com.owncloud.android.DisplayUtils;\r
++import com.owncloud.android.R;\r
++import com.owncloud.android.authentication.AccountUtils;\r
++import com.owncloud.android.datamodel.DataStorageManager;\r
++import com.owncloud.android.datamodel.OCFile;\r
++import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;\r
++import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;\r
++import com.owncloud.android.ui.activity.TransferServiceGetter;\r
++\r
++import java.util.Vector;\r
++\r
++\r
+/**\r
+ * This Adapter populates a ListView with all files and folders in an ownCloud\r
+ * instance.\r
+ * \r
+ * @author Bartek Przybylski\r
+ * \r
+ */\r
+public class FileListListAdapter extends BaseAdapter implements ListAdapter {\r
+ private Context mContext;\r
+ private OCFile mFile = null;\r
+ private Vector<OCFile> mFiles = null;\r
- private DataStorageManager mStorageManager = null;\r
++ private DataStorageManager mStorageManager;\r
+ private Account mAccount;\r
+ private TransferServiceGetter mTransferServiceGetter;\r
- \r
++ //total size of a directory (recursive)\r
++ private Long totalSizeOfDirectoriesRecursive = null;\r
++ private Long lastModifiedOfAllSubdirectories = null;\r
++ \r
+ public FileListListAdapter(Context context, TransferServiceGetter transferServiceGetter) {\r
+ mContext = context;\r
+ mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);\r
+ mTransferServiceGetter = transferServiceGetter;\r
+ }\r
+\r
+ @Override\r
+ public boolean areAllItemsEnabled() {\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public boolean isEnabled(int position) {\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public int getCount() {\r
+ return mFiles != null ? mFiles.size() : 0;\r
+ }\r
+\r
+ @Override\r
+ public Object getItem(int position) {\r
+ if (mFiles == null || mFiles.size() <= position)\r
+ return null;\r
+ return mFiles.get(position);\r
+ }\r
+\r
+ @Override\r
+ public long getItemId(int position) {\r
+ if (mFiles == null || mFiles.size() <= position)\r
+ return 0;\r
+ return mFiles.get(position).getFileId();\r
+ }\r
+\r
+ @Override\r
+ public int getItemViewType(int position) {\r
+ return 0;\r
+ }\r
+\r
++ \r
+ @Override\r
+ public View getView(int position, View convertView, ViewGroup parent) {\r
+ View view = convertView;\r
+ if (view == null) {\r
+ LayoutInflater inflator = (LayoutInflater) mContext\r
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);\r
+ view = inflator.inflate(R.layout.list_item, null);\r
+ }\r
++ \r
+ if (mFiles != null && mFiles.size() > position) {\r
+ OCFile file = mFiles.get(position);\r
+ TextView fileName = (TextView) view.findViewById(R.id.Filename);\r
+ String name = file.getFileName();\r
+\r
+ fileName.setText(name);\r
+ ImageView fileIcon = (ImageView) view.findViewById(R.id.imageView1);\r
+ fileIcon.setImageResource(DisplayUtils.getResourceId(file.getMimetype()));\r
+ ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2);\r
+ FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder();\r
+ FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();\r
+ if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) {\r
+ localStateView.setImageResource(R.drawable.downloading_file_indicator);\r
+ localStateView.setVisibility(View.VISIBLE);\r
+ } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {\r
+ localStateView.setImageResource(R.drawable.uploading_file_indicator);\r
+ localStateView.setVisibility(View.VISIBLE);\r
+ } else if (file.isDown()) {\r
+ localStateView.setImageResource(R.drawable.local_file_indicator);\r
+ localStateView.setVisibility(View.VISIBLE);\r
+ } else {\r
+ localStateView.setVisibility(View.INVISIBLE);\r
+ }\r
- \r
+ \r
+ TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);\r
+ TextView lastModV = (TextView) view.findViewById(R.id.last_mod);\r
+ ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);\r
+ \r
+ if (!file.isDirectory()) {\r
+ fileSizeV.setVisibility(View.VISIBLE);\r
+ fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));\r
+ lastModV.setVisibility(View.VISIBLE);\r
+ lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));\r
+ // this if-else is needed even thoe fav icon is visible by default\r
+ // because android reuses views in listview\r
+ if (!file.keepInSync()) {\r
+ view.findViewById(R.id.imageView3).setVisibility(View.GONE);\r
+ } else {\r
+ view.findViewById(R.id.imageView3).setVisibility(View.VISIBLE);\r
+ }\r
+ \r
+ ListView parentList = (ListView)parent;\r
+ if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) { \r
+ checkBoxV.setVisibility(View.GONE);\r
+ } else {\r
+ if (parentList.isItemChecked(position)) {\r
+ checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);\r
+ } else {\r
+ checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);\r
+ }\r
+ checkBoxV.setVisibility(View.VISIBLE);\r
+ }\r
+ \r
- } else {\r
- fileSizeV.setVisibility(View.GONE);\r
- lastModV.setVisibility(View.GONE);\r
++ } \r
++ else {\r
++ \r
++ getDirectorySizeNumber(file,true);\r
++ if (lastModifiedOfAllSubdirectories == null)\r
++ {\r
++ lastModV.setVisibility(View.GONE);\r
++ fileSizeV.setVisibility(View.GONE);\r
++ }\r
++ else\r
++ {\r
++ lastModV.setVisibility(View.VISIBLE);\r
++ lastModV.setText(DisplayUtils.unixTimeToHumanReadable(lastModifiedOfAllSubdirectories));\r
++ fileSizeV.setVisibility(View.VISIBLE);\r
++ fileSizeV.setText(DisplayUtils.bytesToHumanReadable((totalSizeOfDirectoriesRecursive == null) ? 0 : totalSizeOfDirectoriesRecursive));\r
++ }\r
+ checkBoxV.setVisibility(View.GONE);\r
+ view.findViewById(R.id.imageView3).setVisibility(View.GONE);\r
+ }\r
+ }\r
+\r
+ return view;\r
+ }\r
- \r
++ \r
++ \r
++ /**\r
++ * - This method counts recursively all subdirectories and their files from the root directory. \r
++ * - It also shows a timestamp of the last modificated file inside the root directory\r
++ * \r
++ * @param OCFile : startDirectory\r
++ * @param boolean : counting starts from here ?\r
++ */\r
++ private void getDirectorySizeNumber(OCFile directory,boolean startOfRecursive) {\r
++ if (startOfRecursive) {\r
++ totalSizeOfDirectoriesRecursive = null;\r
++ }\r
++ Vector<OCFile> files = mStorageManager.getDirectoryContent(directory);\r
++ for (OCFile file : files) {\r
++ if(!file.isDirectory()) {\r
++ if (totalSizeOfDirectoriesRecursive == null) {\r
++ totalSizeOfDirectoriesRecursive = file.getFileLength();\r
++ lastModifiedOfAllSubdirectories = file.getModificationTimestamp();\r
++ continue;\r
++ }\r
++ \r
++ totalSizeOfDirectoriesRecursive += file.getFileLength();\r
++ if (lastModifiedOfAllSubdirectories < file.getModificationTimestamp()) {\r
++ lastModifiedOfAllSubdirectories = file.getModificationTimestamp();\r
++ }\r
++ }\r
++ else {\r
++ this.getDirectorySizeNumber(file, false);\r
++ }\r
++ }\r
++ }\r
++ \r
++ \r
+ @Override\r
+ public int getViewTypeCount() {\r
+ return 1;\r
+ }\r
+\r
+ @Override\r
+ public boolean hasStableIds() {\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public boolean isEmpty() {\r
+ return (mFiles == null || mFiles.isEmpty());\r
+ }\r
+\r
+ /**\r
+ * Change the adapted directory for a new one\r
+ * @param directory New file to adapt. Can be NULL, meaning "no content to adapt".\r
+ * @param updatedStorageManager Optional updated storage manager; used to replace mStorageManager if is different (and not NULL)\r
+ */\r
+ public void swapDirectory(OCFile directory, DataStorageManager updatedStorageManager) {\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.getDirectoryContent(mFile);\r
+ } else {\r
+ mFiles = null;\r
+ }\r
+ notifyDataSetChanged();\r
+ }\r
+ \r
+}\r
import java.util.ArrayList;
import java.util.List;
- import com.owncloud.android.AccountUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
+ import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.FileHandler;
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Log_OC.e(TAG, "onActivityCreated() start");
- mAdapter = new FileListListAdapter(mContainerActivity.getInitialDirectory(), mContainerActivity.getStorageManager(), getActivity(), mContainerActivity);
+ mAdapter = new FileListListAdapter(getActivity(), mContainerActivity);
setListAdapter(mAdapter);
registerForContextMenu(getListView());
if (file != null) {
if (file.isDirectory()) {
// update state and view of this fragment
- mFile = file;
listDirectory(file);
// then, notify parent activity to let it update its state and view, and other fragments
mContainerActivity.onBrowsedDownTo(file);
/**
- * Callback method invoked when the parent activity is fully created to get the directory to list firstly.
- *
- * @return Directory to list firstly. Can be NULL.
- */
- public OCFile getInitialDirectory();
-
-
- /**
* Callback method invoked when a the 'transfer state' of a file changes.
*
* This happens when a download or upload is started or ended for a file.
*/
package com.owncloud.android.ui.preview;
-import android.accounts.Account;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.view.View.OnTouchListener;
import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window;
+ import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.fragment.FileFragment;
- import com.owncloud.android.AccountUtils;
+
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
/**
- * Used as an utility to preview image files contained in an ownCloud account.
+ * Holds a swiping galley where image files contained in an ownCloud directory are shown
*
* @author David A. Velasco
*/
public static final String KEY_WAITING_TO_PREVIEW = "WAITING_TO_PREVIEW";
private static final String KEY_WAITING_FOR_BINDER = "WAITING_FOR_BINDER";
- private OCFile mFile;
- private OCFile mParentFolder;
- private Account mAccount;
private DataStorageManager mStorageManager;
private ViewPager mViewPager;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
- mAccount = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
- if (mFile == null) {
- throw new IllegalStateException("Instanced with a NULL OCFile");
- }
- if (mAccount == null) {
- throw new IllegalStateException("Instanced with a NULL ownCloud Account");
- }
- if (!mFile.isImage()) {
- throw new IllegalArgumentException("Non-image file passed as argument");
- }
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
setContentView(R.layout.preview_image_activity);
-
+
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setTitle(mFile.getFileName());
actionBar.hide();
mFullScreen = true;
-
- mStorageManager = new FileDataStorageManager(mAccount, getContentResolver());
- mParentFolder = mStorageManager.getFileById(mFile.getParentId());
- if (mParentFolder == null) {
- // should not be necessary
- mParentFolder = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);
- }
-
if (savedInstanceState != null) {
mRequestWaitingForBinder = savedInstanceState.getBoolean(KEY_WAITING_FOR_BINDER);
} else {
mRequestWaitingForBinder = false;
}
-
- createViewPager();
-
}
- private void createViewPager() {
- mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), mParentFolder, mAccount, mStorageManager);
+ private void initViewPager() {
+ OCFile parentFolder = mStorageManager.getFileById(getFile().getParentId());
+ if (parentFolder == null) {
+ // should not be necessary
+ parentFolder = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);
+ }
+ mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), parentFolder, getAccount(), mStorageManager);
mViewPager = (ViewPager) findViewById(R.id.fragmentPager);
- int position = mPreviewImagePagerAdapter.getFilePosition(mFile);
+ int position = mPreviewImagePagerAdapter.getFilePosition(getFile());
position = (position >= 0) ? position : 0;
mViewPager.setAdapter(mPreviewImagePagerAdapter);
mViewPager.setOnPageChangeListener(this);
mViewPager.setCurrentItem(position);
- if (position == 0 && !mFile.isDown()) {
+ if (position == 0 && !getFile().isDown()) {
// this is necessary because mViewPager.setCurrentItem(0) just after setting the adapter does not result in a call to #onPageSelected(0)
mRequestWaitingForBinder = true;
}
if (mDownloaderBinder == null) {
Log_OC.d(TAG, "requestForDownload called without binder to download service");
- } else if (!mDownloaderBinder.isDownloading(mAccount, file)) {
+ } else if (!mDownloaderBinder.isDownloading(getAccount(), file)) {
Intent i = new Intent(this, FileDownloader.class);
- i.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);
+ i.putExtra(FileDownloader.EXTRA_ACCOUNT, getAccount());
i.putExtra(FileDownloader.EXTRA_FILE, file);
startService(i);
}
public void onReceive(Context context, Intent intent) {
String accountName = intent.getStringExtra(FileDownloader.ACCOUNT_NAME);
String downloadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH);
- if (mAccount.name.equals(accountName) &&
+ if (getAccount().name.equals(accountName) &&
downloadedRemotePath != null) {
OCFile file = mStorageManager.getFileByPath(downloadedRemotePath);
@Override
protected void onAccountSet(boolean stateWasRecovered) {
- // TODO
+ if (getAccount() != null) {
+ OCFile file = getFile();
+ /// Validate handled file (first image to preview)
+ if (file == null) {
+ throw new IllegalStateException("Instanced with a NULL OCFile");
+ }
+ if (!file.isImage()) {
+ throw new IllegalArgumentException("Non-image file passed as argument");
+ }
+ mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
+ file = mStorageManager.getFileById(file.getFileId());
+ if (file != null) {
+ /// Refresh the activity according to the Account and OCFile set
+ setFile(file); // reset after getting it fresh from mStorageManager
+ getSupportActionBar().setTitle(getFile().getFileName());
+ //if (!stateWasRecovered) {
+ initViewPager();
+ //}
+
+ } else {
+ // handled file not in the current Account
+ finish();
+ }
+
+ } else {
+ Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
+ }
}
package com.owncloud.android.ui.preview;
import android.accounts.Account;
-import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
-import android.view.MotionEvent;
import android.widget.MediaController;
import android.widget.VideoView;
- import com.owncloud.android.AccountUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
+import com.owncloud.android.datamodel.DataStorageManager;
+import com.owncloud.android.datamodel.FileDataStorageManager;
+ import com.owncloud.android.authentication.AccountUtils;
+ import com.owncloud.android.authentication.AccountUtils.AccountNotFoundException;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.media.MediaService;
+import com.owncloud.android.ui.activity.FileActivity;
/**
* Activity implementing a basic video player.
*
* @author David A. Velasco
*/
-public class PreviewVideoActivity extends Activity implements OnCompletionListener, OnPreparedListener, OnErrorListener {
+public class PreviewVideoActivity extends FileActivity implements OnCompletionListener, OnPreparedListener, OnErrorListener {
- /** Key to receive an {@link OCFile} to play as an extra value in an {@link Intent} */
- public static final String EXTRA_FILE = "FILE";
-
- /** Key to receive the ownCloud {@link Account} where the file to play is saved as an extra value in an {@link Intent} */
- public static final String EXTRA_ACCOUNT = "ACCOUNT";
-
/** Key to receive a flag signaling if the video should be started immediately */
public static final String EXTRA_AUTOPLAY = "AUTOPLAY";
private static final String TAG = PreviewVideoActivity.class.getSimpleName();
- private OCFile mFile; // video file to play
- private Account mAccount; // ownCloud account holding mFile
+ private DataStorageManager mStorageManager;
+
private int mSavedPlaybackPosition; // in the unit time handled by MediaPlayer.getCurrentPosition()
private boolean mAutoplay; // when 'true', the playback starts immediately with the activity
private VideoView mVideoPlayer; // view to play the file; both performs and show the playback
if (savedInstanceState == null) {
Bundle extras = getIntent().getExtras();
- mFile = extras.getParcelable(EXTRA_FILE);
- mAccount = extras.getParcelable(EXTRA_ACCOUNT);
mSavedPlaybackPosition = extras.getInt(EXTRA_START_POSITION);
mAutoplay = extras.getBoolean(EXTRA_AUTOPLAY);
} else {
- mFile = savedInstanceState.getParcelable(EXTRA_FILE);
- mAccount = savedInstanceState.getParcelable(EXTRA_ACCOUNT);
mSavedPlaybackPosition = savedInstanceState.getInt(EXTRA_START_POSITION);
mAutoplay = savedInstanceState.getBoolean(EXTRA_AUTOPLAY);
}
// keep the screen on while the playback is performed (prevents screen off by battery save)
mVideoPlayer.setKeepScreenOn(true);
-
- if (mFile != null) {
- if (mFile.isDown()) {
- mVideoPlayer.setVideoPath(mFile.getStoragePath());
-
- } else if (mAccount != null) {
- // not working yet
- String url;
- try {
- url = AccountUtils.constructFullURLForAccount(this, mAccount) + mFile.getRemotePath();
- mVideoPlayer.setVideoURI(Uri.parse(url));
- } catch (AccountNotFoundException e) {
- onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_no_account);
- }
-
- } else {
- onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_no_account);
- }
-
- // create and prepare control panel for the user
- mMediaController = new MediaController(this);
- mMediaController.setMediaPlayer(mVideoPlayer);
- mMediaController.setAnchorView(mVideoPlayer);
- mVideoPlayer.setMediaController(mMediaController);
-
- } else {
- onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_nothing_to_play);
- }
}
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Log_OC.e(TAG, "ACTIVITY\t\tonSaveInstanceState");
- outState.putParcelable(PreviewVideoActivity.EXTRA_FILE, mFile);
- outState.putParcelable(PreviewVideoActivity.EXTRA_ACCOUNT, mAccount);
outState.putInt(PreviewVideoActivity.EXTRA_START_POSITION, mVideoPlayer.getCurrentPosition());
outState.putBoolean(PreviewVideoActivity.EXTRA_AUTOPLAY , mVideoPlayer.isPlaying());
}
}
- @Override
- public void onResume() {
- super.onResume();
- Log_OC.e(TAG, "ACTIVTIY\t\tonResume");
- }
-
-
- @Override
- public void onStart() {
- super.onStart();
- Log_OC.e(TAG, "ACTIVTIY\t\tonStart");
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- Log_OC.e(TAG, "ACTIVITY\t\tonDestroy");
- }
-
- @Override
- public void onStop() {
- super.onStop();
- Log_OC.e(TAG, "ACTIVTIY\t\tonStop");
- }
-
-
- @Override
- public void onPause() {
- super.onPause();
- Log_OC.e(TAG, "ACTIVTIY\t\tonPause");
- }
-
-
/**
* Called when the file is ready to be played.
*
}
- /**
- * Screen touches trigger the appearance of the control panel for a limited time.
- *
- * {@inheritDoc}
- */
@Override
- public boolean onTouchEvent (MotionEvent ev){
- /*if (ev.getAction() == MotionEvent.ACTION_DOWN) {
- if (mMediaController.isShowing()) {
- mMediaController.hide();
+ protected void onAccountSet(boolean stateWasRecovered) {
+ if (getAccount() != null) {
+ OCFile file = getFile();
+ /// Validate handled file (first image to preview)
+ if (file == null) {
+ throw new IllegalStateException("Instanced with a NULL OCFile");
+ }
+ if (!file.isVideo()) {
+ throw new IllegalArgumentException("Non-video file passed as argument");
+ }
+ mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
+ file = mStorageManager.getFileById(file.getFileId());
+ if (file != null) {
+ if (file.isDown()) {
+ mVideoPlayer.setVideoPath(file.getStoragePath());
+
+ } else {
- // not working now
- String url = AccountUtils.constructFullURLForAccount(this, getAccount()) + file.getRemotePath();
- mVideoPlayer.setVideoURI(Uri.parse(url));
++ // not working yet
++ String url;
++ try {
++ url = AccountUtils.constructFullURLForAccount(this, getAccount()) + file.getRemotePath();
++ mVideoPlayer.setVideoURI(Uri.parse(url));
++ } catch (AccountNotFoundException e) {
++ onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_no_account);
++ }
+ }
+
+ // create and prepare control panel for the user
+ mMediaController = new MediaController(this);
+ mMediaController.setMediaPlayer(mVideoPlayer);
+ mMediaController.setAnchorView(mVideoPlayer);
+ mVideoPlayer.setMediaController(mMediaController);
+
} else {
- mMediaController.show(MediaService.MEDIA_CONTROL_SHORT_LIFE);
+ finish();
}
- return true;
} else {
- return false;
- }*/
- return false;
- }
+ Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
+ finish();
+ }
+ }
}