Skip to content

Commit 1713380

Browse files
committed
Intent works with folders and files (WIP)
1 parent 186857f commit 1713380

File tree

4 files changed

+43
-13
lines changed

4 files changed

+43
-13
lines changed

owncloudApp/src/main/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@
9393
android:host="@string/url_link_host"
9494
android:pathPrefix="/f/"
9595
android:scheme="https" />
96+
97+
<data
98+
android:host="@string/url_link_host"
99+
android:pathPrefix="/f/"
100+
android:scheme="http" />
96101
</intent-filter>
97102
</activity>
98103
<activity android:name=".ui.activity.ManageAccountsActivity" />

owncloudApp/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,7 @@ class FileDataStorageManager {
11131113
isDownloading = it.getIntFromColumnOrThrow(FILE_IS_DOWNLOADING) == 1
11141114
etagInConflict = it.getStringFromColumnOrThrow(FILE_ETAG_IN_CONFLICT)
11151115
privateLink = it.getStringFromColumnOrThrow(FILE_PRIVATE_LINK)
1116+
owner = it.getStringFromColumnOrThrow(FILE_ACCOUNT_OWNER)
11161117
}
11171118
}
11181119

owncloudApp/src/main/java/com/owncloud/android/datamodel/OCFile.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public static AvailableOfflineStatus fromValue(int value) {
116116
private boolean mSharedByLink;
117117
private boolean mSharedWithSharee;
118118
private String mPrivateLink;
119+
private String mOwner;
119120

120121
/**
121122
* URI to the local path of the file contents, if stored in the device; cached after first call
@@ -125,15 +126,15 @@ public static AvailableOfflineStatus fromValue(int value) {
125126

126127
/**
127128
* Exportable URI to the local path of the file contents, if stored in the device.
128-
*
129+
* <p>
129130
* Cached after first call, until changed.
130131
*/
131132
private Uri mExposedFileUri;
132133
public static final String PRIVATE_LINK_PATH = "/index.php/f/";
133134

134135
/**
135136
* Create new {@link OCFile} with given path.
136-
*
137+
* <p>
137138
* The path received must be URL-decoded. Path separator must be File.separator, and it must be the first
138139
* character in 'path'.
139140
*
@@ -179,6 +180,7 @@ private OCFile(Parcel source) {
179180
mEtagInConflict = source.readString();
180181
mSharedWithSharee = source.readInt() == 1;
181182
mPrivateLink = source.readString();
183+
mOwner = source.readString();
182184

183185
}
184186

@@ -206,6 +208,7 @@ public void writeToParcel(Parcel dest, int flags) {
206208
dest.writeString(mEtagInConflict);
207209
dest.writeInt(mSharedWithSharee ? 1 : 0);
208210
dest.writeString(mPrivateLink);
211+
dest.writeString(mOwner);
209212
}
210213

211214
/**
@@ -352,7 +355,7 @@ public long getModificationTimestamp() {
352355

353356
/**
354357
* Set a UNIX timestamp of the time the time the file was modified.
355-
*
358+
* <p>
356359
* To update with the value returned by the server in every synchronization of the properties
357360
* of this file.
358361
*
@@ -374,7 +377,7 @@ public long getModificationTimestampAtLastSyncForData() {
374377

375378
/**
376379
* Set a UNIX timestamp of the time the time the file was modified.
377-
*
380+
* <p>
378381
* To update with the value returned by the server in every synchronization of THE CONTENTS
379382
* of this file.
380383
*
@@ -396,7 +399,7 @@ public String getFileName() {
396399

397400
/**
398401
* Sets the name of the file
399-
*
402+
* <p>
400403
* Does nothing if the new name is null, empty or includes "/" ; or if the file is the root
401404
* directory
402405
*/
@@ -507,6 +510,7 @@ public long getParentId() {
507510

508511
/**
509512
* get remote path of parent file
513+
*
510514
* @return remote path
511515
*/
512516
public String getParentRemotePath() {
@@ -547,7 +551,7 @@ public AvailableOfflineStatus getAvailableOfflineStatus() {
547551
}
548552

549553
/**
550-
* @return 'True' when
554+
* @return 'True' when
551555
*/
552556
public boolean isAvailableOffline() {
553557
return (mAvailableOfflineStatus != AvailableOfflineStatus.NOT_AVAILABLE_OFFLINE);
@@ -651,8 +655,8 @@ public boolean isText() {
651655
}
652656

653657
/**
654-
* @param type Type to match in the file MIME type; it's MUST include the trailing "/"
655-
* @return 'True' if the file MIME type matches the received parameter in the type part.
658+
* @param type Type to match in the file MIME type; it's MUST include the trailing "/"
659+
* @return 'True' if the file MIME type matches the received parameter in the type part.
656660
*/
657661
private boolean isOfType(String type) {
658662
return (
@@ -750,4 +754,12 @@ public void copyLocalPropertiesFrom(OCFile sourceFile) {
750754
setTreeEtag(sourceFile.getTreeEtag());
751755
setEtagInConflict(sourceFile.getEtagInConflict());
752756
}
757+
758+
public String getOwner() {
759+
return mOwner;
760+
}
761+
762+
public void setOwner(String owner) {
763+
mOwner = (owner == null) ? "" : owner;
764+
}
753765
}

owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,13 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn
223223
override fun onPostCreate(savedInstanceState: Bundle?) {
224224
super.onPostCreate(savedInstanceState)
225225

226-
val dataIntent: Uri? = intent.data
227-
manageDataIntent(dataIntent)
228-
229226
if (savedInstanceState == null) {
230227
createMinFragments()
231228
}
232229

230+
val dataIntent: Uri? = intent.data
231+
manageDataIntent(dataIntent)
232+
233233
setBackgroundText()
234234
}
235235

@@ -299,7 +299,7 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn
299299
private fun initFragmentsWithFile() {
300300
if (account != null && file != null) {
301301
/// First fragment
302-
listOfFilesFragment?.listDirectory(currentDir)
302+
listOfFilesFragment?.listDirectory(file)
303303
?: Timber.e("Still have a chance to lose the initialization of list fragment >(")
304304

305305
/// Second fragment
@@ -420,7 +420,12 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn
420420

421421
fun refreshListOfFilesFragment(reloadData: Boolean) {
422422
val fileListFragment = listOfFilesFragment
423-
fileListFragment?.listDirectory(reloadData)
423+
if (intent.data == null) {
424+
fileListFragment?.listDirectory(reloadData)
425+
} else {
426+
fileListFragment?.listDirectory(isFileDiscovered(intent.data))
427+
}
428+
424429
}
425430

426431
override fun onCreateOptionsMenu(menu: Menu): Boolean {
@@ -1658,6 +1663,7 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn
16581663
} else if (uri != null) {
16591664
isFileDiscovered(uri).let { OCFile ->
16601665
if (OCFile != null) {
1666+
openFile(OCFile)
16611667
} else {
16621668
showMessageInToast(getString(R.string.no_file_found))
16631669
}
@@ -1667,6 +1673,12 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn
16671673

16681674
private fun isFileDiscovered(uri: Uri?): OCFile? = storageManager.getFileByPrivateLink(uri.toString())
16691675

1676+
private fun openFile(file: OCFile) {
1677+
setFile(file)
1678+
setAccount(AccountUtils.getOwnCloudAccountByName(this, file.owner))
1679+
initFragmentsWithFile()
1680+
}
1681+
16701682
companion object {
16711683
private const val TAG_LIST_OF_FILES = "LIST_OF_FILES"
16721684
private const val TAG_SECOND_FRAGMENT = "SECOND_FRAGMENT"

0 commit comments

Comments
 (0)