From 27ac4748667792622fea2685d4fe7940b7c4d51d Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Wed, 8 Jul 2026 22:01:36 +0200 Subject: [PATCH] Default to STRICT_CATCH file-type registration (fixes #477) The app registered a true catch-all VIEW intent-filter (content/file scheme with no MIME/extension constraint plus */*), so the OS offered OpenDocument Reader for unrelated content like vCard/contact URIs (issue #477). A narrower STRICT_CATCH activity-alias and a landing-screen toggle already existed, but CATCH_ALL was the default and the old code force-enabled it on every launch. This makes STRICT_CATCH the default: - Manifest: CATCH_ALL android:enabled=false, STRICT_CATCH android:enabled=true, so fresh installs are strict from first launch. - MainActivity: drive the alias choice from a SharedPreferences flag instead of component state. New installs and existing users who never used the switch default to strict; an explicit toggle is remembered. Users who want the old behavior can still opt in via the switch. - Update the landing-screen help text for the inverted default. Renew the STRICT_CATCH type list to match what the app actually opens: - CoreLoader: add ODF graphics MIME types (the .odg extension patterns were already registered) and xlsx (spreadsheetml.sheet) MIME type and .xlsx extension patterns. pptx stays out since the core disables it. - RawLoader: keep text, images, csv and zip openable by default by registering text/plain, text/csv, image/* and application/zip plus .txt/.csv/.zip extension patterns. text/plain is used deliberately instead of text/* so text/vcard contacts are not matched again (#477). Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01XXRLLpHb7kGTr6tic2H9LZ --- app/src/main/AndroidManifest.xml | 66 +++++++++++++++++++ .../reader/ui/activity/MainActivity.java | 11 +++- app/src/main/res/values/strings.xml | 2 +- 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8c93c3ac3742..1bce8e9434d3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -77,6 +77,7 @@ + + + + + + + + @@ -288,6 +298,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -348,6 +386,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/at/tomtasche/reader/ui/activity/MainActivity.java b/app/src/main/java/at/tomtasche/reader/ui/activity/MainActivity.java index 829b9ecc4c87..1c9bcb417ed4 100644 --- a/app/src/main/java/at/tomtasche/reader/ui/activity/MainActivity.java +++ b/app/src/main/java/at/tomtasche/reader/ui/activity/MainActivity.java @@ -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); @@ -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); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7d46a4f4ae89..51894fdd8b98 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -45,7 +45,7 @@ OpenDocument Reader allows you to view documents that are stored in OpenDocument format (.odt, .ods, .odp and .odg) wherever you are. With OpenDocument Reader you can read and search through your documents in a breeze. Found one last typo left to fix ahead of your big presentation? It now supports modifications too! - 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. + 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. Reading… Initializing TTS… Ready!