Skip to content
Open
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
66 changes: 66 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

<activity-alias
android:name="at.tomtasche.reader.ui.activity.MainActivity.CATCH_ALL"
android:enabled="false"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve file-URI extension matching in strict mode

Disabling CATCH_ALL removes the only default filter that matches an ACTION_VIEW intent carrying a bare file:///.../name.odt URI with no MIME type: the strict extension filters below all require an authority via android:host="*", while normal file:/// URIs have no host. Legacy file managers that send supported documents this way will stop showing the app unless users opt into all-file-types, even though strict mode is supposed to cover document extensions.

Useful? React with 👍 / 👎.

android:exported="true"
android:label="@string/app_title"
android:targetActivity="at.tomtasche.reader.ui.activity.MainActivity"
Expand Down Expand Up @@ -208,6 +209,7 @@
</activity-alias>
<activity-alias
android:name="at.tomtasche.reader.ui.activity.MainActivity.STRICT_CATCH"
android:enabled="true"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep strict mode from matching generic binary MIME

Enabling STRICT_CATCH by default also enables its MIME-only application/octet-stream entry. Android treats a type-only filter as matching content:/file: URIs with that MIME type, so any provider that reports a generic binary type for an unrelated file will still offer OpenDocument Reader with the catch-all switch off. Constrain octet-stream handling to the extension-based filters or remove it from strict mode so the new default is actually document-only.

Useful? React with 👍 / 👎.

android:exported="true"
android:label="@string/app_title"
android:targetActivity="at.tomtasche.reader.ui.activity.MainActivity"
Expand All @@ -225,10 +227,18 @@
<data android:mimeType="application/vnd.oasis.opendocument.spreadsheet-template" />
<data android:mimeType="application/vnd.oasis.opendocument.presentation" />
<data android:mimeType="application/vnd.oasis.opendocument.presentation-template" />
<data android:mimeType="application/vnd.oasis.opendocument.graphics" />
<data android:mimeType="application/vnd.oasis.opendocument.graphics-template" />
<data android:mimeType="application/octet-stream" />
<data android:mimeType="application/pdf" />
<data android:mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.document" />
<data android:mimeType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
<data android:mimeType="application/msword" />
<!-- raw types handled by RawLoader; text/plain (not text/*) avoids re-matching text/vcard contacts (#477) -->
<data android:mimeType="text/plain" />
<data android:mimeType="text/csv" />
<data android:mimeType="image/*" />
<data android:mimeType="application/zip" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -288,6 +298,34 @@
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.doc" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.doc" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.doc" />
<data android:pathPattern=".*\\.xlsx" />
<data android:pathPattern=".*\\..*\\.xlsx" />
<data android:pathPattern=".*\\..*\\..*\\.xlsx" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.xlsx" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.xlsx" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.xlsx" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.xlsx" />
<data android:pathPattern=".*\\.txt" />
<data android:pathPattern=".*\\..*\\.txt" />
<data android:pathPattern=".*\\..*\\..*\\.txt" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.txt" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.txt" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.txt" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.txt" />
<data android:pathPattern=".*\\.csv" />
<data android:pathPattern=".*\\..*\\.csv" />
<data android:pathPattern=".*\\..*\\..*\\.csv" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.csv" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.csv" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.csv" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.csv" />
<data android:pathPattern=".*\\.zip" />
<data android:pathPattern=".*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.zip" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -348,6 +386,34 @@
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.doc" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.doc" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.doc" />
<data android:pathPattern=".*\\.xlsx" />
<data android:pathPattern=".*\\..*\\.xlsx" />
<data android:pathPattern=".*\\..*\\..*\\.xlsx" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.xlsx" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.xlsx" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.xlsx" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.xlsx" />
<data android:pathPattern=".*\\.txt" />
<data android:pathPattern=".*\\..*\\.txt" />
<data android:pathPattern=".*\\..*\\..*\\.txt" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.txt" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.txt" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.txt" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.txt" />
<data android:pathPattern=".*\\.csv" />
<data android:pathPattern=".*\\..*\\.csv" />
<data android:pathPattern=".*\\..*\\..*\\.csv" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.csv" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.csv" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.csv" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.csv" />
<data android:pathPattern=".*\\.zip" />
<data android:pathPattern=".*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.zip" />
</intent-filter>
</activity-alias>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,18 @@ protected void onStart() {
}
}

private static final String PREF_CATCH_ALL_ENABLED = "catch_all_enabled";

private void initializeCatchAllSwitch() {
ComponentName catchAllComponent = new ComponentName(this, "at.tomtasche.reader.ui.activity.MainActivity.CATCH_ALL");
ComponentName strictCatchComponent = new ComponentName(this, "at.tomtasche.reader.ui.activity.MainActivity.STRICT_CATCH");

boolean isCatchAllEnabled = getPackageManager().getComponentEnabledSetting(catchAllComponent) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

// catch-all is only active if the user explicitly opted in. new installs and
// existing users who never touched the switch default to STRICT_CATCH, so we
// no longer volunteer to open unrelated file types like contacts (issue #477).
boolean isCatchAllEnabled = preferences.getBoolean(PREF_CATCH_ALL_ENABLED, false);

// retoggle components for users upgrading to latest version of app
toggleComponent(catchAllComponent, isCatchAllEnabled);
Expand All @@ -231,6 +238,8 @@ private void initializeCatchAllSwitch() {
catchAllSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
preferences.edit().putBoolean(PREF_CATCH_ALL_ENABLED, isChecked).apply();

toggleComponent(catchAllComponent, isChecked);
toggleComponent(strictCatchComponent, !isChecked);
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<string name="landing_intro_view">OpenDocument Reader allows you to view documents that are stored in OpenDocument format (.odt, .ods, .odp and .odg) wherever you are.</string>
<string name="landing_intro_search">With OpenDocument Reader you can read and search through your documents in a breeze.</string>
<string name="landing_intro_edit">Found one last typo left to fix ahead of your big presentation? It now supports modifications too!</string>
<string name="landing_intro_open_all">This app registers to open all file types by default in order to support apps like \"Samsung My Files\". You may turn this feature off here if it causes problems for you.</string>
<string name="landing_intro_open_all">By default this app only offers to open document files. If another app like \"Samsung My Files\" won\'t let you open a document here, turn this on to register for all file types.</string>
<string name="tts_status_reading">Reading…</string>
<string name="tts_status_initializing">Initializing TTS…</string>
<string name="tts_status_ready">Ready!</string>
Expand Down
Loading