Commit 45110429 authored by Geoffrey Métais's avatar Geoffrey Métais

Handle auto mode for brightness

Prevents for device on auto brightness mode to get a brutal brightness change
There is no proper solution to get the correct value in this case, so I set the starting level at mid range
parent a8084723
......@@ -86,6 +86,7 @@ import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.text.format.DateFormat;
import android.util.DisplayMetrics;
......@@ -233,6 +234,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
// Brightness
private boolean mIsFirstBrightnessGesture = true;
private float mRestoreAutoBrightness = -1f;
// Tracks & Subtitles
private Map<Integer,String> mAudioTracksList;
......@@ -540,6 +542,20 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
mPresentation.dismiss();
mPresentation = null;
}
restoreBrightness();
}
@TargetApi(android.os.Build.VERSION_CODES.FROYO)
private void restoreBrightness() {
if (mRestoreAutoBrightness != -1f) {
int brightness = (int) (mRestoreAutoBrightness*255f);
Settings.System.putInt(getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS,
brightness);
Settings.System.putInt(getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
}
}
@Override
......@@ -1494,14 +1510,23 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
}
}
@TargetApi(android.os.Build.VERSION_CODES.FROYO)
private void initBrightnessTouch() {
float brightnesstemp = 0.01f;
float brightnesstemp = 0.6f;
// Initialize the layoutParams screen brightness
try {
brightnesstemp = android.provider.Settings.System.getInt(getContentResolver(),
if (LibVlcUtil.isFroyoOrLater() &&
Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
Settings.System.putInt(getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
mRestoreAutoBrightness = android.provider.Settings.System.getInt(getContentResolver(),
android.provider.Settings.System.SCREEN_BRIGHTNESS) / 255.0f;
} else {
brightnesstemp = android.provider.Settings.System.getInt(getContentResolver(),
android.provider.Settings.System.SCREEN_BRIGHTNESS) / 255.0f;
}
} catch (SettingNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
WindowManager.LayoutParams lp = getWindow().getAttributes();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment