Skip to content

Commit

Permalink
CR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
fesave committed Apr 6, 2022
1 parent 818f74f commit ad15940
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions owncloudApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="@string/url_link_host"
android:host="@string/deep_link_host"
android:pathPrefix="/f/"
android:scheme="https" />

<data
android:host="@string/url_link_host"
android:host="@string/deep_link_host"
android:pathPrefix="/f/"
android:scheme="http" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class FileActivity extends DrawerActivity
public static final String EXTRA_ACCOUNT = "com.owncloud.android.ui.activity.ACCOUNT";
public static final String EXTRA_FROM_NOTIFICATION =
"com.owncloud.android.ui.activity.FROM_NOTIFICATION";
public static final String ALREADY_HANDLED_DEEP_LINK =
public static final String EXTRA_ALREADY_HANDLED_DEEP_LINK =
"com.owncloud.android.ui.activity.ALREADY_HANDLED_DEEP_LINK";
public static final String EXTRA_FILE_LIST_OPTION = "EXTRA_FILE_LIST_OPTION";

Expand Down Expand Up @@ -135,7 +135,7 @@ protected void onCreate(Bundle savedInstanceState) {
if (savedInstanceState != null) {
mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION);
mAlreadyHandledDeepLink = savedInstanceState.getBoolean(FileActivity.ALREADY_HANDLED_DEEP_LINK);
mAlreadyHandledDeepLink = savedInstanceState.getBoolean(FileActivity.EXTRA_ALREADY_HANDLED_DEEP_LINK);
mFileOperationsHelper.setOpIdWaitingFor(
savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE)
);
Expand Down Expand Up @@ -219,7 +219,7 @@ protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(FileActivity.EXTRA_FILE, mFile);
outState.putBoolean(FileActivity.EXTRA_FROM_NOTIFICATION, mFromNotification);
outState.putBoolean(FileActivity.ALREADY_HANDLED_DEEP_LINK, mAlreadyHandledDeepLink);
outState.putBoolean(FileActivity.EXTRA_ALREADY_HANDLED_DEEP_LINK, mAlreadyHandledDeepLink);
outState.putLong(KEY_WAITING_FOR_OP_ID, mFileOperationsHelper.getOpIdWaitingFor());
if (getSupportActionBar() != null && getSupportActionBar().getTitle() != null) {
// Null check in case the actionbar is used in ActionBar.NAVIGATION_MODE_LIST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.extensions.checkPasscodeEnforced
import com.owncloud.android.extensions.manageOptionLockSelected
import com.owncloud.android.extensions.showMessageInSnackbar
import com.owncloud.android.extensions.showMessageInToast
import com.owncloud.android.files.services.FileDownloader
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder
import com.owncloud.android.files.services.FileUploader
Expand Down Expand Up @@ -228,7 +227,9 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn
}

val dataIntent: Uri? = intent.data
manageDataIntent(dataIntent)
dataIntent?.let {
handleDeepLink(dataIntent)
}

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

/// Second fragment
Expand Down Expand Up @@ -423,7 +424,7 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn
if (intent.data == null || isAlreadyHandledDeepLink) {
fileListFragment?.listDirectory(reloadData)
} else {
fileListFragment?.listDirectory(isFileDiscovered(intent.data))
fileListFragment?.listDirectory(getFileDiscovered(intent.data))
}

}
Expand Down Expand Up @@ -1657,21 +1658,21 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn
manageOptionLockSelected(type)
}

private fun manageDataIntent(uri: Uri?) {
private fun handleDeepLink(uri: Uri?) {
if (uri != null && AccountUtils.getAccounts(applicationContext).isEmpty()) {
showMessageInToast(getString(R.string.no_account_configured))
showMessageInSnackbar(message = getString(R.string.no_account_configured))
} else if (uri != null && AccountUtils.getAccounts(applicationContext).size == 1) {
isFileDiscovered(uri).let { OCFile ->
if (OCFile != null) {
manageItem(OCFile)
getFileDiscovered(uri).let { oCFile ->
if (oCFile != null) {
manageItem(oCFile)
} else {
showMessageInToast(getString(R.string.no_file_found))
showMessageInSnackbar(message = getString(R.string.no_file_found))
}
}
}
}

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

private fun manageItem(file: OCFile) {
onBrowsedDownTo(file)
Expand Down
2 changes: 1 addition & 1 deletion owncloudApp/src/main/res/values/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@
<bool name="clear_cookies_on_validation">false</bool>

<!--Deep Links -->
<string name="url_link_host">*</string>
<string name="deep_link_host">*</string>

</resources>

0 comments on commit ad15940

Please sign in to comment.