File tree Expand file tree Collapse file tree 4 files changed +39
-0
lines changed
java/com/programminghoch10/DisableSounds Expand file tree Collapse file tree 4 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 11com.programminghoch10.DisableSounds.DisableForcedCameraSoundHook
22com.programminghoch10.DisableSounds.DisableScreenshotSoundHook
3+ com.programminghoch10.DisableSounds.DisableShutterSoundsHook
Original file line number Diff line number Diff line change 1+ package com.programminghoch10.DisableSounds
2+
3+ import android.annotation.SuppressLint
4+ import android.media.MediaActionSound
5+ import android.os.Build
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+ @SuppressLint(" ObsoleteSdkInt" )
14+ override fun handleLoadPackage (lpparam : XC_LoadPackage .LoadPackageParam ? ) {
15+ val sharedPreferences = XSharedPreferences (BuildConfig .APPLICATION_ID , SHARED_PREFERENCES_NAME )
16+ if (! sharedPreferences.getBoolean(" shutter" , false )) return
17+
18+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN ) for (methodName in listOf (" load" , " play" )) XposedHelpers .findAndHookMethod(
19+ MediaActionSound ::class .java,
20+ methodName,
21+ Int ::class .java,
22+ XC_MethodReplacement .DO_NOTHING ,
23+ )
24+
25+ // TODO: need a native hook for old Camera API methods
26+ // https://cs.android.com/android/platform/superproject/main/+/main:frameworks/av/services/camera/libcameraservice/CameraService.cpp;l=4097?q=camera_click.ogg
27+ // then the "might not work" warning can be removed from @string/disable_shutter_sounds_description_on
28+ }
29+ }
Original file line number Diff line number Diff line change 33 <string name =" title_activity_settings" >DisableSounds Configuration</string >
44 <string name =" app_name" >DisableSounds</string >
55 <string name =" description" >Disable various system sounds</string >
6+ <string name =" disable_shutter_sounds_title" >Disable shutter sounds</string >
7+ <string name =" disable_shutter_sounds_description" >Disable shutter, focus and video recording sounds.</string >
8+ <string name =" disable_shutter_sounds_description_on" >Some apps using the old Camera API might not be muted. On Android 13 and older the screenshot sound might be muted too.</string >
69 <string name =" disable_screenshot_sound_title" >Disable screenshot sound</string >
710 <string name =" disable_screenshot_sound_description" >@null</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 : key =" shutter"
6+ app : title =" @string/disable_shutter_sounds_title"
7+ app : summary =" @string/disable_shutter_sounds_description"
8+ app : summaryOn =" @string/disable_shutter_sounds_description_on"
9+ />
410 <SwitchPreference
511 app : key =" screenshot"
612 app : title =" @string/disable_screenshot_sound_title"
You can’t perform that action at this time.
0 commit comments