|
1
|
-package com.customIcon;
|
1
|
+package com.vodeapp.customsIcon;
|
|
2
|
|
2
|
|
|
|
|
3
|
+import android.app.Activity;
|
|
|
|
4
|
+import android.content.ComponentName;
|
|
|
|
5
|
+import android.content.pm.PackageManager;
|
|
|
|
6
|
+
|
|
|
|
7
|
+import com.facebook.react.bridge.Callback;
|
|
3
|
import com.facebook.react.bridge.ReactApplicationContext;
|
8
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
9
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
5
|
import com.facebook.react.bridge.ReactMethod;
|
10
|
import com.facebook.react.bridge.ReactMethod;
|
|
6
|
-import com.facebook.react.bridge.Callback;
|
|
|
|
7
|
-
|
|
|
|
8
|
-public class CustomIconModule extends ReactContextBaseJavaModule {
|
|
|
|
9
|
|
11
|
|
|
|
|
12
|
+public class CustomsIconModule extends ReactContextBaseJavaModule {
|
|
10
|
private final ReactApplicationContext reactContext;
|
13
|
private final ReactApplicationContext reactContext;
|
|
11
|
|
14
|
|
|
12
|
- public CustomIconModule(ReactApplicationContext reactContext) {
|
15
|
+ public CustomsIconModule(ReactApplicationContext reactContext) {
|
|
13
|
super(reactContext);
|
16
|
super(reactContext);
|
|
14
|
this.reactContext = reactContext;
|
17
|
this.reactContext = reactContext;
|
|
15
|
}
|
18
|
}
|
|
@@ -20,6 +23,22 @@ public class CustomIconModule extends ReactContextBaseJavaModule { |
|
@@ -20,6 +23,22 @@ public class CustomIconModule extends ReactContextBaseJavaModule { |
|
20
|
}
|
23
|
}
|
|
21
|
|
24
|
|
|
22
|
@ReactMethod
|
25
|
@ReactMethod
|
|
|
|
26
|
+ public void changeIcon(String name) {
|
|
|
|
27
|
+ String pageName = this.reactContext.getPackageName();
|
|
|
|
28
|
+ PackageManager packageManager = this.reactContext.getPackageManager();
|
|
|
|
29
|
+ Activity activity = getActivity();
|
|
|
|
30
|
+ ComponentName am =activity.getComponentName();
|
|
|
|
31
|
+ packageManager.setComponentEnabledSetting(new ComponentName(this.reactContext, pageName +
|
|
|
|
32
|
+ am.getShortClassName()), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager
|
|
|
|
33
|
+ .DONT_KILL_APP);
|
|
|
|
34
|
+ packageManager.setComponentEnabledSetting(new ComponentName(this.reactContext,pageName +
|
|
|
|
35
|
+ "."+name), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager
|
|
|
|
36
|
+ .DONT_KILL_APP);
|
|
|
|
37
|
+ }
|
|
|
|
38
|
+ public Activity getActivity() {
|
|
|
|
39
|
+ return this.getCurrentActivity();
|
|
|
|
40
|
+ }
|
|
|
|
41
|
+ @ReactMethod
|
|
23
|
public void sampleMethod(String stringArgument, int numberArgument, Callback callback) {
|
42
|
public void sampleMethod(String stringArgument, int numberArgument, Callback callback) {
|
|
24
|
// TODO: Implement some actually useful functionality
|
43
|
// TODO: Implement some actually useful functionality
|
|
25
|
callback.invoke("Received numberArgument: " + numberArgument + " stringArgument: " + stringArgument);
|
44
|
callback.invoke("Received numberArgument: " + numberArgument + " stringArgument: " + stringArgument);
|