android:layout_height="match_parent"
android:background="@color/background_color"
android:gravity="center"
- tools:context=".ui.fragment.FilePreviewFragment" >
+ tools:context=".ui.fragment.FilePreviewFragment">
- <FrameLayout
+ <FrameLayout
android:id="@+id/visual_area"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_alignParentTop="true"
- android:layout_above="@+id/media_controller">
-
- <ImageView
- android:id="@+id/image_preview"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_margin="16dp"
- android:layout_gravity="center"
- android:contentDescription="@string/preview_image_description"
- android:src="@drawable/logo" />
-
- <VideoView
- android:id="@+id/video_preview"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:visibility="gone" />
-
- </FrameLayout>
-
- <com.owncloud.android.media.MediaControlView
- android:id="@id/media_controller"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true" />
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_alignParentTop="true"
+ android:layout_above="@+id/media_controller"
+ >
+
+ <ImageView
+ android:id="@+id/image_preview"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_margin="16dp"
+ android:layout_gravity="center"
+ android:contentDescription="@string/preview_image_description"
+ android:src="@drawable/logo" />
+
+ <VideoView
+ android:id="@+id/video_preview"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:visibility="gone"
+ />
+
+ </FrameLayout>
+
+ <com.owncloud.android.media.MediaControlView
+ android:id="@id/media_controller"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_margin="16dp"
+ />
</RelativeLayout>
*/
public boolean isImage() {
return ((mMimeType != null && mMimeType.startsWith("image/")) ||
- FileStorageUtils.getMimeTypeFromName(mRemotePath).startsWith("image/"));
+ getMimeTypeFromName().startsWith("image/"));
+ }
+
+ /**
+ * @return 'True' if the file is simple text (e.g. not application-dependent, like .doc or .docx)
+ */
+ public boolean isText() {
+ return ((mMimeType != null && mMimeType.startsWith("text/")) ||
+ getMimeTypeFromName().startsWith("text/"));
+ }
+
+ public String getMimeTypeFromName() {
+ String extension = "";
+ int pos = mRemotePath.lastIndexOf('.');
+ if (pos >= 0) {
+ extension = mRemotePath.substring(pos + 1);
+ }
+ String result = MimeTypeMap.getSingleton().
+ getMimeTypeFromExtension(extension.toLowerCase());
+ return (result != null) ? result : "";
}
+ /**
+ * @return 'True' if the file is hidden
+ */
+ public boolean isHidden() {
+ return getFileName().startsWith(".");
+ }
+
public String getPermissions() {
return mPermissions;
}
import java.io.File;
- import java.io.IOException;
-
-
--
/**
* Displays, what files the user has available in his ownCloud.
*/
// according to the official
// documentation
- setSupportProgressBarIndeterminateVisibility(mSyncInProgress
- /*|| mRefreshSharesInProgress*/);
+ // enable ActionBar app icon to behave as action to toggle nav drawer
+ //getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setHomeButtonEnabled(true);
+
+ mProgressBar.setIndeterminate(mSyncInProgress);
// always AFTER setContentView(...) ; to work around bug in its implementation
-
+
setBackgroundText();
Log_OC.v(TAG, "onCreate() end");
}
removeStickyBroadcast(intent);
Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
- setSupportProgressBarIndeterminateVisibility(mSyncInProgress
- /*|| mRefreshSharesInProgress*/);
+ mProgressBar.setIndeterminate(mSyncInProgress);
+ //mProgressBar.setVisibility((mSyncInProgress) ? View.VISIBLE : View.INVISIBLE);
+ //setSupportProgressBarIndeterminateVisibility(mSyncInProgress
+ /*|| mRefreshSharesInProgress*/ //);
setBackgroundText();
-
+
}
-
+
if (synchResult != null) {
if (synchResult.getCode().equals(
RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) {
} else {
cleanSecondFragment();
}
-
- // Force the preview if the file is an image
- if (uploadWasFine && PreviewImageFragment.canBePreviewed(getFile())) {
- startImagePreview(getFile());
- } // TODO what about other kind of previews?
+
+ // Force the preview if the file is an image or text file
+ if (uploadWasFine) {
+ OCFile ocFile = getFile();
+ if (PreviewImageFragment.canBePreviewed(ocFile))
+ startImagePreview(getFile());
+ else if (PreviewTextFragment.canBePreviewed(ocFile))
+ startTextPreview(ocFile);
+ // TODO what about other kind of previews?
+ }
}
+ mProgressBar.setIndeterminate(false);
} finally {
if (intent != null) {
removeStickyBroadcast(intent);
getApplicationContext()
);
synchFolderOp.execute(getAccount(), MainApp.getAppContext(), this, null, null);
- setSupportProgressBarIndeterminateVisibility(true);
+
+ mProgressBar.setIndeterminate(true);
setBackgroundText();
}
import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
import com.owncloud.android.ui.preview.PreviewImageFragment;
import com.owncloud.android.ui.preview.PreviewMediaFragment;
+ import com.owncloud.android.utils.DialogMenuItem;
import com.owncloud.android.utils.FileStorageUtils;
+import com.owncloud.android.ui.preview.PreviewTextFragment;
/**
* A Fragment that lists all files and folders in a given path.