1111
1212import androidx .annotation .Keep ;
1313
14+ import java .io .File ;
1415import java .lang .reflect .Field ;
1516import java .lang .reflect .Method ;
1617import java .util .ArrayList ;
1718import java .util .List ;
19+ import java .util .Map ;
1820import java .util .concurrent .atomic .AtomicReference ;
1921import java .util .function .Consumer ;
2022
23+ import com .notxx .xposed .DeviceSharedPreferences ;
24+
2125import com .oasisfeng .nevo .sdk .HookSupport ;
2226import com .oasisfeng .nevo .sdk .NevoDecoratorService ;
2327import com .oasisfeng .nevo .xposed .BuildConfig ;
3741public class MainHook implements IXposedHookLoadPackage {
3842 private static final String TAG = "MainHook" ;
3943
40- private final XSharedPreferences pref = new XSharedPreferences (BuildConfig .APPLICATION_ID );
44+ private final XSharedPreferences pref = DeviceSharedPreferences . get (BuildConfig .APPLICATION_ID );
4145 private final NevoDecoratorService wechat = new com .oasisfeng .nevo .decorators .wechat .WeChatDecorator ();
4246 private final NevoDecoratorService miui = new com .oasisfeng .nevo .decorators .MIUIDecorator ();
4347 private final NevoDecoratorService media = new com .oasisfeng .nevo .decorators .media .MediaDecorator ();
@@ -202,11 +206,13 @@ protected void beforeHookedMethod(MethodHookParam param) {
202206 }
203207 });
204208 } catch (XposedHelpers .ClassNotFoundError e ) { XposedBridge .log ("NotificationManager hook failed" ); }
205- if (pref .getBoolean ("decorator_wechat.enabled" , false ) && (wechat instanceof HookSupport )) ((HookSupport )wechat ).hook (loadPackageParam ); // TODO
209+ wechat .onCreate (pref );
210+ if (!wechat .isDisabled () && (wechat instanceof HookSupport )) ((HookSupport )wechat ).hook (loadPackageParam ); // TODO
206211 }
207212
208213 private void onCreate (Context context ) {
209214 NevoDecoratorService .setAppContext (context );
215+
210216 wechat .onCreate (pref );
211217 miui .onCreate (pref );
212218 media .onCreate (pref );
@@ -219,7 +225,7 @@ private void preApply(NotificationManager nm, String tag, int id, Notification n
219225 return ;
220226 }
221227 XposedHelpers .setAdditionalInstanceField (n , "pre-applied" , true );
222- if (pref . getBoolean ( "decorator_wechat.enabled" , false )) wechat .preApply (nm , tag , id , n );
228+ if (! wechat . isDisabled ( )) wechat .preApply (nm , tag , id , n );
223229 }
224230
225231 private void onNotificationPosted (StatusBarNotification sbn ) {
@@ -230,24 +236,24 @@ private void onNotificationPosted(StatusBarNotification sbn) {
230236 XposedHelpers .setAdditionalInstanceField (sbn , "applied" , true );
231237 switch (sbn .getPackageName ()) {
232238 case "com.tencent.mm" :
233- if (pref . getBoolean ( "decorator_wechat.enabled" , false )) wechat .apply (sbn );
239+ if (! wechat . isDisabled ( )) wechat .apply (sbn );
234240 break ;
235241 case "com.xiaomi.xmsf" :
236- if (pref . getBoolean ( "decorator_miui.enabled" , false )) miui .apply (sbn );
242+ if (! miui . isDisabled ( )) miui .apply (sbn );
237243 break ;
238244 }
239- if (pref . getBoolean ( "decorator_media.enabled" , false )) media .apply (sbn );
245+ if (! media . isDisabled ( )) media .apply (sbn );
240246 }
241247
242248 private void onNotificationRemoved (StatusBarNotification sbn , int reason ) {
243249 switch (sbn .getPackageName ()) {
244250 case "com.tencent.mm" :
245- if (pref . getBoolean ( "decorator_wechat.enabled" , false )) wechat .onNotificationRemoved (sbn , reason );
251+ if (! wechat . isDisabled ( )) wechat .onNotificationRemoved (sbn , reason );
246252 break ;
247253 case "com.xiaomi.xmsf" :
248- if (pref . getBoolean ( "decorator_miui.enabled" , false )) miui .onNotificationRemoved (sbn , reason );
254+ if (! miui . isDisabled ( )) miui .onNotificationRemoved (sbn , reason );
249255 break ;
250256 }
251- if (pref . getBoolean ( "decorator_media.enabled" , false )) media .onNotificationRemoved (sbn , reason );
257+ if (! media . isDisabled ( )) media .onNotificationRemoved (sbn , reason );
252258 }
253259}
0 commit comments