1
0
mirror of https://github.com/danog/termux-api.git synced 2024-11-30 04:19:20 +01:00

add brightness mode (#234)

This commit is contained in:
饺子w 2019-01-25 08:08:40 +08:00 committed by Fredrik Fornwall
parent 3bfb11fe0f
commit 3cf36400e2

View File

@ -11,6 +11,10 @@ public class BrightnessAPI {
public static void onReceive(final TermuxApiReceiver receiver, final Context context, final Intent intent) { public static void onReceive(final TermuxApiReceiver receiver, final Context context, final Intent intent) {
final ContentResolver contentResolver = context.getContentResolver(); final ContentResolver contentResolver = context.getContentResolver();
if (intent.hasExtra("auto")) {
boolean auto = intent.getBooleanExtra("auto", false);
Settings.System.putInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS_MODE, auto?Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC:Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
}
int brightness = intent.getIntExtra("brightness", 0); int brightness = intent.getIntExtra("brightness", 0);
@ -19,7 +23,6 @@ public class BrightnessAPI {
} else if (brightness >= 255) { } else if (brightness >= 255) {
brightness = 255; brightness = 255;
} }
Settings.System.putInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS, brightness); Settings.System.putInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS, brightness);
ResultReturner.noteDone(receiver, intent); ResultReturner.noteDone(receiver, intent);
} }