diff --git a/android-app-core/res/values/text_preferences.xml b/android-app-core/res/values/text_preferences.xml
index fc811068..1f6fb1e7 100644
--- a/android-app-core/res/values/text_preferences.xml
+++ b/android-app-core/res/values/text_preferences.xml
@@ -20,4 +20,7 @@
If turned on calculations are done automatically while typing
expression
+
+ Prevent screen from fading
+ If turned on screen will not fade while using the app
\ No newline at end of file
diff --git a/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorPreferences.java b/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorPreferences.java
index 715a364d..c6635de5 100644
--- a/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorPreferences.java
+++ b/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorPreferences.java
@@ -59,6 +59,7 @@ public final class CalculatorPreferences {
public static final Preference showEqualsButton = BooleanPreference.of("showEqualsButton", true);
public static final Preference autoOrientation = BooleanPreference.of("autoOrientation", true);
public static final Preference hideNumeralBaseDigits = BooleanPreference.of("hideNumeralBaseDigits", true);
+ public static final Preference preventScreenFromFading = BooleanPreference.of("preventScreenFromFading", true);
@Nonnull
public static Theme getTheme(@Nonnull SharedPreferences preferences) {
@@ -196,6 +197,7 @@ public final class CalculatorPreferences {
applyDefaultPreference(preferences, Gui.showEqualsButton);
applyDefaultPreference(preferences, Gui.autoOrientation);
applyDefaultPreference(preferences, Gui.hideNumeralBaseDigits);
+ applyDefaultPreference(preferences, Gui.preventScreenFromFading);
applyDefaultPreference(preferences, Graph.plotImag);
applyDefaultPreference(preferences, History.showIntermediateCalculations);
diff --git a/android-app/res/xml/preferences_appearance.xml b/android-app/res/xml/preferences_appearance.xml
index 814619a6..edc8ae7e 100644
--- a/android-app/res/xml/preferences_appearance.xml
+++ b/android-app/res/xml/preferences_appearance.xml
@@ -97,6 +97,11 @@
a:title="@string/prefs_history_show_intermediate_calculations_title"
a:summary="@string/prefs_history_show_intermediate_calculations_summary" />
+
+
\ No newline at end of file
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
index c71dae83..7d8e9d7a 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
@@ -20,6 +20,8 @@ import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewConfiguration;
+import android.view.Window;
+import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
@@ -41,6 +43,8 @@ import javax.annotation.Nullable;
import static android.os.Build.VERSION_CODES.GINGERBREAD_MR1;
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
+import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
+import static org.solovyev.android.calculator.CalculatorPreferences.Gui.preventScreenFromFading;
import static org.solovyev.android.calculator.wizard.Wizard.FIRST_TIME_WIZARD;
import static org.solovyev.android.calculator.wizard.Wizard.isWizardFinished;
import static org.solovyev.android.calculator.wizard.Wizard.isWizardStarted;
@@ -222,6 +226,13 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
Activities.restartActivity(this);
}
+ final Window window = getWindow();
+ if (preventScreenFromFading.getPreference(preferences)) {
+ window.addFlags(FLAG_KEEP_SCREEN_ON);
+ } else {
+ window.clearFlags(FLAG_KEEP_SCREEN_ON);
+ }
+
this.activityHelper.onResume(this);
}