I'm new to Android Programming, and started my first porject as Xposed Module, This xposed module got an option, when it's enabled it will change a drawable file, good for now ? The problem i'm having is with using "onCheckedChanged" inside the public void handleInitPackageResources .
I've got a lot of errors and i can't understand why/how to fix it, Here's my code :
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.res.XModuleResources;
import de.robv.android.xposed.IXposedHookInitPackageResources;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.callbacks.XC_InitPackageResources.InitPackageResourcesParam;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.Switch;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public class CustomHeaderImage implements IXposedHookZygoteInit, IXposedHookInitPackageResources {
private String MODULE_PATH = null;
@Override
public void initZygote(StartupParam startupParam) throws Throwable {
MODULE_PATH = startupParam.modulePath;
}
@Override
public void handleInitPackageResources(InitPackageResourcesParam resparam) throws Throwable {
if (!resparam.packageName.equals("com.android.systemui"))
return;
///////the place of the switch
////If Enabled Do The Following :
Switch applybutton = (Switch)findViewById(R.id.switch1);
applybutton.setOnClickListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged extends AppCompatActivity(CompoundButton R.id.switch1, boolean on)
{
if (on) {
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);
resparam.res.setReplacement("com.android.systemui", "drawable", "notification_header_bg", modRes.fwd(R.drawable.notification_header_bg));
} else {
}
} }
};
}
Don't mix the activity of your settings app with the actual module, that is not how Xposed works. Your actual module doesn't work as part of the app, you need to separate them and in the app, save the drawable to a file and then access that file in the module
To separate them, make a new class for the actual module. Be sure to change your assets/xposed-init file to the new class