Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
4a5718a
Added text file preview
stoyicker Oct 17, 2014
5795ad3
Reworked the text file preview system to avoid UI freezes with large …
stoyicker Oct 18, 2014
cbf2f96
Fixed a mistake.
stoyicker Oct 19, 2014
bc7bfee
Removed any remains of list appearance
stoyicker Oct 19, 2014
4e6abd4
Minor updates
stoyicker Oct 25, 2014
7644f0b
Fixed line breaks
stoyicker Oct 25, 2014
554cd33
Added Java 1.5 restriction to match the application standards
stoyicker Oct 25, 2014
2b9176a
Added some margins.
stoyicker Oct 25, 2014
96232b1
Removed unnecessary actions
stoyicker Oct 25, 2014
7414d16
Solved 'Share with copied link' flow
stoyicker Oct 26, 2014
afefef9
Reverted the text preview system to a single TextView
stoyicker Oct 26, 2014
46ff60a
Fixed a bug that would cause the details view to be shown upon turnin…
stoyicker Oct 26, 2014
7cc88a2
Added text file preview
stoyicker Oct 17, 2014
ec9f1c7
Reworked the text file preview system to avoid UI freezes with large …
stoyicker Oct 18, 2014
fac3332
Fixed a mistake.
stoyicker Oct 19, 2014
65e82bf
Removed any remains of list appearance
stoyicker Oct 19, 2014
3877ddf
Minor updates
stoyicker Oct 25, 2014
1629981
Fixed line breaks
stoyicker Oct 25, 2014
c9105c6
Added Java 1.5 restriction to match the application standards
stoyicker Oct 25, 2014
0c38416
Added some margins.
stoyicker Oct 25, 2014
5aa4d0e
Removed unnecessary actions
stoyicker Oct 25, 2014
9bdb2cd
Solved 'Share with copied link' flow
stoyicker Oct 26, 2014
093bf4f
Reverted the text preview system to a single TextView
stoyicker Oct 26, 2014
b1ef5d9
Fixed a bug that would cause the details view to be shown upon turnin…
stoyicker Oct 26, 2014
073e7e4
Merge branch 'us4_view_text_files' of github.com:owncloudChalmers/and…
stoyicker Oct 28, 2014
244758e
Update Gradle plugin to 0.14 for compatibility with Android Studio 0.9.0
stoyicker Nov 4, 2014
f202094
Track right branch
stoyicker Nov 4, 2014
1c5416e
Cleanup
stoyicker Nov 4, 2014
da27021
Merge remote-tracking branch 'origin/gradleWithInternalDependency' in…
stoyicker Nov 17, 2014
10a12fb
Merge branch 'gradleWithInternalDependency' into us4_view_text_files
stoyicker Nov 24, 2014
45fd60d
Merge remote-tracking branch 'origin/gradleWithInternalDependency' in…
stoyicker Nov 25, 2014
d5566ce
Merge remote-tracking branch 'upstream/develop' into us4_view_text_files
stoyicker Nov 29, 2014
49e8daf
Merge remote-tracking branch 'upstream/develop' into us4_view_text_files
stoyicker Dec 3, 2014
6cc3917
Update submodule
stoyicker Dec 3, 2014
9a2f6c6
Support margins for API levels pre-17
stoyicker Jun 24, 2015
4c17d77
Added braces to single-line if statements
stoyicker Jun 24, 2015
1508e99
Added exception logging
stoyicker Jun 24, 2015
cc0627d
Implementation of the requested changes to the asynctask that loads t…
stoyicker Jun 24, 2015
efbab82
Moved text load call to onStart
stoyicker Jun 25, 2015
b694fee
Merge commit 'refs/pr/707' into text_file_preview_pr_707_with
Aug 5, 2015
d1257b3
Fix problems in PreviewTextFragment related with changes in develop
Aug 5, 2015
fafc422
Fix Java version to 1.7
Aug 5, 2015
be5dbcb
fixed bug caused by rotating the device
tobiasKaminsky Aug 13, 2015
ae0e116
Fixes the text preview issue
stoyicker Aug 19, 2015
a070742
Merge remote-tracking branch 'origin/master' into text_file_preview_p…
Sep 2, 2015
6b84d83
Merge branch 'text_file_preview_pr_707_with_develop' of github.com:ow…
Sep 2, 2015
fc5c4d8
Merge branch 'master' into text_file_preview_pr_707_with_develop
Sep 4, 2015
68ce6e6
Reverse filter for preview of text files: all text/ but those in blac…
davivel Sep 4, 2015
3f40da0
Fixed text preview filter to take into account local knowledge about …
davivel Sep 7, 2015
1586eea
Merge branch 'master' into text_file_preview_pr_707_with_develop
Sep 7, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions res/layout/file_preview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
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"
Expand Down
33 changes: 33 additions & 0 deletions res/layout/text_file_preview.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?><!--
ownCloud Android client application

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 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/>.

-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">

<TextView
android:id="@+id/text_preview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:visibility="gone"/>
</ScrollView>
38 changes: 31 additions & 7 deletions src/com/owncloud/android/datamodel/OCFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

import android.os.Parcel;
import android.os.Parcelable;
import android.webkit.MimeTypeMap;

import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.utils.FileStorageUtils;

import java.io.File;

Expand Down Expand Up @@ -289,11 +289,13 @@ public String getFileName() {
/**
* Sets the name of the file
* <p/>
* Does nothing if the new name is null, empty or includes "/" ; or if the file is the root directory
* Does nothing if the new name is null, empty or includes "/" ; or if the file is the root
* directory
*/
public void setFileName(String name) {
Log_OC.d(TAG, "OCFile name changin from " + mRemotePath);
if (name != null && name.length() > 0 && !name.contains(PATH_SEPARATOR) && !mRemotePath.equals(ROOT_PATH)) {
if (name != null && name.length() > 0 && !name.contains(PATH_SEPARATOR) &&
!mRemotePath.equals(ROOT_PATH)) {
String parent = (new File(getRemotePath())).getParent();
parent = (parent.endsWith(PATH_SEPARATOR)) ? parent : parent + PATH_SEPARATOR;
mRemotePath = parent + name;
Expand Down Expand Up @@ -454,7 +456,7 @@ public boolean isFavorite() {

@Override
public int describeContents() {
return ((Object) this).hashCode();
return super.hashCode();
}

@Override
Expand Down Expand Up @@ -483,8 +485,11 @@ public boolean equals(Object o) {

@Override
public String toString() {
String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s, parentId=%s, favorite=%s etag=%s]";
asString = String.format(asString, Long.valueOf(mId), getFileName(), mMimeType, isDown(), mLocalPath, mRemotePath, Long.valueOf(mParentId), Boolean.valueOf(mFavorite), mEtag);
String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s, " +
"parentId=%s, favorite=%s etag=%s]";
asString = String.format(asString, Long.valueOf(mId), getFileName(), mMimeType, isDown(),
mLocalPath, mRemotePath, Long.valueOf(mParentId), Boolean.valueOf(mFavorite),
mEtag);
return asString;
}

Expand Down Expand Up @@ -540,7 +545,26 @@ public boolean isVideo() {
*/
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 : "";
}

/**
Expand Down
Loading