Skip to content

Commit

Permalink
CHANGELOG: Added Notification Transparency
Browse files Browse the repository at this point in the history
  • Loading branch information
DHD2280 committed May 17, 2024
1 parent 52a18bb commit 99283bc
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ public static class LockscreenClock {
}

public static class StatusbarNotificationPrefs {
public static final String NOTIF_TRANSPARENCY = "statusbar_notification_transparency";
public static final String NOTIF_TRANSPARENCY_VALUE = "statusbar_notification_transparency_value";
public static final String CUSTOMIZE_CLEAR_BUTTON = "customizeClearButton";
public static final String CLEAR_BUTTON_BG_LINK_ACCENT = "linkBackgroundAccent";
public static final String CLEAR_BUTTON_BG_COLOR = "clearButtonBgColor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.StatusbarNotificationPrefs.CLEAR_BUTTON_ICON_COLOR;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.StatusbarNotificationPrefs.CLEAR_BUTTON_ICON_LINK_ACCENT;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.StatusbarNotificationPrefs.CUSTOMIZE_CLEAR_BUTTON;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.StatusbarNotificationPrefs.NOTIF_TRANSPARENCY_VALUE;

import android.annotation.SuppressLint;
import android.content.Context;
Expand Down Expand Up @@ -188,6 +189,9 @@ public static boolean isVisible(String key) {
}

// Notification
case "statusbar_notification_transparency_value" -> {
return instance.mPreferences.getBoolean("statusbar_notification_transparency", false);
}
case CLEAR_BUTTON_BG_LINK_ACCENT,
CLEAR_BUTTON_ICON_LINK_ACCENT -> {
return instance.mPreferences.getBoolean(CUSTOMIZE_CLEAR_BUTTON, false);
Expand Down Expand Up @@ -595,6 +599,8 @@ public static String getSummary(Context fragmentCompat, @NonNull String key) {
fragmentCompat.getString(R.string.status_bar_clock_auto_hide_sdur_summary) + "\n" +
instance.mPreferences.getSliderInt("status_bar_clock_auto_hide_sduration", 5) + " " +
fragmentCompat.getString(R.string.seconds);
case NOTIF_TRANSPARENCY_VALUE ->
String.valueOf(instance.mPreferences.getSliderInt(NOTIF_TRANSPARENCY_VALUE, 25));

// Header Clock
case "qs_header_clock_text_scaling" -> instance.mPreferences.getSliderFloat("qs_header_clock_text_scaling", 1.0f) + "%";
Expand Down
14 changes: 13 additions & 1 deletion app/src/main/java/it/dhd/oxygencustomizer/xposed/ModPacks.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
package it.dhd.oxygencustomizer.xposed;

import static de.robv.android.xposed.XposedBridge.hookAllMethods;
import static de.robv.android.xposed.XposedBridge.log;
import static de.robv.android.xposed.XposedHelpers.findClass;
import static it.dhd.oxygencustomizer.utils.Constants.Packages.SYSTEM_UI;

import android.content.Context;

import java.lang.reflect.Method;
import java.util.ArrayList;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import it.dhd.oxygencustomizer.utils.Constants;
import it.dhd.oxygencustomizer.xposed.hooks.HookTester;
import it.dhd.oxygencustomizer.xposed.hooks.framework.Buttons;
Expand All @@ -26,6 +36,7 @@
import it.dhd.oxygencustomizer.xposed.hooks.systemui.statusbar.BatteryStyleManager;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.statusbar.HeaderClock;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.statusbar.HeaderImage;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.statusbar.NotificationTransparency;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.statusbar.QSTiles;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.statusbar.QSTransparency;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.statusbar.QsTileCustomization;
Expand All @@ -48,7 +59,7 @@ public static ArrayList<Class<? extends XposedMods>> getMods(String packageName)
modPacks.add(PhoneWindowManager.class);
modPacks.add(Buttons.class);
}
case Constants.Packages.SYSTEM_UI -> {
case SYSTEM_UI -> {
if (!XPLauncher.isChildProcess) {
// Battery Data Provider
modPacks.add(BatteryDataProvider.class);
Expand All @@ -69,6 +80,7 @@ public static ArrayList<Class<? extends XposedMods>> getMods(String packageName)
modPacks.add(StatusbarClock.class);
modPacks.add(StatusbarIcons.class);
modPacks.add(BatteryStyleManager.class);
modPacks.add(NotificationTransparency.class);
// QS
modPacks.add(QSTransparency.class);
modPacks.add(QSTiles.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package it.dhd.oxygencustomizer.xposed.hooks.systemui.statusbar;

import static de.robv.android.xposed.XposedBridge.hookAllMethods;
import static de.robv.android.xposed.XposedBridge.log;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import static de.robv.android.xposed.XposedHelpers.findClass;
import static de.robv.android.xposed.XposedHelpers.setBooleanField;
import static de.robv.android.xposed.XposedHelpers.setIntField;
import static it.dhd.oxygencustomizer.utils.Constants.Packages.SYSTEM_UI;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.StatusbarNotificationPrefs.NOTIF_TRANSPARENCY;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.StatusbarNotificationPrefs.NOTIF_TRANSPARENCY_VALUE;
import static it.dhd.oxygencustomizer.xposed.XPrefs.Xprefs;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Drawable;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import it.dhd.oxygencustomizer.xposed.XposedMods;

public class NotificationTransparency extends XposedMods {

private final static String listenPackage = SYSTEM_UI;
private final static String TAG = "Oxygen Customizer - Notification Transparency: ";
private boolean notificationTransparency = false;
private int notificationTransparencyValue = 25;

public NotificationTransparency(Context context) {
super(context);
}

@Override
public void updatePrefs(String... Key) {
notificationTransparency = Xprefs.getBoolean(NOTIF_TRANSPARENCY, false);
notificationTransparencyValue = Xprefs.getSliderInt(NOTIF_TRANSPARENCY_VALUE, 25);
}

@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
Class<?> NotificationBackgroundView = findClass("com.android.systemui.statusbar.notification.row.NotificationBackgroundView", lpparam.classLoader);
Class<?> ExpandableNotificationRow = findClass("com.android.systemui.statusbar.notification.row.ExpandableNotificationRow", lpparam.classLoader);

findAndHookMethod(NotificationBackgroundView,
"draw",
Canvas.class,
Drawable.class,
new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Drawable d = (Drawable) param.args[1];
if (d!=null && notificationTransparency) {
d.setAlpha(notificationTransparencyValue);
}
}
});
findAndHookMethod(ExpandableNotificationRow, "updateBackgroundForGroupState", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// blurColor
if (notificationTransparency) {
setBooleanField(param.thisObject, "mShowGroupBackgroundWhenExpanded", true);
}
}
});
}

@Override
public boolean listensTo(String packageName) {
return listenPackage.equals(packageName);
}
}

3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
<string name="status_bar_notification_info_overflow" translatable="false">\u221E</string>
<string name="statusbar_notifications_cat">Statusbar Notifications</string>
<string name="statusbar_use_app_icon">Use app icon for notifications</string>
<string name="statusbar_notifications_transparency">Notifications Transparency</string>
<string name="statusbar_notification_transparency">Notification transparency</string>
<string name="statusbar_notification_transparency_value">Transparency amount</string>
<string name="statusbar_notification_count">Show notification count</string>
<string name="statusbar_notifications_related">Notifications Prefs</string>
<string name="remove_charging_complete_notification_title">Remove charging complete notification</string>
Expand Down
28 changes: 21 additions & 7 deletions app/src/main/res/xml/statusbar_notifications.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:search="http://schemas.android.com/apk/it.dhd.oxygencustomizer.customprefs.preferencesearch">
xmlns:app="http://schemas.android.com/apk/res-auto">
<it.dhd.oxygencustomizer.customprefs.IllustrationPreference
android:key="sb_illustration"
app:lottie_rawRes="@raw/notification_illustration" />
Expand All @@ -23,11 +22,26 @@
android:selectable="false"/>
</PreferenceCategory>

<!--<SwitchPreferenceCompat
android:defaultValue="false"
android:key="statusbar_notification_count"
android:title="@string/statusbar_notification_count"
app:iconSpaceReserved="false"/> -->
<PreferenceCategory
app:iconSpaceReserved="false"
android:title="@string/statusbar_notifications_transparency">

<SwitchPreferenceCompat
android:defaultValue="false"
android:key="statusbar_notification_transparency"
android:title="@string/statusbar_notification_transparency"
android:summaryOn="@string/general_on"
android:summaryOff="@string/general_off"
app:iconSpaceReserved="false"/>

<it.dhd.oxygencustomizer.customprefs.SliderPreference
android:key="statusbar_notification_transparency_value"
android:title="@string/statusbar_notification_transparency_value"
app:defaultValue="25"
app:maxVal="255"
app:minVal="0"/>

</PreferenceCategory>

<PreferenceCategory
app:iconSpaceReserved="false"
Expand Down

0 comments on commit 99283bc

Please sign in to comment.