Skip to content

Commit

Permalink
Prevented image files from being previewed when a security method is …
Browse files Browse the repository at this point in the history
…configured.
  • Loading branch information
fesave committed Apr 21, 2022
1 parent 5de88b7 commit 7b5a4a5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
13 changes: 10 additions & 3 deletions owncloudApp/src/main/java/com/owncloud/android/MainApp.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
/**
* ownCloud Android client application
*
* @author masensio
* @author David A. Velasco
* @author David González Verdugo
* @author Christian Schabesberger
* @author David Crespo Ríos
* Copyright (C) 2020 ownCloud GmbH.
* @author Fernando Sanz Velasco
* Copyright (C) 2022 ownCloud GmbH.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
Expand Down Expand Up @@ -46,6 +47,7 @@ import com.owncloud.android.lib.common.OwnCloudClient
import com.owncloud.android.lib.common.SingleSessionManager
import com.owncloud.android.presentation.ui.authentication.LoginActivity
import com.owncloud.android.presentation.ui.migration.StorageMigrationActivity
import com.owncloud.android.presentation.ui.releasenotes.ReleaseNotesActivity
import com.owncloud.android.presentation.ui.security.BiometricActivity
import com.owncloud.android.presentation.ui.security.BiometricManager
import com.owncloud.android.presentation.ui.security.LockTimeout
Expand All @@ -58,8 +60,8 @@ import com.owncloud.android.presentation.ui.settings.fragments.SettingsLogsFragm
import com.owncloud.android.providers.LogsProvider
import com.owncloud.android.ui.activity.FileDisplayActivity
import com.owncloud.android.ui.activity.SplashActivity
import com.owncloud.android.presentation.ui.releasenotes.ReleaseNotesActivity
import com.owncloud.android.ui.activity.WhatsNewActivity
import com.owncloud.android.ui.preview.PreviewImageActivity
import com.owncloud.android.utils.DOWNLOAD_NOTIFICATION_CHANNEL_ID
import com.owncloud.android.utils.DebugInjector
import com.owncloud.android.utils.FILE_SYNC_CONFLICT_CHANNEL_ID
Expand Down Expand Up @@ -126,6 +128,11 @@ class MainApp : Application() {

override fun onActivityStarted(activity: Activity) {
Timber.v("${activity.javaClass.simpleName} onStart() starting")

if (activity is PreviewImageActivity && activity.isFromDeepLink) {
activity.finish()
}

if (activity is SplashActivity ||
activity is FileDisplayActivity ||
activity is LoginActivity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class FileActivity extends DrawerActivity

public static final String EXTRA_FILE = "com.owncloud.android.ui.activity.FILE";
public static final String EXTRA_ACCOUNT = "com.owncloud.android.ui.activity.ACCOUNT";
public static final String EXTRA_DEEP_LINK= "com.owncloud.android.ui.activity.DEEP_LINK";
public static final String EXTRA_FROM_NOTIFICATION =
"com.owncloud.android.ui.activity.FROM_NOTIFICATION";
public static final String EXTRA_ALREADY_HANDLED_DEEP_LINK =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
* @author Christian Schabesberger
* @author Shashvat Kedia
* @author Abel García de Prada
* @author Fernando Sanz Velasco
* Copyright (C) 2011 Bartek Przybylski
* Copyright (C) 2020 ownCloud GmbH.
* Copyright (C) 2022 ownCloud GmbH.
*
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -1489,10 +1490,11 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn
*
* @param file Image [OCFile] to show.
*/
fun startImagePreview(file: OCFile) {
fun startImagePreview(file: OCFile, isFromDeepLink: Boolean = false) {
val showDetailsIntent = Intent(this, PreviewImageActivity::class.java)
showDetailsIntent.putExtra(EXTRA_FILE, file)
showDetailsIntent.putExtra(EXTRA_ACCOUNT, account)
showDetailsIntent.putExtra(EXTRA_DEEP_LINK, isFromDeepLink)
startActivity(showDetailsIntent)

}
Expand Down Expand Up @@ -1685,7 +1687,7 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn
}

if (PreviewImageFragment.canBePreviewed(file)) {
startImagePreview(file)
startImagePreview(file, isFromDeepLink = true)
} else {
initFragmentsWithFile()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ public void onItemClick(AdapterView<?> l, View v, int position, long id) {
} else { /// Click on a file
if (PreviewImageFragment.canBePreviewed(file)) {
// preview image - it handles the sync, if needed
((FileDisplayActivity) mContainerActivity).startImagePreview(file);
((FileDisplayActivity) mContainerActivity).startImagePreview(file, false);
} else if (PreviewTextFragment.canBePreviewed(file)) {
((FileDisplayActivity) mContainerActivity).startTextPreview(file);
mContainerActivity.getFileOperationsHelper().syncFile(file);
Expand Down Expand Up @@ -1269,7 +1269,7 @@ private void showSnackMessage(int messageResource) {
snackbar.show();
}

public void setSearchListener(SearchView searchView){
public void setSearchListener(SearchView searchView) {
searchView.setOnQueryTextFocusChangeListener(this);
searchView.setOnQueryTextListener(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
* @author David A. Velasco
* @author David González Verdugo
* @author Christian Schabesberger
* Copyright (C) 2020 ownCloud GmbH.
* <p>
* @author Fernando Sanz Velasco
* Copyright (C) 2022 ownCloud GmbH.
*
* 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.
* <p>
*
* This program is distributed in the hd 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.
* <p>
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Expand Down Expand Up @@ -501,4 +502,7 @@ private void updateActionBarTitle(String title) {
}
}

}
public Boolean isFromDeepLink() {
return getIntent().getBooleanExtra(EXTRA_DEEP_LINK, false);
}
}

0 comments on commit 7b5a4a5

Please sign in to comment.