Skip to content

Commit 28e242b

Browse files
committed
toggle night mode and dnd
1 parent fa09253 commit 28e242b

File tree

8 files changed

+53
-7
lines changed

8 files changed

+53
-7
lines changed

.idea/deploymentTargetDropDown.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/migrations.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def sFile = file(keystoreProperties['storeFile'])
88
def sPassword = keystoreProperties['storePassword']
99
def kAlias = keystoreProperties['keyAlias']
1010
def kPassword = keystoreProperties['keyPassword']
11-
def lastVersion = 66
12-
def lastVersionName = "23.11.26"
11+
def lastVersion = 67
12+
def lastVersionName = "23.12.18"
1313

1414
if (gradle.startParameter.taskNames.contains(":app:assembleDevelop")) {
1515
lastVersion += 1

app/src/main/java/name/monwf/customiuizer/mods/GlobalActions.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.app.ActivityOptions;
1313
import android.app.Instrumentation;
1414
import android.app.NotificationManager;
15+
import android.app.UiModeManager;
1516
import android.bluetooth.BluetoothAdapter;
1617
import android.content.BroadcastReceiver;
1718
import android.content.ComponentName;
@@ -394,6 +395,22 @@ public void run() {
394395
Toast.makeText(context, modRes.getString(R.string.toggle_hotspot_on), Toast.LENGTH_SHORT).show();
395396
XposedHelpers.callMethod(mHotspotController, "setHotspotEnabled", !mHotspotEnabled);
396397
}
398+
else if (action.equals(ACTION_PREFIX + "ToggleZenMode")) {
399+
Object zenModeController = XposedHelpers.callStaticMethod(findClass("com.android.systemui.Dependency", context.getClassLoader()), "get", findClassIfExists("com.android.systemui.statusbar.policy.ZenModeController", context.getClassLoader()));
400+
boolean zenModeEnabled = (boolean)XposedHelpers.callMethod(zenModeController, "isZenModeOn");
401+
if (zenModeEnabled) {
402+
XposedHelpers.callMethod(zenModeController, "setZen", 0, null, "DNDTile");
403+
}
404+
else {
405+
XposedHelpers.callMethod(zenModeController, "setZen", 1, null, "DNDTile");
406+
}
407+
}
408+
else if (action.equals(ACTION_PREFIX + "ToggleNightMode")) {
409+
Settings.System.putInt(context.getContentResolver(), "dark_mode_enable_by_setting", 1);
410+
UiModeManager mUiModeManager = (UiModeManager) context.getSystemService("uimode");
411+
boolean nightMode = mUiModeManager.getNightMode() == 2;
412+
XposedHelpers.callMethod(mUiModeManager, "setNightModeActivated", !nightMode);
413+
}
397414

398415
if (action.equals(ACTION_PREFIX + "ToggleFlashlight")) {
399416
XposedHelpers.callStaticMethod(findClass("com.miui.systemui.util.CommonUtil", context.getClassLoader()), "toggleTorch");
@@ -851,7 +868,9 @@ protected void after(final AfterHookCallback param) throws Throwable {
851868

852869
intentfilter.addAction(ACTION_PREFIX + "ToggleGPS");
853870
intentfilter.addAction(ACTION_PREFIX + "ToggleHotspot");
871+
intentfilter.addAction(ACTION_PREFIX + "ToggleZenMode");
854872
intentfilter.addAction(ACTION_PREFIX + "ToggleFlashlight");
873+
intentfilter.addAction(ACTION_PREFIX + "ToggleNightMode");
855874

856875
intentfilter.addAction(ACTION_PREFIX + "ClearMemory");
857876
intentfilter.addAction(ACTION_PREFIX + "ClearNotifications");
@@ -974,6 +993,8 @@ public static boolean toggleThis(Context context, int what) {
974993
case 8: whatStr = "Flashlight"; break;
975994
case 9: whatStr = "MobileData"; break;
976995
case 10: whatStr = "Hotspot"; break;
996+
case 11: whatStr = "ZenMode";break;
997+
case 12: whatStr = "NightMode";break;
977998
default: return false;
978999
}
9791000
context.sendBroadcast(new Intent(ACTION_PREFIX + "Toggle" + whatStr));

app/src/main/res/values/arrays.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,14 @@
233233
<item>@string/array_global_actions_launch</item>
234234
<item>@string/array_global_actions_shortcut</item>
235235
<item>@string/array_global_actions_activity</item>
236+
<item>@string/array_global_actions_toggle</item>
236237
</string-array>
237238
<integer-array name="global_launch_actions_val">
238239
<item>1</item>
239240
<item>8</item>
240241
<item>9</item>
241242
<item>20</item>
243+
<item>10</item>
242244
</integer-array>
243245

244246
<string-array name="global_toggles">
@@ -252,6 +254,8 @@
252254
<item>@string/array_global_toggle_torch</item>
253255
<item>@string/array_global_toggle_mobiledata</item>
254256
<item>@string/system_statusbaricons_hotspot_title</item>
257+
<item>@string/system_statusbaricons_dnd_title</item>
258+
<item>@string/various_calluibright_night_title</item>
255259
</string-array>
256260
<integer-array name="global_toggles_val">
257261
<item>1</item>
@@ -264,6 +268,8 @@
264268
<item>8</item>
265269
<item>9</item>
266270
<item>10</item>
271+
<item>11</item>
272+
<item>12</item>
267273
</integer-array>
268274

269275
<string-array name="appsort">

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
google()
99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:8.1.4'
11+
classpath 'com.android.tools.build:gradle:8.2.0'
1212
}
1313
}
1414

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Sat Feb 12 19:15:23 YEKT 2022
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)