File tree Expand file tree Collapse file tree 7 files changed +49
-0
lines changed
java/com/programminghoch10/DisableSounds
metadata/com.programminghoch10.DisableSounds/en-US Expand file tree Collapse file tree 7 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 33Disable various system sounds.
44
55- Disable (regionally) forced camera sound
6+ - Disable shutter sound
67- Disable screenshot sound
78
89## Forced camera sound
Original file line number Diff line number Diff line change 11com.programminghoch10.DisableSounds.DisableForcedCameraSoundsHook
22com.programminghoch10.DisableSounds.DisableScreenshotSoundsHook
3+ com.programminghoch10.DisableSounds.DisableShutterSoundsHook
Original file line number Diff line number Diff line change 1+ package com.programminghoch10.DisableSounds
2+
3+ import android.media.MediaActionSound
4+ import android.os.Build
5+ import com.programminghoch10.DisableSounds.BuildConfig.SHARED_PREFERENCES_NAME
6+ import de.robv.android.xposed.IXposedHookLoadPackage
7+ import de.robv.android.xposed.XC_MethodReplacement
8+ import de.robv.android.xposed.XSharedPreferences
9+ import de.robv.android.xposed.XposedHelpers
10+ import de.robv.android.xposed.callbacks.XC_LoadPackage
11+
12+ class DisableShutterSoundsHook : IXposedHookLoadPackage {
13+ override fun handleLoadPackage (lpparam : XC_LoadPackage .LoadPackageParam ? ) {
14+ val sharedPreferences = XSharedPreferences (BuildConfig .APPLICATION_ID , SHARED_PREFERENCES_NAME )
15+ if (! sharedPreferences.getBoolean(" shutter" , false )) return
16+
17+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN ) {
18+ for (methodName in listOf (" load" , " play" )) {
19+ XposedHelpers .findAndHookMethod(
20+ MediaActionSound ::class .java,
21+ methodName,
22+ Int ::class .java,
23+ XC_MethodReplacement .DO_NOTHING ,
24+ )
25+ }
26+ }
27+
28+ // TODO: need a native hook for old Camera API methods
29+ // https://cs.android.com/android/platform/superproject/main/+/main:frameworks/av/services/camera/libcameraservice/CameraService.cpp;l=4097?q=camera_click.ogg
30+ // then the "might not work" warning can be removed from @string/disable_shutter_sounds_description_on
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <resources >
3+ <string name =" disable_shutter_sounds_description_on" >Some apps using the old Camera API might not be muted.</string >
4+ </resources >
Original file line number Diff line number Diff line change 55 <string name =" description" >Disable various system sounds</string >
66 <string name =" disable_screenshot_sounds_title" >Disable screenshot sounds</string >
77 <string name =" disable_screenshot_sounds_description" >Disable screenshot and screen recording sounds.</string >
8+ <string name =" disable_shutter_sounds_title" >Disable shutter sounds</string >
9+ <string name =" disable_shutter_sounds_description" >Disable shutter, focus and video recording sounds.</string >
10+ <string name =" disable_shutter_sounds_description_on" >Some apps using the old Camera API might not be muted. The screenshot sound might be muted too.</string >
811</resources >
Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" utf-8" ?>
22<PreferenceScreen
33 xmlns : app =" http://schemas.android.com/apk/res-auto" >
4+ <SwitchPreference
5+ app : iconSpaceReserved =" false"
6+ app : key =" shutter"
7+ app : summary =" @string/disable_shutter_sounds_description"
8+ app : summaryOn =" @string/disable_shutter_sounds_description_on"
9+ app : title =" @string/disable_shutter_sounds_title"
10+ />
411 <SwitchPreference
512 app : iconSpaceReserved =" false"
613 app : key =" screenshot"
Original file line number Diff line number Diff line change 11Disable various system sounds.
22
33- Disable (regionally) forced camera sound
4+ - Disable shutter sound
45- Disable screenshot sound
You can’t perform that action at this time.
0 commit comments