@hamzahrmalik strange, i don't see you credit all the people on other threads who answered all of your innocent-sounding questions that allowed you to write this tutorial. although at least you finally added credit to rovo89 after you originally claimed this was all your work. that was nice of you, i suppose.
@hamzahrmalik strange, i don't see you credit all the people on other threads who answered all of your innocent-sounding questions that allowed you to write this tutorial. although at least you finally added credit to rovo89 after you originally claimed this was all your work. that was nice of you, i suppose.
Thanks for the excellent tutorial.
I would like to know when and where to use "XposedProjectAutoSetup 2.1.jar" file.
And where is the link to XposedBridge API jar.
So visit http://grepcode.com/project/repository.grepcode.com/java/ext/com.google.android/android/ in your browser to view Android's source code. If (in Android 4+) you browse to com.android.systemui.statusbar.policy.Clock.java
you will find the class that controls the clock.
Add this inside your method
Code:if (!lpparam.packageName.equals("com.android.systemui"))//check if the package being loaded is systemUI return; //All code here is only called if it is indeed SystemUI
how did you know to use "com.android.systemui" here and not "com.android" or "com.android.systemui.statusbar", etc.?
how did you know to use "com.android.systemui" here and not "com.android" or "com.android.systemui.statusbar", etc.?
i want to be ROM specific.
i have modified the res/layout/status_bar.xml
i have copied it in xposed project structure under res/layout.
It belongs to com.android.systemui.... and i want it to use my xml on runtime.
Can i simply replace it using initpackageresources and initzygote like we did for dimens??? its an xml file so im not sure.
Just let me know the function to achieve this. Thanks in advance
If you want to be ROM specific, make a flash able zip. If you really want to use Xposed wait until tutorial 8 (later today) which covers modifying layouts
Sent from my iPod touch using Tapatalk
I want to be able to toggle it... and in case something goes wrong, easily recover.... and that needs xposed framework. Systemui crashing is a pain if it goes wrong.
ANyways, i have done the hard part and resolved all the ids/styles etc etc but in the end, there was some clash between replacement of systemui layout and at the same time changing dimens in android framework.
It wasnt accepting the dimens change witht he layout change of systemui.
I separated the code into two modules. one for layout and one for dimens. THey seem to work on their own, but not together.
One of them changes dimens correctly... other changes the layout correctly. When both modules run together,,, only layout module works.
Maybe my understanding of Zygote/Xposed/Java is flawed at some level.... hopefully ur new tutorial will help me clear my doubts.
Thanks
public class Meizuclock implements IXposedHookZygoteInit, IXposedHookInitPackageResources {
public static String MODULE_PATH = null;
@Override
public void initZygote(StartupParam startupParam) throws Throwable {
// TODO Auto-generated method stub
MODULE_PATH = startupParam.modulePath;
XResources.setSystemWideReplacement("android", "bool", "config_unplugTurnsOnScreen", false);
XResources.setSystemWideReplacement("android", "bool", "config_allowAllRotations", true);
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, null);
XResources.setSystemWideReplacement("android", "dimen", "navigation_bar_height", modRes.fwd(R.dimen.navbarh));
XResources.setSystemWideReplacement("android", "dimen", "navigation_bar_height_landscape", modRes.fwd(R.dimen.navbarhl));
XResources.setSystemWideReplacement("android", "dimen", "navigation_bar_width", modRes.fwd(R.dimen.navbarw));
}
@Override
public void handleInitPackageResources(InitPackageResourcesParam resparam) throws Throwable {
if (!resparam.packageName.equals("com.android.systemui"))
return;
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);
resparam.res.setReplacement("com.android.systemui", "layout", "status_bar", modRes.fwd(R.layout.status_bar));
}
}
Even when code combined. It doesnt work. only layout works...
Please have a look at below:
---------- Post added at 11:59 PM ---------- Previous post was at 11:57 PM ----------
RED doesnt work
BLUE works
Single module. Separate modules. Both times, the red part doest seem to work....
However.... when ONLY the red part module is ALONE activated... it works.,
public class Meizuclock implements IXposedHookZygoteInit, IXposedHookInitPackageResources {
public static String MODULE_PATH = null;
@Override
public void initZygote(StartupParam startupParam) throws Throwable {
// TODO Auto-generated method stub
MODULE_PATH = startupParam.modulePath;
XResources.setSystemWideReplacement("android", "bool", "config_unplugTurnsOnScreen", false);
XResources.setSystemWideReplacement("android", "bool", "config_allowAllRotations", true);
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, null);
}
@Override
public void handleInitPackageResources(InitPackageResourcesPar am resparam) throws Throwable {
if (!resparam.packageName.equals("com.android.systemu i"))
return;
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);
resparam.res.setReplacement("com.android.systemui" , "layout", "status_bar", modRes.fwd(R.layout.status_bar));
resparam.res.setReplacement("android", "dimen", "navigation_bar_height", modRes.fwd(R.dimen.navbarh));
resparam.res.setReplacement("android", "dimen", "navigation_bar_height_landscape", modRes.fwd(R.dimen.navbarhl));
resparam.res.setReplacement("android", "dimen", "navigation_bar_width", modRes.fwd(R.dimen.navbarw));
}
}
<meta-data
android:name="xposedmodule"
android:value="true" />
<meta-data
android:name="xposedminversion"
android:value="30" />
<meta-data
android:name="xposeddescription"
android:value="Add a smiley face" />
package com.hamzah.smileyclock;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
public class Main implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
}
}
if (!lpparam.packageName.equals("com.android.systemui"))//check if the package being loaded is systemUI
return;
//All code here is only called if it is indeed SystemUI
findAndHookMethod("com.android.systemui.statusbar.policy.Clock", lpparam.classLoader, "updateClock", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
});
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
TextView tv = (TextView) param.thisObject;
tv.setText(":)");
tv.appendText(":)");
package com.hamzah.smileyclock;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import android.widget.TextView;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
public class Main implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals("com.android.systemui"))
return;
findAndHookMethod("com.android.systemui.statusbar.policy.Clock", lpparam.classLoader, "updateClock", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
TextView tv = (TextView) param.thisObject;
tv.setText(":)");
}
});
}
}
XResources.setSystemWideReplacement("android", "bool", "config_unplugTurnsOnScreen", false);
String MODULE_PATH = startupParam.modulePath;
if (!resparam.packageName.equals("android"))
return;
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);
36dp
XResources.setSystemWideReplacement("android", "dimen", "navigation_bar_height", modRes.fwd(R.dimen.navigationbarSize));
public void apply(){
EditText et = (EditText) findViewById(R.id.input);
String input = et.getText().toString();
}
SharedPreferences pref = getSharedPreferences("user_settings", MODE_WORLD_READABLE);
Editor editor = pref.edit();
editor.putString("user_text", input);
tv.setText(":)");
XSharedPreferences pref = new XSharedPreferences("com.hamzah.smileyclock", "user_settings");
//Gets the shared preference
String text = pref.getString("user_text", "");
//reads the value which is saves, using nothing as default value to use if nothing is saved
tv.setText(text);
//sets the text to saved value
resparam.res.hookLayout("com.android.systemui", "layout", "navigation_bar", new XC_LayoutInflated() {
@Override
public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable {
}
});
@Override
public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable {
View navbar = (View) liparam.view.findViewById(
liparam.res.getIdentifier("nav_buttons", "id", "com.android.systemui"));
}
<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.statusbar.phone.NavigationBarView android:background="#ff000000" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<FrameLayout android:id="@id/rot0" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal" android:id="@id/nav_buttons" android:clipChildren="false" android:clipToPadding="false" android:layout_width="fill_parent" android:layout_height="fill_parent" android:animateLayoutChanges="true">
<View android:visibility="invisible" android:layout_width="40.0dip" android:layout_height="fill_parent" android:layout_weight="0.0" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@id/back" android:layout_width="80.0dip" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_back" android:layout_weight="0.0" android:contentDescription="@string/accessibility_back" systemui:keyCode="4" systemui:glowBackground="@drawable/ic_sysbar_highlight" />
<View android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@id/home" android:layout_width="80.0dip" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_home" android:layout_weight="0.0" android:contentDescription="@string/accessibility_home" systemui:keyCode="3" systemui:keyRepeat="false" systemui:glowBackground="@drawable/ic_sysbar_highlight" />
<View android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@id/recent_apps" android:layout_width="80.0dip" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_recent" android:layout_weight="0.0" android:contentDescription="@string/accessibility_recent" systemui:glowBackground="@drawable/ic_sysbar_highlight" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@id/menu" android:visibility="invisible" android:layout_width="40.0dip" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_menu" android:layout_weight="0.0" android:contentDescription="@string/accessibility_menu" systemui:keyCode="82" systemui:glowBackground="@drawable/ic_sysbar_highlight" />
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:id="@id/lights_out" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView android:layout_width="80.0dip" android:layout_height="fill_parent" android:layout_marginLeft="40.0dip" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:layout_weight="0.0" />
<View android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0" />
<ImageView android:layout_width="80.0dip" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_lights_out_dot_large" android:scaleType="center" android:layout_weight="0.0" />
<View android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0" />
<ImageView android:layout_width="80.0dip" android:layout_height="fill_parent" android:layout_marginRight="40.0dip" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:layout_weight="0.0" />
</LinearLayout>
<View android:layout_gravity="top" android:id="@id/deadzone" android:clickable="true" android:layout_width="fill_parent" android:layout_height="@dimen/navigation_bar_deadzone_size" />
</FrameLayout>
<FrameLayout android:id="@id/rot90" android:paddingTop="0.0dip" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent">
[COLOR="Green"]<LinearLayout android:orientation="vertical" [COLOR="Red"]android:id="@id/nav_buttons"[/COLOR] android:clipChildren="false" android:clipToPadding="false" android:layout_width="fill_parent" android:layout_height="fill_parent" android:animateLayoutChanges="true">[/COLOR]
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@id/menu" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="40.0dip" android:src="@drawable/ic_sysbar_menu_land" android:layout_weight="0.0" android:contentDescription="@string/accessibility_menu" systemui:keyCode="82" systemui:glowBackground="@drawable/ic_sysbar_highlight_land" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@id/recent_apps" android:layout_width="fill_parent" android:layout_height="80.0dip" android:src="@drawable/ic_sysbar_recent_land" android:layout_weight="0.0" android:contentDescription="@string/accessibility_recent" systemui:glowBackground="@drawable/ic_sysbar_highlight_land" />
<View android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@id/home" android:layout_width="fill_parent" android:layout_height="80.0dip" android:src="@drawable/ic_sysbar_home_land" android:layout_weight="0.0" android:contentDescription="@string/accessibility_home" systemui:keyCode="3" systemui:keyRepeat="false" systemui:glowBackground="@drawable/ic_sysbar_highlight_land" />
<View android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@id/back" android:layout_width="fill_parent" android:layout_height="80.0dip" android:src="@drawable/ic_sysbar_back_land" android:layout_weight="0.0" android:contentDescription="@string/accessibility_back" systemui:keyCode="4" systemui:glowBackground="@drawable/ic_sysbar_highlight_land" />
<View android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="40.0dip" android:layout_weight="0.0" />
</LinearLayout>
<LinearLayout android:orientation="vertical" android:id="@id/lights_out" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView android:layout_width="fill_parent" android:layout_height="80.0dip" android:layout_marginTop="40.0dip" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:layout_weight="0.0" />
<View android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0" />
<ImageView android:layout_width="fill_parent" android:layout_height="80.0dip" android:src="@drawable/ic_sysbar_lights_out_dot_large" android:scaleType="center" android:layout_weight="0.0" />
<View android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0" />
<ImageView android:layout_width="fill_parent" android:layout_height="80.0dip" android:layout_marginBottom="40.0dip" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:layout_weight="0.0" />
</LinearLayout>
<View android:layout_gravity="left" android:id="@id/deadzone" android:clickable="true" android:layout_width="@dimen/navigation_bar_deadzone_size" android:layout_height="fill_parent" />
</FrameLayout>
<View android:id="@id/rot270" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent" />
</com.android.systemui.statusbar.phone.NavigationBarView>
navbar.setBackgroundColor(Color.BLUE);
findAndHookMethod("com.android.settings.Settings", lpparam.classLoader, "onCreate", new XC_MethodHook() {
});
findAndHookMethod("com.android.settings.Settings", lpparam.classLoader, "onCreate", [B]Bundle.class[/B], new XC_MethodHook() {
});
findAndHookMethod("com.android.settings.Settings", lpparam.classLoader, "onCreate", [B]"android.os.Bundle"[/B], new XC_MethodHook() {
});
Nice Tutorials, but this what you've posted until now is already published by a lot of peoples (also on the offical GitHub-Page).
It would be awesome if you show some other (non-public) Tutorials, e.g how to make a PreferenceMenu and use it
#KeepItUp