Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Add color picker for status bar color (replacing the list) and clock …
Browse files Browse the repository at this point in the history
…color (added in this commit)
  • Loading branch information
rovo89 committed May 9, 2012
1 parent ae20e18 commit 201f32d
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "externals/colorpicker"]
path = externals/colorpicker
url = git://github.com/rovo89/android-ColorPickerPreference.git
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ protected Parcelable onSaveInstanceState() {
// Save the instance state
final SavedState myState = new SavedState(superState);
myState.progress = mProgress;
myState.step = mStep;
myState.min = mMin;
myState.max = mMax;
return myState;
}
Expand Down Expand Up @@ -234,15 +236,18 @@ public SavedState(Parcel source) {

// Restore the click counter
progress = source.readInt();
step = source.readInt();
min = source.readInt();
max = source.readInt();
}

@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);

// Save the click counter
dest.writeInt(progress);
dest.writeInt(step);
dest.writeInt(min);
dest.writeInt(max);
}

Expand Down
1 change: 1 addition & 0 deletions XposedTweakbox/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
# Project target.
target=android-15
android.library.reference.1=../XposedLibrary
android.library.reference.2=../externals/colorpicker
14 changes: 0 additions & 14 deletions XposedTweakbox/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,5 @@
<item name="classical_recent">1</item>
<item name="new_recent">2</item>
</string-array>
<string-array name="statusbarColors">
<item name="transparent">Transparent</item>
<item name="semi_transparent25">Semi-transparent (25%)</item>
<item name="semi_transparent50">Semi-transparent (50%)</item>
<item name="semi_transparent75">Semi-transparent (75%)</item>
<item name="default">Default</item>
</string-array>
<string-array name="statusbarColorValues">
<item name="transparent">0</item>
<item name="semi_transparent25">0x3f000000</item>
<item name="semi_transparent50">0x7f000000</item>
<item name="semi_transparent75">0xbf000000</item>
<item name="default">0xdeadbeef</item>
</string-array>

</resources>
19 changes: 13 additions & 6 deletions XposedTweakbox/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@
android:summary="Number of bars to be displayed for the signal strength indicator (Samsung only)"
android:title="Signal strength bars" />

<de.robv.android.xposed.library.ui.IntegerListPreference
android:defaultValue="0xdeadbeef"
android:entries="@array/statusbarColors"
android:entryValues="@array/statusbarColorValues"
<net.margaritov.preference.colorpicker.ColorPickerPreference
alphaSlider="true"
showCheckbox="true"
android:defaultValue="#ff000000"
android:key="statusbar_color"
android:summary="Color of the statusbar: %s\nNOTE: Most applications do not put anything behind the statusbar (why should they?). This will probably look weird if you are not on the home screen."
android:summary="Color of the statusbar.\nNOTE: This will probably look weird if you are not on the home screen because most applications do not put anything behind the status bar (why should they?)"
android:title="Background color" />
<net.margaritov.preference.colorpicker.ColorPickerPreference
alphaSlider="true"
showCheckbox="true"
android:defaultValue="#ffbebebe"
android:key="statusbar_clock_color"
android:summary="Color of the clock in the statusbar"
android:title="Clock color" />
</PreferenceScreen>
<PreferenceScreen
android:key="battery"
Expand Down Expand Up @@ -83,7 +90,7 @@
android:key="volume_keys_skip_track_screenon"
android:summaryOff="The previous option is only active when the screen is turned off"
android:summaryOn="The previous option is active independently from the screen state"
android:title="... also when screen is turned on" />
android:title="... also when screen is turned on" />
-->
</PreferenceScreen>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@
import android.app.AndroidAppHelper;
import android.content.SharedPreferences;
import android.content.res.XResources;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.drawable.ColorDrawable;
import android.telephony.SignalStrength;
import android.view.WindowManager;
import android.widget.TextView;
import de.robv.android.xposed.Callback;
import de.robv.android.xposed.XposedBridge;


public class XposedTweakbox {
public static final String MY_PACKAGE_NAME = "de.robv.android.xposed.mods.tweakbox";
public static int signalStrengthBars = 4;
private static int signalStrengthBars = 4;
private static int statusBarClockColor = 0xffbebebe;

public static void init(String startClassName) throws Exception {
if (startClassName != null)
Expand Down Expand Up @@ -71,14 +74,22 @@ private static void handleLoadPackage(String packageName, ClassLoader classLoade
}
}

if (pref.getInt("statusbar_color", 0xdeadbeef) != 0xdeadbeef) {
if (pref.getBoolean("statusbar_color_enabled", false)) {
// http://forum.xda-developers.com/showthread.php?t=1523703
try {
Constructor<?> constructLayoutParams = WindowManager.LayoutParams.class.getDeclaredConstructor(int.class, int.class, int.class, int.class, int.class);
XposedBridge.hookMethod(constructLayoutParams, XposedTweakbox.class, "handleInitLayoutParams", Callback.PRIORITY_HIGHEST);
} catch (Exception e) {
XposedBridge.log(e);
}
} catch (Exception e) { XposedBridge.log(e); }
}

if (pref.getBoolean("statusbar_clock_color_enabled", false)) {
try {
statusBarClockColor = pref.getInt("statusbar_clock_color", 0xffbebebe);
Method updateClock =
Class.forName("com.android.systemui.statusbar.policy.Clock", false, classLoader)
.getDeclaredMethod("updateClock");
XposedBridge.hookMethod(updateClock, XposedTweakbox.class, "handleUpdateClock", Callback.PRIORITY_DEFAULT);
} catch (Exception e) { XposedBridge.log(e); }
}

if (pref.getInt("num_signal_bars", 4) > 4) {
Expand All @@ -88,9 +99,7 @@ private static void handleLoadPackage(String packageName, ClassLoader classLoade

Method methodGsmGetLevel = SignalStrength.class.getDeclaredMethod("getGsmLevel");
XposedBridge.hookMethod(methodGsmGetLevel, XposedTweakbox.class, "handleSignalStrengthGetGsmLevel", Callback.PRIORITY_DEFAULT);
} catch (Exception e) {
XposedBridge.log(e);
}
} catch (Exception e) { XposedBridge.log(e); }
}
}
}
Expand All @@ -106,9 +115,9 @@ private static void handleInitPackageResources(String packageName, XResources re
signalStrengthBars);
} catch (Exception e) { XposedBridge.log(e); }

int statusbarColor = pref.getInt("statusbar_color", 0xdeadbeef);
if (statusbarColor != 0xdeadbeef) {
if (pref.getBoolean("statusbar_color_enabled", false)) {
try {
int statusbarColor = pref.getInt("statusbar_color", Color.BLACK);
res.setReplacement("com.android.systemui", "drawable", "status_bar_background", new ColorDrawable(statusbarColor));
} catch (Exception e) { XposedBridge.log(e); }
}
Expand Down Expand Up @@ -185,4 +194,12 @@ private static Object handleSignalStrengthGetGsmLevel(Iterator<Callback> iterato
else return 10001;
}
}

@SuppressWarnings("unused")
private static Object handleUpdateClock(Iterator<Callback> iterator, Method method, Object thisObject, Object[] args) throws Throwable {
Object result = XposedBridge.callNext(iterator, method, thisObject, args);
TextView clock = (TextView) thisObject;
clock.setTextColor(statusBarClockColor);
return result;
}
}
1 change: 1 addition & 0 deletions externals/colorpicker
Submodule colorpicker added at f2cd67

0 comments on commit 201f32d

Please sign in to comment.