Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gplay: do not allow to download APK/AAB #13258

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,15 @@ public List<OCFile> getAllFilesRecursivelyInsideFolder(OCFile file) {
}

if (!file.isFolder()) {
result.add(file);
if (!file.isAPKorAAB()) {
result.add(file);
}
return result;
}

List<OCFile> filesInsideFolder = getFolderContent(file.getFileId(), false);
for (OCFile item: filesInsideFolder) {
if (!item.isFolder()) {
if (!item.isFolder() && !item.isAPKorAAB()) {
result.add(item);
} else {
result.addAll(getAllFilesRecursivelyInsideFolder(item));
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/owncloud/android/datamodel/OCFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.os.Parcelable;
import android.text.TextUtils;

import com.owncloud.android.BuildConfig;
import com.owncloud.android.R;
import com.owncloud.android.lib.common.network.WebdavEntry;
import com.owncloud.android.lib.common.network.WebdavUtils;
Expand Down Expand Up @@ -1050,4 +1051,12 @@ public void setE2eCounter(@Nullable Long e2eCounter) {
this.e2eCounter = e2eCounter;
}
}

public boolean isAPKorAAB() {
if (BuildConfig.FLAVOR.equals("gplay")) {
return getFileName().endsWith(".apk") || getFileName().endsWith(".aab");
} else {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ private void onOverflowIconClicked() {
additionalFilter.add(R.id.action_send_file);
additionalFilter.add(R.id.action_sync_file);
}
if (getFile().isAPKorAAB()) {
additionalFilter.add(R.id.action_download_file);
additionalFilter.add(R.id.action_export_file);
}
final FragmentManager fragmentManager = getChildFragmentManager();
FileActionsBottomSheet.newInstance(file, true, additionalFilter)
.setResultListener(fragmentManager, this, this::optionsItemSelected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,16 @@ public void onOverflowIconClicked(OCFile file, View view) {
public void openActionsMenu(final int filesCount, final Set<OCFile> checkedFiles, final boolean isOverflow) {
throttler.run("overflowClick", () -> {
final FragmentManager childFragmentManager = getChildFragmentManager();
FileActionsBottomSheet.newInstance(filesCount, checkedFiles, isOverflow)

List<Integer> toHide = new ArrayList<>();
if (isAPKorAAB(checkedFiles)) {
toHide.add(R.id.action_send_share_file);
toHide.add(R.id.action_export_file);
toHide.add(R.id.action_sync_file);
toHide.add(R.id.action_download_file);
}

FileActionsBottomSheet.newInstance(filesCount, checkedFiles, isOverflow, toHide)
.setResultListener(childFragmentManager, this, (id) -> {
onFileActionChosen(id, checkedFiles);
})
Expand Down Expand Up @@ -1037,6 +1046,12 @@ private void folderOnItemClick(OCFile file, int position) {
}

private void fileOnItemClick(OCFile file) {
if (isAPKorAAB(Set.of(file))) {
Snackbar.make(getRecyclerView(),
R.string.gplay_restriction,
Snackbar.LENGTH_LONG).show();
return;
}
if (PreviewImageFragment.canBePreviewed(file)) {
// preview image - it handles the download, if needed
if (searchFragment) {
Expand Down Expand Up @@ -2064,4 +2079,13 @@ public void setFabEnabled(final boolean enabled) {
public boolean isEmpty() {
return mAdapter == null || mAdapter.isEmpty();
}

private boolean isAPKorAAB(Set<OCFile> files) {
for (OCFile file : files) {
if (file.isAPKorAAB()) {
return true;
}
}
return false;
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1208,4 +1208,5 @@
<string name="sub_folder_rule_day">Year/Month/Day</string>
<string name="secure_share_not_set_up">Secure sharing is not set up for this user</string>
<string name="share_not_allowed_when_file_drop">Resharing is not allowed during secure file drop</string>
<string name="gplay_restriction">Google restricted downloading APK/AAB files!</string>
</resources>
Loading