mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-06-12 05:07:45 +02:00
chore: Separate extensions by app (#3905)
This commit is contained in:
3
extensions/tudortmund/build.gradle.kts
Normal file
3
extensions/tudortmund/build.gradle.kts
Normal file
@ -0,0 +1,3 @@
|
||||
dependencies {
|
||||
compileOnly(libs.appcompat)
|
||||
}
|
1
extensions/tudortmund/src/main/AndroidManifest.xml
Normal file
1
extensions/tudortmund/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1 @@
|
||||
<manifest/>
|
@ -0,0 +1,46 @@
|
||||
package app.revanced.extension.tudortmund.lockscreen;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.os.Build;
|
||||
import android.view.Display;
|
||||
import android.view.Window;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
|
||||
|
||||
public class ShowOnLockscreenPatch {
|
||||
/**
|
||||
* @noinspection deprecation
|
||||
*/
|
||||
public static Window getWindow(AppCompatActivity activity, float brightness) {
|
||||
Window window = activity.getWindow();
|
||||
|
||||
if (brightness >= 0) {
|
||||
// High brightness set, therefore show on lockscreen.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) activity.setShowWhenLocked(true);
|
||||
else window.addFlags(FLAG_SHOW_WHEN_LOCKED | FLAG_DISMISS_KEYGUARD);
|
||||
} else {
|
||||
// Ignore brightness reset when the screen is turned off.
|
||||
DisplayManager displayManager = (DisplayManager) activity.getSystemService(Context.DISPLAY_SERVICE);
|
||||
|
||||
boolean isScreenOn = false;
|
||||
for (Display display : displayManager.getDisplays()) {
|
||||
if (display.getState() == Display.STATE_OFF) continue;
|
||||
|
||||
isScreenOn = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (isScreenOn) {
|
||||
// Hide on lockscreen.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) activity.setShowWhenLocked(false);
|
||||
else window.clearFlags(FLAG_SHOW_WHEN_LOCKED | FLAG_DISMISS_KEYGUARD);
|
||||
}
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user