Skip to content

Commit

Permalink
Receiver: rewrite to accept more document formats
Browse files Browse the repository at this point in the history
Issue #21
  • Loading branch information
2bllw8 committed May 19, 2022
1 parent ec73d12 commit 3814c8a
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 189 deletions.
9 changes: 7 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
android:label="@string/receiver_label"
android:stateNotNeeded="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
Expand All @@ -116,12 +121,12 @@
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/pdf" />
<data android:mimeType="video/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="video/*" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>
</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.function.Consumer;

import exe.bbllw8.anemo.R;
Expand Down Expand Up @@ -139,6 +140,16 @@ public Cursor querySearchDocuments(String rootId, String[] projection, Bundle qu
}
}

@Override
public DocumentsContract.Path findDocumentPath(String parentDocumentId,
String childDocumentId) {
if (lockStore.isLocked()) {
return new DocumentsContract.Path(null, Collections.emptyList());
} else {
return super.findDocumentPath(parentDocumentId, childDocumentId);
}
}

@Override
public ParcelFileDescriptor openDocument(String documentId, String mode,
CancellationSignal signal) throws FileNotFoundException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
Expand Down Expand Up @@ -294,6 +296,20 @@ public Cursor queryChildDocuments(String parentDocumentId, String[] projection,
return result;
}

@Override
public DocumentsContract.Path findDocumentPath(String parentDocumentId,
String childDocumentId) {
final String pathStr;
if (parentDocumentId == null) {
pathStr = childDocumentId;
} else {
pathStr = childDocumentId.substring(parentDocumentId.length());
}

final List<String> segments = Arrays.asList(pathStr.split("/"));
return new DocumentsContract.Path(parentDocumentId, segments);
}

@Override
public String getDocumentType(String documentId) throws FileNotFoundException {
final Try<Path> pathTry = getPathForId(documentId);
Expand Down
102 changes: 0 additions & 102 deletions app/src/main/java/exe/bbllw8/anemo/documents/receiver/Importer.java

This file was deleted.

Loading

0 comments on commit 3814c8a

Please sign in to comment.