* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* 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.
* 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.
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.operations.CreateShareOperation;
import com.owncloud.android.operations.RemoveFileOperation;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.operations.CreateShareOperation;
import com.owncloud.android.operations.RemoveFileOperation;
import com.owncloud.android.operations.UnshareLinkOperation;
import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.operations.UnshareLinkOperation;
import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.FileDisplayActivity;
-public class PreviewImageActivity extends FileActivity implements
- FileFragment.ContainerActivity,
-ViewPager.OnPageChangeListener, OnRemoteOperationListener {
+public class PreviewImageActivity extends FileActivity implements
+ FileFragment.ContainerActivity,
+ ViewPager.OnPageChangeListener, OnRemoteOperationListener {
mFullScreenAnchorView = getWindow().getDecorView();
// to keep our UI controls visibility in line with system bars
// visibility
mFullScreenAnchorView = getWindow().getDecorView();
// to keep our UI controls visibility in line with system bars
// visibility
- String parentPath = getFile().getRemotePath().substring(0, getFile().getRemotePath().lastIndexOf(getFile().getFileName()));
+ String parentPath = getFile().getRemotePath().substring(0,
+ getFile().getRemotePath().lastIndexOf(getFile().getFileName()));
OCFile parentFolder = getStorageManager().getFileByPath(parentPath);
if (parentFolder == null) {
// should not be necessary
parentFolder = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
}
OCFile parentFolder = getStorageManager().getFileByPath(parentPath);
if (parentFolder == null) {
// should not be necessary
parentFolder = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
}
- mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), parentFolder, getAccount(), getStorageManager());
+
+ mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(),
+ parentFolder, getAccount(), getStorageManager(), MainApp.getOnlyOnDevice());
+
position = (position >= 0) ? position : 0;
mViewPager.setAdapter(mPreviewImagePagerAdapter);
mViewPager.setOnPageChangeListener(this);
mViewPager.setCurrentItem(position);
if (position == 0 && !getFile().isDown()) {
position = (position >= 0) ? position : 0;
mViewPager.setAdapter(mPreviewImagePagerAdapter);
mViewPager.setOnPageChangeListener(this);
mViewPager.setCurrentItem(position);
if (position == 0 && !getFile().isDown()) {
- private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) {
+ private void onUnshareLinkOperationFinish(UnshareLinkOperation operation,
+ RemoteOperationResult result) {
if (result.isSuccess()) {
OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath());
if (file != null) {
if (result.isSuccess()) {
OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath());
if (file != null) {
- private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) {
+ private void onCreateShareOperationFinish(CreateShareOperation operation,
+ RemoteOperationResult result) {
if (result.isSuccess()) {
OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath());
if (file != null) {
if (result.isSuccess()) {
OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath());
if (file != null) {
+ private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation,
+ RemoteOperationResult result) {
+ if (result.isSuccess()) {
+ invalidateOptionsMenu();
+ }
+
+ }
+
@Override
protected ServiceConnection newTransferenceServiceConnection() {
return new PreviewImageServiceConnection();
@Override
protected ServiceConnection newTransferenceServiceConnection() {
return new PreviewImageServiceConnection();
mDownloaderBinder = (FileDownloaderBinder) service;
if (mRequestWaitingForBinder) {
mRequestWaitingForBinder = false;
mDownloaderBinder = (FileDownloaderBinder) service;
if (mRequestWaitingForBinder) {
mRequestWaitingForBinder = false;
Log_OC.d(TAG, "Upload service connected");
mUploaderBinder = (FileUploaderBinder) service;
} else {
Log_OC.d(TAG, "Upload service connected");
mUploaderBinder = (FileUploaderBinder) service;
} else {
Log_OC.d(TAG, "Download service suddenly disconnected");
mDownloaderBinder = null;
Log_OC.d(TAG, "Download service suddenly disconnected");
mDownloaderBinder = null;
Intent showDetailsIntent = new Intent(this, FileDisplayActivity.class);
showDetailsIntent.setAction(FileDisplayActivity.ACTION_DETAILS);
showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, file);
Intent showDetailsIntent = new Intent(this, FileDisplayActivity.class);
showDetailsIntent.setAction(FileDisplayActivity.ACTION_DETAILS);
showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, file);
- showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this));
+ showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT,
+ AccountUtils.getCurrentOwnCloudAccount(this));
startActivity(showDetailsIntent);
int pos = mPreviewImagePagerAdapter.getFilePosition(file);
file = mPreviewImagePagerAdapter.getFileAt(pos);
startActivity(showDetailsIntent);
int pos = mPreviewImagePagerAdapter.getFilePosition(file);
file = mPreviewImagePagerAdapter.getFileAt(pos);
} else {
OCFile currentFile = mPreviewImagePagerAdapter.getFileAt(position);
getSupportActionBar().setTitle(currentFile.getFileName());
} else {
OCFile currentFile = mPreviewImagePagerAdapter.getFileAt(position);
getSupportActionBar().setTitle(currentFile.getFileName());
if (!currentFile.isDown()) {
if (!mPreviewImagePagerAdapter.pendingErrorAt(position)) {
requestForDownload(currentFile);
if (!currentFile.isDown()) {
if (!mPreviewImagePagerAdapter.pendingErrorAt(position)) {
requestForDownload(currentFile);
* Called when the scroll state changes. Useful for discovering when the user begins dragging,
* when the pager is automatically settling to the current page. when it is fully stopped/idle.
*
* Called when the scroll state changes. Useful for discovering when the user begins dragging,
* when the pager is automatically settling to the current page. when it is fully stopped/idle.
*
- * This method will be invoked when the current page is scrolled, either as part of a programmatically
- * initiated smooth scroll or a user initiated touch scroll.
+ * This method will be invoked when the current page is scrolled, either as part of a
+ * programmatically initiated smooth scroll or a user initiated touch scroll.
OCFile file = getStorageManager().getFileByPath(downloadedRemotePath);
int position = mPreviewImagePagerAdapter.getFilePosition(file);
OCFile file = getStorageManager().getFileByPath(downloadedRemotePath);
int position = mPreviewImagePagerAdapter.getFilePosition(file);
- boolean downloadWasFine = intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false);
- //boolean isOffscreen = Math.abs((mViewPager.getCurrentItem() - position)) <= mViewPager.getOffscreenPageLimit();
+ boolean downloadWasFine = intent.getBooleanExtra(
+ FileDownloader.EXTRA_DOWNLOAD_RESULT, false);
+ //boolean isOffscreen = Math.abs((mViewPager.getCurrentItem() - position))
+ // <= mViewPager.getOffscreenPageLimit();
if (downloadWasFine) {
mPreviewImagePagerAdapter.updateFile(position, file);
} else {
mPreviewImagePagerAdapter.updateWithDownloadError(position);
}
if (downloadWasFine) {
mPreviewImagePagerAdapter.updateFile(position, file);
} else {
mPreviewImagePagerAdapter.updateWithDownloadError(position);
}