Added Keep screen on function

This commit is contained in:
Ziver Koc 2014-08-08 16:40:55 +02:00
parent a031b1c2d9
commit 313056da11
3 changed files with 17 additions and 2 deletions

View file

@ -13,6 +13,7 @@ import android.preference.PreferenceManager;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.WindowManager;
import android.widget.Toast;
import com.ericsson.uecontrol.R;
@ -187,11 +188,17 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
}
private void updateExecutionState(){
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if(action_execute != null) {
if (currentExecutor.isRunning())
if (currentExecutor.isRunning()) {
action_execute.setTitle(R.string.action_stop);
else
if(prefs.getBoolean("screen_on", false))
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
else {
action_execute.setTitle(R.string.action_run);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
}

View file

@ -29,5 +29,7 @@
<string name="pref_debug">Debug Logging</string>
<string name="pref_debug_summ">Enable application debug logging</string>
<string name="action_reset">Reset</string>
<string name="pref_screen_on_summ">Keep screen on while execution</string>
<string name="pref_screen_on">Keep Screen On</string>
</resources>

View file

@ -14,6 +14,12 @@
android:title="@string/pref_logging_path"
android:summary="@string/pref_logging_path_summ"
android:defaultValue="/sdcard/uecontrol/" />
<CheckBoxPreference
android:key="screen_on"
android:title="@string/pref_screen_on"
android:summary="@string/pref_screen_on_summ"
android:defaultValue="false" />
</PreferenceCategory>
<PreferenceCategory