Skip to content

Commit

Permalink
toggle night mode and dnd
Browse files Browse the repository at this point in the history
  • Loading branch information
MonwF committed Dec 18, 2023
1 parent fa09253 commit 28e242b
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 7 deletions.
10 changes: 10 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def sFile = file(keystoreProperties['storeFile'])
def sPassword = keystoreProperties['storePassword']
def kAlias = keystoreProperties['keyAlias']
def kPassword = keystoreProperties['keyPassword']
def lastVersion = 66
def lastVersionName = "23.11.26"
def lastVersion = 67
def lastVersionName = "23.12.18"

if (gradle.startParameter.taskNames.contains(":app:assembleDevelop")) {
lastVersion += 1
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/name/monwf/customiuizer/mods/GlobalActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.app.ActivityOptions;
import android.app.Instrumentation;
import android.app.NotificationManager;
import android.app.UiModeManager;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
Expand Down Expand Up @@ -394,6 +395,22 @@ public void run() {
Toast.makeText(context, modRes.getString(R.string.toggle_hotspot_on), Toast.LENGTH_SHORT).show();
XposedHelpers.callMethod(mHotspotController, "setHotspotEnabled", !mHotspotEnabled);
}
else if (action.equals(ACTION_PREFIX + "ToggleZenMode")) {
Object zenModeController = XposedHelpers.callStaticMethod(findClass("com.android.systemui.Dependency", context.getClassLoader()), "get", findClassIfExists("com.android.systemui.statusbar.policy.ZenModeController", context.getClassLoader()));
boolean zenModeEnabled = (boolean)XposedHelpers.callMethod(zenModeController, "isZenModeOn");
if (zenModeEnabled) {
XposedHelpers.callMethod(zenModeController, "setZen", 0, null, "DNDTile");
}
else {
XposedHelpers.callMethod(zenModeController, "setZen", 1, null, "DNDTile");
}
}
else if (action.equals(ACTION_PREFIX + "ToggleNightMode")) {
Settings.System.putInt(context.getContentResolver(), "dark_mode_enable_by_setting", 1);
UiModeManager mUiModeManager = (UiModeManager) context.getSystemService("uimode");
boolean nightMode = mUiModeManager.getNightMode() == 2;
XposedHelpers.callMethod(mUiModeManager, "setNightModeActivated", !nightMode);
}

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

intentfilter.addAction(ACTION_PREFIX + "ToggleGPS");
intentfilter.addAction(ACTION_PREFIX + "ToggleHotspot");
intentfilter.addAction(ACTION_PREFIX + "ToggleZenMode");
intentfilter.addAction(ACTION_PREFIX + "ToggleFlashlight");
intentfilter.addAction(ACTION_PREFIX + "ToggleNightMode");

intentfilter.addAction(ACTION_PREFIX + "ClearMemory");
intentfilter.addAction(ACTION_PREFIX + "ClearNotifications");
Expand Down Expand Up @@ -974,6 +993,8 @@ public static boolean toggleThis(Context context, int what) {
case 8: whatStr = "Flashlight"; break;
case 9: whatStr = "MobileData"; break;
case 10: whatStr = "Hotspot"; break;
case 11: whatStr = "ZenMode";break;
case 12: whatStr = "NightMode";break;
default: return false;
}
context.sendBroadcast(new Intent(ACTION_PREFIX + "Toggle" + whatStr));
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,14 @@
<item>@string/array_global_actions_launch</item>
<item>@string/array_global_actions_shortcut</item>
<item>@string/array_global_actions_activity</item>
<item>@string/array_global_actions_toggle</item>
</string-array>
<integer-array name="global_launch_actions_val">
<item>1</item>
<item>8</item>
<item>9</item>
<item>20</item>
<item>10</item>
</integer-array>

<string-array name="global_toggles">
Expand All @@ -252,6 +254,8 @@
<item>@string/array_global_toggle_torch</item>
<item>@string/array_global_toggle_mobiledata</item>
<item>@string/system_statusbaricons_hotspot_title</item>
<item>@string/system_statusbaricons_dnd_title</item>
<item>@string/various_calluibright_night_title</item>
</string-array>
<integer-array name="global_toggles_val">
<item>1</item>
Expand All @@ -264,6 +268,8 @@
<item>8</item>
<item>9</item>
<item>10</item>
<item>11</item>
<item>12</item>
</integer-array>

<string-array name="appsort">
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.4'
classpath 'com.android.tools.build:gradle:8.2.0'
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Feb 12 19:15:23 YEKT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit 28e242b

Please sign in to comment.