Skip to content

Commit ac96894

Browse files
CopilotTomTasche
andcommitted
Simplify to two-mode design: catch-all vs catch-supported types
Co-authored-by: TomTasche <128734+TomTasche@users.noreply.github.com>
1 parent cbfad52 commit ac96894

2 files changed

Lines changed: 11 additions & 166 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -218,112 +218,6 @@
218218
android:label="@string/app_title"
219219
android:targetActivity="at.tomtasche.reader.ui.activity.MainActivity"
220220
tools:ignore="AppLinkUrlError">
221-
<intent-filter>
222-
<action android:name="android.intent.action.VIEW" />
223-
224-
<category android:name="android.intent.category.DEFAULT" />
225-
<category android:name="android.intent.category.BROWSABLE" />
226-
227-
<data android:mimeType="application/vnd.oasis.opendocument.text" />
228-
<data android:mimeType="application/vnd.oasis.opendocument.text-template" />
229-
<data android:mimeType="application/vnd.oasis.opendocument.spreadsheet" />
230-
<data android:mimeType="application/vnd.oasis.opendocument.spreadsheet-template" />
231-
<data android:mimeType="application/vnd.oasis.opendocument.presentation" />
232-
<data android:mimeType="application/vnd.oasis.opendocument.presentation-template" />
233-
<data android:mimeType="application/octet-stream" />
234-
</intent-filter>
235-
<intent-filter>
236-
<action android:name="android.intent.action.VIEW" />
237-
238-
<category android:name="android.intent.category.BROWSABLE" />
239-
<category android:name="android.intent.category.DEFAULT" />
240-
241-
<data android:scheme="content" />
242-
<data android:scheme="file" />
243-
<data android:host="*" />
244-
<data android:pathPattern=".*\\.odt" />
245-
<data android:pathPattern=".*\\..*\\.odt" />
246-
<data android:pathPattern=".*\\..*\\..*\\.odt" />
247-
<data android:pathPattern=".*\\..*\\..*\\..*\\.odt" />
248-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.odt" />
249-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.odt" />
250-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.odt" />
251-
<data android:pathPattern=".*\\.ods" />
252-
<data android:pathPattern=".*\\..*\\.ods" />
253-
<data android:pathPattern=".*\\..*\\..*\\.ods" />
254-
<data android:pathPattern=".*\\..*\\..*\\..*\\.ods" />
255-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ods" />
256-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ods" />
257-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ods" />
258-
<data android:pathPattern=".*\\.odp" />
259-
<data android:pathPattern=".*\\..*\\.odp" />
260-
<data android:pathPattern=".*\\..*\\..*\\.odp" />
261-
<data android:pathPattern=".*\\..*\\..*\\..*\\.odp" />
262-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.odp" />
263-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.odp" />
264-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.odp" />
265-
<data android:pathPattern=".*\\.odg" />
266-
<data android:pathPattern=".*\\..*\\.odg" />
267-
<data android:pathPattern=".*\\..*\\..*\\.odg" />
268-
<data android:pathPattern=".*\\..*\\..*\\..*\\.odg" />
269-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.odg" />
270-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.odg" />
271-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.odg" />
272-
<data android:pathPattern=".*\\.odt" />
273-
<data android:pathPattern=".*\\.ods" />
274-
<data android:pathPattern=".*\\.odp" />
275-
<data android:pathPattern=".*\\.odg" />
276-
</intent-filter>
277-
<intent-filter>
278-
<action android:name="android.intent.action.VIEW" />
279-
280-
<category android:name="android.intent.category.BROWSABLE" />
281-
<category android:name="android.intent.category.DEFAULT" />
282-
283-
<data android:mimeType="*/*" />
284-
<data android:scheme="content" />
285-
<data android:scheme="file" />
286-
<data android:host="*" />
287-
<data android:pathPattern=".*\\.odt" />
288-
<data android:pathPattern=".*\\..*\\.odt" />
289-
<data android:pathPattern=".*\\..*\\..*\\.odt" />
290-
<data android:pathPattern=".*\\..*\\..*\\..*\\.odt" />
291-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.odt" />
292-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.odt" />
293-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.odt" />
294-
<data android:pathPattern=".*\\.ods" />
295-
<data android:pathPattern=".*\\..*\\.ods" />
296-
<data android:pathPattern=".*\\..*\\..*\\.ods" />
297-
<data android:pathPattern=".*\\..*\\..*\\..*\\.ods" />
298-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ods" />
299-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ods" />
300-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ods" />
301-
<data android:pathPattern=".*\\.odp" />
302-
<data android:pathPattern=".*\\..*\\.odp" />
303-
<data android:pathPattern=".*\\..*\\..*\\.odp" />
304-
<data android:pathPattern=".*\\..*\\..*\\..*\\.odp" />
305-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.odp" />
306-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.odp" />
307-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.odp" />
308-
<data android:pathPattern=".*\\.odg" />
309-
<data android:pathPattern=".*\\..*\\.odg" />
310-
<data android:pathPattern=".*\\..*\\..*\\.odg" />
311-
<data android:pathPattern=".*\\..*\\..*\\..*\\.odg" />
312-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.odg" />
313-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.odg" />
314-
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.odg" />
315-
<data android:pathPattern=".*\\.odt" />
316-
<data android:pathPattern=".*\\.ods" />
317-
<data android:pathPattern=".*\\.odp" />
318-
<data android:pathPattern=".*\\.odg" />
319-
</intent-filter>
320-
</activity-alias>
321-
<activity-alias
322-
android:name="at.tomtasche.reader.ui.activity.MainActivity.COMMON_TYPES"
323-
android:exported="true"
324-
android:label="@string/app_title"
325-
android:targetActivity="at.tomtasche.reader.ui.activity.MainActivity"
326-
tools:ignore="AppLinkUrlError">
327221
<!-- PDF files -->
328222
<intent-filter>
329223
<action android:name="android.intent.action.VIEW" />
@@ -412,7 +306,7 @@
412306
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.doc" />
413307
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.doc" />
414308
</intent-filter>
415-
<!-- OpenDocument formats - copy from STRICT_CATCH -->
309+
<!-- OpenDocument formats -->
416310
<intent-filter>
417311
<action android:name="android.intent.action.VIEW" />
418312

@@ -514,6 +408,7 @@
514408
</intent-filter>
515409
</activity-alias>
516410

411+
517412
<activity
518413
android:name="com.google.android.gms.ads.AdActivity"
519414
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

app/src/main/java/at/tomtasche/reader/ui/activity/MainActivity.java

Lines changed: 9 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -218,80 +218,30 @@ protected void onStart() {
218218

219219
private void initializeCatchAllSwitch() {
220220
ComponentName catchAllComponent = new ComponentName(this, "at.tomtasche.reader.ui.activity.MainActivity.CATCH_ALL");
221-
ComponentName commonTypesComponent = new ComponentName(this, "at.tomtasche.reader.ui.activity.MainActivity.COMMON_TYPES");
222221
ComponentName strictCatchComponent = new ComponentName(this, "at.tomtasche.reader.ui.activity.MainActivity.STRICT_CATCH");
223222

224-
// Determine current mode based on enabled components
225223
boolean isCatchAllEnabled = getPackageManager().getComponentEnabledSetting(catchAllComponent) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
226-
boolean isCommonTypesEnabled = getPackageManager().getComponentEnabledSetting(commonTypesComponent) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
227-
boolean isStrictEnabled = getPackageManager().getComponentEnabledSetting(strictCatchComponent) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
228-
229-
// Determine current mode - prioritize in order: CATCH_ALL -> COMMON_TYPES -> STRICT
230-
String currentMode;
231-
if (isCatchAllEnabled) {
232-
currentMode = "CATCH_ALL";
233-
} else if (isCommonTypesEnabled) {
234-
currentMode = "COMMON_TYPES";
235-
} else if (isStrictEnabled) {
236-
currentMode = "STRICT";
237-
} else {
238-
// Default for new installations or if all are disabled
239-
currentMode = "COMMON_TYPES";
240-
}
241-
242-
// Set the appropriate mode
243-
setFileTypeMode(currentMode);
224+
225+
// retoggle components for users upgrading to latest version of app
226+
toggleComponent(catchAllComponent, isCatchAllEnabled);
227+
toggleComponent(strictCatchComponent, !isCatchAllEnabled);
244228

245229
SwitchCompat catchAllSwitch = findViewById(R.id.landing_catch_all);
246230

247231
catchAllSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
248232
@Override
249233
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
250-
if (isChecked) {
251-
// Switch to common types mode
252-
setFileTypeMode("COMMON_TYPES");
253-
} else {
254-
// Switch to strict mode
255-
setFileTypeMode("STRICT");
256-
}
234+
toggleComponent(catchAllComponent, isChecked);
235+
toggleComponent(strictCatchComponent, !isChecked);
257236
}
258237
});
259238

260-
// Set switch state: checked if common types is enabled, unchecked if strict is enabled
261-
// Note: We don't expose CATCH_ALL mode in the UI anymore, as per issue #374 request
262-
catchAllSwitch.setChecked(currentMode.equals("COMMON_TYPES"));
239+
catchAllSwitch.setChecked(isCatchAllEnabled);
263240

264-
analyticsManager.report("file_mode_" + currentMode.toLowerCase());
265-
}
266-
267-
private void setFileTypeMode(String mode) {
268-
ComponentName catchAllComponent = new ComponentName(this, "at.tomtasche.reader.ui.activity.MainActivity.CATCH_ALL");
269-
ComponentName commonTypesComponent = new ComponentName(this, "at.tomtasche.reader.ui.activity.MainActivity.COMMON_TYPES");
270-
ComponentName strictCatchComponent = new ComponentName(this, "at.tomtasche.reader.ui.activity.MainActivity.STRICT_CATCH");
271-
272-
// Disable all components first
273-
toggleComponent(catchAllComponent, false);
274-
toggleComponent(commonTypesComponent, false);
275-
toggleComponent(strictCatchComponent, false);
276-
277-
// Enable the appropriate component
278-
switch (mode) {
279-
case "CATCH_ALL":
280-
toggleComponent(catchAllComponent, true);
281-
break;
282-
case "COMMON_TYPES":
283-
toggleComponent(commonTypesComponent, true);
284-
break;
285-
case "STRICT":
286-
toggleComponent(strictCatchComponent, true);
287-
break;
288-
default:
289-
// Default to common types
290-
toggleComponent(commonTypesComponent, true);
291-
break;
292-
}
241+
analyticsManager.report(isCatchAllEnabled ? "catch_all_enabled" : "catch_all_disabled");
293242
}
294243

244+
295245
private void toggleComponent(ComponentName component, boolean enabled) {
296246
int newState = enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
297247
getPackageManager().setComponentEnabledSetting(component, newState, PackageManager.DONT_KILL_APP);

0 commit comments

Comments
 (0)