prevent screen from fading
This commit is contained in:
parent
2fb20dc2b5
commit
e1b0679263
@ -20,4 +20,7 @@
|
||||
<string name="p_calculations_calculate_on_fly_summary">If turned on calculations are done automatically while typing
|
||||
expression
|
||||
</string>
|
||||
|
||||
<string name="prefs_prevent_screen_from_fading_title">Prevent screen from fading</string>
|
||||
<string name="prefs_prevent_screen_from_fading_summary">If turned on screen will not fade while using the app</string>
|
||||
</resources>
|
@ -59,6 +59,7 @@ public final class CalculatorPreferences {
|
||||
public static final Preference<Boolean> showEqualsButton = BooleanPreference.of("showEqualsButton", true);
|
||||
public static final Preference<Boolean> autoOrientation = BooleanPreference.of("autoOrientation", true);
|
||||
public static final Preference<Boolean> hideNumeralBaseDigits = BooleanPreference.of("hideNumeralBaseDigits", true);
|
||||
public static final Preference<Boolean> 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);
|
||||
|
@ -97,6 +97,11 @@
|
||||
a:title="@string/prefs_history_show_intermediate_calculations_title"
|
||||
a:summary="@string/prefs_history_show_intermediate_calculations_summary" />
|
||||
|
||||
<android.preference.CheckBoxPreference
|
||||
a:key="preventScreenFromFading"
|
||||
a:title="@string/prefs_prevent_screen_from_fading_title"
|
||||
a:summary="@string/prefs_prevent_screen_from_fading_summary" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
</PreferenceScreen>
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user